oh-my-ag 1.3.0 → 1.4.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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/bin/cli.js +144 -140
  3. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -1,119 +1,34 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as r9}from"node:module";var i9=Object.create;var{getPrototypeOf:n9,defineProperty:V4,getOwnPropertyNames:s9}=Object;var o9=Object.prototype.hasOwnProperty;var s=($,G,J)=>{J=$!=null?i9(n9($)):{};let Z=G||!$||!$.__esModule?V4(J,"default",{value:$,enumerable:!0}):J;for(let X of s9($))if(!o9.call(Z,X))V4(Z,X,{get:()=>$[X],enumerable:!0});return Z};var u=($,G)=>()=>(G||$((G={exports:{}}).exports,G),G.exports);var w=r9(import.meta.url);var n1=u((a9)=>{class J2 extends Error{constructor($,G,J){super(J);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=G,this.exitCode=$,this.nestedError=void 0}}class M4 extends J2{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}a9.CommanderError=J2;a9.InvalidArgumentError=M4});var _0=u((J$)=>{var{InvalidArgumentError:$$}=n1();class T4{constructor($,G){switch(this.description=G||"",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($,G){if(G===this.defaultValue||!Array.isArray(G))return[$];return G.concat($)}default($,G){return this.defaultValue=$,this.defaultValueDescription=G,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(G,J)=>{if(!this.argChoices.includes(G))throw new $$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(G,J);return G},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function G$($){let G=$.name()+($.variadic===!0?"...":"");return $.required?"<"+G+">":"["+G+"]"}J$.Argument=T4;J$.humanReadableArgName=G$});var Z2=u((Q$)=>{var{humanReadableArgName:z$}=_0();class x4{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let G=$.commands.filter((Z)=>!Z._hidden),J=$._getHelpCommand();if(J&&!J._hidden)G.push(J);if(this.sortSubcommands)G.sort((Z,X)=>{return Z.name().localeCompare(X.name())});return G}compareOptions($,G){let J=(Z)=>{return Z.short?Z.short.replace(/^-/,""):Z.long.replace(/^--/,"")};return J($).localeCompare(J(G))}visibleOptions($){let G=$.options.filter((Z)=>!Z.hidden),J=$._getHelpOption();if(J&&!J.hidden){let Z=J.short&&$._findOption(J.short),X=J.long&&$._findOption(J.long);if(!Z&&!X)G.push(J);else if(J.long&&!X)G.push($.createOption(J.long,J.description));else if(J.short&&!Z)G.push($.createOption(J.short,J.description))}if(this.sortOptions)G.sort(this.compareOptions);return G}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let G=[];for(let J=$.parent;J;J=J.parent){let Z=J.options.filter((X)=>!X.hidden);G.push(...Z)}if(this.sortOptions)G.sort(this.compareOptions);return G}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((G)=>{G.description=G.description||$._argsDescription[G.name()]||""});if($.registeredArguments.find((G)=>G.description))return $.registeredArguments;return[]}subcommandTerm($){let G=$.registeredArguments.map((J)=>z$(J)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(G?" "+G:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,G){return G.visibleCommands($).reduce((J,Z)=>{return Math.max(J,G.subcommandTerm(Z).length)},0)}longestOptionTermLength($,G){return G.visibleOptions($).reduce((J,Z)=>{return Math.max(J,G.optionTerm(Z).length)},0)}longestGlobalOptionTermLength($,G){return G.visibleGlobalOptions($).reduce((J,Z)=>{return Math.max(J,G.optionTerm(Z).length)},0)}longestArgumentTermLength($,G){return G.visibleArguments($).reduce((J,Z)=>{return Math.max(J,G.argumentTerm(Z).length)},0)}commandUsage($){let G=$._name;if($._aliases[0])G=G+"|"+$._aliases[0];let J="";for(let Z=$.parent;Z;Z=Z.parent)J=Z.name()+" "+J;return J+G+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let G=[];if($.argChoices)G.push(`choices: ${$.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")G.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)G.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)G.push(`env: ${$.envVar}`);if(G.length>0)return`${$.description} (${G.join(", ")})`;return $.description}argumentDescription($){let G=[];if($.argChoices)G.push(`choices: ${$.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if($.defaultValue!==void 0)G.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(G.length>0){let J=`(${G.join(", ")})`;if($.description)return`${$.description} ${J}`;return J}return $.description}formatHelp($,G){let J=G.padWidth($,G),Z=G.helpWidth||80,X=2,z=2;function N(_,q){if(q){let B=`${_.padEnd(J+2)}${q}`;return G.wrap(B,Z-2,J+2)}return _}function Q(_){return _.join(`
3
- `).replace(/^/gm," ".repeat(2))}let Y=[`Usage: ${G.commandUsage($)}`,""],K=G.commandDescription($);if(K.length>0)Y=Y.concat([G.wrap(K,Z,0),""]);let I=G.visibleArguments($).map((_)=>{return N(G.argumentTerm(_),G.argumentDescription(_))});if(I.length>0)Y=Y.concat(["Arguments:",Q(I),""]);let H=G.visibleOptions($).map((_)=>{return N(G.optionTerm(_),G.optionDescription(_))});if(H.length>0)Y=Y.concat(["Options:",Q(H),""]);if(this.showGlobalOptions){let _=G.visibleGlobalOptions($).map((q)=>{return N(G.optionTerm(q),G.optionDescription(q))});if(_.length>0)Y=Y.concat(["Global Options:",Q(_),""])}let U=G.visibleCommands($).map((_)=>{return N(G.subcommandTerm(_),G.subcommandDescription(_))});if(U.length>0)Y=Y.concat(["Commands:",Q(U),""]);return Y.join(`
4
- `)}padWidth($,G){return Math.max(G.longestOptionTermLength($,G),G.longestGlobalOptionTermLength($,G),G.longestSubcommandTermLength($,G),G.longestArgumentTermLength($,G))}wrap($,G,J,Z=40){let z=new RegExp(`[\\n][${" \\f\\t\\v   -    \uFEFF"}]+`);if($.match(z))return $;let N=G-J;if(N<Z)return $;let Q=$.slice(0,J),Y=$.slice(J).replace(`\r
2
+ import{createRequire as d3}from"node:module";var k3=Object.create;var{getPrototypeOf:h3,defineProperty:m2,getOwnPropertyNames:n3}=Object;var c3=Object.prototype.hasOwnProperty;var i=($,I,N)=>{N=$!=null?k3(h3($)):{};let G=I||!$||!$.__esModule?m2(N,"default",{value:$,enumerable:!0}):N;for(let J of n3($))if(!c3.call(G,J))m2(G,J,{get:()=>$[J],enumerable:!0});return G};var v=($,I)=>()=>(I||$((I={exports:{}}).exports,I),I.exports);var O=d3(import.meta.url);var a1=v((p3)=>{class T$ extends Error{constructor($,I,N){super(N);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=I,this.exitCode=$,this.nestedError=void 0}}class i2 extends T${constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}p3.CommanderError=T$;p3.InvalidArgumentError=i2});var B0=v((t3)=>{var{InvalidArgumentError:r3}=a1();class k2{constructor($,I){switch(this.description=I||"",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($,I){if(I===this.defaultValue||!Array.isArray(I))return[$];return I.concat($)}default($,I){return this.defaultValue=$,this.defaultValueDescription=I,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(I,N)=>{if(!this.argChoices.includes(I))throw new r3(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(I,N);return I},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function a3($){let I=$.name()+($.variadic===!0?"...":"");return $.required?"<"+I+">":"["+I+"]"}t3.Argument=k2;t3.humanReadableArgName=a3});var U$=v((N5)=>{var{humanReadableArgName:I5}=B0();class h2{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let I=$.commands.filter((G)=>!G._hidden),N=$._getHelpCommand();if(N&&!N._hidden)I.push(N);if(this.sortSubcommands)I.sort((G,J)=>{return G.name().localeCompare(J.name())});return I}compareOptions($,I){let N=(G)=>{return G.short?G.short.replace(/^-/,""):G.long.replace(/^--/,"")};return N($).localeCompare(N(I))}visibleOptions($){let I=$.options.filter((G)=>!G.hidden),N=$._getHelpOption();if(N&&!N.hidden){let G=N.short&&$._findOption(N.short),J=N.long&&$._findOption(N.long);if(!G&&!J)I.push(N);else if(N.long&&!J)I.push($.createOption(N.long,N.description));else if(N.short&&!G)I.push($.createOption(N.short,N.description))}if(this.sortOptions)I.sort(this.compareOptions);return I}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let I=[];for(let N=$.parent;N;N=N.parent){let G=N.options.filter((J)=>!J.hidden);I.push(...G)}if(this.sortOptions)I.sort(this.compareOptions);return I}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((I)=>{I.description=I.description||$._argsDescription[I.name()]||""});if($.registeredArguments.find((I)=>I.description))return $.registeredArguments;return[]}subcommandTerm($){let I=$.registeredArguments.map((N)=>I5(N)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(I?" "+I:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,I){return I.visibleCommands($).reduce((N,G)=>{return Math.max(N,I.subcommandTerm(G).length)},0)}longestOptionTermLength($,I){return I.visibleOptions($).reduce((N,G)=>{return Math.max(N,I.optionTerm(G).length)},0)}longestGlobalOptionTermLength($,I){return I.visibleGlobalOptions($).reduce((N,G)=>{return Math.max(N,I.optionTerm(G).length)},0)}longestArgumentTermLength($,I){return I.visibleArguments($).reduce((N,G)=>{return Math.max(N,I.argumentTerm(G).length)},0)}commandUsage($){let I=$._name;if($._aliases[0])I=I+"|"+$._aliases[0];let N="";for(let G=$.parent;G;G=G.parent)N=G.name()+" "+N;return N+I+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let I=[];if($.argChoices)I.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")I.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)I.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)I.push(`env: ${$.envVar}`);if(I.length>0)return`${$.description} (${I.join(", ")})`;return $.description}argumentDescription($){let I=[];if($.argChoices)I.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0)I.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(I.length>0){let N=`(${I.join(", ")})`;if($.description)return`${$.description} ${N}`;return N}return $.description}formatHelp($,I){let N=I.padWidth($,I),G=I.helpWidth||80,J=2,Z=2;function z(S,Y){if(Y){let K=`${S.padEnd(N+2)}${Y}`;return I.wrap(K,G-2,N+2)}return S}function x(S){return S.join(`
3
+ `).replace(/^/gm," ".repeat(2))}let Q=[`Usage: ${I.commandUsage($)}`,""],X=I.commandDescription($);if(X.length>0)Q=Q.concat([I.wrap(X,G,0),""]);let j=I.visibleArguments($).map((S)=>{return z(I.argumentTerm(S),I.argumentDescription(S))});if(j.length>0)Q=Q.concat(["Arguments:",x(j),""]);let M=I.visibleOptions($).map((S)=>{return z(I.optionTerm(S),I.optionDescription(S))});if(M.length>0)Q=Q.concat(["Options:",x(M),""]);if(this.showGlobalOptions){let S=I.visibleGlobalOptions($).map((Y)=>{return z(I.optionTerm(Y),I.optionDescription(Y))});if(S.length>0)Q=Q.concat(["Global Options:",x(S),""])}let R=I.visibleCommands($).map((S)=>{return z(I.subcommandTerm(S),I.subcommandDescription(S))});if(R.length>0)Q=Q.concat(["Commands:",x(R),""]);return Q.join(`
4
+ `)}padWidth($,I){return Math.max(I.longestOptionTermLength($,I),I.longestGlobalOptionTermLength($,I),I.longestSubcommandTermLength($,I),I.longestArgumentTermLength($,I))}wrap($,I,N,G=40){let Z=new RegExp(`[\\n][${" \\f\\t\\v   -    \uFEFF"}]+`);if($.match(Z))return $;let z=I-N;if(z<G)return $;let x=$.slice(0,N),Q=$.slice(N).replace(`\r
5
5
  `,`
6
- `),K=" ".repeat(J),H=`\\s${"​"}`,U=new RegExp(`
7
- |.{1,${N-1}}([${H}]|$)|[^${H}]+?([${H}]|$)`,"g"),_=Y.match(U)||[];return Q+_.map((q,B)=>{if(q===`
8
- `)return"";return(B>0?K:"")+q.trimEnd()}).join(`
9
- `)}}Q$.Help=x4});var X2=u((I$)=>{var{InvalidArgumentError:Y$}=n1();class W4{constructor($,G){this.flags=$,this.description=G||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let J=H$($);if(this.short=J.shortFlag,this.long=J.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($,G){return this.defaultValue=$,this.defaultValueDescription=G,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let G=$;if(typeof $==="string")G={[$]:!0};return this.implied=Object.assign(this.implied||{},G),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,G){if(G===this.defaultValue||!Array.isArray(G))return[$];return G.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(G,J)=>{if(!this.argChoices.includes(G))throw new Y$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(G,J);return G},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return K$(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class L4{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((G)=>{if(G.negate)this.negativeOptions.set(G.attributeName(),G);else this.positiveOptions.set(G.attributeName(),G)}),this.negativeOptions.forEach((G,J)=>{if(this.positiveOptions.has(J))this.dualOptions.add(J)})}valueFromOption($,G){let J=G.attributeName();if(!this.dualOptions.has(J))return!0;let Z=this.negativeOptions.get(J).presetArg,X=Z!==void 0?Z:!1;return G.negate===(X===$)}}function K$($){return $.split("-").reduce((G,J)=>{return G+J[0].toUpperCase()+J.slice(1)})}function H$($){let G,J,Z=$.split(/[ |,]+/);if(Z.length>1&&!/^[[<]/.test(Z[1]))G=Z.shift();if(J=Z.shift(),!G&&/^-[^-]$/.test(J))G=J,J=void 0;return{shortFlag:G,longFlag:J}}I$.Option=W4;I$.DualOptions=L4});var A4=u((j$)=>{function U$($,G){if(Math.abs($.length-G.length)>3)return Math.max($.length,G.length);let J=[];for(let Z=0;Z<=$.length;Z++)J[Z]=[Z];for(let Z=0;Z<=G.length;Z++)J[0][Z]=Z;for(let Z=1;Z<=G.length;Z++)for(let X=1;X<=$.length;X++){let z=1;if($[X-1]===G[Z-1])z=0;else z=1;if(J[X][Z]=Math.min(J[X-1][Z]+1,J[X][Z-1]+1,J[X-1][Z-1]+z),X>1&&Z>1&&$[X-1]===G[Z-2]&&$[X-2]===G[Z-1])J[X][Z]=Math.min(J[X][Z],J[X-2][Z-2]+1)}return J[$.length][G.length]}function _$($,G){if(!G||G.length===0)return"";G=Array.from(new Set(G));let J=$.startsWith("--");if(J)$=$.slice(2),G=G.map((N)=>N.slice(2));let Z=[],X=3,z=0.4;if(G.forEach((N)=>{if(N.length<=1)return;let Q=U$($,N),Y=Math.max($.length,N.length);if((Y-Q)/Y>z){if(Q<X)X=Q,Z=[N];else if(Q===X)Z.push(N)}}),Z.sort((N,Q)=>N.localeCompare(Q)),J)Z=Z.map((N)=>`--${N}`);if(Z.length>1)return`
10
- (Did you mean one of ${Z.join(", ")}?)`;if(Z.length===1)return`
11
- (Did you mean ${Z[0]}?)`;return""}j$.suggestSimilar=_$});var F4=u((L$)=>{var V$=w("node:events").EventEmitter,z2=w("node:child_process"),q1=w("node:path"),Q2=w("node:fs"),k=w("node:process"),{Argument:M$,humanReadableArgName:T$}=_0(),{CommanderError:N2}=n1(),{Help:x$}=Z2(),{Option:D4,DualOptions:W$}=X2(),{suggestSimilar:C4}=A4();class Y2 extends V${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:(G)=>k.stdout.write(G),writeErr:(G)=>k.stderr.write(G),getOutHelpWidth:()=>k.stdout.isTTY?k.stdout.columns:void 0,getErrHelpWidth:()=>k.stderr.isTTY?k.stderr.columns:void 0,outputError:(G,J)=>J(G)},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 G=this;G;G=G.parent)$.push(G);return $}command($,G,J){let Z=G,X=J;if(typeof Z==="object"&&Z!==null)X=Z,Z=null;X=X||{};let[,z,N]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(z);if(Z)Q.description(Z),Q._executableHandler=!0;if(X.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(X.noHelp||X.hidden),Q._executableFile=X.executableFile||null,N)Q.arguments(N);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),Z)return this;return Q}createCommand($){return new Y2($)}createHelp(){return Object.assign(new x$,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($,G){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
12
- - specify the name in Command constructor or using .name()`);if(G=G||{},G.isDefault)this._defaultCommandName=$._name;if(G.noHelp||G.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,G){return new M$($,G)}argument($,G,J,Z){let X=this.createArgument($,G);if(typeof J==="function")X.default(Z).argParser(J);else X.default(J);return this.addArgument(X),this}arguments($){return $.trim().split(/ +/).forEach((G)=>{this.argument(G)}),this}addArgument($){let G=this.registeredArguments.slice(-1)[0];if(G&&G.variadic)throw Error(`only the last argument can be variadic '${G.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($,G){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,J,Z]=$.match(/([^ ]+) *(.*)/),X=G??"display help for command",z=this.createCommand(J);if(z.helpOption(!1),Z)z.arguments(Z);if(X)z.description(X);return this._addImplicitHelpCommand=!0,this._helpCommand=z,this}addHelpCommand($,G){if(typeof $!=="object")return this.helpCommand($,G),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($,G){let J=["preSubcommand","preAction","postAction"];if(!J.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
13
- Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(G);else this._lifeCycleHooks[$]=[G];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(G)=>{if(G.code!=="commander.executeSubCommandAsync")throw G};return this}_exit($,G,J){if(this._exitCallback)this._exitCallback(new N2($,G,J));k.exit($)}action($){let G=(J)=>{let Z=this.registeredArguments.length,X=J.slice(0,Z);if(this._storeOptionsAsProperties)X[Z]=this;else X[Z]=this.opts();return X.push(this),$.apply(this,X)};return this._actionHandler=G,this}createOption($,G){return new D4($,G)}_callParseArg($,G,J,Z){try{return $.parseArg(G,J)}catch(X){if(X.code==="commander.invalidArgument"){let z=`${Z} ${X.message}`;this.error(z,{exitCode:X.exitCode,code:X.code})}throw X}}_registerOption($){let G=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(G){let J=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${J}'
14
- - already used by option '${G.flags}'`)}this.options.push($)}_registerCommand($){let G=(Z)=>{return[Z.name()].concat(Z.aliases())},J=G($).find((Z)=>this._findCommand(Z));if(J){let Z=G(this._findCommand(J)).join("|"),X=G($).join("|");throw Error(`cannot add command '${X}' as already have command '${Z}'`)}this.commands.push($)}addOption($){this._registerOption($);let G=$.name(),J=$.attributeName();if($.negate){let X=$.long.replace(/^--no-/,"--");if(!this._findOption(X))this.setOptionValueWithSource(J,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(J,$.defaultValue,"default");let Z=(X,z,N)=>{if(X==null&&$.presetArg!==void 0)X=$.presetArg;let Q=this.getOptionValue(J);if(X!==null&&$.parseArg)X=this._callParseArg($,X,Q,z);else if(X!==null&&$.variadic)X=$._concatValue(X,Q);if(X==null)if($.negate)X=!1;else if($.isBoolean()||$.optional)X=!0;else X="";this.setOptionValueWithSource(J,X,N)};if(this.on("option:"+G,(X)=>{let z=`error: option '${$.flags}' argument '${X}' is invalid.`;Z(X,z,"cli")}),$.envVar)this.on("optionEnv:"+G,(X)=>{let z=`error: option '${$.flags}' value '${X}' from env '${$.envVar}' is invalid.`;Z(X,z,"env")});return this}_optionEx($,G,J,Z,X){if(typeof G==="object"&&G instanceof D4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let z=this.createOption(G,J);if(z.makeOptionMandatory(!!$.mandatory),typeof Z==="function")z.default(X).argParser(Z);else if(Z instanceof RegExp){let N=Z;Z=(Q,Y)=>{let K=N.exec(Q);return K?K[0]:Y},z.default(X).argParser(Z)}else z.default(Z);return this.addOption(z)}option($,G,J,Z){return this._optionEx({},$,G,J,Z)}requiredOption($,G,J,Z){return this._optionEx({mandatory:!0},$,G,J,Z)}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($,G){return this.setOptionValueWithSource($,G,void 0)}setOptionValueWithSource($,G,J){if(this._storeOptionsAsProperties)this[$]=G;else this._optionValues[$]=G;return this._optionValueSources[$]=J,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let G;return this._getCommandAndAncestors().forEach((J)=>{if(J.getOptionValueSource($)!==void 0)G=J.getOptionValueSource($)}),G}_prepareUserArgs($,G){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(G=G||{},$===void 0&&G.from===void 0){if(k.versions?.electron)G.from="electron";let Z=k.execArgv??[];if(Z.includes("-e")||Z.includes("--eval")||Z.includes("-p")||Z.includes("--print"))G.from="eval"}if($===void 0)$=k.argv;this.rawArgs=$.slice();let J;switch(G.from){case void 0:case"node":this._scriptPath=$[1],J=$.slice(2);break;case"electron":if(k.defaultApp)this._scriptPath=$[1],J=$.slice(2);else J=$.slice(1);break;case"user":J=$.slice(0);break;case"eval":J=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${G.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",J}parse($,G){let J=this._prepareUserArgs($,G);return this._parseCommand([],J),this}async parseAsync($,G){let J=this._prepareUserArgs($,G);return await this._parseCommand([],J),this}_executeSubCommand($,G){G=G.slice();let J=!1,Z=[".js",".ts",".tsx",".mjs",".cjs"];function X(K,I){let H=q1.resolve(K,I);if(Q2.existsSync(H))return H;if(Z.includes(q1.extname(I)))return;let U=Z.find((_)=>Q2.existsSync(`${H}${_}`));if(U)return`${H}${U}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=$._executableFile||`${this._name}-${$._name}`,N=this._executableDir||"";if(this._scriptPath){let K;try{K=Q2.realpathSync(this._scriptPath)}catch(I){K=this._scriptPath}N=q1.resolve(q1.dirname(K),N)}if(N){let K=X(N,z);if(!K&&!$._executableFile&&this._scriptPath){let I=q1.basename(this._scriptPath,q1.extname(this._scriptPath));if(I!==this._name)K=X(N,`${I}-${$._name}`)}z=K||z}J=Z.includes(q1.extname(z));let Q;if(k.platform!=="win32")if(J)G.unshift(z),G=O4(k.execArgv).concat(G),Q=z2.spawn(k.argv[0],G,{stdio:"inherit"});else Q=z2.spawn(z,G,{stdio:"inherit"});else G.unshift(z),G=O4(k.execArgv).concat(G),Q=z2.spawn(k.execPath,G,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((I)=>{k.on(I,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(I)})});let Y=this._exitCallback;Q.on("close",(K)=>{if(K=K??1,!Y)k.exit(K);else Y(new N2(K,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(K)=>{if(K.code==="ENOENT"){let I=N?`searched for local subcommand relative to directory '${N}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",H=`'${z}' does not exist
6
+ `),X=" ".repeat(N),M=`\\s${"​"}`,R=new RegExp(`
7
+ |.{1,${z-1}}([${M}]|$)|[^${M}]+?([${M}]|$)`,"g"),S=Q.match(R)||[];return x+S.map((Y,K)=>{if(Y===`
8
+ `)return"";return(K>0?X:"")+Y.trimEnd()}).join(`
9
+ `)}}N5.Help=h2});var q$=v((z5)=>{var{InvalidArgumentError:J5}=a1();class n2{constructor($,I){this.flags=$,this.description=I||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let N=x5($);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($,I){return this.defaultValue=$,this.defaultValueDescription=I,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let I=$;if(typeof $==="string")I={[$]:!0};return this.implied=Object.assign(this.implied||{},I),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,I){if(I===this.defaultValue||!Array.isArray(I))return[$];return I.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(I,N)=>{if(!this.argChoices.includes(I))throw new J5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(I,N);return I},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return Z5(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class c2{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((I)=>{if(I.negate)this.negativeOptions.set(I.attributeName(),I);else this.positiveOptions.set(I.attributeName(),I)}),this.negativeOptions.forEach((I,N)=>{if(this.positiveOptions.has(N))this.dualOptions.add(N)})}valueFromOption($,I){let N=I.attributeName();if(!this.dualOptions.has(N))return!0;let G=this.negativeOptions.get(N).presetArg,J=G!==void 0?G:!1;return I.negate===(J===$)}}function Z5($){return $.split("-").reduce((I,N)=>{return I+N[0].toUpperCase()+N.slice(1)})}function x5($){let I,N,G=$.split(/[ |,]+/);if(G.length>1&&!/^[[<]/.test(G[1]))I=G.shift();if(N=G.shift(),!I&&/^-[^-]$/.test(N))I=N,N=void 0;return{shortFlag:I,longFlag:N}}z5.Option=n2;z5.DualOptions=c2});var d2=v((K5)=>{function M5($,I){if(Math.abs($.length-I.length)>3)return Math.max($.length,I.length);let N=[];for(let G=0;G<=$.length;G++)N[G]=[G];for(let G=0;G<=I.length;G++)N[0][G]=G;for(let G=1;G<=I.length;G++)for(let J=1;J<=$.length;J++){let Z=1;if($[J-1]===I[G-1])Z=0;else Z=1;if(N[J][G]=Math.min(N[J-1][G]+1,N[J][G-1]+1,N[J-1][G-1]+Z),J>1&&G>1&&$[J-1]===I[G-2]&&$[J-2]===I[G-1])N[J][G]=Math.min(N[J][G],N[J-2][G-2]+1)}return N[$.length][I.length]}function j5($,I){if(!I||I.length===0)return"";I=Array.from(new Set(I));let N=$.startsWith("--");if(N)$=$.slice(2),I=I.map((z)=>z.slice(2));let G=[],J=3,Z=0.4;if(I.forEach((z)=>{if(z.length<=1)return;let x=M5($,z),Q=Math.max($.length,z.length);if((Q-x)/Q>Z){if(x<J)J=x,G=[z];else if(x===J)G.push(z)}}),G.sort((z,x)=>z.localeCompare(x)),N)G=G.map((z)=>`--${z}`);if(G.length>1)return`
10
+ (Did you mean one of ${G.join(", ")}?)`;if(G.length===1)return`
11
+ (Did you mean ${G[0]}?)`;return""}K5.suggestSimilar=j5});var r2=v((q5)=>{var R5=O("node:events").EventEmitter,C$=O("node:child_process"),S1=O("node:path"),B$=O("node:fs"),w=O("node:process"),{Argument:S5,humanReadableArgName:H5}=B0(),{CommanderError:g$}=a1(),{Help:T5}=U$(),{Option:p2,DualOptions:U5}=q$(),{suggestSimilar:s2}=d2();class L$ extends R5{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:(I)=>w.stdout.write(I),writeErr:(I)=>w.stderr.write(I),getOutHelpWidth:()=>w.stdout.isTTY?w.stdout.columns:void 0,getErrHelpWidth:()=>w.stderr.isTTY?w.stderr.columns:void 0,outputError:(I,N)=>N(I)},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 I=this;I;I=I.parent)$.push(I);return $}command($,I,N){let G=I,J=N;if(typeof G==="object"&&G!==null)J=G,G=null;J=J||{};let[,Z,z]=$.match(/([^ ]+) *(.*)/),x=this.createCommand(Z);if(G)x.description(G),x._executableHandler=!0;if(J.isDefault)this._defaultCommandName=x._name;if(x._hidden=!!(J.noHelp||J.hidden),x._executableFile=J.executableFile||null,z)x.arguments(z);if(this._registerCommand(x),x.parent=this,x.copyInheritedSettings(this),G)return this;return x}createCommand($){return new L$($)}createHelp(){return Object.assign(new T5,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($,I){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
12
+ - specify the name in Command constructor or using .name()`);if(I=I||{},I.isDefault)this._defaultCommandName=$._name;if(I.noHelp||I.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,I){return new S5($,I)}argument($,I,N,G){let J=this.createArgument($,I);if(typeof N==="function")J.default(G).argParser(N);else J.default(N);return this.addArgument(J),this}arguments($){return $.trim().split(/ +/).forEach((I)=>{this.argument(I)}),this}addArgument($){let I=this.registeredArguments.slice(-1)[0];if(I&&I.variadic)throw Error(`only the last argument can be variadic '${I.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($,I){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,N,G]=$.match(/([^ ]+) *(.*)/),J=I??"display help for command",Z=this.createCommand(N);if(Z.helpOption(!1),G)Z.arguments(G);if(J)Z.description(J);return this._addImplicitHelpCommand=!0,this._helpCommand=Z,this}addHelpCommand($,I){if(typeof $!=="object")return this.helpCommand($,I),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($,I){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(I);else this._lifeCycleHooks[$]=[I];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(I)=>{if(I.code!=="commander.executeSubCommandAsync")throw I};return this}_exit($,I,N){if(this._exitCallback)this._exitCallback(new g$($,I,N));w.exit($)}action($){let I=(N)=>{let G=this.registeredArguments.length,J=N.slice(0,G);if(this._storeOptionsAsProperties)J[G]=this;else J[G]=this.opts();return J.push(this),$.apply(this,J)};return this._actionHandler=I,this}createOption($,I){return new p2($,I)}_callParseArg($,I,N,G){try{return $.parseArg(I,N)}catch(J){if(J.code==="commander.invalidArgument"){let Z=`${G} ${J.message}`;this.error(Z,{exitCode:J.exitCode,code:J.code})}throw J}}_registerOption($){let I=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(I){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 '${I.flags}'`)}this.options.push($)}_registerCommand($){let I=(G)=>{return[G.name()].concat(G.aliases())},N=I($).find((G)=>this._findCommand(G));if(N){let G=I(this._findCommand(N)).join("|"),J=I($).join("|");throw Error(`cannot add command '${J}' as already have command '${G}'`)}this.commands.push($)}addOption($){this._registerOption($);let I=$.name(),N=$.attributeName();if($.negate){let J=$.long.replace(/^--no-/,"--");if(!this._findOption(J))this.setOptionValueWithSource(N,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(N,$.defaultValue,"default");let G=(J,Z,z)=>{if(J==null&&$.presetArg!==void 0)J=$.presetArg;let x=this.getOptionValue(N);if(J!==null&&$.parseArg)J=this._callParseArg($,J,x,Z);else if(J!==null&&$.variadic)J=$._concatValue(J,x);if(J==null)if($.negate)J=!1;else if($.isBoolean()||$.optional)J=!0;else J="";this.setOptionValueWithSource(N,J,z)};if(this.on("option:"+I,(J)=>{let Z=`error: option '${$.flags}' argument '${J}' is invalid.`;G(J,Z,"cli")}),$.envVar)this.on("optionEnv:"+I,(J)=>{let Z=`error: option '${$.flags}' value '${J}' from env '${$.envVar}' is invalid.`;G(J,Z,"env")});return this}_optionEx($,I,N,G,J){if(typeof I==="object"&&I instanceof p2)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Z=this.createOption(I,N);if(Z.makeOptionMandatory(!!$.mandatory),typeof G==="function")Z.default(J).argParser(G);else if(G instanceof RegExp){let z=G;G=(x,Q)=>{let X=z.exec(x);return X?X[0]:Q},Z.default(J).argParser(G)}else Z.default(G);return this.addOption(Z)}option($,I,N,G){return this._optionEx({},$,I,N,G)}requiredOption($,I,N,G){return this._optionEx({mandatory:!0},$,I,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($,I){return this.setOptionValueWithSource($,I,void 0)}setOptionValueWithSource($,I,N){if(this._storeOptionsAsProperties)this[$]=I;else this._optionValues[$]=I;return this._optionValueSources[$]=N,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let I;return this._getCommandAndAncestors().forEach((N)=>{if(N.getOptionValueSource($)!==void 0)I=N.getOptionValueSource($)}),I}_prepareUserArgs($,I){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(I=I||{},$===void 0&&I.from===void 0){if(w.versions?.electron)I.from="electron";let G=w.execArgv??[];if(G.includes("-e")||G.includes("--eval")||G.includes("-p")||G.includes("--print"))I.from="eval"}if($===void 0)$=w.argv;this.rawArgs=$.slice();let N;switch(I.from){case void 0:case"node":this._scriptPath=$[1],N=$.slice(2);break;case"electron":if(w.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: '${I.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",N}parse($,I){let N=this._prepareUserArgs($,I);return this._parseCommand([],N),this}async parseAsync($,I){let N=this._prepareUserArgs($,I);return await this._parseCommand([],N),this}_executeSubCommand($,I){I=I.slice();let N=!1,G=[".js",".ts",".tsx",".mjs",".cjs"];function J(X,j){let M=S1.resolve(X,j);if(B$.existsSync(M))return M;if(G.includes(S1.extname(j)))return;let R=G.find((S)=>B$.existsSync(`${M}${S}`));if(R)return`${M}${R}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Z=$._executableFile||`${this._name}-${$._name}`,z=this._executableDir||"";if(this._scriptPath){let X;try{X=B$.realpathSync(this._scriptPath)}catch(j){X=this._scriptPath}z=S1.resolve(S1.dirname(X),z)}if(z){let X=J(z,Z);if(!X&&!$._executableFile&&this._scriptPath){let j=S1.basename(this._scriptPath,S1.extname(this._scriptPath));if(j!==this._name)X=J(z,`${j}-${$._name}`)}Z=X||Z}N=G.includes(S1.extname(Z));let x;if(w.platform!=="win32")if(N)I.unshift(Z),I=o2(w.execArgv).concat(I),x=C$.spawn(w.argv[0],I,{stdio:"inherit"});else x=C$.spawn(Z,I,{stdio:"inherit"});else I.unshift(Z),I=o2(w.execArgv).concat(I),x=C$.spawn(w.execPath,I,{stdio:"inherit"});if(!x.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((j)=>{w.on(j,()=>{if(x.killed===!1&&x.exitCode===null)x.kill(j)})});let Q=this._exitCallback;x.on("close",(X)=>{if(X=X??1,!Q)w.exit(X);else Q(new g$(X,"commander.executeSubCommandAsync","(close)"))}),x.on("error",(X)=>{if(X.code==="ENOENT"){let j=z?`searched for local subcommand relative to directory '${z}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",M=`'${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
- - ${I}`;throw Error(H)}else if(K.code==="EACCES")throw Error(`'${z}' not executable`);if(!Y)k.exit(1);else{let I=new N2(1,"commander.executeSubCommandAsync","(error)");I.nestedError=K,Y(I)}}),this.runningCommand=Q}_dispatchSubcommand($,G,J){let Z=this._findCommand($);if(!Z)this.help({error:!0});let X;return X=this._chainOrCallSubCommandHook(X,Z,"preSubcommand"),X=this._chainOrCall(X,()=>{if(Z._executableHandler)this._executeSubCommand(Z,G.concat(J));else return Z._parseCommand(G,J)}),X}_dispatchHelpCommand($){if(!$)this.help();let G=this._findCommand($);if(G&&!G._executableHandler)G.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,G)=>{if($.required&&this.args[G]==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 $=(J,Z,X)=>{let z=Z;if(Z!==null&&J.parseArg){let N=`error: command-argument value '${Z}' is invalid for argument '${J.name()}'.`;z=this._callParseArg(J,Z,X,N)}return z};this._checkNumberOfArguments();let G=[];this.registeredArguments.forEach((J,Z)=>{let X=J.defaultValue;if(J.variadic){if(Z<this.args.length){if(X=this.args.slice(Z),J.parseArg)X=X.reduce((z,N)=>{return $(J,N,z)},J.defaultValue)}else if(X===void 0)X=[]}else if(Z<this.args.length){if(X=this.args[Z],J.parseArg)X=$(J,X,J.defaultValue)}G[Z]=X}),this.processedArgs=G}_chainOrCall($,G){if($&&$.then&&typeof $.then==="function")return $.then(()=>G());return G()}_chainOrCallHooks($,G){let J=$,Z=[];if(this._getCommandAndAncestors().reverse().filter((X)=>X._lifeCycleHooks[G]!==void 0).forEach((X)=>{X._lifeCycleHooks[G].forEach((z)=>{Z.push({hookedCommand:X,callback:z})})}),G==="postAction")Z.reverse();return Z.forEach((X)=>{J=this._chainOrCall(J,()=>{return X.callback(X.hookedCommand,this)})}),J}_chainOrCallSubCommandHook($,G,J){let Z=$;if(this._lifeCycleHooks[J]!==void 0)this._lifeCycleHooks[J].forEach((X)=>{Z=this._chainOrCall(Z,()=>{return X(this,G)})});return Z}_parseCommand($,G){let J=this.parseOptions(G);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(J.operands),G=J.unknown,this.args=$.concat(G),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),G);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(G),this._dispatchSubcommand(this._defaultCommandName,$,G);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(J.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Z=()=>{if(J.unknown.length>0)this.unknownOption(J.unknown[0])},X=`command:${this.name()}`;if(this._actionHandler){Z(),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(X,$,G)});return z=this._chainOrCallHooks(z,"postAction"),z}if(this.parent&&this.parent.listenerCount(X))Z(),this._processArguments(),this.parent.emit(X,$,G);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,G);if(this.listenerCount("command:*"))this.emit("command:*",$,G);else if(this.commands.length)this.unknownCommand();else Z(),this._processArguments()}else if(this.commands.length)Z(),this.help({error:!0});else Z(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((G)=>G._name===$||G._aliases.includes($))}_findOption($){return this.options.find((G)=>G.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((G)=>{if(G.mandatory&&$.getOptionValue(G.attributeName())===void 0)$.missingMandatoryOptionValue(G)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((J)=>{let Z=J.attributeName();if(this.getOptionValue(Z)===void 0)return!1;return this.getOptionValueSource(Z)!=="default"});$.filter((J)=>J.conflictsWith.length>0).forEach((J)=>{let Z=$.find((X)=>J.conflictsWith.includes(X.attributeName()));if(Z)this._conflictingOption(J,Z)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let G=[],J=[],Z=G,X=$.slice();function z(Q){return Q.length>1&&Q[0]==="-"}let N=null;while(X.length){let Q=X.shift();if(Q==="--"){if(Z===J)Z.push(Q);Z.push(...X);break}if(N&&!z(Q)){this.emit(`option:${N.name()}`,Q);continue}if(N=null,z(Q)){let Y=this._findOption(Q);if(Y){if(Y.required){let K=X.shift();if(K===void 0)this.optionMissingArgument(Y);this.emit(`option:${Y.name()}`,K)}else if(Y.optional){let K=null;if(X.length>0&&!z(X[0]))K=X.shift();this.emit(`option:${Y.name()}`,K)}else this.emit(`option:${Y.name()}`);N=Y.variadic?Y:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let Y=this._findOption(`-${Q[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,Q.slice(2));else this.emit(`option:${Y.name()}`),X.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let Y=Q.indexOf("="),K=this._findOption(Q.slice(0,Y));if(K&&(K.required||K.optional)){this.emit(`option:${K.name()}`,Q.slice(Y+1));continue}}if(z(Q))Z=J;if((this._enablePositionalOptions||this._passThroughOptions)&&G.length===0&&J.length===0){if(this._findCommand(Q)){if(G.push(Q),X.length>0)J.push(...X);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(G.push(Q),X.length>0)G.push(...X);break}else if(this._defaultCommandName){if(J.push(Q),X.length>0)J.push(...X);break}}if(this._passThroughOptions){if(Z.push(Q),X.length>0)Z.push(...X);break}Z.push(Q)}return{operands:G,unknown:J}}opts(){if(this._storeOptionsAsProperties){let $={},G=this.options.length;for(let J=0;J<G;J++){let Z=this.options[J].attributeName();$[Z]=Z===this._versionOptionName?this._version:this[Z]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,G)=>Object.assign($,G.opts()),{})}error($,G){if(this._outputConfiguration.outputError(`${$}
17
+ - ${j}`;throw Error(M)}else if(X.code==="EACCES")throw Error(`'${Z}' not executable`);if(!Q)w.exit(1);else{let j=new g$(1,"commander.executeSubCommandAsync","(error)");j.nestedError=X,Q(j)}}),this.runningCommand=x}_dispatchSubcommand($,I,N){let G=this._findCommand($);if(!G)this.help({error:!0});let J;return J=this._chainOrCallSubCommandHook(J,G,"preSubcommand"),J=this._chainOrCall(J,()=>{if(G._executableHandler)this._executeSubCommand(G,I.concat(N));else return G._parseCommand(I,N)}),J}_dispatchHelpCommand($){if(!$)this.help();let I=this._findCommand($);if(I&&!I._executableHandler)I.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,I)=>{if($.required&&this.args[I]==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,J)=>{let Z=G;if(G!==null&&N.parseArg){let z=`error: command-argument value '${G}' is invalid for argument '${N.name()}'.`;Z=this._callParseArg(N,G,J,z)}return Z};this._checkNumberOfArguments();let I=[];this.registeredArguments.forEach((N,G)=>{let J=N.defaultValue;if(N.variadic){if(G<this.args.length){if(J=this.args.slice(G),N.parseArg)J=J.reduce((Z,z)=>{return $(N,z,Z)},N.defaultValue)}else if(J===void 0)J=[]}else if(G<this.args.length){if(J=this.args[G],N.parseArg)J=$(N,J,N.defaultValue)}I[G]=J}),this.processedArgs=I}_chainOrCall($,I){if($&&$.then&&typeof $.then==="function")return $.then(()=>I());return I()}_chainOrCallHooks($,I){let N=$,G=[];if(this._getCommandAndAncestors().reverse().filter((J)=>J._lifeCycleHooks[I]!==void 0).forEach((J)=>{J._lifeCycleHooks[I].forEach((Z)=>{G.push({hookedCommand:J,callback:Z})})}),I==="postAction")G.reverse();return G.forEach((J)=>{N=this._chainOrCall(N,()=>{return J.callback(J.hookedCommand,this)})}),N}_chainOrCallSubCommandHook($,I,N){let G=$;if(this._lifeCycleHooks[N]!==void 0)this._lifeCycleHooks[N].forEach((J)=>{G=this._chainOrCall(G,()=>{return J(this,I)})});return G}_parseCommand($,I){let N=this.parseOptions(I);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(N.operands),I=N.unknown,this.args=$.concat(I),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),I);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(I),this._dispatchSubcommand(this._defaultCommandName,$,I);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])},J=`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(J,$,I)});return Z=this._chainOrCallHooks(Z,"postAction"),Z}if(this.parent&&this.parent.listenerCount(J))G(),this._processArguments(),this.parent.emit(J,$,I);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,I);if(this.listenerCount("command:*"))this.emit("command:*",$,I);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((I)=>I._name===$||I._aliases.includes($))}_findOption($){return this.options.find((I)=>I.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((I)=>{if(I.mandatory&&$.getOptionValue(I.attributeName())===void 0)$.missingMandatoryOptionValue(I)})})}_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((J)=>N.conflictsWith.includes(J.attributeName()));if(G)this._conflictingOption(N,G)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let I=[],N=[],G=I,J=$.slice();function Z(x){return x.length>1&&x[0]==="-"}let z=null;while(J.length){let x=J.shift();if(x==="--"){if(G===N)G.push(x);G.push(...J);break}if(z&&!Z(x)){this.emit(`option:${z.name()}`,x);continue}if(z=null,Z(x)){let Q=this._findOption(x);if(Q){if(Q.required){let X=J.shift();if(X===void 0)this.optionMissingArgument(Q);this.emit(`option:${Q.name()}`,X)}else if(Q.optional){let X=null;if(J.length>0&&!Z(J[0]))X=J.shift();this.emit(`option:${Q.name()}`,X)}else this.emit(`option:${Q.name()}`);z=Q.variadic?Q:null;continue}}if(x.length>2&&x[0]==="-"&&x[1]!=="-"){let Q=this._findOption(`-${x[1]}`);if(Q){if(Q.required||Q.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Q.name()}`,x.slice(2));else this.emit(`option:${Q.name()}`),J.unshift(`-${x.slice(2)}`);continue}}if(/^--[^=]+=/.test(x)){let Q=x.indexOf("="),X=this._findOption(x.slice(0,Q));if(X&&(X.required||X.optional)){this.emit(`option:${X.name()}`,x.slice(Q+1));continue}}if(Z(x))G=N;if((this._enablePositionalOptions||this._passThroughOptions)&&I.length===0&&N.length===0){if(this._findCommand(x)){if(I.push(x),J.length>0)N.push(...J);break}else if(this._getHelpCommand()&&x===this._getHelpCommand().name()){if(I.push(x),J.length>0)I.push(...J);break}else if(this._defaultCommandName){if(N.push(x),J.length>0)N.push(...J);break}}if(this._passThroughOptions){if(G.push(x),J.length>0)G.push(...J);break}G.push(x)}return{operands:I,unknown:N}}opts(){if(this._storeOptionsAsProperties){let $={},I=this.options.length;for(let N=0;N<I;N++){let G=this.options[N].attributeName();$[G]=G===this._versionOptionName?this._version:this[G]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,I)=>Object.assign($,I.opts()),{})}error($,I){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 J=G||{},Z=J.exitCode||1,X=J.code||"commander.error";this._exit(Z,X,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in k.env){let G=$.attributeName();if(this.getOptionValue(G)===void 0||["default","config","env"].includes(this.getOptionValueSource(G)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,k.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new W$(this.options),G=(J)=>{return this.getOptionValue(J)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(J))};this.options.filter((J)=>J.implied!==void 0&&G(J.attributeName())&&$.valueFromOption(this.getOptionValue(J.attributeName()),J)).forEach((J)=>{Object.keys(J.implied).filter((Z)=>!G(Z)).forEach((Z)=>{this.setOptionValueWithSource(Z,J.implied[Z],"implied")})})}missingArgument($){let G=`error: missing required argument '${$}'`;this.error(G,{code:"commander.missingArgument"})}optionMissingArgument($){let G=`error: option '${$.flags}' argument missing`;this.error(G,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let G=`error: required option '${$.flags}' not specified`;this.error(G,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,G){let J=(z)=>{let N=z.attributeName(),Q=this.getOptionValue(N),Y=this.options.find((I)=>I.negate&&N===I.attributeName()),K=this.options.find((I)=>!I.negate&&N===I.attributeName());if(Y&&(Y.presetArg===void 0&&Q===!1||Y.presetArg!==void 0&&Q===Y.presetArg))return Y;return K||z},Z=(z)=>{let N=J(z),Q=N.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${N.envVar}'`;return`option '${N.flags}'`},X=`error: ${Z($)} cannot be used with ${Z(G)}`;this.error(X,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let G="";if($.startsWith("--")&&this._showSuggestionAfterError){let Z=[],X=this;do{let z=X.createHelp().visibleOptions(X).filter((N)=>N.long).map((N)=>N.long);Z=Z.concat(z),X=X.parent}while(X&&!X._enablePositionalOptions);G=C4($,Z)}let J=`error: unknown option '${$}'${G}`;this.error(J,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let G=this.registeredArguments.length,J=G===1?"":"s",X=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${G} argument${J} but got ${$.length}.`;this.error(X,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],G="";if(this._showSuggestionAfterError){let Z=[];this.createHelp().visibleCommands(this).forEach((X)=>{if(Z.push(X.name()),X.alias())Z.push(X.alias())}),G=C4($,Z)}let J=`error: unknown command '${$}'${G}`;this.error(J,{code:"commander.unknownCommand"})}version($,G,J){if($===void 0)return this._version;this._version=$,G=G||"-V, --version",J=J||"output the version number";let Z=this.createOption(G,J);return this._versionOptionName=Z.attributeName(),this._registerOption(Z),this.on("option:"+Z.name(),()=>{this._outputConfiguration.writeOut(`${$}
21
- `),this._exit(0,"commander.version",$)}),this}description($,G){if($===void 0&&G===void 0)return this._description;if(this._description=$,G)this._argsDescription=G;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let G=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)G=this.commands[this.commands.length-1];if($===G._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand($);if(J){let Z=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${Z}'`)}return G._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((G)=>this.alias(G)),this}usage($){if($===void 0){if(this._usage)return this._usage;let G=this.registeredArguments.map((J)=>{return T$(J)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?G:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=q1.basename($,q1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let G=this.createHelp();if(G.helpWidth===void 0)G.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return G.formatHelp(this,G)}_getHelpContext($){$=$||{};let G={error:!!$.error},J;if(G.error)J=(Z)=>this._outputConfiguration.writeErr(Z);else J=(Z)=>this._outputConfiguration.writeOut(Z);return G.write=$.write||J,G.command=this,G}outputHelp($){let G;if(typeof $==="function")G=$,$=void 0;let J=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((X)=>X.emit("beforeAllHelp",J)),this.emit("beforeHelp",J);let Z=this.helpInformation(J);if(G){if(Z=G(Z),typeof Z!=="string"&&!Buffer.isBuffer(Z))throw Error("outputHelp callback must return a string or a Buffer")}if(J.write(Z),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",J),this._getCommandAndAncestors().forEach((X)=>X.emit("afterAllHelp",J))}helpOption($,G){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",G=G??"display help for command",this._helpOption=this.createOption($,G),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 G=k.exitCode||0;if(G===0&&$&&typeof $!=="function"&&$.error)G=1;this._exit(G,"commander.help","(outputHelp)")}addHelpText($,G){let J=["beforeAll","before","after","afterAll"];if(!J.includes($))throw Error(`Unexpected value for position to addHelpText.
22
- Expecting one of '${J.join("', '")}'`);let Z=`${$}Help`;return this.on(Z,(X)=>{let z;if(typeof G==="function")z=G({error:X.error,command:X.command});else z=G;if(z)X.write(`${z}
23
- `)}),this}_outputHelpIfRequested($){let G=this._getHelpOption();if(G&&$.find((Z)=>G.is(Z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function O4($){return $.map((G)=>{if(!G.startsWith("--inspect"))return G;let J,Z="127.0.0.1",X="9229",z;if((z=G.match(/^(--inspect(-brk)?)$/))!==null)J=z[1];else if((z=G.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=z[1],/^\d+$/.test(z[3]))X=z[3];else Z=z[3];else if((z=G.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=z[1],Z=z[3],X=z[4];if(J&&X!=="0")return`${J}=${Z}:${parseInt(X)+1}`;return G})}L$.Command=Y2});var w4=u((O$)=>{var{Argument:P4}=_0(),{Command:K2}=F4(),{CommanderError:D$,InvalidArgumentError:E4}=n1(),{Help:C$}=Z2(),{Option:S4}=X2();O$.program=new K2;O$.createCommand=($)=>new K2($);O$.createOption=($,G)=>new S4($,G);O$.createArgument=($,G)=>new P4($,G);O$.Command=K2;O$.Option=S4;O$.Argument=P4;O$.Help=C$;O$.CommanderError=D$;O$.InvalidArgumentError=E4;O$.InvalidOptionArgumentError=E4});var f1=u((VG,H2)=>{var R0=process||{},g4=R0.argv||[],j0=R0.env||{},k$=!(!!j0.NO_COLOR||g4.includes("--no-color"))&&(!!j0.FORCE_COLOR||g4.includes("--color")||R0.platform==="win32"||(R0.stdout||{}).isTTY&&j0.TERM!=="dumb"||!!j0.CI),h$=($,G,J=$)=>(Z)=>{let X=""+Z,z=X.indexOf(G,$.length);return~z?$+m$(X,G,J,z)+G:$+X+G},m$=($,G,J,Z)=>{let X="",z=0;do X+=$.substring(z,Z)+J,z=Z+G.length,Z=$.indexOf(G,z);while(~Z);return X+$.substring(z)},f4=($=k$)=>{let G=$?h$:()=>String;return{isColorSupported:$,reset:G("\x1B[0m","\x1B[0m"),bold:G("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:G("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:G("\x1B[3m","\x1B[23m"),underline:G("\x1B[4m","\x1B[24m"),inverse:G("\x1B[7m","\x1B[27m"),hidden:G("\x1B[8m","\x1B[28m"),strikethrough:G("\x1B[9m","\x1B[29m"),black:G("\x1B[30m","\x1B[39m"),red:G("\x1B[31m","\x1B[39m"),green:G("\x1B[32m","\x1B[39m"),yellow:G("\x1B[33m","\x1B[39m"),blue:G("\x1B[34m","\x1B[39m"),magenta:G("\x1B[35m","\x1B[39m"),cyan:G("\x1B[36m","\x1B[39m"),white:G("\x1B[37m","\x1B[39m"),gray:G("\x1B[90m","\x1B[39m"),bgBlack:G("\x1B[40m","\x1B[49m"),bgRed:G("\x1B[41m","\x1B[49m"),bgGreen:G("\x1B[42m","\x1B[49m"),bgYellow:G("\x1B[43m","\x1B[49m"),bgBlue:G("\x1B[44m","\x1B[49m"),bgMagenta:G("\x1B[45m","\x1B[49m"),bgCyan:G("\x1B[46m","\x1B[49m"),bgWhite:G("\x1B[47m","\x1B[49m"),blackBright:G("\x1B[90m","\x1B[39m"),redBright:G("\x1B[91m","\x1B[39m"),greenBright:G("\x1B[92m","\x1B[39m"),yellowBright:G("\x1B[93m","\x1B[39m"),blueBright:G("\x1B[94m","\x1B[39m"),magentaBright:G("\x1B[95m","\x1B[39m"),cyanBright:G("\x1B[96m","\x1B[39m"),whiteBright:G("\x1B[97m","\x1B[39m"),bgBlackBright:G("\x1B[100m","\x1B[49m"),bgRedBright:G("\x1B[101m","\x1B[49m"),bgGreenBright:G("\x1B[102m","\x1B[49m"),bgYellowBright:G("\x1B[103m","\x1B[49m"),bgBlueBright:G("\x1B[104m","\x1B[49m"),bgMagentaBright:G("\x1B[105m","\x1B[49m"),bgCyanBright:G("\x1B[106m","\x1B[49m"),bgWhiteBright:G("\x1B[107m","\x1B[49m")}};H2.exports=f4();H2.exports.createColors=f4});var q2=u((MG,b4)=>{var I2={to($,G){if(!G)return`\x1B[${$+1}G`;return`\x1B[${G+1};${$+1}H`},move($,G){let J="";if($<0)J+=`\x1B[${-$}D`;else if($>0)J+=`\x1B[${$}C`;if(G<0)J+=`\x1B[${-G}A`;else if(G>0)J+=`\x1B[${G}B`;return J},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"},l$={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},d$={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let G="";for(let J=0;J<$;J++)G+=this.line+(J<$-1?I2.up():"");if($)G+=I2.left;return G}};b4.exports={cursor:I2,scroll:l$,erase:d$,beep:"\x07"}});var U1=u((aG,b3)=>{var g3=["nodebuffer","arraybuffer","fragments"],f3=typeof Blob<"u";if(f3)g3.push("blob");b3.exports={BINARY_TYPES:g3,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:f3,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var J0=u((tG,m0)=>{var{EMPTY_BUFFER:S6}=U1(),i2=Buffer[Symbol.species];function w6($,G){if($.length===0)return S6;if($.length===1)return $[0];let J=Buffer.allocUnsafe(G),Z=0;for(let X=0;X<$.length;X++){let z=$[X];J.set(z,Z),Z+=z.length}if(Z<G)return new i2(J.buffer,J.byteOffset,Z);return J}function u3($,G,J,Z,X){for(let z=0;z<X;z++)J[Z+z]=$[z]^G[z&3]}function k3($,G){for(let J=0;J<$.length;J++)$[J]^=G[J&3]}function y6($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function n2($){if(n2.readOnly=!0,Buffer.isBuffer($))return $;let G;if($ instanceof ArrayBuffer)G=new i2($);else if(ArrayBuffer.isView($))G=new i2($.buffer,$.byteOffset,$.byteLength);else G=Buffer.from($),n2.readOnly=!1;return G}m0.exports={concat:w6,mask:u3,toArrayBuffer:y6,toBuffer:n2,unmask:k3};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();m0.exports.mask=function(G,J,Z,X,z){if(z<48)u3(G,J,Z,X,z);else $.mask(G,J,Z,X,z)},m0.exports.unmask=function(G,J){if(G.length<32)k3(G,J);else $.unmask(G,J)}}catch($){}});var d3=u((eG,l3)=>{var h3=Symbol("kDone"),s2=Symbol("kRun");class m3{constructor($){this[h3]=()=>{this.pending--,this[s2]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[s2]()}[s2](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[h3])}}}l3.exports=m3});var X0=u(($J,s3)=>{var Z0=w("zlib"),c3=J0(),v6=d3(),{kStatusCode:p3}=U1(),g6=Buffer[Symbol.species],f6=Buffer.from([0,0,255,255]),d0=Symbol("permessage-deflate"),_1=Symbol("total-length"),u1=Symbol("callback"),T1=Symbol("buffers"),k1=Symbol("error"),l0;class i3{constructor($,G,J){if(this._maxPayload=J|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!G,this._deflate=null,this._inflate=null,this.params=null,!l0){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;l0=new v6(Z)}}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[u1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let G=this._options,J=$.find((Z)=>{if(G.serverNoContextTakeover===!1&&Z.server_no_context_takeover||Z.server_max_window_bits&&(G.serverMaxWindowBits===!1||typeof G.serverMaxWindowBits==="number"&&G.serverMaxWindowBits>Z.server_max_window_bits)||typeof G.clientMaxWindowBits==="number"&&!Z.client_max_window_bits)return!1;return!0});if(!J)throw Error("None of the extension offers can be accepted");if(G.serverNoContextTakeover)J.server_no_context_takeover=!0;if(G.clientNoContextTakeover)J.client_no_context_takeover=!0;if(typeof G.serverMaxWindowBits==="number")J.server_max_window_bits=G.serverMaxWindowBits;if(typeof G.clientMaxWindowBits==="number")J.client_max_window_bits=G.clientMaxWindowBits;else if(J.client_max_window_bits===!0||G.clientMaxWindowBits===!1)delete J.client_max_window_bits;return J}acceptAsClient($){let G=$[0];if(this._options.clientNoContextTakeover===!1&&G.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!G.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")G.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&G.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return G}normalizeParams($){return $.forEach((G)=>{Object.keys(G).forEach((J)=>{let Z=G[J];if(Z.length>1)throw Error(`Parameter "${J}" must have only a single value`);if(Z=Z[0],J==="client_max_window_bits"){if(Z!==!0){let X=+Z;if(!Number.isInteger(X)||X<8||X>15)throw TypeError(`Invalid value for parameter "${J}": ${Z}`);Z=X}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${J}": ${Z}`)}else if(J==="server_max_window_bits"){let X=+Z;if(!Number.isInteger(X)||X<8||X>15)throw TypeError(`Invalid value for parameter "${J}": ${Z}`);Z=X}else if(J==="client_no_context_takeover"||J==="server_no_context_takeover"){if(Z!==!0)throw TypeError(`Invalid value for parameter "${J}": ${Z}`)}else throw Error(`Unknown parameter "${J}"`);G[J]=Z})}),$}decompress($,G,J){l0.add((Z)=>{this._decompress($,G,(X,z)=>{Z(),J(X,z)})})}compress($,G,J){l0.add((Z)=>{this._compress($,G,(X,z)=>{Z(),J(X,z)})})}_decompress($,G,J){let Z=this._isServer?"client":"server";if(!this._inflate){let X=`${Z}_max_window_bits`,z=typeof this.params[X]!=="number"?Z0.Z_DEFAULT_WINDOWBITS:this.params[X];this._inflate=Z0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:z}),this._inflate[d0]=this,this._inflate[_1]=0,this._inflate[T1]=[],this._inflate.on("error",u6),this._inflate.on("data",n3)}if(this._inflate[u1]=J,this._inflate.write($),G)this._inflate.write(f6);this._inflate.flush(()=>{let X=this._inflate[k1];if(X){this._inflate.close(),this._inflate=null,J(X);return}let z=c3.concat(this._inflate[T1],this._inflate[_1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[_1]=0,this._inflate[T1]=[],G&&this.params[`${Z}_no_context_takeover`])this._inflate.reset();J(null,z)})}_compress($,G,J){let Z=this._isServer?"server":"client";if(!this._deflate){let X=`${Z}_max_window_bits`,z=typeof this.params[X]!=="number"?Z0.Z_DEFAULT_WINDOWBITS:this.params[X];this._deflate=Z0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:z}),this._deflate[_1]=0,this._deflate[T1]=[],this._deflate.on("data",b6)}this._deflate[u1]=J,this._deflate.write($),this._deflate.flush(Z0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let X=c3.concat(this._deflate[T1],this._deflate[_1]);if(G)X=new g6(X.buffer,X.byteOffset,X.length-4);if(this._deflate[u1]=null,this._deflate[_1]=0,this._deflate[T1]=[],G&&this.params[`${Z}_no_context_takeover`])this._deflate.reset();J(null,X)})}}s3.exports=i3;function b6($){this[T1].push($),this[_1]+=$.length}function n3($){if(this[_1]+=$.length,this[d0]._maxPayload<1||this[_1]<=this[d0]._maxPayload){this[T1].push($);return}this[k1]=RangeError("Max payload size exceeded"),this[k1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[k1][p3]=1009,this.removeListener("data",n3),this.reset()}function u6($){if(this[d0]._inflate=null,this[k1]){this[u1](this[k1]);return}$[p3]=1007,this[u1]($)}});var h1=u((GJ,c0)=>{var{isUtf8:o3}=w("buffer"),{hasBlob:k6}=U1(),h6=[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 m6($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function o2($){let G=$.length,J=0;while(J<G)if(($[J]&128)===0)J++;else if(($[J]&224)===192){if(J+1===G||($[J+1]&192)!==128||($[J]&254)===192)return!1;J+=2}else if(($[J]&240)===224){if(J+2>=G||($[J+1]&192)!==128||($[J+2]&192)!==128||$[J]===224&&($[J+1]&224)===128||$[J]===237&&($[J+1]&224)===160)return!1;J+=3}else if(($[J]&248)===240){if(J+3>=G||($[J+1]&192)!==128||($[J+2]&192)!==128||($[J+3]&192)!==128||$[J]===240&&($[J+1]&240)===128||$[J]===244&&$[J+1]>143||$[J]>244)return!1;J+=4}else return!1;return!0}function l6($){return k6&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}c0.exports={isBlob:l6,isValidStatusCode:m6,isValidUTF8:o2,tokenChars:h6};if(o3)c0.exports.isValidUTF8=function($){return $.length<24?o2($):o3($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();c0.exports.isValidUTF8=function(G){return G.length<32?o2(G):$(G)}}catch($){}});var a2=u((JJ,$9)=>{var{Writable:d6}=w("stream"),r3=X0(),{BINARY_TYPES:c6,EMPTY_BUFFER:a3,kStatusCode:p6,kWebSocket:i6}=U1(),{concat:r2,toArrayBuffer:n6,unmask:s6}=J0(),{isValidStatusCode:o6,isValidUTF8:t3}=h1(),p0=Buffer[Symbol.species];class e3 extends d6{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||c6[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[i6]=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($,G,J){if(this._opcode===8&&this._state==0)return J();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(J)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let J=this._buffers[0];return this._buffers[0]=new p0(J.buffer,J.byteOffset+$,J.length-$),new p0(J.buffer,J.byteOffset,$)}let G=Buffer.allocUnsafe($);do{let J=this._buffers[0],Z=G.length-$;if($>=J.length)G.set(this._buffers.shift(),Z);else G.set(new Uint8Array(J.buffer,J.byteOffset,$),Z),this._buffers[0]=new p0(J.buffer,J.byteOffset+$,J.length-$);$-=J.length}while($>0);return G}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 G=this.consume(2);if((G[0]&48)!==0){let Z=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(Z);return}let J=(G[0]&64)===64;if(J&&!this._extensions[r3.extensionName]){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(this._fin=(G[0]&128)===128,this._opcode=G[0]&15,this._payloadLength=G[1]&127,this._opcode===0){if(J){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(!this._fragmented){let Z=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}this._compressed=J}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Z=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(Z);return}if(J){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Z=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(Z);return}}else{let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(G[1]&128)===128,this._isServer){if(!this._masked){let Z=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(Z);return}}else if(this._masked){let Z=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(Z);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 G=this.consume(8),J=G.readUInt32BE(0);if(J>Math.pow(2,21)-1){let Z=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(Z);return}this._payloadLength=J*Math.pow(2,32)+G.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let G=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(G);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 G=a3;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(G=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)s6(G,this._mask)}if(this._opcode>7){this.controlMessage(G,$);return}if(this._compressed){this._state=5,this.decompress(G,$);return}if(G.length)this._messageLength=this._totalPayloadLength,this._fragments.push(G);this.dataMessage($)}decompress($,G){this._extensions[r3.extensionName].decompress($,this._fin,(Z,X)=>{if(Z)return G(Z);if(X.length){if(this._messageLength+=X.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");G(z);return}this._fragments.push(X)}if(this.dataMessage(G),this._state===0)this.startLoop(G)})}dataMessage($){if(!this._fin){this._state=0;return}let G=this._messageLength,J=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Z;if(this._binaryType==="nodebuffer")Z=r2(J,G);else if(this._binaryType==="arraybuffer")Z=n6(r2(J,G));else if(this._binaryType==="blob")Z=new Blob(J);else Z=J;if(this._allowSynchronousEvents)this.emit("message",Z,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!0),this._state=0,this.startLoop($)})}else{let Z=r2(J,G);if(!this._skipUTF8Validation&&!t3(Z)){let X=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(X);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Z,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!1),this._state=0,this.startLoop($)})}}controlMessage($,G){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,a3),this.end();else{let J=$.readUInt16BE(0);if(!o6(J)){let X=this.createError(RangeError,`invalid status code ${J}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");G(X);return}let Z=new p0($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!t3(Z)){let X=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");G(X);return}this._loop=!1,this.emit("conclude",J,Z),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(G)})}createError($,G,J,Z,X){this._loop=!1,this._errored=!0;let z=new $(J?`Invalid WebSocket frame: ${G}`:G);return Error.captureStackTrace(z,this.createError),z.code=X,z[p6]=Z,z}}$9.exports=e3});var e2=u((XJ,Z9)=>{var{Duplex:ZJ}=w("stream"),{randomFillSync:r6}=w("crypto"),G9=X0(),{EMPTY_BUFFER:a6,kWebSocket:t6,NOOP:e6}=U1(),{isBlob:m1,isValidStatusCode:$8}=h1(),{mask:J9,toBuffer:E1}=J0(),G1=Symbol("kByteLength"),G8=Buffer.alloc(4),S1,l1=8192,z1=0,J8=1,Z8=2;class x1{constructor($,G,J){if(this._extensions=G||{},J)this._generateMask=J,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=z1,this.onerror=e6,this[t6]=void 0}static frame($,G){let J,Z=!1,X=2,z=!1;if(G.mask){if(J=G.maskBuffer||G8,G.generateMask)G.generateMask(J);else{if(l1===8192){if(S1===void 0)S1=Buffer.alloc(8192);r6(S1,0,8192),l1=0}J[0]=S1[l1++],J[1]=S1[l1++],J[2]=S1[l1++],J[3]=S1[l1++]}z=(J[0]|J[1]|J[2]|J[3])===0,X=6}let N;if(typeof $==="string")if((!G.mask||z)&&G[G1]!==void 0)N=G[G1];else $=Buffer.from($),N=$.length;else N=$.length,Z=G.mask&&G.readOnly&&!z;let Q=N;if(N>=65536)X+=8,Q=127;else if(N>125)X+=2,Q=126;let Y=Buffer.allocUnsafe(Z?N+X:X);if(Y[0]=G.fin?G.opcode|128:G.opcode,G.rsv1)Y[0]|=64;if(Y[1]=Q,Q===126)Y.writeUInt16BE(N,2);else if(Q===127)Y[2]=Y[3]=0,Y.writeUIntBE(N,4,6);if(!G.mask)return[Y,$];if(Y[1]|=128,Y[X-4]=J[0],Y[X-3]=J[1],Y[X-2]=J[2],Y[X-1]=J[3],z)return[Y,$];if(Z)return J9($,J,Y,X,N),[Y];return J9($,J,$,0,N),[Y,$]}close($,G,J,Z){let X;if($===void 0)X=a6;else if(typeof $!=="number"||!$8($))throw TypeError("First argument must be a valid error code number");else if(G===void 0||!G.length)X=Buffer.allocUnsafe(2),X.writeUInt16BE($,0);else{let N=Buffer.byteLength(G);if(N>123)throw RangeError("The message must not be greater than 123 bytes");if(X=Buffer.allocUnsafe(2+N),X.writeUInt16BE($,0),typeof G==="string")X.write(G,2);else X.set(G,2)}let z={[G1]:X.length,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==z1)this.enqueue([this.dispatch,X,!1,z,Z]);else this.sendFrame(x1.frame(X,z),Z)}ping($,G,J){let Z,X;if(typeof $==="string")Z=Buffer.byteLength($),X=!1;else if(m1($))Z=$.size,X=!1;else $=E1($),Z=$.length,X=E1.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[G1]:Z,fin:!0,generateMask:this._generateMask,mask:G,maskBuffer:this._maskBuffer,opcode:9,readOnly:X,rsv1:!1};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,!1,z,J]);else this.getBlobData($,!1,z,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,!1,z,J]);else this.sendFrame(x1.frame($,z),J)}pong($,G,J){let Z,X;if(typeof $==="string")Z=Buffer.byteLength($),X=!1;else if(m1($))Z=$.size,X=!1;else $=E1($),Z=$.length,X=E1.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[G1]:Z,fin:!0,generateMask:this._generateMask,mask:G,maskBuffer:this._maskBuffer,opcode:10,readOnly:X,rsv1:!1};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,!1,z,J]);else this.getBlobData($,!1,z,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,!1,z,J]);else this.sendFrame(x1.frame($,z),J)}send($,G,J){let Z=this._extensions[G9.extensionName],X=G.binary?2:1,z=G.compress,N,Q;if(typeof $==="string")N=Buffer.byteLength($),Q=!1;else if(m1($))N=$.size,Q=!1;else $=E1($),N=$.length,Q=E1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,z&&Z&&Z.params[Z._isServer?"server_no_context_takeover":"client_no_context_takeover"])z=N>=Z._threshold;this._compress=z}else z=!1,X=0;if(G.fin)this._firstFragment=!0;let Y={[G1]:N,fin:G.fin,generateMask:this._generateMask,mask:G.mask,maskBuffer:this._maskBuffer,opcode:X,readOnly:Q,rsv1:z};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,this._compress,Y,J]);else this.getBlobData($,this._compress,Y,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,this._compress,Y,J]);else this.dispatch($,this._compress,Y,J)}getBlobData($,G,J,Z){this._bufferedBytes+=J[G1],this._state=Z8,$.arrayBuffer().then((X)=>{if(this._socket.destroyed){let N=Error("The socket was closed while the blob was being read");process.nextTick(t2,this,N,Z);return}this._bufferedBytes-=J[G1];let z=E1(X);if(!G)this._state=z1,this.sendFrame(x1.frame(z,J),Z),this.dequeue();else this.dispatch(z,G,J,Z)}).catch((X)=>{process.nextTick(X8,this,X,Z)})}dispatch($,G,J,Z){if(!G){this.sendFrame(x1.frame($,J),Z);return}let X=this._extensions[G9.extensionName];this._bufferedBytes+=J[G1],this._state=J8,X.compress($,J.fin,(z,N)=>{if(this._socket.destroyed){let Q=Error("The socket was closed while data was being compressed");t2(this,Q,Z);return}this._bufferedBytes-=J[G1],this._state=z1,J.readOnly=!1,this.sendFrame(x1.frame(N,J),Z),this.dequeue()})}dequeue(){while(this._state===z1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][G1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][G1],this._queue.push($)}sendFrame($,G){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],G),this._socket.uncork();else this._socket.write($[0],G)}}Z9.exports=x1;function t2($,G,J){if(typeof J==="function")J(G);for(let Z=0;Z<$._queue.length;Z++){let X=$._queue[Z],z=X[X.length-1];if(typeof z==="function")z(G)}}function X8($,G,J){t2($,G,J),$.onerror(G)}});var q9=u((zJ,I9)=>{var{kForOnEventAttribute:z0,kListener:$4}=U1(),X9=Symbol("kCode"),z9=Symbol("kData"),Q9=Symbol("kError"),N9=Symbol("kMessage"),Y9=Symbol("kReason"),d1=Symbol("kTarget"),K9=Symbol("kType"),H9=Symbol("kWasClean");class W1{constructor($){this[d1]=null,this[K9]=$}get target(){return this[d1]}get type(){return this[K9]}}Object.defineProperty(W1.prototype,"target",{enumerable:!0});Object.defineProperty(W1.prototype,"type",{enumerable:!0});class c1 extends W1{constructor($,G={}){super($);this[X9]=G.code===void 0?0:G.code,this[Y9]=G.reason===void 0?"":G.reason,this[H9]=G.wasClean===void 0?!1:G.wasClean}get code(){return this[X9]}get reason(){return this[Y9]}get wasClean(){return this[H9]}}Object.defineProperty(c1.prototype,"code",{enumerable:!0});Object.defineProperty(c1.prototype,"reason",{enumerable:!0});Object.defineProperty(c1.prototype,"wasClean",{enumerable:!0});class Q0 extends W1{constructor($,G={}){super($);this[Q9]=G.error===void 0?null:G.error,this[N9]=G.message===void 0?"":G.message}get error(){return this[Q9]}get message(){return this[N9]}}Object.defineProperty(Q0.prototype,"error",{enumerable:!0});Object.defineProperty(Q0.prototype,"message",{enumerable:!0});class n0 extends W1{constructor($,G={}){super($);this[z9]=G.data===void 0?null:G.data}get data(){return this[z9]}}Object.defineProperty(n0.prototype,"data",{enumerable:!0});var z8={addEventListener($,G,J={}){for(let X of this.listeners($))if(!J[z0]&&X[$4]===G&&!X[z0])return;let Z;if($==="message")Z=function(z,N){let Q=new n0("message",{data:N?z:z.toString()});Q[d1]=this,i0(G,this,Q)};else if($==="close")Z=function(z,N){let Q=new c1("close",{code:z,reason:N.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});Q[d1]=this,i0(G,this,Q)};else if($==="error")Z=function(z){let N=new Q0("error",{error:z,message:z.message});N[d1]=this,i0(G,this,N)};else if($==="open")Z=function(){let z=new W1("open");z[d1]=this,i0(G,this,z)};else return;if(Z[z0]=!!J[z0],Z[$4]=G,J.once)this.once($,Z);else this.on($,Z)},removeEventListener($,G){for(let J of this.listeners($))if(J[$4]===G&&!J[z0]){this.removeListener($,J);break}}};I9.exports={CloseEvent:c1,ErrorEvent:Q0,Event:W1,EventTarget:z8,MessageEvent:n0};function i0($,G,J){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,J);else $.call(G,J)}});var G4=u((QJ,B9)=>{var{tokenChars:N0}=h1();function K1($,G,J){if($[G]===void 0)$[G]=[J];else $[G].push(J)}function Q8($){let G=Object.create(null),J=Object.create(null),Z=!1,X=!1,z=!1,N,Q,Y=-1,K=-1,I=-1,H=0;for(;H<$.length;H++)if(K=$.charCodeAt(H),N===void 0)if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(H!==0&&(K===32||K===9)){if(I===-1&&Y!==-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;let _=$.slice(Y,I);if(K===44)K1(G,_,J),J=Object.create(null);else N=_;Y=I=-1}else throw SyntaxError(`Unexpected character at index ${H}`);else if(Q===void 0)if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(K===32||K===9){if(I===-1&&Y!==-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;if(K1(J,$.slice(Y,I),!0),K===44)K1(G,N,J),J=Object.create(null),N=void 0;Y=I=-1}else if(K===61&&Y!==-1&&I===-1)Q=$.slice(Y,H),Y=I=-1;else throw SyntaxError(`Unexpected character at index ${H}`);else if(X){if(N0[K]!==1)throw SyntaxError(`Unexpected character at index ${H}`);if(Y===-1)Y=H;else if(!Z)Z=!0;X=!1}else if(z)if(N0[K]===1){if(Y===-1)Y=H}else if(K===34&&Y!==-1)z=!1,I=H;else if(K===92)X=!0;else throw SyntaxError(`Unexpected character at index ${H}`);else if(K===34&&$.charCodeAt(H-1)===61)z=!0;else if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(Y!==-1&&(K===32||K===9)){if(I===-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;let _=$.slice(Y,I);if(Z)_=_.replace(/\\/g,""),Z=!1;if(K1(J,Q,_),K===44)K1(G,N,J),J=Object.create(null),N=void 0;Q=void 0,Y=I=-1}else throw SyntaxError(`Unexpected character at index ${H}`);if(Y===-1||z||K===32||K===9)throw SyntaxError("Unexpected end of input");if(I===-1)I=H;let U=$.slice(Y,I);if(N===void 0)K1(G,U,J);else{if(Q===void 0)K1(J,U,!0);else if(Z)K1(J,Q,U.replace(/\\/g,""));else K1(J,Q,U);K1(G,N,J)}return G}function N8($){return Object.keys($).map((G)=>{let J=$[G];if(!Array.isArray(J))J=[J];return J.map((Z)=>{return[G].concat(Object.keys(Z).map((X)=>{let z=Z[X];if(!Array.isArray(z))z=[z];return z.map((N)=>N===!0?X:`${X}=${N}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}B9.exports={format:N8,parse:Q8}});var a0=u((KJ,D9)=>{var Y8=w("events"),K8=w("https"),H8=w("http"),j9=w("net"),I8=w("tls"),{randomBytes:q8,createHash:B8}=w("crypto"),{Duplex:NJ,Readable:YJ}=w("stream"),{URL:J4}=w("url"),L1=X0(),U8=a2(),_8=e2(),{isBlob:j8}=h1(),{BINARY_TYPES:U9,CLOSE_TIMEOUT:R8,EMPTY_BUFFER:s0,GUID:V8,kForOnEventAttribute:Z4,kListener:M8,kStatusCode:T8,kWebSocket:l,NOOP:R9}=U1(),{EventTarget:{addEventListener:x8,removeEventListener:W8}}=q9(),{format:L8,parse:A8}=G4(),{toBuffer:D8}=J0(),V9=Symbol("kAborted"),X4=[8,13],j1=["CONNECTING","OPEN","CLOSING","CLOSED"],C8=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class C extends Y8{constructor($,G,J){super();if(this._binaryType=U9[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=s0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=C.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,G===void 0)G=[];else if(!Array.isArray(G))if(typeof G==="object"&&G!==null)J=G,G=[];else G=[G];M9(this,$,G,J)}else this._autoPong=J.autoPong,this._closeTimeout=J.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!U9.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($,G,J){let Z=new U8({allowSynchronousEvents:J.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation}),X=new _8($,this._extensions,J.generateMask);if(this._receiver=Z,this._sender=X,this._socket=$,Z[l]=this,X[l]=this,$[l]=this,Z.on("conclude",P8),Z.on("drain",E8),Z.on("error",S8),Z.on("message",w8),Z.on("ping",y8),Z.on("pong",v8),X.onerror=g8,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(G.length>0)$.unshift(G);$.on("close",W9),$.on("data",r0),$.on("end",L9),$.on("error",A9),this._readyState=C.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=C.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[L1.extensionName])this._extensions[L1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=C.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,G){if(this.readyState===C.CLOSED)return;if(this.readyState===C.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===C.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=C.CLOSING,this._sender.close($,G,!this._isServer,(J)=>{if(J)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),x9(this)}pause(){if(this.readyState===C.CONNECTING||this.readyState===C.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,G,J){if(this.readyState===C.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=G=void 0;else if(typeof G==="function")J=G,G=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==C.OPEN){z4(this,$,J);return}if(G===void 0)G=!this._isServer;this._sender.ping($||s0,G,J)}pong($,G,J){if(this.readyState===C.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=G=void 0;else if(typeof G==="function")J=G,G=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==C.OPEN){z4(this,$,J);return}if(G===void 0)G=!this._isServer;this._sender.pong($||s0,G,J)}resume(){if(this.readyState===C.CONNECTING||this.readyState===C.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,G,J){if(this.readyState===C.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")J=G,G={};if(typeof $==="number")$=$.toString();if(this.readyState!==C.OPEN){z4(this,$,J);return}let Z={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...G};if(!this._extensions[L1.extensionName])Z.compress=!1;this._sender.send($||s0,Z,J)}terminate(){if(this.readyState===C.CLOSED)return;if(this.readyState===C.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=C.CLOSING,this._socket.destroy()}}Object.defineProperty(C,"CONNECTING",{enumerable:!0,value:j1.indexOf("CONNECTING")});Object.defineProperty(C.prototype,"CONNECTING",{enumerable:!0,value:j1.indexOf("CONNECTING")});Object.defineProperty(C,"OPEN",{enumerable:!0,value:j1.indexOf("OPEN")});Object.defineProperty(C.prototype,"OPEN",{enumerable:!0,value:j1.indexOf("OPEN")});Object.defineProperty(C,"CLOSING",{enumerable:!0,value:j1.indexOf("CLOSING")});Object.defineProperty(C.prototype,"CLOSING",{enumerable:!0,value:j1.indexOf("CLOSING")});Object.defineProperty(C,"CLOSED",{enumerable:!0,value:j1.indexOf("CLOSED")});Object.defineProperty(C.prototype,"CLOSED",{enumerable:!0,value:j1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(C.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(C.prototype,`on${$}`,{enumerable:!0,get(){for(let G of this.listeners($))if(G[Z4])return G[M8];return null},set(G){for(let J of this.listeners($))if(J[Z4]){this.removeListener($,J);break}if(typeof G!=="function")return;this.addEventListener($,G,{[Z4]:!0})}})});C.prototype.addEventListener=x8;C.prototype.removeEventListener=W8;D9.exports=C;function M9($,G,J,Z){let X={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:R8,protocolVersion:X4[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Z,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=X.autoPong,$._closeTimeout=X.closeTimeout,!X4.includes(X.protocolVersion))throw RangeError(`Unsupported protocol version: ${X.protocolVersion} (supported versions: ${X4.join(", ")})`);let z;if(G instanceof J4)z=G;else try{z=new J4(G)}catch(B){throw SyntaxError(`Invalid URL: ${G}`)}if(z.protocol==="http:")z.protocol="ws:";else if(z.protocol==="https:")z.protocol="wss:";$._url=z.href;let N=z.protocol==="wss:",Q=z.protocol==="ws+unix:",Y;if(z.protocol!=="ws:"&&!N&&!Q)Y=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(Q&&!z.pathname)Y="The URL's pathname is empty";else if(z.hash)Y="The URL contains a fragment identifier";if(Y){let B=SyntaxError(Y);if($._redirects===0)throw B;else{o0($,B);return}}let K=N?443:80,I=q8(16).toString("base64"),H=N?K8.request:H8.request,U=new Set,_;if(X.createConnection=X.createConnection||(N?F8:O8),X.defaultPort=X.defaultPort||K,X.port=z.port||K,X.host=z.hostname.startsWith("[")?z.hostname.slice(1,-1):z.hostname,X.headers={...X.headers,"Sec-WebSocket-Version":X.protocolVersion,"Sec-WebSocket-Key":I,Connection:"Upgrade",Upgrade:"websocket"},X.path=z.pathname+z.search,X.timeout=X.handshakeTimeout,X.perMessageDeflate)_=new L1(X.perMessageDeflate!==!0?X.perMessageDeflate:{},!1,X.maxPayload),X.headers["Sec-WebSocket-Extensions"]=L8({[L1.extensionName]:_.offer()});if(J.length){for(let B of J){if(typeof B!=="string"||!C8.test(B)||U.has(B))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(B)}X.headers["Sec-WebSocket-Protocol"]=J.join(",")}if(X.origin)if(X.protocolVersion<13)X.headers["Sec-WebSocket-Origin"]=X.origin;else X.headers.Origin=X.origin;if(z.username||z.password)X.auth=`${z.username}:${z.password}`;if(Q){let B=X.path.split(":");X.socketPath=B[0],X.path=B[1]}let q;if(X.followRedirects){if($._redirects===0){$._originalIpc=Q,$._originalSecure=N,$._originalHostOrSocketPath=Q?X.socketPath:z.host;let B=Z&&Z.headers;if(Z={...Z,headers:{}},B)for(let[M,V]of Object.entries(B))Z.headers[M.toLowerCase()]=V}else if($.listenerCount("redirect")===0){let B=Q?$._originalIpc?X.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:z.host===$._originalHostOrSocketPath;if(!B||$._originalSecure&&!N){if(delete X.headers.authorization,delete X.headers.cookie,!B)delete X.headers.host;X.auth=void 0}}if(X.auth&&!Z.headers.authorization)Z.headers.authorization="Basic "+Buffer.from(X.auth).toString("base64");if(q=$._req=H(X),$._redirects)$.emit("redirect",$.url,q)}else q=$._req=H(X);if(X.timeout)q.on("timeout",()=>{r($,q,"Opening handshake has timed out")});if(q.on("error",(B)=>{if(q===null||q[V9])return;q=$._req=null,o0($,B)}),q.on("response",(B)=>{let M=B.headers.location,V=B.statusCode;if(M&&X.followRedirects&&V>=300&&V<400){if(++$._redirects>X.maxRedirects){r($,q,"Maximum redirects exceeded");return}q.abort();let x;try{x=new J4(M,G)}catch(L){let D=SyntaxError(`Invalid URL: ${M}`);o0($,D);return}M9($,x,J,Z)}else if(!$.emit("unexpected-response",q,B))r($,q,`Unexpected server response: ${B.statusCode}`)}),q.on("upgrade",(B,M,V)=>{if($.emit("upgrade",B),$.readyState!==C.CONNECTING)return;q=$._req=null;let x=B.headers.upgrade;if(x===void 0||x.toLowerCase()!=="websocket"){r($,M,"Invalid Upgrade header");return}let L=B8("sha1").update(I+V8).digest("base64");if(B.headers["sec-websocket-accept"]!==L){r($,M,"Invalid Sec-WebSocket-Accept header");return}let D=B.headers["sec-websocket-protocol"],A;if(D!==void 0){if(!U.size)A="Server sent a subprotocol but none was requested";else if(!U.has(D))A="Server sent an invalid subprotocol"}else if(U.size)A="Server sent no subprotocol";if(A){r($,M,A);return}if(D)$._protocol=D;let F=B.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){r($,M,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=A8(F)}catch(b){r($,M,"Invalid Sec-WebSocket-Extensions header");return}let W=Object.keys(T);if(W.length!==1||W[0]!==L1.extensionName){r($,M,"Server indicated an extension that was not requested");return}try{_.accept(T[L1.extensionName])}catch(b){r($,M,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[L1.extensionName]=_}$.setSocket(M,V,{allowSynchronousEvents:X.allowSynchronousEvents,generateMask:X.generateMask,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation})}),X.finishRequest)X.finishRequest(q,$);else q.end()}function o0($,G){$._readyState=C.CLOSING,$._errorEmitted=!0,$.emit("error",G),$.emitClose()}function O8($){return $.path=$.socketPath,j9.connect($)}function F8($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=j9.isIP($.host)?"":$.host;return I8.connect($)}function r($,G,J){$._readyState=C.CLOSING;let Z=Error(J);if(Error.captureStackTrace(Z,r),G.setHeader){if(G[V9]=!0,G.abort(),G.socket&&!G.socket.destroyed)G.socket.destroy();process.nextTick(o0,$,Z)}else G.destroy(Z),G.once("error",$.emit.bind($,"error")),G.once("close",$.emitClose.bind($))}function z4($,G,J){if(G){let Z=j8(G)?G.size:D8(G).length;if($._socket)$._sender._bufferedBytes+=Z;else $._bufferedAmount+=Z}if(J){let Z=Error(`WebSocket is not open: readyState ${$.readyState} (${j1[$.readyState]})`);process.nextTick(J,Z)}}function P8($,G){let J=this[l];if(J._closeFrameReceived=!0,J._closeMessage=G,J._closeCode=$,J._socket[l]===void 0)return;if(J._socket.removeListener("data",r0),process.nextTick(T9,J._socket),$===1005)J.close();else J.close($,G)}function E8(){let $=this[l];if(!$.isPaused)$._socket.resume()}function S8($){let G=this[l];if(G._socket[l]!==void 0)G._socket.removeListener("data",r0),process.nextTick(T9,G._socket),G.close($[T8]);if(!G._errorEmitted)G._errorEmitted=!0,G.emit("error",$)}function _9(){this[l].emitClose()}function w8($,G){this[l].emit("message",$,G)}function y8($){let G=this[l];if(G._autoPong)G.pong($,!this._isServer,R9);G.emit("ping",$)}function v8($){this[l].emit("pong",$)}function T9($){$.resume()}function g8($){let G=this[l];if(G.readyState===C.CLOSED)return;if(G.readyState===C.OPEN)G._readyState=C.CLOSING,x9(G);if(this._socket.end(),!G._errorEmitted)G._errorEmitted=!0,G.emit("error",$)}function x9($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function W9(){let $=this[l];if(this.removeListener("close",W9),this.removeListener("data",r0),this.removeListener("end",L9),$._readyState=C.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let G=this.read(this._readableState.length);$._receiver.write(G)}if($._receiver.end(),this[l]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",_9),$._receiver.on("finish",_9)}function r0($){if(!this[l]._receiver.write($))this.pause()}function L9(){let $=this[l];$._readyState=C.CLOSING,$._receiver.end(),this.end()}function A9(){let $=this[l];if(this.removeListener("error",A9),this.on("error",R9),$)$._readyState=C.CLOSING,this.destroy()}});var P9=u((IJ,F9)=>{var HJ=a0(),{Duplex:f8}=w("stream");function C9($){$.emit("close")}function b8(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function O9($){if(this.removeListener("error",O9),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function u8($,G){let J=!0,Z=new f8({...G,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(z,N){let Q=!N&&Z._readableState.objectMode?z.toString():z;if(!Z.push(Q))$.pause()}),$.once("error",function(z){if(Z.destroyed)return;J=!1,Z.destroy(z)}),$.once("close",function(){if(Z.destroyed)return;Z.push(null)}),Z._destroy=function(X,z){if($.readyState===$.CLOSED){z(X),process.nextTick(C9,Z);return}let N=!1;if($.once("error",function(Y){N=!0,z(Y)}),$.once("close",function(){if(!N)z(X);process.nextTick(C9,Z)}),J)$.terminate()},Z._final=function(X){if($.readyState===$.CONNECTING){$.once("open",function(){Z._final(X)});return}if($._socket===null)return;if($._socket._writableState.finished){if(X(),Z._readableState.endEmitted)Z.destroy()}else $._socket.once("finish",function(){X()}),$.close()},Z._read=function(){if($.isPaused)$.resume()},Z._write=function(X,z,N){if($.readyState===$.CONNECTING){$.once("open",function(){Z._write(X,z,N)});return}$.send(X,N)},Z.on("end",b8),Z.on("error",O9),Z}F9.exports=u8});var S9=u((qJ,E9)=>{var{tokenChars:k8}=h1();function h8($){let G=new Set,J=-1,Z=-1,X=0;for(X;X<$.length;X++){let N=$.charCodeAt(X);if(Z===-1&&k8[N]===1){if(J===-1)J=X}else if(X!==0&&(N===32||N===9)){if(Z===-1&&J!==-1)Z=X}else if(N===44){if(J===-1)throw SyntaxError(`Unexpected character at index ${X}`);if(Z===-1)Z=X;let Q=$.slice(J,Z);if(G.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);G.add(Q),J=Z=-1}else throw SyntaxError(`Unexpected character at index ${X}`)}if(J===-1||Z!==-1)throw SyntaxError("Unexpected end of input");let z=$.slice(J,X);if(G.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);return G.add(z),G}E9.exports={parse:h8}});var f9=u((UJ,g9)=>{var m8=w("events"),t0=w("http"),{Duplex:BJ}=w("stream"),{createHash:l8}=w("crypto"),w9=G4(),w1=X0(),d8=S9(),c8=a0(),{CLOSE_TIMEOUT:p8,GUID:i8,kWebSocket:n8}=U1(),s8=/^[+/0-9A-Za-z]{22}==$/;class v9 extends m8{constructor($,G){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:p8,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c8,...$},$.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=t0.createServer((J,Z)=>{let X=t0.STATUS_CODES[426];Z.writeHead(426,{"Content-Length":X.length,"Content-Type":"text/plain"}),Z.end(X)}),this._server.listen($.port,$.host,$.backlog,G);else if($.server)this._server=$.server;if(this._server){let J=this.emit.bind(this,"connection");this._removeListeners=o8(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Z,X,z)=>{this.handleUpgrade(Z,X,z,J)}})}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(Y0,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(Y0,this);else this._shouldEmitClose=!0;else process.nextTick(Y0,this)}else{let G=this._server;this._removeListeners(),this._removeListeners=this._server=null,G.close(()=>{Y0(this)})}}shouldHandle($){if(this.options.path){let G=$.url.indexOf("?");if((G!==-1?$.url.slice(0,G):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,G,J,Z){G.on("error",y9);let X=$.headers["sec-websocket-key"],z=$.headers.upgrade,N=+$.headers["sec-websocket-version"];if($.method!=="GET"){y1(this,$,G,405,"Invalid HTTP method");return}if(z===void 0||z.toLowerCase()!=="websocket"){y1(this,$,G,400,"Invalid Upgrade header");return}if(X===void 0||!s8.test(X)){y1(this,$,G,400,"Missing or invalid Sec-WebSocket-Key header");return}if(N!==13&&N!==8){y1(this,$,G,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){K0(G,400);return}let Q=$.headers["sec-websocket-protocol"],Y=new Set;if(Q!==void 0)try{Y=d8.parse(Q)}catch(H){y1(this,$,G,400,"Invalid Sec-WebSocket-Protocol header");return}let K=$.headers["sec-websocket-extensions"],I={};if(this.options.perMessageDeflate&&K!==void 0){let H=new w1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let U=w9.parse(K);if(U[w1.extensionName])H.accept(U[w1.extensionName]),I[w1.extensionName]=H}catch(U){y1(this,$,G,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let H={origin:$.headers[`${N===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(H,(U,_,q,B)=>{if(!U)return K0(G,_||401,q,B);this.completeUpgrade(I,X,Y,$,G,J,Z)});return}if(!this.options.verifyClient(H))return K0(G,401)}this.completeUpgrade(I,X,Y,$,G,J,Z)}completeUpgrade($,G,J,Z,X,z,N){if(!X.readable||!X.writable)return X.destroy();if(X[n8])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return K0(X,503);let Y=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${l8("sha1").update(G+i8).digest("base64")}`],K=new this.options.WebSocket(null,void 0,this.options);if(J.size){let I=this.options.handleProtocols?this.options.handleProtocols(J,Z):J.values().next().value;if(I)Y.push(`Sec-WebSocket-Protocol: ${I}`),K._protocol=I}if($[w1.extensionName]){let I=$[w1.extensionName].params,H=w9.format({[w1.extensionName]:[I]});Y.push(`Sec-WebSocket-Extensions: ${H}`),K._extensions=$}if(this.emit("headers",Y,Z),X.write(Y.concat(`\r
20
+ `),this.outputHelp({error:!0});let N=I||{},G=N.exitCode||1,J=N.code||"commander.error";this._exit(G,J,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in w.env){let I=$.attributeName();if(this.getOptionValue(I)===void 0||["default","config","env"].includes(this.getOptionValueSource(I)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,w.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new U5(this.options),I=(N)=>{return this.getOptionValue(N)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(N))};this.options.filter((N)=>N.implied!==void 0&&I(N.attributeName())&&$.valueFromOption(this.getOptionValue(N.attributeName()),N)).forEach((N)=>{Object.keys(N.implied).filter((G)=>!I(G)).forEach((G)=>{this.setOptionValueWithSource(G,N.implied[G],"implied")})})}missingArgument($){let I=`error: missing required argument '${$}'`;this.error(I,{code:"commander.missingArgument"})}optionMissingArgument($){let I=`error: option '${$.flags}' argument missing`;this.error(I,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let I=`error: required option '${$.flags}' not specified`;this.error(I,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,I){let N=(Z)=>{let z=Z.attributeName(),x=this.getOptionValue(z),Q=this.options.find((j)=>j.negate&&z===j.attributeName()),X=this.options.find((j)=>!j.negate&&z===j.attributeName());if(Q&&(Q.presetArg===void 0&&x===!1||Q.presetArg!==void 0&&x===Q.presetArg))return Q;return X||Z},G=(Z)=>{let z=N(Z),x=z.attributeName();if(this.getOptionValueSource(x)==="env")return`environment variable '${z.envVar}'`;return`option '${z.flags}'`},J=`error: ${G($)} cannot be used with ${G(I)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let I="";if($.startsWith("--")&&this._showSuggestionAfterError){let G=[],J=this;do{let Z=J.createHelp().visibleOptions(J).filter((z)=>z.long).map((z)=>z.long);G=G.concat(Z),J=J.parent}while(J&&!J._enablePositionalOptions);I=s2($,G)}let N=`error: unknown option '${$}'${I}`;this.error(N,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let I=this.registeredArguments.length,N=I===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${I} argument${N} but got ${$.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],I="";if(this._showSuggestionAfterError){let G=[];this.createHelp().visibleCommands(this).forEach((J)=>{if(G.push(J.name()),J.alias())G.push(J.alias())}),I=s2($,G)}let N=`error: unknown command '${$}'${I}`;this.error(N,{code:"commander.unknownCommand"})}version($,I,N){if($===void 0)return this._version;this._version=$,I=I||"-V, --version",N=N||"output the version number";let G=this.createOption(I,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($,I){if($===void 0&&I===void 0)return this._description;if(this._description=$,I)this._argsDescription=I;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let I=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)I=this.commands[this.commands.length-1];if($===I._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 I._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((I)=>this.alias(I)),this}usage($){if($===void 0){if(this._usage)return this._usage;let I=this.registeredArguments.map((N)=>{return H5(N)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?I:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=S1.basename($,S1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let I=this.createHelp();if(I.helpWidth===void 0)I.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return I.formatHelp(this,I)}_getHelpContext($){$=$||{};let I={error:!!$.error},N;if(I.error)N=(G)=>this._outputConfiguration.writeErr(G);else N=(G)=>this._outputConfiguration.writeOut(G);return I.write=$.write||N,I.command=this,I}outputHelp($){let I;if(typeof $==="function")I=$,$=void 0;let N=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((J)=>J.emit("beforeAllHelp",N)),this.emit("beforeHelp",N);let G=this.helpInformation(N);if(I){if(G=I(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((J)=>J.emit("afterAllHelp",N))}helpOption($,I){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",I=I??"display help for command",this._helpOption=this.createOption($,I),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 I=w.exitCode||0;if(I===0&&$&&typeof $!=="function"&&$.error)I=1;this._exit(I,"commander.help","(outputHelp)")}addHelpText($,I){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,(J)=>{let Z;if(typeof I==="function")Z=I({error:J.error,command:J.command});else Z=I;if(Z)J.write(`${Z}
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
24
24
  `).join(`\r
25
- `)),X.removeListener("error",y9),K.setSocket(X,z,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(K),K.on("close",()=>{if(this.clients.delete(K),this._shouldEmitClose&&!this.clients.size)process.nextTick(Y0,this)});N(K,Z)}}g9.exports=v9;function o8($,G){for(let J of Object.keys(G))$.on(J,G[J]);return function(){for(let Z of Object.keys(G))$.removeListener(Z,G[Z])}}function Y0($){$._state=2,$.emit("close")}function y9(){this.destroy()}function K0($,G,J,Z){J=J||t0.STATUS_CODES[G],Z={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(J),...Z},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${G} ${t0.STATUS_CODES[G]}\r
26
- `+Object.keys(Z).map((X)=>`${X}: ${Z[X]}`).join(`\r
25
+ `)),J.removeListener("error",_8),X.setSocket(J,Z,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(X),X.on("close",()=>{if(this.clients.delete(X),this._shouldEmitClose&&!this.clients.size)process.nextTick(x0,this)});z(X,G)}}f8.exports=V8;function c9($,I){for(let N of Object.keys(I))$.on(N,I[N]);return function(){for(let G of Object.keys(I))$.removeListener(G,I[G])}}function x0($){$._state=2,$.emit("close")}function _8(){this.destroy()}function z0($,I,N,G){N=N||m0.STATUS_CODES[I],G={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(N),...G},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${I} ${m0.STATUS_CODES[I]}\r
26
+ `+Object.keys(G).map((J)=>`${J}: ${G[J]}`).join(`\r
27
27
  `)+`\r
28
28
  \r
29
- `+J)}function y1($,G,J,Z,X,z){if($.listenerCount("wsClientError")){let N=Error(X);Error.captureStackTrace(N,y1),$.emit("wsClientError",N,J,G)}else K0(J,Z,X,z)}});var y4=s(w4(),1),{program:NG,createCommand:YG,createArgument:KG,createOption:HG,CommanderError:IG,InvalidArgumentError:qG,InvalidOptionArgumentError:BG,Command:v4,Argument:UG,Option:_G,Help:jG}=y4.default;var s1=s(f1(),1),d=s(q2(),1);import{stdout as V2,stdin as l4}from"node:process";import*as V1 from"node:readline";import c$ from"node:readline";import{ReadStream as u4}from"node:tty";var p$=($)=>$===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,i$=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,n$=($)=>$>=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,B2=/[\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,M0=/\t{1,1000}/y,U2=/[\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,T0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,s$=/\p{M}+/gu,o$={limit:1/0,ellipsis:""},d4=($,G={},J={})=>{let Z=G.limit??1/0,X=G.ellipsis??"",z=G?.ellipsisWidth??(X?d4(X,o$,J).width:0),N=J.ansiWidth??0,Q=J.controlWidth??0,Y=J.tabWidth??8,K=J.ambiguousWidth??1,I=J.emojiWidth??2,H=J.fullWidthWidth??2,U=J.regularWidth??1,_=J.wideWidth??2,q=0,B=0,M=$.length,V=0,x=!1,L=M,D=Math.max(0,Z-z),A=0,F=0,T=0,W=0;$:for(;;){if(F>A||B>=M&&B>q){let b=$.slice(A,F)||$.slice(q,B);V=0;for(let p of b.replaceAll(s$,"")){let n=p.codePointAt(0)||0;if(i$(n)?W=H:n$(n)?W=_:K!==U&&p$(n)?W=K:W=U,T+W>D&&(L=Math.min(L,Math.max(A,q)+V)),T+W>Z){x=!0;break $}V+=p.length,T+=W}A=F=0}if(B>=M)break;if(T0.lastIndex=B,T0.test($)){if(V=T0.lastIndex-B,W=V*U,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/U))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=T0.lastIndex;continue}if(B2.lastIndex=B,B2.test($)){if(T+N>D&&(L=Math.min(L,B)),T+N>Z){x=!0;break}T+=N,A=q,F=B,B=q=B2.lastIndex;continue}if(V0.lastIndex=B,V0.test($)){if(V=V0.lastIndex-B,W=V*Q,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/Q))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=V0.lastIndex;continue}if(M0.lastIndex=B,M0.test($)){if(V=M0.lastIndex-B,W=V*Y,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/Y))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=M0.lastIndex;continue}if(U2.lastIndex=B,U2.test($)){if(T+I>D&&(L=Math.min(L,B)),T+I>Z){x=!0;break}T+=I,A=q,F=B,B=q=U2.lastIndex;continue}B+=1}return{width:x?D:T,index:x?L:M,truncated:x,ellipsed:x&&Z>=z}},r$={limit:1/0,ellipsis:"",ellipsisWidth:0},o1=($,G={})=>d4($,r$,G).width,W0="\x1B",c4="›",a$=39,M2="\x07",p4="[",t$="]",i4="m",T2=`${t$}8;;`,k4=new RegExp(`(?:\\${p4}(?<code>\\d+)m|\\${T2}(?<uri>.*)${M2})`,"y"),e$=($)=>{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},h4=($)=>`${W0}${p4}${$}${i4}`,m4=($)=>`${W0}${T2}${$}${M2}`,$5=($)=>$.map((G)=>o1(G)),_2=($,G,J)=>{let Z=G[Symbol.iterator](),X=!1,z=!1,N=$.at(-1),Q=N===void 0?0:o1(N),Y=Z.next(),K=Z.next(),I=0;for(;!Y.done;){let H=Y.value,U=o1(H);Q+U<=J?$[$.length-1]+=H:($.push(H),Q=0),(H===W0||H===c4)&&(X=!0,z=G.startsWith(T2,I+1)),X?z?H===M2&&(X=!1,z=!1):H===i4&&(X=!1):(Q+=U,Q===J&&!K.done&&($.push(""),Q=0)),Y=K,K=Z.next(),I+=H.length}N=$.at(-1),!Q&&N!==void 0&&N.length>0&&$.length>1&&($[$.length-2]+=$.pop())},G5=($)=>{let G=$.split(" "),J=G.length;for(;J>0&&!(o1(G[J-1])>0);)J--;return J===G.length?$:G.slice(0,J).join(" ")+G.slice(J).join("")},J5=($,G,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Z="",X,z,N=$.split(" "),Q=$5(N),Y=[""];for(let[q,B]of N.entries()){J.trim!==!1&&(Y[Y.length-1]=(Y.at(-1)??"").trimStart());let M=o1(Y.at(-1)??"");if(q!==0&&(M>=G&&(J.wordWrap===!1||J.trim===!1)&&(Y.push(""),M=0),(M>0||J.trim===!1)&&(Y[Y.length-1]+=" ",M++)),J.hard&&Q[q]>G){let V=G-M,x=1+Math.floor((Q[q]-V-1)/G);Math.floor((Q[q]-1)/G)<x&&Y.push(""),_2(Y,B,G);continue}if(M+Q[q]>G&&M>0&&Q[q]>0){if(J.wordWrap===!1&&M<G){_2(Y,B,G);continue}Y.push("")}if(M+Q[q]>G&&J.wordWrap===!1){_2(Y,B,G);continue}Y[Y.length-1]+=B}J.trim!==!1&&(Y=Y.map((q)=>G5(q)));let K=Y.join(`
30
- `),I=K[Symbol.iterator](),H=I.next(),U=I.next(),_=0;for(;!H.done;){let q=H.value,B=U.value;if(Z+=q,q===W0||q===c4){k4.lastIndex=_+1;let V=k4.exec(K)?.groups;if(V?.code!==void 0){let x=Number.parseFloat(V.code);X=x===a$?void 0:x}else V?.uri!==void 0&&(z=V.uri.length===0?void 0:V.uri)}let M=X?e$(X):void 0;B===`
31
- `?(z&&(Z+=m4("")),X&&M&&(Z+=h4(M))):q===`
32
- `&&(X&&M&&(Z+=h4(X)),z&&(Z+=m4(z))),_+=q.length,H=U,U=I.next()}return Z};function j2($,G,J){return String($).normalize().replaceAll(`\r
33
- `,`
34
- `).split(`
35
- `).map((Z)=>J5(Z,G,J)).join(`
36
- `)}var Z5=["up","down","left","right","space","enter","cancel"],J1={actions:new Set(Z5),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 x2($,G){if(typeof $=="string")return J1.aliases.get($)===G;for(let J of $)if(J!==void 0&&x2(J,G))return!0;return!1}function X5($,G){if($===G)return;let J=$.split(`
37
- `),Z=G.split(`
38
- `),X=Math.max(J.length,Z.length),z=[];for(let N=0;N<X;N++)J[N]!==Z[N]&&z.push(N);return{lines:z,numLinesBefore:J.length,numLinesAfter:Z.length,numLines:X}}var z5=globalThis.process.platform.startsWith("win"),R2=Symbol("clack:cancel");function t($){return $===R2}function x0($,G){let J=$;J.isTTY&&J.setRawMode(G)}function n4({input:$=l4,output:G=V2,overwrite:J=!0,hideCursor:Z=!0}={}){let X=V1.createInterface({input:$,output:G,prompt:"",tabSize:1});V1.emitKeypressEvents($,X),$ instanceof u4&&$.isTTY&&$.setRawMode(!0);let z=(N,{name:Q,sequence:Y})=>{let K=String(N);if(x2([K,Q,Y],"cancel")){Z&&G.write(d.cursor.show),process.exit(0);return}if(!J)return;V1.moveCursor(G,Q==="return"?0:-1,Q==="return"?-1:0,()=>{V1.clearLine(G,1,()=>{$.once("keypress",z)})})};return Z&&G.write(d.cursor.hide),$.once("keypress",z),()=>{$.off("keypress",z),Z&&G.write(d.cursor.show),$ instanceof u4&&$.isTTY&&!z5&&$.setRawMode(!1),X.terminal=!1,X.close()}}var r1=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,W2=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20;function C1($,G,J,Z=J){let X=r1($??V2);return j2(G,X-J.length,{hard:!0,trim:!1}).split(`
39
- `).map((z,N)=>`${N===0?Z:J}${z}`).join(`
40
- `)}class O1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,G=!0){let{input:J=l4,output:Z=V2,render:X,signal:z,...N}=$;this.opts=N,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=X.bind(this),this._track=G,this._abortSignal=z,this.input=J,this.output=Z}unsubscribe(){this._subscribers.clear()}setSubscriber($,G){let J=this._subscribers.get($)??[];J.push(G),this._subscribers.set($,J)}on($,G){this.setSubscriber($,{cb:G})}once($,G){this.setSubscriber($,{cb:G,once:!0})}emit($,...G){let J=this._subscribers.get($)??[],Z=[];for(let X of J)X.cb(...G),X.once&&Z.push(()=>J.splice(J.indexOf(X),1));for(let X of Z)X()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(R2);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=c$.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),x0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(d.cursor.show),this.output.off("resize",this.render),x0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(d.cursor.show),this.output.off("resize",this.render),x0(this.input,!1),$(R2)})})}_isActionKey($,G){return $==="\t"}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,G){this.userInput=$??"",this.emit("userInput",this.userInput),G&&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($,G){if(this._track&&G.name!=="return"&&(G.name&&this._isActionKey($,G)&&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"),G?.name&&(!this._track&&J1.aliases.has(G.name)&&this.emit("cursor",J1.aliases.get(G.name)),J1.actions.has(G.name)&&this.emit("cursor",G.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$?.toLowerCase(),G),G?.name==="return"){if(this.opts.validate){let J=this.opts.validate(this.value);J&&(this.error=J instanceof Error?J.message:J,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}x2([$,G?.name,G?.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(`
41
- `),x0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=j2(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
42
- `).length-1;this.output.write(d.cursor.move(-999,$*-1))}render(){let $=j2(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(d.cursor.hide);else{let G=X5(this._prevFrame,$),J=W2(this.output);if(this.restoreCursor(),G){let Z=Math.max(0,G.numLinesAfter-J),X=Math.max(0,G.numLinesBefore-J),z=G.lines.find((N)=>N>=Z);if(z===void 0){this._prevFrame=$;return}if(G.lines.length===1){this.output.write(d.cursor.move(0,z-X)),this.output.write(d.erase.lines(1));let N=$.split(`
43
- `);this.output.write(N[z]),this._prevFrame=$,this.output.write(d.cursor.move(0,N.length-z-1));return}else if(G.lines.length>1){if(Z<X)z=Z;else{let Q=z-X;Q>0&&this.output.write(d.cursor.move(0,Q))}this.output.write(d.erase.down());let N=$.split(`
44
- `).slice(z);this.output.write(N.join(`
45
- `)),this._prevFrame=$;return}}this.output.write(d.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function Q5($,G){if($===void 0||G.length===0)return 0;let J=G.findIndex((Z)=>Z.value===$);return J!==-1?J:0}function N5($,G){return(G.label??String(G.value)).toLowerCase().includes($.toLowerCase())}function Y5($,G){if(G)return $?G:G[0]}class s4 extends O1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#J="";#Z;#G;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return s1.default.inverse(s1.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[G,...J]=this.userInput.slice(this._cursor);return`${$}${s1.default.inverse(G)}${J.join("")}`}get options(){return typeof this.#G=="function"?this.#G():this.#G}constructor($){super($),this.#G=$.options;let G=this.options;this.filteredOptions=[...G],this.multiple=$.multiple===!0,this.#Z=$.filter??N5;let J;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?J=$.initialValue:J=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(J=[this.options[0].value]),J)for(let Z of J){let X=G.findIndex((z)=>z.value===Z);X!==-1&&(this.toggleSelected(Z),this.#$=X)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(Z,X)=>this.#X(Z,X)),this.on("userInput",(Z)=>this.#z(Z))}_isActionKey($,G){return $==="\t"||this.multiple&&this.isNavigating&&G.name==="space"&&$!==void 0&&$!==""}#X($,G){let J=G.name==="up",Z=G.name==="down",X=G.name==="return";J||Z?(this.#$=Math.max(0,Math.min(this.#$+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):X?this.value=Y5(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(G.name==="tab"||this.isNavigating&&G.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((G)=>G!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#z($){if($!==this.#J){this.#J=$;let G=this.options;$?this.filteredOptions=G.filter((J)=>this.#Z($,J)):this.filteredOptions=[...G],this.#$=Q5(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class L2 extends O1{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",(G)=>{this.output.write(d.cursor.move(0,-1)),this.value=G,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class o4 extends O1{options;cursor=0;#$;getGroupItems($){return this.options.filter((G)=>G.group===$)}isGroupSelected($){let G=this.getGroupItems($),J=this.value;return J===void 0?!1:G.every((Z)=>J.includes(Z.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let G=$.value,J=this.getGroupItems(G);this.isGroupSelected(G)?this.value=this.value.filter((Z)=>J.findIndex((X)=>X.value===Z)===-1):this.value=[...this.value,...J.map((Z)=>Z.value)],this.value=Array.from(new Set(this.value))}else{let G=this.value.includes($.value);this.value=G?this.value.filter((J)=>J!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:G}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(G).flatMap(([J,Z])=>[{value:J,group:!0,label:J},...Z.map((X)=>({...X,group:J}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===$.cursorAt),this.#$?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;!this.#$&&Z&&(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 Z=this.options[this.cursor]?.group===!0;!this.#$&&Z&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function D1($,G,J){let Z=$+G,X=Math.max(J.length-1,0),z=Z<0?X:Z>X?0:Z;return J[z].disabled?D1(z,G<0?-1:1,J):z}class A2 extends O1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,G=this.value!==void 0&&this.value.length===$.length;this.value=G?[]:$.map((J)=>J.value)}toggleInvert(){let $=this.value;if(!$)return;let G=this._enabledOptions.filter((J)=>!$.includes(J.value));this.value=G.map((J)=>J.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((G)=>G!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let G=Math.max(this.options.findIndex(({value:J})=>J===$.cursorAt),0);this.cursor=this.options[G].disabled?D1(G,1,this.options):G,this.on("key",(J)=>{J==="a"&&this.toggleAll(),J==="i"&&this.toggleInvert()}),this.on("cursor",(J)=>{switch(J){case"left":case"up":this.cursor=D1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=D1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class D2 extends O1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let G=this.options.findIndex(({value:Z})=>Z===$.initialValue),J=G===-1?0:G;this.cursor=this.options[J].disabled?D1(J,1,this.options):J,this.changeValue(),this.on("cursor",(Z)=>{switch(Z){case"left":case"up":this.cursor=D1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=D1(this.cursor,1,this.options);break}this.changeValue()})}}class C2 extends O1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let G=$.slice(0,this.cursor),[J,...Z]=$.slice(this.cursor);return`${G}${s1.default.inverse(J)}${Z.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(G)=>{this._setValue(G)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var j=s(f1(),1);import e from"node:process";var t1=s(q2(),1);function K5(){return e.platform!=="win32"?e.env.TERM!=="linux":!!e.env.CI||!!e.env.WT_SESSION||!!e.env.TERMINUS_SUBLIME||e.env.ConEmuTask==="{cmd::Cmder}"||e.env.TERM_PROGRAM==="Terminus-Sublime"||e.env.TERM_PROGRAM==="vscode"||e.env.TERM==="xterm-256color"||e.env.TERM==="alacritty"||e.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var E2=K5(),H5=()=>process.env.CI==="true";var E=($,G)=>E2?$:G,I5=E("◆","*"),J3=E("■","x"),Z3=E("▲","x"),F0=E("◇","o"),q5=E("┌","T"),P=E("│","|"),M1=E("└","—"),PG=E("┐","T"),EG=E("┘","—"),S2=E("●",">"),O0=E("○"," "),B5=E("◻","[•]"),r4=E("◼","[+]"),a4=E("◻","[ ]"),SG=E("▪","•"),t4=E("─","-"),U5=E("╮","+"),_5=E("├","+"),j5=E("╯","+"),R5=E("╰","+"),wG=E("╭","+"),V5=E("●","•"),M5=E("◆","*"),T5=E("▲","!"),x5=E("■","x"),P0=($)=>{switch($){case"initial":case"active":return j.default.cyan(I5);case"cancel":return j.default.red(J3);case"error":return j.default.yellow(Z3);case"submit":return j.default.green(F0)}},X3=($)=>{switch($){case"initial":case"active":return j.default.cyan(P);case"cancel":return j.default.red(P);case"error":return j.default.yellow(P);case"submit":return j.default.green(P)}},W5=($)=>$===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,L5=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,A5=($)=>$>=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,O2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,L0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,A0=/\t{1,1000}/y,F2=/[\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,D0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,D5=/\p{M}+/gu,C5={limit:1/0,ellipsis:""},z3=($,G={},J={})=>{let Z=G.limit??1/0,X=G.ellipsis??"",z=G?.ellipsisWidth??(X?z3(X,C5,J).width:0),N=J.ansiWidth??0,Q=J.controlWidth??0,Y=J.tabWidth??8,K=J.ambiguousWidth??1,I=J.emojiWidth??2,H=J.fullWidthWidth??2,U=J.regularWidth??1,_=J.wideWidth??2,q=0,B=0,M=$.length,V=0,x=!1,L=M,D=Math.max(0,Z-z),A=0,F=0,T=0,W=0;$:for(;;){if(F>A||B>=M&&B>q){let b=$.slice(A,F)||$.slice(q,B);V=0;for(let p of b.replaceAll(D5,"")){let n=p.codePointAt(0)||0;if(L5(n)?W=H:A5(n)?W=_:K!==U&&W5(n)?W=K:W=U,T+W>D&&(L=Math.min(L,Math.max(A,q)+V)),T+W>Z){x=!0;break $}V+=p.length,T+=W}A=F=0}if(B>=M)break;if(D0.lastIndex=B,D0.test($)){if(V=D0.lastIndex-B,W=V*U,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/U))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=D0.lastIndex;continue}if(O2.lastIndex=B,O2.test($)){if(T+N>D&&(L=Math.min(L,B)),T+N>Z){x=!0;break}T+=N,A=q,F=B,B=q=O2.lastIndex;continue}if(L0.lastIndex=B,L0.test($)){if(V=L0.lastIndex-B,W=V*Q,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/Q))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=L0.lastIndex;continue}if(A0.lastIndex=B,A0.test($)){if(V=A0.lastIndex-B,W=V*Y,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/Y))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=A0.lastIndex;continue}if(F2.lastIndex=B,F2.test($)){if(T+I>D&&(L=Math.min(L,B)),T+I>Z){x=!0;break}T+=I,A=q,F=B,B=q=F2.lastIndex;continue}B+=1}return{width:x?D:T,index:x?L:M,truncated:x,ellipsed:x&&Z>=z}},O5={limit:1/0,ellipsis:"",ellipsisWidth:0},Y1=($,G={})=>z3($,O5,G).width,E0="\x1B",Q3="›",F5=39,y2="\x07",N3="[",P5="]",Y3="m",v2=`${P5}8;;`,e4=new RegExp(`(?:\\${N3}(?<code>\\d+)m|\\${v2}(?<uri>.*)${y2})`,"y"),E5=($)=>{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},$3=($)=>`${E0}${N3}${$}${Y3}`,G3=($)=>`${E0}${v2}${$}${y2}`,S5=($)=>$.map((G)=>Y1(G)),P2=($,G,J)=>{let Z=G[Symbol.iterator](),X=!1,z=!1,N=$.at(-1),Q=N===void 0?0:Y1(N),Y=Z.next(),K=Z.next(),I=0;for(;!Y.done;){let H=Y.value,U=Y1(H);Q+U<=J?$[$.length-1]+=H:($.push(H),Q=0),(H===E0||H===Q3)&&(X=!0,z=G.startsWith(v2,I+1)),X?z?H===y2&&(X=!1,z=!1):H===Y3&&(X=!1):(Q+=U,Q===J&&!K.done&&($.push(""),Q=0)),Y=K,K=Z.next(),I+=H.length}N=$.at(-1),!Q&&N!==void 0&&N.length>0&&$.length>1&&($[$.length-2]+=$.pop())},w5=($)=>{let G=$.split(" "),J=G.length;for(;J>0&&!(Y1(G[J-1])>0);)J--;return J===G.length?$:G.slice(0,J).join(" ")+G.slice(J).join("")},y5=($,G,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Z="",X,z,N=$.split(" "),Q=S5(N),Y=[""];for(let[q,B]of N.entries()){J.trim!==!1&&(Y[Y.length-1]=(Y.at(-1)??"").trimStart());let M=Y1(Y.at(-1)??"");if(q!==0&&(M>=G&&(J.wordWrap===!1||J.trim===!1)&&(Y.push(""),M=0),(M>0||J.trim===!1)&&(Y[Y.length-1]+=" ",M++)),J.hard&&Q[q]>G){let V=G-M,x=1+Math.floor((Q[q]-V-1)/G);Math.floor((Q[q]-1)/G)<x&&Y.push(""),P2(Y,B,G);continue}if(M+Q[q]>G&&M>0&&Q[q]>0){if(J.wordWrap===!1&&M<G){P2(Y,B,G);continue}Y.push("")}if(M+Q[q]>G&&J.wordWrap===!1){P2(Y,B,G);continue}Y[Y.length-1]+=B}J.trim!==!1&&(Y=Y.map((q)=>w5(q)));let K=Y.join(`
46
- `),I=K[Symbol.iterator](),H=I.next(),U=I.next(),_=0;for(;!H.done;){let q=H.value,B=U.value;if(Z+=q,q===E0||q===Q3){e4.lastIndex=_+1;let V=e4.exec(K)?.groups;if(V?.code!==void 0){let x=Number.parseFloat(V.code);X=x===F5?void 0:x}else V?.uri!==void 0&&(z=V.uri.length===0?void 0:V.uri)}let M=X?E5(X):void 0;B===`
47
- `?(z&&(Z+=G3("")),X&&M&&(Z+=$3(M))):q===`
48
- `&&(X&&M&&(Z+=$3(X)),z&&(Z+=G3(z))),_+=q.length,H=U,U=I.next()}return Z};function e1($,G,J){return String($).normalize().replaceAll(`\r
49
- `,`
50
- `).split(`
51
- `).map((Z)=>y5(Z,G,J)).join(`
52
- `)}var v5=($,G,J,Z,X)=>{let z=G,N=0;for(let Q=J;Q<Z;Q++){let Y=$[Q];if(z=z-Y.length,N++,z<=X)break}return{lineCount:z,removals:N}},w2=($)=>{let{cursor:G,options:J,style:Z}=$,X=$.output??process.stdout,z=r1(X),N=$.columnPadding??0,Q=$.rowPadding??4,Y=z-N,K=W2(X),I=j.default.dim("..."),H=$.maxItems??Number.POSITIVE_INFINITY,U=Math.max(K-Q,0),_=Math.max(Math.min(H,U),5),q=0;G>=_-3&&(q=Math.max(Math.min(G-_+3,J.length-_),0));let B=_<J.length&&q>0,M=_<J.length&&q+_<J.length,V=Math.min(q+_,J.length),x=[],L=0;B&&L++,M&&L++;let D=q+(B?1:0),A=V-(M?1:0);for(let T=D;T<A;T++){let W=e1(Z(J[T],T===G),Y,{hard:!0,trim:!1}).split(`
53
- `);x.push(W),L+=W.length}if(L>U){let T=0,W=0,b=L,p=G-D,n=(A1,v)=>v5(x,b,A1,v,U);B?({lineCount:b,removals:T}=n(0,p),b>U&&({lineCount:b,removals:W}=n(p+1,x.length))):({lineCount:b,removals:W}=n(p+1,x.length),b>U&&({lineCount:b,removals:T}=n(0,p))),T>0&&(B=!0,x.splice(0,T)),W>0&&(M=!0,x.splice(x.length-W,W))}let F=[];B&&F.push(I);for(let T of x)for(let W of T)F.push(W);return M&&F.push(I),F};var K3=($)=>{let G=$.active??"Yes",J=$.inactive??"No";return new L2({active:G,inactive:J,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let Z=`${j.default.gray(P)}
54
- ${P0(this.state)} ${$.message}
55
- `,X=this.value?G:J;switch(this.state){case"submit":return`${Z}${j.default.gray(P)} ${j.default.dim(X)}`;case"cancel":return`${Z}${j.default.gray(P)} ${j.default.strikethrough(j.default.dim(X))}
56
- ${j.default.gray(P)}`;default:return`${Z}${j.default.cyan(P)} ${this.value?`${j.default.green(S2)} ${G}`:`${j.default.dim(O0)} ${j.default.dim(G)}`} ${j.default.dim("/")} ${this.value?`${j.default.dim(O0)} ${j.default.dim(J)}`:`${j.default.green(S2)} ${J}`}
57
- ${j.default.cyan(M1)}
58
- `}}}).prompt()};var Z1={message:($=[],{symbol:G=j.default.gray(P),secondarySymbol:J=j.default.gray(P),output:Z=process.stdout,spacing:X=1,withGuide:z}={})=>{let N=[],Q=(z??J1.withGuide)!==!1,Y=Q?J:"",K=Q?`${G} `:"",I=Q?`${J} `:"";for(let U=0;U<X;U++)N.push(Y);let H=Array.isArray($)?$:$.split(`
59
- `);if(H.length>0){let[U,..._]=H;U.length>0?N.push(`${K}${U}`):N.push(Q?G:"");for(let q of _)q.length>0?N.push(`${I}${q}`):N.push(Q?J:"")}Z.write(`${N.join(`
60
- `)}
61
- `)},info:($,G)=>{Z1.message($,{...G,symbol:j.default.blue(V5)})},success:($,G)=>{Z1.message($,{...G,symbol:j.default.green(M5)})},step:($,G)=>{Z1.message($,{...G,symbol:j.default.green(F0)})},warn:($,G)=>{Z1.message($,{...G,symbol:j.default.yellow(T5)})},warning:($,G)=>{Z1.warn($,G)},error:($,G)=>{Z1.message($,{...G,symbol:j.default.red(x5)})}},B1=($="",G)=>{(G?.output??process.stdout).write(`${j.default.gray(M1)} ${j.default.red($)}
62
-
63
- `)},F1=($="",G)=>{(G?.output??process.stdout).write(`${j.default.gray(q5)} ${$}
64
- `)},$1=($="",G)=>{(G?.output??process.stdout).write(`${j.default.gray(P)}
65
- ${j.default.gray(M1)} ${$}
66
-
67
- `)},a1=($,G)=>$.split(`
68
- `).map((J)=>G(J)).join(`
69
- `),g2=($)=>{let G=(Z,X)=>{let z=Z.label??String(Z.value);return X==="disabled"?`${j.default.gray(a4)} ${a1(z,(N)=>j.default.strikethrough(j.default.gray(N)))}${Z.hint?` ${j.default.dim(`(${Z.hint??"disabled"})`)}`:""}`:X==="active"?`${j.default.cyan(B5)} ${z}${Z.hint?` ${j.default.dim(`(${Z.hint})`)}`:""}`:X==="selected"?`${j.default.green(r4)} ${a1(z,j.default.dim)}${Z.hint?` ${j.default.dim(`(${Z.hint})`)}`:""}`:X==="cancelled"?`${a1(z,(N)=>j.default.strikethrough(j.default.dim(N)))}`:X==="active-selected"?`${j.default.green(r4)} ${z}${Z.hint?` ${j.default.dim(`(${Z.hint})`)}`:""}`:X==="submitted"?`${a1(z,j.default.dim)}`:`${j.default.dim(a4)} ${a1(z,j.default.dim)}`},J=$.required??!0;return new A2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:J,cursorAt:$.cursorAt,validate(Z){if(J&&(Z===void 0||Z.length===0))return`Please select at least one option.
70
- ${j.default.reset(j.default.dim(`Press ${j.default.gray(j.default.bgWhite(j.default.inverse(" space ")))} to select, ${j.default.gray(j.default.bgWhite(j.default.inverse(" enter ")))} to submit`))}`},render(){let Z=C1($.output,$.message,`${X3(this.state)} `,`${P0(this.state)} `),X=`${j.default.gray(P)}
71
- ${Z}
72
- `,z=this.value??[],N=(Q,Y)=>{if(Q.disabled)return G(Q,"disabled");let K=z.includes(Q.value);return Y&&K?G(Q,"active-selected"):K?G(Q,"selected"):G(Q,Y?"active":"inactive")};switch(this.state){case"submit":{let Q=this.options.filter(({value:K})=>z.includes(K)).map((K)=>G(K,"submitted")).join(j.default.dim(", "))||j.default.dim("none"),Y=C1($.output,Q,`${j.default.gray(P)} `);return`${X}${Y}`}case"cancel":{let Q=this.options.filter(({value:K})=>z.includes(K)).map((K)=>G(K,"cancelled")).join(j.default.dim(", "));if(Q.trim()==="")return`${X}${j.default.gray(P)}`;let Y=C1($.output,Q,`${j.default.gray(P)} `);return`${X}${Y}
73
- ${j.default.gray(P)}`}case"error":{let Q=`${j.default.yellow(P)} `,Y=this.error.split(`
74
- `).map((H,U)=>U===0?`${j.default.yellow(M1)} ${j.default.yellow(H)}`:` ${H}`).join(`
75
- `),K=X.split(`
76
- `).length,I=Y.split(`
77
- `).length+1;return`${X}${Q}${w2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:K+I,style:N}).join(`
78
- ${Q}`)}
79
- ${Y}
80
- `}default:{let Q=`${j.default.cyan(P)} `,Y=X.split(`
81
- `).length;return`${X}${Q}${w2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:Y+2,style:N}).join(`
82
- ${Q}`)}
83
- ${j.default.cyan(M1)}
84
- `}}}}).prompt()},g5=($)=>j.default.dim($),f5=($,G,J)=>{let Z={hard:!0,trim:!1},X=e1($,G,Z).split(`
85
- `),z=X.reduce((Y,K)=>Math.max(Y1(K),Y),0),N=X.map(J).reduce((Y,K)=>Math.max(Y1(K),Y),0),Q=G-(N-z);return e1($,Q,Z)},g=($="",G="",J)=>{let Z=J?.output??e.stdout,X=(J?.withGuide??J1.withGuide)!==!1,z=J?.format??g5,N=["",...f5($,r1(Z)-6,z).split(`
86
- `).map(z),""],Q=Y1(G),Y=Math.max(N.reduce((U,_)=>{let q=Y1(_);return q>U?q:U},0),Q)+2,K=N.map((U)=>`${j.default.gray(P)} ${U}${" ".repeat(Y-Y1(U))}${j.default.gray(P)}`).join(`
87
- `),I=X?`${j.default.gray(P)}
88
- `:"",H=X?_5:R5;Z.write(`${I}${j.default.green(F0)} ${j.default.reset(G)} ${j.default.gray(t4.repeat(Math.max(Y-Q-1,1))+U5)}
89
- ${K}
90
- ${j.default.gray(H+t4.repeat(Y+2)+j5)}
91
- `)};var b5=j.default.magenta,S0=({indicator:$="dots",onCancel:G,output:J=process.stdout,cancelMessage:Z,errorMessage:X,frames:z=E2?["◒","◐","◓","◑"]:["•","o","O","0"],delay:N=E2?80:120,signal:Q,...Y}={})=>{let K=H5(),I,H,U=!1,_=!1,q="",B,M=performance.now(),V=r1(J),x=Y?.styleFrame??b5,L=(v)=>{let a=v>1?X??J1.messages.error:Z??J1.messages.cancel;_=v===1,U&&(A1(a,v),_&&typeof G=="function"&&G())},D=()=>L(2),A=()=>L(1),F=()=>{process.on("uncaughtExceptionMonitor",D),process.on("unhandledRejection",D),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",L),Q&&Q.addEventListener("abort",A)},T=()=>{process.removeListener("uncaughtExceptionMonitor",D),process.removeListener("unhandledRejection",D),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",L),Q&&Q.removeEventListener("abort",A)},W=()=>{if(B===void 0)return;K&&J.write(`
92
- `);let v=e1(B,V,{hard:!0,trim:!1}).split(`
93
- `);v.length>1&&J.write(t1.cursor.up(v.length-1)),J.write(t1.cursor.to(0)),J.write(t1.erase.down())},b=(v)=>v.replace(/\.+$/,""),p=(v)=>{let a=(performance.now()-v)/1000,H1=Math.floor(a/60),I1=Math.floor(a%60);return H1>0?`[${H1}m ${I1}s]`:`[${I1}s]`},n=(v="")=>{U=!0,I=n4({output:J}),q=b(v),M=performance.now(),J.write(`${j.default.gray(P)}
94
- `);let a=0,H1=0;F(),H=setInterval(()=>{if(K&&q===B)return;W(),B=q;let I1=x(z[a]),U0;if(K)U0=`${I1} ${q}...`;else if($==="timer")U0=`${I1} ${q} ${p(M)}`;else{let p9=".".repeat(Math.floor(H1)).slice(0,3);U0=`${I1} ${q}${p9}`}let c9=e1(U0,V,{hard:!0,trim:!1});J.write(c9),a=a+1<z.length?a+1:0,H1=H1<4?H1+0.125:0},N)},A1=(v="",a=0,H1=!1)=>{if(!U)return;U=!1,clearInterval(H),W();let I1=a===0?j.default.green(F0):a===1?j.default.red(J3):j.default.red(Z3);q=v??q,H1||($==="timer"?J.write(`${I1} ${q} ${p(M)}
95
- `):J.write(`${I1} ${q}
96
- `)),T(),I()};return{start:n,stop:(v="")=>A1(v,0),message:(v="")=>{q=b(v??q)},cancel:(v="")=>A1(v,1),error:(v="")=>A1(v,2),clear:()=>A1("",0,!0),get isCancelled(){return _}}},yG={light:E("─","-"),heavy:E("━","="),block:E("█","#")};var C0=($,G)=>$.includes(`
97
- `)?$.split(`
98
- `).map((J)=>G(J)).join(`
99
- `):G($),w0=($)=>{let G=(J,Z)=>{let X=J.label??String(J.value);switch(Z){case"disabled":return`${j.default.gray(O0)} ${C0(X,j.default.gray)}${J.hint?` ${j.default.dim(`(${J.hint??"disabled"})`)}`:""}`;case"selected":return`${C0(X,j.default.dim)}`;case"active":return`${j.default.green(S2)} ${X}${J.hint?` ${j.default.dim(`(${J.hint})`)}`:""}`;case"cancelled":return`${C0(X,(z)=>j.default.strikethrough(j.default.dim(z)))}`;default:return`${j.default.dim(O0)} ${C0(X,j.default.dim)}`}};return new D2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let J=`${P0(this.state)} `,Z=`${X3(this.state)} `,X=C1($.output,$.message,Z,J),z=`${j.default.gray(P)}
100
- ${X}
101
- `;switch(this.state){case"submit":{let N=`${j.default.gray(P)} `,Q=C1($.output,G(this.options[this.cursor],"selected"),N);return`${z}${Q}`}case"cancel":{let N=`${j.default.gray(P)} `,Q=C1($.output,G(this.options[this.cursor],"cancelled"),N);return`${z}${Q}
102
- ${j.default.gray(P)}`}default:{let N=`${j.default.cyan(P)} `,Q=z.split(`
103
- `).length;return`${z}${N}${w2({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:N.length,rowPadding:Q+2,style:(Y,K)=>G(Y,Y.disabled?"disabled":K?"active":"inactive")}).join(`
104
- ${N}`)}
105
- ${j.default.cyan(M1)}
106
- `}}}}).prompt()};var vG=`${j.default.gray(P)} `;var y0=($)=>new C2({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let G=($?.withGuide??J1.withGuide)!==!1,J=`${`${G?`${j.default.gray(P)}
107
- `:""}${P0(this.state)} `}${$.message}
108
- `,Z=$.placeholder?j.default.inverse($.placeholder[0])+j.default.dim($.placeholder.slice(1)):j.default.inverse(j.default.hidden("_")),X=this.userInput?this.userInputWithCursor:Z,z=this.value??"";switch(this.state){case"error":{let N=this.error?` ${j.default.yellow(this.error)}`:"",Q=G?`${j.default.yellow(P)} `:"",Y=G?j.default.yellow(M1):"";return`${J.trim()}
109
- ${Q}${X}
110
- ${Y}${N}
111
- `}case"submit":{let N=z?` ${j.default.dim(z)}`:"",Q=G?j.default.gray(P):"";return`${J}${Q}${N}`}case"cancel":{let N=z?` ${j.default.strikethrough(j.default.dim(z))}`:"",Q=G?j.default.gray(P):"";return`${J}${Q}${N}${z.trim()?`
112
- ${Q}`:""}`}default:{let N=G?`${j.default.cyan(P)} `:"",Q=G?j.default.cyan(M1):"";return`${J}${N}${X}
113
- ${Q}
114
- `}}}}).prompt();var R=s(f1(),1);import{existsSync as h,mkdirSync as i1,readFileSync as v1,writeFileSync as g1,readdirSync as p1}from"node:fs";import{execSync as m}from"node:child_process";import{dirname as G2,join as S}from"node:path";import{createHash as C7}from"node:crypto";async function f2($,G,{concurrency:J=Number.POSITIVE_INFINITY,stopOnError:Z=!0,signal:X}={}){return new Promise((z,N)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof G!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(J)&&J>=1||J===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${J}\` (${typeof J})`);let Q=[],Y=[],K=new Map,I=!1,H=!1,U=!1,_=0,q=0,B=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),M=()=>{L(X.reason)},V=()=>{X?.removeEventListener("abort",M)},x=(A)=>{z(A),V()},L=(A)=>{I=!0,H=!0,N(A),V()};if(X){if(X.aborted)L(X.reason);X.addEventListener("abort",M,{once:!0})}let D=async()=>{if(H)return;let A=await B.next(),F=q;if(q++,A.done){if(U=!0,_===0&&!H){if(!Z&&Y.length>0){L(AggregateError(Y));return}if(H=!0,K.size===0){x(Q);return}let T=[];for(let[W,b]of Q.entries()){if(K.get(W)===H3)continue;T.push(b)}x(T)}return}_++,(async()=>{try{let T=await A.value;if(H)return;let W=await G(T,F);if(W===H3)K.set(F,W);Q[F]=W,_--,await D()}catch(T){if(Z)L(T);else{Y.push(T),_--;try{await D()}catch(W){L(W)}}}})()};(async()=>{for(let A=0;A<J;A++){try{await D()}catch(F){L(F);break}if(U||I)break}})()})}var H3=Symbol("skip");import{stat as U6}from"fs";import{stat as _6,readdir as j6}from"fs/promises";import{EventEmitter as R6}from"events";import*as O from"path";import{stat as k5,lstat as I3,readdir as h5,realpath as m5}from"node:fs/promises";import{Readable as l5}from"node:stream";import{resolve as q3,relative as d5,join as c5,sep as p5}from"node:path";var o={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},b2={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:o.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(b2);var j3="READDIRP_RECURSIVE_ERROR",i5=new Set(["ENOENT","EPERM","EACCES","ELOOP",j3]),B3=[o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE],n5=new Set([o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE]),s5=new Set([o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE]),o5=($)=>i5.has($.code),r5=process.platform==="win32",U3=($)=>!0,_3=($)=>{if($===void 0)return U3;if(typeof $==="function")return $;if(typeof $==="string"){let G=$.trim();return(J)=>J.basename===G}if(Array.isArray($)){let G=$.map((J)=>J.trim());return(J)=>G.some((Z)=>J.basename===Z)}return U3};class R3 extends l5{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let G={...b2,...$},{root:J,type:Z}=G;this._fileFilter=_3(G.fileFilter),this._directoryFilter=_3(G.directoryFilter);let X=G.lstat?I3:k5;if(r5)this._stat=(z)=>X(z,{bigint:!0});else this._stat=X;this._maxDepth=G.depth??b2.depth,this._wantsDir=Z?n5.has(Z):!1,this._wantsFile=Z?s5.has(Z):!1,this._wantsEverything=Z===o.EVERYTHING_TYPE,this._root=q3(J),this._isDirent=!G.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(J,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let G=this.parent,J=G&&G.files;if(J&&J.length>0){let{path:Z,depth:X}=G,z=J.splice(0,$).map((Q)=>this._formatEntry(Q,Z)),N=await Promise.all(z);for(let Q of N){if(!Q)continue;if(this.destroyed)return;let Y=await this._getEntryType(Q);if(Y==="directory"&&this._directoryFilter(Q)){if(X<=this._maxDepth)this.parents.push(this._exploreDir(Q.fullPath,X+1));if(this._wantsDir)this.push(Q),$--}else if((Y==="file"||this._includeAsFile(Q))&&this._fileFilter(Q)){if(this._wantsFile)this.push(Q),$--}}}else{let Z=this.parents.pop();if(!Z){this.push(null);break}if(this.parent=await Z,this.destroyed)return}}}catch(G){this.destroy(G)}finally{this.reading=!1}}async _exploreDir($,G){let J;try{J=await h5($,this._rdOptions)}catch(Z){this._onError(Z)}return{files:J,depth:G,path:$}}async _formatEntry($,G){let J,Z=this._isDirent?$.name:$;try{let X=q3(c5(G,Z));J={path:d5(this._root,X),fullPath:X,basename:Z},J[this._statsProp]=this._isDirent?$:await this._stat(X)}catch(X){this._onError(X);return}return J}_onError($){if(o5($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let G=$[this._statsProp];if(G.isFile())return"file";if(G.isDirectory())return"directory";if(G&&G.isSymbolicLink()){let J=$.fullPath;try{let Z=await m5(J),X=await I3(Z);if(X.isFile())return"file";if(X.isDirectory()){let z=Z.length;if(J.startsWith(Z)&&J.substr(z,1)===p5){let N=Error(`Circular symlink detected: "${J}" points to "${Z}"`);return N.code=j3,this._onError(N)}return"directory"}}catch(Z){return this._onError(Z),""}}}_includeAsFile($){let G=$&&$[this._statsProp];return G&&this._wantsEverything&&!G.isDirectory()}}function V3($,G={}){let J=G.entryType||G.type;if(J==="both")J=o.FILE_DIR_TYPE;if(J)G.type=J;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(J&&!B3.includes(J))throw Error(`readdirp: Invalid type passed. Use one of ${B3.join(", ")}`);return G.root=$,new R3(G)}import{watchFile as a5,unwatchFile as M3,watch as t5}from"fs";import{open as e5,stat as x3,lstat as $6,realpath as u2}from"fs/promises";import*as f from"path";import{type as G6}from"os";var J6="data",m2="end",W3="close",b0=()=>{};var u0=process.platform,l2=u0==="win32",Z6=u0==="darwin",X6=u0==="linux",z6=u0==="freebsd",L3=G6()==="OS400",y={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},X1=y,Q6="watch",N6={lstat:$6,stat:x3},P1="listeners",v0="errHandlers",b1="rawEmitters",Y6=[P1,v0,b1],K6=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"]),H6=($)=>K6.has(f.extname($).slice(1).toLowerCase()),h2=($,G)=>{if($ instanceof Set)$.forEach(G);else G($)},$0=($,G,J)=>{let Z=$[G];if(!(Z instanceof Set))$[G]=Z=new Set([Z]);Z.add(J)},I6=($)=>(G)=>{let J=$[G];if(J instanceof Set)J.clear();else delete $[G]},G0=($,G,J)=>{let Z=$[G];if(Z instanceof Set)Z.delete(J);else if(Z===J)delete $[G]},A3=($)=>$ instanceof Set?$.size===0:!$,g0=new Map;function T3($,G,J,Z,X){let z=(N,Q)=>{if(J($),X(N,Q,{watchedPath:$}),Q&&$!==Q)f0(f.resolve($,Q),P1,f.join($,Q))};try{return t5($,{persistent:G.persistent},z)}catch(N){Z(N);return}}var f0=($,G,J,Z,X)=>{let z=g0.get($);if(!z)return;h2(z[G],(N)=>{N(J,Z,X)})},q6=($,G,J,Z)=>{let{listener:X,errHandler:z,rawEmitter:N}=Z,Q=g0.get(G),Y;if(!J.persistent){if(Y=T3($,J,X,z,N),!Y)return;return Y.close.bind(Y)}if(Q)$0(Q,P1,X),$0(Q,v0,z),$0(Q,b1,N);else{if(Y=T3($,J,f0.bind(null,G,P1),z,f0.bind(null,G,b1)),!Y)return;Y.on(X1.ERROR,async(K)=>{let I=f0.bind(null,G,v0);if(Q)Q.watcherUnusable=!0;if(l2&&K.code==="EPERM")try{await(await e5($,"r")).close(),I(K)}catch(H){}else I(K)}),Q={listeners:X,errHandlers:z,rawEmitters:N,watcher:Y},g0.set(G,Q)}return()=>{if(G0(Q,P1,X),G0(Q,v0,z),G0(Q,b1,N),A3(Q.listeners))Q.watcher.close(),g0.delete(G),Y6.forEach(I6(Q)),Q.watcher=void 0,Object.freeze(Q)}},k2=new Map,B6=($,G,J,Z)=>{let{listener:X,rawEmitter:z}=Z,N=k2.get(G),Q=N&&N.options;if(Q&&(Q.persistent<J.persistent||Q.interval>J.interval))M3(G),N=void 0;if(N)$0(N,P1,X),$0(N,b1,z);else N={listeners:X,rawEmitters:z,options:J,watcher:a5(G,J,(Y,K)=>{h2(N.rawEmitters,(H)=>{H(X1.CHANGE,G,{curr:Y,prev:K})});let I=Y.mtimeMs;if(Y.size!==K.size||I>K.mtimeMs||I===0)h2(N.listeners,(H)=>H($,Y))})},k2.set(G,N);return()=>{if(G0(N,P1,X),G0(N,b1,z),A3(N.listeners))k2.delete(G),M3(G),N.options=N.watcher=void 0,Object.freeze(N)}};class d2{constructor($){this.fsw=$,this._boundHandleError=(G)=>$._handleError(G)}_watchWithNodeFs($,G){let J=this.fsw.options,Z=f.dirname($),X=f.basename($);this.fsw._getWatchedDir(Z).add(X);let N=f.resolve($),Q={persistent:J.persistent};if(!G)G=b0;let Y;if(J.usePolling){let K=J.interval!==J.binaryInterval;Q.interval=K&&H6(X)?J.binaryInterval:J.interval,Y=B6($,N,Q,{listener:G,rawEmitter:this.fsw._emitRaw})}else Y=q6($,N,Q,{listener:G,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return Y}_handleFile($,G,J){if(this.fsw.closed)return;let Z=f.dirname($),X=f.basename($),z=this.fsw._getWatchedDir(Z),N=G;if(z.has(X))return;let Q=async(K,I)=>{if(!this.fsw._throttle(Q6,$,5))return;if(!I||I.mtimeMs===0)try{let H=await x3($);if(this.fsw.closed)return;let{atimeMs:U,mtimeMs:_}=H;if(!U||U<=_||_!==N.mtimeMs)this.fsw._emit(X1.CHANGE,$,H);if((Z6||X6||z6)&&N.ino!==H.ino){this.fsw._closeFile(K),N=H;let q=this._watchWithNodeFs($,Q);if(q)this.fsw._addPathCloser(K,q)}else N=H}catch(H){this.fsw._remove(Z,X)}else if(z.has(X)){let{atimeMs:H,mtimeMs:U}=I;if(!H||H<=U||U!==N.mtimeMs)this.fsw._emit(X1.CHANGE,$,I);N=I}},Y=this._watchWithNodeFs($,Q);if(!(J&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(X1.ADD,$,0))return;this.fsw._emit(X1.ADD,$,G)}return Y}async _handleSymlink($,G,J,Z){if(this.fsw.closed)return;let X=$.fullPath,z=this.fsw._getWatchedDir(G);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let N;try{N=await u2(J)}catch(Q){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(z.has(Z)){if(this.fsw._symlinkPaths.get(X)!==N)this.fsw._symlinkPaths.set(X,N),this.fsw._emit(X1.CHANGE,J,$.stats)}else z.add(Z),this.fsw._symlinkPaths.set(X,N),this.fsw._emit(X1.ADD,J,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(X))return!0;this.fsw._symlinkPaths.set(X,!0)}_handleRead($,G,J,Z,X,z,N){if($=f.join($,""),N=this.fsw._throttle("readdir",$,1000),!N)return;let Q=this.fsw._getWatchedDir(J.path),Y=new Set,K=this.fsw._readdirp($,{fileFilter:(I)=>J.filterPath(I),directoryFilter:(I)=>J.filterDir(I)});if(!K)return;return K.on(J6,async(I)=>{if(this.fsw.closed){K=void 0;return}let H=I.path,U=f.join($,H);if(Y.add(H),I.stats.isSymbolicLink()&&await this._handleSymlink(I,$,U,H))return;if(this.fsw.closed){K=void 0;return}if(H===Z||!Z&&!Q.has(H))this.fsw._incrReadyCount(),U=f.join(X,f.relative(X,U)),this._addToNodeFs(U,G,J,z+1)}).on(X1.ERROR,this._boundHandleError),new Promise((I,H)=>{if(!K)return H();K.once(m2,()=>{if(this.fsw.closed){K=void 0;return}let U=N?N.clear():!1;if(I(void 0),Q.getChildren().filter((_)=>{return _!==$&&!Y.has(_)}).forEach((_)=>{this.fsw._remove($,_)}),K=void 0,U)this._handleRead($,!1,J,Z,X,z,N)})})}async _handleDir($,G,J,Z,X,z,N){let Q=this.fsw._getWatchedDir(f.dirname($)),Y=Q.has(f.basename($));if(!(J&&this.fsw.options.ignoreInitial)&&!X&&!Y)this.fsw._emit(X1.ADD_DIR,$,G);Q.add(f.basename($)),this.fsw._getWatchedDir($);let K,I,H=this.fsw.options.depth;if((H==null||Z<=H)&&!this.fsw._symlinkPaths.has(N)){if(!X){if(await this._handleRead($,J,z,X,$,Z,K),this.fsw.closed)return}I=this._watchWithNodeFs($,(U,_)=>{if(_&&_.mtimeMs===0)return;this._handleRead(U,!1,z,X,$,Z,K)})}return I}async _addToNodeFs($,G,J,Z,X){let z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return z(),!1;let N=this.fsw._getWatchHelpers($);if(J)N.filterPath=(Q)=>J.filterPath(Q),N.filterDir=(Q)=>J.filterDir(Q);try{let Q=await N6[N.statMethod](N.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(N.watchPath,Q))return z(),!1;let Y=this.fsw.options.followSymlinks,K;if(Q.isDirectory()){let I=f.resolve($),H=Y?await u2($):$;if(this.fsw.closed)return;if(K=await this._handleDir(N.watchPath,Q,G,Z,X,N,H),this.fsw.closed)return;if(I!==H&&H!==void 0)this.fsw._symlinkPaths.set(I,H)}else if(Q.isSymbolicLink()){let I=Y?await u2($):$;if(this.fsw.closed)return;let H=f.dirname(N.watchPath);if(this.fsw._getWatchedDir(H).add(N.watchPath),this.fsw._emit(X1.ADD,N.watchPath,Q),K=await this._handleDir(H,Q,G,Z,$,N,I),this.fsw.closed)return;if(I!==void 0)this.fsw._symlinkPaths.set(f.resolve($),I)}else K=this._handleFile(N.watchPath,Q,G);if(z(),K)this.fsw._addPathCloser($,K);return!1}catch(Q){if(this.fsw._handleError(Q))return z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var c2="/",V6="//",E3=".",M6="..",T6="string",x6=/\\/g,D3=/\/\//,W6=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,L6=/^\.[/\\]/;function k0($){return Array.isArray($)?$:[$]}var p2=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function A6($){if(typeof $==="function")return $;if(typeof $==="string")return(G)=>$===G;if($ instanceof RegExp)return(G)=>$.test(G);if(typeof $==="object"&&$!==null)return(G)=>{if($.path===G)return!0;if($.recursive){let J=O.relative($.path,G);if(!J)return!1;return!J.startsWith("..")&&!O.isAbsolute(J)}return!1};return()=>!1}function D6($){if(typeof $!=="string")throw Error("string expected");$=O.normalize($),$=$.replace(/\\/g,"/");let G=!1;if($.startsWith("//"))G=!0;let J=/\/\//;while($.match(J))$=$.replace(J,"/");if(G)$="/"+$;return $}function C3($,G,J){let Z=D6(G);for(let X=0;X<$.length;X++){let z=$[X];if(z(Z,J))return!0}return!1}function C6($,G){if($==null)throw TypeError("anymatch: specify first argument");let Z=k0($).map((X)=>A6(X));if(G==null)return(X,z)=>{return C3(Z,X,z)};return C3(Z,G)}var O3=($)=>{let G=k0($).flat();if(!G.every((J)=>typeof J===T6))throw TypeError(`Non-string provided as watch path: ${G}`);return G.map(S3)},F3=($)=>{let G=$.replace(x6,c2),J=!1;if(G.startsWith(V6))J=!0;while(G.match(D3))G=G.replace(D3,c2);if(J)G=c2+G;return G},S3=($)=>F3(O.normalize(F3($))),P3=($="")=>(G)=>{if(typeof G==="string")return S3(O.isAbsolute(G)?G:O.join($,G));else return G},O6=($,G)=>{if(O.isAbsolute($))return $;return O.join(G,$)},F6=Object.freeze(new Set);class w3{constructor($,G){this.path=$,this._removeWatcher=G,this.items=new Set}add($){let{items:G}=this;if(!G)return;if($!==E3&&$!==M6)G.add($)}async remove($){let{items:G}=this;if(!G)return;if(G.delete($),G.size>0)return;let J=this.path;try{await j6(J)}catch(Z){if(this._removeWatcher)this._removeWatcher(O.dirname(J),O.basename(J))}}has($){let{items:G}=this;if(!G)return;return G.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=b0,this.items=F6,Object.freeze(this)}}var P6="stat",E6="lstat";class y3{constructor($,G,J){this.fsw=J;let Z=$;this.path=$=$.replace(L6,""),this.watchPath=Z,this.fullWatchPath=O.resolve(Z),this.dirParts=[],this.dirParts.forEach((X)=>{if(X.length>1)X.pop()}),this.followSymlinks=G,this.statMethod=G?P6:E6}entryPath($){return O.join(this.watchPath,O.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:G}=$;if(G&&G.isSymbolicLink())return this.filterDir($);let J=this.entryPath($);return this.fsw._isntIgnored(J,G)&&this.fsw._hasReadPermissions(G)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class v3 extends R6{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 G=$.awaitWriteFinish,J={stabilityThreshold:2000,pollInterval:100},Z={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?k0($.ignored):k0([]),awaitWriteFinish:G===!0?J:typeof G==="object"?{...J,...G}:!1};if(L3)Z.usePolling=!0;if(Z.atomic===void 0)Z.atomic=!Z.usePolling;let X=process.env.CHOKIDAR_USEPOLLING;if(X!==void 0){let Q=X.toLowerCase();if(Q==="false"||Q==="0")Z.usePolling=!1;else if(Q==="true"||Q==="1")Z.usePolling=!0;else Z.usePolling=!!Q}let z=process.env.CHOKIDAR_INTERVAL;if(z)Z.interval=Number.parseInt(z,10);let N=0;this._emitReady=()=>{if(N++,N>=this._readyCount)this._emitReady=b0,this._readyEmitted=!0,process.nextTick(()=>this.emit(y.READY))},this._emitRaw=(...Q)=>this.emit(y.RAW,...Q),this._boundRemove=this._remove.bind(this),this.options=Z,this._nodeFsHandler=new d2(this),Object.freeze(Z)}_addIgnoredPath($){if(p2($)){for(let G of this._ignoredPaths)if(p2(G)&&G.path===$.path&&G.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let G of this._ignoredPaths)if(p2(G)&&G.path===$)this._ignoredPaths.delete(G)}}add($,G,J){let{cwd:Z}=this.options;this.closed=!1,this._closePromise=void 0;let X=O3($);if(Z)X=X.map((z)=>{return O6(z,Z)});if(X.forEach((z)=>{this._removeIgnoredPath(z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=X.length,Promise.all(X.map(async(z)=>{let N=await this._nodeFsHandler._addToNodeFs(z,!J,void 0,0,G);if(N)this._emitReady();return N})).then((z)=>{if(this.closed)return;z.forEach((N)=>{if(N)this.add(O.dirname(N),O.basename(G||N))})}),this}unwatch($){if(this.closed)return this;let G=O3($),{cwd:J}=this.options;return G.forEach((Z)=>{if(!O.isAbsolute(Z)&&!this._closers.has(Z)){if(J)Z=O.join(J,Z);Z=O.resolve(Z)}if(this._closePath(Z),this._addIgnoredPath(Z),this._watched.has(Z))this._addIgnoredPath({path:Z,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((G)=>G.forEach((J)=>{let Z=J();if(Z instanceof Promise)$.push(Z)})),this._streams.forEach((G)=>G.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((G)=>G.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((G,J)=>{let X=(this.options.cwd?O.relative(this.options.cwd,J):J)||E3;$[X]=G.getChildren().sort()}),$}emitWithAll($,G){if(this.emit($,...G),$!==y.ERROR)this.emit(y.ALL,$,...G)}async _emit($,G,J){if(this.closed)return;let Z=this.options;if(l2)G=O.normalize(G);if(Z.cwd)G=O.relative(Z.cwd,G);let X=[G];if(J!=null)X.push(J);let z=Z.awaitWriteFinish,N;if(z&&(N=this._pendingWrites.get(G)))return N.lastChange=new Date,this;if(Z.atomic){if($===y.UNLINK)return this._pendingUnlinks.set(G,[$,...X]),setTimeout(()=>{this._pendingUnlinks.forEach((Q,Y)=>{this.emit(...Q),this.emit(y.ALL,...Q),this._pendingUnlinks.delete(Y)})},typeof Z.atomic==="number"?Z.atomic:100),this;if($===y.ADD&&this._pendingUnlinks.has(G))$=y.CHANGE,this._pendingUnlinks.delete(G)}if(z&&($===y.ADD||$===y.CHANGE)&&this._readyEmitted){let Q=(Y,K)=>{if(Y)$=y.ERROR,X[0]=Y,this.emitWithAll($,X);else if(K){if(X.length>1)X[1]=K;else X.push(K);this.emitWithAll($,X)}};return this._awaitWriteFinish(G,z.stabilityThreshold,$,Q),this}if($===y.CHANGE){if(!this._throttle(y.CHANGE,G,50))return this}if(Z.alwaysStat&&J===void 0&&($===y.ADD||$===y.ADD_DIR||$===y.CHANGE)){let Q=Z.cwd?O.join(Z.cwd,G):G,Y;try{Y=await _6(Q)}catch(K){}if(!Y||this.closed)return;X.push(Y)}return this.emitWithAll($,X),this}_handleError($){let G=$&&$.code;if($&&G!=="ENOENT"&&G!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||G!=="EPERM"&&G!=="EACCES"))this.emit(y.ERROR,$);return $||this.closed}_throttle($,G,J){if(!this._throttled.has($))this._throttled.set($,new Map);let Z=this._throttled.get($);if(!Z)throw Error("invalid throttle");let X=Z.get(G);if(X)return X.count++,!1;let z,N=()=>{let Y=Z.get(G),K=Y?Y.count:0;if(Z.delete(G),clearTimeout(z),Y)clearTimeout(Y.timeoutObject);return K};z=setTimeout(N,J);let Q={timeoutObject:z,clear:N,count:0};return Z.set(G,Q),Q}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,G,J,Z){let X=this.options.awaitWriteFinish;if(typeof X!=="object")return;let z=X.pollInterval,N,Q=$;if(this.options.cwd&&!O.isAbsolute($))Q=O.join(this.options.cwd,$);let Y=new Date,K=this._pendingWrites;function I(H){U6(Q,(U,_)=>{if(U||!K.has($)){if(U&&U.code!=="ENOENT")Z(U);return}let q=Number(new Date);if(H&&_.size!==H.size)K.get($).lastChange=q;let B=K.get($);if(q-B.lastChange>=G)K.delete($),Z(void 0,_);else N=setTimeout(I,z,_)})}if(!K.has($))K.set($,{lastChange:Y,cancelWait:()=>{return K.delete($),clearTimeout(N),J}}),N=setTimeout(I,z)}_isIgnored($,G){if(this.options.atomic&&W6.test($))return!0;if(!this._userIgnored){let{cwd:J}=this.options,X=(this.options.ignored||[]).map(P3(J)),N=[...[...this._ignoredPaths].map(P3(J)),...X];this._userIgnored=C6(N,void 0)}return this._userIgnored($,G)}_isntIgnored($,G){return!this._isIgnored($,G)}_getWatchHelpers($){return new y3($,this.options.followSymlinks,this)}_getWatchedDir($){let G=O.resolve($);if(!this._watched.has(G))this._watched.set(G,new w3(G,this._boundRemove));return this._watched.get(G)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,G,J){let Z=O.join($,G),X=O.resolve(Z);if(J=J!=null?J:this._watched.has(Z)||this._watched.has(X),!this._throttle("remove",Z,100))return;if(!J&&this._watched.size===1)this.add($,G,!0);this._getWatchedDir(Z).getChildren().forEach((H)=>this._remove(Z,H));let Q=this._getWatchedDir($),Y=Q.has(G);if(Q.remove(G),this._symlinkPaths.has(X))this._symlinkPaths.delete(X);let K=Z;if(this.options.cwd)K=O.relative(this.options.cwd,Z);if(this.options.awaitWriteFinish&&this._pendingWrites.has(K)){if(this._pendingWrites.get(K).cancelWait()===y.ADD)return}this._watched.delete(Z),this._watched.delete(X);let I=J?y.UNLINK_DIR:y.UNLINK;if(Y&&!this._isIgnored(Z))this._emit(I,Z);this._closePath(Z)}_closePath($){this._closeFile($);let G=O.dirname($);this._getWatchedDir(G).remove(O.basename($))}_closeFile($){let G=this._closers.get($);if(!G)return;G.forEach((J)=>J()),this._closers.delete($)}_addPathCloser($,G){if(!G)return;let J=this._closers.get($);if(!J)J=[],this._closers.set($,J);J.push(G)}_readdirp($,G){if(this.closed)return;let J={type:y.ALL,alwaysStat:!0,lstat:!0,...G,depth:0},Z=V3($,J);return this._streams.add(Z),Z.once(W3,()=>{Z=void 0}),Z.once(m2,()=>{if(Z)this._streams.delete(Z),Z=void 0}),Z}}function h0($,G={}){let J=new v3(G);return J.add($),J}import{createServer as e8}from"node:http";import{readFileSync as $7,existsSync as G7,readdirSync as H0,statSync as H4,mkdirSync as J7}from"node:fs";import{join as Q1,basename as u9}from"node:path";var r8=s(P9(),1),a8=s(a2(),1),t8=s(e2(),1),Q4=s(a0(),1),N4=s(f9(),1);var e0=s(f1(),1),b9=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT):9847;function Z7(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return Q1($,".serena","memories");return Q1(process.cwd(),".serena","memories")}function I0($){try{return $7($,"utf-8")}catch{return""}}function X7($){try{let G=H0($);if(G.includes("orchestrator-session.md"))return Q1($,"orchestrator-session.md");let J=G.filter((Z)=>/^session-.*\.md$/.test(Z)).map((Z)=>({name:Z,mtime:H4(Q1($,Z)).mtimeMs})).sort((Z,X)=>X.mtime-Z.mtime);if(J.length>0)return Q1($,J[0].name)}catch{}return null}function z7($){let G=X7($);if(!G)return{id:"N/A",status:"UNKNOWN"};let J=I0(G);if(!J)return{id:"N/A",status:"UNKNOWN"};let Z=(J.match(/session-id:\s*(.+)/i)||[])[1]||(J.match(/# Session:\s*(.+)/i)||[])[1]||J.match(/(session-\d{8}-\d{6})/)?.[1]||u9(G,".md")||"N/A",X="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(J))X="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(J))X="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(J))X="FAILED";else if(/Step \d+:.*\[/i.test(J))X="RUNNING";return{id:Z.trim(),status:X}}function Q7($){let G=I0(Q1($,"task-board.md"));if(!G)return[];let J=[],Z=G.split(`
115
- `);for(let X of Z){if(!X.startsWith("|")||/^\|\s*-+/.test(X))continue;let z=X.split("|").map((N)=>N.trim()).filter(Boolean);if(z.length<2||/^agent$/i.test(z[0]))continue;J.push({agent:z[0]||"",status:z[1]||"pending",task:z[2]||""})}return J}function K4($,G){try{let J=H0($).filter((z)=>z.startsWith(`progress-${G}`)&&z.endsWith(".md")).sort().reverse();if(J.length===0)return null;let X=I0(Q1($,J[0])).match(/turn[:\s]*(\d+)/i);return X?parseInt(X[1],10):null}catch{return null}}function N7($){try{return H0($).filter((J)=>J.endsWith(".md")&&J!==".gitkeep").map((J)=>({name:J,mtime:H4(Q1($,J)).mtimeMs})).sort((J,Z)=>Z.mtime-J.mtime).slice(0,10).map((J)=>{let Z=J.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||J.name.replace(/\.md$/,""),z=I0(Q1($,J.name)).split(`
116
- `).map((Q)=>Q.trim()).filter((Q)=>Q&&!Q.startsWith("---")&&Q.length>3),N="";for(let Q=z.length-1;Q>=0;Q--){let Y=z[Q];if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(Y)){if(N=Y.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),N.length>5)break}}if(N.length>80)N=N.substring(0,77)+"...";return{agent:Z,message:N,file:J.name}}).filter((J)=>J.message)}catch{return[]}}function Y7($){let G=[],J=new Set;try{let Z=H0($).filter((X)=>X.endsWith(".md")&&X!==".gitkeep").map((X)=>({name:X,mtime:H4(Q1($,X)).mtimeMs})).sort((X,z)=>z.mtime-X.mtime);for(let X of Z){let z=I0(Q1($,X.name)),N=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(N)Q=N[1].trim();else if(/_agent|agent_|-agent/i.test(X.name))Q=X.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!J.has(Q.toLowerCase())){J.add(Q.toLowerCase());let Y="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))Y="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))Y="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))Y="failed";let K=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),I=K?K[1].trim().substring(0,60):"";G.push({agent:Q,status:Y,task:I,turn:K4($,Q)})}}}catch{}return G}function Y4($){let G=z7($),Z=Q7($).map((X)=>({...X,turn:K4($,X.agent)}));if(Z.length===0)Z=Y7($);if(Z.length===0)try{let X=H0($).filter((z)=>z.startsWith("progress-")&&z.endsWith(".md"));for(let z of X){let N=z.replace(/^progress-/,"").replace(/\.md$/,"");Z.push({agent:N,status:"running",task:"",turn:K4($,N)})}}catch{}return{session:G,agents:Z,activity:N7($),memoriesDir:$,updatedAt:new Date().toISOString()}}var K7=`<!DOCTYPE html>
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 J of G){if(!J.startsWith("|")||/^\|\s*-+/.test(J))continue;let Z=J.split("|").map((z)=>z.trim()).filter(Boolean);if(Z.length<2||/^agent$/i.test(Z[0]))continue;N.push({agent:Z[0]||"",status:Z[1]||"pending",task:Z[2]||""})}return N}function t$($,I){try{let N=Q0($).filter((Z)=>Z.startsWith(`progress-${I}`)&&Z.endsWith(".md")).sort().reverse();if(N.length===0)return null;let J=X0(z1($,N[0])).match(/turn[:\s]*(\d+)/i);return J?parseInt(J[1],10):null}catch{return null}}function xI($){try{return Q0($).filter((N)=>N.endsWith(".md")&&N!==".gitkeep").map((N)=>({name:N,mtime:e$(z1($,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=X0(z1($,N.name)).split(`
31
+ `).map((x)=>x.trim()).filter((x)=>x&&!x.startsWith("---")&&x.length>3),z="";for(let x=Z.length-1;x>=0;x--){let Q=Z[x];if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(Q)){if(z=Q.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),z.length>5)break}}if(z.length>80)z=z.substring(0,77)+"...";return{agent:G,message:z,file:N.name}}).filter((N)=>N.message)}catch{return[]}}function zI($){let I=[],N=new Set;try{let G=Q0($).filter((J)=>J.endsWith(".md")&&J!==".gitkeep").map((J)=>({name:J,mtime:e$(z1($,J)).mtimeMs})).sort((J,Z)=>Z.mtime-J.mtime);for(let J of G){let Z=X0(z1($,J.name)),z=Z.match(/\*\*Agent\*\*:\s*(.+)/i)||Z.match(/Agent:\s*(.+)/i)||Z.match(/^#+\s*(.+?)\s*Agent/im),x=null;if(z)x=z[1].trim();else if(/_agent|agent_|-agent/i.test(J.name))x=J.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(x&&!N.has(x.toLowerCase())){N.add(x.toLowerCase());let Q="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(Z))Q="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(Z))Q="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(Z))Q="failed";let X=Z.match(/## Task\s*\n+(.+)/i)||Z.match(/\*\*Task\*\*:\s*(.+)/i),j=X?X[1].trim().substring(0,60):"";I.push({agent:x,status:Q,task:j,turn:t$($,x)})}}}catch{}return I}function a$($){let I=JI($),G=ZI($).map((J)=>({...J,turn:t$($,J.agent)}));if(G.length===0)G=zI($);if(G.length===0)try{let J=Q0($).filter((Z)=>Z.startsWith("progress-")&&Z.endsWith(".md"));for(let Z of J){let z=Z.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:z,status:"running",task:"",turn:t$($,z)})}}catch{}return{session:I,agents:G,activity:xI($),memoriesDir:$,updatedAt:new Date().toISOString()}}var QI=`<!DOCTYPE html>
117
32
  <html lang="en">
118
33
  <head>
119
34
  <meta charset="UTF-8">
@@ -170,36 +85,125 @@ ${Q}
170
85
  fetch('/api/state').then(r=>r.json()).then(renderState).catch(()=>{});connect();
171
86
  </script>
172
87
  </body>
173
- </html>`;function k9(){let $=Z7();if(!G7($))J7($,{recursive:!0});let G=e8((N,Q)=>{if(N.url==="/api/state")Q.writeHead(200,{"Content-Type":"application/json"}),Q.end(JSON.stringify(Y4($)));else Q.writeHead(200,{"Content-Type":"text/html"}),Q.end(K7)}),J=new N4.default({server:G}),Z=null;function X(N,Q){if(Z)clearTimeout(Z);Z=setTimeout(()=>{let Y=JSON.stringify({type:"update",event:N,file:Q,data:Y4($)});J.clients.forEach((K)=>{if(K.readyState===Q4.default.OPEN)K.send(Y)})},100)}let z=h0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});z.on("all",(N,Q)=>X(N,u9(Q))),J.on("connection",(N)=>{N.send(JSON.stringify({type:"full",data:Y4($)})),N.on("error",()=>N.terminate())}),process.on("SIGINT",()=>{console.log(`
174
- Shutting down...`),z.close(),J.clients.forEach((N)=>N.terminate()),J.close(()=>G.close(()=>process.exit(0))),setTimeout(()=>process.exit(1),3000).unref()}),process.on("SIGTERM",()=>process.emit("SIGINT")),G.listen(b9,()=>{console.log(e0.default.magenta(`
175
- \uD83D\uDEF8 Serena Memory Dashboard`)),console.log(e0.default.white(` http://localhost:${b9}`)),console.log(e0.default.dim(` Watching: ${$}
176
- `))})}var c=s(f1(),1);import{readFileSync as H7,existsSync as I7,readdirSync as q0,statSync as q4,mkdirSync as q7}from"node:fs";import{join as N1,basename as B7}from"node:path";var U7="●",_7="✓",j7="✗",R7="○",V7="◌";function M7(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return N1($,".serena","memories");return N1(process.cwd(),".serena","memories")}function B0($){try{return H7($,"utf-8")}catch{return""}}function T7($){try{let G=q0($);if(G.includes("orchestrator-session.md"))return N1($,"orchestrator-session.md");let J=G.filter((Z)=>/^session-.*\.md$/.test(Z)).map((Z)=>({name:Z,mtime:q4(N1($,Z)).mtimeMs})).sort((Z,X)=>X.mtime-Z.mtime);if(J.length>0&&J[0])return N1($,J[0].name)}catch{}return null}function x7($){let G=T7($);if(!G)return{id:"N/A",status:"UNKNOWN"};let J=B0(G);if(!J)return{id:"N/A",status:"UNKNOWN"};let Z=(J.match(/session-id:\s*(.+)/i)||[])[1]||(J.match(/# Session:\s*(.+)/i)||[])[1]||J.match(/(session-\d{8}-\d{6})/)?.[1]||B7(G,".md"),X="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(J))X="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(J))X="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(J))X="FAILED";else if(/Step \d+:.*\[/i.test(J))X="RUNNING";return{id:(Z||"N/A").trim(),status:X}}function W7($){let G=B0(N1($,"task-board.md"));if(!G)return[];let J=[],Z=G.split(`
177
- `);for(let X of Z){if(!X.startsWith("|")||/^\|\s*-+/.test(X))continue;let z=X.split("|").map((K)=>K.trim()).filter(Boolean),N=z[0];if(z.length<2||!N||/^agent$/i.test(N))continue;let Q=z[1],Y=z[2];J.push({agent:N,status:Q||"pending",task:Y||""})}return J}function I4($,G){try{let J=q0($).filter((z)=>z.startsWith(`progress-${G}`)&&z.endsWith(".md")).sort().reverse();if(J.length===0||!J[0])return null;let X=B0(N1($,J[0])).match(/turn[:\s]*(\d+)/i);return X&&X[1]?parseInt(X[1],10):null}catch{return null}}function L7($){try{let G=q0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:q4(N1($,Z)).mtimeMs})).sort((Z,X)=>X.mtime-Z.mtime).slice(0,5),J=[];for(let Z of G){let X=Z.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||Z.name.replace(/\.md$/,""),N=B0(N1($,Z.name)).split(`
178
- `).map((Y)=>Y.trim()).filter((Y)=>Y&&!Y.startsWith("---")&&Y.length>3),Q="";for(let Y=N.length-1;Y>=0;Y--){let K=N[Y];if(!K)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(K)){if(Q=K.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),Q.length>5)break}}if(Q.length>52)Q=Q.substring(0,49)+"...";if(Q)J.push({agent:X,message:Q})}return J}catch{return[]}}function A7($){let G=[],J=new Set;try{let Z=q0($).filter((X)=>X.endsWith(".md")&&X!==".gitkeep").map((X)=>({name:X,mtime:q4(N1($,X)).mtimeMs})).sort((X,z)=>z.mtime-X.mtime);for(let X of Z){let z=B0(N1($,X.name)),N=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(N&&N[1])Q=N[1].trim();else if(/_agent|agent_|-agent/i.test(X.name))Q=X.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!J.has(Q.toLowerCase())){J.add(Q.toLowerCase());let Y="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))Y="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))Y="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))Y="failed";let K=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),I=K&&K[1]?K[1].trim().substring(0,20):"";G.push({agent:Q,status:Y,task:I,turn:I4($,Q)})}}}catch{}return G}function D7($){let G=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(G))return`${c.default.green(U7)} running`;else if(["completed","done","finished"].includes(G))return`${c.default.cyan(_7)} completed`;else if(["failed","error"].includes(G))return`${c.default.red(j7)} failed`;else if(["blocked","waiting"].includes(G))return`${c.default.yellow(R7)} blocked`;return`${c.default.dim(V7)} pending`}function h9($){console.clear();let G=x7($),Z=W7($).map((B)=>({...B,turn:I4($,B.agent)}));if(Z.length===0)Z=A7($);if(Z.length===0)try{let B=q0($).filter((M)=>M.startsWith("progress-")&&M.endsWith(".md"));for(let M of B){let V=M.replace(/^progress-/,"").replace(/\.md$/,"");Z.push({agent:V,status:"running",task:"",turn:I4($,V)})}}catch{}let X=56,z="═".repeat(X),N=(B)=>" ".repeat(Math.max(0,B)),Q=(B)=>c.default.magenta(B),Y=(B)=>c.default.bold(B),K=(B)=>c.default.dim(B),I=c.default.yellow;if(G.status==="RUNNING")I=c.default.green;else if(G.status==="COMPLETED")I=c.default.cyan;else if(G.status==="FAILED")I=c.default.red;console.log(`${Q("╔"+z+"╗")}`),console.log(`${Q("║")} ${Y(Q("Serena Memory Dashboard"))}${N(X-25)}${Q("║")}`);let H=`Session: ${Y(G.id.padEnd(20))} [${I(G.status)}]`;if(console.log(`${Q("║")} ${H}${N(X-4-H.length-9)}${Q("║")}`),console.log(`${Q("╠"+z+"╣")}`),console.log(`${Q("║")} ${Y("Agent".padEnd(12)+" "+"Status".padEnd(12)+" "+"Turn".padEnd(6)+" "+"Task".padEnd(20))} ${Q("║")}`),console.log(`${Q("║")} ${K("──────────".padEnd(12)+" "+"──────────".padEnd(12)+" "+"────".padEnd(6)+" "+"──────────────────".padEnd(20))} ${Q("║")}`),Z.length===0)console.log(`${Q("║")} ${K("No agents detected yet"+N(32))}${Q("║")}`);else for(let B of Z){let M=D7(B.status),V=B.turn!=null?String(B.turn):"-",x=B.task.substring(0,20);console.log(`${Q("║")} ${B.agent.padEnd(12)} ${M.padEnd(22)} ${V.padEnd(6)} ${x.padEnd(20)}${Q("║")}`)}console.log(`${Q("╠"+z+"╣")}`),console.log(`${Q("║")} ${Y("Latest Activity:")}${N(X-18)}${Q("║")}`);let U=L7($);if(U.length===0)console.log(`${Q("║")} ${K("No activity yet"+N(38))}${Q("║")}`);else for(let B of U){let M=`[${B.agent}] ${B.message}`;console.log(`${Q("║")} ${K(M.substring(0,52).padEnd(52))}${Q("║")}`)}console.log(`${Q("╠"+z+"╣")}`);let q=`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("║")} ${K(q)}${N(X-4-q.length)}${Q("║")}`),console.log(`${Q("╚"+z+"╝")}`)}function m9(){let $=M7();if(!I7($))q7($,{recursive:!0}),console.log(c.default.yellow(`Created ${$} — waiting for memory files...`));console.log(c.default.magenta(`
179
- \uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(c.default.dim(` Watching: ${$}
180
- `)),h9($);let G=h0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});G.on("all",()=>h9($)),process.on("SIGINT",()=>{console.log(`
181
- `),G.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var U4="first-fluke/oh-my-ag",_4=`https://raw.githubusercontent.com/${U4}/main/.agent/skills`,O7="1.1.1",i={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"}]},F7={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:[...i.domain,...i.coordination,...i.utility].map(($)=>$.name)};async function P7($){let G=["SKILL.md"],J=["resources/execution-protocol.md","resources/tech-stack.md","resources/checklist.md","resources/templates.md","resources/error-playbook.md"];for(let Z of J){let X=`${_4}/${$}/${Z}`;if((await fetch(X,{method:"HEAD"})).ok)G.push(Z)}return G}async function l9($,G){let J=S(G,".agent","skills",$),Z=await P7($);for(let X of Z){let z=`${_4}/${$}/${X}`,N=await fetch(z);if(!N.ok)continue;let Q=await N.text(),Y=S(J,X),K=G2(Y);if(!h(K))i1(K,{recursive:!0});g1(Y,Q,"utf-8")}return!0}async function d9($){let G=S($,".agent","skills","_shared"),J=["reasoning-templates.md","clarification-protocol.md","context-loading.md","skill-routing.md"];if(!h(G))i1(G,{recursive:!0});for(let Z of J){let X=`${_4}/_shared/${Z}`,z=await fetch(X);if(!z.ok)continue;let N=await z.text();g1(S(G,Z),N,"utf-8")}}function E7($){return C7("sha256").update($,"utf-8").digest("hex")}async function S7($){let G=S($,".agent","skills","_version.json");if(!h(G))return null;try{let J=v1(G,"utf-8");return JSON.parse(J).version||null}catch{return null}}async function w7($,G){let J=S($,".agent","skills","_version.json"),Z=G2(J);if(!h(Z))i1(Z,{recursive:!0});g1(J,JSON.stringify({version:G},null,2),"utf-8")}async function y7(){let $=`https://raw.githubusercontent.com/${U4}/main/prompt-manifest.json`,G=await fetch($);if(!G.ok)throw Error("Failed to fetch remote manifest");return await G.json()}async function v7($){let G=`https://raw.githubusercontent.com/${U4}/main/${$.path}`,J=await fetch(G);if(!J.ok)return{path:$.path,success:!1,error:`HTTP ${J.status}`};let Z=await J.text();if(E7(Z)!==$.sha256)return{path:$.path,success:!1,error:"SHA256 mismatch"};let z=S(process.cwd(),$.path),N=G2(z);if(!h(N))i1(N,{recursive:!0});return g1(z,Z,"utf-8"),{path:$.path,success:!0}}async function g7(){console.clear(),F1(R.default.bgMagenta(R.default.white(" \uD83D\uDEF8 oh-my-ag update ")));let $=process.cwd(),G=S0();try{G.start("Checking for updates...");let J=await y7(),Z=await S7($);if(Z===J.version){G.stop(R.default.green("Already up to date!")),$1(`Current version: ${R.default.cyan(Z)}`);return}G.message(`Updating from ${Z||"not installed"} to ${R.default.cyan(J.version)}...`);let X=await f2(J.files,async(Q)=>v7(Q),{concurrency:10}),z=X.filter((Q)=>!Q.success);if(z.length>0)G.stop("Update completed with errors"),g(z.map((Q)=>`${R.default.red("")} ${Q.path}: ${Q.error}`).join(`
182
- `),`${z.length} files failed`);else G.stop(`Updated to version ${R.default.cyan(J.version)}!`);await w7($,J.version);let N=X.length-z.length;$1(z.length>0?`${N} files updated, ${z.length} failed`:`${N} files updated successfully`)}catch(J){G.stop("Update failed"),Z1.error(J instanceof Error?J.message:String(J)),process.exit(1)}}async function $2($,G,J){try{let Z=m(`${G} --version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();return{name:$,installed:!0,version:Z,installCmd:J}}catch{return{name:$,installed:!1,installCmd:J}}}async function f7($){let G=process.env.HOME||process.env.USERPROFILE||"",Z={gemini:{path:`${G}/.gemini/settings.json`,type:"json"},claude:{path:`${G}/.claude.json`,type:"json"},codex:{path:`${G}/.codex/config.toml`,type:"toml"}}[$];if(!Z)return{configured:!1};if(h(Z.path))try{let X=v1(Z.path,"utf-8");if(Z.type==="json"){let z=JSON.parse(X);return{configured:!!(z.mcpServers||z.mcp),path:Z.path}}return{configured:!0,path:Z.path}}catch{return{configured:!1}}return{configured:!1}}async function b7(){let $=[];try{m("which fswatch",{stdio:"ignore"}),$.push({name:"fswatch",available:!0,type:"terminal"})}catch{$.push({name:"fswatch",available:!1,type:"terminal",installCmd:"brew install fswatch (macOS) or apt install inotify-tools (Linux)"})}let G=S(process.cwd(),"scripts","dashboard-web","server.js");if(h(G))try{let J=S(process.cwd(),"node_modules"),Z=h(S(J,"chokidar")),X=h(S(J,"ws"));if(Z&&X)$.push({name:"chokidar + ws",available:!0,type:"web"});else $.push({name:"chokidar + ws",available:!1,type:"web",installCmd:"npm install"})}catch{$.push({name:"chokidar + ws",available:!1,type:"web",installCmd:"npm install"})}return $}async function u7(){let $=S(process.cwd(),".agent","skills");if(!h($))return[];let G=[...i.domain,...i.coordination,...i.utility],J=[];for(let Z of G){let X=S($,Z.name),z=S(X,"SKILL.md");J.push({name:Z.name,installed:h(X),hasSkillMd:h(z)})}return J}async function k7($=!1){let G=process.cwd(),J=await Promise.all([$2("gemini","gemini","npm install -g @anthropic-ai/gemini-cli"),$2("claude","claude","npm install -g @anthropic-ai/claude-code"),$2("codex","codex","npm install -g @openai/codex"),$2("qwen","qwen","pip install qwen-cli")]),Z=await Promise.all(J.filter((_)=>_.installed).map(async(_)=>{let q=await f7(_.name);return{..._,mcp:q}})),X=await b7(),z=await u7(),N=S(G,".serena","memories"),Q=h(N),Y=0;if(Q)try{Y=p1(N).length}catch{}let K=J.filter((_)=>!_.installed),I=z.length>0?z.filter((_)=>!_.installed||!_.hasSkillMd):[...i.domain,...i.coordination,...i.utility].map((_)=>({name:_.name,installed:!1,hasSkillMd:!1})),H=K.length+Z.filter((_)=>!_.mcp.configured).length+X.filter((_)=>!_.available).length+I.length;if($){let _={ok:H===0,issues:H,clis:J.map((q)=>({name:q.name,installed:q.installed,version:q.version||null})),mcp:Z.map((q)=>({name:q.name,configured:q.mcp.configured,path:q.mcp.path||null})),dashboard:X.map((q)=>({name:q.name,available:q.available,type:q.type})),skills:z.length>0?z.map((q)=>({name:q.name,installed:q.installed,complete:q.hasSkillMd})):[],missingSkills:I.map((q)=>q.name),serena:{exists:Q,fileCount:Y}};console.log(JSON.stringify(_,null,2)),process.exit(H===0?0:1)}console.clear(),F1(R.default.bgMagenta(R.default.white(" \uD83E\uDE7A oh-my-ag doctor ")));let U=S0();try{let _=[R.default.bold("\uD83D\uDD0D CLI Installation Status"),"┌─────────┬──────────┬─────────────┐",`│ ${R.default.bold("CLI")} │ ${R.default.bold("Status")} │ ${R.default.bold("Version")} │`,"├─────────┼──────────┼─────────────┤",...J.map((V)=>{let x=V.installed?R.default.green("✅ Installed"):R.default.red("❌ Missing"),L=V.version||"-";return`│ ${V.name.padEnd(7)} │ ${x.padEnd(8)} │ ${L.padEnd(11)} │`}),"└─────────┴──────────┴─────────────┘"].join(`
183
- `);if(g(_,"CLI Status"),K.length>0)g(K.map((V)=>`${R.default.yellow("→")} ${V.name}: ${R.default.dim(V.installCmd)}`).join(`
184
- `),"Install missing CLIs");if(Z.length>0){let V=[R.default.bold("\uD83D\uDD17 MCP Connection Status"),"┌─────────┬──────────┬─────────────────────┐",`│ ${R.default.bold("CLI")} ${R.default.bold("MCP Config")} │ ${R.default.bold("Path")} │`,"├─────────┼──────────┼─────────────────────┤",...Z.map((x)=>{let L=x.mcp.configured?R.default.green("✅ Configured"):R.default.yellow("⚠️ Not configured"),D=x.mcp.path?x.mcp.path.split("/").pop()||"":"-";return`│ ${x.name.padEnd(7)} │ ${L.padEnd(8)} │ ${D.padEnd(19)} │`}),"└─────────┴──────────┴─────────────────────┘"].join(`
185
- `);g(V,"MCP Status")}let q=[R.default.bold("\uD83D\uDCCA Dashboard Dependencies"),"┌─────────────────┬──────────┬────────────────────────────────────┐",`│ ${R.default.bold("Dependency")} │ ${R.default.bold("Status")} │ ${R.default.bold("Install Command")} │`,"├─────────────────┼──────────┼────────────────────────────────────┤",...X.map((V)=>{let x=V.available?R.default.green("✅ Available"):R.default.red("❌ Missing"),L=V.installCmd||"-";return`│ ${V.name.padEnd(15)} │ ${x.padEnd(8)} │ ${L.padEnd(34)} │`}),"└─────────────────┴──────────┴────────────────────────────────────┘"].join(`
186
- `);g(q,"Dashboard Status");let B=z.filter((V)=>V.installed).length,M=z.filter((V)=>V.hasSkillMd).length;if(z.length>0){let V=[R.default.bold(`\uD83D\uDCE6 Skills (${B}/${z.length} installed, ${M} complete)`),"┌────────────────────┬──────────┬─────────────┐",`│ ${R.default.bold("Skill")} │ ${R.default.bold("Installed")} │ ${R.default.bold("SKILL.md")} │`,"├────────────────────┼──────────┼─────────────┤",...z.map((x)=>{let L=x.installed?R.default.green("✅"):R.default.red("❌"),D=x.hasSkillMd?R.default.green("✅"):R.default.red("❌");return`│ ${x.name.padEnd(18)} │ ${L.padEnd(8)} │ ${D.padEnd(11)} │`}),"└────────────────────┴──────────┴─────────────┘"].join(`
187
- `);g(V,"Skills Status")}else g(R.default.yellow("No skills installed."),"Skills Status");if(I.length>0){let V=await K3({message:`Found ${I.length} missing/incomplete skill(s). Install them?`,initialValue:!0});if(t(V))B1("Cancelled."),process.exit(0);if(V){let x=I.map((A)=>A.name),L=await w0({message:"Which skills to install?",options:[{value:"all",label:`✨ All (${x.length} skills)`,hint:"Recommended"},{value:"select",label:"\uD83D\uDD27 Select individually"}]});if(t(L))B1("Cancelled."),process.exit(0);let D;if(L==="select"){let A=[...i.domain,...i.coordination,...i.utility],F=await g2({message:"Select skills to install:",options:I.map((T)=>{let W=A.find((b)=>b.name===T.name);return{value:T.name,label:T.name,hint:W?.desc||""}}),required:!0});if(t(F))B1("Cancelled."),process.exit(0);D=F}else D=x;U.start("Installing skills...");try{await d9(G);for(let A of D)U.message(`Installing ${R.default.cyan(A)}...`),await l9(A,G);U.stop(`Installed ${D.length} skill(s)!`),g(D.map((A)=>`${R.default.green("✓")} ${A}`).join(`
188
- `),"Installed Skills")}catch(A){U.stop("Installation failed"),Z1.error(A instanceof Error?A.message:String(A))}}}if(Q)g(`${R.default.green("✅")} Serena memory directory exists
189
- ${R.default.dim(`${Y} memory files found`)}`,"Serena Memory");else g(`${R.default.yellow("⚠️")} Serena memory directory not found
190
- ${R.default.dim("Dashboard will show 'No agents detected'")}`,"Serena Memory");if(H===0)$1(R.default.green("✅ All checks passed! Ready to use."));else $1(R.default.yellow(`⚠️ Found ${H} issue(s). See details above.`))}catch(_){if(U)U.stop("Check failed");Z1.error(_ instanceof Error?_.message:String(_)),process.exit(1)}}function j4($){return S($,".serena","metrics.json")}function B4(){return{sessions:0,skillsUsed:{},tasksCompleted:0,totalSessionTime:0,filesChanged:0,linesAdded:0,linesRemoved:0,lastUpdated:new Date().toISOString(),startDate:new Date().toISOString()}}function h7($){let G=j4($);if(h(G))try{return JSON.parse(v1(G,"utf-8"))}catch{return B4()}return B4()}function m7($,G){let J=j4($),Z=G2(J);if(!h(Z))i1(Z,{recursive:!0});G.lastUpdated=new Date().toISOString(),g1(J,JSON.stringify(G,null,2),"utf-8")}function l7($){try{let J=m("git diff --stat HEAD~10 2>/dev/null || git diff --stat",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
191
- `),Z=J[J.length-1]||"",X=Z.match(/(\d+) files? changed/),z=Z.match(/(\d+) insertions?\(\+\)/),N=Z.match(/(\d+) deletions?\(-\)/);return{filesChanged:X?.[1]?parseInt(X[1],10):0,linesAdded:z?.[1]?parseInt(z[1],10):0,linesRemoved:N?.[1]?parseInt(N[1],10):0}}catch{return{filesChanged:0,linesAdded:0,linesRemoved:0}}}function d7($){let G=S($,".serena","memories"),J={};if(!h(G))return J;try{let Z=p1(G);for(let X of Z){let z=X.match(/(?:progress|result)-(\w+)/);if(z?.[1]){let N=z[1];J[N]=(J[N]||0)+1}}}catch{}return J}async function c7($=!1,G=!1){let J=process.cwd(),Z=j4(J);if(G){if(h(Z))g1(Z,JSON.stringify(B4(),null,2),"utf-8");if($)console.log(JSON.stringify({reset:!0}));else console.log(R.default.green("✅ Metrics reset successfully."));return}let X=h7(J),z=l7(J),N=d7(J);for(let[H,U]of Object.entries(N))X.skillsUsed[H]=(X.skillsUsed[H]||0)+U;X.filesChanged+=z.filesChanged,X.linesAdded+=z.linesAdded,X.linesRemoved+=z.linesRemoved,X.sessions+=1,m7(J,X);let Q=Math.max(1,Math.ceil((Date.now()-new Date(X.startDate).getTime())/86400000)),Y=X.sessions>0?Math.round(X.totalSessionTime/X.sessions):0;if($){console.log(JSON.stringify({...X,gitStats:z,daysSinceStart:Q,avgSessionTime:Y},null,2));return}console.clear(),F1(R.default.bgMagenta(R.default.white(" \uD83D\uDCCA oh-my-ag stats ")));let K=[R.default.bold(`\uD83D\uDCC8 Productivity Metrics (${Q} days)`),"┌─────────────────────┬──────────────┐",`│ ${R.default.bold("Metric")} │ ${R.default.bold("Value")} │`,"├─────────────────────┼──────────────┤",`│ Sessions │ ${String(X.sessions).padEnd(12)} │`,`│ Tasks Completed │ ${String(X.tasksCompleted).padEnd(12)} │`,`│ Files Changed │ ${String(X.filesChanged).padEnd(12)} │`,`│ Lines Added │ ${R.default.green("+"+X.linesAdded).padEnd(12)} │`,`│ Lines Removed │ ${R.default.red("-"+X.linesRemoved).padEnd(12)} │`,"└─────────────────────┴──────────────┘"].join(`
192
- `);g(K,"Overview");let I=Object.entries(X.skillsUsed).sort(([,H],[,U])=>U-H).slice(0,5);if(I.length>0){let H=[R.default.bold("\uD83C\uDFC6 Top Skills Used"),...I.map(([U,_],q)=>` ${q+1}. ${U} (${_})`)].join(`
193
- `);g(H,"Skills")}$1(R.default.dim(`Data stored in: ${Z}`))}function R4($){return S($,".serena","retrospectives")}function p7($){let G=R4($);if(!h(G))return[];try{return p1(G).filter((Z)=>Z.endsWith(".json")).sort().reverse().slice(0,10).map((Z)=>JSON.parse(v1(S(G,Z),"utf-8")))}catch{return[]}}function i7($,G){let J=R4($);if(!h(J))i1(J,{recursive:!0});let Z=`${G.date.replace(/[:.]/g,"-")}_${G.id}.json`;g1(S(J,Z),JSON.stringify(G,null,2),"utf-8")}function n7($,G=5){try{return m(`git log --oneline -${G} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
194
- `).filter(Boolean)}catch{return[]}}function s7($){try{return m("git diff --name-only HEAD~5 2>/dev/null || git diff --name-only",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
195
- `).filter(Boolean).slice(0,10)}catch{return[]}}async function o7($=!1){let G=process.cwd(),J=R4(G),Z=p7(G);if($){console.log(JSON.stringify({retrospectives:Z},null,2));return}console.clear(),F1(R.default.bgMagenta(R.default.white(" \uD83D\uDD04 oh-my-ag retro ")));let X=Z[0];if(X)g([R.default.bold("\uD83D\uDCC5 Last Retrospective"),`Date: ${X.date}`,"",R.default.bold("Summary:"),X.summary,"",R.default.bold("Key Learnings:"),...X.keyLearnings.map((U)=>` • ${U}`),"",R.default.bold("Next Steps:"),...X.nextSteps.map((U)=>` → ${U}`)].join(`
196
- `),"Previous Session");let z=await w0({message:"What would you like to do?",options:[{value:"new",label:"\uD83D\uDCDD Create new retrospective"},{value:"list",label:"\uD83D\uDCCB View past retrospectives"},{value:"exit",label:"\uD83D\uDC4B Exit"}]});if(t(z)||z==="exit"){$1(R.default.dim("Goodbye!"));return}if(z==="list"){if(Z.length===0)g(R.default.yellow("No retrospectives found."),"History");else{let U=Z.map((_,q)=>`${q+1}. [${_.date.split("T")[0]}] ${_.summary.slice(0,50)}...`).join(`
197
- `);g(U,`\uD83D\uDCDA Past Retrospectives (${Z.length})`)}$1(R.default.dim(`Stored in: ${J}`));return}let N=n7(G),Q=s7(G);if(N.length>0)g(N.join(`
198
- `),"Recent Commits");if(Q.length>0)g(Q.join(`
199
- `),"Changed Files");let Y=await y0({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(t(Y)){B1("Cancelled.");return}let K=await y0({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(t(K)){B1("Cancelled.");return}let I=await y0({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(t(I)){B1("Cancelled.");return}let H={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:Y,keyLearnings:K.split(",").map((U)=>U.trim()).filter(Boolean),filesChanged:Q,nextSteps:I.split(",").map((U)=>U.trim()).filter(Boolean)};i7(G,H),g([R.default.green("✅ Retrospective saved!"),"",`Summary: ${H.summary}`,`Learnings: ${H.keyLearnings.length} items`,`Next steps: ${H.nextSteps.length} items`].join(`
200
- `),"Saved"),$1(R.default.dim(`Stored in: ${J}`))}async function r7($=!1,G=!1){let J=process.cwd(),Z=S(J,".agent","results"),X="/tmp",z={cleaned:0,skipped:0,details:[]},N=(K)=>{z.details.push($?`[DRY-RUN] ${K}`:`[CLEAN] ${K}`),z.cleaned++},Q=(K)=>{z.details.push(`[SKIP] ${K}`),z.skipped++};try{let K=p1("/tmp").filter((I)=>I.startsWith("subagent-")&&I.endsWith(".pid"));for(let I of K){let H=S("/tmp",I),U=v1(H,"utf-8").trim();if(!U){if(N(`Removing empty PID file: ${H}`),!$)try{m(`rm -f "${H}"`)}catch{}continue}let _=parseInt(U,10);if(isNaN(_)){if(N(`Removing invalid PID file: ${H}`),!$)try{m(`rm -f "${H}"`)}catch{}continue}try{if(m(`kill -0 ${_} 2>/dev/null`),N(`Killing orphaned process PID=${_} (from ${H})`),!$)try{m(`kill ${_} 2>/dev/null || true`),await new Promise((q)=>setTimeout(q,1000));try{m(`kill -0 ${_} 2>/dev/null`),m(`kill -9 ${_} 2>/dev/null || true`)}catch{}m(`rm -f "${H}"`)}catch{}}catch{if(N(`Removing stale PID file (process gone): ${H}`),!$)try{m(`rm -f "${H}"`)}catch{}}}}catch{}try{let K=p1("/tmp").filter((I)=>I.startsWith("subagent-")&&I.endsWith(".log"));for(let I of K){let H=S("/tmp",I),U=I.replace(".log",".pid"),_=S("/tmp",U);if(h(_))try{let q=v1(_,"utf-8").trim(),B=parseInt(q,10);if(!isNaN(B)){m(`kill -0 ${B} 2>/dev/null`),Q(`Log file has active process: ${H}`);continue}}catch{}if(N(`Removing stale log file: ${H}`),!$)try{m(`rm -f "${H}"`)}catch{}}}catch{}if(h(Z))try{let K=p1(Z).filter((I)=>I.startsWith("parallel-"));for(let I of K){let H=S(Z,I,"pids.txt");if(!h(H))continue;let _=v1(H,"utf-8").split(`
201
- `).filter((B)=>B.trim()),q=!1;for(let B of _){let[M,V]=B.split(":"),x=parseInt(M?.trim()||"",10);if(isNaN(x))continue;try{if(m(`kill -0 ${x} 2>/dev/null`),q=!0,N(`Killing orphaned parallel agent PID=${x} (${V?.trim()||"unknown"})`),!$)try{m(`kill ${x} 2>/dev/null || true`),m(`rm -f "${H}"`)}catch{}}catch{}}if(!q){if(N(`Removing stale PID list: ${H}`),!$)try{m(`rm -f "${H}"`)}catch{}}else if(!$){await new Promise((B)=>setTimeout(B,1000));try{m(`rm -f "${H}"`)}catch{}}}}catch{}else Q(`No results directory found: ${Z}`);if(G){console.log(JSON.stringify(z,null,2));return}if(console.clear(),F1(R.default.bgMagenta(R.default.white(" \uD83E\uDDF9 oh-my-ag cleanup "))),$)g(R.default.yellow("Dry-run mode — no changes will be made"),"Mode");if(z.details.length>0){let K=[R.default.bold("Cleanup Details"),...z.details.map((I)=>{if(I.startsWith("[DRY-RUN]"))return R.default.yellow(I);if(I.startsWith("[CLEAN]"))return R.default.green(I);return R.default.cyan(I)})].join(`
202
- `);g(K,"Details")}let Y=[R.default.bold("Summary"),"┌─────────┬────────┐",`│ ${R.default.bold("Action")} │ ${R.default.bold("Count")} │`,"├─────────┼────────┤",`│ Cleaned │ ${String(z.cleaned).padEnd(6)} │`,`│ Skipped │ ${String(z.skipped).padEnd(6)} │`,"└─────────┴────────┘"].join(`
203
- `);if(g(Y,"Results"),$)$1(R.default.yellow("Run without --dry-run to apply changes"));else $1(R.default.green("Cleanup complete!"))}async function a7(){console.clear(),F1(R.default.bgMagenta(R.default.white(" \uD83D\uDEF8 oh-my-ag ")));let $=await w0({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(t($))B1("Cancelled."),process.exit(0);let G;if($==="custom"){let X=[...i.domain,...i.coordination,...i.utility],z=await g2({message:"Select skills:",options:X.map((N)=>({value:N.name,label:N.name,hint:N.desc})),required:!0});if(t(z))B1("Cancelled."),process.exit(0);G=z}else G=F7[$]??[];let J=process.cwd(),Z=S0();Z.start("Installing skills...");try{await d9(J);for(let X of G)Z.message(`Installing ${R.default.cyan(X)}...`),await l9(X,J);Z.stop("Skills installed!"),g([...G.map((X)=>`${R.default.green("✓")} ${X}`),"",R.default.dim(`Location: ${S(J,".agent","skills")}`)].join(`
204
- `),"Installed"),$1(R.default.green("Done! Open your project in your IDE to use the skills.")),g(`${R.default.yellow("❤️")} Enjoying oh-my-ag? Give it a star!
205
- ${R.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Support")}catch(X){Z.stop("Installation failed"),Z1.error(X instanceof Error?X.message:String(X)),process.exit(1)}}var R1=new v4;R1.name("oh-my-ag").description("Multi-Agent Skills for Antigravity IDE").version(O7).action(()=>{a7().catch(console.error)});R1.command("dashboard").description("Start terminal dashboard (real-time agent monitoring)").action(()=>{m9()});R1.command("dashboard:web").description("Start web dashboard on http://localhost:9847").action(()=>{k9()});R1.command("update").description("Update skills to latest version from registry").action(()=>{g7().catch(console.error)});R1.command("doctor").description("Check CLI installations, MCP configs, and skill status").option("--json","Output as JSON for CI/CD").action(($)=>{k7($.json).catch(console.error)});R1.command("stats").description("View productivity metrics").option("--json","Output as JSON").option("--reset","Reset metrics data").action(($)=>{c7($.json,$.reset).catch(console.error)});R1.command("retro").description("Session retrospective (learnings & next steps)").option("--json","Output as JSON").action(($)=>{o7($.json).catch(console.error)});R1.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(($)=>{r7($.dryRun,$.json).catch(console.error)});R1.parse();
88
+ </html>`;function y8(){let $=NI();if(!$I($))II($,{recursive:!0});let I=t9((z,x)=>{if(z.url==="/api/state")x.writeHead(200,{"Content-Type":"application/json"}),x.end(JSON.stringify(a$($)));else x.writeHead(200,{"Content-Type":"text/html"}),x.end(QI)}),N=new o$.default({server:I}),G=null;function J(z,x){if(G)clearTimeout(G);G=setTimeout(()=>{let Q=JSON.stringify({type:"update",event:z,file:x,data:a$($)});N.clients.forEach((X)=>{if(X.readyState===s$.default.OPEN)X.send(Q)})},100)}let Z=A0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});Z.on("all",(z,x)=>J(z,O8(x))),N.on("connection",(z)=>{z.send(JSON.stringify({type:"full",data:a$($)})),z.on("error",()=>z.terminate())}),process.on("SIGINT",()=>{console.log(`
89
+ Shutting down...`),Z.close(),N.clients.forEach((z)=>z.terminate()),N.close(()=>I.close(()=>process.exit(0))),setTimeout(()=>process.exit(1),3000).unref()}),process.on("SIGTERM",()=>process.emit("SIGINT")),I.listen(W8,()=>{console.log(h0.default.magenta(`
90
+ \uD83D\uDEF8 Serena Memory Dashboard`)),console.log(h0.default.white(` http://localhost:${W8}`)),console.log(h0.default.dim(` Watching: ${$}
91
+ `))})}var h=i(x1(),1);import{readFileSync as XI,existsSync as MI,readdirSync as M0,statSync as I2,mkdirSync as jI}from"node:fs";import{join as Q1,basename as KI}from"node:path";var YI="●",RI="✓",SI="✗",HI="○",TI="◌";function UI(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return Q1($,".serena","memories");return Q1(process.cwd(),".serena","memories")}function j0($){try{return XI($,"utf-8")}catch{return""}}function qI($){try{let I=M0($);if(I.includes("orchestrator-session.md"))return Q1($,"orchestrator-session.md");let N=I.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:I2(Q1($,G)).mtimeMs})).sort((G,J)=>J.mtime-G.mtime);if(N.length>0&&N[0])return Q1($,N[0].name)}catch{}return null}function CI($){let I=qI($);if(!I)return{id:"N/A",status:"UNKNOWN"};let N=j0(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]||KI(I,".md"),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||"N/A").trim(),status:J}}function BI($){let I=j0(Q1($,"task-board.md"));if(!I)return[];let N=[],G=I.split(`
92
+ `);for(let J of G){if(!J.startsWith("|")||/^\|\s*-+/.test(J))continue;let Z=J.split("|").map((X)=>X.trim()).filter(Boolean),z=Z[0];if(Z.length<2||!z||/^agent$/i.test(z))continue;let x=Z[1],Q=Z[2];N.push({agent:z,status:x||"pending",task:Q||""})}return N}function $2($,I){try{let N=M0($).filter((Z)=>Z.startsWith(`progress-${I}`)&&Z.endsWith(".md")).sort().reverse();if(N.length===0||!N[0])return null;let J=j0(Q1($,N[0])).match(/turn[:\s]*(\d+)/i);return J&&J[1]?parseInt(J[1],10):null}catch{return null}}function gI($){try{let I=M0($).filter((G)=>G.endsWith(".md")&&G!==".gitkeep").map((G)=>({name:G,mtime:I2(Q1($,G)).mtimeMs})).sort((G,J)=>J.mtime-G.mtime).slice(0,5),N=[];for(let G of I){let J=G.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||G.name.replace(/\.md$/,""),z=j0(Q1($,G.name)).split(`
93
+ `).map((Q)=>Q.trim()).filter((Q)=>Q&&!Q.startsWith("---")&&Q.length>3),x="";for(let Q=z.length-1;Q>=0;Q--){let X=z[Q];if(!X)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(X)){if(x=X.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),x.length>5)break}}if(x.length>52)x=x.substring(0,49)+"...";if(x)N.push({agent:J,message:x})}return N}catch{return[]}}function LI($){let I=[],N=new Set;try{let G=M0($).filter((J)=>J.endsWith(".md")&&J!==".gitkeep").map((J)=>({name:J,mtime:I2(Q1($,J)).mtimeMs})).sort((J,Z)=>Z.mtime-J.mtime);for(let J of G){let Z=j0(Q1($,J.name)),z=Z.match(/\*\*Agent\*\*:\s*(.+)/i)||Z.match(/Agent:\s*(.+)/i)||Z.match(/^#+\s*(.+?)\s*Agent/im),x=null;if(z&&z[1])x=z[1].trim();else if(/_agent|agent_|-agent/i.test(J.name))x=J.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(x&&!N.has(x.toLowerCase())){N.add(x.toLowerCase());let Q="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(Z))Q="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(Z))Q="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(Z))Q="failed";let X=Z.match(/## Task\s*\n+(.+)/i)||Z.match(/\*\*Task\*\*:\s*(.+)/i),j=X&&X[1]?X[1].trim().substring(0,20):"";I.push({agent:x,status:Q,task:j,turn:$2($,x)})}}}catch{}return I}function DI($){let I=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(I))return`${h.default.green(YI)} running`;else if(["completed","done","finished"].includes(I))return`${h.default.cyan(RI)} completed`;else if(["failed","error"].includes(I))return`${h.default.red(SI)} failed`;else if(["blocked","waiting"].includes(I))return`${h.default.yellow(HI)} blocked`;return`${h.default.dim(TI)} pending`}function E8($){console.clear();let I=CI($),G=BI($).map((K)=>({...K,turn:$2($,K.agent)}));if(G.length===0)G=LI($);if(G.length===0)try{let K=M0($).filter((T)=>T.startsWith("progress-")&&T.endsWith(".md"));for(let T of K){let C=T.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:C,status:"running",task:"",turn:$2($,C)})}}catch{}let J=56,Z="═".repeat(J),z=(K)=>" ".repeat(Math.max(0,K)),x=(K)=>h.default.magenta(K),Q=(K)=>h.default.bold(K),X=(K)=>h.default.dim(K),j=h.default.yellow;if(I.status==="RUNNING")j=h.default.green;else if(I.status==="COMPLETED")j=h.default.cyan;else if(I.status==="FAILED")j=h.default.red;console.log(`${x("╔"+Z+"╗")}`),console.log(`${x("║")} ${Q(x("Serena Memory Dashboard"))}${z(J-25)}${x("║")}`);let M=`Session: ${Q(I.id.padEnd(20))} [${j(I.status)}]`;if(console.log(`${x("║")} ${M}${z(J-4-M.length-9)}${x("║")}`),console.log(`${x("╠"+Z+"╣")}`),console.log(`${x("║")} ${Q("Agent".padEnd(12)+" "+"Status".padEnd(12)+" "+"Turn".padEnd(6)+" "+"Task".padEnd(20))} ${x("║")}`),console.log(`${x("║")} ${X("──────────".padEnd(12)+" "+"──────────".padEnd(12)+" "+"────".padEnd(6)+" "+"──────────────────".padEnd(20))} ${x("║")}`),G.length===0)console.log(`${x("║")} ${X("No agents detected yet"+z(32))}${x("║")}`);else for(let K of G){let T=DI(K.status),C=K.turn!=null?String(K.turn):"-",U=K.task.substring(0,20);console.log(`${x("║")} ${K.agent.padEnd(12)} ${T.padEnd(22)} ${C.padEnd(6)} ${U.padEnd(20)}${x("║")}`)}console.log(`${x("╠"+Z+"╣")}`),console.log(`${x("║")} ${Q("Latest Activity:")}${z(J-18)}${x("║")}`);let R=gI($);if(R.length===0)console.log(`${x("║")} ${X("No activity yet"+z(38))}${x("║")}`);else for(let K of R){let T=`[${K.agent}] ${K.message}`;console.log(`${x("║")} ${X(T.substring(0,52).padEnd(52))}${x("║")}`)}console.log(`${x("╠"+Z+"╣")}`);let Y=`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(`${x("║")} ${X(Y)}${z(J-4-Y.length)}${x("║")}`),console.log(`${x("╚"+Z+"╝")}`)}function l8(){let $=UI();if(!MI($))jI($,{recursive:!0}),console.log(h.default.yellow(`Created ${$} — waiting for memory files...`));console.log(h.default.magenta(`
94
+ \uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(h.default.dim(` Watching: ${$}
95
+ `)),E8($);let I=A0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});I.on("all",()=>E8($)),process.on("SIGINT",()=>{console.log(`
96
+ `),I.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var K0=i(x1(),1),n=i(G2(),1);import{stdout as X2,stdin as i8}from"node:process";import*as _1 from"node:readline";import fI from"node:readline";import{ReadStream as v8}from"node:tty";var AI=($)=>$===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,PI=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,FI=($)=>$>=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,J2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,n0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,c0=/\t{1,1000}/y,Z2=/[\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,d0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,WI=/\p{M}+/gu,OI={limit:1/0,ellipsis:""},k8=($,I={},N={})=>{let G=I.limit??1/0,J=I.ellipsis??"",Z=I?.ellipsisWidth??(J?k8(J,OI,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(WI,"")){let s=c.codePointAt(0)||0;if(PI(s)?g=M:FI(s)?g=S:X!==R&&AI(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(d0.lastIndex=K,d0.test($)){if(C=d0.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=d0.lastIndex;continue}if(J2.lastIndex=K,J2.test($)){if(q+z>_&&(B=Math.min(B,K)),q+z>G){U=!0;break}q+=z,L=Y,f=K,K=Y=J2.lastIndex;continue}if(n0.lastIndex=K,n0.test($)){if(C=n0.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=n0.lastIndex;continue}if(c0.lastIndex=K,c0.test($)){if(C=c0.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=c0.lastIndex;continue}if(Z2.lastIndex=K,Z2.test($)){if(q+j>_&&(B=Math.min(B,K)),q+j>G){U=!0;break}q+=j,L=Y,f=K,K=Y=Z2.lastIndex;continue}K+=1}return{width:U?_:q,index:U?B:T,truncated:U,ellipsed:U&&G>=Z}},yI={limit:1/0,ellipsis:"",ellipsisWidth:0},Y0=($,I={})=>k8($,yI,I).width,s0="\x1B",h8="›",EI=39,M2="\x07",n8="[",lI="]",c8="m",j2=`${lI}8;;`,w8=new RegExp(`(?:\\${n8}(?<code>\\d+)m|\\${j2}(?<uri>.*)${M2})`,"y"),uI=($)=>{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},b8=($)=>`${s0}${n8}${$}${c8}`,m8=($)=>`${s0}${j2}${$}${M2}`,vI=($)=>$.map((I)=>Y0(I)),x2=($,I,N)=>{let G=I[Symbol.iterator](),J=!1,Z=!1,z=$.at(-1),x=z===void 0?0:Y0(z),Q=G.next(),X=G.next(),j=0;for(;!Q.done;){let M=Q.value,R=Y0(M);x+R<=N?$[$.length-1]+=M:($.push(M),x=0),(M===s0||M===h8)&&(J=!0,Z=I.startsWith(j2,j+1)),J?Z?M===M2&&(J=!1,Z=!1):M===c8&&(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())},wI=($)=>{let I=$.split(" "),N=I.length;for(;N>0&&!(Y0(I[N-1])>0);)N--;return N===I.length?$:I.slice(0,N).join(" ")+I.slice(N).join("")},bI=($,I,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",J,Z,z=$.split(" "),x=vI(z),Q=[""];for(let[Y,K]of z.entries()){N.trim!==!1&&(Q[Q.length-1]=(Q.at(-1)??"").trimStart());let T=Y0(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(""),x2(Q,K,I);continue}if(T+x[Y]>I&&T>0&&x[Y]>0){if(N.wordWrap===!1&&T<I){x2(Q,K,I);continue}Q.push("")}if(T+x[Y]>I&&N.wordWrap===!1){x2(Q,K,I);continue}Q[Q.length-1]+=K}N.trim!==!1&&(Q=Q.map((Y)=>wI(Y)));let X=Q.join(`
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();