oh-my-ag 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/skills/frontend-agent/resources/component-template.tsx +20 -19
- package/.agent/skills/orchestrator/scripts/parallel-run.sh +1 -1
- package/.agent/skills/workflow-guide/SKILL.md +12 -2
- package/.agent/skills/workflow-guide/resources/examples.md +8 -5
- package/README.ko.md +42 -21
- package/README.md +40 -20
- package/bin/cli.js +148 -143
- package/package.json +7 -2
- package/.agent/skills/orchestrator/scripts/spawn-agent.sh +0 -263
package/bin/cli.js
CHANGED
|
@@ -1,34 +1,152 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
3
|
-
`).replace(/^/gm," ".repeat(2))}let
|
|
4
|
-
`)}padWidth($,
|
|
2
|
+
import{createRequire as X5}from"node:module";var N5=Object.create;var{getPrototypeOf:G5,defineProperty:s2,getOwnPropertyNames:Z5}=Object;var z5=Object.prototype.hasOwnProperty;var k=($,J,N)=>{N=$!=null?N5(G5($)):{};let G=J||!$||!$.__esModule?s2(N,"default",{value:$,enumerable:!0}):N;for(let Z of Z5($))if(!z5.call(G,Z))s2(G,Z,{get:()=>$[Z],enumerable:!0});return G};var u=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var f=X5(import.meta.url);var N0=u((Q5)=>{class _$ extends Error{constructor($,J,N){super(N);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=J,this.exitCode=$,this.nestedError=void 0}}class o2 extends _${constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}Q5.CommanderError=_$;Q5.InvalidArgumentError=o2});var W0=u((j5)=>{var{InvalidArgumentError:Y5}=N0();class r2{constructor($,J){switch(this.description=J||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(J,N)=>{if(!this.argChoices.includes(J))throw new Y5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,N);return J},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function K5($){let J=$.name()+($.variadic===!0?"...":"");return $.required?"<"+J+">":"["+J+"]"}j5.Argument=r2;j5.humanReadableArgName=K5});var C$=u((q5)=>{var{humanReadableArgName:R5}=W0();class a2{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let J=$.commands.filter((G)=>!G._hidden),N=$._getHelpCommand();if(N&&!N._hidden)J.push(N);if(this.sortSubcommands)J.sort((G,Z)=>{return G.name().localeCompare(Z.name())});return J}compareOptions($,J){let N=(G)=>{return G.short?G.short.replace(/^-/,""):G.long.replace(/^--/,"")};return N($).localeCompare(N(J))}visibleOptions($){let J=$.options.filter((G)=>!G.hidden),N=$._getHelpOption();if(N&&!N.hidden){let G=N.short&&$._findOption(N.short),Z=N.long&&$._findOption(N.long);if(!G&&!Z)J.push(N);else if(N.long&&!Z)J.push($.createOption(N.long,N.description));else if(N.short&&!G)J.push($.createOption(N.short,N.description))}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let J=[];for(let N=$.parent;N;N=N.parent){let G=N.options.filter((Z)=>!Z.hidden);J.push(...G)}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((J)=>{J.description=J.description||$._argsDescription[J.name()]||""});if($.registeredArguments.find((J)=>J.description))return $.registeredArguments;return[]}subcommandTerm($){let J=$.registeredArguments.map((N)=>R5(N)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(J?" "+J:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,J){return J.visibleCommands($).reduce((N,G)=>{return Math.max(N,J.subcommandTerm(G).length)},0)}longestOptionTermLength($,J){return J.visibleOptions($).reduce((N,G)=>{return Math.max(N,J.optionTerm(G).length)},0)}longestGlobalOptionTermLength($,J){return J.visibleGlobalOptions($).reduce((N,G)=>{return Math.max(N,J.optionTerm(G).length)},0)}longestArgumentTermLength($,J){return J.visibleArguments($).reduce((N,G)=>{return Math.max(N,J.argumentTerm(G).length)},0)}commandUsage($){let J=$._name;if($._aliases[0])J=J+"|"+$._aliases[0];let N="";for(let G=$.parent;G;G=G.parent)N=G.name()+" "+N;return N+J+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)J.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)J.push(`env: ${$.envVar}`);if(J.length>0)return`${$.description} (${J.join(", ")})`;return $.description}argumentDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0)J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(J.length>0){let N=`(${J.join(", ")})`;if($.description)return`${$.description} ${N}`;return N}return $.description}formatHelp($,J){let N=J.padWidth($,J),G=J.helpWidth||80,Z=2,z=2;function X(R,x){if(x){let j=`${R.padEnd(N+2)}${x}`;return J.wrap(j,G-2,N+2)}return R}function Q(R){return R.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(2))}let M=[`Usage: ${J.commandUsage($)}`,""],I=J.commandDescription($);if(I.length>0)M=M.concat([J.wrap(I,G,0),""]);let K=J.visibleArguments($).map((R)=>{return X(J.argumentTerm(R),J.argumentDescription(R))});if(K.length>0)M=M.concat(["Arguments:",Q(K),""]);let Y=J.visibleOptions($).map((R)=>{return X(J.optionTerm(R),J.optionDescription(R))});if(Y.length>0)M=M.concat(["Options:",Q(Y),""]);if(this.showGlobalOptions){let R=J.visibleGlobalOptions($).map((x)=>{return X(J.optionTerm(x),J.optionDescription(x))});if(R.length>0)M=M.concat(["Global Options:",Q(R),""])}let H=J.visibleCommands($).map((R)=>{return X(J.subcommandTerm(R),J.subcommandDescription(R))});if(H.length>0)M=M.concat(["Commands:",Q(H),""]);return M.join(`
|
|
4
|
+
`)}padWidth($,J){return Math.max(J.longestOptionTermLength($,J),J.longestGlobalOptionTermLength($,J),J.longestSubcommandTermLength($,J),J.longestArgumentTermLength($,J))}wrap($,J,N,G=40){let z=new RegExp(`[\\n][${" \\f\\t\\v - \uFEFF"}]+`);if($.match(z))return $;let X=J-N;if(X<G)return $;let Q=$.slice(0,N),M=$.slice(N).replace(`\r
|
|
5
5
|
`,`
|
|
6
|
-
`),
|
|
7
|
-
|.{1,${
|
|
8
|
-
`)return"";return(
|
|
9
|
-
`)}}
|
|
6
|
+
`),I=" ".repeat(N),Y=`\\s${""}`,H=new RegExp(`
|
|
7
|
+
|.{1,${X-1}}([${Y}]|$)|[^${Y}]+?([${Y}]|$)`,"g"),R=M.match(H)||[];return Q+R.map((x,j)=>{if(x===`
|
|
8
|
+
`)return"";return(j>0?I:"")+x.trimEnd()}).join(`
|
|
9
|
+
`)}}q5.Help=a2});var L$=u((_5)=>{var{InvalidArgumentError:B5}=N0();class t2{constructor($,J){this.flags=$,this.description=J||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let N=V5($);if(this.short=N.shortFlag,this.long=N.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}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let J=$;if(typeof $==="string")J={[$]:!0};return this.implied=Object.assign(this.implied||{},J),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(J,N)=>{if(!this.argChoices.includes(J))throw new B5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,N);return J},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return T5(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class e2{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((J)=>{if(J.negate)this.negativeOptions.set(J.attributeName(),J);else this.positiveOptions.set(J.attributeName(),J)}),this.negativeOptions.forEach((J,N)=>{if(this.positiveOptions.has(N))this.dualOptions.add(N)})}valueFromOption($,J){let N=J.attributeName();if(!this.dualOptions.has(N))return!0;let G=this.negativeOptions.get(N).presetArg,Z=G!==void 0?G:!1;return J.negate===(Z===$)}}function T5($){return $.split("-").reduce((J,N)=>{return J+N[0].toUpperCase()+N.slice(1)})}function V5($){let J,N,G=$.split(/[ |,]+/);if(G.length>1&&!/^[[<]/.test(G[1]))J=G.shift();if(N=G.shift(),!J&&/^-[^-]$/.test(N))J=N,N=void 0;return{shortFlag:J,longFlag:N}}_5.Option=t2;_5.DualOptions=e2});var $4=u((P5)=>{function A5($,J){if(Math.abs($.length-J.length)>3)return Math.max($.length,J.length);let N=[];for(let G=0;G<=$.length;G++)N[G]=[G];for(let G=0;G<=J.length;G++)N[0][G]=G;for(let G=1;G<=J.length;G++)for(let Z=1;Z<=$.length;Z++){let z=1;if($[Z-1]===J[G-1])z=0;else z=1;if(N[Z][G]=Math.min(N[Z-1][G]+1,N[Z][G-1]+1,N[Z-1][G-1]+z),Z>1&&G>1&&$[Z-1]===J[G-2]&&$[Z-2]===J[G-1])N[Z][G]=Math.min(N[Z][G],N[Z-2][G-2]+1)}return N[$.length][J.length]}function D5($,J){if(!J||J.length===0)return"";J=Array.from(new Set(J));let N=$.startsWith("--");if(N)$=$.slice(2),J=J.map((X)=>X.slice(2));let G=[],Z=3,z=0.4;if(J.forEach((X)=>{if(X.length<=1)return;let Q=A5($,X),M=Math.max($.length,X.length);if((M-Q)/M>z){if(Q<Z)Z=Q,G=[X];else if(Q===Z)G.push(X)}}),G.sort((X,Q)=>X.localeCompare(Q)),N)G=G.map((X)=>`--${X}`);if(G.length>1)return`
|
|
10
10
|
(Did you mean one of ${G.join(", ")}?)`;if(G.length===1)return`
|
|
11
|
-
(Did you mean ${G[0]}?)`;return""}
|
|
12
|
-
- specify the name in Command constructor or using .name()`);if(
|
|
13
|
-
Expecting one of '${N.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(
|
|
14
|
-
- already used by option '${
|
|
11
|
+
(Did you mean ${G[0]}?)`;return""}P5.suggestSimilar=D5});var Z4=u((y5)=>{var W5=f("node:events").EventEmitter,A$=f("node:child_process"),T1=f("node:path"),D$=f("node:fs"),b=f("node:process"),{Argument:F5,humanReadableArgName:O5}=W0(),{CommanderError:P$}=N0(),{Help:g5}=C$(),{Option:J4,DualOptions:f5}=L$(),{suggestSimilar:N4}=$4();class S$ extends W5{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",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._outputConfiguration={writeOut:(J)=>b.stdout.write(J),writeErr:(J)=>b.stderr.write(J),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,outputError:(J,N)=>N(J)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let J=this;J;J=J.parent)$.push(J);return $}command($,J,N){let G=J,Z=N;if(typeof G==="object"&&G!==null)Z=G,G=null;Z=Z||{};let[,z,X]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(z);if(G)Q.description(G),Q._executableHandler=!0;if(Z.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(Z.noHelp||Z.hidden),Q._executableFile=Z.executableFile||null,X)Q.arguments(X);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),G)return this;return Q}createCommand($){return new S$($)}createHelp(){return Object.assign(new g5,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,J){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
12
|
+
- specify the name in Command constructor or using .name()`);if(J=J||{},J.isDefault)this._defaultCommandName=$._name;if(J.noHelp||J.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,J){return new F5($,J)}argument($,J,N,G){let Z=this.createArgument($,J);if(typeof N==="function")Z.default(G).argParser(N);else Z.default(N);return this.addArgument(Z),this}arguments($){return $.trim().split(/ +/).forEach((J)=>{this.argument(J)}),this}addArgument($){let J=this.registeredArguments.slice(-1)[0];if(J&&J.variadic)throw Error(`only the last argument can be variadic '${J.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,J){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,N,G]=$.match(/([^ ]+) *(.*)/),Z=J??"display help for command",z=this.createCommand(N);if(z.helpOption(!1),G)z.arguments(G);if(Z)z.description(Z);return this._addImplicitHelpCommand=!0,this._helpCommand=z,this}addHelpCommand($,J){if(typeof $!=="object")return this.helpCommand($,J),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,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($,J){let N=["preSubcommand","preAction","postAction"];if(!N.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
13
|
+
Expecting one of '${N.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(J);else this._lifeCycleHooks[$]=[J];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(J)=>{if(J.code!=="commander.executeSubCommandAsync")throw J};return this}_exit($,J,N){if(this._exitCallback)this._exitCallback(new P$($,J,N));b.exit($)}action($){let J=(N)=>{let G=this.registeredArguments.length,Z=N.slice(0,G);if(this._storeOptionsAsProperties)Z[G]=this;else Z[G]=this.opts();return Z.push(this),$.apply(this,Z)};return this._actionHandler=J,this}createOption($,J){return new J4($,J)}_callParseArg($,J,N,G){try{return $.parseArg(J,N)}catch(Z){if(Z.code==="commander.invalidArgument"){let z=`${G} ${Z.message}`;this.error(z,{exitCode:Z.exitCode,code:Z.code})}throw Z}}_registerOption($){let J=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(J){let N=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${N}'
|
|
14
|
+
- already used by option '${J.flags}'`)}this.options.push($)}_registerCommand($){let J=(G)=>{return[G.name()].concat(G.aliases())},N=J($).find((G)=>this._findCommand(G));if(N){let G=J(this._findCommand(N)).join("|"),Z=J($).join("|");throw Error(`cannot add command '${Z}' as already have command '${G}'`)}this.commands.push($)}addOption($){this._registerOption($);let J=$.name(),N=$.attributeName();if($.negate){let Z=$.long.replace(/^--no-/,"--");if(!this._findOption(Z))this.setOptionValueWithSource(N,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(N,$.defaultValue,"default");let G=(Z,z,X)=>{if(Z==null&&$.presetArg!==void 0)Z=$.presetArg;let Q=this.getOptionValue(N);if(Z!==null&&$.parseArg)Z=this._callParseArg($,Z,Q,z);else if(Z!==null&&$.variadic)Z=$._concatValue(Z,Q);if(Z==null)if($.negate)Z=!1;else if($.isBoolean()||$.optional)Z=!0;else Z="";this.setOptionValueWithSource(N,Z,X)};if(this.on("option:"+J,(Z)=>{let z=`error: option '${$.flags}' argument '${Z}' is invalid.`;G(Z,z,"cli")}),$.envVar)this.on("optionEnv:"+J,(Z)=>{let z=`error: option '${$.flags}' value '${Z}' from env '${$.envVar}' is invalid.`;G(Z,z,"env")});return this}_optionEx($,J,N,G,Z){if(typeof J==="object"&&J instanceof J4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let z=this.createOption(J,N);if(z.makeOptionMandatory(!!$.mandatory),typeof G==="function")z.default(Z).argParser(G);else if(G instanceof RegExp){let X=G;G=(Q,M)=>{let I=X.exec(Q);return I?I[0]:M},z.default(Z).argParser(G)}else z.default(G);return this.addOption(z)}option($,J,N,G){return this._optionEx({},$,J,N,G)}requiredOption($,J,N,G){return this._optionEx({mandatory:!0},$,J,N,G)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,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($=!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=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,J){return this.setOptionValueWithSource($,J,void 0)}setOptionValueWithSource($,J,N){if(this._storeOptionsAsProperties)this[$]=J;else this._optionValues[$]=J;return this._optionValueSources[$]=N,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let J;return this._getCommandAndAncestors().forEach((N)=>{if(N.getOptionValueSource($)!==void 0)J=N.getOptionValueSource($)}),J}_prepareUserArgs($,J){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(J=J||{},$===void 0&&J.from===void 0){if(b.versions?.electron)J.from="electron";let G=b.execArgv??[];if(G.includes("-e")||G.includes("--eval")||G.includes("-p")||G.includes("--print"))J.from="eval"}if($===void 0)$=b.argv;this.rawArgs=$.slice();let N;switch(J.from){case void 0:case"node":this._scriptPath=$[1],N=$.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=$[1],N=$.slice(2);else N=$.slice(1);break;case"user":N=$.slice(0);break;case"eval":N=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${J.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",N}parse($,J){let N=this._prepareUserArgs($,J);return this._parseCommand([],N),this}async parseAsync($,J){let N=this._prepareUserArgs($,J);return await this._parseCommand([],N),this}_executeSubCommand($,J){J=J.slice();let N=!1,G=[".js",".ts",".tsx",".mjs",".cjs"];function Z(I,K){let Y=T1.resolve(I,K);if(D$.existsSync(Y))return Y;if(G.includes(T1.extname(K)))return;let H=G.find((R)=>D$.existsSync(`${Y}${R}`));if(H)return`${Y}${H}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=$._executableFile||`${this._name}-${$._name}`,X=this._executableDir||"";if(this._scriptPath){let I;try{I=D$.realpathSync(this._scriptPath)}catch(K){I=this._scriptPath}X=T1.resolve(T1.dirname(I),X)}if(X){let I=Z(X,z);if(!I&&!$._executableFile&&this._scriptPath){let K=T1.basename(this._scriptPath,T1.extname(this._scriptPath));if(K!==this._name)I=Z(X,`${K}-${$._name}`)}z=I||z}N=G.includes(T1.extname(z));let Q;if(b.platform!=="win32")if(N)J.unshift(z),J=G4(b.execArgv).concat(J),Q=A$.spawn(b.argv[0],J,{stdio:"inherit"});else Q=A$.spawn(z,J,{stdio:"inherit"});else J.unshift(z),J=G4(b.execArgv).concat(J),Q=A$.spawn(b.execPath,J,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((K)=>{b.on(K,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(K)})});let M=this._exitCallback;Q.on("close",(I)=>{if(I=I??1,!M)b.exit(I);else M(new P$(I,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(I)=>{if(I.code==="ENOENT"){let K=X?`searched for local subcommand relative to directory '${X}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",Y=`'${z}' does not exist
|
|
15
15
|
- if '${$._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
|
-
- ${
|
|
17
|
+
- ${K}`;throw Error(Y)}else if(I.code==="EACCES")throw Error(`'${z}' not executable`);if(!M)b.exit(1);else{let K=new P$(1,"commander.executeSubCommandAsync","(error)");K.nestedError=I,M(K)}}),this.runningCommand=Q}_dispatchSubcommand($,J,N){let G=this._findCommand($);if(!G)this.help({error:!0});let Z;return Z=this._chainOrCallSubCommandHook(Z,G,"preSubcommand"),Z=this._chainOrCall(Z,()=>{if(G._executableHandler)this._executeSubCommand(G,J.concat(N));else return G._parseCommand(J,N)}),Z}_dispatchHelpCommand($){if(!$)this.help();let J=this._findCommand($);if(J&&!J._executableHandler)J.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,J)=>{if($.required&&this.args[J]==null)this.missingArgument($.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 $=(N,G,Z)=>{let z=G;if(G!==null&&N.parseArg){let X=`error: command-argument value '${G}' is invalid for argument '${N.name()}'.`;z=this._callParseArg(N,G,Z,X)}return z};this._checkNumberOfArguments();let J=[];this.registeredArguments.forEach((N,G)=>{let Z=N.defaultValue;if(N.variadic){if(G<this.args.length){if(Z=this.args.slice(G),N.parseArg)Z=Z.reduce((z,X)=>{return $(N,X,z)},N.defaultValue)}else if(Z===void 0)Z=[]}else if(G<this.args.length){if(Z=this.args[G],N.parseArg)Z=$(N,Z,N.defaultValue)}J[G]=Z}),this.processedArgs=J}_chainOrCall($,J){if($&&$.then&&typeof $.then==="function")return $.then(()=>J());return J()}_chainOrCallHooks($,J){let N=$,G=[];if(this._getCommandAndAncestors().reverse().filter((Z)=>Z._lifeCycleHooks[J]!==void 0).forEach((Z)=>{Z._lifeCycleHooks[J].forEach((z)=>{G.push({hookedCommand:Z,callback:z})})}),J==="postAction")G.reverse();return G.forEach((Z)=>{N=this._chainOrCall(N,()=>{return Z.callback(Z.hookedCommand,this)})}),N}_chainOrCallSubCommandHook($,J,N){let G=$;if(this._lifeCycleHooks[N]!==void 0)this._lifeCycleHooks[N].forEach((Z)=>{G=this._chainOrCall(G,()=>{return Z(this,J)})});return G}_parseCommand($,J){let N=this.parseOptions(J);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(N.operands),J=N.unknown,this.args=$.concat(J),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),J);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(J),this._dispatchSubcommand(this._defaultCommandName,$,J);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(N.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=()=>{if(N.unknown.length>0)this.unknownOption(N.unknown[0])},Z=`command:${this.name()}`;if(this._actionHandler){G(),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(Z,$,J)});return z=this._chainOrCallHooks(z,"postAction"),z}if(this.parent&&this.parent.listenerCount(Z))G(),this._processArguments(),this.parent.emit(Z,$,J);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,J);if(this.listenerCount("command:*"))this.emit("command:*",$,J);else if(this.commands.length)this.unknownCommand();else G(),this._processArguments()}else if(this.commands.length)G(),this.help({error:!0});else G(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((J)=>J._name===$||J._aliases.includes($))}_findOption($){return this.options.find((J)=>J.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((J)=>{if(J.mandatory&&$.getOptionValue(J.attributeName())===void 0)$.missingMandatoryOptionValue(J)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((N)=>{let G=N.attributeName();if(this.getOptionValue(G)===void 0)return!1;return this.getOptionValueSource(G)!=="default"});$.filter((N)=>N.conflictsWith.length>0).forEach((N)=>{let G=$.find((Z)=>N.conflictsWith.includes(Z.attributeName()));if(G)this._conflictingOption(N,G)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let J=[],N=[],G=J,Z=$.slice();function z(Q){return Q.length>1&&Q[0]==="-"}let X=null;while(Z.length){let Q=Z.shift();if(Q==="--"){if(G===N)G.push(Q);G.push(...Z);break}if(X&&!z(Q)){this.emit(`option:${X.name()}`,Q);continue}if(X=null,z(Q)){let M=this._findOption(Q);if(M){if(M.required){let I=Z.shift();if(I===void 0)this.optionMissingArgument(M);this.emit(`option:${M.name()}`,I)}else if(M.optional){let I=null;if(Z.length>0&&!z(Z[0]))I=Z.shift();this.emit(`option:${M.name()}`,I)}else this.emit(`option:${M.name()}`);X=M.variadic?M:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let M=this._findOption(`-${Q[1]}`);if(M){if(M.required||M.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${M.name()}`,Q.slice(2));else this.emit(`option:${M.name()}`),Z.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let M=Q.indexOf("="),I=this._findOption(Q.slice(0,M));if(I&&(I.required||I.optional)){this.emit(`option:${I.name()}`,Q.slice(M+1));continue}}if(z(Q))G=N;if((this._enablePositionalOptions||this._passThroughOptions)&&J.length===0&&N.length===0){if(this._findCommand(Q)){if(J.push(Q),Z.length>0)N.push(...Z);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(J.push(Q),Z.length>0)J.push(...Z);break}else if(this._defaultCommandName){if(N.push(Q),Z.length>0)N.push(...Z);break}}if(this._passThroughOptions){if(G.push(Q),Z.length>0)G.push(...Z);break}G.push(Q)}return{operands:J,unknown:N}}opts(){if(this._storeOptionsAsProperties){let $={},J=this.options.length;for(let N=0;N<J;N++){let G=this.options[N].attributeName();$[G]=G===this._versionOptionName?this._version:this[G]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,J)=>Object.assign($,J.opts()),{})}error($,J){if(this._outputConfiguration.outputError(`${$}
|
|
18
18
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
19
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
20
|
-
`),this.outputHelp({error:!0});let N=
|
|
21
|
-
`),this._exit(0,"commander.version",$)}),this}description($,
|
|
22
|
-
Expecting one of '${N.join("', '")}'`);let G=`${$}Help`;return this.on(G,(
|
|
23
|
-
`)}),this}_outputHelpIfRequested($){let I=this._getHelpOption();if(I&&$.find((G)=>I.is(G)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function o2($){return $.map((I)=>{if(!I.startsWith("--inspect"))return I;let N,G="127.0.0.1",J="9229",Z;if((Z=I.match(/^(--inspect(-brk)?)$/))!==null)N=Z[1];else if((Z=I.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(N=Z[1],/^\d+$/.test(Z[3]))J=Z[3];else G=Z[3];else if((Z=I.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)N=Z[1],G=Z[3],J=Z[4];if(N&&J!=="0")return`${N}=${G}:${parseInt(J)+1}`;return I})}q5.Command=L$});var $4=v((L5)=>{var{Argument:a2}=B0(),{Command:D$}=r2(),{CommanderError:B5,InvalidArgumentError:t2}=a1(),{Help:g5}=U$(),{Option:e2}=q$();L5.program=new D$;L5.createCommand=($)=>new D$($);L5.createOption=($,I)=>new e2($,I);L5.createArgument=($,I)=>new a2($,I);L5.Command=D$;L5.Option=e2;L5.Argument=a2;L5.Help=g5;L5.CommanderError=B5;L5.InvalidArgumentError=t2;L5.InvalidOptionArgumentError=t2});var H1=v((V7,P4)=>{var f4=["nodebuffer","arraybuffer","fragments"],A4=typeof Blob<"u";if(A4)f4.push("blob");P4.exports={BINARY_TYPES:f4,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:A4,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var $0=v((f7,P0)=>{var{EMPTY_BUFFER:f6}=H1(),E$=Buffer[Symbol.species];function A6($,I){if($.length===0)return f6;if($.length===1)return $[0];let N=Buffer.allocUnsafe(I),G=0;for(let J=0;J<$.length;J++){let Z=$[J];N.set(Z,G),G+=Z.length}if(G<I)return new E$(N.buffer,N.byteOffset,G);return N}function F4($,I,N,G,J){for(let Z=0;Z<J;Z++)N[G+Z]=$[Z]^I[Z&3]}function W4($,I){for(let N=0;N<$.length;N++)$[N]^=I[N&3]}function P6($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function l$($){if(l$.readOnly=!0,Buffer.isBuffer($))return $;let I;if($ instanceof ArrayBuffer)I=new E$($);else if(ArrayBuffer.isView($))I=new E$($.buffer,$.byteOffset,$.byteLength);else I=Buffer.from($),l$.readOnly=!1;return I}P0.exports={concat:A6,mask:F4,toArrayBuffer:P6,toBuffer:l$,unmask:W4};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();P0.exports.mask=function(I,N,G,J,Z){if(Z<48)F4(I,N,G,J,Z);else $.mask(I,N,G,J,Z)},P0.exports.unmask=function(I,N){if(I.length<32)W4(I,N);else $.unmask(I,N)}}catch($){}});var l4=v((A7,E4)=>{var O4=Symbol("kDone"),u$=Symbol("kRun");class y4{constructor($){this[O4]=()=>{this.pending--,this[u$]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[u$]()}[u$](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[O4])}}}E4.exports=y4});var N0=v((P7,m4)=>{var I0=O("zlib"),u4=$0(),F6=l4(),{kStatusCode:v4}=H1(),W6=Buffer[Symbol.species],O6=Buffer.from([0,0,255,255]),W0=Symbol("permessage-deflate"),T1=Symbol("total-length"),b1=Symbol("callback"),B1=Symbol("buffers"),m1=Symbol("error"),F0;class w4{constructor($,I,N){if(this._maxPayload=N|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!I,this._deflate=null,this._inflate=null,this.params=null,!F0){let G=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;F0=new F6(G)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[b1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let I=this._options,N=$.find((G)=>{if(I.serverNoContextTakeover===!1&&G.server_no_context_takeover||G.server_max_window_bits&&(I.serverMaxWindowBits===!1||typeof I.serverMaxWindowBits==="number"&&I.serverMaxWindowBits>G.server_max_window_bits)||typeof I.clientMaxWindowBits==="number"&&!G.client_max_window_bits)return!1;return!0});if(!N)throw Error("None of the extension offers can be accepted");if(I.serverNoContextTakeover)N.server_no_context_takeover=!0;if(I.clientNoContextTakeover)N.client_no_context_takeover=!0;if(typeof I.serverMaxWindowBits==="number")N.server_max_window_bits=I.serverMaxWindowBits;if(typeof I.clientMaxWindowBits==="number")N.client_max_window_bits=I.clientMaxWindowBits;else if(N.client_max_window_bits===!0||I.clientMaxWindowBits===!1)delete N.client_max_window_bits;return N}acceptAsClient($){let I=$[0];if(this._options.clientNoContextTakeover===!1&&I.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!I.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")I.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&I.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return I}normalizeParams($){return $.forEach((I)=>{Object.keys(I).forEach((N)=>{let G=I[N];if(G.length>1)throw Error(`Parameter "${N}" must have only a single value`);if(G=G[0],N==="client_max_window_bits"){if(G!==!0){let J=+G;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=J}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else if(N==="server_max_window_bits"){let J=+G;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=J}else if(N==="client_no_context_takeover"||N==="server_no_context_takeover"){if(G!==!0)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else throw Error(`Unknown parameter "${N}"`);I[N]=G})}),$}decompress($,I,N){F0.add((G)=>{this._decompress($,I,(J,Z)=>{G(),N(J,Z)})})}compress($,I,N){F0.add((G)=>{this._compress($,I,(J,Z)=>{G(),N(J,Z)})})}_decompress($,I,N){let G=this._isServer?"client":"server";if(!this._inflate){let J=`${G}_max_window_bits`,Z=typeof this.params[J]!=="number"?I0.Z_DEFAULT_WINDOWBITS:this.params[J];this._inflate=I0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Z}),this._inflate[W0]=this,this._inflate[T1]=0,this._inflate[B1]=[],this._inflate.on("error",E6),this._inflate.on("data",b4)}if(this._inflate[b1]=N,this._inflate.write($),I)this._inflate.write(O6);this._inflate.flush(()=>{let J=this._inflate[m1];if(J){this._inflate.close(),this._inflate=null,N(J);return}let Z=u4.concat(this._inflate[B1],this._inflate[T1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[T1]=0,this._inflate[B1]=[],I&&this.params[`${G}_no_context_takeover`])this._inflate.reset();N(null,Z)})}_compress($,I,N){let G=this._isServer?"server":"client";if(!this._deflate){let J=`${G}_max_window_bits`,Z=typeof this.params[J]!=="number"?I0.Z_DEFAULT_WINDOWBITS:this.params[J];this._deflate=I0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Z}),this._deflate[T1]=0,this._deflate[B1]=[],this._deflate.on("data",y6)}this._deflate[b1]=N,this._deflate.write($),this._deflate.flush(I0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let J=u4.concat(this._deflate[B1],this._deflate[T1]);if(I)J=new W6(J.buffer,J.byteOffset,J.length-4);if(this._deflate[b1]=null,this._deflate[T1]=0,this._deflate[B1]=[],I&&this.params[`${G}_no_context_takeover`])this._deflate.reset();N(null,J)})}}m4.exports=w4;function y6($){this[B1].push($),this[T1]+=$.length}function b4($){if(this[T1]+=$.length,this[W0]._maxPayload<1||this[T1]<=this[W0]._maxPayload){this[B1].push($);return}this[m1]=RangeError("Max payload size exceeded"),this[m1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[m1][v4]=1009,this.removeListener("data",b4),this.reset()}function E6($){if(this[W0]._inflate=null,this[m1]){this[b1](this[m1]);return}$[v4]=1007,this[b1]($)}});var i1=v((F7,O0)=>{var{isUtf8:i4}=O("buffer"),{hasBlob:l6}=H1(),u6=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function v6($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function v$($){let I=$.length,N=0;while(N<I)if(($[N]&128)===0)N++;else if(($[N]&224)===192){if(N+1===I||($[N+1]&192)!==128||($[N]&254)===192)return!1;N+=2}else if(($[N]&240)===224){if(N+2>=I||($[N+1]&192)!==128||($[N+2]&192)!==128||$[N]===224&&($[N+1]&224)===128||$[N]===237&&($[N+1]&224)===160)return!1;N+=3}else if(($[N]&248)===240){if(N+3>=I||($[N+1]&192)!==128||($[N+2]&192)!==128||($[N+3]&192)!==128||$[N]===240&&($[N+1]&240)===128||$[N]===244&&$[N+1]>143||$[N]>244)return!1;N+=4}else return!1;return!0}function w6($){return l6&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}O0.exports={isBlob:w6,isValidStatusCode:v6,isValidUTF8:v$,tokenChars:u6};if(i4)O0.exports.isValidUTF8=function($){return $.length<24?v$($):i4($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();O0.exports.isValidUTF8=function(I){return I.length<32?v$(I):$(I)}}catch($){}});var b$=v((W7,d4)=>{var{Writable:b6}=O("stream"),k4=N0(),{BINARY_TYPES:m6,EMPTY_BUFFER:h4,kStatusCode:i6,kWebSocket:k6}=H1(),{concat:w$,toArrayBuffer:h6,unmask:n6}=$0(),{isValidStatusCode:c6,isValidUTF8:n4}=i1(),y0=Buffer[Symbol.species];class c4 extends b6{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||m6[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[k6]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,I,N){if(this._opcode===8&&this._state==0)return N();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(N)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let N=this._buffers[0];return this._buffers[0]=new y0(N.buffer,N.byteOffset+$,N.length-$),new y0(N.buffer,N.byteOffset,$)}let I=Buffer.allocUnsafe($);do{let N=this._buffers[0],G=I.length-$;if($>=N.length)I.set(this._buffers.shift(),G);else I.set(new Uint8Array(N.buffer,N.byteOffset,$),G),this._buffers[0]=new y0(N.buffer,N.byteOffset+$,N.length-$);$-=N.length}while($>0);return I}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let I=this.consume(2);if((I[0]&48)!==0){let G=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(G);return}let N=(I[0]&64)===64;if(N&&!this._extensions[k4.extensionName]){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._fin=(I[0]&128)===128,this._opcode=I[0]&15,this._payloadLength=I[1]&127,this._opcode===0){if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(!this._fragmented){let G=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._compressed=N}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let G=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(G);return}if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let G=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(G);return}}else{let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(I[1]&128)===128,this._isServer){if(!this._masked){let G=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(G);return}}else if(this._masked){let G=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(G);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let I=this.consume(8),N=I.readUInt32BE(0);if(N>Math.pow(2,21)-1){let G=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(G);return}this._payloadLength=N*Math.pow(2,32)+I.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let I=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(I);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let I=h4;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(I=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)n6(I,this._mask)}if(this._opcode>7){this.controlMessage(I,$);return}if(this._compressed){this._state=5,this.decompress(I,$);return}if(I.length)this._messageLength=this._totalPayloadLength,this._fragments.push(I);this.dataMessage($)}decompress($,I){this._extensions[k4.extensionName].decompress($,this._fin,(G,J)=>{if(G)return I(G);if(J.length){if(this._messageLength+=J.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");I(Z);return}this._fragments.push(J)}if(this.dataMessage(I),this._state===0)this.startLoop(I)})}dataMessage($){if(!this._fin){this._state=0;return}let I=this._messageLength,N=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let G;if(this._binaryType==="nodebuffer")G=w$(N,I);else if(this._binaryType==="arraybuffer")G=h6(w$(N,I));else if(this._binaryType==="blob")G=new Blob(N);else G=N;if(this._allowSynchronousEvents)this.emit("message",G,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!0),this._state=0,this.startLoop($)})}else{let G=w$(N,I);if(!this._skipUTF8Validation&&!n4(G)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(J);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",G,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!1),this._state=0,this.startLoop($)})}}controlMessage($,I){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,h4),this.end();else{let N=$.readUInt16BE(0);if(!c6(N)){let J=this.createError(RangeError,`invalid status code ${N}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");I(J);return}let G=new y0($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!n4(G)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");I(J);return}this._loop=!1,this.emit("conclude",N,G),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(I)})}createError($,I,N,G,J){this._loop=!1,this._errored=!0;let Z=new $(N?`Invalid WebSocket frame: ${I}`:I);return Error.captureStackTrace(Z,this.createError),Z.code=J,Z[i6]=G,Z}}d4.exports=c4});var i$=v((y7,o4)=>{var{Duplex:O7}=O("stream"),{randomFillSync:d6}=O("crypto"),p4=N0(),{EMPTY_BUFFER:p6,kWebSocket:s6,NOOP:o6}=H1(),{isBlob:k1,isValidStatusCode:r6}=i1(),{mask:s4,toBuffer:F1}=$0(),I1=Symbol("kByteLength"),a6=Buffer.alloc(4),W1,h1=8192,Z1=0,t6=1,e6=2;class g1{constructor($,I,N){if(this._extensions=I||{},N)this._generateMask=N,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Z1,this.onerror=o6,this[s6]=void 0}static frame($,I){let N,G=!1,J=2,Z=!1;if(I.mask){if(N=I.maskBuffer||a6,I.generateMask)I.generateMask(N);else{if(h1===8192){if(W1===void 0)W1=Buffer.alloc(8192);d6(W1,0,8192),h1=0}N[0]=W1[h1++],N[1]=W1[h1++],N[2]=W1[h1++],N[3]=W1[h1++]}Z=(N[0]|N[1]|N[2]|N[3])===0,J=6}let z;if(typeof $==="string")if((!I.mask||Z)&&I[I1]!==void 0)z=I[I1];else $=Buffer.from($),z=$.length;else z=$.length,G=I.mask&&I.readOnly&&!Z;let x=z;if(z>=65536)J+=8,x=127;else if(z>125)J+=2,x=126;let Q=Buffer.allocUnsafe(G?z+J:J);if(Q[0]=I.fin?I.opcode|128:I.opcode,I.rsv1)Q[0]|=64;if(Q[1]=x,x===126)Q.writeUInt16BE(z,2);else if(x===127)Q[2]=Q[3]=0,Q.writeUIntBE(z,4,6);if(!I.mask)return[Q,$];if(Q[1]|=128,Q[J-4]=N[0],Q[J-3]=N[1],Q[J-2]=N[2],Q[J-1]=N[3],Z)return[Q,$];if(G)return s4($,N,Q,J,z),[Q];return s4($,N,$,0,z),[Q,$]}close($,I,N,G){let J;if($===void 0)J=p6;else if(typeof $!=="number"||!r6($))throw TypeError("First argument must be a valid error code number");else if(I===void 0||!I.length)J=Buffer.allocUnsafe(2),J.writeUInt16BE($,0);else{let z=Buffer.byteLength(I);if(z>123)throw RangeError("The message must not be greater than 123 bytes");if(J=Buffer.allocUnsafe(2+z),J.writeUInt16BE($,0),typeof I==="string")J.write(I,2);else J.set(I,2)}let Z={[I1]:J.length,fin:!0,generateMask:this._generateMask,mask:N,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==Z1)this.enqueue([this.dispatch,J,!1,Z,G]);else this.sendFrame(g1.frame(J,Z),G)}ping($,I,N){let G,J;if(typeof $==="string")G=Buffer.byteLength($),J=!1;else if(k1($))G=$.size,J=!1;else $=F1($),G=$.length,J=F1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let Z={[I1]:G,fin:!0,generateMask:this._generateMask,mask:I,maskBuffer:this._maskBuffer,opcode:9,readOnly:J,rsv1:!1};if(k1($))if(this._state!==Z1)this.enqueue([this.getBlobData,$,!1,Z,N]);else this.getBlobData($,!1,Z,N);else if(this._state!==Z1)this.enqueue([this.dispatch,$,!1,Z,N]);else this.sendFrame(g1.frame($,Z),N)}pong($,I,N){let G,J;if(typeof $==="string")G=Buffer.byteLength($),J=!1;else if(k1($))G=$.size,J=!1;else $=F1($),G=$.length,J=F1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let Z={[I1]:G,fin:!0,generateMask:this._generateMask,mask:I,maskBuffer:this._maskBuffer,opcode:10,readOnly:J,rsv1:!1};if(k1($))if(this._state!==Z1)this.enqueue([this.getBlobData,$,!1,Z,N]);else this.getBlobData($,!1,Z,N);else if(this._state!==Z1)this.enqueue([this.dispatch,$,!1,Z,N]);else this.sendFrame(g1.frame($,Z),N)}send($,I,N){let G=this._extensions[p4.extensionName],J=I.binary?2:1,Z=I.compress,z,x;if(typeof $==="string")z=Buffer.byteLength($),x=!1;else if(k1($))z=$.size,x=!1;else $=F1($),z=$.length,x=F1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Z&&G&&G.params[G._isServer?"server_no_context_takeover":"client_no_context_takeover"])Z=z>=G._threshold;this._compress=Z}else Z=!1,J=0;if(I.fin)this._firstFragment=!0;let Q={[I1]:z,fin:I.fin,generateMask:this._generateMask,mask:I.mask,maskBuffer:this._maskBuffer,opcode:J,readOnly:x,rsv1:Z};if(k1($))if(this._state!==Z1)this.enqueue([this.getBlobData,$,this._compress,Q,N]);else this.getBlobData($,this._compress,Q,N);else if(this._state!==Z1)this.enqueue([this.dispatch,$,this._compress,Q,N]);else this.dispatch($,this._compress,Q,N)}getBlobData($,I,N,G){this._bufferedBytes+=N[I1],this._state=e6,$.arrayBuffer().then((J)=>{if(this._socket.destroyed){let z=Error("The socket was closed while the blob was being read");process.nextTick(m$,this,z,G);return}this._bufferedBytes-=N[I1];let Z=F1(J);if(!I)this._state=Z1,this.sendFrame(g1.frame(Z,N),G),this.dequeue();else this.dispatch(Z,I,N,G)}).catch((J)=>{process.nextTick($9,this,J,G)})}dispatch($,I,N,G){if(!I){this.sendFrame(g1.frame($,N),G);return}let J=this._extensions[p4.extensionName];this._bufferedBytes+=N[I1],this._state=t6,J.compress($,N.fin,(Z,z)=>{if(this._socket.destroyed){let x=Error("The socket was closed while data was being compressed");m$(this,x,G);return}this._bufferedBytes-=N[I1],this._state=Z1,N.readOnly=!1,this.sendFrame(g1.frame(z,N),G),this.dequeue()})}dequeue(){while(this._state===Z1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][I1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][I1],this._queue.push($)}sendFrame($,I){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],I),this._socket.uncork();else this._socket.write($[0],I)}}o4.exports=g1;function m$($,I,N){if(typeof N==="function")N(I);for(let G=0;G<$._queue.length;G++){let J=$._queue[G],Z=J[J.length-1];if(typeof Z==="function")Z(I)}}function $9($,I,N){m$($,I,N),$.onerror(I)}});var J8=v((E7,G8)=>{var{kForOnEventAttribute:G0,kListener:k$}=H1(),r4=Symbol("kCode"),a4=Symbol("kData"),t4=Symbol("kError"),e4=Symbol("kMessage"),$8=Symbol("kReason"),n1=Symbol("kTarget"),I8=Symbol("kType"),N8=Symbol("kWasClean");class L1{constructor($){this[n1]=null,this[I8]=$}get target(){return this[n1]}get type(){return this[I8]}}Object.defineProperty(L1.prototype,"target",{enumerable:!0});Object.defineProperty(L1.prototype,"type",{enumerable:!0});class c1 extends L1{constructor($,I={}){super($);this[r4]=I.code===void 0?0:I.code,this[$8]=I.reason===void 0?"":I.reason,this[N8]=I.wasClean===void 0?!1:I.wasClean}get code(){return this[r4]}get reason(){return this[$8]}get wasClean(){return this[N8]}}Object.defineProperty(c1.prototype,"code",{enumerable:!0});Object.defineProperty(c1.prototype,"reason",{enumerable:!0});Object.defineProperty(c1.prototype,"wasClean",{enumerable:!0});class J0 extends L1{constructor($,I={}){super($);this[t4]=I.error===void 0?null:I.error,this[e4]=I.message===void 0?"":I.message}get error(){return this[t4]}get message(){return this[e4]}}Object.defineProperty(J0.prototype,"error",{enumerable:!0});Object.defineProperty(J0.prototype,"message",{enumerable:!0});class l0 extends L1{constructor($,I={}){super($);this[a4]=I.data===void 0?null:I.data}get data(){return this[a4]}}Object.defineProperty(l0.prototype,"data",{enumerable:!0});var I9={addEventListener($,I,N={}){for(let J of this.listeners($))if(!N[G0]&&J[k$]===I&&!J[G0])return;let G;if($==="message")G=function(Z,z){let x=new l0("message",{data:z?Z:Z.toString()});x[n1]=this,E0(I,this,x)};else if($==="close")G=function(Z,z){let x=new c1("close",{code:Z,reason:z.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});x[n1]=this,E0(I,this,x)};else if($==="error")G=function(Z){let z=new J0("error",{error:Z,message:Z.message});z[n1]=this,E0(I,this,z)};else if($==="open")G=function(){let Z=new L1("open");Z[n1]=this,E0(I,this,Z)};else return;if(G[G0]=!!N[G0],G[k$]=I,N.once)this.once($,G);else this.on($,G)},removeEventListener($,I){for(let N of this.listeners($))if(N[k$]===I&&!N[G0]){this.removeListener($,N);break}}};G8.exports={CloseEvent:c1,ErrorEvent:J0,Event:L1,EventTarget:I9,MessageEvent:l0};function E0($,I,N){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,N);else $.call(I,N)}});var h$=v((l7,Z8)=>{var{tokenChars:Z0}=i1();function j1($,I,N){if($[I]===void 0)$[I]=[N];else $[I].push(N)}function N9($){let I=Object.create(null),N=Object.create(null),G=!1,J=!1,Z=!1,z,x,Q=-1,X=-1,j=-1,M=0;for(;M<$.length;M++)if(X=$.charCodeAt(M),z===void 0)if(j===-1&&Z0[X]===1){if(Q===-1)Q=M}else if(M!==0&&(X===32||X===9)){if(j===-1&&Q!==-1)j=M}else if(X===59||X===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${M}`);if(j===-1)j=M;let S=$.slice(Q,j);if(X===44)j1(I,S,N),N=Object.create(null);else z=S;Q=j=-1}else throw SyntaxError(`Unexpected character at index ${M}`);else if(x===void 0)if(j===-1&&Z0[X]===1){if(Q===-1)Q=M}else if(X===32||X===9){if(j===-1&&Q!==-1)j=M}else if(X===59||X===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${M}`);if(j===-1)j=M;if(j1(N,$.slice(Q,j),!0),X===44)j1(I,z,N),N=Object.create(null),z=void 0;Q=j=-1}else if(X===61&&Q!==-1&&j===-1)x=$.slice(Q,M),Q=j=-1;else throw SyntaxError(`Unexpected character at index ${M}`);else if(J){if(Z0[X]!==1)throw SyntaxError(`Unexpected character at index ${M}`);if(Q===-1)Q=M;else if(!G)G=!0;J=!1}else if(Z)if(Z0[X]===1){if(Q===-1)Q=M}else if(X===34&&Q!==-1)Z=!1,j=M;else if(X===92)J=!0;else throw SyntaxError(`Unexpected character at index ${M}`);else if(X===34&&$.charCodeAt(M-1)===61)Z=!0;else if(j===-1&&Z0[X]===1){if(Q===-1)Q=M}else if(Q!==-1&&(X===32||X===9)){if(j===-1)j=M}else if(X===59||X===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${M}`);if(j===-1)j=M;let S=$.slice(Q,j);if(G)S=S.replace(/\\/g,""),G=!1;if(j1(N,x,S),X===44)j1(I,z,N),N=Object.create(null),z=void 0;x=void 0,Q=j=-1}else throw SyntaxError(`Unexpected character at index ${M}`);if(Q===-1||Z||X===32||X===9)throw SyntaxError("Unexpected end of input");if(j===-1)j=M;let R=$.slice(Q,j);if(z===void 0)j1(I,R,N);else{if(x===void 0)j1(N,R,!0);else if(G)j1(N,x,R.replace(/\\/g,""));else j1(N,x,R);j1(I,z,N)}return I}function G9($){return Object.keys($).map((I)=>{let N=$[I];if(!Array.isArray(N))N=[N];return N.map((G)=>{return[I].concat(Object.keys(G).map((J)=>{let Z=G[J];if(!Array.isArray(Z))Z=[Z];return Z.map((z)=>z===!0?J:`${J}=${z}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}Z8.exports={format:G9,parse:N9}});var b0=v((w7,T8)=>{var J9=O("events"),Z9=O("https"),x9=O("http"),Q8=O("net"),z9=O("tls"),{randomBytes:Q9,createHash:X9}=O("crypto"),{Duplex:u7,Readable:v7}=O("stream"),{URL:n$}=O("url"),D1=N0(),M9=b$(),j9=i$(),{isBlob:K9}=i1(),{BINARY_TYPES:x8,CLOSE_TIMEOUT:Y9,EMPTY_BUFFER:u0,GUID:R9,kForOnEventAttribute:c$,kListener:S9,kStatusCode:H9,kWebSocket:k,NOOP:X8}=H1(),{EventTarget:{addEventListener:T9,removeEventListener:U9}}=J8(),{format:q9,parse:C9}=h$(),{toBuffer:B9}=$0(),M8=Symbol("kAborted"),d$=[8,13],U1=["CONNECTING","OPEN","CLOSING","CLOSED"],g9=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class D extends J9{constructor($,I,N){super();if(this._binaryType=x8[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=u0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=D.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,I===void 0)I=[];else if(!Array.isArray(I))if(typeof I==="object"&&I!==null)N=I,I=[];else I=[I];j8(this,$,I,N)}else this._autoPong=N.autoPong,this._closeTimeout=N.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!x8.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,I,N){let G=new M9({allowSynchronousEvents:N.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:N.maxPayload,skipUTF8Validation:N.skipUTF8Validation}),J=new j9($,this._extensions,N.generateMask);if(this._receiver=G,this._sender=J,this._socket=$,G[k]=this,J[k]=this,$[k]=this,G.on("conclude",_9),G.on("drain",V9),G.on("error",f9),G.on("message",A9),G.on("ping",P9),G.on("pong",F9),J.onerror=W9,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(I.length>0)$.unshift(I);$.on("close",R8),$.on("data",w0),$.on("end",S8),$.on("error",H8),this._readyState=D.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=D.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[D1.extensionName])this._extensions[D1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=D.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,I){if(this.readyState===D.CLOSED)return;if(this.readyState===D.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===D.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=D.CLOSING,this._sender.close($,I,!this._isServer,(N)=>{if(N)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),Y8(this)}pause(){if(this.readyState===D.CONNECTING||this.readyState===D.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,I,N){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=I=void 0;else if(typeof I==="function")N=I,I=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){p$(this,$,N);return}if(I===void 0)I=!this._isServer;this._sender.ping($||u0,I,N)}pong($,I,N){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=I=void 0;else if(typeof I==="function")N=I,I=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){p$(this,$,N);return}if(I===void 0)I=!this._isServer;this._sender.pong($||u0,I,N)}resume(){if(this.readyState===D.CONNECTING||this.readyState===D.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,I,N){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof I==="function")N=I,I={};if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){p$(this,$,N);return}let G={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...I};if(!this._extensions[D1.extensionName])G.compress=!1;this._sender.send($||u0,G,N)}terminate(){if(this.readyState===D.CLOSED)return;if(this.readyState===D.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=D.CLOSING,this._socket.destroy()}}Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:U1.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:U1.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:U1.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:U1.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:U1.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:U1.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:U1.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:U1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(D.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(D.prototype,`on${$}`,{enumerable:!0,get(){for(let I of this.listeners($))if(I[c$])return I[S9];return null},set(I){for(let N of this.listeners($))if(N[c$]){this.removeListener($,N);break}if(typeof I!=="function")return;this.addEventListener($,I,{[c$]:!0})}})});D.prototype.addEventListener=T9;D.prototype.removeEventListener=U9;T8.exports=D;function j8($,I,N,G){let J={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Y9,protocolVersion:d$[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...G,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=J.autoPong,$._closeTimeout=J.closeTimeout,!d$.includes(J.protocolVersion))throw RangeError(`Unsupported protocol version: ${J.protocolVersion} (supported versions: ${d$.join(", ")})`);let Z;if(I instanceof n$)Z=I;else try{Z=new n$(I)}catch(K){throw SyntaxError(`Invalid URL: ${I}`)}if(Z.protocol==="http:")Z.protocol="ws:";else if(Z.protocol==="https:")Z.protocol="wss:";$._url=Z.href;let z=Z.protocol==="wss:",x=Z.protocol==="ws+unix:",Q;if(Z.protocol!=="ws:"&&!z&&!x)Q=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(x&&!Z.pathname)Q="The URL's pathname is empty";else if(Z.hash)Q="The URL contains a fragment identifier";if(Q){let K=SyntaxError(Q);if($._redirects===0)throw K;else{v0($,K);return}}let X=z?443:80,j=Q9(16).toString("base64"),M=z?Z9.request:x9.request,R=new Set,S;if(J.createConnection=J.createConnection||(z?D9:L9),J.defaultPort=J.defaultPort||X,J.port=Z.port||X,J.host=Z.hostname.startsWith("[")?Z.hostname.slice(1,-1):Z.hostname,J.headers={...J.headers,"Sec-WebSocket-Version":J.protocolVersion,"Sec-WebSocket-Key":j,Connection:"Upgrade",Upgrade:"websocket"},J.path=Z.pathname+Z.search,J.timeout=J.handshakeTimeout,J.perMessageDeflate)S=new D1(J.perMessageDeflate!==!0?J.perMessageDeflate:{},!1,J.maxPayload),J.headers["Sec-WebSocket-Extensions"]=q9({[D1.extensionName]:S.offer()});if(N.length){for(let K of N){if(typeof K!=="string"||!g9.test(K)||R.has(K))throw SyntaxError("An invalid or duplicated subprotocol was specified");R.add(K)}J.headers["Sec-WebSocket-Protocol"]=N.join(",")}if(J.origin)if(J.protocolVersion<13)J.headers["Sec-WebSocket-Origin"]=J.origin;else J.headers.Origin=J.origin;if(Z.username||Z.password)J.auth=`${Z.username}:${Z.password}`;if(x){let K=J.path.split(":");J.socketPath=K[0],J.path=K[1]}let Y;if(J.followRedirects){if($._redirects===0){$._originalIpc=x,$._originalSecure=z,$._originalHostOrSocketPath=x?J.socketPath:Z.host;let K=G&&G.headers;if(G={...G,headers:{}},K)for(let[T,C]of Object.entries(K))G.headers[T.toLowerCase()]=C}else if($.listenerCount("redirect")===0){let K=x?$._originalIpc?J.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:Z.host===$._originalHostOrSocketPath;if(!K||$._originalSecure&&!z){if(delete J.headers.authorization,delete J.headers.cookie,!K)delete J.headers.host;J.auth=void 0}}if(J.auth&&!G.headers.authorization)G.headers.authorization="Basic "+Buffer.from(J.auth).toString("base64");if(Y=$._req=M(J),$._redirects)$.emit("redirect",$.url,Y)}else Y=$._req=M(J);if(J.timeout)Y.on("timeout",()=>{r($,Y,"Opening handshake has timed out")});if(Y.on("error",(K)=>{if(Y===null||Y[M8])return;Y=$._req=null,v0($,K)}),Y.on("response",(K)=>{let T=K.headers.location,C=K.statusCode;if(T&&J.followRedirects&&C>=300&&C<400){if(++$._redirects>J.maxRedirects){r($,Y,"Maximum redirects exceeded");return}Y.abort();let U;try{U=new n$(T,I)}catch(B){let _=SyntaxError(`Invalid URL: ${T}`);v0($,_);return}j8($,U,N,G)}else if(!$.emit("unexpected-response",Y,K))r($,Y,`Unexpected server response: ${K.statusCode}`)}),Y.on("upgrade",(K,T,C)=>{if($.emit("upgrade",K),$.readyState!==D.CONNECTING)return;Y=$._req=null;let U=K.headers.upgrade;if(U===void 0||U.toLowerCase()!=="websocket"){r($,T,"Invalid Upgrade header");return}let B=X9("sha1").update(j+R9).digest("base64");if(K.headers["sec-websocket-accept"]!==B){r($,T,"Invalid Sec-WebSocket-Accept header");return}let _=K.headers["sec-websocket-protocol"],L;if(_!==void 0){if(!R.size)L="Server sent a subprotocol but none was requested";else if(!R.has(_))L="Server sent an invalid subprotocol"}else if(R.size)L="Server sent no subprotocol";if(L){r($,T,L);return}if(_)$._protocol=_;let f=K.headers["sec-websocket-extensions"];if(f!==void 0){if(!S){r($,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let q;try{q=C9(f)}catch(b){r($,T,"Invalid Sec-WebSocket-Extensions header");return}let g=Object.keys(q);if(g.length!==1||g[0]!==D1.extensionName){r($,T,"Server indicated an extension that was not requested");return}try{S.accept(q[D1.extensionName])}catch(b){r($,T,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[D1.extensionName]=S}$.setSocket(T,C,{allowSynchronousEvents:J.allowSynchronousEvents,generateMask:J.generateMask,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation})}),J.finishRequest)J.finishRequest(Y,$);else Y.end()}function v0($,I){$._readyState=D.CLOSING,$._errorEmitted=!0,$.emit("error",I),$.emitClose()}function L9($){return $.path=$.socketPath,Q8.connect($)}function D9($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=Q8.isIP($.host)?"":$.host;return z9.connect($)}function r($,I,N){$._readyState=D.CLOSING;let G=Error(N);if(Error.captureStackTrace(G,r),I.setHeader){if(I[M8]=!0,I.abort(),I.socket&&!I.socket.destroyed)I.socket.destroy();process.nextTick(v0,$,G)}else I.destroy(G),I.once("error",$.emit.bind($,"error")),I.once("close",$.emitClose.bind($))}function p$($,I,N){if(I){let G=K9(I)?I.size:B9(I).length;if($._socket)$._sender._bufferedBytes+=G;else $._bufferedAmount+=G}if(N){let G=Error(`WebSocket is not open: readyState ${$.readyState} (${U1[$.readyState]})`);process.nextTick(N,G)}}function _9($,I){let N=this[k];if(N._closeFrameReceived=!0,N._closeMessage=I,N._closeCode=$,N._socket[k]===void 0)return;if(N._socket.removeListener("data",w0),process.nextTick(K8,N._socket),$===1005)N.close();else N.close($,I)}function V9(){let $=this[k];if(!$.isPaused)$._socket.resume()}function f9($){let I=this[k];if(I._socket[k]!==void 0)I._socket.removeListener("data",w0),process.nextTick(K8,I._socket),I.close($[H9]);if(!I._errorEmitted)I._errorEmitted=!0,I.emit("error",$)}function z8(){this[k].emitClose()}function A9($,I){this[k].emit("message",$,I)}function P9($){let I=this[k];if(I._autoPong)I.pong($,!this._isServer,X8);I.emit("ping",$)}function F9($){this[k].emit("pong",$)}function K8($){$.resume()}function W9($){let I=this[k];if(I.readyState===D.CLOSED)return;if(I.readyState===D.OPEN)I._readyState=D.CLOSING,Y8(I);if(this._socket.end(),!I._errorEmitted)I._errorEmitted=!0,I.emit("error",$)}function Y8($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function R8(){let $=this[k];if(this.removeListener("close",R8),this.removeListener("data",w0),this.removeListener("end",S8),$._readyState=D.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let I=this.read(this._readableState.length);$._receiver.write(I)}if($._receiver.end(),this[k]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",z8),$._receiver.on("finish",z8)}function w0($){if(!this[k]._receiver.write($))this.pause()}function S8(){let $=this[k];$._readyState=D.CLOSING,$._receiver.end(),this.end()}function H8(){let $=this[k];if(this.removeListener("error",H8),this.on("error",X8),$)$._readyState=D.CLOSING,this.destroy()}});var B8=v((m7,C8)=>{var b7=b0(),{Duplex:O9}=O("stream");function U8($){$.emit("close")}function y9(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function q8($){if(this.removeListener("error",q8),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function E9($,I){let N=!0,G=new O9({...I,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(Z,z){let x=!z&&G._readableState.objectMode?Z.toString():Z;if(!G.push(x))$.pause()}),$.once("error",function(Z){if(G.destroyed)return;N=!1,G.destroy(Z)}),$.once("close",function(){if(G.destroyed)return;G.push(null)}),G._destroy=function(J,Z){if($.readyState===$.CLOSED){Z(J),process.nextTick(U8,G);return}let z=!1;if($.once("error",function(Q){z=!0,Z(Q)}),$.once("close",function(){if(!z)Z(J);process.nextTick(U8,G)}),N)$.terminate()},G._final=function(J){if($.readyState===$.CONNECTING){$.once("open",function(){G._final(J)});return}if($._socket===null)return;if($._socket._writableState.finished){if(J(),G._readableState.endEmitted)G.destroy()}else $._socket.once("finish",function(){J()}),$.close()},G._read=function(){if($.isPaused)$.resume()},G._write=function(J,Z,z){if($.readyState===$.CONNECTING){$.once("open",function(){G._write(J,Z,z)});return}$.send(J,z)},G.on("end",y9),G.on("error",q8),G}C8.exports=E9});var L8=v((i7,g8)=>{var{tokenChars:l9}=i1();function u9($){let I=new Set,N=-1,G=-1,J=0;for(J;J<$.length;J++){let z=$.charCodeAt(J);if(G===-1&&l9[z]===1){if(N===-1)N=J}else if(J!==0&&(z===32||z===9)){if(G===-1&&N!==-1)G=J}else if(z===44){if(N===-1)throw SyntaxError(`Unexpected character at index ${J}`);if(G===-1)G=J;let x=$.slice(N,G);if(I.has(x))throw SyntaxError(`The "${x}" subprotocol is duplicated`);I.add(x),N=G=-1}else throw SyntaxError(`Unexpected character at index ${J}`)}if(N===-1||G!==-1)throw SyntaxError("Unexpected end of input");let Z=$.slice(N,J);if(I.has(Z))throw SyntaxError(`The "${Z}" subprotocol is duplicated`);return I.add(Z),I}g8.exports={parse:u9}});var A8=v((h7,f8)=>{var v9=O("events"),m0=O("http"),{Duplex:k7}=O("stream"),{createHash:w9}=O("crypto"),D8=h$(),O1=N0(),b9=L8(),m9=b0(),{CLOSE_TIMEOUT:i9,GUID:k9,kWebSocket:h9}=H1(),n9=/^[+/0-9A-Za-z]{22}==$/;class V8 extends v9{constructor($,I){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:i9,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:m9,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=m0.createServer((N,G)=>{let J=m0.STATUS_CODES[426];G.writeHead(426,{"Content-Length":J.length,"Content-Type":"text/plain"}),G.end(J)}),this._server.listen($.port,$.host,$.backlog,I);else if($.server)this._server=$.server;if(this._server){let N=this.emit.bind(this,"connection");this._removeListeners=c9(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(G,J,Z)=>{this.handleUpgrade(G,J,Z,N)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(x0,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(x0,this);else this._shouldEmitClose=!0;else process.nextTick(x0,this)}else{let I=this._server;this._removeListeners(),this._removeListeners=this._server=null,I.close(()=>{x0(this)})}}shouldHandle($){if(this.options.path){let I=$.url.indexOf("?");if((I!==-1?$.url.slice(0,I):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,I,N,G){I.on("error",_8);let J=$.headers["sec-websocket-key"],Z=$.headers.upgrade,z=+$.headers["sec-websocket-version"];if($.method!=="GET"){y1(this,$,I,405,"Invalid HTTP method");return}if(Z===void 0||Z.toLowerCase()!=="websocket"){y1(this,$,I,400,"Invalid Upgrade header");return}if(J===void 0||!n9.test(J)){y1(this,$,I,400,"Missing or invalid Sec-WebSocket-Key header");return}if(z!==13&&z!==8){y1(this,$,I,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){z0(I,400);return}let x=$.headers["sec-websocket-protocol"],Q=new Set;if(x!==void 0)try{Q=b9.parse(x)}catch(M){y1(this,$,I,400,"Invalid Sec-WebSocket-Protocol header");return}let X=$.headers["sec-websocket-extensions"],j={};if(this.options.perMessageDeflate&&X!==void 0){let M=new O1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let R=D8.parse(X);if(R[O1.extensionName])M.accept(R[O1.extensionName]),j[O1.extensionName]=M}catch(R){y1(this,$,I,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let M={origin:$.headers[`${z===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(M,(R,S,Y,K)=>{if(!R)return z0(I,S||401,Y,K);this.completeUpgrade(j,J,Q,$,I,N,G)});return}if(!this.options.verifyClient(M))return z0(I,401)}this.completeUpgrade(j,J,Q,$,I,N,G)}completeUpgrade($,I,N,G,J,Z,z){if(!J.readable||!J.writable)return J.destroy();if(J[h9])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return z0(J,503);let Q=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${w9("sha1").update(I+k9).digest("base64")}`],X=new this.options.WebSocket(null,void 0,this.options);if(N.size){let j=this.options.handleProtocols?this.options.handleProtocols(N,G):N.values().next().value;if(j)Q.push(`Sec-WebSocket-Protocol: ${j}`),X._protocol=j}if($[O1.extensionName]){let j=$[O1.extensionName].params,M=D8.format({[O1.extensionName]:[j]});Q.push(`Sec-WebSocket-Extensions: ${M}`),X._extensions=$}if(this.emit("headers",Q,G),J.write(Q.concat(`\r
|
|
20
|
+
`),this.outputHelp({error:!0});let N=J||{},G=N.exitCode||1,Z=N.code||"commander.error";this._exit(G,Z,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let J=$.attributeName();if(this.getOptionValue(J)===void 0||["default","config","env"].includes(this.getOptionValueSource(J)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new f5(this.options),J=(N)=>{return this.getOptionValue(N)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(N))};this.options.filter((N)=>N.implied!==void 0&&J(N.attributeName())&&$.valueFromOption(this.getOptionValue(N.attributeName()),N)).forEach((N)=>{Object.keys(N.implied).filter((G)=>!J(G)).forEach((G)=>{this.setOptionValueWithSource(G,N.implied[G],"implied")})})}missingArgument($){let J=`error: missing required argument '${$}'`;this.error(J,{code:"commander.missingArgument"})}optionMissingArgument($){let J=`error: option '${$.flags}' argument missing`;this.error(J,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let J=`error: required option '${$.flags}' not specified`;this.error(J,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,J){let N=(z)=>{let X=z.attributeName(),Q=this.getOptionValue(X),M=this.options.find((K)=>K.negate&&X===K.attributeName()),I=this.options.find((K)=>!K.negate&&X===K.attributeName());if(M&&(M.presetArg===void 0&&Q===!1||M.presetArg!==void 0&&Q===M.presetArg))return M;return I||z},G=(z)=>{let X=N(z),Q=X.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},Z=`error: ${G($)} cannot be used with ${G(J)}`;this.error(Z,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let J="";if($.startsWith("--")&&this._showSuggestionAfterError){let G=[],Z=this;do{let z=Z.createHelp().visibleOptions(Z).filter((X)=>X.long).map((X)=>X.long);G=G.concat(z),Z=Z.parent}while(Z&&!Z._enablePositionalOptions);J=N4($,G)}let N=`error: unknown option '${$}'${J}`;this.error(N,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let J=this.registeredArguments.length,N=J===1?"":"s",Z=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${J} argument${N} but got ${$.length}.`;this.error(Z,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],J="";if(this._showSuggestionAfterError){let G=[];this.createHelp().visibleCommands(this).forEach((Z)=>{if(G.push(Z.name()),Z.alias())G.push(Z.alias())}),J=N4($,G)}let N=`error: unknown command '${$}'${J}`;this.error(N,{code:"commander.unknownCommand"})}version($,J,N){if($===void 0)return this._version;this._version=$,J=J||"-V, --version",N=N||"output the version number";let G=this.createOption(J,N);return this._versionOptionName=G.attributeName(),this._registerOption(G),this.on("option:"+G.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
21
|
+
`),this._exit(0,"commander.version",$)}),this}description($,J){if($===void 0&&J===void 0)return this._description;if(this._description=$,J)this._argsDescription=J;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let J=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)J=this.commands[this.commands.length-1];if($===J._name)throw Error("Command alias can't be the same as its name");let N=this.parent?._findCommand($);if(N){let G=[N.name()].concat(N.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${G}'`)}return J._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((J)=>this.alias(J)),this}usage($){if($===void 0){if(this._usage)return this._usage;let J=this.registeredArguments.map((N)=>{return O5(N)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?J:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=T1.basename($,T1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let J=this.createHelp();if(J.helpWidth===void 0)J.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return J.formatHelp(this,J)}_getHelpContext($){$=$||{};let J={error:!!$.error},N;if(J.error)N=(G)=>this._outputConfiguration.writeErr(G);else N=(G)=>this._outputConfiguration.writeOut(G);return J.write=$.write||N,J.command=this,J}outputHelp($){let J;if(typeof $==="function")J=$,$=void 0;let N=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((Z)=>Z.emit("beforeAllHelp",N)),this.emit("beforeHelp",N);let G=this.helpInformation(N);if(J){if(G=J(G),typeof G!=="string"&&!Buffer.isBuffer(G))throw Error("outputHelp callback must return a string or a Buffer")}if(N.write(G),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",N),this._getCommandAndAncestors().forEach((Z)=>Z.emit("afterAllHelp",N))}helpOption($,J){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",J=J??"display help for command",this._helpOption=this.createOption($,J),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let J=b.exitCode||0;if(J===0&&$&&typeof $!=="function"&&$.error)J=1;this._exit(J,"commander.help","(outputHelp)")}addHelpText($,J){let N=["beforeAll","before","after","afterAll"];if(!N.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
22
|
+
Expecting one of '${N.join("', '")}'`);let G=`${$}Help`;return this.on(G,(Z)=>{let z;if(typeof J==="function")z=J({error:Z.error,command:Z.command});else z=J;if(z)Z.write(`${z}
|
|
23
|
+
`)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((G)=>J.is(G)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function G4($){return $.map((J)=>{if(!J.startsWith("--inspect"))return J;let N,G="127.0.0.1",Z="9229",z;if((z=J.match(/^(--inspect(-brk)?)$/))!==null)N=z[1];else if((z=J.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(N=z[1],/^\d+$/.test(z[3]))Z=z[3];else G=z[3];else if((z=J.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)N=z[1],G=z[3],Z=z[4];if(N&&Z!=="0")return`${N}=${G}:${parseInt(Z)+1}`;return J})}y5.Command=S$});var M4=u((u5)=>{var{Argument:z4}=W0(),{Command:W$}=Z4(),{CommanderError:w5,InvalidArgumentError:X4}=N0(),{Help:v5}=C$(),{Option:Q4}=L$();u5.program=new W$;u5.createCommand=($)=>new W$($);u5.createOption=($,J)=>new Q4($,J);u5.createArgument=($,J)=>new z4($,J);u5.Command=W$;u5.Option=Q4;u5.Argument=z4;u5.Help=v5;u5.CommanderError=w5;u5.InvalidArgumentError=X4;u5.InvalidOptionArgumentError=X4});var N1=u((ON,F$)=>{var O0=process||{},K4=O0.argv||[],F0=O0.env||{},o5=!(!!F0.NO_COLOR||K4.includes("--no-color"))&&(!!F0.FORCE_COLOR||K4.includes("--color")||O0.platform==="win32"||(O0.stdout||{}).isTTY&&F0.TERM!=="dumb"||!!F0.CI),r5=($,J,N=$)=>(G)=>{let Z=""+G,z=Z.indexOf(J,$.length);return~z?$+a5(Z,J,N,z)+J:$+Z+J},a5=($,J,N,G)=>{let Z="",z=0;do Z+=$.substring(z,G)+N,z=G+J.length,G=$.indexOf(J,z);while(~G);return Z+$.substring(z)},j4=($=o5)=>{let J=$?r5:()=>String;return{isColorSupported:$,reset:J("\x1B[0m","\x1B[0m"),bold:J("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:J("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:J("\x1B[3m","\x1B[23m"),underline:J("\x1B[4m","\x1B[24m"),inverse:J("\x1B[7m","\x1B[27m"),hidden:J("\x1B[8m","\x1B[28m"),strikethrough:J("\x1B[9m","\x1B[29m"),black:J("\x1B[30m","\x1B[39m"),red:J("\x1B[31m","\x1B[39m"),green:J("\x1B[32m","\x1B[39m"),yellow:J("\x1B[33m","\x1B[39m"),blue:J("\x1B[34m","\x1B[39m"),magenta:J("\x1B[35m","\x1B[39m"),cyan:J("\x1B[36m","\x1B[39m"),white:J("\x1B[37m","\x1B[39m"),gray:J("\x1B[90m","\x1B[39m"),bgBlack:J("\x1B[40m","\x1B[49m"),bgRed:J("\x1B[41m","\x1B[49m"),bgGreen:J("\x1B[42m","\x1B[49m"),bgYellow:J("\x1B[43m","\x1B[49m"),bgBlue:J("\x1B[44m","\x1B[49m"),bgMagenta:J("\x1B[45m","\x1B[49m"),bgCyan:J("\x1B[46m","\x1B[49m"),bgWhite:J("\x1B[47m","\x1B[49m"),blackBright:J("\x1B[90m","\x1B[39m"),redBright:J("\x1B[91m","\x1B[39m"),greenBright:J("\x1B[92m","\x1B[39m"),yellowBright:J("\x1B[93m","\x1B[39m"),blueBright:J("\x1B[94m","\x1B[39m"),magentaBright:J("\x1B[95m","\x1B[39m"),cyanBright:J("\x1B[96m","\x1B[39m"),whiteBright:J("\x1B[97m","\x1B[39m"),bgBlackBright:J("\x1B[100m","\x1B[49m"),bgRedBright:J("\x1B[101m","\x1B[49m"),bgGreenBright:J("\x1B[102m","\x1B[49m"),bgYellowBright:J("\x1B[103m","\x1B[49m"),bgBlueBright:J("\x1B[104m","\x1B[49m"),bgMagentaBright:J("\x1B[105m","\x1B[49m"),bgCyanBright:J("\x1B[106m","\x1B[49m"),bgWhiteBright:J("\x1B[107m","\x1B[49m")}};F$.exports=j4();F$.exports.createColors=j4});var f$=u((lN,U4)=>{var g$={to($,J){if(!J)return`\x1B[${$+1}G`;return`\x1B[${J+1};${$+1}H`},move($,J){let N="";if($<0)N+=`\x1B[${-$}D`;else if($>0)N+=`\x1B[${$}C`;if(J<0)N+=`\x1B[${-J}A`;else if(J>0)N+=`\x1B[${J}B`;return N},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},G6={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},Z6={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let J="";for(let N=0;N<$;N++)J+=this.line+(N<$-1?g$.up():"");if($)J+=g$.left;return J}};U4.exports={cursor:g$,scroll:G6,erase:Z6,beep:"\x07"}});var _1=u((JZ,o8)=>{var p8=["nodebuffer","arraybuffer","fragments"],s8=typeof Blob<"u";if(s8)p8.push("blob");o8.exports={BINARY_TYPES:p8,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:s8,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var R0=u((NZ,I$)=>{var{EMPTY_BUFFER:H7}=_1(),S2=Buffer[Symbol.species];function R7($,J){if($.length===0)return H7;if($.length===1)return $[0];let N=Buffer.allocUnsafe(J),G=0;for(let Z=0;Z<$.length;Z++){let z=$[Z];N.set(z,G),G+=z.length}if(G<J)return new S2(N.buffer,N.byteOffset,G);return N}function r8($,J,N,G,Z){for(let z=0;z<Z;z++)N[G+z]=$[z]^J[z&3]}function a8($,J){for(let N=0;N<$.length;N++)$[N]^=J[N&3]}function q7($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function W2($){if(W2.readOnly=!0,Buffer.isBuffer($))return $;let J;if($ instanceof ArrayBuffer)J=new S2($);else if(ArrayBuffer.isView($))J=new S2($.buffer,$.byteOffset,$.byteLength);else J=Buffer.from($),W2.readOnly=!1;return J}I$.exports={concat:R7,mask:r8,toArrayBuffer:q7,toBuffer:W2,unmask:a8};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();I$.exports.mask=function(J,N,G,Z,z){if(z<48)r8(J,N,G,Z,z);else $.mask(J,N,G,Z,z)},I$.exports.unmask=function(J,N){if(J.length<32)a8(J,N);else $.unmask(J,N)}}catch($){}});var J3=u((GZ,$3)=>{var t8=Symbol("kDone"),F2=Symbol("kRun");class e8{constructor($){this[t8]=()=>{this.pending--,this[F2]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[F2]()}[F2](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[t8])}}}$3.exports=e8});var U0=u((ZZ,X3)=>{var q0=f("zlib"),N3=R0(),U7=J3(),{kStatusCode:G3}=_1(),B7=Buffer[Symbol.species],T7=Buffer.from([0,0,255,255]),K$=Symbol("permessage-deflate"),C1=Symbol("total-length"),s1=Symbol("callback"),S1=Symbol("buffers"),o1=Symbol("error"),Y$;class Z3{constructor($,J,N){if(this._maxPayload=N|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!J,this._deflate=null,this._inflate=null,this.params=null,!Y$){let G=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Y$=new U7(G)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[s1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let J=this._options,N=$.find((G)=>{if(J.serverNoContextTakeover===!1&&G.server_no_context_takeover||G.server_max_window_bits&&(J.serverMaxWindowBits===!1||typeof J.serverMaxWindowBits==="number"&&J.serverMaxWindowBits>G.server_max_window_bits)||typeof J.clientMaxWindowBits==="number"&&!G.client_max_window_bits)return!1;return!0});if(!N)throw Error("None of the extension offers can be accepted");if(J.serverNoContextTakeover)N.server_no_context_takeover=!0;if(J.clientNoContextTakeover)N.client_no_context_takeover=!0;if(typeof J.serverMaxWindowBits==="number")N.server_max_window_bits=J.serverMaxWindowBits;if(typeof J.clientMaxWindowBits==="number")N.client_max_window_bits=J.clientMaxWindowBits;else if(N.client_max_window_bits===!0||J.clientMaxWindowBits===!1)delete N.client_max_window_bits;return N}acceptAsClient($){let J=$[0];if(this._options.clientNoContextTakeover===!1&&J.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!J.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")J.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&J.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return J}normalizeParams($){return $.forEach((J)=>{Object.keys(J).forEach((N)=>{let G=J[N];if(G.length>1)throw Error(`Parameter "${N}" must have only a single value`);if(G=G[0],N==="client_max_window_bits"){if(G!==!0){let Z=+G;if(!Number.isInteger(Z)||Z<8||Z>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=Z}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else if(N==="server_max_window_bits"){let Z=+G;if(!Number.isInteger(Z)||Z<8||Z>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=Z}else if(N==="client_no_context_takeover"||N==="server_no_context_takeover"){if(G!==!0)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else throw Error(`Unknown parameter "${N}"`);J[N]=G})}),$}decompress($,J,N){Y$.add((G)=>{this._decompress($,J,(Z,z)=>{G(),N(Z,z)})})}compress($,J,N){Y$.add((G)=>{this._compress($,J,(Z,z)=>{G(),N(Z,z)})})}_decompress($,J,N){let G=this._isServer?"client":"server";if(!this._inflate){let Z=`${G}_max_window_bits`,z=typeof this.params[Z]!=="number"?q0.Z_DEFAULT_WINDOWBITS:this.params[Z];this._inflate=q0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:z}),this._inflate[K$]=this,this._inflate[C1]=0,this._inflate[S1]=[],this._inflate.on("error",_7),this._inflate.on("data",z3)}if(this._inflate[s1]=N,this._inflate.write($),J)this._inflate.write(T7);this._inflate.flush(()=>{let Z=this._inflate[o1];if(Z){this._inflate.close(),this._inflate=null,N(Z);return}let z=N3.concat(this._inflate[S1],this._inflate[C1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[C1]=0,this._inflate[S1]=[],J&&this.params[`${G}_no_context_takeover`])this._inflate.reset();N(null,z)})}_compress($,J,N){let G=this._isServer?"server":"client";if(!this._deflate){let Z=`${G}_max_window_bits`,z=typeof this.params[Z]!=="number"?q0.Z_DEFAULT_WINDOWBITS:this.params[Z];this._deflate=q0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:z}),this._deflate[C1]=0,this._deflate[S1]=[],this._deflate.on("data",V7)}this._deflate[s1]=N,this._deflate.write($),this._deflate.flush(q0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let Z=N3.concat(this._deflate[S1],this._deflate[C1]);if(J)Z=new B7(Z.buffer,Z.byteOffset,Z.length-4);if(this._deflate[s1]=null,this._deflate[C1]=0,this._deflate[S1]=[],J&&this.params[`${G}_no_context_takeover`])this._deflate.reset();N(null,Z)})}}X3.exports=Z3;function V7($){this[S1].push($),this[C1]+=$.length}function z3($){if(this[C1]+=$.length,this[K$]._maxPayload<1||this[C1]<=this[K$]._maxPayload){this[S1].push($);return}this[o1]=RangeError("Max payload size exceeded"),this[o1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[o1][G3]=1009,this.removeListener("data",z3),this.reset()}function _7($){if(this[K$]._inflate=null,this[o1]){this[s1](this[o1]);return}$[G3]=1007,this[s1]($)}});var r1=u((zZ,j$)=>{var{isUtf8:Q3}=f("buffer"),{hasBlob:C7}=_1(),L7=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function A7($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function O2($){let J=$.length,N=0;while(N<J)if(($[N]&128)===0)N++;else if(($[N]&224)===192){if(N+1===J||($[N+1]&192)!==128||($[N]&254)===192)return!1;N+=2}else if(($[N]&240)===224){if(N+2>=J||($[N+1]&192)!==128||($[N+2]&192)!==128||$[N]===224&&($[N+1]&224)===128||$[N]===237&&($[N+1]&224)===160)return!1;N+=3}else if(($[N]&248)===240){if(N+3>=J||($[N+1]&192)!==128||($[N+2]&192)!==128||($[N+3]&192)!==128||$[N]===240&&($[N+1]&240)===128||$[N]===244&&$[N+1]>143||$[N]>244)return!1;N+=4}else return!1;return!0}function D7($){return C7&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}j$.exports={isBlob:D7,isValidStatusCode:A7,isValidUTF8:O2,tokenChars:L7};if(Q3)j$.exports.isValidUTF8=function($){return $.length<24?O2($):Q3($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();j$.exports.isValidUTF8=function(J){return J.length<32?O2(J):$(J)}}catch($){}});var f2=u((XZ,j3)=>{var{Writable:P7}=f("stream"),M3=U0(),{BINARY_TYPES:S7,EMPTY_BUFFER:I3,kStatusCode:W7,kWebSocket:F7}=_1(),{concat:g2,toArrayBuffer:O7,unmask:g7}=R0(),{isValidStatusCode:f7,isValidUTF8:Y3}=r1(),x$=Buffer[Symbol.species];class K3 extends P7{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||S7[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[F7]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,J,N){if(this._opcode===8&&this._state==0)return N();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(N)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let N=this._buffers[0];return this._buffers[0]=new x$(N.buffer,N.byteOffset+$,N.length-$),new x$(N.buffer,N.byteOffset,$)}let J=Buffer.allocUnsafe($);do{let N=this._buffers[0],G=J.length-$;if($>=N.length)J.set(this._buffers.shift(),G);else J.set(new Uint8Array(N.buffer,N.byteOffset,$),G),this._buffers[0]=new x$(N.buffer,N.byteOffset+$,N.length-$);$-=N.length}while($>0);return J}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let J=this.consume(2);if((J[0]&48)!==0){let G=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(G);return}let N=(J[0]&64)===64;if(N&&!this._extensions[M3.extensionName]){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._fin=(J[0]&128)===128,this._opcode=J[0]&15,this._payloadLength=J[1]&127,this._opcode===0){if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(!this._fragmented){let G=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._compressed=N}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let G=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(G);return}if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let G=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(G);return}}else{let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(J[1]&128)===128,this._isServer){if(!this._masked){let G=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(G);return}}else if(this._masked){let G=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(G);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let J=this.consume(8),N=J.readUInt32BE(0);if(N>Math.pow(2,21)-1){let G=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(G);return}this._payloadLength=N*Math.pow(2,32)+J.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let J=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(J);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let J=I3;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(J=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)g7(J,this._mask)}if(this._opcode>7){this.controlMessage(J,$);return}if(this._compressed){this._state=5,this.decompress(J,$);return}if(J.length)this._messageLength=this._totalPayloadLength,this._fragments.push(J);this.dataMessage($)}decompress($,J){this._extensions[M3.extensionName].decompress($,this._fin,(G,Z)=>{if(G)return J(G);if(Z.length){if(this._messageLength+=Z.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");J(z);return}this._fragments.push(Z)}if(this.dataMessage(J),this._state===0)this.startLoop(J)})}dataMessage($){if(!this._fin){this._state=0;return}let J=this._messageLength,N=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let G;if(this._binaryType==="nodebuffer")G=g2(N,J);else if(this._binaryType==="arraybuffer")G=O7(g2(N,J));else if(this._binaryType==="blob")G=new Blob(N);else G=N;if(this._allowSynchronousEvents)this.emit("message",G,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!0),this._state=0,this.startLoop($)})}else{let G=g2(N,J);if(!this._skipUTF8Validation&&!Y3(G)){let Z=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(Z);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",G,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!1),this._state=0,this.startLoop($)})}}controlMessage($,J){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,I3),this.end();else{let N=$.readUInt16BE(0);if(!f7(N)){let Z=this.createError(RangeError,`invalid status code ${N}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");J(Z);return}let G=new x$($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!Y3(G)){let Z=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");J(Z);return}this._loop=!1,this.emit("conclude",N,G),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(J)})}createError($,J,N,G,Z){this._loop=!1,this._errored=!0;let z=new $(N?`Invalid WebSocket frame: ${J}`:J);return Error.captureStackTrace(z,this.createError),z.code=Z,z[W7]=G,z}}j3.exports=K3});var E2=u((MZ,R3)=>{var{Duplex:QZ}=f("stream"),{randomFillSync:y7}=f("crypto"),x3=U0(),{EMPTY_BUFFER:E7,kWebSocket:w7,NOOP:v7}=_1(),{isBlob:a1,isValidStatusCode:u7}=r1(),{mask:H3,toBuffer:b1}=R0(),z1=Symbol("kByteLength"),b7=Buffer.alloc(4),l1,t1=8192,K1=0,l7=1,k7=2;class W1{constructor($,J,N){if(this._extensions=J||{},N)this._generateMask=N,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=K1,this.onerror=v7,this[w7]=void 0}static frame($,J){let N,G=!1,Z=2,z=!1;if(J.mask){if(N=J.maskBuffer||b7,J.generateMask)J.generateMask(N);else{if(t1===8192){if(l1===void 0)l1=Buffer.alloc(8192);y7(l1,0,8192),t1=0}N[0]=l1[t1++],N[1]=l1[t1++],N[2]=l1[t1++],N[3]=l1[t1++]}z=(N[0]|N[1]|N[2]|N[3])===0,Z=6}let X;if(typeof $==="string")if((!J.mask||z)&&J[z1]!==void 0)X=J[z1];else $=Buffer.from($),X=$.length;else X=$.length,G=J.mask&&J.readOnly&&!z;let Q=X;if(X>=65536)Z+=8,Q=127;else if(X>125)Z+=2,Q=126;let M=Buffer.allocUnsafe(G?X+Z:Z);if(M[0]=J.fin?J.opcode|128:J.opcode,J.rsv1)M[0]|=64;if(M[1]=Q,Q===126)M.writeUInt16BE(X,2);else if(Q===127)M[2]=M[3]=0,M.writeUIntBE(X,4,6);if(!J.mask)return[M,$];if(M[1]|=128,M[Z-4]=N[0],M[Z-3]=N[1],M[Z-2]=N[2],M[Z-1]=N[3],z)return[M,$];if(G)return H3($,N,M,Z,X),[M];return H3($,N,$,0,X),[M,$]}close($,J,N,G){let Z;if($===void 0)Z=E7;else if(typeof $!=="number"||!u7($))throw TypeError("First argument must be a valid error code number");else if(J===void 0||!J.length)Z=Buffer.allocUnsafe(2),Z.writeUInt16BE($,0);else{let X=Buffer.byteLength(J);if(X>123)throw RangeError("The message must not be greater than 123 bytes");if(Z=Buffer.allocUnsafe(2+X),Z.writeUInt16BE($,0),typeof J==="string")Z.write(J,2);else Z.set(J,2)}let z={[z1]:Z.length,fin:!0,generateMask:this._generateMask,mask:N,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==K1)this.enqueue([this.dispatch,Z,!1,z,G]);else this.sendFrame(W1.frame(Z,z),G)}ping($,J,N){let G,Z;if(typeof $==="string")G=Buffer.byteLength($),Z=!1;else if(a1($))G=$.size,Z=!1;else $=b1($),G=$.length,Z=b1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[z1]:G,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:9,readOnly:Z,rsv1:!1};if(a1($))if(this._state!==K1)this.enqueue([this.getBlobData,$,!1,z,N]);else this.getBlobData($,!1,z,N);else if(this._state!==K1)this.enqueue([this.dispatch,$,!1,z,N]);else this.sendFrame(W1.frame($,z),N)}pong($,J,N){let G,Z;if(typeof $==="string")G=Buffer.byteLength($),Z=!1;else if(a1($))G=$.size,Z=!1;else $=b1($),G=$.length,Z=b1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[z1]:G,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:10,readOnly:Z,rsv1:!1};if(a1($))if(this._state!==K1)this.enqueue([this.getBlobData,$,!1,z,N]);else this.getBlobData($,!1,z,N);else if(this._state!==K1)this.enqueue([this.dispatch,$,!1,z,N]);else this.sendFrame(W1.frame($,z),N)}send($,J,N){let G=this._extensions[x3.extensionName],Z=J.binary?2:1,z=J.compress,X,Q;if(typeof $==="string")X=Buffer.byteLength($),Q=!1;else if(a1($))X=$.size,Q=!1;else $=b1($),X=$.length,Q=b1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,z&&G&&G.params[G._isServer?"server_no_context_takeover":"client_no_context_takeover"])z=X>=G._threshold;this._compress=z}else z=!1,Z=0;if(J.fin)this._firstFragment=!0;let M={[z1]:X,fin:J.fin,generateMask:this._generateMask,mask:J.mask,maskBuffer:this._maskBuffer,opcode:Z,readOnly:Q,rsv1:z};if(a1($))if(this._state!==K1)this.enqueue([this.getBlobData,$,this._compress,M,N]);else this.getBlobData($,this._compress,M,N);else if(this._state!==K1)this.enqueue([this.dispatch,$,this._compress,M,N]);else this.dispatch($,this._compress,M,N)}getBlobData($,J,N,G){this._bufferedBytes+=N[z1],this._state=k7,$.arrayBuffer().then((Z)=>{if(this._socket.destroyed){let X=Error("The socket was closed while the blob was being read");process.nextTick(y2,this,X,G);return}this._bufferedBytes-=N[z1];let z=b1(Z);if(!J)this._state=K1,this.sendFrame(W1.frame(z,N),G),this.dequeue();else this.dispatch(z,J,N,G)}).catch((Z)=>{process.nextTick(m7,this,Z,G)})}dispatch($,J,N,G){if(!J){this.sendFrame(W1.frame($,N),G);return}let Z=this._extensions[x3.extensionName];this._bufferedBytes+=N[z1],this._state=l7,Z.compress($,N.fin,(z,X)=>{if(this._socket.destroyed){let Q=Error("The socket was closed while data was being compressed");y2(this,Q,G);return}this._bufferedBytes-=N[z1],this._state=K1,N.readOnly=!1,this.sendFrame(W1.frame(X,N),G),this.dequeue()})}dequeue(){while(this._state===K1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][z1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][z1],this._queue.push($)}sendFrame($,J){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],J),this._socket.uncork();else this._socket.write($[0],J)}}R3.exports=W1;function y2($,J,N){if(typeof N==="function")N(J);for(let G=0;G<$._queue.length;G++){let Z=$._queue[G],z=Z[Z.length-1];if(typeof z==="function")z(J)}}function m7($,J,N){y2($,J,N),$.onerror(J)}});var A3=u((IZ,L3)=>{var{kForOnEventAttribute:B0,kListener:w2}=_1(),q3=Symbol("kCode"),U3=Symbol("kData"),B3=Symbol("kError"),T3=Symbol("kMessage"),V3=Symbol("kReason"),e1=Symbol("kTarget"),_3=Symbol("kType"),C3=Symbol("kWasClean");class F1{constructor($){this[e1]=null,this[_3]=$}get target(){return this[e1]}get type(){return this[_3]}}Object.defineProperty(F1.prototype,"target",{enumerable:!0});Object.defineProperty(F1.prototype,"type",{enumerable:!0});class $0 extends F1{constructor($,J={}){super($);this[q3]=J.code===void 0?0:J.code,this[V3]=J.reason===void 0?"":J.reason,this[C3]=J.wasClean===void 0?!1:J.wasClean}get code(){return this[q3]}get reason(){return this[V3]}get wasClean(){return this[C3]}}Object.defineProperty($0.prototype,"code",{enumerable:!0});Object.defineProperty($0.prototype,"reason",{enumerable:!0});Object.defineProperty($0.prototype,"wasClean",{enumerable:!0});class T0 extends F1{constructor($,J={}){super($);this[B3]=J.error===void 0?null:J.error,this[T3]=J.message===void 0?"":J.message}get error(){return this[B3]}get message(){return this[T3]}}Object.defineProperty(T0.prototype,"error",{enumerable:!0});Object.defineProperty(T0.prototype,"message",{enumerable:!0});class R$ extends F1{constructor($,J={}){super($);this[U3]=J.data===void 0?null:J.data}get data(){return this[U3]}}Object.defineProperty(R$.prototype,"data",{enumerable:!0});var h7={addEventListener($,J,N={}){for(let Z of this.listeners($))if(!N[B0]&&Z[w2]===J&&!Z[B0])return;let G;if($==="message")G=function(z,X){let Q=new R$("message",{data:X?z:z.toString()});Q[e1]=this,H$(J,this,Q)};else if($==="close")G=function(z,X){let Q=new $0("close",{code:z,reason:X.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});Q[e1]=this,H$(J,this,Q)};else if($==="error")G=function(z){let X=new T0("error",{error:z,message:z.message});X[e1]=this,H$(J,this,X)};else if($==="open")G=function(){let z=new F1("open");z[e1]=this,H$(J,this,z)};else return;if(G[B0]=!!N[B0],G[w2]=J,N.once)this.once($,G);else this.on($,G)},removeEventListener($,J){for(let N of this.listeners($))if(N[w2]===J&&!N[B0]){this.removeListener($,N);break}}};L3.exports={CloseEvent:$0,ErrorEvent:T0,Event:F1,EventTarget:h7,MessageEvent:R$};function H$($,J,N){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,N);else $.call(J,N)}});var v2=u((YZ,D3)=>{var{tokenChars:V0}=r1();function q1($,J,N){if($[J]===void 0)$[J]=[N];else $[J].push(N)}function c7($){let J=Object.create(null),N=Object.create(null),G=!1,Z=!1,z=!1,X,Q,M=-1,I=-1,K=-1,Y=0;for(;Y<$.length;Y++)if(I=$.charCodeAt(Y),X===void 0)if(K===-1&&V0[I]===1){if(M===-1)M=Y}else if(Y!==0&&(I===32||I===9)){if(K===-1&&M!==-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;let R=$.slice(M,K);if(I===44)q1(J,R,N),N=Object.create(null);else X=R;M=K=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);else if(Q===void 0)if(K===-1&&V0[I]===1){if(M===-1)M=Y}else if(I===32||I===9){if(K===-1&&M!==-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;if(q1(N,$.slice(M,K),!0),I===44)q1(J,X,N),N=Object.create(null),X=void 0;M=K=-1}else if(I===61&&M!==-1&&K===-1)Q=$.slice(M,Y),M=K=-1;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(Z){if(V0[I]!==1)throw SyntaxError(`Unexpected character at index ${Y}`);if(M===-1)M=Y;else if(!G)G=!0;Z=!1}else if(z)if(V0[I]===1){if(M===-1)M=Y}else if(I===34&&M!==-1)z=!1,K=Y;else if(I===92)Z=!0;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(I===34&&$.charCodeAt(Y-1)===61)z=!0;else if(K===-1&&V0[I]===1){if(M===-1)M=Y}else if(M!==-1&&(I===32||I===9)){if(K===-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;let R=$.slice(M,K);if(G)R=R.replace(/\\/g,""),G=!1;if(q1(N,Q,R),I===44)q1(J,X,N),N=Object.create(null),X=void 0;Q=void 0,M=K=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);if(M===-1||z||I===32||I===9)throw SyntaxError("Unexpected end of input");if(K===-1)K=Y;let H=$.slice(M,K);if(X===void 0)q1(J,H,N);else{if(Q===void 0)q1(N,H,!0);else if(G)q1(N,Q,H.replace(/\\/g,""));else q1(N,Q,H);q1(J,X,N)}return J}function d7($){return Object.keys($).map((J)=>{let N=$[J];if(!Array.isArray(N))N=[N];return N.map((G)=>{return[J].concat(Object.keys(G).map((Z)=>{let z=G[Z];if(!Array.isArray(z))z=[z];return z.map((X)=>X===!0?Z:`${Z}=${X}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}D3.exports={format:d7,parse:c7}});var T$=u((xZ,u3)=>{var i7=f("events"),n7=f("https"),p7=f("http"),W3=f("net"),s7=f("tls"),{randomBytes:o7,createHash:r7}=f("crypto"),{Duplex:KZ,Readable:jZ}=f("stream"),{URL:u2}=f("url"),O1=U0(),a7=f2(),t7=E2(),{isBlob:e7}=r1(),{BINARY_TYPES:P3,CLOSE_TIMEOUT:$J,EMPTY_BUFFER:q$,GUID:JJ,kForOnEventAttribute:b2,kListener:NJ,kStatusCode:GJ,kWebSocket:h,NOOP:F3}=_1(),{EventTarget:{addEventListener:ZJ,removeEventListener:zJ}}=A3(),{format:XJ,parse:QJ}=v2(),{toBuffer:MJ}=R0(),O3=Symbol("kAborted"),l2=[8,13],L1=["CONNECTING","OPEN","CLOSING","CLOSED"],IJ=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class P extends i7{constructor($,J,N){super();if(this._binaryType=P3[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=q$,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=P.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,J===void 0)J=[];else if(!Array.isArray(J))if(typeof J==="object"&&J!==null)N=J,J=[];else J=[J];g3(this,$,J,N)}else this._autoPong=N.autoPong,this._closeTimeout=N.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!P3.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,J,N){let G=new a7({allowSynchronousEvents:N.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:N.maxPayload,skipUTF8Validation:N.skipUTF8Validation}),Z=new t7($,this._extensions,N.generateMask);if(this._receiver=G,this._sender=Z,this._socket=$,G[h]=this,Z[h]=this,$[h]=this,G.on("conclude",jJ),G.on("drain",xJ),G.on("error",HJ),G.on("message",RJ),G.on("ping",qJ),G.on("pong",UJ),Z.onerror=BJ,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(J.length>0)$.unshift(J);$.on("close",E3),$.on("data",B$),$.on("end",w3),$.on("error",v3),this._readyState=P.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=P.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[O1.extensionName])this._extensions[O1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=P.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,J){if(this.readyState===P.CLOSED)return;if(this.readyState===P.CONNECTING){$1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===P.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=P.CLOSING,this._sender.close($,J,!this._isServer,(N)=>{if(N)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),y3(this)}pause(){if(this.readyState===P.CONNECTING||this.readyState===P.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=J=void 0;else if(typeof J==="function")N=J,J=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}if(J===void 0)J=!this._isServer;this._sender.ping($||q$,J,N)}pong($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=J=void 0;else if(typeof J==="function")N=J,J=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}if(J===void 0)J=!this._isServer;this._sender.pong($||q$,J,N)}resume(){if(this.readyState===P.CONNECTING||this.readyState===P.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")N=J,J={};if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}let G={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...J};if(!this._extensions[O1.extensionName])G.compress=!1;this._sender.send($||q$,G,N)}terminate(){if(this.readyState===P.CLOSED)return;if(this.readyState===P.CONNECTING){$1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=P.CLOSING,this._socket.destroy()}}Object.defineProperty(P,"CONNECTING",{enumerable:!0,value:L1.indexOf("CONNECTING")});Object.defineProperty(P.prototype,"CONNECTING",{enumerable:!0,value:L1.indexOf("CONNECTING")});Object.defineProperty(P,"OPEN",{enumerable:!0,value:L1.indexOf("OPEN")});Object.defineProperty(P.prototype,"OPEN",{enumerable:!0,value:L1.indexOf("OPEN")});Object.defineProperty(P,"CLOSING",{enumerable:!0,value:L1.indexOf("CLOSING")});Object.defineProperty(P.prototype,"CLOSING",{enumerable:!0,value:L1.indexOf("CLOSING")});Object.defineProperty(P,"CLOSED",{enumerable:!0,value:L1.indexOf("CLOSED")});Object.defineProperty(P.prototype,"CLOSED",{enumerable:!0,value:L1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(P.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(P.prototype,`on${$}`,{enumerable:!0,get(){for(let J of this.listeners($))if(J[b2])return J[NJ];return null},set(J){for(let N of this.listeners($))if(N[b2]){this.removeListener($,N);break}if(typeof J!=="function")return;this.addEventListener($,J,{[b2]:!0})}})});P.prototype.addEventListener=ZJ;P.prototype.removeEventListener=zJ;u3.exports=P;function g3($,J,N,G){let Z={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:$J,protocolVersion:l2[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...G,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=Z.autoPong,$._closeTimeout=Z.closeTimeout,!l2.includes(Z.protocolVersion))throw RangeError(`Unsupported protocol version: ${Z.protocolVersion} (supported versions: ${l2.join(", ")})`);let z;if(J instanceof u2)z=J;else try{z=new u2(J)}catch(j){throw SyntaxError(`Invalid URL: ${J}`)}if(z.protocol==="http:")z.protocol="ws:";else if(z.protocol==="https:")z.protocol="wss:";$._url=z.href;let X=z.protocol==="wss:",Q=z.protocol==="ws+unix:",M;if(z.protocol!=="ws:"&&!X&&!Q)M=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(Q&&!z.pathname)M="The URL's pathname is empty";else if(z.hash)M="The URL contains a fragment identifier";if(M){let j=SyntaxError(M);if($._redirects===0)throw j;else{U$($,j);return}}let I=X?443:80,K=o7(16).toString("base64"),Y=X?n7.request:p7.request,H=new Set,R;if(Z.createConnection=Z.createConnection||(X?KJ:YJ),Z.defaultPort=Z.defaultPort||I,Z.port=z.port||I,Z.host=z.hostname.startsWith("[")?z.hostname.slice(1,-1):z.hostname,Z.headers={...Z.headers,"Sec-WebSocket-Version":Z.protocolVersion,"Sec-WebSocket-Key":K,Connection:"Upgrade",Upgrade:"websocket"},Z.path=z.pathname+z.search,Z.timeout=Z.handshakeTimeout,Z.perMessageDeflate)R=new O1(Z.perMessageDeflate!==!0?Z.perMessageDeflate:{},!1,Z.maxPayload),Z.headers["Sec-WebSocket-Extensions"]=XJ({[O1.extensionName]:R.offer()});if(N.length){for(let j of N){if(typeof j!=="string"||!IJ.test(j)||H.has(j))throw SyntaxError("An invalid or duplicated subprotocol was specified");H.add(j)}Z.headers["Sec-WebSocket-Protocol"]=N.join(",")}if(Z.origin)if(Z.protocolVersion<13)Z.headers["Sec-WebSocket-Origin"]=Z.origin;else Z.headers.Origin=Z.origin;if(z.username||z.password)Z.auth=`${z.username}:${z.password}`;if(Q){let j=Z.path.split(":");Z.socketPath=j[0],Z.path=j[1]}let x;if(Z.followRedirects){if($._redirects===0){$._originalIpc=Q,$._originalSecure=X,$._originalHostOrSocketPath=Q?Z.socketPath:z.host;let j=G&&G.headers;if(G={...G,headers:{}},j)for(let[U,T]of Object.entries(j))G.headers[U.toLowerCase()]=T}else if($.listenerCount("redirect")===0){let j=Q?$._originalIpc?Z.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:z.host===$._originalHostOrSocketPath;if(!j||$._originalSecure&&!X){if(delete Z.headers.authorization,delete Z.headers.cookie,!j)delete Z.headers.host;Z.auth=void 0}}if(Z.auth&&!G.headers.authorization)G.headers.authorization="Basic "+Buffer.from(Z.auth).toString("base64");if(x=$._req=Y(Z),$._redirects)$.emit("redirect",$.url,x)}else x=$._req=Y(Z);if(Z.timeout)x.on("timeout",()=>{$1($,x,"Opening handshake has timed out")});if(x.on("error",(j)=>{if(x===null||x[O3])return;x=$._req=null,U$($,j)}),x.on("response",(j)=>{let U=j.headers.location,T=j.statusCode;if(U&&Z.followRedirects&&T>=300&&T<400){if(++$._redirects>Z.maxRedirects){$1($,x,"Maximum redirects exceeded");return}x.abort();let B;try{B=new u2(U,J)}catch(_){let A=SyntaxError(`Invalid URL: ${U}`);U$($,A);return}g3($,B,N,G)}else if(!$.emit("unexpected-response",x,j))$1($,x,`Unexpected server response: ${j.statusCode}`)}),x.on("upgrade",(j,U,T)=>{if($.emit("upgrade",j),$.readyState!==P.CONNECTING)return;x=$._req=null;let B=j.headers.upgrade;if(B===void 0||B.toLowerCase()!=="websocket"){$1($,U,"Invalid Upgrade header");return}let _=r7("sha1").update(K+JJ).digest("base64");if(j.headers["sec-websocket-accept"]!==_){$1($,U,"Invalid Sec-WebSocket-Accept header");return}let A=j.headers["sec-websocket-protocol"],L;if(A!==void 0){if(!H.size)L="Server sent a subprotocol but none was requested";else if(!H.has(A))L="Server sent an invalid subprotocol"}else if(H.size)L="Server sent no subprotocol";if(L){$1($,U,L);return}if(A)$._protocol=A;let D=j.headers["sec-websocket-extensions"];if(D!==void 0){if(!R){$1($,U,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let V;try{V=QJ(D)}catch(l){$1($,U,"Invalid Sec-WebSocket-Extensions header");return}let C=Object.keys(V);if(C.length!==1||C[0]!==O1.extensionName){$1($,U,"Server indicated an extension that was not requested");return}try{R.accept(V[O1.extensionName])}catch(l){$1($,U,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[O1.extensionName]=R}$.setSocket(U,T,{allowSynchronousEvents:Z.allowSynchronousEvents,generateMask:Z.generateMask,maxPayload:Z.maxPayload,skipUTF8Validation:Z.skipUTF8Validation})}),Z.finishRequest)Z.finishRequest(x,$);else x.end()}function U$($,J){$._readyState=P.CLOSING,$._errorEmitted=!0,$.emit("error",J),$.emitClose()}function YJ($){return $.path=$.socketPath,W3.connect($)}function KJ($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=W3.isIP($.host)?"":$.host;return s7.connect($)}function $1($,J,N){$._readyState=P.CLOSING;let G=Error(N);if(Error.captureStackTrace(G,$1),J.setHeader){if(J[O3]=!0,J.abort(),J.socket&&!J.socket.destroyed)J.socket.destroy();process.nextTick(U$,$,G)}else J.destroy(G),J.once("error",$.emit.bind($,"error")),J.once("close",$.emitClose.bind($))}function k2($,J,N){if(J){let G=e7(J)?J.size:MJ(J).length;if($._socket)$._sender._bufferedBytes+=G;else $._bufferedAmount+=G}if(N){let G=Error(`WebSocket is not open: readyState ${$.readyState} (${L1[$.readyState]})`);process.nextTick(N,G)}}function jJ($,J){let N=this[h];if(N._closeFrameReceived=!0,N._closeMessage=J,N._closeCode=$,N._socket[h]===void 0)return;if(N._socket.removeListener("data",B$),process.nextTick(f3,N._socket),$===1005)N.close();else N.close($,J)}function xJ(){let $=this[h];if(!$.isPaused)$._socket.resume()}function HJ($){let J=this[h];if(J._socket[h]!==void 0)J._socket.removeListener("data",B$),process.nextTick(f3,J._socket),J.close($[GJ]);if(!J._errorEmitted)J._errorEmitted=!0,J.emit("error",$)}function S3(){this[h].emitClose()}function RJ($,J){this[h].emit("message",$,J)}function qJ($){let J=this[h];if(J._autoPong)J.pong($,!this._isServer,F3);J.emit("ping",$)}function UJ($){this[h].emit("pong",$)}function f3($){$.resume()}function BJ($){let J=this[h];if(J.readyState===P.CLOSED)return;if(J.readyState===P.OPEN)J._readyState=P.CLOSING,y3(J);if(this._socket.end(),!J._errorEmitted)J._errorEmitted=!0,J.emit("error",$)}function y3($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function E3(){let $=this[h];if(this.removeListener("close",E3),this.removeListener("data",B$),this.removeListener("end",w3),$._readyState=P.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let J=this.read(this._readableState.length);$._receiver.write(J)}if($._receiver.end(),this[h]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",S3),$._receiver.on("finish",S3)}function B$($){if(!this[h]._receiver.write($))this.pause()}function w3(){let $=this[h];$._readyState=P.CLOSING,$._receiver.end(),this.end()}function v3(){let $=this[h];if(this.removeListener("error",v3),this.on("error",F3),$)$._readyState=P.CLOSING,this.destroy()}});var m3=u((RZ,k3)=>{var HZ=T$(),{Duplex:TJ}=f("stream");function b3($){$.emit("close")}function VJ(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function l3($){if(this.removeListener("error",l3),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function _J($,J){let N=!0,G=new TJ({...J,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(z,X){let Q=!X&&G._readableState.objectMode?z.toString():z;if(!G.push(Q))$.pause()}),$.once("error",function(z){if(G.destroyed)return;N=!1,G.destroy(z)}),$.once("close",function(){if(G.destroyed)return;G.push(null)}),G._destroy=function(Z,z){if($.readyState===$.CLOSED){z(Z),process.nextTick(b3,G);return}let X=!1;if($.once("error",function(M){X=!0,z(M)}),$.once("close",function(){if(!X)z(Z);process.nextTick(b3,G)}),N)$.terminate()},G._final=function(Z){if($.readyState===$.CONNECTING){$.once("open",function(){G._final(Z)});return}if($._socket===null)return;if($._socket._writableState.finished){if(Z(),G._readableState.endEmitted)G.destroy()}else $._socket.once("finish",function(){Z()}),$.close()},G._read=function(){if($.isPaused)$.resume()},G._write=function(Z,z,X){if($.readyState===$.CONNECTING){$.once("open",function(){G._write(Z,z,X)});return}$.send(Z,X)},G.on("end",VJ),G.on("error",l3),G}k3.exports=_J});var c3=u((qZ,h3)=>{var{tokenChars:CJ}=r1();function LJ($){let J=new Set,N=-1,G=-1,Z=0;for(Z;Z<$.length;Z++){let X=$.charCodeAt(Z);if(G===-1&&CJ[X]===1){if(N===-1)N=Z}else if(Z!==0&&(X===32||X===9)){if(G===-1&&N!==-1)G=Z}else if(X===44){if(N===-1)throw SyntaxError(`Unexpected character at index ${Z}`);if(G===-1)G=Z;let Q=$.slice(N,G);if(J.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);J.add(Q),N=G=-1}else throw SyntaxError(`Unexpected character at index ${Z}`)}if(N===-1||G!==-1)throw SyntaxError("Unexpected end of input");let z=$.slice(N,Z);if(J.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);return J.add(z),J}h3.exports={parse:LJ}});var s3=u((BZ,p3)=>{var AJ=f("events"),V$=f("http"),{Duplex:UZ}=f("stream"),{createHash:DJ}=f("crypto"),d3=v2(),k1=U0(),PJ=c3(),SJ=T$(),{CLOSE_TIMEOUT:WJ,GUID:FJ,kWebSocket:OJ}=_1(),gJ=/^[+/0-9A-Za-z]{22}==$/;class n3 extends AJ{constructor($,J){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:WJ,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:SJ,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=V$.createServer((N,G)=>{let Z=V$.STATUS_CODES[426];G.writeHead(426,{"Content-Length":Z.length,"Content-Type":"text/plain"}),G.end(Z)}),this._server.listen($.port,$.host,$.backlog,J);else if($.server)this._server=$.server;if(this._server){let N=this.emit.bind(this,"connection");this._removeListeners=fJ(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(G,Z,z)=>{this.handleUpgrade(G,Z,z,N)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(_0,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(_0,this);else this._shouldEmitClose=!0;else process.nextTick(_0,this)}else{let J=this._server;this._removeListeners(),this._removeListeners=this._server=null,J.close(()=>{_0(this)})}}shouldHandle($){if(this.options.path){let J=$.url.indexOf("?");if((J!==-1?$.url.slice(0,J):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,J,N,G){J.on("error",i3);let Z=$.headers["sec-websocket-key"],z=$.headers.upgrade,X=+$.headers["sec-websocket-version"];if($.method!=="GET"){m1(this,$,J,405,"Invalid HTTP method");return}if(z===void 0||z.toLowerCase()!=="websocket"){m1(this,$,J,400,"Invalid Upgrade header");return}if(Z===void 0||!gJ.test(Z)){m1(this,$,J,400,"Missing or invalid Sec-WebSocket-Key header");return}if(X!==13&&X!==8){m1(this,$,J,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){C0(J,400);return}let Q=$.headers["sec-websocket-protocol"],M=new Set;if(Q!==void 0)try{M=PJ.parse(Q)}catch(Y){m1(this,$,J,400,"Invalid Sec-WebSocket-Protocol header");return}let I=$.headers["sec-websocket-extensions"],K={};if(this.options.perMessageDeflate&&I!==void 0){let Y=new k1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let H=d3.parse(I);if(H[k1.extensionName])Y.accept(H[k1.extensionName]),K[k1.extensionName]=Y}catch(H){m1(this,$,J,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Y={origin:$.headers[`${X===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(Y,(H,R,x,j)=>{if(!H)return C0(J,R||401,x,j);this.completeUpgrade(K,Z,M,$,J,N,G)});return}if(!this.options.verifyClient(Y))return C0(J,401)}this.completeUpgrade(K,Z,M,$,J,N,G)}completeUpgrade($,J,N,G,Z,z,X){if(!Z.readable||!Z.writable)return Z.destroy();if(Z[OJ])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return C0(Z,503);let M=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${DJ("sha1").update(J+FJ).digest("base64")}`],I=new this.options.WebSocket(null,void 0,this.options);if(N.size){let K=this.options.handleProtocols?this.options.handleProtocols(N,G):N.values().next().value;if(K)M.push(`Sec-WebSocket-Protocol: ${K}`),I._protocol=K}if($[k1.extensionName]){let K=$[k1.extensionName].params,Y=d3.format({[k1.extensionName]:[K]});M.push(`Sec-WebSocket-Extensions: ${Y}`),I._extensions=$}if(this.emit("headers",M,G),Z.write(M.concat(`\r
|
|
24
24
|
`).join(`\r
|
|
25
|
-
`)),
|
|
26
|
-
`+Object.keys(G).map((
|
|
25
|
+
`)),Z.removeListener("error",i3),I.setSocket(Z,z,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(I),I.on("close",()=>{if(this.clients.delete(I),this._shouldEmitClose&&!this.clients.size)process.nextTick(_0,this)});X(I,G)}}p3.exports=n3;function fJ($,J){for(let N of Object.keys(J))$.on(N,J[N]);return function(){for(let G of Object.keys(J))$.removeListener(G,J[G])}}function _0($){$._state=2,$.emit("close")}function i3(){this.destroy()}function C0($,J,N,G){N=N||V$.STATUS_CODES[J],G={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(N),...G},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${J} ${V$.STATUS_CODES[J]}\r
|
|
26
|
+
`+Object.keys(G).map((Z)=>`${Z}: ${G[Z]}`).join(`\r
|
|
27
27
|
`)+`\r
|
|
28
28
|
\r
|
|
29
|
-
`+N)}function y1($,I,N,G,J,Z){if($.listenerCount("wsClientError")){let z=Error(J);Error.captureStackTrace(z,y1),$.emit("wsClientError",z,N,I)}else z0(N,G,J,Z)}});var x1=v((c7,r$)=>{var k0=process||{},P8=k0.argv||[],i0=k0.env||{},o9=!(!!i0.NO_COLOR||P8.includes("--no-color"))&&(!!i0.FORCE_COLOR||P8.includes("--color")||k0.platform==="win32"||(k0.stdout||{}).isTTY&&i0.TERM!=="dumb"||!!i0.CI),r9=($,I,N=$)=>(G)=>{let J=""+G,Z=J.indexOf(I,$.length);return~Z?$+a9(J,I,N,Z)+I:$+J+I},a9=($,I,N,G)=>{let J="",Z=0;do J+=$.substring(Z,G)+N,Z=G+I.length,G=$.indexOf(I,Z);while(~G);return J+$.substring(Z)},F8=($=o9)=>{let I=$?r9:()=>String;return{isColorSupported:$,reset:I("\x1B[0m","\x1B[0m"),bold:I("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:I("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:I("\x1B[3m","\x1B[23m"),underline:I("\x1B[4m","\x1B[24m"),inverse:I("\x1B[7m","\x1B[27m"),hidden:I("\x1B[8m","\x1B[28m"),strikethrough:I("\x1B[9m","\x1B[29m"),black:I("\x1B[30m","\x1B[39m"),red:I("\x1B[31m","\x1B[39m"),green:I("\x1B[32m","\x1B[39m"),yellow:I("\x1B[33m","\x1B[39m"),blue:I("\x1B[34m","\x1B[39m"),magenta:I("\x1B[35m","\x1B[39m"),cyan:I("\x1B[36m","\x1B[39m"),white:I("\x1B[37m","\x1B[39m"),gray:I("\x1B[90m","\x1B[39m"),bgBlack:I("\x1B[40m","\x1B[49m"),bgRed:I("\x1B[41m","\x1B[49m"),bgGreen:I("\x1B[42m","\x1B[49m"),bgYellow:I("\x1B[43m","\x1B[49m"),bgBlue:I("\x1B[44m","\x1B[49m"),bgMagenta:I("\x1B[45m","\x1B[49m"),bgCyan:I("\x1B[46m","\x1B[49m"),bgWhite:I("\x1B[47m","\x1B[49m"),blackBright:I("\x1B[90m","\x1B[39m"),redBright:I("\x1B[91m","\x1B[39m"),greenBright:I("\x1B[92m","\x1B[39m"),yellowBright:I("\x1B[93m","\x1B[39m"),blueBright:I("\x1B[94m","\x1B[39m"),magentaBright:I("\x1B[95m","\x1B[39m"),cyanBright:I("\x1B[96m","\x1B[39m"),whiteBright:I("\x1B[97m","\x1B[39m"),bgBlackBright:I("\x1B[100m","\x1B[49m"),bgRedBright:I("\x1B[101m","\x1B[49m"),bgGreenBright:I("\x1B[102m","\x1B[49m"),bgYellowBright:I("\x1B[103m","\x1B[49m"),bgBlueBright:I("\x1B[104m","\x1B[49m"),bgMagentaBright:I("\x1B[105m","\x1B[49m"),bgCyanBright:I("\x1B[106m","\x1B[49m"),bgWhiteBright:I("\x1B[107m","\x1B[49m")}};r$.exports=F8();r$.exports.createColors=F8});var G2=v((NG,u8)=>{var N2={to($,I){if(!I)return`\x1B[${$+1}G`;return`\x1B[${I+1};${$+1}H`},move($,I){let N="";if($<0)N+=`\x1B[${-$}D`;else if($>0)N+=`\x1B[${$}C`;if(I<0)N+=`\x1B[${-I}A`;else if(I>0)N+=`\x1B[${I}B`;return N},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},_I={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},VI={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let I="";for(let N=0;N<$;N++)I+=this.line+(N<$-1?N2.up():"");if($)I+=N2.left;return I}};u8.exports={cursor:N2,scroll:_I,erase:VI,beep:"\x07"}});var I4=i($4(),1),{program:I7,createCommand:N7,createArgument:G7,createOption:J7,CommanderError:Z7,InvalidArgumentError:x7,InvalidOptionArgumentError:z7,Command:N4,Argument:Q7,Option:X7,Help:M7}=I4.default;import{stat as M6}from"fs";import{stat as j6,readdir as K6}from"fs/promises";import{EventEmitter as Y6}from"events";import*as V from"path";import{stat as l5,lstat as G4,readdir as u5,realpath as v5}from"node:fs/promises";import{Readable as w5}from"node:stream";import{resolve as J4,relative as b5,join as m5,sep as i5}from"node:path";var o={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},_$={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:o.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(_$);var Q4="READDIRP_RECURSIVE_ERROR",k5=new Set(["ENOENT","EPERM","EACCES","ELOOP",Q4]),Z4=[o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE],h5=new Set([o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE]),n5=new Set([o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE]),c5=($)=>k5.has($.code),d5=process.platform==="win32",x4=($)=>!0,z4=($)=>{if($===void 0)return x4;if(typeof $==="function")return $;if(typeof $==="string"){let I=$.trim();return(N)=>N.basename===I}if(Array.isArray($)){let I=$.map((N)=>N.trim());return(N)=>I.some((G)=>N.basename===G)}return x4};class X4 extends w5{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let I={..._$,...$},{root:N,type:G}=I;this._fileFilter=z4(I.fileFilter),this._directoryFilter=z4(I.directoryFilter);let J=I.lstat?G4:l5;if(d5)this._stat=(Z)=>J(Z,{bigint:!0});else this._stat=J;this._maxDepth=I.depth??_$.depth,this._wantsDir=G?h5.has(G):!1,this._wantsFile=G?n5.has(G):!1,this._wantsEverything=G===o.EVERYTHING_TYPE,this._root=J4(N),this._isDirent=!I.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(N,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let I=this.parent,N=I&&I.files;if(N&&N.length>0){let{path:G,depth:J}=I,Z=N.splice(0,$).map((x)=>this._formatEntry(x,G)),z=await Promise.all(Z);for(let x of z){if(!x)continue;if(this.destroyed)return;let Q=await this._getEntryType(x);if(Q==="directory"&&this._directoryFilter(x)){if(J<=this._maxDepth)this.parents.push(this._exploreDir(x.fullPath,J+1));if(this._wantsDir)this.push(x),$--}else if((Q==="file"||this._includeAsFile(x))&&this._fileFilter(x)){if(this._wantsFile)this.push(x),$--}}}else{let G=this.parents.pop();if(!G){this.push(null);break}if(this.parent=await G,this.destroyed)return}}}catch(I){this.destroy(I)}finally{this.reading=!1}}async _exploreDir($,I){let N;try{N=await u5($,this._rdOptions)}catch(G){this._onError(G)}return{files:N,depth:I,path:$}}async _formatEntry($,I){let N,G=this._isDirent?$.name:$;try{let J=J4(m5(I,G));N={path:b5(this._root,J),fullPath:J,basename:G},N[this._statsProp]=this._isDirent?$:await this._stat(J)}catch(J){this._onError(J);return}return N}_onError($){if(c5($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let I=$[this._statsProp];if(I.isFile())return"file";if(I.isDirectory())return"directory";if(I&&I.isSymbolicLink()){let N=$.fullPath;try{let G=await v5(N),J=await G4(G);if(J.isFile())return"file";if(J.isDirectory()){let Z=G.length;if(N.startsWith(G)&&N.substr(Z,1)===i5){let z=Error(`Circular symlink detected: "${N}" points to "${G}"`);return z.code=Q4,this._onError(z)}return"directory"}}catch(G){return this._onError(G),""}}}_includeAsFile($){let I=$&&$[this._statsProp];return I&&this._wantsEverything&&!I.isDirectory()}}function M4($,I={}){let N=I.entryType||I.type;if(N==="both")N=o.FILE_DIR_TYPE;if(N)I.type=N;if(!$)throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");else if(typeof $!=="string")throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(N&&!Z4.includes(N))throw Error(`readdirp: Invalid type passed. Use one of ${Z4.join(", ")}`);return I.root=$,new X4(I)}import{watchFile as p5,unwatchFile as j4,watch as s5}from"fs";import{open as o5,stat as Y4,lstat as r5,realpath as V$}from"fs/promises";import*as u from"path";import{type as a5}from"os";var t5="data",P$="end",R4="close",_0=()=>{};var V0=process.platform,F$=V0==="win32",e5=V0==="darwin",$6=V0==="linux",I6=V0==="freebsd",S4=a5()==="OS400",y={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},J1=y,N6="watch",G6={lstat:r5,stat:Y4},P1="listeners",g0="errHandlers",w1="rawEmitters",J6=[P1,g0,w1],Z6=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),x6=($)=>Z6.has(u.extname($).slice(1).toLowerCase()),A$=($,I)=>{if($ instanceof Set)$.forEach(I);else I($)},t1=($,I,N)=>{let G=$[I];if(!(G instanceof Set))$[I]=G=new Set([G]);G.add(N)},z6=($)=>(I)=>{let N=$[I];if(N instanceof Set)N.clear();else delete $[I]},e1=($,I,N)=>{let G=$[I];if(G instanceof Set)G.delete(N);else if(G===N)delete $[I]},H4=($)=>$ instanceof Set?$.size===0:!$,L0=new Map;function K4($,I,N,G,J){let Z=(z,x)=>{if(N($),J(z,x,{watchedPath:$}),x&&$!==x)D0(u.resolve($,x),P1,u.join($,x))};try{return s5($,{persistent:I.persistent},Z)}catch(z){G(z);return}}var D0=($,I,N,G,J)=>{let Z=L0.get($);if(!Z)return;A$(Z[I],(z)=>{z(N,G,J)})},Q6=($,I,N,G)=>{let{listener:J,errHandler:Z,rawEmitter:z}=G,x=L0.get(I),Q;if(!N.persistent){if(Q=K4($,N,J,Z,z),!Q)return;return Q.close.bind(Q)}if(x)t1(x,P1,J),t1(x,g0,Z),t1(x,w1,z);else{if(Q=K4($,N,D0.bind(null,I,P1),Z,D0.bind(null,I,w1)),!Q)return;Q.on(J1.ERROR,async(X)=>{let j=D0.bind(null,I,g0);if(x)x.watcherUnusable=!0;if(F$&&X.code==="EPERM")try{await(await o5($,"r")).close(),j(X)}catch(M){}else j(X)}),x={listeners:J,errHandlers:Z,rawEmitters:z,watcher:Q},L0.set(I,x)}return()=>{if(e1(x,P1,J),e1(x,g0,Z),e1(x,w1,z),H4(x.listeners))x.watcher.close(),L0.delete(I),J6.forEach(z6(x)),x.watcher=void 0,Object.freeze(x)}},f$=new Map,X6=($,I,N,G)=>{let{listener:J,rawEmitter:Z}=G,z=f$.get(I),x=z&&z.options;if(x&&(x.persistent<N.persistent||x.interval>N.interval))j4(I),z=void 0;if(z)t1(z,P1,J),t1(z,w1,Z);else z={listeners:J,rawEmitters:Z,options:N,watcher:p5(I,N,(Q,X)=>{A$(z.rawEmitters,(M)=>{M(J1.CHANGE,I,{curr:Q,prev:X})});let j=Q.mtimeMs;if(Q.size!==X.size||j>X.mtimeMs||j===0)A$(z.listeners,(M)=>M($,Q))})},f$.set(I,z);return()=>{if(e1(z,P1,J),e1(z,w1,Z),H4(z.listeners))f$.delete(I),j4(I),z.options=z.watcher=void 0,Object.freeze(z)}};class W${constructor($){this.fsw=$,this._boundHandleError=(I)=>$._handleError(I)}_watchWithNodeFs($,I){let N=this.fsw.options,G=u.dirname($),J=u.basename($);this.fsw._getWatchedDir(G).add(J);let z=u.resolve($),x={persistent:N.persistent};if(!I)I=_0;let Q;if(N.usePolling){let X=N.interval!==N.binaryInterval;x.interval=X&&x6(J)?N.binaryInterval:N.interval,Q=X6($,z,x,{listener:I,rawEmitter:this.fsw._emitRaw})}else Q=Q6($,z,x,{listener:I,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return Q}_handleFile($,I,N){if(this.fsw.closed)return;let G=u.dirname($),J=u.basename($),Z=this.fsw._getWatchedDir(G),z=I;if(Z.has(J))return;let x=async(X,j)=>{if(!this.fsw._throttle(N6,$,5))return;if(!j||j.mtimeMs===0)try{let M=await Y4($);if(this.fsw.closed)return;let{atimeMs:R,mtimeMs:S}=M;if(!R||R<=S||S!==z.mtimeMs)this.fsw._emit(J1.CHANGE,$,M);if((e5||$6||I6)&&z.ino!==M.ino){this.fsw._closeFile(X),z=M;let Y=this._watchWithNodeFs($,x);if(Y)this.fsw._addPathCloser(X,Y)}else z=M}catch(M){this.fsw._remove(G,J)}else if(Z.has(J)){let{atimeMs:M,mtimeMs:R}=j;if(!M||M<=R||R!==z.mtimeMs)this.fsw._emit(J1.CHANGE,$,j);z=j}},Q=this._watchWithNodeFs($,x);if(!(N&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(J1.ADD,$,0))return;this.fsw._emit(J1.ADD,$,I)}return Q}async _handleSymlink($,I,N,G){if(this.fsw.closed)return;let J=$.fullPath,Z=this.fsw._getWatchedDir(I);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let z;try{z=await V$(N)}catch(x){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(Z.has(G)){if(this.fsw._symlinkPaths.get(J)!==z)this.fsw._symlinkPaths.set(J,z),this.fsw._emit(J1.CHANGE,N,$.stats)}else Z.add(G),this.fsw._symlinkPaths.set(J,z),this.fsw._emit(J1.ADD,N,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(J))return!0;this.fsw._symlinkPaths.set(J,!0)}_handleRead($,I,N,G,J,Z,z){if($=u.join($,""),z=this.fsw._throttle("readdir",$,1000),!z)return;let x=this.fsw._getWatchedDir(N.path),Q=new Set,X=this.fsw._readdirp($,{fileFilter:(j)=>N.filterPath(j),directoryFilter:(j)=>N.filterDir(j)});if(!X)return;return X.on(t5,async(j)=>{if(this.fsw.closed){X=void 0;return}let M=j.path,R=u.join($,M);if(Q.add(M),j.stats.isSymbolicLink()&&await this._handleSymlink(j,$,R,M))return;if(this.fsw.closed){X=void 0;return}if(M===G||!G&&!x.has(M))this.fsw._incrReadyCount(),R=u.join(J,u.relative(J,R)),this._addToNodeFs(R,I,N,Z+1)}).on(J1.ERROR,this._boundHandleError),new Promise((j,M)=>{if(!X)return M();X.once(P$,()=>{if(this.fsw.closed){X=void 0;return}let R=z?z.clear():!1;if(j(void 0),x.getChildren().filter((S)=>{return S!==$&&!Q.has(S)}).forEach((S)=>{this.fsw._remove($,S)}),X=void 0,R)this._handleRead($,!1,N,G,J,Z,z)})})}async _handleDir($,I,N,G,J,Z,z){let x=this.fsw._getWatchedDir(u.dirname($)),Q=x.has(u.basename($));if(!(N&&this.fsw.options.ignoreInitial)&&!J&&!Q)this.fsw._emit(J1.ADD_DIR,$,I);x.add(u.basename($)),this.fsw._getWatchedDir($);let X,j,M=this.fsw.options.depth;if((M==null||G<=M)&&!this.fsw._symlinkPaths.has(z)){if(!J){if(await this._handleRead($,N,Z,J,$,G,X),this.fsw.closed)return}j=this._watchWithNodeFs($,(R,S)=>{if(S&&S.mtimeMs===0)return;this._handleRead(R,!1,Z,J,$,G,X)})}return j}async _addToNodeFs($,I,N,G,J){let Z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return Z(),!1;let z=this.fsw._getWatchHelpers($);if(N)z.filterPath=(x)=>N.filterPath(x),z.filterDir=(x)=>N.filterDir(x);try{let x=await G6[z.statMethod](z.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(z.watchPath,x))return Z(),!1;let Q=this.fsw.options.followSymlinks,X;if(x.isDirectory()){let j=u.resolve($),M=Q?await V$($):$;if(this.fsw.closed)return;if(X=await this._handleDir(z.watchPath,x,I,G,J,z,M),this.fsw.closed)return;if(j!==M&&M!==void 0)this.fsw._symlinkPaths.set(j,M)}else if(x.isSymbolicLink()){let j=Q?await V$($):$;if(this.fsw.closed)return;let M=u.dirname(z.watchPath);if(this.fsw._getWatchedDir(M).add(z.watchPath),this.fsw._emit(J1.ADD,z.watchPath,x),X=await this._handleDir(M,x,I,G,$,z,j),this.fsw.closed)return;if(j!==void 0)this.fsw._symlinkPaths.set(u.resolve($),j)}else X=this._handleFile(z.watchPath,x,I);if(Z(),X)this.fsw._addPathCloser($,X);return!1}catch(x){if(this.fsw._handleError(x))return Z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var O$="/",R6="//",g4=".",S6="..",H6="string",T6=/\\/g,T4=/\/\//,U6=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,q6=/^\.[/\\]/;function f0($){return Array.isArray($)?$:[$]}var y$=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function C6($){if(typeof $==="function")return $;if(typeof $==="string")return(I)=>$===I;if($ instanceof RegExp)return(I)=>$.test(I);if(typeof $==="object"&&$!==null)return(I)=>{if($.path===I)return!0;if($.recursive){let N=V.relative($.path,I);if(!N)return!1;return!N.startsWith("..")&&!V.isAbsolute(N)}return!1};return()=>!1}function B6($){if(typeof $!=="string")throw Error("string expected");$=V.normalize($),$=$.replace(/\\/g,"/");let I=!1;if($.startsWith("//"))I=!0;let N=/\/\//;while($.match(N))$=$.replace(N,"/");if(I)$="/"+$;return $}function U4($,I,N){let G=B6(I);for(let J=0;J<$.length;J++){let Z=$[J];if(Z(G,N))return!0}return!1}function g6($,I){if($==null)throw TypeError("anymatch: specify first argument");let G=f0($).map((J)=>C6(J));if(I==null)return(J,Z)=>{return U4(G,J,Z)};return U4(G,I)}var q4=($)=>{let I=f0($).flat();if(!I.every((N)=>typeof N===H6))throw TypeError(`Non-string provided as watch path: ${I}`);return I.map(L4)},C4=($)=>{let I=$.replace(T6,O$),N=!1;if(I.startsWith(R6))N=!0;while(I.match(T4))I=I.replace(T4,O$);if(N)I=O$+I;return I},L4=($)=>C4(V.normalize(C4($))),B4=($="")=>(I)=>{if(typeof I==="string")return L4(V.isAbsolute(I)?I:V.join($,I));else return I},L6=($,I)=>{if(V.isAbsolute($))return $;return V.join(I,$)},D6=Object.freeze(new Set);class D4{constructor($,I){this.path=$,this._removeWatcher=I,this.items=new Set}add($){let{items:I}=this;if(!I)return;if($!==g4&&$!==S6)I.add($)}async remove($){let{items:I}=this;if(!I)return;if(I.delete($),I.size>0)return;let N=this.path;try{await K6(N)}catch(G){if(this._removeWatcher)this._removeWatcher(V.dirname(N),V.basename(N))}}has($){let{items:I}=this;if(!I)return;return I.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=_0,this.items=D6,Object.freeze(this)}}var _6="stat",V6="lstat";class _4{constructor($,I,N){this.fsw=N;let G=$;this.path=$=$.replace(q6,""),this.watchPath=G,this.fullWatchPath=V.resolve(G),this.dirParts=[],this.dirParts.forEach((J)=>{if(J.length>1)J.pop()}),this.followSymlinks=I,this.statMethod=I?_6:V6}entryPath($){return V.join(this.watchPath,V.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:I}=$;if(I&&I.isSymbolicLink())return this.filterDir($);let N=this.entryPath($);return this.fsw._isntIgnored(N,I)&&this.fsw._hasReadPermissions(I)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class V4 extends Y6{constructor($={}){super();this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let I=$.awaitWriteFinish,N={stabilityThreshold:2000,pollInterval:100},G={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?f0($.ignored):f0([]),awaitWriteFinish:I===!0?N:typeof I==="object"?{...N,...I}:!1};if(S4)G.usePolling=!0;if(G.atomic===void 0)G.atomic=!G.usePolling;let J=process.env.CHOKIDAR_USEPOLLING;if(J!==void 0){let x=J.toLowerCase();if(x==="false"||x==="0")G.usePolling=!1;else if(x==="true"||x==="1")G.usePolling=!0;else G.usePolling=!!x}let Z=process.env.CHOKIDAR_INTERVAL;if(Z)G.interval=Number.parseInt(Z,10);let z=0;this._emitReady=()=>{if(z++,z>=this._readyCount)this._emitReady=_0,this._readyEmitted=!0,process.nextTick(()=>this.emit(y.READY))},this._emitRaw=(...x)=>this.emit(y.RAW,...x),this._boundRemove=this._remove.bind(this),this.options=G,this._nodeFsHandler=new W$(this),Object.freeze(G)}_addIgnoredPath($){if(y$($)){for(let I of this._ignoredPaths)if(y$(I)&&I.path===$.path&&I.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let I of this._ignoredPaths)if(y$(I)&&I.path===$)this._ignoredPaths.delete(I)}}add($,I,N){let{cwd:G}=this.options;this.closed=!1,this._closePromise=void 0;let J=q4($);if(G)J=J.map((Z)=>{return L6(Z,G)});if(J.forEach((Z)=>{this._removeIgnoredPath(Z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=J.length,Promise.all(J.map(async(Z)=>{let z=await this._nodeFsHandler._addToNodeFs(Z,!N,void 0,0,I);if(z)this._emitReady();return z})).then((Z)=>{if(this.closed)return;Z.forEach((z)=>{if(z)this.add(V.dirname(z),V.basename(I||z))})}),this}unwatch($){if(this.closed)return this;let I=q4($),{cwd:N}=this.options;return I.forEach((G)=>{if(!V.isAbsolute(G)&&!this._closers.has(G)){if(N)G=V.join(N,G);G=V.resolve(G)}if(this._closePath(G),this._addIgnoredPath(G),this._watched.has(G))this._addIgnoredPath({path:G,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((I)=>I.forEach((N)=>{let G=N();if(G instanceof Promise)$.push(G)})),this._streams.forEach((I)=>I.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((I)=>I.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=$.length?Promise.all($).then(()=>{return}):Promise.resolve(),this._closePromise}getWatched(){let $={};return this._watched.forEach((I,N)=>{let J=(this.options.cwd?V.relative(this.options.cwd,N):N)||g4;$[J]=I.getChildren().sort()}),$}emitWithAll($,I){if(this.emit($,...I),$!==y.ERROR)this.emit(y.ALL,$,...I)}async _emit($,I,N){if(this.closed)return;let G=this.options;if(F$)I=V.normalize(I);if(G.cwd)I=V.relative(G.cwd,I);let J=[I];if(N!=null)J.push(N);let Z=G.awaitWriteFinish,z;if(Z&&(z=this._pendingWrites.get(I)))return z.lastChange=new Date,this;if(G.atomic){if($===y.UNLINK)return this._pendingUnlinks.set(I,[$,...J]),setTimeout(()=>{this._pendingUnlinks.forEach((x,Q)=>{this.emit(...x),this.emit(y.ALL,...x),this._pendingUnlinks.delete(Q)})},typeof G.atomic==="number"?G.atomic:100),this;if($===y.ADD&&this._pendingUnlinks.has(I))$=y.CHANGE,this._pendingUnlinks.delete(I)}if(Z&&($===y.ADD||$===y.CHANGE)&&this._readyEmitted){let x=(Q,X)=>{if(Q)$=y.ERROR,J[0]=Q,this.emitWithAll($,J);else if(X){if(J.length>1)J[1]=X;else J.push(X);this.emitWithAll($,J)}};return this._awaitWriteFinish(I,Z.stabilityThreshold,$,x),this}if($===y.CHANGE){if(!this._throttle(y.CHANGE,I,50))return this}if(G.alwaysStat&&N===void 0&&($===y.ADD||$===y.ADD_DIR||$===y.CHANGE)){let x=G.cwd?V.join(G.cwd,I):I,Q;try{Q=await j6(x)}catch(X){}if(!Q||this.closed)return;J.push(Q)}return this.emitWithAll($,J),this}_handleError($){let I=$&&$.code;if($&&I!=="ENOENT"&&I!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||I!=="EPERM"&&I!=="EACCES"))this.emit(y.ERROR,$);return $||this.closed}_throttle($,I,N){if(!this._throttled.has($))this._throttled.set($,new Map);let G=this._throttled.get($);if(!G)throw Error("invalid throttle");let J=G.get(I);if(J)return J.count++,!1;let Z,z=()=>{let Q=G.get(I),X=Q?Q.count:0;if(G.delete(I),clearTimeout(Z),Q)clearTimeout(Q.timeoutObject);return X};Z=setTimeout(z,N);let x={timeoutObject:Z,clear:z,count:0};return G.set(I,x),x}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,I,N,G){let J=this.options.awaitWriteFinish;if(typeof J!=="object")return;let Z=J.pollInterval,z,x=$;if(this.options.cwd&&!V.isAbsolute($))x=V.join(this.options.cwd,$);let Q=new Date,X=this._pendingWrites;function j(M){M6(x,(R,S)=>{if(R||!X.has($)){if(R&&R.code!=="ENOENT")G(R);return}let Y=Number(new Date);if(M&&S.size!==M.size)X.get($).lastChange=Y;let K=X.get($);if(Y-K.lastChange>=I)X.delete($),G(void 0,S);else z=setTimeout(j,Z,S)})}if(!X.has($))X.set($,{lastChange:Q,cancelWait:()=>{return X.delete($),clearTimeout(z),N}}),z=setTimeout(j,Z)}_isIgnored($,I){if(this.options.atomic&&U6.test($))return!0;if(!this._userIgnored){let{cwd:N}=this.options,J=(this.options.ignored||[]).map(B4(N)),z=[...[...this._ignoredPaths].map(B4(N)),...J];this._userIgnored=g6(z,void 0)}return this._userIgnored($,I)}_isntIgnored($,I){return!this._isIgnored($,I)}_getWatchHelpers($){return new _4($,this.options.followSymlinks,this)}_getWatchedDir($){let I=V.resolve($);if(!this._watched.has(I))this._watched.set(I,new D4(I,this._boundRemove));return this._watched.get(I)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,I,N){let G=V.join($,I),J=V.resolve(G);if(N=N!=null?N:this._watched.has(G)||this._watched.has(J),!this._throttle("remove",G,100))return;if(!N&&this._watched.size===1)this.add($,I,!0);this._getWatchedDir(G).getChildren().forEach((M)=>this._remove(G,M));let x=this._getWatchedDir($),Q=x.has(I);if(x.remove(I),this._symlinkPaths.has(J))this._symlinkPaths.delete(J);let X=G;if(this.options.cwd)X=V.relative(this.options.cwd,G);if(this.options.awaitWriteFinish&&this._pendingWrites.has(X)){if(this._pendingWrites.get(X).cancelWait()===y.ADD)return}this._watched.delete(G),this._watched.delete(J);let j=N?y.UNLINK_DIR:y.UNLINK;if(Q&&!this._isIgnored(G))this._emit(j,G);this._closePath(G)}_closePath($){this._closeFile($);let I=V.dirname($);this._getWatchedDir(I).remove(V.basename($))}_closeFile($){let I=this._closers.get($);if(!I)return;I.forEach((N)=>N()),this._closers.delete($)}_addPathCloser($,I){if(!I)return;let N=this._closers.get($);if(!N)N=[],this._closers.set($,N);N.push(I)}_readdirp($,I){if(this.closed)return;let N={type:y.ALL,alwaysStat:!0,lstat:!0,...I,depth:0},G=M4($,N);return this._streams.add(G),G.once(R4,()=>{G=void 0}),G.once(P$,()=>{if(G)this._streams.delete(G),G=void 0}),G}}function A0($,I={}){let N=new V4(I);return N.add($),N}import{createServer as t9}from"node:http";import{readFileSync as e9,existsSync as $I,readdirSync as Q0,statSync as e$,mkdirSync as II}from"node:fs";import{join as z1,basename as O8}from"node:path";var d9=i(B8(),1),p9=i(b$(),1),s9=i(i$(),1),s$=i(b0(),1),o$=i(A8(),1);var h0=i(x1(),1),W8=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT):9847;function NI(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return z1($,".serena","memories");return z1(process.cwd(),".serena","memories")}function X0($){try{return e9($,"utf-8")}catch{return""}}function GI($){try{let I=Q0($);if(I.includes("orchestrator-session.md"))return z1($,"orchestrator-session.md");let N=I.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:e$(z1($,G)).mtimeMs})).sort((G,J)=>J.mtime-G.mtime);if(N.length>0)return z1($,N[0].name)}catch{}return null}function JI($){let I=GI($);if(!I)return{id:"N/A",status:"UNKNOWN"};let N=X0(I);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||O8(I,".md")||"N/A",J="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))J="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))J="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))J="FAILED";else if(/Step \d+:.*\[/i.test(N))J="RUNNING";return{id:G.trim(),status:J}}function ZI($){let I=X0(z1($,"task-board.md"));if(!I)return[];let N=[],G=I.split(`
|
|
30
|
-
`);for(let
|
|
31
|
-
`)
|
|
29
|
+
`+N)}function m1($,J,N,G,Z,z){if($.listenerCount("wsClientError")){let X=Error(Z);Error.captureStackTrace(X,m1),$.emit("wsClientError",X,N,J)}else C0(N,G,Z,z)}});var I4=k(M4(),1),{program:TN,createCommand:VN,createArgument:_N,createOption:CN,CommanderError:LN,InvalidArgumentError:AN,InvalidOptionArgumentError:DN,Command:Y4,Argument:PN,Option:SN,Help:WN}=I4.default;var V1=k(N1(),1);import{spawn as t5}from"node:child_process";import r from"node:fs";import O$ from"node:path";function x4($){try{return process.kill($,0),!0}catch(J){return!1}}async function H4($,J,N,G){let Z=O$.resolve(J),z=O$.resolve(G);if(!r.existsSync(Z))console.error(V1.default.red(`ERROR: Prompt file not found: ${Z}`)),process.exit(1);if(!r.existsSync(z))console.error(V1.default.red(`ERROR: Workspace directory not found: ${z}`)),process.exit(1);let X=`/tmp/subagent-${N}-${$}.log`,Q=`/tmp/subagent-${N}-${$}.pid`,M=r.readFileSync(Z,"utf-8"),I=r.openSync(X,"w");console.log(V1.default.blue(`[${$}] Spawning subagent...`)),console.log(V1.default.dim(` Workspace: ${z}`)),console.log(V1.default.dim(` Log: ${X}`));let K=t5("gemini",["-p",M,"--yolo"],{cwd:z,stdio:["ignore",I,I],detached:!1});if(!K.pid)console.error(V1.default.red(`[${$}] Failed to spawn process`)),process.exit(1);r.writeFileSync(Q,K.pid.toString()),console.log(V1.default.green(`[${$}] Started with PID ${K.pid}`));let Y=()=>{try{if(r.existsSync(Q))r.unlinkSync(Q);if(r.existsSync(X))r.unlinkSync(X)}catch(R){}},H=()=>{if(K.pid&&x4(K.pid))process.kill(K.pid);Y(),process.exit()};process.on("SIGINT",H),process.on("SIGTERM",H),K.on("exit",(R)=>{console.log(V1.default.blue(`[${$}] Exited with code ${R}`)),Y(),process.exit(R??0)})}async function R4($,J,N=process.cwd()){let G={};for(let Z of J){let z=O$.join(N,".serena","memories",`result-${Z}.md`),X=`/tmp/subagent-${$}-${Z}.pid`;if(r.existsSync(z)){let M=r.readFileSync(z,"utf-8").match(/^## Status:\s*(\S+)/m);if(M?.[1])G[Z]=M[1];else G[Z]="completed"}else if(r.existsSync(X)){let Q=r.readFileSync(X,"utf-8").trim(),M=parseInt(Q,10);if(!Number.isNaN(M)&&x4(M))G[Z]="running";else G[Z]="crashed"}else G[Z]="crashed"}for(let[Z,z]of Object.entries(G))console.log(`${Z}:${z}`)}import{spawn as e5}from"node:child_process";import $6 from"node:http";import J6 from"node:https";var N6="http://localhost:12341/sse";async function q4($){let J=$||N6,N=J.replace("/sse","/mcp"),G=new URL(J),z=G.protocol==="https:"?J6:$6,X=null,Q=!1;async function M(){return new Promise((U)=>{let T=z.get(J,(B)=>{U(!0),T.destroy()});T.on("error",()=>{U(!1)}),T.end()})}async function I(){let U=G.port||"12341",T=G.hostname||"0.0.0.0";if(console.error(`Starting Serena server on ${T}:${U}...`),X=e5("uvx",["--from","git+https://github.com/oraios/serena","serena-mcp-server","--host",T,"--port",U,"--context","ide","--open-web-dashboard","false"],{stdio:"pipe",detached:!1}),X.stderr)X.stderr.on("data",(_)=>{process.stderr.write(`[Serena] ${_}`)});X.on("error",(_)=>{console.error("Failed to start Serena server:",_),process.exit(1)}),X.on("exit",(_,A)=>{if(console.error(`Serena server exited with code ${_} signal ${A}`),!Q)process.exit(_||1)}),console.error("Waiting for Serena to be ready...");for(let _=0;_<30;_++){if(await M()){console.error("Serena server is ready!");return}await new Promise((A)=>setTimeout(A,1000))}console.error("Timed out waiting for Serena server to start."),process.exit(1)}if(!await M())await I();else console.error(`Connected to existing Serena server at ${J}`);function Y(){let U={method:"GET",headers:{Accept:"text/event-stream","Cache-Control":"no-cache"}},T=z.request(J,U,(B)=>{if(B.statusCode!==200){console.error(`SSE connection failed: ${B.statusCode}`);return}let _="";B.on("data",(A)=>{_+=A.toString();let L=_.split(`
|
|
30
|
+
`);_=L.pop()||"";let D="message",V="";for(let C of L)if(C.startsWith("event:"))D=C.slice(6).trim();else if(C.startsWith("data:"))V=C.slice(5).trim();else if(C===""&&V)H(D,V),D="message",V=""}),B.on("end",()=>{console.error("SSE connection closed, reconnecting..."),setTimeout(Y,1000)}),B.on("error",(A)=>{console.error("SSE error:",A.message),setTimeout(Y,1000)})});T.on("error",(B)=>{console.error("SSE connection error:",B.message),setTimeout(Y,1000)}),T.end()}function H(U,T){try{if(U==="message"||U==="endpoint")return;let B=JSON.parse(T);process.stdout.write(`${JSON.stringify(B)}
|
|
31
|
+
`)}catch(B){}}let R="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(U)=>{R+=U.toString();let T=R.split(`
|
|
32
|
+
`);R=T.pop()||"";for(let B of T)if(B.trim())x(B.trim())});function x(U){try{let T=JSON.parse(U),B=JSON.stringify(T),_=new URL(N),A={hostname:_.hostname,port:_.port,path:_.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(B)}},L=z.request(A,(D)=>{let V="";D.on("data",(C)=>{V+=C.toString()}),D.on("end",()=>{if(V.trim())process.stdout.write(`${V}
|
|
33
|
+
`)})});L.on("error",(D)=>{let V={jsonrpc:"2.0",id:T.id,error:{code:-32603,message:`Bridge error: ${D.message}`}};process.stdout.write(`${JSON.stringify(V)}
|
|
34
|
+
`)}),L.write(B),L.end()}catch(T){let B=T instanceof Error?T.message:String(T);console.error("Failed to parse IDE message:",B)}}Y(),process.stdin.resume();let j=()=>{if(Q=!0,X)console.error("Stopping Serena server..."),X.kill("SIGTERM");process.exit(0)};process.on("SIGINT",j),process.on("SIGTERM",j)}import{execSync as s}from"node:child_process";import{existsSync as J2,readdirSync as N2,readFileSync as G2}from"node:fs";import{join as I0}from"node:path";var G0=k(N1(),1),i=k(f$(),1);import{stdout as b$,stdin as C4}from"node:process";import*as A1 from"node:readline";import z6 from"node:readline";import{ReadStream as B4}from"node:tty";var X6=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,Q6=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,M6=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,y$=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,g0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,f0=/\t{1,1000}/y,E$=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,y0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,I6=/\p{M}+/gu,Y6={limit:1/0,ellipsis:""},L4=($,J={},N={})=>{let G=J.limit??1/0,Z=J.ellipsis??"",z=J?.ellipsisWidth??(Z?L4(Z,Y6,N).width:0),X=N.ansiWidth??0,Q=N.controlWidth??0,M=N.tabWidth??8,I=N.ambiguousWidth??1,K=N.emojiWidth??2,Y=N.fullWidthWidth??2,H=N.regularWidth??1,R=N.wideWidth??2,x=0,j=0,U=$.length,T=0,B=!1,_=U,A=Math.max(0,G-z),L=0,D=0,V=0,C=0;$:for(;;){if(D>L||j>=U&&j>x){let l=$.slice(L,D)||$.slice(x,j);T=0;for(let p of l.replaceAll(I6,"")){let o=p.codePointAt(0)||0;if(Q6(o)?C=Y:M6(o)?C=R:I!==H&&X6(o)?C=I:C=H,V+C>A&&(_=Math.min(_,Math.max(L,x)+T)),V+C>G){B=!0;break $}T+=p.length,V+=C}L=D=0}if(j>=U)break;if(y0.lastIndex=j,y0.test($)){if(T=y0.lastIndex-j,C=T*H,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/H))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=y0.lastIndex;continue}if(y$.lastIndex=j,y$.test($)){if(V+X>A&&(_=Math.min(_,j)),V+X>G){B=!0;break}V+=X,L=x,D=j,j=x=y$.lastIndex;continue}if(g0.lastIndex=j,g0.test($)){if(T=g0.lastIndex-j,C=T*Q,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/Q))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=g0.lastIndex;continue}if(f0.lastIndex=j,f0.test($)){if(T=f0.lastIndex-j,C=T*M,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/M))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=f0.lastIndex;continue}if(E$.lastIndex=j,E$.test($)){if(V+K>A&&(_=Math.min(_,j)),V+K>G){B=!0;break}V+=K,L=x,D=j,j=x=E$.lastIndex;continue}j+=1}return{width:B?A:V,index:B?_:U,truncated:B,ellipsed:B&&G>=z}},K6={limit:1/0,ellipsis:"",ellipsisWidth:0},Z0=($,J={})=>L4($,K6,J).width,w0="\x1B",A4="",j6=39,l$="\x07",D4="[",x6="]",P4="m",k$=`${x6}8;;`,T4=new RegExp(`(?:\\${D4}(?<code>\\d+)m|\\${k$}(?<uri>.*)${l$})`,"y"),H6=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},V4=($)=>`${w0}${D4}${$}${P4}`,_4=($)=>`${w0}${k$}${$}${l$}`,R6=($)=>$.map((J)=>Z0(J)),w$=($,J,N)=>{let G=J[Symbol.iterator](),Z=!1,z=!1,X=$.at(-1),Q=X===void 0?0:Z0(X),M=G.next(),I=G.next(),K=0;for(;!M.done;){let Y=M.value,H=Z0(Y);Q+H<=N?$[$.length-1]+=Y:($.push(Y),Q=0),(Y===w0||Y===A4)&&(Z=!0,z=J.startsWith(k$,K+1)),Z?z?Y===l$&&(Z=!1,z=!1):Y===P4&&(Z=!1):(Q+=H,Q===N&&!I.done&&($.push(""),Q=0)),M=I,I=G.next(),K+=Y.length}X=$.at(-1),!Q&&X!==void 0&&X.length>0&&$.length>1&&($[$.length-2]+=$.pop())},q6=($)=>{let J=$.split(" "),N=J.length;for(;N>0&&!(Z0(J[N-1])>0);)N--;return N===J.length?$:J.slice(0,N).join(" ")+J.slice(N).join("")},U6=($,J,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",Z,z,X=$.split(" "),Q=R6(X),M=[""];for(let[x,j]of X.entries()){N.trim!==!1&&(M[M.length-1]=(M.at(-1)??"").trimStart());let U=Z0(M.at(-1)??"");if(x!==0&&(U>=J&&(N.wordWrap===!1||N.trim===!1)&&(M.push(""),U=0),(U>0||N.trim===!1)&&(M[M.length-1]+=" ",U++)),N.hard&&Q[x]>J){let T=J-U,B=1+Math.floor((Q[x]-T-1)/J);Math.floor((Q[x]-1)/J)<B&&M.push(""),w$(M,j,J);continue}if(U+Q[x]>J&&U>0&&Q[x]>0){if(N.wordWrap===!1&&U<J){w$(M,j,J);continue}M.push("")}if(U+Q[x]>J&&N.wordWrap===!1){w$(M,j,J);continue}M[M.length-1]+=j}N.trim!==!1&&(M=M.map((x)=>q6(x)));let I=M.join(`
|
|
35
|
+
`),K=I[Symbol.iterator](),Y=K.next(),H=K.next(),R=0;for(;!Y.done;){let x=Y.value,j=H.value;if(G+=x,x===w0||x===A4){T4.lastIndex=R+1;let T=T4.exec(I)?.groups;if(T?.code!==void 0){let B=Number.parseFloat(T.code);Z=B===j6?void 0:B}else T?.uri!==void 0&&(z=T.uri.length===0?void 0:T.uri)}let U=Z?H6(Z):void 0;j===`
|
|
36
|
+
`?(z&&(G+=_4("")),Z&&U&&(G+=V4(U))):x===`
|
|
37
|
+
`&&(Z&&U&&(G+=V4(Z)),z&&(G+=_4(z))),R+=x.length,Y=H,H=K.next()}return G};function v$($,J,N){return String($).normalize().replaceAll(`\r
|
|
38
|
+
`,`
|
|
39
|
+
`).split(`
|
|
40
|
+
`).map((G)=>U6(G,J,N)).join(`
|
|
41
|
+
`)}var B6=["up","down","left","right","space","enter","cancel"],Q1={actions:new Set(B6),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function m$($,J){if(typeof $=="string")return Q1.aliases.get($)===J;for(let N of $)if(N!==void 0&&m$(N,J))return!0;return!1}function T6($,J){if($===J)return;let N=$.split(`
|
|
42
|
+
`),G=J.split(`
|
|
43
|
+
`),Z=Math.max(N.length,G.length),z=[];for(let X=0;X<Z;X++)N[X]!==G[X]&&z.push(X);return{lines:z,numLinesBefore:N.length,numLinesAfter:G.length,numLines:Z}}var V6=globalThis.process.platform.startsWith("win"),u$=Symbol("clack:cancel");function c($){return $===u$}function E0($,J){let N=$;N.isTTY&&N.setRawMode(J)}function S4({input:$=C4,output:J=b$,overwrite:N=!0,hideCursor:G=!0}={}){let Z=A1.createInterface({input:$,output:J,prompt:"",tabSize:1});A1.emitKeypressEvents($,Z),$ instanceof B4&&$.isTTY&&$.setRawMode(!0);let z=(X,{name:Q,sequence:M})=>{let I=String(X);if(m$([I,Q,M],"cancel")){G&&J.write(i.cursor.show),process.exit(0);return}if(!N)return;A1.moveCursor(J,Q==="return"?0:-1,Q==="return"?-1:0,()=>{A1.clearLine(J,1,()=>{$.once("keypress",z)})})};return G&&J.write(i.cursor.hide),$.once("keypress",z),()=>{$.off("keypress",z),G&&J.write(i.cursor.show),$ instanceof B4&&$.isTTY&&!V6&&$.setRawMode(!1),Z.terminal=!1,Z.close()}}var z0=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,h$=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20;function y1($,J,N,G=N){let Z=z0($??b$);return v$(J,Z-N.length,{hard:!0,trim:!1}).split(`
|
|
44
|
+
`).map((z,X)=>`${X===0?G:N}${z}`).join(`
|
|
45
|
+
`)}class E1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,J=!0){let{input:N=C4,output:G=b$,render:Z,signal:z,...X}=$;this.opts=X,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Z.bind(this),this._track=J,this._abortSignal=z,this.input=N,this.output=G}unsubscribe(){this._subscribers.clear()}setSubscriber($,J){let N=this._subscribers.get($)??[];N.push(J),this._subscribers.set($,N)}on($,J){this.setSubscriber($,{cb:J})}once($,J){this.setSubscriber($,{cb:J,once:!0})}emit($,...J){let N=this._subscribers.get($)??[],G=[];for(let Z of N)Z.cb(...J),Z.once&&G.push(()=>N.splice(N.indexOf(Z),1));for(let Z of G)Z()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(u$);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=z6.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),E0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(i.cursor.show),this.output.off("resize",this.render),E0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(i.cursor.show),this.output.off("resize",this.render),E0(this.input,!1),$(u$)})})}_isActionKey($,J){return $==="\t"}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,J){this.userInput=$??"",this.emit("userInput",this.userInput),J&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,J){if(this._track&&J.name!=="return"&&(J.name&&this._isActionKey($,J)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),J?.name&&(!this._track&&Q1.aliases.has(J.name)&&this.emit("cursor",Q1.aliases.get(J.name)),Q1.actions.has(J.name)&&this.emit("cursor",J.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$?.toLowerCase(),J),J?.name==="return"){if(this.opts.validate){let N=this.opts.validate(this.value);N&&(this.error=N instanceof Error?N.message:N,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}m$([$,J?.name,J?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
46
|
+
`),E0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=v$(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
47
|
+
`).length-1;this.output.write(i.cursor.move(-999,$*-1))}render(){let $=v$(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(i.cursor.hide);else{let J=T6(this._prevFrame,$),N=h$(this.output);if(this.restoreCursor(),J){let G=Math.max(0,J.numLinesAfter-N),Z=Math.max(0,J.numLinesBefore-N),z=J.lines.find((X)=>X>=G);if(z===void 0){this._prevFrame=$;return}if(J.lines.length===1){this.output.write(i.cursor.move(0,z-Z)),this.output.write(i.erase.lines(1));let X=$.split(`
|
|
48
|
+
`);this.output.write(X[z]),this._prevFrame=$,this.output.write(i.cursor.move(0,X.length-z-1));return}else if(J.lines.length>1){if(G<Z)z=G;else{let Q=z-Z;Q>0&&this.output.write(i.cursor.move(0,Q))}this.output.write(i.erase.down());let X=$.split(`
|
|
49
|
+
`).slice(z);this.output.write(X.join(`
|
|
50
|
+
`)),this._prevFrame=$;return}}this.output.write(i.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function _6($,J){if($===void 0||J.length===0)return 0;let N=J.findIndex((G)=>G.value===$);return N!==-1?N:0}function C6($,J){return(J.label??String(J.value)).toLowerCase().includes($.toLowerCase())}function L6($,J){if(J)return $?J:J[0]}class W4 extends E1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#N="";#G;#J;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return G0.default.inverse(G0.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[J,...N]=this.userInput.slice(this._cursor);return`${$}${G0.default.inverse(J)}${N.join("")}`}get options(){return typeof this.#J=="function"?this.#J():this.#J}constructor($){super($),this.#J=$.options;let J=this.options;this.filteredOptions=[...J],this.multiple=$.multiple===!0,this.#G=$.filter??C6;let N;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?N=$.initialValue:N=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(N=[this.options[0].value]),N)for(let G of N){let Z=J.findIndex((z)=>z.value===G);Z!==-1&&(this.toggleSelected(G),this.#$=Z)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(G,Z)=>this.#Z(G,Z)),this.on("userInput",(G)=>this.#z(G))}_isActionKey($,J){return $==="\t"||this.multiple&&this.isNavigating&&J.name==="space"&&$!==void 0&&$!==""}#Z($,J){let N=J.name==="up",G=J.name==="down",Z=J.name==="return";N||G?(this.#$=Math.max(0,Math.min(this.#$+(N?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Z?this.value=L6(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(J.name==="tab"||this.isNavigating&&J.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected($){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes($)?this.selectedValues=this.selectedValues.filter((J)=>J!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#z($){if($!==this.#N){this.#N=$;let J=this.options;$?this.filteredOptions=J.filter((N)=>this.#G($,N)):this.filteredOptions=[...J],this.#$=_6(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class c$ extends E1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(J)=>{this.output.write(i.cursor.move(0,-1)),this.value=J,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class F4 extends E1{options;cursor=0;#$;getGroupItems($){return this.options.filter((J)=>J.group===$)}isGroupSelected($){let J=this.getGroupItems($),N=this.value;return N===void 0?!1:J.every((G)=>N.includes(G.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let J=$.value,N=this.getGroupItems(J);this.isGroupSelected(J)?this.value=this.value.filter((G)=>N.findIndex((Z)=>Z.value===G)===-1):this.value=[...this.value,...N.map((G)=>G.value)],this.value=Array.from(new Set(this.value))}else{let J=this.value.includes($.value);this.value=J?this.value.filter((N)=>N!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:J}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(J).flatMap(([N,G])=>[{value:N,group:!0,label:N},...G.map((Z)=>({...Z,group:N}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),this.#$?0:1),this.on("cursor",(N)=>{switch(N){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function f1($,J,N){let G=$+J,Z=Math.max(N.length-1,0),z=G<0?Z:G>Z?0:G;return N[z].disabled?f1(z,J<0?-1:1,N):z}class d$ extends E1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,J=this.value!==void 0&&this.value.length===$.length;this.value=J?[]:$.map((N)=>N.value)}toggleInvert(){let $=this.value;if(!$)return;let J=this._enabledOptions.filter((N)=>!$.includes(N.value));this.value=J.map((N)=>N.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((J)=>J!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let J=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),0);this.cursor=this.options[J].disabled?f1(J,1,this.options):J,this.on("key",(N)=>{N==="a"&&this.toggleAll(),N==="i"&&this.toggleInvert()}),this.on("cursor",(N)=>{switch(N){case"left":case"up":this.cursor=f1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=f1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class i$ extends E1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let J=this.options.findIndex(({value:G})=>G===$.initialValue),N=J===-1?0:J;this.cursor=this.options[N].disabled?f1(N,1,this.options):N,this.changeValue(),this.on("cursor",(G)=>{switch(G){case"left":case"up":this.cursor=f1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=f1(this.cursor,1,this.options);break}this.changeValue()})}}class n$ extends E1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let J=$.slice(0,this.cursor),[N,...G]=$.slice(this.cursor);return`${J}${G0.default.inverse(N)}${G.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var q=k(N1(),1);import G1 from"node:process";var Q0=k(f$(),1);function A6(){return G1.platform!=="win32"?G1.env.TERM!=="linux":!!G1.env.CI||!!G1.env.WT_SESSION||!!G1.env.TERMINUS_SUBLIME||G1.env.ConEmuTask==="{cmd::Cmder}"||G1.env.TERM_PROGRAM==="Terminus-Sublime"||G1.env.TERM_PROGRAM==="vscode"||G1.env.TERM==="xterm-256color"||G1.env.TERM==="alacritty"||G1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var r$=A6(),D6=()=>process.env.CI==="true";var g=($,J)=>r$?$:J,P6=g("◆","*"),v4=g("■","x"),u4=g("▲","x"),m0=g("◇","o"),S6=g("┌","T"),W=g("│","|"),D1=g("└","—"),oN=g("┐","T"),rN=g("┘","—"),a$=g("●",">"),k0=g("○"," "),W6=g("◻","[•]"),O4=g("◼","[+]"),g4=g("◻","[ ]"),aN=g("▪","•"),f4=g("─","-"),F6=g("╮","+"),O6=g("├","+"),g6=g("╯","+"),f6=g("╰","+"),tN=g("╭","+"),y6=g("●","•"),E6=g("◆","*"),w6=g("▲","!"),v6=g("■","x"),h0=($)=>{switch($){case"initial":case"active":return q.default.cyan(P6);case"cancel":return q.default.red(v4);case"error":return q.default.yellow(u4);case"submit":return q.default.green(m0)}},b4=($)=>{switch($){case"initial":case"active":return q.default.cyan(W);case"cancel":return q.default.red(W);case"error":return q.default.yellow(W);case"submit":return q.default.green(W)}},u6=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,b6=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,l6=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,p$=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,v0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,u0=/\t{1,1000}/y,s$=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,b0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,k6=/\p{M}+/gu,m6={limit:1/0,ellipsis:""},l4=($,J={},N={})=>{let G=J.limit??1/0,Z=J.ellipsis??"",z=J?.ellipsisWidth??(Z?l4(Z,m6,N).width:0),X=N.ansiWidth??0,Q=N.controlWidth??0,M=N.tabWidth??8,I=N.ambiguousWidth??1,K=N.emojiWidth??2,Y=N.fullWidthWidth??2,H=N.regularWidth??1,R=N.wideWidth??2,x=0,j=0,U=$.length,T=0,B=!1,_=U,A=Math.max(0,G-z),L=0,D=0,V=0,C=0;$:for(;;){if(D>L||j>=U&&j>x){let l=$.slice(L,D)||$.slice(x,j);T=0;for(let p of l.replaceAll(k6,"")){let o=p.codePointAt(0)||0;if(b6(o)?C=Y:l6(o)?C=R:I!==H&&u6(o)?C=I:C=H,V+C>A&&(_=Math.min(_,Math.max(L,x)+T)),V+C>G){B=!0;break $}T+=p.length,V+=C}L=D=0}if(j>=U)break;if(b0.lastIndex=j,b0.test($)){if(T=b0.lastIndex-j,C=T*H,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/H))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=b0.lastIndex;continue}if(p$.lastIndex=j,p$.test($)){if(V+X>A&&(_=Math.min(_,j)),V+X>G){B=!0;break}V+=X,L=x,D=j,j=x=p$.lastIndex;continue}if(v0.lastIndex=j,v0.test($)){if(T=v0.lastIndex-j,C=T*Q,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/Q))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=v0.lastIndex;continue}if(u0.lastIndex=j,u0.test($)){if(T=u0.lastIndex-j,C=T*M,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/M))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=u0.lastIndex;continue}if(s$.lastIndex=j,s$.test($)){if(V+K>A&&(_=Math.min(_,j)),V+K>G){B=!0;break}V+=K,L=x,D=j,j=x=s$.lastIndex;continue}j+=1}return{width:B?A:V,index:B?_:U,truncated:B,ellipsed:B&&G>=z}},h6={limit:1/0,ellipsis:"",ellipsisWidth:0},H1=($,J={})=>l4($,h6,J).width,c0="\x1B",k4="",c6=39,e$="\x07",m4="[",d6="]",h4="m",$2=`${d6}8;;`,y4=new RegExp(`(?:\\${m4}(?<code>\\d+)m|\\${$2}(?<uri>.*)${e$})`,"y"),i6=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},E4=($)=>`${c0}${m4}${$}${h4}`,w4=($)=>`${c0}${$2}${$}${e$}`,n6=($)=>$.map((J)=>H1(J)),o$=($,J,N)=>{let G=J[Symbol.iterator](),Z=!1,z=!1,X=$.at(-1),Q=X===void 0?0:H1(X),M=G.next(),I=G.next(),K=0;for(;!M.done;){let Y=M.value,H=H1(Y);Q+H<=N?$[$.length-1]+=Y:($.push(Y),Q=0),(Y===c0||Y===k4)&&(Z=!0,z=J.startsWith($2,K+1)),Z?z?Y===e$&&(Z=!1,z=!1):Y===h4&&(Z=!1):(Q+=H,Q===N&&!I.done&&($.push(""),Q=0)),M=I,I=G.next(),K+=Y.length}X=$.at(-1),!Q&&X!==void 0&&X.length>0&&$.length>1&&($[$.length-2]+=$.pop())},p6=($)=>{let J=$.split(" "),N=J.length;for(;N>0&&!(H1(J[N-1])>0);)N--;return N===J.length?$:J.slice(0,N).join(" ")+J.slice(N).join("")},s6=($,J,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",Z,z,X=$.split(" "),Q=n6(X),M=[""];for(let[x,j]of X.entries()){N.trim!==!1&&(M[M.length-1]=(M.at(-1)??"").trimStart());let U=H1(M.at(-1)??"");if(x!==0&&(U>=J&&(N.wordWrap===!1||N.trim===!1)&&(M.push(""),U=0),(U>0||N.trim===!1)&&(M[M.length-1]+=" ",U++)),N.hard&&Q[x]>J){let T=J-U,B=1+Math.floor((Q[x]-T-1)/J);Math.floor((Q[x]-1)/J)<B&&M.push(""),o$(M,j,J);continue}if(U+Q[x]>J&&U>0&&Q[x]>0){if(N.wordWrap===!1&&U<J){o$(M,j,J);continue}M.push("")}if(U+Q[x]>J&&N.wordWrap===!1){o$(M,j,J);continue}M[M.length-1]+=j}N.trim!==!1&&(M=M.map((x)=>p6(x)));let I=M.join(`
|
|
51
|
+
`),K=I[Symbol.iterator](),Y=K.next(),H=K.next(),R=0;for(;!Y.done;){let x=Y.value,j=H.value;if(G+=x,x===c0||x===k4){y4.lastIndex=R+1;let T=y4.exec(I)?.groups;if(T?.code!==void 0){let B=Number.parseFloat(T.code);Z=B===c6?void 0:B}else T?.uri!==void 0&&(z=T.uri.length===0?void 0:T.uri)}let U=Z?i6(Z):void 0;j===`
|
|
52
|
+
`?(z&&(G+=w4("")),Z&&U&&(G+=E4(U))):x===`
|
|
53
|
+
`&&(Z&&U&&(G+=E4(Z)),z&&(G+=w4(z))),R+=x.length,Y=H,H=K.next()}return G};function M0($,J,N){return String($).normalize().replaceAll(`\r
|
|
54
|
+
`,`
|
|
55
|
+
`).split(`
|
|
56
|
+
`).map((G)=>s6(G,J,N)).join(`
|
|
57
|
+
`)}var o6=($,J,N,G,Z)=>{let z=J,X=0;for(let Q=N;Q<G;Q++){let M=$[Q];if(z=z-M.length,X++,z<=Z)break}return{lineCount:z,removals:X}},t$=($)=>{let{cursor:J,options:N,style:G}=$,Z=$.output??process.stdout,z=z0(Z),X=$.columnPadding??0,Q=$.rowPadding??4,M=z-X,I=h$(Z),K=q.default.dim("..."),Y=$.maxItems??Number.POSITIVE_INFINITY,H=Math.max(I-Q,0),R=Math.max(Math.min(Y,H),5),x=0;J>=R-3&&(x=Math.max(Math.min(J-R+3,N.length-R),0));let j=R<N.length&&x>0,U=R<N.length&&x+R<N.length,T=Math.min(x+R,N.length),B=[],_=0;j&&_++,U&&_++;let A=x+(j?1:0),L=T-(U?1:0);for(let V=A;V<L;V++){let C=M0(G(N[V],V===J),M,{hard:!0,trim:!1}).split(`
|
|
58
|
+
`);B.push(C),_+=C.length}if(_>H){let V=0,C=0,l=_,p=J-A,o=(g1,w)=>o6(B,l,g1,w,H);j?({lineCount:l,removals:V}=o(0,p),l>H&&({lineCount:l,removals:C}=o(p+1,B.length))):({lineCount:l,removals:C}=o(p+1,B.length),l>H&&({lineCount:l,removals:V}=o(0,p))),V>0&&(j=!0,B.splice(0,V)),C>0&&(U=!0,B.splice(B.length-C,C))}let D=[];j&&D.push(K);for(let V of B)for(let C of V)D.push(C);return U&&D.push(K),D};var w1=($)=>{let J=$.active??"Yes",N=$.inactive??"No";return new c$({active:J,inactive:N,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let G=`${q.default.gray(W)}
|
|
59
|
+
${h0(this.state)} ${$.message}
|
|
60
|
+
`,Z=this.value?J:N;switch(this.state){case"submit":return`${G}${q.default.gray(W)} ${q.default.dim(Z)}`;case"cancel":return`${G}${q.default.gray(W)} ${q.default.strikethrough(q.default.dim(Z))}
|
|
61
|
+
${q.default.gray(W)}`;default:return`${G}${q.default.cyan(W)} ${this.value?`${q.default.green(a$)} ${J}`:`${q.default.dim(k0)} ${q.default.dim(J)}`} ${q.default.dim("/")} ${this.value?`${q.default.dim(k0)} ${q.default.dim(N)}`:`${q.default.green(a$)} ${N}`}
|
|
62
|
+
${q.default.cyan(D1)}
|
|
63
|
+
`}}}).prompt()};var d={message:($=[],{symbol:J=q.default.gray(W),secondarySymbol:N=q.default.gray(W),output:G=process.stdout,spacing:Z=1,withGuide:z}={})=>{let X=[],Q=(z??Q1.withGuide)!==!1,M=Q?N:"",I=Q?`${J} `:"",K=Q?`${N} `:"";for(let H=0;H<Z;H++)X.push(M);let Y=Array.isArray($)?$:$.split(`
|
|
64
|
+
`);if(Y.length>0){let[H,...R]=Y;H.length>0?X.push(`${I}${H}`):X.push(Q?J:"");for(let x of R)x.length>0?X.push(`${K}${x}`):X.push(Q?N:"")}G.write(`${X.join(`
|
|
65
|
+
`)}
|
|
66
|
+
`)},info:($,J)=>{d.message($,{...J,symbol:q.default.blue(y6)})},success:($,J)=>{d.message($,{...J,symbol:q.default.green(E6)})},step:($,J)=>{d.message($,{...J,symbol:q.default.green(m0)})},warn:($,J)=>{d.message($,{...J,symbol:q.default.yellow(w6)})},warning:($,J)=>{d.warn($,J)},error:($,J)=>{d.message($,{...J,symbol:q.default.red(v6)})}},Z1=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(D1)} ${q.default.red($)}
|
|
67
|
+
|
|
68
|
+
`)},a=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(S6)} ${$}
|
|
69
|
+
`)},m=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(W)}
|
|
70
|
+
${q.default.gray(D1)} ${$}
|
|
71
|
+
|
|
72
|
+
`)},X0=($,J)=>$.split(`
|
|
73
|
+
`).map((N)=>J(N)).join(`
|
|
74
|
+
`),d0=($)=>{let J=(G,Z)=>{let z=G.label??String(G.value);return Z==="disabled"?`${q.default.gray(g4)} ${X0(z,(X)=>q.default.strikethrough(q.default.gray(X)))}${G.hint?` ${q.default.dim(`(${G.hint??"disabled"})`)}`:""}`:Z==="active"?`${q.default.cyan(W6)} ${z}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="selected"?`${q.default.green(O4)} ${X0(z,q.default.dim)}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="cancelled"?`${X0(z,(X)=>q.default.strikethrough(q.default.dim(X)))}`:Z==="active-selected"?`${q.default.green(O4)} ${z}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="submitted"?`${X0(z,q.default.dim)}`:`${q.default.dim(g4)} ${X0(z,q.default.dim)}`},N=$.required??!0;return new d$({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:N,cursorAt:$.cursorAt,validate(G){if(N&&(G===void 0||G.length===0))return`Please select at least one option.
|
|
75
|
+
${q.default.reset(q.default.dim(`Press ${q.default.gray(q.default.bgWhite(q.default.inverse(" space ")))} to select, ${q.default.gray(q.default.bgWhite(q.default.inverse(" enter ")))} to submit`))}`},render(){let G=y1($.output,$.message,`${b4(this.state)} `,`${h0(this.state)} `),Z=`${q.default.gray(W)}
|
|
76
|
+
${G}
|
|
77
|
+
`,z=this.value??[],X=(Q,M)=>{if(Q.disabled)return J(Q,"disabled");let I=z.includes(Q.value);return M&&I?J(Q,"active-selected"):I?J(Q,"selected"):J(Q,M?"active":"inactive")};switch(this.state){case"submit":{let Q=this.options.filter(({value:I})=>z.includes(I)).map((I)=>J(I,"submitted")).join(q.default.dim(", "))||q.default.dim("none"),M=y1($.output,Q,`${q.default.gray(W)} `);return`${Z}${M}`}case"cancel":{let Q=this.options.filter(({value:I})=>z.includes(I)).map((I)=>J(I,"cancelled")).join(q.default.dim(", "));if(Q.trim()==="")return`${Z}${q.default.gray(W)}`;let M=y1($.output,Q,`${q.default.gray(W)} `);return`${Z}${M}
|
|
78
|
+
${q.default.gray(W)}`}case"error":{let Q=`${q.default.yellow(W)} `,M=this.error.split(`
|
|
79
|
+
`).map((Y,H)=>H===0?`${q.default.yellow(D1)} ${q.default.yellow(Y)}`:` ${Y}`).join(`
|
|
80
|
+
`),I=Z.split(`
|
|
81
|
+
`).length,K=M.split(`
|
|
82
|
+
`).length+1;return`${Z}${Q}${t$({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:I+K,style:X}).join(`
|
|
83
|
+
${Q}`)}
|
|
84
|
+
${M}
|
|
85
|
+
`}default:{let Q=`${q.default.cyan(W)} `,M=Z.split(`
|
|
86
|
+
`).length;return`${Z}${Q}${t$({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:M+2,style:X}).join(`
|
|
87
|
+
${Q}`)}
|
|
88
|
+
${q.default.cyan(D1)}
|
|
89
|
+
`}}}}).prompt()},r6=($)=>q.default.dim($),a6=($,J,N)=>{let G={hard:!0,trim:!1},Z=M0($,J,G).split(`
|
|
90
|
+
`),z=Z.reduce((M,I)=>Math.max(H1(I),M),0),X=Z.map(N).reduce((M,I)=>Math.max(H1(I),M),0),Q=J-(X-z);return M0($,Q,G)},O=($="",J="",N)=>{let G=N?.output??G1.stdout,Z=(N?.withGuide??Q1.withGuide)!==!1,z=N?.format??r6,X=["",...a6($,z0(G)-6,z).split(`
|
|
91
|
+
`).map(z),""],Q=H1(J),M=Math.max(X.reduce((H,R)=>{let x=H1(R);return x>H?x:H},0),Q)+2,I=X.map((H)=>`${q.default.gray(W)} ${H}${" ".repeat(M-H1(H))}${q.default.gray(W)}`).join(`
|
|
92
|
+
`),K=Z?`${q.default.gray(W)}
|
|
93
|
+
`:"",Y=Z?O6:f6;G.write(`${K}${q.default.green(m0)} ${q.default.reset(J)} ${q.default.gray(f4.repeat(Math.max(M-Q-1,1))+F6)}
|
|
94
|
+
${I}
|
|
95
|
+
${q.default.gray(Y+f4.repeat(M+2)+g6)}
|
|
96
|
+
`)};var t6=q.default.magenta,h1=({indicator:$="dots",onCancel:J,output:N=process.stdout,cancelMessage:G,errorMessage:Z,frames:z=r$?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=r$?80:120,signal:Q,...M}={})=>{let I=D6(),K,Y,H=!1,R=!1,x="",j,U=performance.now(),T=z0(N),B=M?.styleFrame??t6,_=(w)=>{let J1=w>1?Z??Q1.messages.error:G??Q1.messages.cancel;R=w===1,H&&(g1(J1,w),R&&typeof J=="function"&&J())},A=()=>_(2),L=()=>_(1),D=()=>{process.on("uncaughtExceptionMonitor",A),process.on("unhandledRejection",A),process.on("SIGINT",L),process.on("SIGTERM",L),process.on("exit",_),Q&&Q.addEventListener("abort",L)},V=()=>{process.removeListener("uncaughtExceptionMonitor",A),process.removeListener("unhandledRejection",A),process.removeListener("SIGINT",L),process.removeListener("SIGTERM",L),process.removeListener("exit",_),Q&&Q.removeEventListener("abort",L)},C=()=>{if(j===void 0)return;I&&N.write(`
|
|
97
|
+
`);let w=M0(j,T,{hard:!0,trim:!1}).split(`
|
|
98
|
+
`);w.length>1&&N.write(Q0.cursor.up(w.length-1)),N.write(Q0.cursor.to(0)),N.write(Q0.erase.down())},l=(w)=>w.replace(/\.+$/,""),p=(w)=>{let J1=(performance.now()-w)/1000,U1=Math.floor(J1/60),B1=Math.floor(J1%60);return U1>0?`[${U1}m ${B1}s]`:`[${B1}s]`},o=(w="")=>{H=!0,K=S4({output:N}),x=l(w),U=performance.now(),N.write(`${q.default.gray(W)}
|
|
99
|
+
`);let J1=0,U1=0;D(),Y=setInterval(()=>{if(I&&x===j)return;C(),j=x;let B1=B(z[J1]),S0;if(I)S0=`${B1} ${x}...`;else if($==="timer")S0=`${B1} ${x} ${p(U)}`;else{let J5=".".repeat(Math.floor(U1)).slice(0,3);S0=`${B1} ${x}${J5}`}let $5=M0(S0,T,{hard:!0,trim:!1});N.write($5),J1=J1+1<z.length?J1+1:0,U1=U1<4?U1+0.125:0},X)},g1=(w="",J1=0,U1=!1)=>{if(!H)return;H=!1,clearInterval(Y),C();let B1=J1===0?q.default.green(m0):J1===1?q.default.red(v4):q.default.red(u4);x=w??x,U1||($==="timer"?N.write(`${B1} ${x} ${p(U)}
|
|
100
|
+
`):N.write(`${B1} ${x}
|
|
101
|
+
`)),V(),K()};return{start:o,stop:(w="")=>g1(w,0),message:(w="")=>{x=l(w??x)},cancel:(w="")=>g1(w,1),error:(w="")=>g1(w,2),clear:()=>g1("",0,!0),get isCancelled(){return R}}},eN={light:g("─","-"),heavy:g("━","="),block:g("█","#")};var l0=($,J)=>$.includes(`
|
|
102
|
+
`)?$.split(`
|
|
103
|
+
`).map((N)=>J(N)).join(`
|
|
104
|
+
`):J($),c1=($)=>{let J=(N,G)=>{let Z=N.label??String(N.value);switch(G){case"disabled":return`${q.default.gray(k0)} ${l0(Z,q.default.gray)}${N.hint?` ${q.default.dim(`(${N.hint??"disabled"})`)}`:""}`;case"selected":return`${l0(Z,q.default.dim)}`;case"active":return`${q.default.green(a$)} ${Z}${N.hint?` ${q.default.dim(`(${N.hint})`)}`:""}`;case"cancelled":return`${l0(Z,(z)=>q.default.strikethrough(q.default.dim(z)))}`;default:return`${q.default.dim(k0)} ${l0(Z,q.default.dim)}`}};return new i$({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let N=`${h0(this.state)} `,G=`${b4(this.state)} `,Z=y1($.output,$.message,G,N),z=`${q.default.gray(W)}
|
|
105
|
+
${Z}
|
|
106
|
+
`;switch(this.state){case"submit":{let X=`${q.default.gray(W)} `,Q=y1($.output,J(this.options[this.cursor],"selected"),X);return`${z}${Q}`}case"cancel":{let X=`${q.default.gray(W)} `,Q=y1($.output,J(this.options[this.cursor],"cancelled"),X);return`${z}${Q}
|
|
107
|
+
${q.default.gray(W)}`}default:{let X=`${q.default.cyan(W)} `,Q=z.split(`
|
|
108
|
+
`).length;return`${z}${X}${t$({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:X.length,rowPadding:Q+2,style:(M,I)=>J(M,M.disabled?"disabled":I?"active":"inactive")}).join(`
|
|
109
|
+
${X}`)}
|
|
110
|
+
${q.default.cyan(D1)}
|
|
111
|
+
`}}}}).prompt()};var $G=`${q.default.gray(W)} `;var i0=($)=>new n$({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let J=($?.withGuide??Q1.withGuide)!==!1,N=`${`${J?`${q.default.gray(W)}
|
|
112
|
+
`:""}${h0(this.state)} `}${$.message}
|
|
113
|
+
`,G=$.placeholder?q.default.inverse($.placeholder[0])+q.default.dim($.placeholder.slice(1)):q.default.inverse(q.default.hidden("_")),Z=this.userInput?this.userInputWithCursor:G,z=this.value??"";switch(this.state){case"error":{let X=this.error?` ${q.default.yellow(this.error)}`:"",Q=J?`${q.default.yellow(W)} `:"",M=J?q.default.yellow(D1):"";return`${N.trim()}
|
|
114
|
+
${Q}${Z}
|
|
115
|
+
${M}${X}
|
|
116
|
+
`}case"submit":{let X=z?` ${q.default.dim(z)}`:"",Q=J?q.default.gray(W):"";return`${N}${Q}${X}`}case"cancel":{let X=z?` ${q.default.strikethrough(q.default.dim(z))}`:"",Q=J?q.default.gray(W):"";return`${N}${Q}${X}${z.trim()?`
|
|
117
|
+
${Q}`:""}`}default:{let X=J?`${q.default.cyan(W)} `:"",Q=J?q.default.cyan(D1):"";return`${N}${X}${Z}
|
|
118
|
+
${Q}
|
|
119
|
+
`}}}}).prompt();var t=k(N1(),1);async function c4($=!1,J=!1){let N=process.cwd(),G=I0(N,".agent","results"),Z="/tmp",z={cleaned:0,skipped:0,details:[]},X=(I)=>{z.details.push($?`[DRY-RUN] ${I}`:`[CLEAN] ${I}`),z.cleaned++},Q=(I)=>{z.details.push(`[SKIP] ${I}`),z.skipped++};try{let I=N2("/tmp").filter((K)=>K.startsWith("subagent-")&&K.endsWith(".pid"));for(let K of I){let Y=I0("/tmp",K),H=G2(Y,"utf-8").trim();if(!H){if(X(`Removing empty PID file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}continue}let R=parseInt(H,10);if(Number.isNaN(R)){if(X(`Removing invalid PID file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}continue}try{if(s(`kill -0 ${R} 2>/dev/null`),X(`Killing orphaned process PID=${R} (from ${Y})`),!$)try{s(`kill ${R} 2>/dev/null || true`),await new Promise((x)=>setTimeout(x,1000));try{s(`kill -0 ${R} 2>/dev/null`),s(`kill -9 ${R} 2>/dev/null || true`)}catch{}s(`rm -f "${Y}"`)}catch{}}catch{if(X(`Removing stale PID file (process gone): ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}}}catch{}try{let I=N2("/tmp").filter((K)=>K.startsWith("subagent-")&&K.endsWith(".log"));for(let K of I){let Y=I0("/tmp",K),H=K.replace(".log",".pid"),R=I0("/tmp",H);if(J2(R))try{let x=G2(R,"utf-8").trim(),j=parseInt(x,10);if(!Number.isNaN(j)){s(`kill -0 ${j} 2>/dev/null`),Q(`Log file has active process: ${Y}`);continue}}catch{}if(X(`Removing stale log file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}}catch{}if(J2(G))try{let I=N2(G).filter((K)=>K.startsWith("parallel-"));for(let K of I){let Y=I0(G,K,"pids.txt");if(!J2(Y))continue;let R=G2(Y,"utf-8").split(`
|
|
120
|
+
`).filter((j)=>j.trim()),x=!1;for(let j of R){let[U,T]=j.split(":"),B=parseInt(U?.trim()||"",10);if(Number.isNaN(B))continue;try{if(s(`kill -0 ${B} 2>/dev/null`),x=!0,X(`Killing orphaned parallel agent PID=${B} (${T?.trim()||"unknown"})`),!$)try{s(`kill ${B} 2>/dev/null || true`),s(`rm -f "${Y}"`)}catch{}}catch{}}if(!x){if(X(`Removing stale PID list: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}else if(!$){await new Promise((j)=>setTimeout(j,1000));try{s(`rm -f "${Y}"`)}catch{}}}}catch{}else Q(`No results directory found: ${G}`);if(J){console.log(JSON.stringify(z,null,2));return}if(console.clear(),a(t.default.bgMagenta(t.default.white(" \uD83E\uDDF9 oh-my-ag cleanup "))),$)O(t.default.yellow("Dry-run mode — no changes will be made"),"Mode");if(z.details.length>0){let I=[t.default.bold("Cleanup Details"),...z.details.map((K)=>{if(K.startsWith("[DRY-RUN]"))return t.default.yellow(K);if(K.startsWith("[CLEAN]"))return t.default.green(K);return t.default.cyan(K)})].join(`
|
|
121
|
+
`);O(I,"Details")}let M=[t.default.bold("Summary"),"┌─────────┬────────┐",`│ ${t.default.bold("Action")} │ ${t.default.bold("Count")} │`,"├─────────┼────────┤",`│ Cleaned │ ${String(z.cleaned).padEnd(6)} │`,`│ Skipped │ ${String(z.skipped).padEnd(6)} │`,"└─────────┴────────┘"].join(`
|
|
122
|
+
`);if(O(M,"Results"),$)m(t.default.yellow("Run without --dry-run to apply changes"));else m(t.default.green("Cleanup complete!"))}import{execSync as J9}from"node:child_process";import{existsSync as j0,readdirSync as N9,readFileSync as G9}from"node:fs";import{join as a0}from"node:path";var F=k(N1(),1);import{existsSync as n0,mkdirSync as p0,writeFileSync as Y0}from"node:fs";import{dirname as e6,join as R1}from"node:path";var K0="first-fluke/oh-my-ag",z2=`https://raw.githubusercontent.com/${K0}/main/.agent/skills`,Z2=`https://raw.githubusercontent.com/${K0}/main/.agent`,i1={domain:[{name:"frontend-agent",desc:"React/Next.js UI specialist"},{name:"backend-agent",desc:"FastAPI/SQLAlchemy API specialist"},{name:"mobile-agent",desc:"Flutter/Dart mobile specialist"}],coordination:[{name:"pm-agent",desc:"Product manager - task decomposition"},{name:"qa-agent",desc:"QA - OWASP, Lighthouse, WCAG"},{name:"workflow-guide",desc:"Manual multi-agent orchestration"},{name:"orchestrator",desc:"Automated parallel CLI execution"}],utility:[{name:"debug-agent",desc:"Bug fixing specialist"},{name:"commit",desc:"Conventional Commits helper"}]},d4={fullstack:["frontend-agent","backend-agent","pm-agent","qa-agent","debug-agent","commit"],frontend:["frontend-agent","pm-agent","qa-agent","debug-agent","commit"],backend:["backend-agent","pm-agent","qa-agent","debug-agent","commit"],mobile:["mobile-agent","pm-agent","qa-agent","debug-agent","commit"],all:[...i1.domain,...i1.coordination,...i1.utility].map(($)=>$.name)};async function $9($){let J=["SKILL.md"],N=["resources/execution-protocol.md","resources/tech-stack.md","resources/checklist.md","resources/templates.md","resources/error-playbook.md"];for(let G of N){let Z=`${z2}/${$}/${G}`;if((await fetch(Z,{method:"HEAD"})).ok)J.push(G)}return J}async function s0($,J){let N=R1(J,".agent","skills",$),G=await $9($);for(let Z of G){let z=`${z2}/${$}/${Z}`,X=await fetch(z);if(!X.ok)continue;let Q=await X.text(),M=R1(N,Z),I=e6(M);if(!n0(I))p0(I,{recursive:!0});Y0(M,Q,"utf-8")}return!0}async function o0($){let J=R1($,".agent","skills","_shared"),N=["reasoning-templates.md","clarification-protocol.md","context-loading.md","skill-routing.md"];if(!n0(J))p0(J,{recursive:!0});for(let G of N){let Z=`${z2}/_shared/${G}`,z=await fetch(Z);if(!z.ok)continue;let X=await z.text();Y0(R1(J,G),X,"utf-8")}}async function i4($){let J=R1($,".agent","workflows"),N=["coordinate.md","debug.md","orchestrate.md","plan.md","review.md","setup.md","tools.md"];if(!n0(J))p0(J,{recursive:!0});for(let G of N){let Z=`${Z2}/workflows/${G}`,z=await fetch(Z);if(!z.ok)continue;let X=await z.text();Y0(R1(J,G),X,"utf-8")}}async function n4($){let J=R1($,".agent","config"),N=R1($,".agent");if(!n0(J))p0(J,{recursive:!0});let G="user-preferences.yaml",Z=`${Z2}/config/${G}`,z=await fetch(Z);if(z.ok){let I=await z.text();Y0(R1(J,G),I,"utf-8")}let X="mcp.json",Q=`${Z2}/${X}`,M=await fetch(Q);if(M.ok){let I=await M.text();Y0(R1(N,X),I,"utf-8")}}function n1(){return[...i1.domain,...i1.coordination,...i1.utility]}async function r0($,J,N){try{let G=J9(`${J} --version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();return{name:$,installed:!0,version:G,installCmd:N}}catch{return{name:$,installed:!1,installCmd:N}}}async function Z9($){let J=process.env.HOME||process.env.USERPROFILE||"",G={gemini:{path:`${J}/.gemini/settings.json`,type:"json"},claude:{path:`${J}/.claude.json`,type:"json"},codex:{path:`${J}/.codex/config.toml`,type:"toml"}}[$];if(!G)return{configured:!1};if(j0(G.path))try{let Z=G9(G.path,"utf-8");if(G.type==="json"){let z=JSON.parse(Z);return{configured:!!(z.mcpServers||z.mcp),path:G.path}}return{configured:!0,path:G.path}}catch{return{configured:!1}}return{configured:!1}}async function z9(){let $=a0(process.cwd(),".agent","skills");if(!j0($))return[];let J=n1(),N=[];for(let G of J){let Z=a0($,G.name),z=a0(Z,"SKILL.md");N.push({name:G.name,installed:j0(Z),hasSkillMd:j0(z)})}return N}async function p4($=!1){let J=process.cwd(),N=await Promise.all([r0("gemini","gemini","bun install --global @anthropic-ai/gemini-cli"),r0("claude","claude","bun install --global @anthropic-ai/claude-code"),r0("codex","codex","bun install --global @openai/codex"),r0("qwen","qwen","bun install --global @qwen-code/qwen-code")]),G=await Promise.all(N.filter((H)=>H.installed).map(async(H)=>{let R=await Z9(H.name);return{...H,mcp:R}})),Z=await z9(),z=a0(J,".serena","memories"),X=j0(z),Q=0;if(X)try{Q=N9(z).length}catch{}let M=N.filter((H)=>!H.installed),I=Z.length>0?Z.filter((H)=>!H.installed||!H.hasSkillMd):n1().map((H)=>({name:H.name,installed:!1,hasSkillMd:!1})),K=M.length+G.filter((H)=>!H.mcp.configured).length+I.length;if($){let H={ok:K===0,issues:K,clis:N.map((R)=>({name:R.name,installed:R.installed,version:R.version||null})),mcp:G.map((R)=>({name:R.name,configured:R.mcp.configured,path:R.mcp.path||null})),skills:Z.length>0?Z.map((R)=>({name:R.name,installed:R.installed,complete:R.hasSkillMd})):[],missingSkills:I.map((R)=>R.name),serena:{exists:X,fileCount:Q}};console.log(JSON.stringify(H,null,2)),process.exit(K===0?0:1)}console.clear(),a(F.default.bgMagenta(F.default.white(" \uD83E\uDE7A oh-my-ag doctor ")));let Y=h1();try{let H=[F.default.bold("\uD83D\uDD0D CLI Installation Status"),"┌─────────┬──────────┬─────────────┐",`│ ${F.default.bold("CLI")} │ ${F.default.bold("Status")} │ ${F.default.bold("Version")} │`,"├─────────┼──────────┼─────────────┤",...N.map((j)=>{let U=j.installed?F.default.green("✅ Installed"):F.default.red("❌ Missing"),T=j.version||"-";return`│ ${j.name.padEnd(7)} │ ${U.padEnd(8)} │ ${T.padEnd(11)} │`}),"└─────────┴──────────┴─────────────┘"].join(`
|
|
123
|
+
`);if(O(H,"CLI Status"),M.length>0)O(M.map((j)=>`${F.default.yellow("→")} ${j.name}: ${F.default.dim(j.installCmd)}`).join(`
|
|
124
|
+
`),"Install missing CLIs");if(G.length>0){let j=[F.default.bold("\uD83D\uDD17 MCP Connection Status"),"┌─────────┬──────────┬─────────────────────┐",`│ ${F.default.bold("CLI")} │ ${F.default.bold("MCP Config")} │ ${F.default.bold("Path")} │`,"├─────────┼──────────┼─────────────────────┤",...G.map((U)=>{let T=U.mcp.configured?F.default.green("✅ Configured"):F.default.yellow("⚠️ Not configured"),B=U.mcp.path?U.mcp.path.split("/").pop()||"":"-";return`│ ${U.name.padEnd(7)} │ ${T.padEnd(8)} │ ${B.padEnd(19)} │`}),"└─────────┴──────────┴─────────────────────┘"].join(`
|
|
125
|
+
`);O(j,"MCP Status")}let R=Z.filter((j)=>j.installed).length,x=Z.filter((j)=>j.hasSkillMd).length;if(Z.length>0){let j=[F.default.bold(`\uD83D\uDCE6 Skills (${R}/${Z.length} installed, ${x} complete)`),"┌────────────────────┬──────────┬─────────────┐",`│ ${F.default.bold("Skill")} │ ${F.default.bold("Installed")} │ ${F.default.bold("SKILL.md")} │`,"├────────────────────┼──────────┼─────────────┤",...Z.map((U)=>{let T=U.installed?F.default.green("✅"):F.default.red("❌"),B=U.hasSkillMd?F.default.green("✅"):F.default.red("❌");return`│ ${U.name.padEnd(18)} │ ${T.padEnd(8)} │ ${B.padEnd(11)} │`}),"└────────────────────┴──────────┴─────────────┘"].join(`
|
|
126
|
+
`);O(j,"Skills Status")}else O(F.default.yellow("No skills installed."),"Skills Status");if(I.length>0){let j=await w1({message:`Found ${I.length} missing/incomplete skill(s). Install them?`,initialValue:!0});if(c(j))Z1("Cancelled."),process.exit(0);if(j){let U=I.map((_)=>_.name),T=await c1({message:"Which skills to install?",options:[{value:"all",label:`✨ All (${U.length} skills)`,hint:"Recommended"},{value:"select",label:"\uD83D\uDD27 Select individually"}]});if(c(T))Z1("Cancelled."),process.exit(0);let B;if(T==="select"){let _=n1(),A=await d0({message:"Select skills to install:",options:I.map((L)=>{let D=_.find((V)=>V.name===L.name);return{value:L.name,label:L.name,hint:D?.desc||""}}),required:!0});if(c(A))Z1("Cancelled."),process.exit(0);B=A}else B=U;Y.start("Installing skills...");try{await o0(J);for(let _ of B)Y.message(`Installing ${F.default.cyan(_)}...`),await s0(_,J);Y.stop(`Installed ${B.length} skill(s)!`),O(B.map((_)=>`${F.default.green("✓")} ${_}`).join(`
|
|
127
|
+
`),"Installed Skills")}catch(_){Y.stop("Installation failed"),d.error(_ instanceof Error?_.message:String(_))}}}if(X)O(`${F.default.green("✅")} Serena memory directory exists
|
|
128
|
+
${F.default.dim(`${Q} memory files found`)}`,"Serena Memory");else O(`${F.default.yellow("⚠️")} Serena memory directory not found
|
|
129
|
+
${F.default.dim("Dashboard will show 'No agents detected'")}`,"Serena Memory");if(K===0)m(F.default.green("✅ All checks passed! Ready to use."));else m(F.default.yellow(`⚠️ Found ${K} issue(s). See details above.`))}catch(H){if(Y)Y.stop("Check failed");d.error(H instanceof Error?H.message:String(H)),process.exit(1)}}import{existsSync as s4,readFileSync as o4,writeFileSync as r4}from"node:fs";import{join as X2}from"node:path";var M1=k(N1(),1);async function a4(){console.clear(),a(M1.default.bgMagenta(M1.default.white(" \uD83D\uDEF8 oh-my-ag ")));let $=await c1({message:"What type of project?",options:[{value:"all",label:"✨ All",hint:"Install everything"},{value:"fullstack",label:"\uD83C\uDF10 Fullstack",hint:"Frontend + Backend + PM + QA"},{value:"frontend",label:"\uD83C\uDFA8 Frontend",hint:"React/Next.js"},{value:"backend",label:"⚙️ Backend",hint:"FastAPI/Python"},{value:"mobile",label:"\uD83D\uDCF1 Mobile",hint:"Flutter/Dart"},{value:"custom",label:"\uD83D\uDD27 Custom",hint:"Choose skills"}]});if(c($))Z1("Cancelled."),process.exit(0);let J;if($==="custom"){let Z=n1(),z=await d0({message:"Select skills:",options:Z.map((X)=>({value:X.name,label:X.name,hint:X.desc})),required:!0});if(c(z))Z1("Cancelled."),process.exit(0);J=z}else J=d4[$]??[];let N=process.cwd(),G=h1();G.start("Installing skills...");try{await o0(N),await i4(N),await n4(N);for(let Y of J)G.message(`Installing ${M1.default.cyan(Y)}...`),await s0(Y,N);G.stop("Skills installed!"),O([...J.map((Y)=>`${M1.default.green("✓")} ${Y}`),"",M1.default.dim(`Location: ${X2(N,".agent","skills")}`)].join(`
|
|
130
|
+
`),"Installed"),m(M1.default.green("Done! Open your project in your IDE to use the skills.")),O(`${M1.default.yellow("❤️")} Enjoying oh-my-ag? Give it a star!
|
|
131
|
+
${M1.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Support");let Z=process.env.HOME||process.env.USERPROFILE||"",z=X2(Z,".gemini","antigravity","mcp_config.json"),X=null,Q=!1;try{if(s4(z)){let Y=o4(z,"utf-8");X=JSON.parse(Y),Q=!0}}catch(Y){}if(Q&&X&&X.mcpServers){let Y=X.mcpServers.serena,H="oh-my-ag@latest";if(!(Y&&Y.command==="npx"&&Array.isArray(Y.args)&&Y.args.includes("oh-my-ag@latest")&&Y.args.includes("bridge"))){let x=await w1({message:"Configure Serena MCP with bridge? (Required for full functionality)",initialValue:!0});if(c(x));else if(x){X.mcpServers.serena={command:"npx",args:["-y","oh-my-ag@latest","bridge","http://localhost:12341/sse"],disabled:!1};try{r4(z,JSON.stringify(X,null,2)),d.success(M1.default.green("Serena MCP configured successfully!"))}catch(j){d.error(`Failed to update MCP config: ${j}`)}}}}let M=X2(Z,".gemini","settings.json"),I=null,K=!1;try{if(s4(M)){let Y=o4(M,"utf-8");I=JSON.parse(Y),K=!0}}catch(Y){}if(K&&I&&I.mcpServers){let Y=I.mcpServers.serena;if(!(Y&&Y.url==="http://localhost:12341/sse")){let R=await w1({message:"Configure Serena for Gemini CLI? (SSE Mode)",initialValue:!0});if(c(R));else if(R){I.mcpServers.serena={url:"http://localhost:12341/sse"};try{r4(M,JSON.stringify(I,null,2)),d.success(M1.default.green("Gemini CLI configured successfully!"))}catch(x){d.error(`Failed to update Gemini config: ${x}`)}}}}}catch(Z){G.stop("Installation failed"),d.error(Z instanceof Error?Z.message:String(Z)),process.exit(1)}}import{existsSync as I8,mkdirSync as Q9,readdirSync as M9,readFileSync as I9,writeFileSync as Y9}from"node:fs";import{join as K2}from"node:path";var y=k(N1(),1);import{execSync as v1}from"node:child_process";function t0($){try{let N=v1("git diff --stat HEAD~10 2>/dev/null || git diff --stat",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
132
|
+
`),G=N[N.length-1]||"",Z=G.match(/(\d+) files? changed/),z=G.match(/(\d+) insertions?\(\+\)/),X=G.match(/(\d+) deletions?\(-\)/);return{filesChanged:Z?.[1]?parseInt(Z[1],10):0,linesAdded:z?.[1]?parseInt(z[1],10):0,linesRemoved:X?.[1]?parseInt(X[1],10):0}}catch{return{filesChanged:0,linesAdded:0,linesRemoved:0}}}function e4($,J=5){try{return v1(`git log --oneline -${J} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
133
|
+
`).filter(Boolean)}catch{return[]}}function e0($){try{return v1("git diff --name-only HEAD~5 2>/dev/null || git diff --name-only",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
134
|
+
`).filter(Boolean).slice(0,10)}catch{return[]}}function t4($,J=10){try{return v1(`git log --format="%s" -${J} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
135
|
+
`).filter(Boolean)}catch{return[]}}function $8($){let J={},N=/^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\(.+\))?:/;for(let G of $){let Z=G.match(N);if(Z){let z=Z[1];if(z)J[z]=(J[z]||0)+1}}return J}function J8($){try{let J=`${$}/.serena/retrospectives`,N=v1(`ls -t "${J}"/*.json 2>/dev/null | head -1`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();if(!N)return null;let G=v1(`cat "${N}"`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]});return JSON.parse(G).date||null}catch{return null}}function N8($,J){if(!J)return t4($,10);try{let G=new Date(J).toISOString().split("T")[0];return v1(`git log --format="%s" --since="${G}" 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
136
|
+
`).filter(Boolean)}catch{return t4($,10)}}import{existsSync as M2,readdirSync as X9,readFileSync as Q2}from"node:fs";import{join as $$}from"node:path";function I2($){return $$($,".serena","memories")}function G8($){let J=I2($);if(!M2(J))return[];try{return X9(J).filter((N)=>N.endsWith(".md")&&N!==".gitkeep")}catch{return[]}}function Z8($,J){let N=$.match(/^progress-(\w+)\.md$/),G=$.match(/^result-(\w+)\.md$/);if(N?.[1])return{agent:N[1],type:"progress",content:J.slice(0,500)};if(G?.[1])return{agent:G[1],type:"result",content:J.slice(0,500)};return null}function z8($){let J=I2($),N={agents:[],activities:[],completedTasks:[],inProgressTasks:[]};if(!M2(J))return N;let G=G8($);for(let Z of G){if(Z==="orchestrator-session.md"){try{let X=Q2($$(J,Z),"utf-8").match(/session[:\s]+(\S+)/i);if(X)N.sessionId=X[1]}catch{}continue}try{let z=Q2($$(J,Z),"utf-8"),X=Z8(Z,z);if(X){if(N.activities.push(X),!N.agents.includes(X.agent))N.agents.push(X.agent);if(X.type==="result"){let Q=z.match(/task[:\s]+(.+)/i)||z.match(/##\s*(.+)/);if(Q?.[1])N.completedTasks.push(Q[1].trim())}else if(X.type==="progress"){let Q=z.match(/current[:\s]+(.+)/i)||z.match(/working on[:\s]+(.+)/i);if(Q?.[1]&&!N.completedTasks.includes(Q[1].trim()))N.inProgressTasks.push(Q[1].trim())}}}catch{}}return N}function X8($,J){let N=[],G=I2($);if(!M2(G))return N;let Z=J?new Date(J).getTime():0,z=G8($);for(let X of z){if(X==="orchestrator-session.md")continue;try{let Q=$$(G,X),M=Q2(Q,"utf-8"),I=Z8(X,M);if(I)N.push(I)}catch{}}return N}function Q8($){let J=[];for(let N of $){let G=N.content.toLowerCase();if(G.includes("error")||G.includes("fail"))J.push(`${N.agent}: Error handling improved`);if(G.includes("refactor"))J.push(`${N.agent}: Code structure refactored`);if(G.includes("test"))J.push(`${N.agent}: Test coverage added`);if(G.includes("performance")||G.includes("optimize"))J.push(`${N.agent}: Performance optimized`)}return[...new Set(J)].slice(0,5)}function j2($){return K2($,".serena","retrospectives")}function K9($){let J=j2($);if(!I8(J))return[];try{return M9(J).filter((G)=>G.endsWith(".json")).sort().reverse().slice(0,10).map((G)=>JSON.parse(I9(K2(J,G),"utf-8")))}catch{return[]}}function Y2($,J){let N=j2($);if(!I8(N))Q9(N,{recursive:!0});let G=`${J.date.replace(/[:.]/g,"-")}_${J.id}.json`;Y9(K2(N,G),JSON.stringify(J,null,2),"utf-8")}function M8($){let J=J8($),N=N8($,J),G=$8(N),Z=t0($),z=z8($),X=X8($,J||void 0),Q=Object.entries(G).sort(([,Y],[,H])=>H-Y)[0],M="Development session";if(Q){let[Y]=Q;M={feat:"Feature development",fix:"Bug fixes and improvements",refactor:"Code refactoring",docs:"Documentation updates",test:"Testing improvements",chore:"Maintenance tasks",build:"Build system updates",perf:"Performance improvements"}[Y]||"Development session"}if(Z.filesChanged>0)M+=` (${Z.filesChanged} files, +${Z.linesAdded}/-${Z.linesRemoved})`;if(z.agents.length>0)M+=` with ${z.agents.join(", ")}`;let I=Q8(X);if(N.length>0&&I.length===0){if(G.refactor||G.perf)I.push("Code quality and performance improvements");if(G.test)I.push("Enhanced test coverage");if(G.fix)I.push("Issue resolution and stability improvements")}let K=[];if(z.inProgressTasks.length>0)K.push(...z.inProgressTasks.slice(0,3));if(N.length>0){let Y=N[0]?.toLowerCase()||"";if(Y.includes("wip")||Y.includes("todo"))K.push("Complete work-in-progress items")}if(K.length===0)K.push("Continue development","Review and test changes");return{summary:M,learnings:I.slice(0,5),nextSteps:K.slice(0,5)}}async function Y8($=!1,J=!1){let N=process.cwd(),G=j2(N),Z=K9(N);if($){console.log(JSON.stringify({retrospectives:Z},null,2));return}if(!J){let{summary:R,learnings:x,nextSteps:j}=M8(N),U=e0(N),T={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:R,keyLearnings:x,filesChanged:U,nextSteps:j};Y2(N,T),console.clear(),a(y.default.bgMagenta(y.default.white(" \uD83D\uDD04 oh-my-ag retro "))),O([y.default.green("✅ Auto-generated retrospective saved!"),"",y.default.bold("Summary:"),R,"",y.default.bold("Key Learnings:"),...x.map((B)=>` • ${B}`),"",y.default.bold("Next Steps:"),...j.map((B)=>` → ${B}`)].join(`
|
|
137
|
+
`),"Saved"),m(y.default.dim(`Stored in: ${G}`));return}console.clear(),a(y.default.bgMagenta(y.default.white(" \uD83D\uDD04 oh-my-ag retro (interactive) ")));let z=Z[0];if(z)O([y.default.bold("\uD83D\uDCC5 Last Retrospective"),`Date: ${z.date}`,"",y.default.bold("Summary:"),z.summary,"",y.default.bold("Key Learnings:"),...z.keyLearnings.map((R)=>` • ${R}`),"",y.default.bold("Next Steps:"),...z.nextSteps.map((R)=>` → ${R}`)].join(`
|
|
138
|
+
`),"Previous Session");let X=await c1({message:"What would you like to do?",options:[{value:"auto",label:"✨ Auto-generate from git history",hint:"Analyze commits and agent activity"},{value:"manual",label:"\uD83D\uDCDD Create manually",hint:"Write your own retrospective"},{value:"list",label:"\uD83D\uDCCB View past retrospectives"},{value:"exit",label:"\uD83D\uDC4B Exit"}]});if(c(X)||X==="exit"){m(y.default.dim("Goodbye!"));return}if(X==="list"){if(Z.length===0)O(y.default.yellow("No retrospectives found."),"History");else{let R=Z.map((x,j)=>`${j+1}. [${x.date.split("T")[0]}] ${x.summary.slice(0,50)}...`).join(`
|
|
139
|
+
`);O(R,`\uD83D\uDCDA Past Retrospectives (${Z.length})`)}m(y.default.dim(`Stored in: ${G}`));return}if(X==="auto"){let{summary:R,learnings:x,nextSteps:j}=M8(N),U=e0(N);O([y.default.bold("\uD83E\uDD16 Auto-generated Content"),"",y.default.bold("Summary:"),R,"",y.default.bold("Key Learnings:"),...x.map((_)=>` • ${_}`),"",y.default.bold("Next Steps:"),...j.map((_)=>` → ${_}`)].join(`
|
|
140
|
+
`),"Preview");let T=await w1({message:"Save this retrospective?",initialValue:!0});if(c(T)||!T){Z1("Cancelled.");return}let B={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:R,keyLearnings:x,filesChanged:U,nextSteps:j};Y2(N,B),O([y.default.green("✅ Retrospective saved!"),"",`Summary: ${B.summary}`,`Learnings: ${B.keyLearnings.length} items`,`Next steps: ${B.nextSteps.length} items`].join(`
|
|
141
|
+
`),"Saved"),m(y.default.dim(`Stored in: ${G}`));return}let Q=e4(N),M=e0(N);if(Q.length>0)O(Q.join(`
|
|
142
|
+
`),"Recent Commits");if(M.length>0)O(M.join(`
|
|
143
|
+
`),"Changed Files");let I=await i0({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(c(I)){Z1("Cancelled.");return}let K=await i0({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(c(K)){Z1("Cancelled.");return}let Y=await i0({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(c(Y)){Z1("Cancelled.");return}let H={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:I,keyLearnings:K.split(",").map((R)=>R.trim()).filter(Boolean),filesChanged:M,nextSteps:Y.split(",").map((R)=>R.trim()).filter(Boolean)};Y2(N,H),O([y.default.green("✅ Retrospective saved!"),"",`Summary: ${H.summary}`,`Learnings: ${H.keyLearnings.length} items`,`Next steps: ${H.nextSteps.length} items`].join(`
|
|
144
|
+
`),"Saved"),m(y.default.dim(`Stored in: ${G}`))}import{existsSync as J$,mkdirSync as j9,readdirSync as x9,readFileSync as H9,writeFileSync as K8}from"node:fs";import{dirname as R9,join as j8}from"node:path";var I1=k(N1(),1);function H2($){return j8($,".serena","metrics.json")}function x2(){return{sessions:0,skillsUsed:{},tasksCompleted:0,totalSessionTime:0,filesChanged:0,linesAdded:0,linesRemoved:0,lastUpdated:new Date().toISOString(),startDate:new Date().toISOString()}}function q9($){let J=H2($);if(J$(J))try{return JSON.parse(H9(J,"utf-8"))}catch{return x2()}return x2()}function U9($,J){let N=H2($),G=R9(N);if(!J$(G))j9(G,{recursive:!0});J.lastUpdated=new Date().toISOString(),K8(N,JSON.stringify(J,null,2),"utf-8")}function B9($){let J=j8($,".serena","memories"),N={};if(!J$(J))return N;try{let G=x9(J);for(let Z of G){let z=Z.match(/(?:progress|result)-(\w+)/);if(z?.[1]){let X=z[1];N[X]=(N[X]||0)+1}}}catch{}return N}async function x8($=!1,J=!1){let N=process.cwd(),G=H2(N);if(J){if(J$(G))K8(G,JSON.stringify(x2(),null,2),"utf-8");if($)console.log(JSON.stringify({reset:!0}));else console.log(I1.default.green("✅ Metrics reset successfully."));return}let Z=q9(N),z=t0(N),X=B9(N);for(let[Y,H]of Object.entries(X))Z.skillsUsed[Y]=(Z.skillsUsed[Y]||0)+H;Z.filesChanged+=z.filesChanged,Z.linesAdded+=z.linesAdded,Z.linesRemoved+=z.linesRemoved,Z.sessions+=1,U9(N,Z);let Q=Math.max(1,Math.ceil((Date.now()-new Date(Z.startDate).getTime())/86400000)),M=Z.sessions>0?Math.round(Z.totalSessionTime/Z.sessions):0;if($){console.log(JSON.stringify({...Z,gitStats:z,daysSinceStart:Q,avgSessionTime:M},null,2));return}console.clear(),a(I1.default.bgMagenta(I1.default.white(" \uD83D\uDCCA oh-my-ag stats ")));let I=[I1.default.bold(`\uD83D\uDCC8 Productivity Metrics (${Q} days)`),"┌─────────────────────┬──────────────┐",`│ ${I1.default.bold("Metric")} │ ${I1.default.bold("Value")} │`,"├─────────────────────┼──────────────┤",`│ Sessions │ ${String(Z.sessions).padEnd(12)} │`,`│ Tasks Completed │ ${String(Z.tasksCompleted).padEnd(12)} │`,`│ Files Changed │ ${String(Z.filesChanged).padEnd(12)} │`,`│ Lines Added │ ${I1.default.green(`+${Z.linesAdded}`).padEnd(12)} │`,`│ Lines Removed │ ${I1.default.red(`-${Z.linesRemoved}`).padEnd(12)} │`,"└─────────────────────┴──────────────┘"].join(`
|
|
145
|
+
`);O(I,"Overview");let K=Object.entries(Z.skillsUsed).sort(([,Y],[,H])=>H-Y).slice(0,5);if(K.length>0){let Y=[I1.default.bold("\uD83C\uDFC6 Top Skills Used"),...K.map(([H,R],x)=>` ${x+1}. ${H} (${R})`)].join(`
|
|
146
|
+
`);O(Y,"Skills")}m(I1.default.dim(`Data stored in: ${G}`))}async function R2($,J,{concurrency:N=Number.POSITIVE_INFINITY,stopOnError:G=!0,signal:Z}={}){return new Promise((z,X)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof J!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(N)&&N>=1||N===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${N}\` (${typeof N})`);let Q=[],M=[],I=new Map,K=!1,Y=!1,H=!1,R=0,x=0,j=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),U=()=>{_(Z.reason)},T=()=>{Z?.removeEventListener("abort",U)},B=(L)=>{z(L),T()},_=(L)=>{K=!0,Y=!0,X(L),T()};if(Z){if(Z.aborted)_(Z.reason);Z.addEventListener("abort",U,{once:!0})}let A=async()=>{if(Y)return;let L=await j.next(),D=x;if(x++,L.done){if(H=!0,R===0&&!Y){if(!G&&M.length>0){_(AggregateError(M));return}if(Y=!0,I.size===0){B(Q);return}let V=[];for(let[C,l]of Q.entries()){if(I.get(C)===H8)continue;V.push(l)}B(V)}return}R++,(async()=>{try{let V=await L.value;if(Y)return;let C=await J(V,D);if(C===H8)I.set(D,C);Q[D]=C,R--,await A()}catch(V){if(G)_(V);else{M.push(V),R--;try{await A()}catch(C){_(C)}}}})()};(async()=>{for(let L=0;L<N;L++){try{await A()}catch(D){_(D);break}if(H||K)break}})()})}var H8=Symbol("skip");var P1=k(N1(),1);import{createHash as T9}from"node:crypto";import{existsSync as q2,mkdirSync as R8,readFileSync as V9,writeFileSync as q8}from"node:fs";import{dirname as U8,join as U2}from"node:path";function _9($){return T9("sha256").update($,"utf-8").digest("hex")}async function B8($){let J=U2($,".agent","skills","_version.json");if(!q2(J))return null;try{let N=V9(J,"utf-8");return JSON.parse(N).version||null}catch{return null}}async function T8($,J){let N=U2($,".agent","skills","_version.json"),G=U8(N);if(!q2(G))R8(G,{recursive:!0});q8(N,JSON.stringify({version:J},null,2),"utf-8")}async function V8(){let $=`https://raw.githubusercontent.com/${K0}/main/prompt-manifest.json`,J=await fetch($);if(!J.ok)throw Error("Failed to fetch remote manifest");return await J.json()}async function _8($){let J=`https://raw.githubusercontent.com/${K0}/main/${$.path}`,N=await fetch(J);if(!N.ok)return{path:$.path,success:!1,error:`HTTP ${N.status}`};let G=await N.text();if(_9(G)!==$.sha256)return{path:$.path,success:!1,error:"SHA256 mismatch"};let z=U2(process.cwd(),$.path),X=U8(z);if(!q2(X))R8(X,{recursive:!0});return q8(z,G,"utf-8"),{path:$.path,success:!0}}async function C8(){console.clear(),a(P1.default.bgMagenta(P1.default.white(" \uD83D\uDEF8 oh-my-ag update ")));let $=process.cwd(),J=h1();try{J.start("Checking for updates...");let N=await V8(),G=await B8($);if(G===N.version){J.stop(P1.default.green("Already up to date!")),m(`Current version: ${P1.default.cyan(G)}`);return}J.message(`Updating from ${G||"not installed"} to ${P1.default.cyan(N.version)}...`);let Z=await R2(N.files,async(Q)=>_8(Q),{concurrency:10}),z=Z.filter((Q)=>!Q.success);if(z.length>0)J.stop("Update completed with errors"),O(z.map((Q)=>`${P1.default.red("✗")} ${Q.path}: ${Q.error}`).join(`
|
|
147
|
+
`),`${z.length} files failed`);else J.stop(`Updated to version ${P1.default.cyan(N.version)}!`);await T8($,N.version);let X=Z.length-z.length;m(z.length>0?`${X} files updated, ${z.length} failed`:`${X} files updated successfully`)}catch(N){J.stop("Update failed"),d.error(N instanceof Error?N.message:String(N)),process.exit(1)}}import{existsSync as vJ,mkdirSync as uJ,readdirSync as L0,readFileSync as bJ,statSync as i2}from"node:fs";import{createServer as lJ}from"node:http";import{basename as r3,join as j1}from"node:path";import{stat as a9}from"fs";import{stat as t9,readdir as e9}from"fs/promises";import{EventEmitter as $7}from"events";import*as S from"path";import{stat as C9,lstat as L8,readdir as L9,realpath as A9}from"node:fs/promises";import{Readable as D9}from"node:stream";import{resolve as A8,relative as P9,join as S9,sep as W9}from"node:path";var e={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},B2={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:e.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(B2);var W8="READDIRP_RECURSIVE_ERROR",F9=new Set(["ENOENT","EPERM","EACCES","ELOOP",W8]),D8=[e.DIR_TYPE,e.EVERYTHING_TYPE,e.FILE_DIR_TYPE,e.FILE_TYPE],O9=new Set([e.DIR_TYPE,e.EVERYTHING_TYPE,e.FILE_DIR_TYPE]),g9=new Set([e.EVERYTHING_TYPE,e.FILE_DIR_TYPE,e.FILE_TYPE]),f9=($)=>F9.has($.code),y9=process.platform==="win32",P8=($)=>!0,S8=($)=>{if($===void 0)return P8;if(typeof $==="function")return $;if(typeof $==="string"){let J=$.trim();return(N)=>N.basename===J}if(Array.isArray($)){let J=$.map((N)=>N.trim());return(N)=>J.some((G)=>N.basename===G)}return P8};class F8 extends D9{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let J={...B2,...$},{root:N,type:G}=J;this._fileFilter=S8(J.fileFilter),this._directoryFilter=S8(J.directoryFilter);let Z=J.lstat?L8:C9;if(y9)this._stat=(z)=>Z(z,{bigint:!0});else this._stat=Z;this._maxDepth=J.depth??B2.depth,this._wantsDir=G?O9.has(G):!1,this._wantsFile=G?g9.has(G):!1,this._wantsEverything=G===e.EVERYTHING_TYPE,this._root=A8(N),this._isDirent=!J.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(N,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let J=this.parent,N=J&&J.files;if(N&&N.length>0){let{path:G,depth:Z}=J,z=N.splice(0,$).map((Q)=>this._formatEntry(Q,G)),X=await Promise.all(z);for(let Q of X){if(!Q)continue;if(this.destroyed)return;let M=await this._getEntryType(Q);if(M==="directory"&&this._directoryFilter(Q)){if(Z<=this._maxDepth)this.parents.push(this._exploreDir(Q.fullPath,Z+1));if(this._wantsDir)this.push(Q),$--}else if((M==="file"||this._includeAsFile(Q))&&this._fileFilter(Q)){if(this._wantsFile)this.push(Q),$--}}}else{let G=this.parents.pop();if(!G){this.push(null);break}if(this.parent=await G,this.destroyed)return}}}catch(J){this.destroy(J)}finally{this.reading=!1}}async _exploreDir($,J){let N;try{N=await L9($,this._rdOptions)}catch(G){this._onError(G)}return{files:N,depth:J,path:$}}async _formatEntry($,J){let N,G=this._isDirent?$.name:$;try{let Z=A8(S9(J,G));N={path:P9(this._root,Z),fullPath:Z,basename:G},N[this._statsProp]=this._isDirent?$:await this._stat(Z)}catch(Z){this._onError(Z);return}return N}_onError($){if(f9($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let J=$[this._statsProp];if(J.isFile())return"file";if(J.isDirectory())return"directory";if(J&&J.isSymbolicLink()){let N=$.fullPath;try{let G=await A9(N),Z=await L8(G);if(Z.isFile())return"file";if(Z.isDirectory()){let z=G.length;if(N.startsWith(G)&&N.substr(z,1)===W9){let X=Error(`Circular symlink detected: "${N}" points to "${G}"`);return X.code=W8,this._onError(X)}return"directory"}}catch(G){return this._onError(G),""}}}_includeAsFile($){let J=$&&$[this._statsProp];return J&&this._wantsEverything&&!J.isDirectory()}}function O8($,J={}){let N=J.entryType||J.type;if(N==="both")N=e.FILE_DIR_TYPE;if(N)J.type=N;if(!$)throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");else if(typeof $!=="string")throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(N&&!D8.includes(N))throw Error(`readdirp: Invalid type passed. Use one of ${D8.join(", ")}`);return J.root=$,new F8(J)}import{watchFile as E9,unwatchFile as g8,watch as w9}from"fs";import{open as v9,stat as y8,lstat as u9,realpath as T2}from"fs/promises";import*as v from"path";import{type as b9}from"os";var l9="data",C2="end",E8="close",z$=()=>{};var X$=process.platform,L2=X$==="win32",k9=X$==="darwin",m9=X$==="linux",h9=X$==="freebsd",w8=b9()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},Y1=E,c9="watch",d9={lstat:u9,stat:y8},u1="listeners",N$="errHandlers",p1="rawEmitters",i9=[u1,N$,p1],n9=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),p9=($)=>n9.has(v.extname($).slice(1).toLowerCase()),_2=($,J)=>{if($ instanceof Set)$.forEach(J);else J($)},x0=($,J,N)=>{let G=$[J];if(!(G instanceof Set))$[J]=G=new Set([G]);G.add(N)},s9=($)=>(J)=>{let N=$[J];if(N instanceof Set)N.clear();else delete $[J]},H0=($,J,N)=>{let G=$[J];if(G instanceof Set)G.delete(N);else if(G===N)delete $[J]},v8=($)=>$ instanceof Set?$.size===0:!$,G$=new Map;function f8($,J,N,G,Z){let z=(X,Q)=>{if(N($),Z(X,Q,{watchedPath:$}),Q&&$!==Q)Z$(v.resolve($,Q),u1,v.join($,Q))};try{return w9($,{persistent:J.persistent},z)}catch(X){G(X);return}}var Z$=($,J,N,G,Z)=>{let z=G$.get($);if(!z)return;_2(z[J],(X)=>{X(N,G,Z)})},o9=($,J,N,G)=>{let{listener:Z,errHandler:z,rawEmitter:X}=G,Q=G$.get(J),M;if(!N.persistent){if(M=f8($,N,Z,z,X),!M)return;return M.close.bind(M)}if(Q)x0(Q,u1,Z),x0(Q,N$,z),x0(Q,p1,X);else{if(M=f8($,N,Z$.bind(null,J,u1),z,Z$.bind(null,J,p1)),!M)return;M.on(Y1.ERROR,async(I)=>{let K=Z$.bind(null,J,N$);if(Q)Q.watcherUnusable=!0;if(L2&&I.code==="EPERM")try{await(await v9($,"r")).close(),K(I)}catch(Y){}else K(I)}),Q={listeners:Z,errHandlers:z,rawEmitters:X,watcher:M},G$.set(J,Q)}return()=>{if(H0(Q,u1,Z),H0(Q,N$,z),H0(Q,p1,X),v8(Q.listeners))Q.watcher.close(),G$.delete(J),i9.forEach(s9(Q)),Q.watcher=void 0,Object.freeze(Q)}},V2=new Map,r9=($,J,N,G)=>{let{listener:Z,rawEmitter:z}=G,X=V2.get(J),Q=X&&X.options;if(Q&&(Q.persistent<N.persistent||Q.interval>N.interval))g8(J),X=void 0;if(X)x0(X,u1,Z),x0(X,p1,z);else X={listeners:Z,rawEmitters:z,options:N,watcher:E9(J,N,(M,I)=>{_2(X.rawEmitters,(Y)=>{Y(Y1.CHANGE,J,{curr:M,prev:I})});let K=M.mtimeMs;if(M.size!==I.size||K>I.mtimeMs||K===0)_2(X.listeners,(Y)=>Y($,M))})},V2.set(J,X);return()=>{if(H0(X,u1,Z),H0(X,p1,z),v8(X.listeners))V2.delete(J),g8(J),X.options=X.watcher=void 0,Object.freeze(X)}};class A2{constructor($){this.fsw=$,this._boundHandleError=(J)=>$._handleError(J)}_watchWithNodeFs($,J){let N=this.fsw.options,G=v.dirname($),Z=v.basename($);this.fsw._getWatchedDir(G).add(Z);let X=v.resolve($),Q={persistent:N.persistent};if(!J)J=z$;let M;if(N.usePolling){let I=N.interval!==N.binaryInterval;Q.interval=I&&p9(Z)?N.binaryInterval:N.interval,M=r9($,X,Q,{listener:J,rawEmitter:this.fsw._emitRaw})}else M=o9($,X,Q,{listener:J,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return M}_handleFile($,J,N){if(this.fsw.closed)return;let G=v.dirname($),Z=v.basename($),z=this.fsw._getWatchedDir(G),X=J;if(z.has(Z))return;let Q=async(I,K)=>{if(!this.fsw._throttle(c9,$,5))return;if(!K||K.mtimeMs===0)try{let Y=await y8($);if(this.fsw.closed)return;let{atimeMs:H,mtimeMs:R}=Y;if(!H||H<=R||R!==X.mtimeMs)this.fsw._emit(Y1.CHANGE,$,Y);if((k9||m9||h9)&&X.ino!==Y.ino){this.fsw._closeFile(I),X=Y;let x=this._watchWithNodeFs($,Q);if(x)this.fsw._addPathCloser(I,x)}else X=Y}catch(Y){this.fsw._remove(G,Z)}else if(z.has(Z)){let{atimeMs:Y,mtimeMs:H}=K;if(!Y||Y<=H||H!==X.mtimeMs)this.fsw._emit(Y1.CHANGE,$,K);X=K}},M=this._watchWithNodeFs($,Q);if(!(N&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(Y1.ADD,$,0))return;this.fsw._emit(Y1.ADD,$,J)}return M}async _handleSymlink($,J,N,G){if(this.fsw.closed)return;let Z=$.fullPath,z=this.fsw._getWatchedDir(J);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let X;try{X=await T2(N)}catch(Q){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(z.has(G)){if(this.fsw._symlinkPaths.get(Z)!==X)this.fsw._symlinkPaths.set(Z,X),this.fsw._emit(Y1.CHANGE,N,$.stats)}else z.add(G),this.fsw._symlinkPaths.set(Z,X),this.fsw._emit(Y1.ADD,N,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(Z))return!0;this.fsw._symlinkPaths.set(Z,!0)}_handleRead($,J,N,G,Z,z,X){if($=v.join($,""),X=this.fsw._throttle("readdir",$,1000),!X)return;let Q=this.fsw._getWatchedDir(N.path),M=new Set,I=this.fsw._readdirp($,{fileFilter:(K)=>N.filterPath(K),directoryFilter:(K)=>N.filterDir(K)});if(!I)return;return I.on(l9,async(K)=>{if(this.fsw.closed){I=void 0;return}let Y=K.path,H=v.join($,Y);if(M.add(Y),K.stats.isSymbolicLink()&&await this._handleSymlink(K,$,H,Y))return;if(this.fsw.closed){I=void 0;return}if(Y===G||!G&&!Q.has(Y))this.fsw._incrReadyCount(),H=v.join(Z,v.relative(Z,H)),this._addToNodeFs(H,J,N,z+1)}).on(Y1.ERROR,this._boundHandleError),new Promise((K,Y)=>{if(!I)return Y();I.once(C2,()=>{if(this.fsw.closed){I=void 0;return}let H=X?X.clear():!1;if(K(void 0),Q.getChildren().filter((R)=>{return R!==$&&!M.has(R)}).forEach((R)=>{this.fsw._remove($,R)}),I=void 0,H)this._handleRead($,!1,N,G,Z,z,X)})})}async _handleDir($,J,N,G,Z,z,X){let Q=this.fsw._getWatchedDir(v.dirname($)),M=Q.has(v.basename($));if(!(N&&this.fsw.options.ignoreInitial)&&!Z&&!M)this.fsw._emit(Y1.ADD_DIR,$,J);Q.add(v.basename($)),this.fsw._getWatchedDir($);let I,K,Y=this.fsw.options.depth;if((Y==null||G<=Y)&&!this.fsw._symlinkPaths.has(X)){if(!Z){if(await this._handleRead($,N,z,Z,$,G,I),this.fsw.closed)return}K=this._watchWithNodeFs($,(H,R)=>{if(R&&R.mtimeMs===0)return;this._handleRead(H,!1,z,Z,$,G,I)})}return K}async _addToNodeFs($,J,N,G,Z){let z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return z(),!1;let X=this.fsw._getWatchHelpers($);if(N)X.filterPath=(Q)=>N.filterPath(Q),X.filterDir=(Q)=>N.filterDir(Q);try{let Q=await d9[X.statMethod](X.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(X.watchPath,Q))return z(),!1;let M=this.fsw.options.followSymlinks,I;if(Q.isDirectory()){let K=v.resolve($),Y=M?await T2($):$;if(this.fsw.closed)return;if(I=await this._handleDir(X.watchPath,Q,J,G,Z,X,Y),this.fsw.closed)return;if(K!==Y&&Y!==void 0)this.fsw._symlinkPaths.set(K,Y)}else if(Q.isSymbolicLink()){let K=M?await T2($):$;if(this.fsw.closed)return;let Y=v.dirname(X.watchPath);if(this.fsw._getWatchedDir(Y).add(X.watchPath),this.fsw._emit(Y1.ADD,X.watchPath,Q),I=await this._handleDir(Y,Q,J,G,$,X,K),this.fsw.closed)return;if(K!==void 0)this.fsw._symlinkPaths.set(v.resolve($),K)}else I=this._handleFile(X.watchPath,Q,J);if(z(),I)this.fsw._addPathCloser($,I);return!1}catch(Q){if(this.fsw._handleError(Q))return z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var D2="/",J7="//",h8=".",N7="..",G7="string",Z7=/\\/g,u8=/\/\//,z7=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,X7=/^\.[/\\]/;function Q$($){return Array.isArray($)?$:[$]}var P2=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function Q7($){if(typeof $==="function")return $;if(typeof $==="string")return(J)=>$===J;if($ instanceof RegExp)return(J)=>$.test(J);if(typeof $==="object"&&$!==null)return(J)=>{if($.path===J)return!0;if($.recursive){let N=S.relative($.path,J);if(!N)return!1;return!N.startsWith("..")&&!S.isAbsolute(N)}return!1};return()=>!1}function M7($){if(typeof $!=="string")throw Error("string expected");$=S.normalize($),$=$.replace(/\\/g,"/");let J=!1;if($.startsWith("//"))J=!0;let N=/\/\//;while($.match(N))$=$.replace(N,"/");if(J)$="/"+$;return $}function b8($,J,N){let G=M7(J);for(let Z=0;Z<$.length;Z++){let z=$[Z];if(z(G,N))return!0}return!1}function I7($,J){if($==null)throw TypeError("anymatch: specify first argument");let G=Q$($).map((Z)=>Q7(Z));if(J==null)return(Z,z)=>{return b8(G,Z,z)};return b8(G,J)}var l8=($)=>{let J=Q$($).flat();if(!J.every((N)=>typeof N===G7))throw TypeError(`Non-string provided as watch path: ${J}`);return J.map(c8)},k8=($)=>{let J=$.replace(Z7,D2),N=!1;if(J.startsWith(J7))N=!0;while(J.match(u8))J=J.replace(u8,D2);if(N)J=D2+J;return J},c8=($)=>k8(S.normalize(k8($))),m8=($="")=>(J)=>{if(typeof J==="string")return c8(S.isAbsolute(J)?J:S.join($,J));else return J},Y7=($,J)=>{if(S.isAbsolute($))return $;return S.join(J,$)},K7=Object.freeze(new Set);class d8{constructor($,J){this.path=$,this._removeWatcher=J,this.items=new Set}add($){let{items:J}=this;if(!J)return;if($!==h8&&$!==N7)J.add($)}async remove($){let{items:J}=this;if(!J)return;if(J.delete($),J.size>0)return;let N=this.path;try{await e9(N)}catch(G){if(this._removeWatcher)this._removeWatcher(S.dirname(N),S.basename(N))}}has($){let{items:J}=this;if(!J)return;return J.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=z$,this.items=K7,Object.freeze(this)}}var j7="stat",x7="lstat";class i8{constructor($,J,N){this.fsw=N;let G=$;this.path=$=$.replace(X7,""),this.watchPath=G,this.fullWatchPath=S.resolve(G),this.dirParts=[],this.dirParts.forEach((Z)=>{if(Z.length>1)Z.pop()}),this.followSymlinks=J,this.statMethod=J?j7:x7}entryPath($){return S.join(this.watchPath,S.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:J}=$;if(J&&J.isSymbolicLink())return this.filterDir($);let N=this.entryPath($);return this.fsw._isntIgnored(N,J)&&this.fsw._hasReadPermissions(J)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class n8 extends $7{constructor($={}){super();this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let J=$.awaitWriteFinish,N={stabilityThreshold:2000,pollInterval:100},G={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?Q$($.ignored):Q$([]),awaitWriteFinish:J===!0?N:typeof J==="object"?{...N,...J}:!1};if(w8)G.usePolling=!0;if(G.atomic===void 0)G.atomic=!G.usePolling;let Z=process.env.CHOKIDAR_USEPOLLING;if(Z!==void 0){let Q=Z.toLowerCase();if(Q==="false"||Q==="0")G.usePolling=!1;else if(Q==="true"||Q==="1")G.usePolling=!0;else G.usePolling=!!Q}let z=process.env.CHOKIDAR_INTERVAL;if(z)G.interval=Number.parseInt(z,10);let X=0;this._emitReady=()=>{if(X++,X>=this._readyCount)this._emitReady=z$,this._readyEmitted=!0,process.nextTick(()=>this.emit(E.READY))},this._emitRaw=(...Q)=>this.emit(E.RAW,...Q),this._boundRemove=this._remove.bind(this),this.options=G,this._nodeFsHandler=new A2(this),Object.freeze(G)}_addIgnoredPath($){if(P2($)){for(let J of this._ignoredPaths)if(P2(J)&&J.path===$.path&&J.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let J of this._ignoredPaths)if(P2(J)&&J.path===$)this._ignoredPaths.delete(J)}}add($,J,N){let{cwd:G}=this.options;this.closed=!1,this._closePromise=void 0;let Z=l8($);if(G)Z=Z.map((z)=>{return Y7(z,G)});if(Z.forEach((z)=>{this._removeIgnoredPath(z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=Z.length,Promise.all(Z.map(async(z)=>{let X=await this._nodeFsHandler._addToNodeFs(z,!N,void 0,0,J);if(X)this._emitReady();return X})).then((z)=>{if(this.closed)return;z.forEach((X)=>{if(X)this.add(S.dirname(X),S.basename(J||X))})}),this}unwatch($){if(this.closed)return this;let J=l8($),{cwd:N}=this.options;return J.forEach((G)=>{if(!S.isAbsolute(G)&&!this._closers.has(G)){if(N)G=S.join(N,G);G=S.resolve(G)}if(this._closePath(G),this._addIgnoredPath(G),this._watched.has(G))this._addIgnoredPath({path:G,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((J)=>J.forEach((N)=>{let G=N();if(G instanceof Promise)$.push(G)})),this._streams.forEach((J)=>J.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((J)=>J.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=$.length?Promise.all($).then(()=>{return}):Promise.resolve(),this._closePromise}getWatched(){let $={};return this._watched.forEach((J,N)=>{let Z=(this.options.cwd?S.relative(this.options.cwd,N):N)||h8;$[Z]=J.getChildren().sort()}),$}emitWithAll($,J){if(this.emit($,...J),$!==E.ERROR)this.emit(E.ALL,$,...J)}async _emit($,J,N){if(this.closed)return;let G=this.options;if(L2)J=S.normalize(J);if(G.cwd)J=S.relative(G.cwd,J);let Z=[J];if(N!=null)Z.push(N);let z=G.awaitWriteFinish,X;if(z&&(X=this._pendingWrites.get(J)))return X.lastChange=new Date,this;if(G.atomic){if($===E.UNLINK)return this._pendingUnlinks.set(J,[$,...Z]),setTimeout(()=>{this._pendingUnlinks.forEach((Q,M)=>{this.emit(...Q),this.emit(E.ALL,...Q),this._pendingUnlinks.delete(M)})},typeof G.atomic==="number"?G.atomic:100),this;if($===E.ADD&&this._pendingUnlinks.has(J))$=E.CHANGE,this._pendingUnlinks.delete(J)}if(z&&($===E.ADD||$===E.CHANGE)&&this._readyEmitted){let Q=(M,I)=>{if(M)$=E.ERROR,Z[0]=M,this.emitWithAll($,Z);else if(I){if(Z.length>1)Z[1]=I;else Z.push(I);this.emitWithAll($,Z)}};return this._awaitWriteFinish(J,z.stabilityThreshold,$,Q),this}if($===E.CHANGE){if(!this._throttle(E.CHANGE,J,50))return this}if(G.alwaysStat&&N===void 0&&($===E.ADD||$===E.ADD_DIR||$===E.CHANGE)){let Q=G.cwd?S.join(G.cwd,J):J,M;try{M=await t9(Q)}catch(I){}if(!M||this.closed)return;Z.push(M)}return this.emitWithAll($,Z),this}_handleError($){let J=$&&$.code;if($&&J!=="ENOENT"&&J!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||J!=="EPERM"&&J!=="EACCES"))this.emit(E.ERROR,$);return $||this.closed}_throttle($,J,N){if(!this._throttled.has($))this._throttled.set($,new Map);let G=this._throttled.get($);if(!G)throw Error("invalid throttle");let Z=G.get(J);if(Z)return Z.count++,!1;let z,X=()=>{let M=G.get(J),I=M?M.count:0;if(G.delete(J),clearTimeout(z),M)clearTimeout(M.timeoutObject);return I};z=setTimeout(X,N);let Q={timeoutObject:z,clear:X,count:0};return G.set(J,Q),Q}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,J,N,G){let Z=this.options.awaitWriteFinish;if(typeof Z!=="object")return;let z=Z.pollInterval,X,Q=$;if(this.options.cwd&&!S.isAbsolute($))Q=S.join(this.options.cwd,$);let M=new Date,I=this._pendingWrites;function K(Y){a9(Q,(H,R)=>{if(H||!I.has($)){if(H&&H.code!=="ENOENT")G(H);return}let x=Number(new Date);if(Y&&R.size!==Y.size)I.get($).lastChange=x;let j=I.get($);if(x-j.lastChange>=J)I.delete($),G(void 0,R);else X=setTimeout(K,z,R)})}if(!I.has($))I.set($,{lastChange:M,cancelWait:()=>{return I.delete($),clearTimeout(X),N}}),X=setTimeout(K,z)}_isIgnored($,J){if(this.options.atomic&&z7.test($))return!0;if(!this._userIgnored){let{cwd:N}=this.options,Z=(this.options.ignored||[]).map(m8(N)),X=[...[...this._ignoredPaths].map(m8(N)),...Z];this._userIgnored=I7(X,void 0)}return this._userIgnored($,J)}_isntIgnored($,J){return!this._isIgnored($,J)}_getWatchHelpers($){return new i8($,this.options.followSymlinks,this)}_getWatchedDir($){let J=S.resolve($);if(!this._watched.has(J))this._watched.set(J,new d8(J,this._boundRemove));return this._watched.get(J)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,J,N){let G=S.join($,J),Z=S.resolve(G);if(N=N!=null?N:this._watched.has(G)||this._watched.has(Z),!this._throttle("remove",G,100))return;if(!N&&this._watched.size===1)this.add($,J,!0);this._getWatchedDir(G).getChildren().forEach((Y)=>this._remove(G,Y));let Q=this._getWatchedDir($),M=Q.has(J);if(Q.remove(J),this._symlinkPaths.has(Z))this._symlinkPaths.delete(Z);let I=G;if(this.options.cwd)I=S.relative(this.options.cwd,G);if(this.options.awaitWriteFinish&&this._pendingWrites.has(I)){if(this._pendingWrites.get(I).cancelWait()===E.ADD)return}this._watched.delete(G),this._watched.delete(Z);let K=N?E.UNLINK_DIR:E.UNLINK;if(M&&!this._isIgnored(G))this._emit(K,G);this._closePath(G)}_closePath($){this._closeFile($);let J=S.dirname($);this._getWatchedDir(J).remove(S.basename($))}_closeFile($){let J=this._closers.get($);if(!J)return;J.forEach((N)=>N()),this._closers.delete($)}_addPathCloser($,J){if(!J)return;let N=this._closers.get($);if(!N)N=[],this._closers.set($,N);N.push(J)}_readdirp($,J){if(this.closed)return;let N={type:E.ALL,alwaysStat:!0,lstat:!0,...J,depth:0},G=O8($,N);return this._streams.add(G),G.once(E8,()=>{G=void 0}),G.once(C2,()=>{if(G)this._streams.delete(G),G=void 0}),G}}function M$($,J={}){let N=new n8(J);return N.add($),N}var J0=k(N1(),1);var yJ=k(m3(),1),EJ=k(f2(),1),wJ=k(E2(),1),m2=k(T$(),1),h2=k(s3(),1);var o3=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT||"9847",10):9847;function kJ(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return j1($,".serena","memories");return j1(process.cwd(),".serena","memories")}function A0($){try{return bJ($,"utf-8")}catch{return""}}function mJ($){try{let J=L0($);if(J.includes("orchestrator-session.md"))return j1($,"orchestrator-session.md");let N=J.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:i2(j1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime);if(N.length>0&&N[0])return j1($,N[0].name)}catch{}return null}function hJ($){let J=mJ($);if(!J)return{id:"N/A",status:"UNKNOWN"};let N=A0(J);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||r3(J,".md")||"N/A",Z="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))Z="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))Z="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))Z="FAILED";else if(/Step \d+:.*\[/i.test(N))Z="RUNNING";return{id:G.trim(),status:Z}}function cJ($){let J=A0(j1($,"task-board.md"));if(!J)return[];let N=[],G=J.split(`
|
|
148
|
+
`);for(let Z of G){if(!Z.startsWith("|")||/^\|\s*-+/.test(Z))continue;let z=Z.split("|").map((Q)=>Q.trim()).filter(Boolean),X=z[0];if(z.length<2||!X||/^agent$/i.test(X))continue;N.push({agent:z[0]||"",status:z[1]||"pending",task:z[2]||""})}return N}function d2($,J){try{let N=L0($).filter((z)=>z.startsWith(`progress-${J}`)&&z.endsWith(".md")).sort().reverse();if(N.length===0)return null;let Z=(N[0]?A0(j1($,N[0])):"").match(/turn[:\s]*(\d+)/i);return Z?.[1]?parseInt(Z[1],10):null}catch{return null}}function dJ($){try{return L0($).filter((N)=>N.endsWith(".md")&&N!==".gitkeep").map((N)=>({name:N,mtime:i2(j1($,N)).mtimeMs})).sort((N,G)=>G.mtime-N.mtime).slice(0,10).map((N)=>{let G=N.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||N.name.replace(/\.md$/,""),z=A0(j1($,N.name)).split(`
|
|
149
|
+
`).map((Q)=>Q.trim()).filter((Q)=>Q&&!Q.startsWith("---")&&Q.length>3),X="";for(let Q=z.length-1;Q>=0;Q--){let M=z[Q];if(M){if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(M)){if(X=M.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),X.length>5)break}}}if(X.length>80)X=`${X.substring(0,77)}...`;return{agent:G,message:X,file:N.name}}).filter((N)=>N.message)}catch{return[]}}function iJ($){let J=[],N=new Set;try{let G=L0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:i2(j1($,Z)).mtimeMs})).sort((Z,z)=>z.mtime-Z.mtime);for(let Z of G){let z=A0(j1($,Z.name)),X=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(X?.[1])Q=X[1].trim();else if(/_agent|agent_|-agent/i.test(Z.name))Q=Z.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!N.has(Q.toLowerCase())){N.add(Q.toLowerCase());let M="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))M="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))M="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))M="failed";let I=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),K=I?.[1]?I[1].trim().substring(0,60):"";J.push({agent:Q,status:M,task:K,turn:d2($,Q)})}}}catch{}return J}function c2($){let J=hJ($),G=cJ($).map((Z)=>({...Z,turn:d2($,Z.agent)}));if(G.length===0)G=iJ($);if(G.length===0)try{let Z=L0($).filter((z)=>z.startsWith("progress-")&&z.endsWith(".md"));for(let z of Z){let X=z.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:X,status:"running",task:"",turn:d2($,X)})}}catch{}return{session:J,agents:G,activity:dJ($),memoriesDir:$,updatedAt:new Date().toISOString()}}var nJ=`<!DOCTYPE html>
|
|
32
150
|
<html lang="en">
|
|
33
151
|
<head>
|
|
34
152
|
<meta charset="UTF-8">
|
|
@@ -85,125 +203,12 @@ Expecting one of '${N.join("', '")}'`);let G=`${$}Help`;return this.on(G,(J)=>{l
|
|
|
85
203
|
fetch('/api/state').then(r=>r.json()).then(renderState).catch(()=>{});connect();
|
|
86
204
|
</script>
|
|
87
205
|
</body>
|
|
88
|
-
</html>`;function
|
|
89
|
-
Shutting down...`),
|
|
90
|
-
\uD83D\uDEF8 Serena Memory Dashboard`)),console.log(
|
|
91
|
-
`))})}
|
|
92
|
-
`);for(let
|
|
93
|
-
`).map((
|
|
94
|
-
\uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(
|
|
95
|
-
`)),
|
|
96
|
-
`),
|
|
97
|
-
`),j=X[Symbol.iterator](),M=j.next(),R=j.next(),S=0;for(;!M.done;){let Y=M.value,K=R.value;if(G+=Y,Y===s0||Y===h8){w8.lastIndex=S+1;let C=w8.exec(X)?.groups;if(C?.code!==void 0){let U=Number.parseFloat(C.code);J=U===EI?void 0:U}else C?.uri!==void 0&&(Z=C.uri.length===0?void 0:C.uri)}let T=J?uI(J):void 0;K===`
|
|
98
|
-
`?(Z&&(G+=m8("")),J&&T&&(G+=b8(T))):Y===`
|
|
99
|
-
`&&(J&&T&&(G+=b8(J)),Z&&(G+=m8(Z))),S+=Y.length,M=R,R=j.next()}return G};function z2($,I,N){return String($).normalize().replaceAll(`\r
|
|
100
|
-
`,`
|
|
101
|
-
`).split(`
|
|
102
|
-
`).map((G)=>bI(G,I,N)).join(`
|
|
103
|
-
`)}var mI=["up","down","left","right","space","enter","cancel"],X1={actions:new Set(mI),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function K2($,I){if(typeof $=="string")return X1.aliases.get($)===I;for(let N of $)if(N!==void 0&&K2(N,I))return!0;return!1}function iI($,I){if($===I)return;let N=$.split(`
|
|
104
|
-
`),G=I.split(`
|
|
105
|
-
`),J=Math.max(N.length,G.length),Z=[];for(let z=0;z<J;z++)N[z]!==G[z]&&Z.push(z);return{lines:Z,numLinesBefore:N.length,numLinesAfter:G.length,numLines:J}}var kI=globalThis.process.platform.startsWith("win"),Q2=Symbol("clack:cancel");function d($){return $===Q2}function p0($,I){let N=$;N.isTTY&&N.setRawMode(I)}function d8({input:$=i8,output:I=X2,overwrite:N=!0,hideCursor:G=!0}={}){let J=_1.createInterface({input:$,output:I,prompt:"",tabSize:1});_1.emitKeypressEvents($,J),$ instanceof v8&&$.isTTY&&$.setRawMode(!0);let Z=(z,{name:x,sequence:Q})=>{let X=String(z);if(K2([X,x,Q],"cancel")){G&&I.write(n.cursor.show),process.exit(0);return}if(!N)return;_1.moveCursor(I,x==="return"?0:-1,x==="return"?-1:0,()=>{_1.clearLine(I,1,()=>{$.once("keypress",Z)})})};return G&&I.write(n.cursor.hide),$.once("keypress",Z),()=>{$.off("keypress",Z),G&&I.write(n.cursor.show),$ instanceof v8&&$.isTTY&&!kI&&$.setRawMode(!1),J.terminal=!1,J.close()}}var R0=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,Y2=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20;function l1($,I,N,G=N){let J=R0($??X2);return z2(I,J-N.length,{hard:!0,trim:!1}).split(`
|
|
106
|
-
`).map((Z,z)=>`${z===0?G:N}${Z}`).join(`
|
|
107
|
-
`)}class u1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,I=!0){let{input:N=i8,output:G=X2,render:J,signal:Z,...z}=$;this.opts=z,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=J.bind(this),this._track=I,this._abortSignal=Z,this.input=N,this.output=G}unsubscribe(){this._subscribers.clear()}setSubscriber($,I){let N=this._subscribers.get($)??[];N.push(I),this._subscribers.set($,N)}on($,I){this.setSubscriber($,{cb:I})}once($,I){this.setSubscriber($,{cb:I,once:!0})}emit($,...I){let N=this._subscribers.get($)??[],G=[];for(let J of N)J.cb(...I),J.once&&G.push(()=>N.splice(N.indexOf(J),1));for(let J of G)J()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(Q2);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=fI.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),p0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(n.cursor.show),this.output.off("resize",this.render),p0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(n.cursor.show),this.output.off("resize",this.render),p0(this.input,!1),$(Q2)})})}_isActionKey($,I){return $==="\t"}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,I){this.userInput=$??"",this.emit("userInput",this.userInput),I&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,I){if(this._track&&I.name!=="return"&&(I.name&&this._isActionKey($,I)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),I?.name&&(!this._track&&X1.aliases.has(I.name)&&this.emit("cursor",X1.aliases.get(I.name)),X1.actions.has(I.name)&&this.emit("cursor",I.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$?.toLowerCase(),I),I?.name==="return"){if(this.opts.validate){let N=this.opts.validate(this.value);N&&(this.error=N instanceof Error?N.message:N,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}K2([$,I?.name,I?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
108
|
-
`),p0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=z2(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
109
|
-
`).length-1;this.output.write(n.cursor.move(-999,$*-1))}render(){let $=z2(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(n.cursor.hide);else{let I=iI(this._prevFrame,$),N=Y2(this.output);if(this.restoreCursor(),I){let G=Math.max(0,I.numLinesAfter-N),J=Math.max(0,I.numLinesBefore-N),Z=I.lines.find((z)=>z>=G);if(Z===void 0){this._prevFrame=$;return}if(I.lines.length===1){this.output.write(n.cursor.move(0,Z-J)),this.output.write(n.erase.lines(1));let z=$.split(`
|
|
110
|
-
`);this.output.write(z[Z]),this._prevFrame=$,this.output.write(n.cursor.move(0,z.length-Z-1));return}else if(I.lines.length>1){if(G<J)Z=G;else{let x=Z-J;x>0&&this.output.write(n.cursor.move(0,x))}this.output.write(n.erase.down());let z=$.split(`
|
|
111
|
-
`).slice(Z);this.output.write(z.join(`
|
|
112
|
-
`)),this._prevFrame=$;return}}this.output.write(n.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function hI($,I){if($===void 0||I.length===0)return 0;let N=I.findIndex((G)=>G.value===$);return N!==-1?N:0}function nI($,I){return(I.label??String(I.value)).toLowerCase().includes($.toLowerCase())}function cI($,I){if(I)return $?I:I[0]}class p8 extends u1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#N="";#G;#I;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return K0.default.inverse(K0.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[I,...N]=this.userInput.slice(this._cursor);return`${$}${K0.default.inverse(I)}${N.join("")}`}get options(){return typeof this.#I=="function"?this.#I():this.#I}constructor($){super($),this.#I=$.options;let I=this.options;this.filteredOptions=[...I],this.multiple=$.multiple===!0,this.#G=$.filter??nI;let N;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?N=$.initialValue:N=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(N=[this.options[0].value]),N)for(let G of N){let J=I.findIndex((Z)=>Z.value===G);J!==-1&&(this.toggleSelected(G),this.#$=J)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(G,J)=>this.#J(G,J)),this.on("userInput",(G)=>this.#Z(G))}_isActionKey($,I){return $==="\t"||this.multiple&&this.isNavigating&&I.name==="space"&&$!==void 0&&$!==""}#J($,I){let N=I.name==="up",G=I.name==="down",J=I.name==="return";N||G?(this.#$=Math.max(0,Math.min(this.#$+(N?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):J?this.value=cI(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(I.name==="tab"||this.isNavigating&&I.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected($){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes($)?this.selectedValues=this.selectedValues.filter((I)=>I!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#Z($){if($!==this.#N){this.#N=$;let I=this.options;$?this.filteredOptions=I.filter((N)=>this.#G($,N)):this.filteredOptions=[...I],this.#$=hI(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class R2 extends u1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(I)=>{this.output.write(n.cursor.move(0,-1)),this.value=I,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class s8 extends u1{options;cursor=0;#$;getGroupItems($){return this.options.filter((I)=>I.group===$)}isGroupSelected($){let I=this.getGroupItems($),N=this.value;return N===void 0?!1:I.every((G)=>N.includes(G.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let I=$.value,N=this.getGroupItems(I);this.isGroupSelected(I)?this.value=this.value.filter((G)=>N.findIndex((J)=>J.value===G)===-1):this.value=[...this.value,...N.map((G)=>G.value)],this.value=Array.from(new Set(this.value))}else{let I=this.value.includes($.value);this.value=I?this.value.filter((N)=>N!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:I}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(I).flatMap(([N,G])=>[{value:N,group:!0,label:N},...G.map((J)=>({...J,group:N}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),this.#$?0:1),this.on("cursor",(N)=>{switch(N){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function E1($,I,N){let G=$+I,J=Math.max(N.length-1,0),Z=G<0?J:G>J?0:G;return N[Z].disabled?E1(Z,I<0?-1:1,N):Z}class S2 extends u1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,I=this.value!==void 0&&this.value.length===$.length;this.value=I?[]:$.map((N)=>N.value)}toggleInvert(){let $=this.value;if(!$)return;let I=this._enabledOptions.filter((N)=>!$.includes(N.value));this.value=I.map((N)=>N.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((I)=>I!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let I=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),0);this.cursor=this.options[I].disabled?E1(I,1,this.options):I,this.on("key",(N)=>{N==="a"&&this.toggleAll(),N==="i"&&this.toggleInvert()}),this.on("cursor",(N)=>{switch(N){case"left":case"up":this.cursor=E1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=E1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class H2 extends u1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let I=this.options.findIndex(({value:G})=>G===$.initialValue),N=I===-1?0:I;this.cursor=this.options[N].disabled?E1(N,1,this.options):N,this.changeValue(),this.on("cursor",(G)=>{switch(G){case"left":case"up":this.cursor=E1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=E1(this.cursor,1,this.options);break}this.changeValue()})}}class T2 extends u1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let I=$.slice(0,this.cursor),[N,...G]=$.slice(this.cursor);return`${I}${K0.default.inverse(N)}${G.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(I)=>{this._setValue(I)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var H=i(x1(),1);import N1 from"node:process";var H0=i(G2(),1);function dI(){return N1.platform!=="win32"?N1.env.TERM!=="linux":!!N1.env.CI||!!N1.env.WT_SESSION||!!N1.env.TERMINUS_SUBLIME||N1.env.ConEmuTask==="{cmd::Cmder}"||N1.env.TERM_PROGRAM==="Terminus-Sublime"||N1.env.TERM_PROGRAM==="vscode"||N1.env.TERM==="xterm-256color"||N1.env.TERM==="alacritty"||N1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var B2=dI(),pI=()=>process.env.CI==="true";var W=($,I)=>B2?$:I,sI=W("◆","*"),I3=W("■","x"),N3=W("▲","x"),$$=W("◇","o"),oI=W("┌","T"),A=W("│","|"),V1=W("└","—"),KG=W("┐","T"),YG=W("┘","—"),g2=W("●",">"),e0=W("○"," "),rI=W("◻","[•]"),o8=W("◼","[+]"),r8=W("◻","[ ]"),RG=W("▪","•"),a8=W("─","-"),aI=W("╮","+"),tI=W("├","+"),eI=W("╯","+"),$N=W("╰","+"),SG=W("╭","+"),IN=W("●","•"),NN=W("◆","*"),GN=W("▲","!"),JN=W("■","x"),I$=($)=>{switch($){case"initial":case"active":return H.default.cyan(sI);case"cancel":return H.default.red(I3);case"error":return H.default.yellow(N3);case"submit":return H.default.green($$)}},G3=($)=>{switch($){case"initial":case"active":return H.default.cyan(A);case"cancel":return H.default.red(A);case"error":return H.default.yellow(A);case"submit":return H.default.green(A)}},ZN=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,xN=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,zN=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,U2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,o0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,r0=/\t{1,1000}/y,q2=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,a0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,QN=/\p{M}+/gu,XN={limit:1/0,ellipsis:""},J3=($,I={},N={})=>{let G=I.limit??1/0,J=I.ellipsis??"",Z=I?.ellipsisWidth??(J?J3(J,XN,N).width:0),z=N.ansiWidth??0,x=N.controlWidth??0,Q=N.tabWidth??8,X=N.ambiguousWidth??1,j=N.emojiWidth??2,M=N.fullWidthWidth??2,R=N.regularWidth??1,S=N.wideWidth??2,Y=0,K=0,T=$.length,C=0,U=!1,B=T,_=Math.max(0,G-Z),L=0,f=0,q=0,g=0;$:for(;;){if(f>L||K>=T&&K>Y){let b=$.slice(L,f)||$.slice(Y,K);C=0;for(let c of b.replaceAll(QN,"")){let s=c.codePointAt(0)||0;if(xN(s)?g=M:zN(s)?g=S:X!==R&&ZN(s)?g=X:g=R,q+g>_&&(B=Math.min(B,Math.max(L,Y)+C)),q+g>G){U=!0;break $}C+=c.length,q+=g}L=f=0}if(K>=T)break;if(a0.lastIndex=K,a0.test($)){if(C=a0.lastIndex-K,g=C*R,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/R))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=a0.lastIndex;continue}if(U2.lastIndex=K,U2.test($)){if(q+z>_&&(B=Math.min(B,K)),q+z>G){U=!0;break}q+=z,L=Y,f=K,K=Y=U2.lastIndex;continue}if(o0.lastIndex=K,o0.test($)){if(C=o0.lastIndex-K,g=C*x,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/x))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=o0.lastIndex;continue}if(r0.lastIndex=K,r0.test($)){if(C=r0.lastIndex-K,g=C*Q,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/Q))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=r0.lastIndex;continue}if(q2.lastIndex=K,q2.test($)){if(q+j>_&&(B=Math.min(B,K)),q+j>G){U=!0;break}q+=j,L=Y,f=K,K=Y=q2.lastIndex;continue}K+=1}return{width:U?_:q,index:U?B:T,truncated:U,ellipsed:U&&G>=Z}},MN={limit:1/0,ellipsis:"",ellipsisWidth:0},K1=($,I={})=>J3($,MN,I).width,N$="\x1B",Z3="",jN=39,D2="\x07",x3="[",KN="]",z3="m",_2=`${KN}8;;`,t8=new RegExp(`(?:\\${x3}(?<code>\\d+)m|\\${_2}(?<uri>.*)${D2})`,"y"),YN=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},e8=($)=>`${N$}${x3}${$}${z3}`,$3=($)=>`${N$}${_2}${$}${D2}`,RN=($)=>$.map((I)=>K1(I)),C2=($,I,N)=>{let G=I[Symbol.iterator](),J=!1,Z=!1,z=$.at(-1),x=z===void 0?0:K1(z),Q=G.next(),X=G.next(),j=0;for(;!Q.done;){let M=Q.value,R=K1(M);x+R<=N?$[$.length-1]+=M:($.push(M),x=0),(M===N$||M===Z3)&&(J=!0,Z=I.startsWith(_2,j+1)),J?Z?M===D2&&(J=!1,Z=!1):M===z3&&(J=!1):(x+=R,x===N&&!X.done&&($.push(""),x=0)),Q=X,X=G.next(),j+=M.length}z=$.at(-1),!x&&z!==void 0&&z.length>0&&$.length>1&&($[$.length-2]+=$.pop())},SN=($)=>{let I=$.split(" "),N=I.length;for(;N>0&&!(K1(I[N-1])>0);)N--;return N===I.length?$:I.slice(0,N).join(" ")+I.slice(N).join("")},HN=($,I,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",J,Z,z=$.split(" "),x=RN(z),Q=[""];for(let[Y,K]of z.entries()){N.trim!==!1&&(Q[Q.length-1]=(Q.at(-1)??"").trimStart());let T=K1(Q.at(-1)??"");if(Y!==0&&(T>=I&&(N.wordWrap===!1||N.trim===!1)&&(Q.push(""),T=0),(T>0||N.trim===!1)&&(Q[Q.length-1]+=" ",T++)),N.hard&&x[Y]>I){let C=I-T,U=1+Math.floor((x[Y]-C-1)/I);Math.floor((x[Y]-1)/I)<U&&Q.push(""),C2(Q,K,I);continue}if(T+x[Y]>I&&T>0&&x[Y]>0){if(N.wordWrap===!1&&T<I){C2(Q,K,I);continue}Q.push("")}if(T+x[Y]>I&&N.wordWrap===!1){C2(Q,K,I);continue}Q[Q.length-1]+=K}N.trim!==!1&&(Q=Q.map((Y)=>SN(Y)));let X=Q.join(`
|
|
113
|
-
`),j=X[Symbol.iterator](),M=j.next(),R=j.next(),S=0;for(;!M.done;){let Y=M.value,K=R.value;if(G+=Y,Y===N$||Y===Z3){t8.lastIndex=S+1;let C=t8.exec(X)?.groups;if(C?.code!==void 0){let U=Number.parseFloat(C.code);J=U===jN?void 0:U}else C?.uri!==void 0&&(Z=C.uri.length===0?void 0:C.uri)}let T=J?YN(J):void 0;K===`
|
|
114
|
-
`?(Z&&(G+=$3("")),J&&T&&(G+=e8(T))):Y===`
|
|
115
|
-
`&&(J&&T&&(G+=e8(J)),Z&&(G+=$3(Z))),S+=Y.length,M=R,R=j.next()}return G};function T0($,I,N){return String($).normalize().replaceAll(`\r
|
|
116
|
-
`,`
|
|
117
|
-
`).split(`
|
|
118
|
-
`).map((G)=>HN(G,I,N)).join(`
|
|
119
|
-
`)}var TN=($,I,N,G,J)=>{let Z=I,z=0;for(let x=N;x<G;x++){let Q=$[x];if(Z=Z-Q.length,z++,Z<=J)break}return{lineCount:Z,removals:z}},L2=($)=>{let{cursor:I,options:N,style:G}=$,J=$.output??process.stdout,Z=R0(J),z=$.columnPadding??0,x=$.rowPadding??4,Q=Z-z,X=Y2(J),j=H.default.dim("..."),M=$.maxItems??Number.POSITIVE_INFINITY,R=Math.max(X-x,0),S=Math.max(Math.min(M,R),5),Y=0;I>=S-3&&(Y=Math.max(Math.min(I-S+3,N.length-S),0));let K=S<N.length&&Y>0,T=S<N.length&&Y+S<N.length,C=Math.min(Y+S,N.length),U=[],B=0;K&&B++,T&&B++;let _=Y+(K?1:0),L=C-(T?1:0);for(let q=_;q<L;q++){let g=T0(G(N[q],q===I),Q,{hard:!0,trim:!1}).split(`
|
|
120
|
-
`);U.push(g),B+=g.length}if(B>R){let q=0,g=0,b=B,c=I-_,s=(A1,l)=>TN(U,b,A1,l,R);K?({lineCount:b,removals:q}=s(0,c),b>R&&({lineCount:b,removals:g}=s(c+1,U.length))):({lineCount:b,removals:g}=s(c+1,U.length),b>R&&({lineCount:b,removals:q}=s(0,c))),q>0&&(K=!0,U.splice(0,q)),g>0&&(T=!0,U.splice(U.length-g,g))}let f=[];K&&f.push(j);for(let q of U)for(let g of q)f.push(g);return T&&f.push(j),f};var G$=($)=>{let I=$.active??"Yes",N=$.inactive??"No";return new R2({active:I,inactive:N,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let G=`${H.default.gray(A)}
|
|
121
|
-
${I$(this.state)} ${$.message}
|
|
122
|
-
`,J=this.value?I:N;switch(this.state){case"submit":return`${G}${H.default.gray(A)} ${H.default.dim(J)}`;case"cancel":return`${G}${H.default.gray(A)} ${H.default.strikethrough(H.default.dim(J))}
|
|
123
|
-
${H.default.gray(A)}`;default:return`${G}${H.default.cyan(A)} ${this.value?`${H.default.green(g2)} ${I}`:`${H.default.dim(e0)} ${H.default.dim(I)}`} ${H.default.dim("/")} ${this.value?`${H.default.dim(e0)} ${H.default.dim(N)}`:`${H.default.green(g2)} ${N}`}
|
|
124
|
-
${H.default.cyan(V1)}
|
|
125
|
-
`}}}).prompt()};var a={message:($=[],{symbol:I=H.default.gray(A),secondarySymbol:N=H.default.gray(A),output:G=process.stdout,spacing:J=1,withGuide:Z}={})=>{let z=[],x=(Z??X1.withGuide)!==!1,Q=x?N:"",X=x?`${I} `:"",j=x?`${N} `:"";for(let R=0;R<J;R++)z.push(Q);let M=Array.isArray($)?$:$.split(`
|
|
126
|
-
`);if(M.length>0){let[R,...S]=M;R.length>0?z.push(`${X}${R}`):z.push(x?I:"");for(let Y of S)Y.length>0?z.push(`${j}${Y}`):z.push(x?N:"")}G.write(`${z.join(`
|
|
127
|
-
`)}
|
|
128
|
-
`)},info:($,I)=>{a.message($,{...I,symbol:H.default.blue(IN)})},success:($,I)=>{a.message($,{...I,symbol:H.default.green(NN)})},step:($,I)=>{a.message($,{...I,symbol:H.default.green($$)})},warn:($,I)=>{a.message($,{...I,symbol:H.default.yellow(GN)})},warning:($,I)=>{a.warn($,I)},error:($,I)=>{a.message($,{...I,symbol:H.default.red(JN)})}},G1=($="",I)=>{(I?.output??process.stdout).write(`${H.default.gray(V1)} ${H.default.red($)}
|
|
129
|
-
|
|
130
|
-
`)},t=($="",I)=>{(I?.output??process.stdout).write(`${H.default.gray(oI)} ${$}
|
|
131
|
-
`)},m=($="",I)=>{(I?.output??process.stdout).write(`${H.default.gray(A)}
|
|
132
|
-
${H.default.gray(V1)} ${$}
|
|
133
|
-
|
|
134
|
-
`)},S0=($,I)=>$.split(`
|
|
135
|
-
`).map((N)=>I(N)).join(`
|
|
136
|
-
`),J$=($)=>{let I=(G,J)=>{let Z=G.label??String(G.value);return J==="disabled"?`${H.default.gray(r8)} ${S0(Z,(z)=>H.default.strikethrough(H.default.gray(z)))}${G.hint?` ${H.default.dim(`(${G.hint??"disabled"})`)}`:""}`:J==="active"?`${H.default.cyan(rI)} ${Z}${G.hint?` ${H.default.dim(`(${G.hint})`)}`:""}`:J==="selected"?`${H.default.green(o8)} ${S0(Z,H.default.dim)}${G.hint?` ${H.default.dim(`(${G.hint})`)}`:""}`:J==="cancelled"?`${S0(Z,(z)=>H.default.strikethrough(H.default.dim(z)))}`:J==="active-selected"?`${H.default.green(o8)} ${Z}${G.hint?` ${H.default.dim(`(${G.hint})`)}`:""}`:J==="submitted"?`${S0(Z,H.default.dim)}`:`${H.default.dim(r8)} ${S0(Z,H.default.dim)}`},N=$.required??!0;return new S2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:N,cursorAt:$.cursorAt,validate(G){if(N&&(G===void 0||G.length===0))return`Please select at least one option.
|
|
137
|
-
${H.default.reset(H.default.dim(`Press ${H.default.gray(H.default.bgWhite(H.default.inverse(" space ")))} to select, ${H.default.gray(H.default.bgWhite(H.default.inverse(" enter ")))} to submit`))}`},render(){let G=l1($.output,$.message,`${G3(this.state)} `,`${I$(this.state)} `),J=`${H.default.gray(A)}
|
|
138
|
-
${G}
|
|
139
|
-
`,Z=this.value??[],z=(x,Q)=>{if(x.disabled)return I(x,"disabled");let X=Z.includes(x.value);return Q&&X?I(x,"active-selected"):X?I(x,"selected"):I(x,Q?"active":"inactive")};switch(this.state){case"submit":{let x=this.options.filter(({value:X})=>Z.includes(X)).map((X)=>I(X,"submitted")).join(H.default.dim(", "))||H.default.dim("none"),Q=l1($.output,x,`${H.default.gray(A)} `);return`${J}${Q}`}case"cancel":{let x=this.options.filter(({value:X})=>Z.includes(X)).map((X)=>I(X,"cancelled")).join(H.default.dim(", "));if(x.trim()==="")return`${J}${H.default.gray(A)}`;let Q=l1($.output,x,`${H.default.gray(A)} `);return`${J}${Q}
|
|
140
|
-
${H.default.gray(A)}`}case"error":{let x=`${H.default.yellow(A)} `,Q=this.error.split(`
|
|
141
|
-
`).map((M,R)=>R===0?`${H.default.yellow(V1)} ${H.default.yellow(M)}`:` ${M}`).join(`
|
|
142
|
-
`),X=J.split(`
|
|
143
|
-
`).length,j=Q.split(`
|
|
144
|
-
`).length+1;return`${J}${x}${L2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:x.length,rowPadding:X+j,style:z}).join(`
|
|
145
|
-
${x}`)}
|
|
146
|
-
${Q}
|
|
147
|
-
`}default:{let x=`${H.default.cyan(A)} `,Q=J.split(`
|
|
148
|
-
`).length;return`${J}${x}${L2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:x.length,rowPadding:Q+2,style:z}).join(`
|
|
149
|
-
${x}`)}
|
|
150
|
-
${H.default.cyan(V1)}
|
|
151
|
-
`}}}}).prompt()},UN=($)=>H.default.dim($),qN=($,I,N)=>{let G={hard:!0,trim:!1},J=T0($,I,G).split(`
|
|
152
|
-
`),Z=J.reduce((Q,X)=>Math.max(K1(X),Q),0),z=J.map(N).reduce((Q,X)=>Math.max(K1(X),Q),0),x=I-(z-Z);return T0($,x,G)},F=($="",I="",N)=>{let G=N?.output??N1.stdout,J=(N?.withGuide??X1.withGuide)!==!1,Z=N?.format??UN,z=["",...qN($,R0(G)-6,Z).split(`
|
|
153
|
-
`).map(Z),""],x=K1(I),Q=Math.max(z.reduce((R,S)=>{let Y=K1(S);return Y>R?Y:R},0),x)+2,X=z.map((R)=>`${H.default.gray(A)} ${R}${" ".repeat(Q-K1(R))}${H.default.gray(A)}`).join(`
|
|
154
|
-
`),j=J?`${H.default.gray(A)}
|
|
155
|
-
`:"",M=J?tI:$N;G.write(`${j}${H.default.green($$)} ${H.default.reset(I)} ${H.default.gray(a8.repeat(Math.max(Q-x-1,1))+aI)}
|
|
156
|
-
${X}
|
|
157
|
-
${H.default.gray(M+a8.repeat(Q+2)+eI)}
|
|
158
|
-
`)};var CN=H.default.magenta,d1=({indicator:$="dots",onCancel:I,output:N=process.stdout,cancelMessage:G,errorMessage:J,frames:Z=B2?["◒","◐","◓","◑"]:["•","o","O","0"],delay:z=B2?80:120,signal:x,...Q}={})=>{let X=pI(),j,M,R=!1,S=!1,Y="",K,T=performance.now(),C=R0(N),U=Q?.styleFrame??CN,B=(l)=>{let $1=l>1?J??X1.messages.error:G??X1.messages.cancel;S=l===1,R&&(A1($1,l),S&&typeof I=="function"&&I())},_=()=>B(2),L=()=>B(1),f=()=>{process.on("uncaughtExceptionMonitor",_),process.on("unhandledRejection",_),process.on("SIGINT",L),process.on("SIGTERM",L),process.on("exit",B),x&&x.addEventListener("abort",L)},q=()=>{process.removeListener("uncaughtExceptionMonitor",_),process.removeListener("unhandledRejection",_),process.removeListener("SIGINT",L),process.removeListener("SIGTERM",L),process.removeListener("exit",B),x&&x.removeEventListener("abort",L)},g=()=>{if(K===void 0)return;X&&N.write(`
|
|
159
|
-
`);let l=T0(K,C,{hard:!0,trim:!1}).split(`
|
|
160
|
-
`);l.length>1&&N.write(H0.cursor.up(l.length-1)),N.write(H0.cursor.to(0)),N.write(H0.erase.down())},b=(l)=>l.replace(/\.+$/,""),c=(l)=>{let $1=(performance.now()-l)/1000,Y1=Math.floor($1/60),R1=Math.floor($1%60);return Y1>0?`[${Y1}m ${R1}s]`:`[${R1}s]`},s=(l="")=>{R=!0,j=d8({output:N}),Y=b(l),T=performance.now(),N.write(`${H.default.gray(A)}
|
|
161
|
-
`);let $1=0,Y1=0;f(),M=setInterval(()=>{if(X&&Y===K)return;g(),K=Y;let R1=U(Z[$1]),C0;if(X)C0=`${R1} ${Y}...`;else if($==="timer")C0=`${R1} ${Y} ${c(T)}`;else{let i3=".".repeat(Math.floor(Y1)).slice(0,3);C0=`${R1} ${Y}${i3}`}let m3=T0(C0,C,{hard:!0,trim:!1});N.write(m3),$1=$1+1<Z.length?$1+1:0,Y1=Y1<4?Y1+0.125:0},z)},A1=(l="",$1=0,Y1=!1)=>{if(!R)return;R=!1,clearInterval(M),g();let R1=$1===0?H.default.green($$):$1===1?H.default.red(I3):H.default.red(N3);Y=l??Y,Y1||($==="timer"?N.write(`${R1} ${Y} ${c(T)}
|
|
162
|
-
`):N.write(`${R1} ${Y}
|
|
163
|
-
`)),q(),j()};return{start:s,stop:(l="")=>A1(l,0),message:(l="")=>{Y=b(l??Y)},cancel:(l="")=>A1(l,1),error:(l="")=>A1(l,2),clear:()=>A1("",0,!0),get isCancelled(){return S}}},HG={light:W("─","-"),heavy:W("━","="),block:W("█","#")};var t0=($,I)=>$.includes(`
|
|
164
|
-
`)?$.split(`
|
|
165
|
-
`).map((N)=>I(N)).join(`
|
|
166
|
-
`):I($),p1=($)=>{let I=(N,G)=>{let J=N.label??String(N.value);switch(G){case"disabled":return`${H.default.gray(e0)} ${t0(J,H.default.gray)}${N.hint?` ${H.default.dim(`(${N.hint??"disabled"})`)}`:""}`;case"selected":return`${t0(J,H.default.dim)}`;case"active":return`${H.default.green(g2)} ${J}${N.hint?` ${H.default.dim(`(${N.hint})`)}`:""}`;case"cancelled":return`${t0(J,(Z)=>H.default.strikethrough(H.default.dim(Z)))}`;default:return`${H.default.dim(e0)} ${t0(J,H.default.dim)}`}};return new H2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let N=`${I$(this.state)} `,G=`${G3(this.state)} `,J=l1($.output,$.message,G,N),Z=`${H.default.gray(A)}
|
|
167
|
-
${J}
|
|
168
|
-
`;switch(this.state){case"submit":{let z=`${H.default.gray(A)} `,x=l1($.output,I(this.options[this.cursor],"selected"),z);return`${Z}${x}`}case"cancel":{let z=`${H.default.gray(A)} `,x=l1($.output,I(this.options[this.cursor],"cancelled"),z);return`${Z}${x}
|
|
169
|
-
${H.default.gray(A)}`}default:{let z=`${H.default.cyan(A)} `,x=Z.split(`
|
|
170
|
-
`).length;return`${Z}${z}${L2({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:z.length,rowPadding:x+2,style:(Q,X)=>I(Q,Q.disabled?"disabled":X?"active":"inactive")}).join(`
|
|
171
|
-
${z}`)}
|
|
172
|
-
${H.default.cyan(V1)}
|
|
173
|
-
`}}}}).prompt()};var TG=`${H.default.gray(A)} `;var Z$=($)=>new T2({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let I=($?.withGuide??X1.withGuide)!==!1,N=`${`${I?`${H.default.gray(A)}
|
|
174
|
-
`:""}${I$(this.state)} `}${$.message}
|
|
175
|
-
`,G=$.placeholder?H.default.inverse($.placeholder[0])+H.default.dim($.placeholder.slice(1)):H.default.inverse(H.default.hidden("_")),J=this.userInput?this.userInputWithCursor:G,Z=this.value??"";switch(this.state){case"error":{let z=this.error?` ${H.default.yellow(this.error)}`:"",x=I?`${H.default.yellow(A)} `:"",Q=I?H.default.yellow(V1):"";return`${N.trim()}
|
|
176
|
-
${x}${J}
|
|
177
|
-
${Q}${z}
|
|
178
|
-
`}case"submit":{let z=Z?` ${H.default.dim(Z)}`:"",x=I?H.default.gray(A):"";return`${N}${x}${z}`}case"cancel":{let z=Z?` ${H.default.strikethrough(H.default.dim(Z))}`:"",x=I?H.default.gray(A):"";return`${N}${x}${z}${Z.trim()?`
|
|
179
|
-
${x}`:""}`}default:{let z=I?`${H.default.cyan(A)} `:"",x=I?H.default.cyan(V1):"";return`${N}${z}${J}
|
|
180
|
-
${x}
|
|
181
|
-
`}}}}).prompt();var q1=i(x1(),1);import{join as LN}from"node:path";import{existsSync as Q3,mkdirSync as X3,writeFileSync as M3}from"node:fs";import{dirname as BN,join as x$}from"node:path";var z$="first-fluke/oh-my-ag",V2=`https://raw.githubusercontent.com/${z$}/main/.agent/skills`,o1={domain:[{name:"frontend-agent",desc:"React/Next.js UI specialist"},{name:"backend-agent",desc:"FastAPI/SQLAlchemy API specialist"},{name:"mobile-agent",desc:"Flutter/Dart mobile specialist"}],coordination:[{name:"pm-agent",desc:"Product manager - task decomposition"},{name:"qa-agent",desc:"QA - OWASP, Lighthouse, WCAG"},{name:"workflow-guide",desc:"Manual multi-agent orchestration"},{name:"orchestrator",desc:"Automated parallel CLI execution"}],utility:[{name:"debug-agent",desc:"Bug fixing specialist"},{name:"commit",desc:"Conventional Commits helper"}]},j3={fullstack:["frontend-agent","backend-agent","pm-agent","qa-agent","debug-agent","commit"],frontend:["frontend-agent","pm-agent","qa-agent","debug-agent","commit"],backend:["backend-agent","pm-agent","qa-agent","debug-agent","commit"],mobile:["mobile-agent","pm-agent","qa-agent","debug-agent","commit"],all:[...o1.domain,...o1.coordination,...o1.utility].map(($)=>$.name)};async function gN($){let I=["SKILL.md"],N=["resources/execution-protocol.md","resources/tech-stack.md","resources/checklist.md","resources/templates.md","resources/error-playbook.md"];for(let G of N){let J=`${V2}/${$}/${G}`;if((await fetch(J,{method:"HEAD"})).ok)I.push(G)}return I}async function Q$($,I){let N=x$(I,".agent","skills",$),G=await gN($);for(let J of G){let Z=`${V2}/${$}/${J}`,z=await fetch(Z);if(!z.ok)continue;let x=await z.text(),Q=x$(N,J),X=BN(Q);if(!Q3(X))X3(X,{recursive:!0});M3(Q,x,"utf-8")}return!0}async function X$($){let I=x$($,".agent","skills","_shared"),N=["reasoning-templates.md","clarification-protocol.md","context-loading.md","skill-routing.md"];if(!Q3(I))X3(I,{recursive:!0});for(let G of N){let J=`${V2}/_shared/${G}`,Z=await fetch(J);if(!Z.ok)continue;let z=await Z.text();M3(x$(I,G),z,"utf-8")}}function r1(){return[...o1.domain,...o1.coordination,...o1.utility]}async function K3(){console.clear(),t(q1.default.bgMagenta(q1.default.white(" \uD83D\uDEF8 oh-my-ag ")));let $=await p1({message:"What type of project?",options:[{value:"all",label:"✨ All",hint:"Install everything"},{value:"fullstack",label:"\uD83C\uDF10 Fullstack",hint:"Frontend + Backend + PM + QA"},{value:"frontend",label:"\uD83C\uDFA8 Frontend",hint:"React/Next.js"},{value:"backend",label:"⚙️ Backend",hint:"FastAPI/Python"},{value:"mobile",label:"\uD83D\uDCF1 Mobile",hint:"Flutter/Dart"},{value:"custom",label:"\uD83D\uDD27 Custom",hint:"Choose skills"}]});if(d($))G1("Cancelled."),process.exit(0);let I;if($==="custom"){let J=r1(),Z=await J$({message:"Select skills:",options:J.map((z)=>({value:z.name,label:z.name,hint:z.desc})),required:!0});if(d(Z))G1("Cancelled."),process.exit(0);I=Z}else I=j3[$]??[];let N=process.cwd(),G=d1();G.start("Installing skills...");try{await X$(N);for(let J of I)G.message(`Installing ${q1.default.cyan(J)}...`),await Q$(J,N);G.stop("Skills installed!"),F([...I.map((J)=>`${q1.default.green("✓")} ${J}`),"",q1.default.dim(`Location: ${LN(N,".agent","skills")}`)].join(`
|
|
182
|
-
`),"Installed"),m(q1.default.green("Done! Open your project in your IDE to use the skills.")),F(`${q1.default.yellow("❤️")} Enjoying oh-my-ag? Give it a star!
|
|
183
|
-
${q1.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Support")}catch(J){G.stop("Installation failed"),a.error(J instanceof Error?J.message:String(J)),process.exit(1)}}var f1=i(x1(),1);async function f2($,I,{concurrency:N=Number.POSITIVE_INFINITY,stopOnError:G=!0,signal:J}={}){return new Promise((Z,z)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof I!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(N)&&N>=1||N===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${N}\` (${typeof N})`);let x=[],Q=[],X=new Map,j=!1,M=!1,R=!1,S=0,Y=0,K=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),T=()=>{B(J.reason)},C=()=>{J?.removeEventListener("abort",T)},U=(L)=>{Z(L),C()},B=(L)=>{j=!0,M=!0,z(L),C()};if(J){if(J.aborted)B(J.reason);J.addEventListener("abort",T,{once:!0})}let _=async()=>{if(M)return;let L=await K.next(),f=Y;if(Y++,L.done){if(R=!0,S===0&&!M){if(!G&&Q.length>0){B(AggregateError(Q));return}if(M=!0,X.size===0){U(x);return}let q=[];for(let[g,b]of x.entries()){if(X.get(g)===Y3)continue;q.push(b)}U(q)}return}S++,(async()=>{try{let q=await L.value;if(M)return;let g=await I(q,f);if(g===Y3)X.set(f,g);x[f]=g,S--,await _()}catch(q){if(G)B(q);else{Q.push(q),S--;try{await _()}catch(g){B(g)}}}})()};(async()=>{for(let L=0;L<N;L++){try{await _()}catch(f){B(f);break}if(R||j)break}})()})}var Y3=Symbol("skip");import{existsSync as A2,mkdirSync as R3,readFileSync as DN,writeFileSync as S3}from"node:fs";import{dirname as H3,join as P2}from"node:path";import{createHash as _N}from"node:crypto";function VN($){return _N("sha256").update($,"utf-8").digest("hex")}async function T3($){let I=P2($,".agent","skills","_version.json");if(!A2(I))return null;try{let N=DN(I,"utf-8");return JSON.parse(N).version||null}catch{return null}}async function U3($,I){let N=P2($,".agent","skills","_version.json"),G=H3(N);if(!A2(G))R3(G,{recursive:!0});S3(N,JSON.stringify({version:I},null,2),"utf-8")}async function q3(){let $=`https://raw.githubusercontent.com/${z$}/main/prompt-manifest.json`,I=await fetch($);if(!I.ok)throw Error("Failed to fetch remote manifest");return await I.json()}async function C3($){let I=`https://raw.githubusercontent.com/${z$}/main/${$.path}`,N=await fetch(I);if(!N.ok)return{path:$.path,success:!1,error:`HTTP ${N.status}`};let G=await N.text();if(VN(G)!==$.sha256)return{path:$.path,success:!1,error:"SHA256 mismatch"};let Z=P2(process.cwd(),$.path),z=H3(Z);if(!A2(z))R3(z,{recursive:!0});return S3(Z,G,"utf-8"),{path:$.path,success:!0}}async function B3(){console.clear(),t(f1.default.bgMagenta(f1.default.white(" \uD83D\uDEF8 oh-my-ag update ")));let $=process.cwd(),I=d1();try{I.start("Checking for updates...");let N=await q3(),G=await T3($);if(G===N.version){I.stop(f1.default.green("Already up to date!")),m(`Current version: ${f1.default.cyan(G)}`);return}I.message(`Updating from ${G||"not installed"} to ${f1.default.cyan(N.version)}...`);let J=await f2(N.files,async(x)=>C3(x),{concurrency:10}),Z=J.filter((x)=>!x.success);if(Z.length>0)I.stop("Update completed with errors"),F(Z.map((x)=>`${f1.default.red("✗")} ${x.path}: ${x.error}`).join(`
|
|
184
|
-
`),`${Z.length} files failed`);else I.stop(`Updated to version ${f1.default.cyan(N.version)}!`);await U3($,N.version);let z=J.length-Z.length;m(Z.length>0?`${z} files updated, ${Z.length} failed`:`${z} files updated successfully`)}catch(N){I.stop("Update failed"),a.error(N instanceof Error?N.message:String(N)),process.exit(1)}}import{existsSync as U0,readFileSync as fN,readdirSync as AN}from"node:fs";import{execSync as PN}from"node:child_process";import{join as j$}from"node:path";var P=i(x1(),1);async function M$($,I,N){try{let G=PN(`${I} --version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();return{name:$,installed:!0,version:G,installCmd:N}}catch{return{name:$,installed:!1,installCmd:N}}}async function FN($){let I=process.env.HOME||process.env.USERPROFILE||"",G={gemini:{path:`${I}/.gemini/settings.json`,type:"json"},claude:{path:`${I}/.claude.json`,type:"json"},codex:{path:`${I}/.codex/config.toml`,type:"toml"}}[$];if(!G)return{configured:!1};if(U0(G.path))try{let J=fN(G.path,"utf-8");if(G.type==="json"){let Z=JSON.parse(J);return{configured:!!(Z.mcpServers||Z.mcp),path:G.path}}return{configured:!0,path:G.path}}catch{return{configured:!1}}return{configured:!1}}async function WN(){let $=j$(process.cwd(),".agent","skills");if(!U0($))return[];let I=r1(),N=[];for(let G of I){let J=j$($,G.name),Z=j$(J,"SKILL.md");N.push({name:G.name,installed:U0(J),hasSkillMd:U0(Z)})}return N}async function g3($=!1){let I=process.cwd(),N=await Promise.all([M$("gemini","gemini","bun install --global @anthropic-ai/gemini-cli"),M$("claude","claude","bun install --global @anthropic-ai/claude-code"),M$("codex","codex","bun install --global @openai/codex"),M$("qwen","qwen","bun install --global @qwen-code/qwen-code")]),G=await Promise.all(N.filter((R)=>R.installed).map(async(R)=>{let S=await FN(R.name);return{...R,mcp:S}})),J=await WN(),Z=j$(I,".serena","memories"),z=U0(Z),x=0;if(z)try{x=AN(Z).length}catch{}let Q=N.filter((R)=>!R.installed),X=J.length>0?J.filter((R)=>!R.installed||!R.hasSkillMd):r1().map((R)=>({name:R.name,installed:!1,hasSkillMd:!1})),j=Q.length+G.filter((R)=>!R.mcp.configured).length+X.length;if($){let R={ok:j===0,issues:j,clis:N.map((S)=>({name:S.name,installed:S.installed,version:S.version||null})),mcp:G.map((S)=>({name:S.name,configured:S.mcp.configured,path:S.mcp.path||null})),skills:J.length>0?J.map((S)=>({name:S.name,installed:S.installed,complete:S.hasSkillMd})):[],missingSkills:X.map((S)=>S.name),serena:{exists:z,fileCount:x}};console.log(JSON.stringify(R,null,2)),process.exit(j===0?0:1)}console.clear(),t(P.default.bgMagenta(P.default.white(" \uD83E\uDE7A oh-my-ag doctor ")));let M=d1();try{let R=[P.default.bold("\uD83D\uDD0D CLI Installation Status"),"┌─────────┬──────────┬─────────────┐",`│ ${P.default.bold("CLI")} │ ${P.default.bold("Status")} │ ${P.default.bold("Version")} │`,"├─────────┼──────────┼─────────────┤",...N.map((K)=>{let T=K.installed?P.default.green("✅ Installed"):P.default.red("❌ Missing"),C=K.version||"-";return`│ ${K.name.padEnd(7)} │ ${T.padEnd(8)} │ ${C.padEnd(11)} │`}),"└─────────┴──────────┴─────────────┘"].join(`
|
|
185
|
-
`);if(F(R,"CLI Status"),Q.length>0)F(Q.map((K)=>`${P.default.yellow("→")} ${K.name}: ${P.default.dim(K.installCmd)}`).join(`
|
|
186
|
-
`),"Install missing CLIs");if(G.length>0){let K=[P.default.bold("\uD83D\uDD17 MCP Connection Status"),"┌─────────┬──────────┬─────────────────────┐",`│ ${P.default.bold("CLI")} │ ${P.default.bold("MCP Config")} │ ${P.default.bold("Path")} │`,"├─────────┼──────────┼─────────────────────┤",...G.map((T)=>{let C=T.mcp.configured?P.default.green("✅ Configured"):P.default.yellow("⚠️ Not configured"),U=T.mcp.path?T.mcp.path.split("/").pop()||"":"-";return`│ ${T.name.padEnd(7)} │ ${C.padEnd(8)} │ ${U.padEnd(19)} │`}),"└─────────┴──────────┴─────────────────────┘"].join(`
|
|
187
|
-
`);F(K,"MCP Status")}let S=J.filter((K)=>K.installed).length,Y=J.filter((K)=>K.hasSkillMd).length;if(J.length>0){let K=[P.default.bold(`\uD83D\uDCE6 Skills (${S}/${J.length} installed, ${Y} complete)`),"┌────────────────────┬──────────┬─────────────┐",`│ ${P.default.bold("Skill")} │ ${P.default.bold("Installed")} │ ${P.default.bold("SKILL.md")} │`,"├────────────────────┼──────────┼─────────────┤",...J.map((T)=>{let C=T.installed?P.default.green("✅"):P.default.red("❌"),U=T.hasSkillMd?P.default.green("✅"):P.default.red("❌");return`│ ${T.name.padEnd(18)} │ ${C.padEnd(8)} │ ${U.padEnd(11)} │`}),"└────────────────────┴──────────┴─────────────┘"].join(`
|
|
188
|
-
`);F(K,"Skills Status")}else F(P.default.yellow("No skills installed."),"Skills Status");if(X.length>0){let K=await G$({message:`Found ${X.length} missing/incomplete skill(s). Install them?`,initialValue:!0});if(d(K))G1("Cancelled."),process.exit(0);if(K){let T=X.map((B)=>B.name),C=await p1({message:"Which skills to install?",options:[{value:"all",label:`✨ All (${T.length} skills)`,hint:"Recommended"},{value:"select",label:"\uD83D\uDD27 Select individually"}]});if(d(C))G1("Cancelled."),process.exit(0);let U;if(C==="select"){let B=r1(),_=await J$({message:"Select skills to install:",options:X.map((L)=>{let f=B.find((q)=>q.name===L.name);return{value:L.name,label:L.name,hint:f?.desc||""}}),required:!0});if(d(_))G1("Cancelled."),process.exit(0);U=_}else U=T;M.start("Installing skills...");try{await X$(I);for(let B of U)M.message(`Installing ${P.default.cyan(B)}...`),await Q$(B,I);M.stop(`Installed ${U.length} skill(s)!`),F(U.map((B)=>`${P.default.green("✓")} ${B}`).join(`
|
|
189
|
-
`),"Installed Skills")}catch(B){M.stop("Installation failed"),a.error(B instanceof Error?B.message:String(B))}}}if(z)F(`${P.default.green("✅")} Serena memory directory exists
|
|
190
|
-
${P.default.dim(`${x} memory files found`)}`,"Serena Memory");else F(`${P.default.yellow("⚠️")} Serena memory directory not found
|
|
191
|
-
${P.default.dim("Dashboard will show 'No agents detected'")}`,"Serena Memory");if(j===0)m(P.default.green("✅ All checks passed! Ready to use."));else m(P.default.yellow(`⚠️ Found ${j} issue(s). See details above.`))}catch(R){if(M)M.stop("Check failed");a.error(R instanceof Error?R.message:String(R)),process.exit(1)}}import{existsSync as R$,mkdirSync as ON,readFileSync as yN,writeFileSync as A3,readdirSync as EN}from"node:fs";import{dirname as lN,join as P3}from"node:path";var M1=i(x1(),1);import{execSync as v1}from"node:child_process";function K$($){try{let N=v1("git diff --stat HEAD~10 2>/dev/null || git diff --stat",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
192
|
-
`),G=N[N.length-1]||"",J=G.match(/(\d+) files? changed/),Z=G.match(/(\d+) insertions?\(\+\)/),z=G.match(/(\d+) deletions?\(-\)/);return{filesChanged:J?.[1]?parseInt(J[1],10):0,linesAdded:Z?.[1]?parseInt(Z[1],10):0,linesRemoved:z?.[1]?parseInt(z[1],10):0}}catch{return{filesChanged:0,linesAdded:0,linesRemoved:0}}}function D3($,I=5){try{return v1(`git log --oneline -${I} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
193
|
-
`).filter(Boolean)}catch{return[]}}function Y$($){try{return v1("git diff --name-only HEAD~5 2>/dev/null || git diff --name-only",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
194
|
-
`).filter(Boolean).slice(0,10)}catch{return[]}}function L3($,I=10){try{return v1(`git log --format="%s" -${I} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
195
|
-
`).filter(Boolean)}catch{return[]}}function _3($){let I={},N=/^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\(.+\))?:/;for(let G of $){let J=G.match(N);if(J){let Z=J[1];I[Z]=(I[Z]||0)+1}}return I}function V3($){try{let I=`${$}/.serena/retrospectives`,N=v1(`ls -t "${I}"/*.json 2>/dev/null | head -1`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();if(!N)return null;let G=v1(`cat "${N}"`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]});return JSON.parse(G).date||null}catch{return null}}function f3($,I){if(!I)return L3($,10);try{let G=new Date(I).toISOString().split("T")[0];return v1(`git log --format="%s" --since="${G}" 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
196
|
-
`).filter(Boolean)}catch{return L3($,10)}}function W2($){return P3($,".serena","metrics.json")}function F2(){return{sessions:0,skillsUsed:{},tasksCompleted:0,totalSessionTime:0,filesChanged:0,linesAdded:0,linesRemoved:0,lastUpdated:new Date().toISOString(),startDate:new Date().toISOString()}}function uN($){let I=W2($);if(R$(I))try{return JSON.parse(yN(I,"utf-8"))}catch{return F2()}return F2()}function vN($,I){let N=W2($),G=lN(N);if(!R$(G))ON(G,{recursive:!0});I.lastUpdated=new Date().toISOString(),A3(N,JSON.stringify(I,null,2),"utf-8")}function wN($){let I=P3($,".serena","memories"),N={};if(!R$(I))return N;try{let G=EN(I);for(let J of G){let Z=J.match(/(?:progress|result)-(\w+)/);if(Z?.[1]){let z=Z[1];N[z]=(N[z]||0)+1}}}catch{}return N}async function F3($=!1,I=!1){let N=process.cwd(),G=W2(N);if(I){if(R$(G))A3(G,JSON.stringify(F2(),null,2),"utf-8");if($)console.log(JSON.stringify({reset:!0}));else console.log(M1.default.green("✅ Metrics reset successfully."));return}let J=uN(N),Z=K$(N),z=wN(N);for(let[M,R]of Object.entries(z))J.skillsUsed[M]=(J.skillsUsed[M]||0)+R;J.filesChanged+=Z.filesChanged,J.linesAdded+=Z.linesAdded,J.linesRemoved+=Z.linesRemoved,J.sessions+=1,vN(N,J);let x=Math.max(1,Math.ceil((Date.now()-new Date(J.startDate).getTime())/86400000)),Q=J.sessions>0?Math.round(J.totalSessionTime/J.sessions):0;if($){console.log(JSON.stringify({...J,gitStats:Z,daysSinceStart:x,avgSessionTime:Q},null,2));return}console.clear(),t(M1.default.bgMagenta(M1.default.white(" \uD83D\uDCCA oh-my-ag stats ")));let X=[M1.default.bold(`\uD83D\uDCC8 Productivity Metrics (${x} days)`),"┌─────────────────────┬──────────────┐",`│ ${M1.default.bold("Metric")} │ ${M1.default.bold("Value")} │`,"├─────────────────────┼──────────────┤",`│ Sessions │ ${String(J.sessions).padEnd(12)} │`,`│ Tasks Completed │ ${String(J.tasksCompleted).padEnd(12)} │`,`│ Files Changed │ ${String(J.filesChanged).padEnd(12)} │`,`│ Lines Added │ ${M1.default.green("+"+J.linesAdded).padEnd(12)} │`,`│ Lines Removed │ ${M1.default.red("-"+J.linesRemoved).padEnd(12)} │`,"└─────────────────────┴──────────────┘"].join(`
|
|
197
|
-
`);F(X,"Overview");let j=Object.entries(J.skillsUsed).sort(([,M],[,R])=>R-M).slice(0,5);if(j.length>0){let M=[M1.default.bold("\uD83C\uDFC6 Top Skills Used"),...j.map(([R,S],Y)=>` ${Y+1}. ${R} (${S})`)].join(`
|
|
198
|
-
`);F(M,"Skills")}m(M1.default.dim(`Data stored in: ${G}`))}import{existsSync as v3,mkdirSync as mN,writeFileSync as iN,readdirSync as kN,readFileSync as hN}from"node:fs";import{join as l2}from"node:path";var E=i(x1(),1);import{existsSync as O2,readdirSync as bN,readFileSync as S$}from"node:fs";import{join as H$}from"node:path";function y2($){return H$($,".serena","memories")}function W3($){let I=y2($);if(!O2(I))return[];try{return bN(I).filter((N)=>N.endsWith(".md")&&N!==".gitkeep")}catch{return[]}}function O3($,I){let N=$.match(/^progress-(\w+)\.md$/),G=$.match(/^result-(\w+)\.md$/);if(N)return{agent:N[1],type:"progress",content:I.slice(0,500)};if(G)return{agent:G[1],type:"result",content:I.slice(0,500)};return null}function y3($){let I=y2($),N={agents:[],activities:[],completedTasks:[],inProgressTasks:[]};if(!O2(I))return N;let G=W3($);for(let J of G){if(J==="orchestrator-session.md"){try{let z=S$(H$(I,J),"utf-8").match(/session[:\s]+(\S+)/i);if(z)N.sessionId=z[1]}catch{}continue}try{let Z=S$(H$(I,J),"utf-8"),z=O3(J,Z);if(z){if(N.activities.push(z),!N.agents.includes(z.agent))N.agents.push(z.agent);if(z.type==="result"){let x=Z.match(/task[:\s]+(.+)/i)||Z.match(/##\s*(.+)/);if(x)N.completedTasks.push(x[1].trim())}else if(z.type==="progress"){let x=Z.match(/current[:\s]+(.+)/i)||Z.match(/working on[:\s]+(.+)/i);if(x&&!N.completedTasks.includes(x[1].trim()))N.inProgressTasks.push(x[1].trim())}}}catch{}}return N}function E3($,I){let N=[],G=y2($);if(!O2(G))return N;let J=I?new Date(I).getTime():0,Z=W3($);for(let z of Z){if(z==="orchestrator-session.md")continue;try{let x=H$(G,z),Q=S$(x),X=S$(x,"utf-8"),j=O3(z,X);if(j)N.push(j)}catch{}}return N}function l3($){let I=[];for(let N of $){let G=N.content.toLowerCase();if(G.includes("error")||G.includes("fail"))I.push(`${N.agent}: Error handling improved`);if(G.includes("refactor"))I.push(`${N.agent}: Code structure refactored`);if(G.includes("test"))I.push(`${N.agent}: Test coverage added`);if(G.includes("performance")||G.includes("optimize"))I.push(`${N.agent}: Performance optimized`)}return[...new Set(I)].slice(0,5)}function u2($){return l2($,".serena","retrospectives")}function nN($){let I=u2($);if(!v3(I))return[];try{return kN(I).filter((G)=>G.endsWith(".json")).sort().reverse().slice(0,10).map((G)=>JSON.parse(hN(l2(I,G),"utf-8")))}catch{return[]}}function E2($,I){let N=u2($);if(!v3(N))mN(N,{recursive:!0});let G=`${I.date.replace(/[:.]/g,"-")}_${I.id}.json`;iN(l2(N,G),JSON.stringify(I,null,2),"utf-8")}function u3($){let I=V3($),N=f3($,I),G=_3(N),J=K$($),Z=y3($),z=E3($,I||void 0),x=Object.entries(G).sort(([,M],[,R])=>R-M)[0],Q="Development session";if(x){let[M]=x;Q={feat:"Feature development",fix:"Bug fixes and improvements",refactor:"Code refactoring",docs:"Documentation updates",test:"Testing improvements",chore:"Maintenance tasks",build:"Build system updates",perf:"Performance improvements"}[M]||"Development session"}if(J.filesChanged>0)Q+=` (${J.filesChanged} files, +${J.linesAdded}/-${J.linesRemoved})`;if(Z.agents.length>0)Q+=` with ${Z.agents.join(", ")}`;let X=l3(z);if(N.length>0&&X.length===0){if(G.refactor||G.perf)X.push("Code quality and performance improvements");if(G.test)X.push("Enhanced test coverage");if(G.fix)X.push("Issue resolution and stability improvements")}let j=[];if(Z.inProgressTasks.length>0)j.push(...Z.inProgressTasks.slice(0,3));if(N.length>0){let M=N[0]?.toLowerCase()||"";if(M.includes("wip")||M.includes("todo"))j.push("Complete work-in-progress items")}if(j.length===0)j.push("Continue development","Review and test changes");return{summary:Q,learnings:X.slice(0,5),nextSteps:j.slice(0,5)}}async function w3($=!1,I=!1){let N=process.cwd(),G=u2(N),J=nN(N);if($){console.log(JSON.stringify({retrospectives:J},null,2));return}if(!I){let{summary:S,learnings:Y,nextSteps:K}=u3(N),T=Y$(N),C={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:S,keyLearnings:Y,filesChanged:T,nextSteps:K};E2(N,C),console.clear(),t(E.default.bgMagenta(E.default.white(" \uD83D\uDD04 oh-my-ag retro "))),F([E.default.green("✅ Auto-generated retrospective saved!"),"",E.default.bold("Summary:"),S,"",E.default.bold("Key Learnings:"),...Y.map((U)=>` • ${U}`),"",E.default.bold("Next Steps:"),...K.map((U)=>` → ${U}`)].join(`
|
|
199
|
-
`),"Saved"),m(E.default.dim(`Stored in: ${G}`));return}console.clear(),t(E.default.bgMagenta(E.default.white(" \uD83D\uDD04 oh-my-ag retro (interactive) ")));let Z=J[0];if(Z)F([E.default.bold("\uD83D\uDCC5 Last Retrospective"),`Date: ${Z.date}`,"",E.default.bold("Summary:"),Z.summary,"",E.default.bold("Key Learnings:"),...Z.keyLearnings.map((S)=>` • ${S}`),"",E.default.bold("Next Steps:"),...Z.nextSteps.map((S)=>` → ${S}`)].join(`
|
|
200
|
-
`),"Previous Session");let z=await p1({message:"What would you like to do?",options:[{value:"auto",label:"✨ Auto-generate from git history",hint:"Analyze commits and agent activity"},{value:"manual",label:"\uD83D\uDCDD Create manually",hint:"Write your own retrospective"},{value:"list",label:"\uD83D\uDCCB View past retrospectives"},{value:"exit",label:"\uD83D\uDC4B Exit"}]});if(d(z)||z==="exit"){m(E.default.dim("Goodbye!"));return}if(z==="list"){if(J.length===0)F(E.default.yellow("No retrospectives found."),"History");else{let S=J.map((Y,K)=>`${K+1}. [${Y.date.split("T")[0]}] ${Y.summary.slice(0,50)}...`).join(`
|
|
201
|
-
`);F(S,`\uD83D\uDCDA Past Retrospectives (${J.length})`)}m(E.default.dim(`Stored in: ${G}`));return}if(z==="auto"){let{summary:S,learnings:Y,nextSteps:K}=u3(N),T=Y$(N);F([E.default.bold("\uD83E\uDD16 Auto-generated Content"),"",E.default.bold("Summary:"),S,"",E.default.bold("Key Learnings:"),...Y.map((B)=>` • ${B}`),"",E.default.bold("Next Steps:"),...K.map((B)=>` → ${B}`)].join(`
|
|
202
|
-
`),"Preview");let C=await G$({message:"Save this retrospective?",initialValue:!0});if(d(C)||!C){G1("Cancelled.");return}let U={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:S,keyLearnings:Y,filesChanged:T,nextSteps:K};E2(N,U),F([E.default.green("✅ Retrospective saved!"),"",`Summary: ${U.summary}`,`Learnings: ${U.keyLearnings.length} items`,`Next steps: ${U.nextSteps.length} items`].join(`
|
|
203
|
-
`),"Saved"),m(E.default.dim(`Stored in: ${G}`));return}let x=D3(N),Q=Y$(N);if(x.length>0)F(x.join(`
|
|
204
|
-
`),"Recent Commits");if(Q.length>0)F(Q.join(`
|
|
205
|
-
`),"Changed Files");let X=await Z$({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(d(X)){G1("Cancelled.");return}let j=await Z$({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(d(j)){G1("Cancelled.");return}let M=await Z$({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(d(M)){G1("Cancelled.");return}let R={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:X,keyLearnings:j.split(",").map((S)=>S.trim()).filter(Boolean),filesChanged:Q,nextSteps:M.split(",").map((S)=>S.trim()).filter(Boolean)};E2(N,R),F([E.default.green("✅ Retrospective saved!"),"",`Summary: ${R.summary}`,`Learnings: ${R.keyLearnings.length} items`,`Next steps: ${R.nextSteps.length} items`].join(`
|
|
206
|
-
`),"Saved"),m(E.default.dim(`Stored in: ${G}`))}import{existsSync as v2,readFileSync as w2,readdirSync as b2}from"node:fs";import{execSync as p}from"node:child_process";import{join as q0}from"node:path";var e=i(x1(),1);async function b3($=!1,I=!1){let N=process.cwd(),G=q0(N,".agent","results"),J="/tmp",Z={cleaned:0,skipped:0,details:[]},z=(X)=>{Z.details.push($?`[DRY-RUN] ${X}`:`[CLEAN] ${X}`),Z.cleaned++},x=(X)=>{Z.details.push(`[SKIP] ${X}`),Z.skipped++};try{let X=b2("/tmp").filter((j)=>j.startsWith("subagent-")&&j.endsWith(".pid"));for(let j of X){let M=q0("/tmp",j),R=w2(M,"utf-8").trim();if(!R){if(z(`Removing empty PID file: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}continue}let S=parseInt(R,10);if(isNaN(S)){if(z(`Removing invalid PID file: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}continue}try{if(p(`kill -0 ${S} 2>/dev/null`),z(`Killing orphaned process PID=${S} (from ${M})`),!$)try{p(`kill ${S} 2>/dev/null || true`),await new Promise((Y)=>setTimeout(Y,1000));try{p(`kill -0 ${S} 2>/dev/null`),p(`kill -9 ${S} 2>/dev/null || true`)}catch{}p(`rm -f "${M}"`)}catch{}}catch{if(z(`Removing stale PID file (process gone): ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}}}}catch{}try{let X=b2("/tmp").filter((j)=>j.startsWith("subagent-")&&j.endsWith(".log"));for(let j of X){let M=q0("/tmp",j),R=j.replace(".log",".pid"),S=q0("/tmp",R);if(v2(S))try{let Y=w2(S,"utf-8").trim(),K=parseInt(Y,10);if(!isNaN(K)){p(`kill -0 ${K} 2>/dev/null`),x(`Log file has active process: ${M}`);continue}}catch{}if(z(`Removing stale log file: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}}}catch{}if(v2(G))try{let X=b2(G).filter((j)=>j.startsWith("parallel-"));for(let j of X){let M=q0(G,j,"pids.txt");if(!v2(M))continue;let S=w2(M,"utf-8").split(`
|
|
207
|
-
`).filter((K)=>K.trim()),Y=!1;for(let K of S){let[T,C]=K.split(":"),U=parseInt(T?.trim()||"",10);if(isNaN(U))continue;try{if(p(`kill -0 ${U} 2>/dev/null`),Y=!0,z(`Killing orphaned parallel agent PID=${U} (${C?.trim()||"unknown"})`),!$)try{p(`kill ${U} 2>/dev/null || true`),p(`rm -f "${M}"`)}catch{}}catch{}}if(!Y){if(z(`Removing stale PID list: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}}else if(!$){await new Promise((K)=>setTimeout(K,1000));try{p(`rm -f "${M}"`)}catch{}}}}catch{}else x(`No results directory found: ${G}`);if(I){console.log(JSON.stringify(Z,null,2));return}if(console.clear(),t(e.default.bgMagenta(e.default.white(" \uD83E\uDDF9 oh-my-ag cleanup "))),$)F(e.default.yellow("Dry-run mode — no changes will be made"),"Mode");if(Z.details.length>0){let X=[e.default.bold("Cleanup Details"),...Z.details.map((j)=>{if(j.startsWith("[DRY-RUN]"))return e.default.yellow(j);if(j.startsWith("[CLEAN]"))return e.default.green(j);return e.default.cyan(j)})].join(`
|
|
208
|
-
`);F(X,"Details")}let Q=[e.default.bold("Summary"),"┌─────────┬────────┐",`│ ${e.default.bold("Action")} │ ${e.default.bold("Count")} │`,"├─────────┼────────┤",`│ Cleaned │ ${String(Z.cleaned).padEnd(6)} │`,`│ Skipped │ ${String(Z.skipped).padEnd(6)} │`,"└─────────┴────────┘"].join(`
|
|
209
|
-
`);if(F(Q,"Results"),$)m(e.default.yellow("Run without --dry-run to apply changes"));else m(e.default.green("Cleanup complete!"))}var cN="1.1.1",C1=new N4;C1.name("oh-my-ag").description("Multi-Agent Skills for Antigravity IDE").version(cN).action(()=>{K3().catch(console.error)});C1.command("dashboard").description("Start terminal dashboard (real-time agent monitoring)").action(()=>{l8()});C1.command("dashboard:web").description("Start web dashboard on http://localhost:9847").action(()=>{y8()});C1.command("update").description("Update skills to latest version from registry").action(()=>{B3().catch(console.error)});C1.command("doctor").description("Check CLI installations, MCP configs, and skill status").option("--json","Output as JSON for CI/CD").action(($)=>{g3($.json).catch(console.error)});C1.command("stats").description("View productivity metrics").option("--json","Output as JSON").option("--reset","Reset metrics data").action(($)=>{F3($.json,$.reset).catch(console.error)});C1.command("retro").description("Session retrospective (learnings & next steps)").option("--json","Output as JSON").option("--interactive","Interactive mode (manual entry)").action(($)=>{w3($.json,$.interactive).catch(console.error)});C1.command("cleanup").description("Clean up orphaned subagent processes and temp files").option("--dry-run","Show what would be cleaned without making changes").option("--json","Output as JSON").action(($)=>{b3($.dryRun,$.json).catch(console.error)});C1.parse();
|
|
206
|
+
</html>`;function a3(){let $=kJ();if(!vJ($))uJ($,{recursive:!0});let J=lJ((X,Q)=>{if(X.url==="/api/state")Q.writeHead(200,{"Content-Type":"application/json"}),Q.end(JSON.stringify(c2($)));else Q.writeHead(200,{"Content-Type":"text/html"}),Q.end(nJ)}),N=new h2.default({server:J}),G=null;function Z(X,Q){if(G)clearTimeout(G);G=setTimeout(()=>{let M=JSON.stringify({type:"update",event:X,file:Q,data:c2($)});N.clients.forEach((I)=>{if(I.readyState===m2.default.OPEN)I.send(M)})},100)}let z=M$($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});z.on("all",(X,Q)=>Z(X,r3(Q))),N.on("connection",(X)=>{X.send(JSON.stringify({type:"full",data:c2($)})),X.on("error",()=>X.terminate())}),process.on("SIGINT",()=>{console.log(`
|
|
207
|
+
Shutting down...`),z.close(),N.clients.forEach((X)=>{X.terminate()}),N.close(()=>J.close(()=>process.exit(0))),setTimeout(()=>process.exit(1),3000).unref()}),process.on("SIGTERM",()=>process.emit("SIGINT")),J.listen(o3,()=>{console.log(J0.magenta(`
|
|
208
|
+
\uD83D\uDEF8 Serena Memory Dashboard`)),console.log(J0.white(` http://localhost:${o3}`)),console.log(J0.dim(` Watching: ${$}
|
|
209
|
+
`))})}import{existsSync as pJ,mkdirSync as sJ,readdirSync as D0,readFileSync as oJ,statSync as p2}from"node:fs";import{basename as rJ,join as x1}from"node:path";var n=k(N1(),1),aJ="●",tJ="✓",eJ="✗",$N="○",JN="◌";function NN(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return x1($,".serena","memories");return x1(process.cwd(),".serena","memories")}function P0($){try{return oJ($,"utf-8")}catch{return""}}function GN($){try{let J=D0($);if(J.includes("orchestrator-session.md"))return x1($,"orchestrator-session.md");let N=J.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:p2(x1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime);if(N.length>0&&N[0])return x1($,N[0].name)}catch{}return null}function ZN($){let J=GN($);if(!J)return{id:"N/A",status:"UNKNOWN"};let N=P0(J);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||rJ(J,".md"),Z="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))Z="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))Z="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))Z="FAILED";else if(/Step \d+:.*\[/i.test(N))Z="RUNNING";return{id:(G||"N/A").trim(),status:Z}}function zN($){let J=P0(x1($,"task-board.md"));if(!J)return[];let N=[],G=J.split(`
|
|
210
|
+
`);for(let Z of G){if(!Z.startsWith("|")||/^\|\s*-+/.test(Z))continue;let z=Z.split("|").map((I)=>I.trim()).filter(Boolean),X=z[0];if(z.length<2||!X||/^agent$/i.test(X))continue;let Q=z[1],M=z[2];N.push({agent:X,status:Q||"pending",task:M||""})}return N}function n2($,J){try{let N=D0($).filter((z)=>z.startsWith(`progress-${J}`)&&z.endsWith(".md")).sort().reverse();if(N.length===0||!N[0])return null;let Z=P0(x1($,N[0])).match(/turn[:\s]*(\d+)/i);return Z?.[1]?parseInt(Z[1],10):null}catch{return null}}function XN($){try{let J=D0($).filter((G)=>G.endsWith(".md")&&G!==".gitkeep").map((G)=>({name:G,mtime:p2(x1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime).slice(0,5),N=[];for(let G of J){let Z=G.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||G.name.replace(/\.md$/,""),X=P0(x1($,G.name)).split(`
|
|
211
|
+
`).map((M)=>M.trim()).filter((M)=>M&&!M.startsWith("---")&&M.length>3),Q="";for(let M=X.length-1;M>=0;M--){let I=X[M];if(!I)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(I)){if(Q=I.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),Q.length>5)break}}if(Q.length>52)Q=`${Q.substring(0,49)}...`;if(Q)N.push({agent:Z,message:Q})}return N}catch{return[]}}function QN($){let J=[],N=new Set;try{let G=D0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:p2(x1($,Z)).mtimeMs})).sort((Z,z)=>z.mtime-Z.mtime);for(let Z of G){let z=P0(x1($,Z.name)),X=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(X?.[1])Q=X[1].trim();else if(/_agent|agent_|-agent/i.test(Z.name))Q=Z.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!N.has(Q.toLowerCase())){N.add(Q.toLowerCase());let M="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))M="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))M="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))M="failed";let I=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),K=I?.[1]?I[1].trim().substring(0,20):"";J.push({agent:Q,status:M,task:K,turn:n2($,Q)})}}}catch{}return J}function MN($){let J=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(J))return`${n.default.green(aJ)} running`;else if(["completed","done","finished"].includes(J))return`${n.default.cyan(tJ)} completed`;else if(["failed","error"].includes(J))return`${n.default.red(eJ)} failed`;else if(["blocked","waiting"].includes(J))return`${n.default.yellow($N)} blocked`;return`${n.default.dim(JN)} pending`}function t3($){console.clear();let J=ZN($),G=zN($).map((j)=>({...j,turn:n2($,j.agent)}));if(G.length===0)G=QN($);if(G.length===0)try{let j=D0($).filter((U)=>U.startsWith("progress-")&&U.endsWith(".md"));for(let U of j){let T=U.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:T,status:"running",task:"",turn:n2($,T)})}}catch{}let Z=56,z="═".repeat(Z),X=(j)=>" ".repeat(Math.max(0,j)),Q=(j)=>n.default.magenta(j),M=(j)=>n.default.bold(j),I=(j)=>n.default.dim(j),K=n.default.yellow;if(J.status==="RUNNING")K=n.default.green;else if(J.status==="COMPLETED")K=n.default.cyan;else if(J.status==="FAILED")K=n.default.red;console.log(`${Q(`╔${z}╗`)}`),console.log(`${Q("║")} ${M(Q("Serena Memory Dashboard"))}${X(Z-25)}${Q("║")}`);let Y=`Session: ${M(J.id.padEnd(20))} [${K(J.status)}]`;if(console.log(`${Q("║")} ${Y}${X(Z-4-Y.length-9)}${Q("║")}`),console.log(`${Q(`╠${z}╣`)}`),console.log(`${Q("║")} ${M(`${"Agent".padEnd(12)} ${"Status".padEnd(12)} ${"Turn".padEnd(6)} ${"Task".padEnd(20)}`)} ${Q("║")}`),console.log(`${Q("║")} ${I(`${"──────────".padEnd(12)} ${"──────────".padEnd(12)} ${"────".padEnd(6)} ${"──────────────────".padEnd(20)}`)} ${Q("║")}`),G.length===0)console.log(`${Q("║")} ${I(`No agents detected yet${X(32)}`)}${Q("║")}`);else for(let j of G){let U=MN(j.status),T=j.turn!=null?String(j.turn):"-",B=j.task.substring(0,20);console.log(`${Q("║")} ${j.agent.padEnd(12)} ${U.padEnd(22)} ${T.padEnd(6)} ${B.padEnd(20)}${Q("║")}`)}console.log(`${Q(`╠${z}╣`)}`),console.log(`${Q("║")} ${M("Latest Activity:")}${X(Z-18)}${Q("║")}`);let H=XN($);if(H.length===0)console.log(`${Q("║")} ${I(`No activity yet${X(38)}`)}${Q("║")}`);else for(let j of H){let U=`[${j.agent}] ${j.message}`;console.log(`${Q("║")} ${I(U.substring(0,52).padEnd(52))}${Q("║")}`)}console.log(`${Q(`╠${z}╣`)}`);let x=`Updated: ${new Date().toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})} | Ctrl+C to exit`;console.log(`${Q("║")} ${I(x)}${X(Z-4-x.length)}${Q("║")}`),console.log(`${Q(`╚${z}╝`)}`)}function e3(){let $=NN();if(!pJ($))sJ($,{recursive:!0}),console.log(n.default.yellow(`Created ${$} — waiting for memory files...`));console.log(n.default.magenta(`
|
|
212
|
+
\uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(n.default.dim(` Watching: ${$}
|
|
213
|
+
`)),t3($);let J=M$($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});J.on("all",()=>t3($)),process.on("SIGINT",()=>{console.log(`
|
|
214
|
+
`),J.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var IN="1.1.1",X1=new Y4;X1.name("oh-my-ag").description("Multi-Agent Skills for Antigravity IDE").version(IN).action(()=>{a4().catch(console.error)});X1.command("dashboard").description("Start terminal dashboard (real-time agent monitoring)").action(()=>{e3()});X1.command("dashboard:web").description("Start web dashboard on http://localhost:9847").action(()=>{a3()});X1.command("update").description("Update skills to latest version from registry").action(()=>{C8().catch(console.error)});X1.command("doctor").description("Check CLI installations, MCP configs, and skill status").option("--json","Output as JSON for CI/CD").action(($)=>{p4($.json).catch(console.error)});X1.command("stats").description("View productivity metrics").option("--json","Output as JSON").option("--reset","Reset metrics data").action(($)=>{x8($.json,$.reset).catch(console.error)});X1.command("retro").description("Session retrospective (learnings & next steps)").option("--json","Output as JSON").option("--interactive","Interactive mode (manual entry)").action(($)=>{Y8($.json,$.interactive).catch(console.error)});X1.command("cleanup").description("Clean up orphaned subagent processes and temp files").option("--dry-run","Show what would be cleaned without making changes").option("--json","Output as JSON").action(($)=>{c4($.dryRun,$.json).catch(console.error)});X1.command("bridge [url]").description("Bridge MCP stdio to SSE (for Serena)").action(($)=>{q4($).catch(console.error)});X1.command("agent:spawn <agent-id> <prompt-file> <session-id> <workspace>").description("Spawn a subagent (wraps gemini with logging and PID tracking)").action(($,J,N,G)=>{H4($,J,N,G).catch(console.error)});X1.command("agent:status <session-id> [agent-ids...]").description("Check status of subagents").option("-r, --root <path>","Root path for memory checks",process.cwd()).action(($,J,N)=>{R4($,J,N.root).catch(console.error)});X1.parse();
|