oh-my-ag 1.5.0 → 1.5.1

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 (4) hide show
  1. package/README.ko.md +62 -31
  2. package/README.md +52 -23
  3. package/bin/cli.js +111 -109
  4. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -1,152 +1,154 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as X5}from"node:module";var N5=Object.create;var{getPrototypeOf:G5,defineProperty:s2,getOwnPropertyNames:Z5}=Object;var z5=Object.prototype.hasOwnProperty;var k=($,J,N)=>{N=$!=null?N5(G5($)):{};let G=J||!$||!$.__esModule?s2(N,"default",{value:$,enumerable:!0}):N;for(let Z of Z5($))if(!z5.call(G,Z))s2(G,Z,{get:()=>$[Z],enumerable:!0});return G};var u=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var f=X5(import.meta.url);var N0=u((Q5)=>{class _$ extends Error{constructor($,J,N){super(N);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=J,this.exitCode=$,this.nestedError=void 0}}class o2 extends _${constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}Q5.CommanderError=_$;Q5.InvalidArgumentError=o2});var W0=u((j5)=>{var{InvalidArgumentError:Y5}=N0();class r2{constructor($,J){switch(this.description=J||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(J,N)=>{if(!this.argChoices.includes(J))throw new Y5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,N);return J},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function K5($){let J=$.name()+($.variadic===!0?"...":"");return $.required?"<"+J+">":"["+J+"]"}j5.Argument=r2;j5.humanReadableArgName=K5});var C$=u((q5)=>{var{humanReadableArgName:R5}=W0();class a2{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let J=$.commands.filter((G)=>!G._hidden),N=$._getHelpCommand();if(N&&!N._hidden)J.push(N);if(this.sortSubcommands)J.sort((G,Z)=>{return G.name().localeCompare(Z.name())});return J}compareOptions($,J){let N=(G)=>{return G.short?G.short.replace(/^-/,""):G.long.replace(/^--/,"")};return N($).localeCompare(N(J))}visibleOptions($){let J=$.options.filter((G)=>!G.hidden),N=$._getHelpOption();if(N&&!N.hidden){let G=N.short&&$._findOption(N.short),Z=N.long&&$._findOption(N.long);if(!G&&!Z)J.push(N);else if(N.long&&!Z)J.push($.createOption(N.long,N.description));else if(N.short&&!G)J.push($.createOption(N.short,N.description))}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let J=[];for(let N=$.parent;N;N=N.parent){let G=N.options.filter((Z)=>!Z.hidden);J.push(...G)}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((J)=>{J.description=J.description||$._argsDescription[J.name()]||""});if($.registeredArguments.find((J)=>J.description))return $.registeredArguments;return[]}subcommandTerm($){let J=$.registeredArguments.map((N)=>R5(N)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(J?" "+J:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,J){return J.visibleCommands($).reduce((N,G)=>{return Math.max(N,J.subcommandTerm(G).length)},0)}longestOptionTermLength($,J){return J.visibleOptions($).reduce((N,G)=>{return Math.max(N,J.optionTerm(G).length)},0)}longestGlobalOptionTermLength($,J){return J.visibleGlobalOptions($).reduce((N,G)=>{return Math.max(N,J.optionTerm(G).length)},0)}longestArgumentTermLength($,J){return J.visibleArguments($).reduce((N,G)=>{return Math.max(N,J.argumentTerm(G).length)},0)}commandUsage($){let J=$._name;if($._aliases[0])J=J+"|"+$._aliases[0];let N="";for(let G=$.parent;G;G=G.parent)N=G.name()+" "+N;return N+J+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)J.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)J.push(`env: ${$.envVar}`);if(J.length>0)return`${$.description} (${J.join(", ")})`;return $.description}argumentDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0)J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(J.length>0){let N=`(${J.join(", ")})`;if($.description)return`${$.description} ${N}`;return N}return $.description}formatHelp($,J){let N=J.padWidth($,J),G=J.helpWidth||80,Z=2,z=2;function X(R,x){if(x){let j=`${R.padEnd(N+2)}${x}`;return J.wrap(j,G-2,N+2)}return R}function Q(R){return R.join(`
3
- `).replace(/^/gm," ".repeat(2))}let M=[`Usage: ${J.commandUsage($)}`,""],I=J.commandDescription($);if(I.length>0)M=M.concat([J.wrap(I,G,0),""]);let K=J.visibleArguments($).map((R)=>{return X(J.argumentTerm(R),J.argumentDescription(R))});if(K.length>0)M=M.concat(["Arguments:",Q(K),""]);let Y=J.visibleOptions($).map((R)=>{return X(J.optionTerm(R),J.optionDescription(R))});if(Y.length>0)M=M.concat(["Options:",Q(Y),""]);if(this.showGlobalOptions){let R=J.visibleGlobalOptions($).map((x)=>{return X(J.optionTerm(x),J.optionDescription(x))});if(R.length>0)M=M.concat(["Global Options:",Q(R),""])}let H=J.visibleCommands($).map((R)=>{return X(J.subcommandTerm(R),J.subcommandDescription(R))});if(H.length>0)M=M.concat(["Commands:",Q(H),""]);return M.join(`
2
+ import{createRequire as M5}from"node:module";var Z5=Object.create;var{getPrototypeOf:z5,defineProperty:s2,getOwnPropertyNames:X5}=Object;var Q5=Object.prototype.hasOwnProperty;var k=($,J,N)=>{N=$!=null?Z5(z5($)):{};let G=J||!$||!$.__esModule?s2(N,"default",{value:$,enumerable:!0}):N;for(let Z of X5($))if(!Q5.call(G,Z))s2(G,Z,{get:()=>$[Z],enumerable:!0});return G};var u=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var f=M5(import.meta.url);var Z0=u((I5)=>{class C$ extends Error{constructor($,J,N){super(N);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=J,this.exitCode=$,this.nestedError=void 0}}class o2 extends C${constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}I5.CommanderError=C$;I5.InvalidArgumentError=o2});var g0=u((R5)=>{var{InvalidArgumentError:j5}=Z0();class r2{constructor($,J){switch(this.description=J||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(J,N)=>{if(!this.argChoices.includes(J))throw new j5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,N);return J},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function x5($){let J=$.name()+($.variadic===!0?"...":"");return $.required?"<"+J+">":"["+J+"]"}R5.Argument=r2;R5.humanReadableArgName=x5});var L$=u((B5)=>{var{humanReadableArgName:U5}=g0();class a2{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let J=$.commands.filter((G)=>!G._hidden),N=$._getHelpCommand();if(N&&!N._hidden)J.push(N);if(this.sortSubcommands)J.sort((G,Z)=>{return G.name().localeCompare(Z.name())});return J}compareOptions($,J){let N=(G)=>{return G.short?G.short.replace(/^-/,""):G.long.replace(/^--/,"")};return N($).localeCompare(N(J))}visibleOptions($){let J=$.options.filter((G)=>!G.hidden),N=$._getHelpOption();if(N&&!N.hidden){let G=N.short&&$._findOption(N.short),Z=N.long&&$._findOption(N.long);if(!G&&!Z)J.push(N);else if(N.long&&!Z)J.push($.createOption(N.long,N.description));else if(N.short&&!G)J.push($.createOption(N.short,N.description))}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let J=[];for(let N=$.parent;N;N=N.parent){let G=N.options.filter((Z)=>!Z.hidden);J.push(...G)}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((J)=>{J.description=J.description||$._argsDescription[J.name()]||""});if($.registeredArguments.find((J)=>J.description))return $.registeredArguments;return[]}subcommandTerm($){let J=$.registeredArguments.map((N)=>U5(N)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(J?" "+J:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,J){return J.visibleCommands($).reduce((N,G)=>{return Math.max(N,J.subcommandTerm(G).length)},0)}longestOptionTermLength($,J){return J.visibleOptions($).reduce((N,G)=>{return Math.max(N,J.optionTerm(G).length)},0)}longestGlobalOptionTermLength($,J){return J.visibleGlobalOptions($).reduce((N,G)=>{return Math.max(N,J.optionTerm(G).length)},0)}longestArgumentTermLength($,J){return J.visibleArguments($).reduce((N,G)=>{return Math.max(N,J.argumentTerm(G).length)},0)}commandUsage($){let J=$._name;if($._aliases[0])J=J+"|"+$._aliases[0];let N="";for(let G=$.parent;G;G=G.parent)N=G.name()+" "+N;return N+J+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)J.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)J.push(`env: ${$.envVar}`);if(J.length>0)return`${$.description} (${J.join(", ")})`;return $.description}argumentDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0)J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(J.length>0){let N=`(${J.join(", ")})`;if($.description)return`${$.description} ${N}`;return N}return $.description}formatHelp($,J){let N=J.padWidth($,J),G=J.helpWidth||80,Z=2,z=2;function X(R,j){if(j){let x=`${R.padEnd(N+2)}${j}`;return J.wrap(x,G-2,N+2)}return R}function Q(R){return R.join(`
3
+ `).replace(/^/gm," ".repeat(2))}let M=[`Usage: ${J.commandUsage($)}`,""],I=J.commandDescription($);if(I.length>0)M=M.concat([J.wrap(I,G,0),""]);let K=J.visibleArguments($).map((R)=>{return X(J.argumentTerm(R),J.argumentDescription(R))});if(K.length>0)M=M.concat(["Arguments:",Q(K),""]);let Y=J.visibleOptions($).map((R)=>{return X(J.optionTerm(R),J.optionDescription(R))});if(Y.length>0)M=M.concat(["Options:",Q(Y),""]);if(this.showGlobalOptions){let R=J.visibleGlobalOptions($).map((j)=>{return X(J.optionTerm(j),J.optionDescription(j))});if(R.length>0)M=M.concat(["Global Options:",Q(R),""])}let H=J.visibleCommands($).map((R)=>{return X(J.subcommandTerm(R),J.subcommandDescription(R))});if(H.length>0)M=M.concat(["Commands:",Q(H),""]);return M.join(`
4
4
  `)}padWidth($,J){return Math.max(J.longestOptionTermLength($,J),J.longestGlobalOptionTermLength($,J),J.longestSubcommandTermLength($,J),J.longestArgumentTermLength($,J))}wrap($,J,N,G=40){let z=new RegExp(`[\\n][${" \\f\\t\\v   -    \uFEFF"}]+`);if($.match(z))return $;let X=J-N;if(X<G)return $;let Q=$.slice(0,N),M=$.slice(N).replace(`\r
5
5
  `,`
6
6
  `),I=" ".repeat(N),Y=`\\s${"​"}`,H=new RegExp(`
7
- |.{1,${X-1}}([${Y}]|$)|[^${Y}]+?([${Y}]|$)`,"g"),R=M.match(H)||[];return Q+R.map((x,j)=>{if(x===`
8
- `)return"";return(j>0?I:"")+x.trimEnd()}).join(`
9
- `)}}q5.Help=a2});var L$=u((_5)=>{var{InvalidArgumentError:B5}=N0();class t2{constructor($,J){this.flags=$,this.description=J||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let N=V5($);if(this.short=N.shortFlag,this.long=N.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let J=$;if(typeof $==="string")J={[$]:!0};return this.implied=Object.assign(this.implied||{},J),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(J,N)=>{if(!this.argChoices.includes(J))throw new B5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,N);return J},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return T5(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class e2{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((J)=>{if(J.negate)this.negativeOptions.set(J.attributeName(),J);else this.positiveOptions.set(J.attributeName(),J)}),this.negativeOptions.forEach((J,N)=>{if(this.positiveOptions.has(N))this.dualOptions.add(N)})}valueFromOption($,J){let N=J.attributeName();if(!this.dualOptions.has(N))return!0;let G=this.negativeOptions.get(N).presetArg,Z=G!==void 0?G:!1;return J.negate===(Z===$)}}function T5($){return $.split("-").reduce((J,N)=>{return J+N[0].toUpperCase()+N.slice(1)})}function V5($){let J,N,G=$.split(/[ |,]+/);if(G.length>1&&!/^[[<]/.test(G[1]))J=G.shift();if(N=G.shift(),!J&&/^-[^-]$/.test(N))J=N,N=void 0;return{shortFlag:J,longFlag:N}}_5.Option=t2;_5.DualOptions=e2});var $4=u((P5)=>{function A5($,J){if(Math.abs($.length-J.length)>3)return Math.max($.length,J.length);let N=[];for(let G=0;G<=$.length;G++)N[G]=[G];for(let G=0;G<=J.length;G++)N[0][G]=G;for(let G=1;G<=J.length;G++)for(let Z=1;Z<=$.length;Z++){let z=1;if($[Z-1]===J[G-1])z=0;else z=1;if(N[Z][G]=Math.min(N[Z-1][G]+1,N[Z][G-1]+1,N[Z-1][G-1]+z),Z>1&&G>1&&$[Z-1]===J[G-2]&&$[Z-2]===J[G-1])N[Z][G]=Math.min(N[Z][G],N[Z-2][G-2]+1)}return N[$.length][J.length]}function D5($,J){if(!J||J.length===0)return"";J=Array.from(new Set(J));let N=$.startsWith("--");if(N)$=$.slice(2),J=J.map((X)=>X.slice(2));let G=[],Z=3,z=0.4;if(J.forEach((X)=>{if(X.length<=1)return;let Q=A5($,X),M=Math.max($.length,X.length);if((M-Q)/M>z){if(Q<Z)Z=Q,G=[X];else if(Q===Z)G.push(X)}}),G.sort((X,Q)=>X.localeCompare(Q)),N)G=G.map((X)=>`--${X}`);if(G.length>1)return`
7
+ |.{1,${X-1}}([${Y}]|$)|[^${Y}]+?([${Y}]|$)`,"g"),R=M.match(H)||[];return Q+R.map((j,x)=>{if(j===`
8
+ `)return"";return(x>0?I:"")+j.trimEnd()}).join(`
9
+ `)}}B5.Help=a2});var A$=u((L5)=>{var{InvalidArgumentError:T5}=Z0();class t2{constructor($,J){this.flags=$,this.description=J||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let N=C5($);if(this.short=N.shortFlag,this.long=N.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let J=$;if(typeof $==="string")J={[$]:!0};return this.implied=Object.assign(this.implied||{},J),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(J,N)=>{if(!this.argChoices.includes(J))throw new T5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,N);return J},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return _5(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class e2{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((J)=>{if(J.negate)this.negativeOptions.set(J.attributeName(),J);else this.positiveOptions.set(J.attributeName(),J)}),this.negativeOptions.forEach((J,N)=>{if(this.positiveOptions.has(N))this.dualOptions.add(N)})}valueFromOption($,J){let N=J.attributeName();if(!this.dualOptions.has(N))return!0;let G=this.negativeOptions.get(N).presetArg,Z=G!==void 0?G:!1;return J.negate===(Z===$)}}function _5($){return $.split("-").reduce((J,N)=>{return J+N[0].toUpperCase()+N.slice(1)})}function C5($){let J,N,G=$.split(/[ |,]+/);if(G.length>1&&!/^[[<]/.test(G[1]))J=G.shift();if(N=G.shift(),!J&&/^-[^-]$/.test(N))J=N,N=void 0;return{shortFlag:J,longFlag:N}}L5.Option=t2;L5.DualOptions=e2});var $4=u((S5)=>{function P5($,J){if(Math.abs($.length-J.length)>3)return Math.max($.length,J.length);let N=[];for(let G=0;G<=$.length;G++)N[G]=[G];for(let G=0;G<=J.length;G++)N[0][G]=G;for(let G=1;G<=J.length;G++)for(let Z=1;Z<=$.length;Z++){let z=1;if($[Z-1]===J[G-1])z=0;else z=1;if(N[Z][G]=Math.min(N[Z-1][G]+1,N[Z][G-1]+1,N[Z-1][G-1]+z),Z>1&&G>1&&$[Z-1]===J[G-2]&&$[Z-2]===J[G-1])N[Z][G]=Math.min(N[Z][G],N[Z-2][G-2]+1)}return N[$.length][J.length]}function W5($,J){if(!J||J.length===0)return"";J=Array.from(new Set(J));let N=$.startsWith("--");if(N)$=$.slice(2),J=J.map((X)=>X.slice(2));let G=[],Z=3,z=0.4;if(J.forEach((X)=>{if(X.length<=1)return;let Q=P5($,X),M=Math.max($.length,X.length);if((M-Q)/M>z){if(Q<Z)Z=Q,G=[X];else if(Q===Z)G.push(X)}}),G.sort((X,Q)=>X.localeCompare(Q)),N)G=G.map((X)=>`--${X}`);if(G.length>1)return`
10
10
  (Did you mean one of ${G.join(", ")}?)`;if(G.length===1)return`
11
- (Did you mean ${G[0]}?)`;return""}P5.suggestSimilar=D5});var Z4=u((y5)=>{var W5=f("node:events").EventEmitter,A$=f("node:child_process"),T1=f("node:path"),D$=f("node:fs"),b=f("node:process"),{Argument:F5,humanReadableArgName:O5}=W0(),{CommanderError:P$}=N0(),{Help:g5}=C$(),{Option:J4,DualOptions:f5}=L$(),{suggestSimilar:N4}=$4();class S$ extends W5{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(J)=>b.stdout.write(J),writeErr:(J)=>b.stderr.write(J),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,outputError:(J,N)=>N(J)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let J=this;J;J=J.parent)$.push(J);return $}command($,J,N){let G=J,Z=N;if(typeof G==="object"&&G!==null)Z=G,G=null;Z=Z||{};let[,z,X]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(z);if(G)Q.description(G),Q._executableHandler=!0;if(Z.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(Z.noHelp||Z.hidden),Q._executableFile=Z.executableFile||null,X)Q.arguments(X);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),G)return this;return Q}createCommand($){return new S$($)}createHelp(){return Object.assign(new g5,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,J){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
12
- - specify the name in Command constructor or using .name()`);if(J=J||{},J.isDefault)this._defaultCommandName=$._name;if(J.noHelp||J.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,J){return new F5($,J)}argument($,J,N,G){let Z=this.createArgument($,J);if(typeof N==="function")Z.default(G).argParser(N);else Z.default(N);return this.addArgument(Z),this}arguments($){return $.trim().split(/ +/).forEach((J)=>{this.argument(J)}),this}addArgument($){let J=this.registeredArguments.slice(-1)[0];if(J&&J.variadic)throw Error(`only the last argument can be variadic '${J.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,J){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,N,G]=$.match(/([^ ]+) *(.*)/),Z=J??"display help for command",z=this.createCommand(N);if(z.helpOption(!1),G)z.arguments(G);if(Z)z.description(Z);return this._addImplicitHelpCommand=!0,this._helpCommand=z,this}addHelpCommand($,J){if(typeof $!=="object")return this.helpCommand($,J),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,J){let N=["preSubcommand","preAction","postAction"];if(!N.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
13
- Expecting one of '${N.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(J);else this._lifeCycleHooks[$]=[J];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(J)=>{if(J.code!=="commander.executeSubCommandAsync")throw J};return this}_exit($,J,N){if(this._exitCallback)this._exitCallback(new P$($,J,N));b.exit($)}action($){let J=(N)=>{let G=this.registeredArguments.length,Z=N.slice(0,G);if(this._storeOptionsAsProperties)Z[G]=this;else Z[G]=this.opts();return Z.push(this),$.apply(this,Z)};return this._actionHandler=J,this}createOption($,J){return new J4($,J)}_callParseArg($,J,N,G){try{return $.parseArg(J,N)}catch(Z){if(Z.code==="commander.invalidArgument"){let z=`${G} ${Z.message}`;this.error(z,{exitCode:Z.exitCode,code:Z.code})}throw Z}}_registerOption($){let J=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(J){let N=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${N}'
14
- - already used by option '${J.flags}'`)}this.options.push($)}_registerCommand($){let J=(G)=>{return[G.name()].concat(G.aliases())},N=J($).find((G)=>this._findCommand(G));if(N){let G=J(this._findCommand(N)).join("|"),Z=J($).join("|");throw Error(`cannot add command '${Z}' as already have command '${G}'`)}this.commands.push($)}addOption($){this._registerOption($);let J=$.name(),N=$.attributeName();if($.negate){let Z=$.long.replace(/^--no-/,"--");if(!this._findOption(Z))this.setOptionValueWithSource(N,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(N,$.defaultValue,"default");let G=(Z,z,X)=>{if(Z==null&&$.presetArg!==void 0)Z=$.presetArg;let Q=this.getOptionValue(N);if(Z!==null&&$.parseArg)Z=this._callParseArg($,Z,Q,z);else if(Z!==null&&$.variadic)Z=$._concatValue(Z,Q);if(Z==null)if($.negate)Z=!1;else if($.isBoolean()||$.optional)Z=!0;else Z="";this.setOptionValueWithSource(N,Z,X)};if(this.on("option:"+J,(Z)=>{let z=`error: option '${$.flags}' argument '${Z}' is invalid.`;G(Z,z,"cli")}),$.envVar)this.on("optionEnv:"+J,(Z)=>{let z=`error: option '${$.flags}' value '${Z}' from env '${$.envVar}' is invalid.`;G(Z,z,"env")});return this}_optionEx($,J,N,G,Z){if(typeof J==="object"&&J instanceof J4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let z=this.createOption(J,N);if(z.makeOptionMandatory(!!$.mandatory),typeof G==="function")z.default(Z).argParser(G);else if(G instanceof RegExp){let X=G;G=(Q,M)=>{let I=X.exec(Q);return I?I[0]:M},z.default(Z).argParser(G)}else z.default(G);return this.addOption(z)}option($,J,N,G){return this._optionEx({},$,J,N,G)}requiredOption($,J,N,G){return this._optionEx({mandatory:!0},$,J,N,G)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,J){return this.setOptionValueWithSource($,J,void 0)}setOptionValueWithSource($,J,N){if(this._storeOptionsAsProperties)this[$]=J;else this._optionValues[$]=J;return this._optionValueSources[$]=N,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let J;return this._getCommandAndAncestors().forEach((N)=>{if(N.getOptionValueSource($)!==void 0)J=N.getOptionValueSource($)}),J}_prepareUserArgs($,J){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(J=J||{},$===void 0&&J.from===void 0){if(b.versions?.electron)J.from="electron";let G=b.execArgv??[];if(G.includes("-e")||G.includes("--eval")||G.includes("-p")||G.includes("--print"))J.from="eval"}if($===void 0)$=b.argv;this.rawArgs=$.slice();let N;switch(J.from){case void 0:case"node":this._scriptPath=$[1],N=$.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=$[1],N=$.slice(2);else N=$.slice(1);break;case"user":N=$.slice(0);break;case"eval":N=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${J.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",N}parse($,J){let N=this._prepareUserArgs($,J);return this._parseCommand([],N),this}async parseAsync($,J){let N=this._prepareUserArgs($,J);return await this._parseCommand([],N),this}_executeSubCommand($,J){J=J.slice();let N=!1,G=[".js",".ts",".tsx",".mjs",".cjs"];function Z(I,K){let Y=T1.resolve(I,K);if(D$.existsSync(Y))return Y;if(G.includes(T1.extname(K)))return;let H=G.find((R)=>D$.existsSync(`${Y}${R}`));if(H)return`${Y}${H}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=$._executableFile||`${this._name}-${$._name}`,X=this._executableDir||"";if(this._scriptPath){let I;try{I=D$.realpathSync(this._scriptPath)}catch(K){I=this._scriptPath}X=T1.resolve(T1.dirname(I),X)}if(X){let I=Z(X,z);if(!I&&!$._executableFile&&this._scriptPath){let K=T1.basename(this._scriptPath,T1.extname(this._scriptPath));if(K!==this._name)I=Z(X,`${K}-${$._name}`)}z=I||z}N=G.includes(T1.extname(z));let Q;if(b.platform!=="win32")if(N)J.unshift(z),J=G4(b.execArgv).concat(J),Q=A$.spawn(b.argv[0],J,{stdio:"inherit"});else Q=A$.spawn(z,J,{stdio:"inherit"});else J.unshift(z),J=G4(b.execArgv).concat(J),Q=A$.spawn(b.execPath,J,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((K)=>{b.on(K,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(K)})});let M=this._exitCallback;Q.on("close",(I)=>{if(I=I??1,!M)b.exit(I);else M(new P$(I,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(I)=>{if(I.code==="ENOENT"){let K=X?`searched for local subcommand relative to directory '${X}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",Y=`'${z}' does not exist
11
+ (Did you mean ${G[0]}?)`;return""}S5.suggestSimilar=W5});var Z4=u((w5)=>{var O5=f("node:events").EventEmitter,D$=f("node:child_process"),V1=f("node:path"),P$=f("node:fs"),b=f("node:process"),{Argument:g5,humanReadableArgName:f5}=g0(),{CommanderError:W$}=Z0(),{Help:y5}=L$(),{Option:J4,DualOptions:E5}=A$(),{suggestSimilar:N4}=$4();class S$ extends O5{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(J)=>b.stdout.write(J),writeErr:(J)=>b.stderr.write(J),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,outputError:(J,N)=>N(J)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let J=this;J;J=J.parent)$.push(J);return $}command($,J,N){let G=J,Z=N;if(typeof G==="object"&&G!==null)Z=G,G=null;Z=Z||{};let[,z,X]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(z);if(G)Q.description(G),Q._executableHandler=!0;if(Z.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(Z.noHelp||Z.hidden),Q._executableFile=Z.executableFile||null,X)Q.arguments(X);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),G)return this;return Q}createCommand($){return new S$($)}createHelp(){return Object.assign(new y5,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,J){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
12
+ - specify the name in Command constructor or using .name()`);if(J=J||{},J.isDefault)this._defaultCommandName=$._name;if(J.noHelp||J.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,J){return new g5($,J)}argument($,J,N,G){let Z=this.createArgument($,J);if(typeof N==="function")Z.default(G).argParser(N);else Z.default(N);return this.addArgument(Z),this}arguments($){return $.trim().split(/ +/).forEach((J)=>{this.argument(J)}),this}addArgument($){let J=this.registeredArguments.slice(-1)[0];if(J&&J.variadic)throw Error(`only the last argument can be variadic '${J.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,J){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,N,G]=$.match(/([^ ]+) *(.*)/),Z=J??"display help for command",z=this.createCommand(N);if(z.helpOption(!1),G)z.arguments(G);if(Z)z.description(Z);return this._addImplicitHelpCommand=!0,this._helpCommand=z,this}addHelpCommand($,J){if(typeof $!=="object")return this.helpCommand($,J),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,J){let N=["preSubcommand","preAction","postAction"];if(!N.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
13
+ Expecting one of '${N.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(J);else this._lifeCycleHooks[$]=[J];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(J)=>{if(J.code!=="commander.executeSubCommandAsync")throw J};return this}_exit($,J,N){if(this._exitCallback)this._exitCallback(new W$($,J,N));b.exit($)}action($){let J=(N)=>{let G=this.registeredArguments.length,Z=N.slice(0,G);if(this._storeOptionsAsProperties)Z[G]=this;else Z[G]=this.opts();return Z.push(this),$.apply(this,Z)};return this._actionHandler=J,this}createOption($,J){return new J4($,J)}_callParseArg($,J,N,G){try{return $.parseArg(J,N)}catch(Z){if(Z.code==="commander.invalidArgument"){let z=`${G} ${Z.message}`;this.error(z,{exitCode:Z.exitCode,code:Z.code})}throw Z}}_registerOption($){let J=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(J){let N=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${N}'
14
+ - already used by option '${J.flags}'`)}this.options.push($)}_registerCommand($){let J=(G)=>{return[G.name()].concat(G.aliases())},N=J($).find((G)=>this._findCommand(G));if(N){let G=J(this._findCommand(N)).join("|"),Z=J($).join("|");throw Error(`cannot add command '${Z}' as already have command '${G}'`)}this.commands.push($)}addOption($){this._registerOption($);let J=$.name(),N=$.attributeName();if($.negate){let Z=$.long.replace(/^--no-/,"--");if(!this._findOption(Z))this.setOptionValueWithSource(N,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(N,$.defaultValue,"default");let G=(Z,z,X)=>{if(Z==null&&$.presetArg!==void 0)Z=$.presetArg;let Q=this.getOptionValue(N);if(Z!==null&&$.parseArg)Z=this._callParseArg($,Z,Q,z);else if(Z!==null&&$.variadic)Z=$._concatValue(Z,Q);if(Z==null)if($.negate)Z=!1;else if($.isBoolean()||$.optional)Z=!0;else Z="";this.setOptionValueWithSource(N,Z,X)};if(this.on("option:"+J,(Z)=>{let z=`error: option '${$.flags}' argument '${Z}' is invalid.`;G(Z,z,"cli")}),$.envVar)this.on("optionEnv:"+J,(Z)=>{let z=`error: option '${$.flags}' value '${Z}' from env '${$.envVar}' is invalid.`;G(Z,z,"env")});return this}_optionEx($,J,N,G,Z){if(typeof J==="object"&&J instanceof J4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let z=this.createOption(J,N);if(z.makeOptionMandatory(!!$.mandatory),typeof G==="function")z.default(Z).argParser(G);else if(G instanceof RegExp){let X=G;G=(Q,M)=>{let I=X.exec(Q);return I?I[0]:M},z.default(Z).argParser(G)}else z.default(G);return this.addOption(z)}option($,J,N,G){return this._optionEx({},$,J,N,G)}requiredOption($,J,N,G){return this._optionEx({mandatory:!0},$,J,N,G)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,J){return this.setOptionValueWithSource($,J,void 0)}setOptionValueWithSource($,J,N){if(this._storeOptionsAsProperties)this[$]=J;else this._optionValues[$]=J;return this._optionValueSources[$]=N,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let J;return this._getCommandAndAncestors().forEach((N)=>{if(N.getOptionValueSource($)!==void 0)J=N.getOptionValueSource($)}),J}_prepareUserArgs($,J){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(J=J||{},$===void 0&&J.from===void 0){if(b.versions?.electron)J.from="electron";let G=b.execArgv??[];if(G.includes("-e")||G.includes("--eval")||G.includes("-p")||G.includes("--print"))J.from="eval"}if($===void 0)$=b.argv;this.rawArgs=$.slice();let N;switch(J.from){case void 0:case"node":this._scriptPath=$[1],N=$.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=$[1],N=$.slice(2);else N=$.slice(1);break;case"user":N=$.slice(0);break;case"eval":N=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${J.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",N}parse($,J){let N=this._prepareUserArgs($,J);return this._parseCommand([],N),this}async parseAsync($,J){let N=this._prepareUserArgs($,J);return await this._parseCommand([],N),this}_executeSubCommand($,J){J=J.slice();let N=!1,G=[".js",".ts",".tsx",".mjs",".cjs"];function Z(I,K){let Y=V1.resolve(I,K);if(P$.existsSync(Y))return Y;if(G.includes(V1.extname(K)))return;let H=G.find((R)=>P$.existsSync(`${Y}${R}`));if(H)return`${Y}${H}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=$._executableFile||`${this._name}-${$._name}`,X=this._executableDir||"";if(this._scriptPath){let I;try{I=P$.realpathSync(this._scriptPath)}catch(K){I=this._scriptPath}X=V1.resolve(V1.dirname(I),X)}if(X){let I=Z(X,z);if(!I&&!$._executableFile&&this._scriptPath){let K=V1.basename(this._scriptPath,V1.extname(this._scriptPath));if(K!==this._name)I=Z(X,`${K}-${$._name}`)}z=I||z}N=G.includes(V1.extname(z));let Q;if(b.platform!=="win32")if(N)J.unshift(z),J=G4(b.execArgv).concat(J),Q=D$.spawn(b.argv[0],J,{stdio:"inherit"});else Q=D$.spawn(z,J,{stdio:"inherit"});else J.unshift(z),J=G4(b.execArgv).concat(J),Q=D$.spawn(b.execPath,J,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((K)=>{b.on(K,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(K)})});let M=this._exitCallback;Q.on("close",(I)=>{if(I=I??1,!M)b.exit(I);else M(new W$(I,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(I)=>{if(I.code==="ENOENT"){let K=X?`searched for local subcommand relative to directory '${X}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",Y=`'${z}' does not exist
15
15
  - if '${$._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16
16
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
- - ${K}`;throw Error(Y)}else if(I.code==="EACCES")throw Error(`'${z}' not executable`);if(!M)b.exit(1);else{let K=new P$(1,"commander.executeSubCommandAsync","(error)");K.nestedError=I,M(K)}}),this.runningCommand=Q}_dispatchSubcommand($,J,N){let G=this._findCommand($);if(!G)this.help({error:!0});let Z;return Z=this._chainOrCallSubCommandHook(Z,G,"preSubcommand"),Z=this._chainOrCall(Z,()=>{if(G._executableHandler)this._executeSubCommand(G,J.concat(N));else return G._parseCommand(J,N)}),Z}_dispatchHelpCommand($){if(!$)this.help();let J=this._findCommand($);if(J&&!J._executableHandler)J.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,J)=>{if($.required&&this.args[J]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(N,G,Z)=>{let z=G;if(G!==null&&N.parseArg){let X=`error: command-argument value '${G}' is invalid for argument '${N.name()}'.`;z=this._callParseArg(N,G,Z,X)}return z};this._checkNumberOfArguments();let J=[];this.registeredArguments.forEach((N,G)=>{let Z=N.defaultValue;if(N.variadic){if(G<this.args.length){if(Z=this.args.slice(G),N.parseArg)Z=Z.reduce((z,X)=>{return $(N,X,z)},N.defaultValue)}else if(Z===void 0)Z=[]}else if(G<this.args.length){if(Z=this.args[G],N.parseArg)Z=$(N,Z,N.defaultValue)}J[G]=Z}),this.processedArgs=J}_chainOrCall($,J){if($&&$.then&&typeof $.then==="function")return $.then(()=>J());return J()}_chainOrCallHooks($,J){let N=$,G=[];if(this._getCommandAndAncestors().reverse().filter((Z)=>Z._lifeCycleHooks[J]!==void 0).forEach((Z)=>{Z._lifeCycleHooks[J].forEach((z)=>{G.push({hookedCommand:Z,callback:z})})}),J==="postAction")G.reverse();return G.forEach((Z)=>{N=this._chainOrCall(N,()=>{return Z.callback(Z.hookedCommand,this)})}),N}_chainOrCallSubCommandHook($,J,N){let G=$;if(this._lifeCycleHooks[N]!==void 0)this._lifeCycleHooks[N].forEach((Z)=>{G=this._chainOrCall(G,()=>{return Z(this,J)})});return G}_parseCommand($,J){let N=this.parseOptions(J);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(N.operands),J=N.unknown,this.args=$.concat(J),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),J);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(J),this._dispatchSubcommand(this._defaultCommandName,$,J);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(N.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=()=>{if(N.unknown.length>0)this.unknownOption(N.unknown[0])},Z=`command:${this.name()}`;if(this._actionHandler){G(),this._processArguments();let z;if(z=this._chainOrCallHooks(z,"preAction"),z=this._chainOrCall(z,()=>this._actionHandler(this.processedArgs)),this.parent)z=this._chainOrCall(z,()=>{this.parent.emit(Z,$,J)});return z=this._chainOrCallHooks(z,"postAction"),z}if(this.parent&&this.parent.listenerCount(Z))G(),this._processArguments(),this.parent.emit(Z,$,J);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,J);if(this.listenerCount("command:*"))this.emit("command:*",$,J);else if(this.commands.length)this.unknownCommand();else G(),this._processArguments()}else if(this.commands.length)G(),this.help({error:!0});else G(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((J)=>J._name===$||J._aliases.includes($))}_findOption($){return this.options.find((J)=>J.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((J)=>{if(J.mandatory&&$.getOptionValue(J.attributeName())===void 0)$.missingMandatoryOptionValue(J)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((N)=>{let G=N.attributeName();if(this.getOptionValue(G)===void 0)return!1;return this.getOptionValueSource(G)!=="default"});$.filter((N)=>N.conflictsWith.length>0).forEach((N)=>{let G=$.find((Z)=>N.conflictsWith.includes(Z.attributeName()));if(G)this._conflictingOption(N,G)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let J=[],N=[],G=J,Z=$.slice();function z(Q){return Q.length>1&&Q[0]==="-"}let X=null;while(Z.length){let Q=Z.shift();if(Q==="--"){if(G===N)G.push(Q);G.push(...Z);break}if(X&&!z(Q)){this.emit(`option:${X.name()}`,Q);continue}if(X=null,z(Q)){let M=this._findOption(Q);if(M){if(M.required){let I=Z.shift();if(I===void 0)this.optionMissingArgument(M);this.emit(`option:${M.name()}`,I)}else if(M.optional){let I=null;if(Z.length>0&&!z(Z[0]))I=Z.shift();this.emit(`option:${M.name()}`,I)}else this.emit(`option:${M.name()}`);X=M.variadic?M:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let M=this._findOption(`-${Q[1]}`);if(M){if(M.required||M.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${M.name()}`,Q.slice(2));else this.emit(`option:${M.name()}`),Z.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let M=Q.indexOf("="),I=this._findOption(Q.slice(0,M));if(I&&(I.required||I.optional)){this.emit(`option:${I.name()}`,Q.slice(M+1));continue}}if(z(Q))G=N;if((this._enablePositionalOptions||this._passThroughOptions)&&J.length===0&&N.length===0){if(this._findCommand(Q)){if(J.push(Q),Z.length>0)N.push(...Z);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(J.push(Q),Z.length>0)J.push(...Z);break}else if(this._defaultCommandName){if(N.push(Q),Z.length>0)N.push(...Z);break}}if(this._passThroughOptions){if(G.push(Q),Z.length>0)G.push(...Z);break}G.push(Q)}return{operands:J,unknown:N}}opts(){if(this._storeOptionsAsProperties){let $={},J=this.options.length;for(let N=0;N<J;N++){let G=this.options[N].attributeName();$[G]=G===this._versionOptionName?this._version:this[G]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,J)=>Object.assign($,J.opts()),{})}error($,J){if(this._outputConfiguration.outputError(`${$}
17
+ - ${K}`;throw Error(Y)}else if(I.code==="EACCES")throw Error(`'${z}' not executable`);if(!M)b.exit(1);else{let K=new W$(1,"commander.executeSubCommandAsync","(error)");K.nestedError=I,M(K)}}),this.runningCommand=Q}_dispatchSubcommand($,J,N){let G=this._findCommand($);if(!G)this.help({error:!0});let Z;return Z=this._chainOrCallSubCommandHook(Z,G,"preSubcommand"),Z=this._chainOrCall(Z,()=>{if(G._executableHandler)this._executeSubCommand(G,J.concat(N));else return G._parseCommand(J,N)}),Z}_dispatchHelpCommand($){if(!$)this.help();let J=this._findCommand($);if(J&&!J._executableHandler)J.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,J)=>{if($.required&&this.args[J]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(N,G,Z)=>{let z=G;if(G!==null&&N.parseArg){let X=`error: command-argument value '${G}' is invalid for argument '${N.name()}'.`;z=this._callParseArg(N,G,Z,X)}return z};this._checkNumberOfArguments();let J=[];this.registeredArguments.forEach((N,G)=>{let Z=N.defaultValue;if(N.variadic){if(G<this.args.length){if(Z=this.args.slice(G),N.parseArg)Z=Z.reduce((z,X)=>{return $(N,X,z)},N.defaultValue)}else if(Z===void 0)Z=[]}else if(G<this.args.length){if(Z=this.args[G],N.parseArg)Z=$(N,Z,N.defaultValue)}J[G]=Z}),this.processedArgs=J}_chainOrCall($,J){if($&&$.then&&typeof $.then==="function")return $.then(()=>J());return J()}_chainOrCallHooks($,J){let N=$,G=[];if(this._getCommandAndAncestors().reverse().filter((Z)=>Z._lifeCycleHooks[J]!==void 0).forEach((Z)=>{Z._lifeCycleHooks[J].forEach((z)=>{G.push({hookedCommand:Z,callback:z})})}),J==="postAction")G.reverse();return G.forEach((Z)=>{N=this._chainOrCall(N,()=>{return Z.callback(Z.hookedCommand,this)})}),N}_chainOrCallSubCommandHook($,J,N){let G=$;if(this._lifeCycleHooks[N]!==void 0)this._lifeCycleHooks[N].forEach((Z)=>{G=this._chainOrCall(G,()=>{return Z(this,J)})});return G}_parseCommand($,J){let N=this.parseOptions(J);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(N.operands),J=N.unknown,this.args=$.concat(J),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),J);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(J),this._dispatchSubcommand(this._defaultCommandName,$,J);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(N.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=()=>{if(N.unknown.length>0)this.unknownOption(N.unknown[0])},Z=`command:${this.name()}`;if(this._actionHandler){G(),this._processArguments();let z;if(z=this._chainOrCallHooks(z,"preAction"),z=this._chainOrCall(z,()=>this._actionHandler(this.processedArgs)),this.parent)z=this._chainOrCall(z,()=>{this.parent.emit(Z,$,J)});return z=this._chainOrCallHooks(z,"postAction"),z}if(this.parent&&this.parent.listenerCount(Z))G(),this._processArguments(),this.parent.emit(Z,$,J);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,J);if(this.listenerCount("command:*"))this.emit("command:*",$,J);else if(this.commands.length)this.unknownCommand();else G(),this._processArguments()}else if(this.commands.length)G(),this.help({error:!0});else G(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((J)=>J._name===$||J._aliases.includes($))}_findOption($){return this.options.find((J)=>J.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((J)=>{if(J.mandatory&&$.getOptionValue(J.attributeName())===void 0)$.missingMandatoryOptionValue(J)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((N)=>{let G=N.attributeName();if(this.getOptionValue(G)===void 0)return!1;return this.getOptionValueSource(G)!=="default"});$.filter((N)=>N.conflictsWith.length>0).forEach((N)=>{let G=$.find((Z)=>N.conflictsWith.includes(Z.attributeName()));if(G)this._conflictingOption(N,G)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let J=[],N=[],G=J,Z=$.slice();function z(Q){return Q.length>1&&Q[0]==="-"}let X=null;while(Z.length){let Q=Z.shift();if(Q==="--"){if(G===N)G.push(Q);G.push(...Z);break}if(X&&!z(Q)){this.emit(`option:${X.name()}`,Q);continue}if(X=null,z(Q)){let M=this._findOption(Q);if(M){if(M.required){let I=Z.shift();if(I===void 0)this.optionMissingArgument(M);this.emit(`option:${M.name()}`,I)}else if(M.optional){let I=null;if(Z.length>0&&!z(Z[0]))I=Z.shift();this.emit(`option:${M.name()}`,I)}else this.emit(`option:${M.name()}`);X=M.variadic?M:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let M=this._findOption(`-${Q[1]}`);if(M){if(M.required||M.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${M.name()}`,Q.slice(2));else this.emit(`option:${M.name()}`),Z.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let M=Q.indexOf("="),I=this._findOption(Q.slice(0,M));if(I&&(I.required||I.optional)){this.emit(`option:${I.name()}`,Q.slice(M+1));continue}}if(z(Q))G=N;if((this._enablePositionalOptions||this._passThroughOptions)&&J.length===0&&N.length===0){if(this._findCommand(Q)){if(J.push(Q),Z.length>0)N.push(...Z);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(J.push(Q),Z.length>0)J.push(...Z);break}else if(this._defaultCommandName){if(N.push(Q),Z.length>0)N.push(...Z);break}}if(this._passThroughOptions){if(G.push(Q),Z.length>0)G.push(...Z);break}G.push(Q)}return{operands:J,unknown:N}}opts(){if(this._storeOptionsAsProperties){let $={},J=this.options.length;for(let N=0;N<J;N++){let G=this.options[N].attributeName();$[G]=G===this._versionOptionName?this._version:this[G]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,J)=>Object.assign($,J.opts()),{})}error($,J){if(this._outputConfiguration.outputError(`${$}
18
18
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
19
19
  `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
20
- `),this.outputHelp({error:!0});let N=J||{},G=N.exitCode||1,Z=N.code||"commander.error";this._exit(G,Z,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let J=$.attributeName();if(this.getOptionValue(J)===void 0||["default","config","env"].includes(this.getOptionValueSource(J)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new f5(this.options),J=(N)=>{return this.getOptionValue(N)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(N))};this.options.filter((N)=>N.implied!==void 0&&J(N.attributeName())&&$.valueFromOption(this.getOptionValue(N.attributeName()),N)).forEach((N)=>{Object.keys(N.implied).filter((G)=>!J(G)).forEach((G)=>{this.setOptionValueWithSource(G,N.implied[G],"implied")})})}missingArgument($){let J=`error: missing required argument '${$}'`;this.error(J,{code:"commander.missingArgument"})}optionMissingArgument($){let J=`error: option '${$.flags}' argument missing`;this.error(J,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let J=`error: required option '${$.flags}' not specified`;this.error(J,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,J){let N=(z)=>{let X=z.attributeName(),Q=this.getOptionValue(X),M=this.options.find((K)=>K.negate&&X===K.attributeName()),I=this.options.find((K)=>!K.negate&&X===K.attributeName());if(M&&(M.presetArg===void 0&&Q===!1||M.presetArg!==void 0&&Q===M.presetArg))return M;return I||z},G=(z)=>{let X=N(z),Q=X.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},Z=`error: ${G($)} cannot be used with ${G(J)}`;this.error(Z,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let J="";if($.startsWith("--")&&this._showSuggestionAfterError){let G=[],Z=this;do{let z=Z.createHelp().visibleOptions(Z).filter((X)=>X.long).map((X)=>X.long);G=G.concat(z),Z=Z.parent}while(Z&&!Z._enablePositionalOptions);J=N4($,G)}let N=`error: unknown option '${$}'${J}`;this.error(N,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let J=this.registeredArguments.length,N=J===1?"":"s",Z=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${J} argument${N} but got ${$.length}.`;this.error(Z,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],J="";if(this._showSuggestionAfterError){let G=[];this.createHelp().visibleCommands(this).forEach((Z)=>{if(G.push(Z.name()),Z.alias())G.push(Z.alias())}),J=N4($,G)}let N=`error: unknown command '${$}'${J}`;this.error(N,{code:"commander.unknownCommand"})}version($,J,N){if($===void 0)return this._version;this._version=$,J=J||"-V, --version",N=N||"output the version number";let G=this.createOption(J,N);return this._versionOptionName=G.attributeName(),this._registerOption(G),this.on("option:"+G.name(),()=>{this._outputConfiguration.writeOut(`${$}
21
- `),this._exit(0,"commander.version",$)}),this}description($,J){if($===void 0&&J===void 0)return this._description;if(this._description=$,J)this._argsDescription=J;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let J=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)J=this.commands[this.commands.length-1];if($===J._name)throw Error("Command alias can't be the same as its name");let N=this.parent?._findCommand($);if(N){let G=[N.name()].concat(N.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${G}'`)}return J._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((J)=>this.alias(J)),this}usage($){if($===void 0){if(this._usage)return this._usage;let J=this.registeredArguments.map((N)=>{return O5(N)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?J:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=T1.basename($,T1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let J=this.createHelp();if(J.helpWidth===void 0)J.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return J.formatHelp(this,J)}_getHelpContext($){$=$||{};let J={error:!!$.error},N;if(J.error)N=(G)=>this._outputConfiguration.writeErr(G);else N=(G)=>this._outputConfiguration.writeOut(G);return J.write=$.write||N,J.command=this,J}outputHelp($){let J;if(typeof $==="function")J=$,$=void 0;let N=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((Z)=>Z.emit("beforeAllHelp",N)),this.emit("beforeHelp",N);let G=this.helpInformation(N);if(J){if(G=J(G),typeof G!=="string"&&!Buffer.isBuffer(G))throw Error("outputHelp callback must return a string or a Buffer")}if(N.write(G),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",N),this._getCommandAndAncestors().forEach((Z)=>Z.emit("afterAllHelp",N))}helpOption($,J){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",J=J??"display help for command",this._helpOption=this.createOption($,J),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let J=b.exitCode||0;if(J===0&&$&&typeof $!=="function"&&$.error)J=1;this._exit(J,"commander.help","(outputHelp)")}addHelpText($,J){let N=["beforeAll","before","after","afterAll"];if(!N.includes($))throw Error(`Unexpected value for position to addHelpText.
20
+ `),this.outputHelp({error:!0});let N=J||{},G=N.exitCode||1,Z=N.code||"commander.error";this._exit(G,Z,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let J=$.attributeName();if(this.getOptionValue(J)===void 0||["default","config","env"].includes(this.getOptionValueSource(J)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new E5(this.options),J=(N)=>{return this.getOptionValue(N)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(N))};this.options.filter((N)=>N.implied!==void 0&&J(N.attributeName())&&$.valueFromOption(this.getOptionValue(N.attributeName()),N)).forEach((N)=>{Object.keys(N.implied).filter((G)=>!J(G)).forEach((G)=>{this.setOptionValueWithSource(G,N.implied[G],"implied")})})}missingArgument($){let J=`error: missing required argument '${$}'`;this.error(J,{code:"commander.missingArgument"})}optionMissingArgument($){let J=`error: option '${$.flags}' argument missing`;this.error(J,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let J=`error: required option '${$.flags}' not specified`;this.error(J,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,J){let N=(z)=>{let X=z.attributeName(),Q=this.getOptionValue(X),M=this.options.find((K)=>K.negate&&X===K.attributeName()),I=this.options.find((K)=>!K.negate&&X===K.attributeName());if(M&&(M.presetArg===void 0&&Q===!1||M.presetArg!==void 0&&Q===M.presetArg))return M;return I||z},G=(z)=>{let X=N(z),Q=X.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},Z=`error: ${G($)} cannot be used with ${G(J)}`;this.error(Z,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let J="";if($.startsWith("--")&&this._showSuggestionAfterError){let G=[],Z=this;do{let z=Z.createHelp().visibleOptions(Z).filter((X)=>X.long).map((X)=>X.long);G=G.concat(z),Z=Z.parent}while(Z&&!Z._enablePositionalOptions);J=N4($,G)}let N=`error: unknown option '${$}'${J}`;this.error(N,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let J=this.registeredArguments.length,N=J===1?"":"s",Z=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${J} argument${N} but got ${$.length}.`;this.error(Z,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],J="";if(this._showSuggestionAfterError){let G=[];this.createHelp().visibleCommands(this).forEach((Z)=>{if(G.push(Z.name()),Z.alias())G.push(Z.alias())}),J=N4($,G)}let N=`error: unknown command '${$}'${J}`;this.error(N,{code:"commander.unknownCommand"})}version($,J,N){if($===void 0)return this._version;this._version=$,J=J||"-V, --version",N=N||"output the version number";let G=this.createOption(J,N);return this._versionOptionName=G.attributeName(),this._registerOption(G),this.on("option:"+G.name(),()=>{this._outputConfiguration.writeOut(`${$}
21
+ `),this._exit(0,"commander.version",$)}),this}description($,J){if($===void 0&&J===void 0)return this._description;if(this._description=$,J)this._argsDescription=J;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let J=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)J=this.commands[this.commands.length-1];if($===J._name)throw Error("Command alias can't be the same as its name");let N=this.parent?._findCommand($);if(N){let G=[N.name()].concat(N.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${G}'`)}return J._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((J)=>this.alias(J)),this}usage($){if($===void 0){if(this._usage)return this._usage;let J=this.registeredArguments.map((N)=>{return f5(N)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?J:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=V1.basename($,V1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let J=this.createHelp();if(J.helpWidth===void 0)J.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return J.formatHelp(this,J)}_getHelpContext($){$=$||{};let J={error:!!$.error},N;if(J.error)N=(G)=>this._outputConfiguration.writeErr(G);else N=(G)=>this._outputConfiguration.writeOut(G);return J.write=$.write||N,J.command=this,J}outputHelp($){let J;if(typeof $==="function")J=$,$=void 0;let N=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((Z)=>Z.emit("beforeAllHelp",N)),this.emit("beforeHelp",N);let G=this.helpInformation(N);if(J){if(G=J(G),typeof G!=="string"&&!Buffer.isBuffer(G))throw Error("outputHelp callback must return a string or a Buffer")}if(N.write(G),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",N),this._getCommandAndAncestors().forEach((Z)=>Z.emit("afterAllHelp",N))}helpOption($,J){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",J=J??"display help for command",this._helpOption=this.createOption($,J),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let J=b.exitCode||0;if(J===0&&$&&typeof $!=="function"&&$.error)J=1;this._exit(J,"commander.help","(outputHelp)")}addHelpText($,J){let N=["beforeAll","before","after","afterAll"];if(!N.includes($))throw Error(`Unexpected value for position to addHelpText.
22
22
  Expecting one of '${N.join("', '")}'`);let G=`${$}Help`;return this.on(G,(Z)=>{let z;if(typeof J==="function")z=J({error:Z.error,command:Z.command});else z=J;if(z)Z.write(`${z}
23
- `)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((G)=>J.is(G)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function G4($){return $.map((J)=>{if(!J.startsWith("--inspect"))return J;let N,G="127.0.0.1",Z="9229",z;if((z=J.match(/^(--inspect(-brk)?)$/))!==null)N=z[1];else if((z=J.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(N=z[1],/^\d+$/.test(z[3]))Z=z[3];else G=z[3];else if((z=J.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)N=z[1],G=z[3],Z=z[4];if(N&&Z!=="0")return`${N}=${G}:${parseInt(Z)+1}`;return J})}y5.Command=S$});var M4=u((u5)=>{var{Argument:z4}=W0(),{Command:W$}=Z4(),{CommanderError:w5,InvalidArgumentError:X4}=N0(),{Help:v5}=C$(),{Option:Q4}=L$();u5.program=new W$;u5.createCommand=($)=>new W$($);u5.createOption=($,J)=>new Q4($,J);u5.createArgument=($,J)=>new z4($,J);u5.Command=W$;u5.Option=Q4;u5.Argument=z4;u5.Help=v5;u5.CommanderError=w5;u5.InvalidArgumentError=X4;u5.InvalidOptionArgumentError=X4});var N1=u((ON,F$)=>{var O0=process||{},K4=O0.argv||[],F0=O0.env||{},o5=!(!!F0.NO_COLOR||K4.includes("--no-color"))&&(!!F0.FORCE_COLOR||K4.includes("--color")||O0.platform==="win32"||(O0.stdout||{}).isTTY&&F0.TERM!=="dumb"||!!F0.CI),r5=($,J,N=$)=>(G)=>{let Z=""+G,z=Z.indexOf(J,$.length);return~z?$+a5(Z,J,N,z)+J:$+Z+J},a5=($,J,N,G)=>{let Z="",z=0;do Z+=$.substring(z,G)+N,z=G+J.length,G=$.indexOf(J,z);while(~G);return Z+$.substring(z)},j4=($=o5)=>{let J=$?r5:()=>String;return{isColorSupported:$,reset:J("\x1B[0m","\x1B[0m"),bold:J("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:J("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:J("\x1B[3m","\x1B[23m"),underline:J("\x1B[4m","\x1B[24m"),inverse:J("\x1B[7m","\x1B[27m"),hidden:J("\x1B[8m","\x1B[28m"),strikethrough:J("\x1B[9m","\x1B[29m"),black:J("\x1B[30m","\x1B[39m"),red:J("\x1B[31m","\x1B[39m"),green:J("\x1B[32m","\x1B[39m"),yellow:J("\x1B[33m","\x1B[39m"),blue:J("\x1B[34m","\x1B[39m"),magenta:J("\x1B[35m","\x1B[39m"),cyan:J("\x1B[36m","\x1B[39m"),white:J("\x1B[37m","\x1B[39m"),gray:J("\x1B[90m","\x1B[39m"),bgBlack:J("\x1B[40m","\x1B[49m"),bgRed:J("\x1B[41m","\x1B[49m"),bgGreen:J("\x1B[42m","\x1B[49m"),bgYellow:J("\x1B[43m","\x1B[49m"),bgBlue:J("\x1B[44m","\x1B[49m"),bgMagenta:J("\x1B[45m","\x1B[49m"),bgCyan:J("\x1B[46m","\x1B[49m"),bgWhite:J("\x1B[47m","\x1B[49m"),blackBright:J("\x1B[90m","\x1B[39m"),redBright:J("\x1B[91m","\x1B[39m"),greenBright:J("\x1B[92m","\x1B[39m"),yellowBright:J("\x1B[93m","\x1B[39m"),blueBright:J("\x1B[94m","\x1B[39m"),magentaBright:J("\x1B[95m","\x1B[39m"),cyanBright:J("\x1B[96m","\x1B[39m"),whiteBright:J("\x1B[97m","\x1B[39m"),bgBlackBright:J("\x1B[100m","\x1B[49m"),bgRedBright:J("\x1B[101m","\x1B[49m"),bgGreenBright:J("\x1B[102m","\x1B[49m"),bgYellowBright:J("\x1B[103m","\x1B[49m"),bgBlueBright:J("\x1B[104m","\x1B[49m"),bgMagentaBright:J("\x1B[105m","\x1B[49m"),bgCyanBright:J("\x1B[106m","\x1B[49m"),bgWhiteBright:J("\x1B[107m","\x1B[49m")}};F$.exports=j4();F$.exports.createColors=j4});var f$=u((lN,U4)=>{var g$={to($,J){if(!J)return`\x1B[${$+1}G`;return`\x1B[${J+1};${$+1}H`},move($,J){let N="";if($<0)N+=`\x1B[${-$}D`;else if($>0)N+=`\x1B[${$}C`;if(J<0)N+=`\x1B[${-J}A`;else if(J>0)N+=`\x1B[${J}B`;return N},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},G6={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},Z6={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let J="";for(let N=0;N<$;N++)J+=this.line+(N<$-1?g$.up():"");if($)J+=g$.left;return J}};U4.exports={cursor:g$,scroll:G6,erase:Z6,beep:"\x07"}});var _1=u((JZ,o8)=>{var p8=["nodebuffer","arraybuffer","fragments"],s8=typeof Blob<"u";if(s8)p8.push("blob");o8.exports={BINARY_TYPES:p8,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:s8,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var R0=u((NZ,I$)=>{var{EMPTY_BUFFER:H7}=_1(),S2=Buffer[Symbol.species];function R7($,J){if($.length===0)return H7;if($.length===1)return $[0];let N=Buffer.allocUnsafe(J),G=0;for(let Z=0;Z<$.length;Z++){let z=$[Z];N.set(z,G),G+=z.length}if(G<J)return new S2(N.buffer,N.byteOffset,G);return N}function r8($,J,N,G,Z){for(let z=0;z<Z;z++)N[G+z]=$[z]^J[z&3]}function a8($,J){for(let N=0;N<$.length;N++)$[N]^=J[N&3]}function q7($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function W2($){if(W2.readOnly=!0,Buffer.isBuffer($))return $;let J;if($ instanceof ArrayBuffer)J=new S2($);else if(ArrayBuffer.isView($))J=new S2($.buffer,$.byteOffset,$.byteLength);else J=Buffer.from($),W2.readOnly=!1;return J}I$.exports={concat:R7,mask:r8,toArrayBuffer:q7,toBuffer:W2,unmask:a8};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();I$.exports.mask=function(J,N,G,Z,z){if(z<48)r8(J,N,G,Z,z);else $.mask(J,N,G,Z,z)},I$.exports.unmask=function(J,N){if(J.length<32)a8(J,N);else $.unmask(J,N)}}catch($){}});var J3=u((GZ,$3)=>{var t8=Symbol("kDone"),F2=Symbol("kRun");class e8{constructor($){this[t8]=()=>{this.pending--,this[F2]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[F2]()}[F2](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[t8])}}}$3.exports=e8});var U0=u((ZZ,X3)=>{var q0=f("zlib"),N3=R0(),U7=J3(),{kStatusCode:G3}=_1(),B7=Buffer[Symbol.species],T7=Buffer.from([0,0,255,255]),K$=Symbol("permessage-deflate"),C1=Symbol("total-length"),s1=Symbol("callback"),S1=Symbol("buffers"),o1=Symbol("error"),Y$;class Z3{constructor($,J,N){if(this._maxPayload=N|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!J,this._deflate=null,this._inflate=null,this.params=null,!Y$){let G=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Y$=new U7(G)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[s1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let J=this._options,N=$.find((G)=>{if(J.serverNoContextTakeover===!1&&G.server_no_context_takeover||G.server_max_window_bits&&(J.serverMaxWindowBits===!1||typeof J.serverMaxWindowBits==="number"&&J.serverMaxWindowBits>G.server_max_window_bits)||typeof J.clientMaxWindowBits==="number"&&!G.client_max_window_bits)return!1;return!0});if(!N)throw Error("None of the extension offers can be accepted");if(J.serverNoContextTakeover)N.server_no_context_takeover=!0;if(J.clientNoContextTakeover)N.client_no_context_takeover=!0;if(typeof J.serverMaxWindowBits==="number")N.server_max_window_bits=J.serverMaxWindowBits;if(typeof J.clientMaxWindowBits==="number")N.client_max_window_bits=J.clientMaxWindowBits;else if(N.client_max_window_bits===!0||J.clientMaxWindowBits===!1)delete N.client_max_window_bits;return N}acceptAsClient($){let J=$[0];if(this._options.clientNoContextTakeover===!1&&J.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!J.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")J.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&J.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return J}normalizeParams($){return $.forEach((J)=>{Object.keys(J).forEach((N)=>{let G=J[N];if(G.length>1)throw Error(`Parameter "${N}" must have only a single value`);if(G=G[0],N==="client_max_window_bits"){if(G!==!0){let Z=+G;if(!Number.isInteger(Z)||Z<8||Z>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=Z}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else if(N==="server_max_window_bits"){let Z=+G;if(!Number.isInteger(Z)||Z<8||Z>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=Z}else if(N==="client_no_context_takeover"||N==="server_no_context_takeover"){if(G!==!0)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else throw Error(`Unknown parameter "${N}"`);J[N]=G})}),$}decompress($,J,N){Y$.add((G)=>{this._decompress($,J,(Z,z)=>{G(),N(Z,z)})})}compress($,J,N){Y$.add((G)=>{this._compress($,J,(Z,z)=>{G(),N(Z,z)})})}_decompress($,J,N){let G=this._isServer?"client":"server";if(!this._inflate){let Z=`${G}_max_window_bits`,z=typeof this.params[Z]!=="number"?q0.Z_DEFAULT_WINDOWBITS:this.params[Z];this._inflate=q0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:z}),this._inflate[K$]=this,this._inflate[C1]=0,this._inflate[S1]=[],this._inflate.on("error",_7),this._inflate.on("data",z3)}if(this._inflate[s1]=N,this._inflate.write($),J)this._inflate.write(T7);this._inflate.flush(()=>{let Z=this._inflate[o1];if(Z){this._inflate.close(),this._inflate=null,N(Z);return}let z=N3.concat(this._inflate[S1],this._inflate[C1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[C1]=0,this._inflate[S1]=[],J&&this.params[`${G}_no_context_takeover`])this._inflate.reset();N(null,z)})}_compress($,J,N){let G=this._isServer?"server":"client";if(!this._deflate){let Z=`${G}_max_window_bits`,z=typeof this.params[Z]!=="number"?q0.Z_DEFAULT_WINDOWBITS:this.params[Z];this._deflate=q0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:z}),this._deflate[C1]=0,this._deflate[S1]=[],this._deflate.on("data",V7)}this._deflate[s1]=N,this._deflate.write($),this._deflate.flush(q0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let Z=N3.concat(this._deflate[S1],this._deflate[C1]);if(J)Z=new B7(Z.buffer,Z.byteOffset,Z.length-4);if(this._deflate[s1]=null,this._deflate[C1]=0,this._deflate[S1]=[],J&&this.params[`${G}_no_context_takeover`])this._deflate.reset();N(null,Z)})}}X3.exports=Z3;function V7($){this[S1].push($),this[C1]+=$.length}function z3($){if(this[C1]+=$.length,this[K$]._maxPayload<1||this[C1]<=this[K$]._maxPayload){this[S1].push($);return}this[o1]=RangeError("Max payload size exceeded"),this[o1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[o1][G3]=1009,this.removeListener("data",z3),this.reset()}function _7($){if(this[K$]._inflate=null,this[o1]){this[s1](this[o1]);return}$[G3]=1007,this[s1]($)}});var r1=u((zZ,j$)=>{var{isUtf8:Q3}=f("buffer"),{hasBlob:C7}=_1(),L7=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function A7($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function O2($){let J=$.length,N=0;while(N<J)if(($[N]&128)===0)N++;else if(($[N]&224)===192){if(N+1===J||($[N+1]&192)!==128||($[N]&254)===192)return!1;N+=2}else if(($[N]&240)===224){if(N+2>=J||($[N+1]&192)!==128||($[N+2]&192)!==128||$[N]===224&&($[N+1]&224)===128||$[N]===237&&($[N+1]&224)===160)return!1;N+=3}else if(($[N]&248)===240){if(N+3>=J||($[N+1]&192)!==128||($[N+2]&192)!==128||($[N+3]&192)!==128||$[N]===240&&($[N+1]&240)===128||$[N]===244&&$[N+1]>143||$[N]>244)return!1;N+=4}else return!1;return!0}function D7($){return C7&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}j$.exports={isBlob:D7,isValidStatusCode:A7,isValidUTF8:O2,tokenChars:L7};if(Q3)j$.exports.isValidUTF8=function($){return $.length<24?O2($):Q3($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();j$.exports.isValidUTF8=function(J){return J.length<32?O2(J):$(J)}}catch($){}});var f2=u((XZ,j3)=>{var{Writable:P7}=f("stream"),M3=U0(),{BINARY_TYPES:S7,EMPTY_BUFFER:I3,kStatusCode:W7,kWebSocket:F7}=_1(),{concat:g2,toArrayBuffer:O7,unmask:g7}=R0(),{isValidStatusCode:f7,isValidUTF8:Y3}=r1(),x$=Buffer[Symbol.species];class K3 extends P7{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||S7[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[F7]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,J,N){if(this._opcode===8&&this._state==0)return N();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(N)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let N=this._buffers[0];return this._buffers[0]=new x$(N.buffer,N.byteOffset+$,N.length-$),new x$(N.buffer,N.byteOffset,$)}let J=Buffer.allocUnsafe($);do{let N=this._buffers[0],G=J.length-$;if($>=N.length)J.set(this._buffers.shift(),G);else J.set(new Uint8Array(N.buffer,N.byteOffset,$),G),this._buffers[0]=new x$(N.buffer,N.byteOffset+$,N.length-$);$-=N.length}while($>0);return J}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let J=this.consume(2);if((J[0]&48)!==0){let G=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(G);return}let N=(J[0]&64)===64;if(N&&!this._extensions[M3.extensionName]){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._fin=(J[0]&128)===128,this._opcode=J[0]&15,this._payloadLength=J[1]&127,this._opcode===0){if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(!this._fragmented){let G=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._compressed=N}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let G=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(G);return}if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let G=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(G);return}}else{let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(J[1]&128)===128,this._isServer){if(!this._masked){let G=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(G);return}}else if(this._masked){let G=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(G);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let J=this.consume(8),N=J.readUInt32BE(0);if(N>Math.pow(2,21)-1){let G=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(G);return}this._payloadLength=N*Math.pow(2,32)+J.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let J=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(J);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let J=I3;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(J=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)g7(J,this._mask)}if(this._opcode>7){this.controlMessage(J,$);return}if(this._compressed){this._state=5,this.decompress(J,$);return}if(J.length)this._messageLength=this._totalPayloadLength,this._fragments.push(J);this.dataMessage($)}decompress($,J){this._extensions[M3.extensionName].decompress($,this._fin,(G,Z)=>{if(G)return J(G);if(Z.length){if(this._messageLength+=Z.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");J(z);return}this._fragments.push(Z)}if(this.dataMessage(J),this._state===0)this.startLoop(J)})}dataMessage($){if(!this._fin){this._state=0;return}let J=this._messageLength,N=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let G;if(this._binaryType==="nodebuffer")G=g2(N,J);else if(this._binaryType==="arraybuffer")G=O7(g2(N,J));else if(this._binaryType==="blob")G=new Blob(N);else G=N;if(this._allowSynchronousEvents)this.emit("message",G,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!0),this._state=0,this.startLoop($)})}else{let G=g2(N,J);if(!this._skipUTF8Validation&&!Y3(G)){let Z=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(Z);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",G,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!1),this._state=0,this.startLoop($)})}}controlMessage($,J){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,I3),this.end();else{let N=$.readUInt16BE(0);if(!f7(N)){let Z=this.createError(RangeError,`invalid status code ${N}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");J(Z);return}let G=new x$($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!Y3(G)){let Z=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");J(Z);return}this._loop=!1,this.emit("conclude",N,G),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(J)})}createError($,J,N,G,Z){this._loop=!1,this._errored=!0;let z=new $(N?`Invalid WebSocket frame: ${J}`:J);return Error.captureStackTrace(z,this.createError),z.code=Z,z[W7]=G,z}}j3.exports=K3});var E2=u((MZ,R3)=>{var{Duplex:QZ}=f("stream"),{randomFillSync:y7}=f("crypto"),x3=U0(),{EMPTY_BUFFER:E7,kWebSocket:w7,NOOP:v7}=_1(),{isBlob:a1,isValidStatusCode:u7}=r1(),{mask:H3,toBuffer:b1}=R0(),z1=Symbol("kByteLength"),b7=Buffer.alloc(4),l1,t1=8192,K1=0,l7=1,k7=2;class W1{constructor($,J,N){if(this._extensions=J||{},N)this._generateMask=N,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=K1,this.onerror=v7,this[w7]=void 0}static frame($,J){let N,G=!1,Z=2,z=!1;if(J.mask){if(N=J.maskBuffer||b7,J.generateMask)J.generateMask(N);else{if(t1===8192){if(l1===void 0)l1=Buffer.alloc(8192);y7(l1,0,8192),t1=0}N[0]=l1[t1++],N[1]=l1[t1++],N[2]=l1[t1++],N[3]=l1[t1++]}z=(N[0]|N[1]|N[2]|N[3])===0,Z=6}let X;if(typeof $==="string")if((!J.mask||z)&&J[z1]!==void 0)X=J[z1];else $=Buffer.from($),X=$.length;else X=$.length,G=J.mask&&J.readOnly&&!z;let Q=X;if(X>=65536)Z+=8,Q=127;else if(X>125)Z+=2,Q=126;let M=Buffer.allocUnsafe(G?X+Z:Z);if(M[0]=J.fin?J.opcode|128:J.opcode,J.rsv1)M[0]|=64;if(M[1]=Q,Q===126)M.writeUInt16BE(X,2);else if(Q===127)M[2]=M[3]=0,M.writeUIntBE(X,4,6);if(!J.mask)return[M,$];if(M[1]|=128,M[Z-4]=N[0],M[Z-3]=N[1],M[Z-2]=N[2],M[Z-1]=N[3],z)return[M,$];if(G)return H3($,N,M,Z,X),[M];return H3($,N,$,0,X),[M,$]}close($,J,N,G){let Z;if($===void 0)Z=E7;else if(typeof $!=="number"||!u7($))throw TypeError("First argument must be a valid error code number");else if(J===void 0||!J.length)Z=Buffer.allocUnsafe(2),Z.writeUInt16BE($,0);else{let X=Buffer.byteLength(J);if(X>123)throw RangeError("The message must not be greater than 123 bytes");if(Z=Buffer.allocUnsafe(2+X),Z.writeUInt16BE($,0),typeof J==="string")Z.write(J,2);else Z.set(J,2)}let z={[z1]:Z.length,fin:!0,generateMask:this._generateMask,mask:N,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==K1)this.enqueue([this.dispatch,Z,!1,z,G]);else this.sendFrame(W1.frame(Z,z),G)}ping($,J,N){let G,Z;if(typeof $==="string")G=Buffer.byteLength($),Z=!1;else if(a1($))G=$.size,Z=!1;else $=b1($),G=$.length,Z=b1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[z1]:G,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:9,readOnly:Z,rsv1:!1};if(a1($))if(this._state!==K1)this.enqueue([this.getBlobData,$,!1,z,N]);else this.getBlobData($,!1,z,N);else if(this._state!==K1)this.enqueue([this.dispatch,$,!1,z,N]);else this.sendFrame(W1.frame($,z),N)}pong($,J,N){let G,Z;if(typeof $==="string")G=Buffer.byteLength($),Z=!1;else if(a1($))G=$.size,Z=!1;else $=b1($),G=$.length,Z=b1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[z1]:G,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:10,readOnly:Z,rsv1:!1};if(a1($))if(this._state!==K1)this.enqueue([this.getBlobData,$,!1,z,N]);else this.getBlobData($,!1,z,N);else if(this._state!==K1)this.enqueue([this.dispatch,$,!1,z,N]);else this.sendFrame(W1.frame($,z),N)}send($,J,N){let G=this._extensions[x3.extensionName],Z=J.binary?2:1,z=J.compress,X,Q;if(typeof $==="string")X=Buffer.byteLength($),Q=!1;else if(a1($))X=$.size,Q=!1;else $=b1($),X=$.length,Q=b1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,z&&G&&G.params[G._isServer?"server_no_context_takeover":"client_no_context_takeover"])z=X>=G._threshold;this._compress=z}else z=!1,Z=0;if(J.fin)this._firstFragment=!0;let M={[z1]:X,fin:J.fin,generateMask:this._generateMask,mask:J.mask,maskBuffer:this._maskBuffer,opcode:Z,readOnly:Q,rsv1:z};if(a1($))if(this._state!==K1)this.enqueue([this.getBlobData,$,this._compress,M,N]);else this.getBlobData($,this._compress,M,N);else if(this._state!==K1)this.enqueue([this.dispatch,$,this._compress,M,N]);else this.dispatch($,this._compress,M,N)}getBlobData($,J,N,G){this._bufferedBytes+=N[z1],this._state=k7,$.arrayBuffer().then((Z)=>{if(this._socket.destroyed){let X=Error("The socket was closed while the blob was being read");process.nextTick(y2,this,X,G);return}this._bufferedBytes-=N[z1];let z=b1(Z);if(!J)this._state=K1,this.sendFrame(W1.frame(z,N),G),this.dequeue();else this.dispatch(z,J,N,G)}).catch((Z)=>{process.nextTick(m7,this,Z,G)})}dispatch($,J,N,G){if(!J){this.sendFrame(W1.frame($,N),G);return}let Z=this._extensions[x3.extensionName];this._bufferedBytes+=N[z1],this._state=l7,Z.compress($,N.fin,(z,X)=>{if(this._socket.destroyed){let Q=Error("The socket was closed while data was being compressed");y2(this,Q,G);return}this._bufferedBytes-=N[z1],this._state=K1,N.readOnly=!1,this.sendFrame(W1.frame(X,N),G),this.dequeue()})}dequeue(){while(this._state===K1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][z1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][z1],this._queue.push($)}sendFrame($,J){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],J),this._socket.uncork();else this._socket.write($[0],J)}}R3.exports=W1;function y2($,J,N){if(typeof N==="function")N(J);for(let G=0;G<$._queue.length;G++){let Z=$._queue[G],z=Z[Z.length-1];if(typeof z==="function")z(J)}}function m7($,J,N){y2($,J,N),$.onerror(J)}});var A3=u((IZ,L3)=>{var{kForOnEventAttribute:B0,kListener:w2}=_1(),q3=Symbol("kCode"),U3=Symbol("kData"),B3=Symbol("kError"),T3=Symbol("kMessage"),V3=Symbol("kReason"),e1=Symbol("kTarget"),_3=Symbol("kType"),C3=Symbol("kWasClean");class F1{constructor($){this[e1]=null,this[_3]=$}get target(){return this[e1]}get type(){return this[_3]}}Object.defineProperty(F1.prototype,"target",{enumerable:!0});Object.defineProperty(F1.prototype,"type",{enumerable:!0});class $0 extends F1{constructor($,J={}){super($);this[q3]=J.code===void 0?0:J.code,this[V3]=J.reason===void 0?"":J.reason,this[C3]=J.wasClean===void 0?!1:J.wasClean}get code(){return this[q3]}get reason(){return this[V3]}get wasClean(){return this[C3]}}Object.defineProperty($0.prototype,"code",{enumerable:!0});Object.defineProperty($0.prototype,"reason",{enumerable:!0});Object.defineProperty($0.prototype,"wasClean",{enumerable:!0});class T0 extends F1{constructor($,J={}){super($);this[B3]=J.error===void 0?null:J.error,this[T3]=J.message===void 0?"":J.message}get error(){return this[B3]}get message(){return this[T3]}}Object.defineProperty(T0.prototype,"error",{enumerable:!0});Object.defineProperty(T0.prototype,"message",{enumerable:!0});class R$ extends F1{constructor($,J={}){super($);this[U3]=J.data===void 0?null:J.data}get data(){return this[U3]}}Object.defineProperty(R$.prototype,"data",{enumerable:!0});var h7={addEventListener($,J,N={}){for(let Z of this.listeners($))if(!N[B0]&&Z[w2]===J&&!Z[B0])return;let G;if($==="message")G=function(z,X){let Q=new R$("message",{data:X?z:z.toString()});Q[e1]=this,H$(J,this,Q)};else if($==="close")G=function(z,X){let Q=new $0("close",{code:z,reason:X.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});Q[e1]=this,H$(J,this,Q)};else if($==="error")G=function(z){let X=new T0("error",{error:z,message:z.message});X[e1]=this,H$(J,this,X)};else if($==="open")G=function(){let z=new F1("open");z[e1]=this,H$(J,this,z)};else return;if(G[B0]=!!N[B0],G[w2]=J,N.once)this.once($,G);else this.on($,G)},removeEventListener($,J){for(let N of this.listeners($))if(N[w2]===J&&!N[B0]){this.removeListener($,N);break}}};L3.exports={CloseEvent:$0,ErrorEvent:T0,Event:F1,EventTarget:h7,MessageEvent:R$};function H$($,J,N){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,N);else $.call(J,N)}});var v2=u((YZ,D3)=>{var{tokenChars:V0}=r1();function q1($,J,N){if($[J]===void 0)$[J]=[N];else $[J].push(N)}function c7($){let J=Object.create(null),N=Object.create(null),G=!1,Z=!1,z=!1,X,Q,M=-1,I=-1,K=-1,Y=0;for(;Y<$.length;Y++)if(I=$.charCodeAt(Y),X===void 0)if(K===-1&&V0[I]===1){if(M===-1)M=Y}else if(Y!==0&&(I===32||I===9)){if(K===-1&&M!==-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;let R=$.slice(M,K);if(I===44)q1(J,R,N),N=Object.create(null);else X=R;M=K=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);else if(Q===void 0)if(K===-1&&V0[I]===1){if(M===-1)M=Y}else if(I===32||I===9){if(K===-1&&M!==-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;if(q1(N,$.slice(M,K),!0),I===44)q1(J,X,N),N=Object.create(null),X=void 0;M=K=-1}else if(I===61&&M!==-1&&K===-1)Q=$.slice(M,Y),M=K=-1;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(Z){if(V0[I]!==1)throw SyntaxError(`Unexpected character at index ${Y}`);if(M===-1)M=Y;else if(!G)G=!0;Z=!1}else if(z)if(V0[I]===1){if(M===-1)M=Y}else if(I===34&&M!==-1)z=!1,K=Y;else if(I===92)Z=!0;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(I===34&&$.charCodeAt(Y-1)===61)z=!0;else if(K===-1&&V0[I]===1){if(M===-1)M=Y}else if(M!==-1&&(I===32||I===9)){if(K===-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;let R=$.slice(M,K);if(G)R=R.replace(/\\/g,""),G=!1;if(q1(N,Q,R),I===44)q1(J,X,N),N=Object.create(null),X=void 0;Q=void 0,M=K=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);if(M===-1||z||I===32||I===9)throw SyntaxError("Unexpected end of input");if(K===-1)K=Y;let H=$.slice(M,K);if(X===void 0)q1(J,H,N);else{if(Q===void 0)q1(N,H,!0);else if(G)q1(N,Q,H.replace(/\\/g,""));else q1(N,Q,H);q1(J,X,N)}return J}function d7($){return Object.keys($).map((J)=>{let N=$[J];if(!Array.isArray(N))N=[N];return N.map((G)=>{return[J].concat(Object.keys(G).map((Z)=>{let z=G[Z];if(!Array.isArray(z))z=[z];return z.map((X)=>X===!0?Z:`${Z}=${X}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}D3.exports={format:d7,parse:c7}});var T$=u((xZ,u3)=>{var i7=f("events"),n7=f("https"),p7=f("http"),W3=f("net"),s7=f("tls"),{randomBytes:o7,createHash:r7}=f("crypto"),{Duplex:KZ,Readable:jZ}=f("stream"),{URL:u2}=f("url"),O1=U0(),a7=f2(),t7=E2(),{isBlob:e7}=r1(),{BINARY_TYPES:P3,CLOSE_TIMEOUT:$J,EMPTY_BUFFER:q$,GUID:JJ,kForOnEventAttribute:b2,kListener:NJ,kStatusCode:GJ,kWebSocket:h,NOOP:F3}=_1(),{EventTarget:{addEventListener:ZJ,removeEventListener:zJ}}=A3(),{format:XJ,parse:QJ}=v2(),{toBuffer:MJ}=R0(),O3=Symbol("kAborted"),l2=[8,13],L1=["CONNECTING","OPEN","CLOSING","CLOSED"],IJ=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class P extends i7{constructor($,J,N){super();if(this._binaryType=P3[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=q$,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=P.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,J===void 0)J=[];else if(!Array.isArray(J))if(typeof J==="object"&&J!==null)N=J,J=[];else J=[J];g3(this,$,J,N)}else this._autoPong=N.autoPong,this._closeTimeout=N.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!P3.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,J,N){let G=new a7({allowSynchronousEvents:N.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:N.maxPayload,skipUTF8Validation:N.skipUTF8Validation}),Z=new t7($,this._extensions,N.generateMask);if(this._receiver=G,this._sender=Z,this._socket=$,G[h]=this,Z[h]=this,$[h]=this,G.on("conclude",jJ),G.on("drain",xJ),G.on("error",HJ),G.on("message",RJ),G.on("ping",qJ),G.on("pong",UJ),Z.onerror=BJ,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(J.length>0)$.unshift(J);$.on("close",E3),$.on("data",B$),$.on("end",w3),$.on("error",v3),this._readyState=P.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=P.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[O1.extensionName])this._extensions[O1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=P.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,J){if(this.readyState===P.CLOSED)return;if(this.readyState===P.CONNECTING){$1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===P.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=P.CLOSING,this._sender.close($,J,!this._isServer,(N)=>{if(N)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),y3(this)}pause(){if(this.readyState===P.CONNECTING||this.readyState===P.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=J=void 0;else if(typeof J==="function")N=J,J=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}if(J===void 0)J=!this._isServer;this._sender.ping($||q$,J,N)}pong($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=J=void 0;else if(typeof J==="function")N=J,J=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}if(J===void 0)J=!this._isServer;this._sender.pong($||q$,J,N)}resume(){if(this.readyState===P.CONNECTING||this.readyState===P.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")N=J,J={};if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}let G={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...J};if(!this._extensions[O1.extensionName])G.compress=!1;this._sender.send($||q$,G,N)}terminate(){if(this.readyState===P.CLOSED)return;if(this.readyState===P.CONNECTING){$1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=P.CLOSING,this._socket.destroy()}}Object.defineProperty(P,"CONNECTING",{enumerable:!0,value:L1.indexOf("CONNECTING")});Object.defineProperty(P.prototype,"CONNECTING",{enumerable:!0,value:L1.indexOf("CONNECTING")});Object.defineProperty(P,"OPEN",{enumerable:!0,value:L1.indexOf("OPEN")});Object.defineProperty(P.prototype,"OPEN",{enumerable:!0,value:L1.indexOf("OPEN")});Object.defineProperty(P,"CLOSING",{enumerable:!0,value:L1.indexOf("CLOSING")});Object.defineProperty(P.prototype,"CLOSING",{enumerable:!0,value:L1.indexOf("CLOSING")});Object.defineProperty(P,"CLOSED",{enumerable:!0,value:L1.indexOf("CLOSED")});Object.defineProperty(P.prototype,"CLOSED",{enumerable:!0,value:L1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(P.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(P.prototype,`on${$}`,{enumerable:!0,get(){for(let J of this.listeners($))if(J[b2])return J[NJ];return null},set(J){for(let N of this.listeners($))if(N[b2]){this.removeListener($,N);break}if(typeof J!=="function")return;this.addEventListener($,J,{[b2]:!0})}})});P.prototype.addEventListener=ZJ;P.prototype.removeEventListener=zJ;u3.exports=P;function g3($,J,N,G){let Z={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:$J,protocolVersion:l2[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...G,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=Z.autoPong,$._closeTimeout=Z.closeTimeout,!l2.includes(Z.protocolVersion))throw RangeError(`Unsupported protocol version: ${Z.protocolVersion} (supported versions: ${l2.join(", ")})`);let z;if(J instanceof u2)z=J;else try{z=new u2(J)}catch(j){throw SyntaxError(`Invalid URL: ${J}`)}if(z.protocol==="http:")z.protocol="ws:";else if(z.protocol==="https:")z.protocol="wss:";$._url=z.href;let X=z.protocol==="wss:",Q=z.protocol==="ws+unix:",M;if(z.protocol!=="ws:"&&!X&&!Q)M=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(Q&&!z.pathname)M="The URL's pathname is empty";else if(z.hash)M="The URL contains a fragment identifier";if(M){let j=SyntaxError(M);if($._redirects===0)throw j;else{U$($,j);return}}let I=X?443:80,K=o7(16).toString("base64"),Y=X?n7.request:p7.request,H=new Set,R;if(Z.createConnection=Z.createConnection||(X?KJ:YJ),Z.defaultPort=Z.defaultPort||I,Z.port=z.port||I,Z.host=z.hostname.startsWith("[")?z.hostname.slice(1,-1):z.hostname,Z.headers={...Z.headers,"Sec-WebSocket-Version":Z.protocolVersion,"Sec-WebSocket-Key":K,Connection:"Upgrade",Upgrade:"websocket"},Z.path=z.pathname+z.search,Z.timeout=Z.handshakeTimeout,Z.perMessageDeflate)R=new O1(Z.perMessageDeflate!==!0?Z.perMessageDeflate:{},!1,Z.maxPayload),Z.headers["Sec-WebSocket-Extensions"]=XJ({[O1.extensionName]:R.offer()});if(N.length){for(let j of N){if(typeof j!=="string"||!IJ.test(j)||H.has(j))throw SyntaxError("An invalid or duplicated subprotocol was specified");H.add(j)}Z.headers["Sec-WebSocket-Protocol"]=N.join(",")}if(Z.origin)if(Z.protocolVersion<13)Z.headers["Sec-WebSocket-Origin"]=Z.origin;else Z.headers.Origin=Z.origin;if(z.username||z.password)Z.auth=`${z.username}:${z.password}`;if(Q){let j=Z.path.split(":");Z.socketPath=j[0],Z.path=j[1]}let x;if(Z.followRedirects){if($._redirects===0){$._originalIpc=Q,$._originalSecure=X,$._originalHostOrSocketPath=Q?Z.socketPath:z.host;let j=G&&G.headers;if(G={...G,headers:{}},j)for(let[U,T]of Object.entries(j))G.headers[U.toLowerCase()]=T}else if($.listenerCount("redirect")===0){let j=Q?$._originalIpc?Z.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:z.host===$._originalHostOrSocketPath;if(!j||$._originalSecure&&!X){if(delete Z.headers.authorization,delete Z.headers.cookie,!j)delete Z.headers.host;Z.auth=void 0}}if(Z.auth&&!G.headers.authorization)G.headers.authorization="Basic "+Buffer.from(Z.auth).toString("base64");if(x=$._req=Y(Z),$._redirects)$.emit("redirect",$.url,x)}else x=$._req=Y(Z);if(Z.timeout)x.on("timeout",()=>{$1($,x,"Opening handshake has timed out")});if(x.on("error",(j)=>{if(x===null||x[O3])return;x=$._req=null,U$($,j)}),x.on("response",(j)=>{let U=j.headers.location,T=j.statusCode;if(U&&Z.followRedirects&&T>=300&&T<400){if(++$._redirects>Z.maxRedirects){$1($,x,"Maximum redirects exceeded");return}x.abort();let B;try{B=new u2(U,J)}catch(_){let A=SyntaxError(`Invalid URL: ${U}`);U$($,A);return}g3($,B,N,G)}else if(!$.emit("unexpected-response",x,j))$1($,x,`Unexpected server response: ${j.statusCode}`)}),x.on("upgrade",(j,U,T)=>{if($.emit("upgrade",j),$.readyState!==P.CONNECTING)return;x=$._req=null;let B=j.headers.upgrade;if(B===void 0||B.toLowerCase()!=="websocket"){$1($,U,"Invalid Upgrade header");return}let _=r7("sha1").update(K+JJ).digest("base64");if(j.headers["sec-websocket-accept"]!==_){$1($,U,"Invalid Sec-WebSocket-Accept header");return}let A=j.headers["sec-websocket-protocol"],L;if(A!==void 0){if(!H.size)L="Server sent a subprotocol but none was requested";else if(!H.has(A))L="Server sent an invalid subprotocol"}else if(H.size)L="Server sent no subprotocol";if(L){$1($,U,L);return}if(A)$._protocol=A;let D=j.headers["sec-websocket-extensions"];if(D!==void 0){if(!R){$1($,U,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let V;try{V=QJ(D)}catch(l){$1($,U,"Invalid Sec-WebSocket-Extensions header");return}let C=Object.keys(V);if(C.length!==1||C[0]!==O1.extensionName){$1($,U,"Server indicated an extension that was not requested");return}try{R.accept(V[O1.extensionName])}catch(l){$1($,U,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[O1.extensionName]=R}$.setSocket(U,T,{allowSynchronousEvents:Z.allowSynchronousEvents,generateMask:Z.generateMask,maxPayload:Z.maxPayload,skipUTF8Validation:Z.skipUTF8Validation})}),Z.finishRequest)Z.finishRequest(x,$);else x.end()}function U$($,J){$._readyState=P.CLOSING,$._errorEmitted=!0,$.emit("error",J),$.emitClose()}function YJ($){return $.path=$.socketPath,W3.connect($)}function KJ($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=W3.isIP($.host)?"":$.host;return s7.connect($)}function $1($,J,N){$._readyState=P.CLOSING;let G=Error(N);if(Error.captureStackTrace(G,$1),J.setHeader){if(J[O3]=!0,J.abort(),J.socket&&!J.socket.destroyed)J.socket.destroy();process.nextTick(U$,$,G)}else J.destroy(G),J.once("error",$.emit.bind($,"error")),J.once("close",$.emitClose.bind($))}function k2($,J,N){if(J){let G=e7(J)?J.size:MJ(J).length;if($._socket)$._sender._bufferedBytes+=G;else $._bufferedAmount+=G}if(N){let G=Error(`WebSocket is not open: readyState ${$.readyState} (${L1[$.readyState]})`);process.nextTick(N,G)}}function jJ($,J){let N=this[h];if(N._closeFrameReceived=!0,N._closeMessage=J,N._closeCode=$,N._socket[h]===void 0)return;if(N._socket.removeListener("data",B$),process.nextTick(f3,N._socket),$===1005)N.close();else N.close($,J)}function xJ(){let $=this[h];if(!$.isPaused)$._socket.resume()}function HJ($){let J=this[h];if(J._socket[h]!==void 0)J._socket.removeListener("data",B$),process.nextTick(f3,J._socket),J.close($[GJ]);if(!J._errorEmitted)J._errorEmitted=!0,J.emit("error",$)}function S3(){this[h].emitClose()}function RJ($,J){this[h].emit("message",$,J)}function qJ($){let J=this[h];if(J._autoPong)J.pong($,!this._isServer,F3);J.emit("ping",$)}function UJ($){this[h].emit("pong",$)}function f3($){$.resume()}function BJ($){let J=this[h];if(J.readyState===P.CLOSED)return;if(J.readyState===P.OPEN)J._readyState=P.CLOSING,y3(J);if(this._socket.end(),!J._errorEmitted)J._errorEmitted=!0,J.emit("error",$)}function y3($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function E3(){let $=this[h];if(this.removeListener("close",E3),this.removeListener("data",B$),this.removeListener("end",w3),$._readyState=P.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let J=this.read(this._readableState.length);$._receiver.write(J)}if($._receiver.end(),this[h]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",S3),$._receiver.on("finish",S3)}function B$($){if(!this[h]._receiver.write($))this.pause()}function w3(){let $=this[h];$._readyState=P.CLOSING,$._receiver.end(),this.end()}function v3(){let $=this[h];if(this.removeListener("error",v3),this.on("error",F3),$)$._readyState=P.CLOSING,this.destroy()}});var m3=u((RZ,k3)=>{var HZ=T$(),{Duplex:TJ}=f("stream");function b3($){$.emit("close")}function VJ(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function l3($){if(this.removeListener("error",l3),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function _J($,J){let N=!0,G=new TJ({...J,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(z,X){let Q=!X&&G._readableState.objectMode?z.toString():z;if(!G.push(Q))$.pause()}),$.once("error",function(z){if(G.destroyed)return;N=!1,G.destroy(z)}),$.once("close",function(){if(G.destroyed)return;G.push(null)}),G._destroy=function(Z,z){if($.readyState===$.CLOSED){z(Z),process.nextTick(b3,G);return}let X=!1;if($.once("error",function(M){X=!0,z(M)}),$.once("close",function(){if(!X)z(Z);process.nextTick(b3,G)}),N)$.terminate()},G._final=function(Z){if($.readyState===$.CONNECTING){$.once("open",function(){G._final(Z)});return}if($._socket===null)return;if($._socket._writableState.finished){if(Z(),G._readableState.endEmitted)G.destroy()}else $._socket.once("finish",function(){Z()}),$.close()},G._read=function(){if($.isPaused)$.resume()},G._write=function(Z,z,X){if($.readyState===$.CONNECTING){$.once("open",function(){G._write(Z,z,X)});return}$.send(Z,X)},G.on("end",VJ),G.on("error",l3),G}k3.exports=_J});var c3=u((qZ,h3)=>{var{tokenChars:CJ}=r1();function LJ($){let J=new Set,N=-1,G=-1,Z=0;for(Z;Z<$.length;Z++){let X=$.charCodeAt(Z);if(G===-1&&CJ[X]===1){if(N===-1)N=Z}else if(Z!==0&&(X===32||X===9)){if(G===-1&&N!==-1)G=Z}else if(X===44){if(N===-1)throw SyntaxError(`Unexpected character at index ${Z}`);if(G===-1)G=Z;let Q=$.slice(N,G);if(J.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);J.add(Q),N=G=-1}else throw SyntaxError(`Unexpected character at index ${Z}`)}if(N===-1||G!==-1)throw SyntaxError("Unexpected end of input");let z=$.slice(N,Z);if(J.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);return J.add(z),J}h3.exports={parse:LJ}});var s3=u((BZ,p3)=>{var AJ=f("events"),V$=f("http"),{Duplex:UZ}=f("stream"),{createHash:DJ}=f("crypto"),d3=v2(),k1=U0(),PJ=c3(),SJ=T$(),{CLOSE_TIMEOUT:WJ,GUID:FJ,kWebSocket:OJ}=_1(),gJ=/^[+/0-9A-Za-z]{22}==$/;class n3 extends AJ{constructor($,J){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:WJ,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:SJ,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=V$.createServer((N,G)=>{let Z=V$.STATUS_CODES[426];G.writeHead(426,{"Content-Length":Z.length,"Content-Type":"text/plain"}),G.end(Z)}),this._server.listen($.port,$.host,$.backlog,J);else if($.server)this._server=$.server;if(this._server){let N=this.emit.bind(this,"connection");this._removeListeners=fJ(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(G,Z,z)=>{this.handleUpgrade(G,Z,z,N)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(_0,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(_0,this);else this._shouldEmitClose=!0;else process.nextTick(_0,this)}else{let J=this._server;this._removeListeners(),this._removeListeners=this._server=null,J.close(()=>{_0(this)})}}shouldHandle($){if(this.options.path){let J=$.url.indexOf("?");if((J!==-1?$.url.slice(0,J):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,J,N,G){J.on("error",i3);let Z=$.headers["sec-websocket-key"],z=$.headers.upgrade,X=+$.headers["sec-websocket-version"];if($.method!=="GET"){m1(this,$,J,405,"Invalid HTTP method");return}if(z===void 0||z.toLowerCase()!=="websocket"){m1(this,$,J,400,"Invalid Upgrade header");return}if(Z===void 0||!gJ.test(Z)){m1(this,$,J,400,"Missing or invalid Sec-WebSocket-Key header");return}if(X!==13&&X!==8){m1(this,$,J,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){C0(J,400);return}let Q=$.headers["sec-websocket-protocol"],M=new Set;if(Q!==void 0)try{M=PJ.parse(Q)}catch(Y){m1(this,$,J,400,"Invalid Sec-WebSocket-Protocol header");return}let I=$.headers["sec-websocket-extensions"],K={};if(this.options.perMessageDeflate&&I!==void 0){let Y=new k1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let H=d3.parse(I);if(H[k1.extensionName])Y.accept(H[k1.extensionName]),K[k1.extensionName]=Y}catch(H){m1(this,$,J,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Y={origin:$.headers[`${X===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(Y,(H,R,x,j)=>{if(!H)return C0(J,R||401,x,j);this.completeUpgrade(K,Z,M,$,J,N,G)});return}if(!this.options.verifyClient(Y))return C0(J,401)}this.completeUpgrade(K,Z,M,$,J,N,G)}completeUpgrade($,J,N,G,Z,z,X){if(!Z.readable||!Z.writable)return Z.destroy();if(Z[OJ])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return C0(Z,503);let M=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${DJ("sha1").update(J+FJ).digest("base64")}`],I=new this.options.WebSocket(null,void 0,this.options);if(N.size){let K=this.options.handleProtocols?this.options.handleProtocols(N,G):N.values().next().value;if(K)M.push(`Sec-WebSocket-Protocol: ${K}`),I._protocol=K}if($[k1.extensionName]){let K=$[k1.extensionName].params,Y=d3.format({[k1.extensionName]:[K]});M.push(`Sec-WebSocket-Extensions: ${Y}`),I._extensions=$}if(this.emit("headers",M,G),Z.write(M.concat(`\r
23
+ `)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((G)=>J.is(G)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function G4($){return $.map((J)=>{if(!J.startsWith("--inspect"))return J;let N,G="127.0.0.1",Z="9229",z;if((z=J.match(/^(--inspect(-brk)?)$/))!==null)N=z[1];else if((z=J.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(N=z[1],/^\d+$/.test(z[3]))Z=z[3];else G=z[3];else if((z=J.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)N=z[1],G=z[3],Z=z[4];if(N&&Z!=="0")return`${N}=${G}:${parseInt(Z)+1}`;return J})}w5.Command=S$});var M4=u((l5)=>{var{Argument:z4}=g0(),{Command:F$}=Z4(),{CommanderError:u5,InvalidArgumentError:X4}=Z0(),{Help:b5}=L$(),{Option:Q4}=A$();l5.program=new F$;l5.createCommand=($)=>new F$($);l5.createOption=($,J)=>new Q4($,J);l5.createArgument=($,J)=>new z4($,J);l5.Command=F$;l5.Option=Q4;l5.Argument=z4;l5.Help=b5;l5.CommanderError=u5;l5.InvalidArgumentError=X4;l5.InvalidOptionArgumentError=X4});var N1=u((fN,O$)=>{var y0=process||{},K4=y0.argv||[],f0=y0.env||{},a5=!(!!f0.NO_COLOR||K4.includes("--no-color"))&&(!!f0.FORCE_COLOR||K4.includes("--color")||y0.platform==="win32"||(y0.stdout||{}).isTTY&&f0.TERM!=="dumb"||!!f0.CI),t5=($,J,N=$)=>(G)=>{let Z=""+G,z=Z.indexOf(J,$.length);return~z?$+e5(Z,J,N,z)+J:$+Z+J},e5=($,J,N,G)=>{let Z="",z=0;do Z+=$.substring(z,G)+N,z=G+J.length,G=$.indexOf(J,z);while(~G);return Z+$.substring(z)},j4=($=a5)=>{let J=$?t5:()=>String;return{isColorSupported:$,reset:J("\x1B[0m","\x1B[0m"),bold:J("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:J("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:J("\x1B[3m","\x1B[23m"),underline:J("\x1B[4m","\x1B[24m"),inverse:J("\x1B[7m","\x1B[27m"),hidden:J("\x1B[8m","\x1B[28m"),strikethrough:J("\x1B[9m","\x1B[29m"),black:J("\x1B[30m","\x1B[39m"),red:J("\x1B[31m","\x1B[39m"),green:J("\x1B[32m","\x1B[39m"),yellow:J("\x1B[33m","\x1B[39m"),blue:J("\x1B[34m","\x1B[39m"),magenta:J("\x1B[35m","\x1B[39m"),cyan:J("\x1B[36m","\x1B[39m"),white:J("\x1B[37m","\x1B[39m"),gray:J("\x1B[90m","\x1B[39m"),bgBlack:J("\x1B[40m","\x1B[49m"),bgRed:J("\x1B[41m","\x1B[49m"),bgGreen:J("\x1B[42m","\x1B[49m"),bgYellow:J("\x1B[43m","\x1B[49m"),bgBlue:J("\x1B[44m","\x1B[49m"),bgMagenta:J("\x1B[45m","\x1B[49m"),bgCyan:J("\x1B[46m","\x1B[49m"),bgWhite:J("\x1B[47m","\x1B[49m"),blackBright:J("\x1B[90m","\x1B[39m"),redBright:J("\x1B[91m","\x1B[39m"),greenBright:J("\x1B[92m","\x1B[39m"),yellowBright:J("\x1B[93m","\x1B[39m"),blueBright:J("\x1B[94m","\x1B[39m"),magentaBright:J("\x1B[95m","\x1B[39m"),cyanBright:J("\x1B[96m","\x1B[39m"),whiteBright:J("\x1B[97m","\x1B[39m"),bgBlackBright:J("\x1B[100m","\x1B[49m"),bgRedBright:J("\x1B[101m","\x1B[49m"),bgGreenBright:J("\x1B[102m","\x1B[49m"),bgYellowBright:J("\x1B[103m","\x1B[49m"),bgBlueBright:J("\x1B[104m","\x1B[49m"),bgMagentaBright:J("\x1B[105m","\x1B[49m"),bgCyanBright:J("\x1B[106m","\x1B[49m"),bgWhiteBright:J("\x1B[107m","\x1B[49m")}};O$.exports=j4();O$.exports.createColors=j4});var y$=u((mN,U4)=>{var f$={to($,J){if(!J)return`\x1B[${$+1}G`;return`\x1B[${J+1};${$+1}H`},move($,J){let N="";if($<0)N+=`\x1B[${-$}D`;else if($>0)N+=`\x1B[${$}C`;if(J<0)N+=`\x1B[${-J}A`;else if(J>0)N+=`\x1B[${J}B`;return N},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},z6={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},X6={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let J="";for(let N=0;N<$;N++)J+=this.line+(N<$-1?f$.up():"");if($)J+=f$.left;return J}};U4.exports={cursor:f$,scroll:z6,erase:X6,beep:"\x07"}});var _1=u((GZ,a8)=>{var o8=["nodebuffer","arraybuffer","fragments"],r8=typeof Blob<"u";if(r8)o8.push("blob");a8.exports={BINARY_TYPES:o8,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:r8,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var B0=u((ZZ,Y$)=>{var{EMPTY_BUFFER:q7}=_1(),W2=Buffer[Symbol.species];function U7($,J){if($.length===0)return q7;if($.length===1)return $[0];let N=Buffer.allocUnsafe(J),G=0;for(let Z=0;Z<$.length;Z++){let z=$[Z];N.set(z,G),G+=z.length}if(G<J)return new W2(N.buffer,N.byteOffset,G);return N}function t8($,J,N,G,Z){for(let z=0;z<Z;z++)N[G+z]=$[z]^J[z&3]}function e8($,J){for(let N=0;N<$.length;N++)$[N]^=J[N&3]}function B7($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function S2($){if(S2.readOnly=!0,Buffer.isBuffer($))return $;let J;if($ instanceof ArrayBuffer)J=new W2($);else if(ArrayBuffer.isView($))J=new W2($.buffer,$.byteOffset,$.byteLength);else J=Buffer.from($),S2.readOnly=!1;return J}Y$.exports={concat:U7,mask:t8,toArrayBuffer:B7,toBuffer:S2,unmask:e8};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();Y$.exports.mask=function(J,N,G,Z,z){if(z<48)t8(J,N,G,Z,z);else $.mask(J,N,G,Z,z)},Y$.exports.unmask=function(J,N){if(J.length<32)e8(J,N);else $.unmask(J,N)}}catch($){}});var G3=u((zZ,N3)=>{var $3=Symbol("kDone"),F2=Symbol("kRun");class J3{constructor($){this[$3]=()=>{this.pending--,this[F2]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[F2]()}[F2](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[$3])}}}N3.exports=J3});var T0=u((XZ,M3)=>{var V0=f("zlib"),Z3=B0(),V7=G3(),{kStatusCode:z3}=_1(),T7=Buffer[Symbol.species],_7=Buffer.from([0,0,255,255]),j$=Symbol("permessage-deflate"),C1=Symbol("total-length"),r1=Symbol("callback"),W1=Symbol("buffers"),a1=Symbol("error"),K$;class X3{constructor($,J,N){if(this._maxPayload=N|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!J,this._deflate=null,this._inflate=null,this.params=null,!K$){let G=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;K$=new V7(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[r1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let J=this._options,N=$.find((G)=>{if(J.serverNoContextTakeover===!1&&G.server_no_context_takeover||G.server_max_window_bits&&(J.serverMaxWindowBits===!1||typeof J.serverMaxWindowBits==="number"&&J.serverMaxWindowBits>G.server_max_window_bits)||typeof J.clientMaxWindowBits==="number"&&!G.client_max_window_bits)return!1;return!0});if(!N)throw Error("None of the extension offers can be accepted");if(J.serverNoContextTakeover)N.server_no_context_takeover=!0;if(J.clientNoContextTakeover)N.client_no_context_takeover=!0;if(typeof J.serverMaxWindowBits==="number")N.server_max_window_bits=J.serverMaxWindowBits;if(typeof J.clientMaxWindowBits==="number")N.client_max_window_bits=J.clientMaxWindowBits;else if(N.client_max_window_bits===!0||J.clientMaxWindowBits===!1)delete N.client_max_window_bits;return N}acceptAsClient($){let J=$[0];if(this._options.clientNoContextTakeover===!1&&J.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!J.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")J.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&J.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return J}normalizeParams($){return $.forEach((J)=>{Object.keys(J).forEach((N)=>{let G=J[N];if(G.length>1)throw Error(`Parameter "${N}" must have only a single value`);if(G=G[0],N==="client_max_window_bits"){if(G!==!0){let Z=+G;if(!Number.isInteger(Z)||Z<8||Z>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=Z}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else if(N==="server_max_window_bits"){let Z=+G;if(!Number.isInteger(Z)||Z<8||Z>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=Z}else if(N==="client_no_context_takeover"||N==="server_no_context_takeover"){if(G!==!0)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else throw Error(`Unknown parameter "${N}"`);J[N]=G})}),$}decompress($,J,N){K$.add((G)=>{this._decompress($,J,(Z,z)=>{G(),N(Z,z)})})}compress($,J,N){K$.add((G)=>{this._compress($,J,(Z,z)=>{G(),N(Z,z)})})}_decompress($,J,N){let G=this._isServer?"client":"server";if(!this._inflate){let Z=`${G}_max_window_bits`,z=typeof this.params[Z]!=="number"?V0.Z_DEFAULT_WINDOWBITS:this.params[Z];this._inflate=V0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:z}),this._inflate[j$]=this,this._inflate[C1]=0,this._inflate[W1]=[],this._inflate.on("error",L7),this._inflate.on("data",Q3)}if(this._inflate[r1]=N,this._inflate.write($),J)this._inflate.write(_7);this._inflate.flush(()=>{let Z=this._inflate[a1];if(Z){this._inflate.close(),this._inflate=null,N(Z);return}let z=Z3.concat(this._inflate[W1],this._inflate[C1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[C1]=0,this._inflate[W1]=[],J&&this.params[`${G}_no_context_takeover`])this._inflate.reset();N(null,z)})}_compress($,J,N){let G=this._isServer?"server":"client";if(!this._deflate){let Z=`${G}_max_window_bits`,z=typeof this.params[Z]!=="number"?V0.Z_DEFAULT_WINDOWBITS:this.params[Z];this._deflate=V0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:z}),this._deflate[C1]=0,this._deflate[W1]=[],this._deflate.on("data",C7)}this._deflate[r1]=N,this._deflate.write($),this._deflate.flush(V0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let Z=Z3.concat(this._deflate[W1],this._deflate[C1]);if(J)Z=new T7(Z.buffer,Z.byteOffset,Z.length-4);if(this._deflate[r1]=null,this._deflate[C1]=0,this._deflate[W1]=[],J&&this.params[`${G}_no_context_takeover`])this._deflate.reset();N(null,Z)})}}M3.exports=X3;function C7($){this[W1].push($),this[C1]+=$.length}function Q3($){if(this[C1]+=$.length,this[j$]._maxPayload<1||this[C1]<=this[j$]._maxPayload){this[W1].push($);return}this[a1]=RangeError("Max payload size exceeded"),this[a1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[a1][z3]=1009,this.removeListener("data",Q3),this.reset()}function L7($){if(this[j$]._inflate=null,this[a1]){this[r1](this[a1]);return}$[z3]=1007,this[r1]($)}});var t1=u((QZ,x$)=>{var{isUtf8:I3}=f("buffer"),{hasBlob:A7}=_1(),D7=[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 P7($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function O2($){let J=$.length,N=0;while(N<J)if(($[N]&128)===0)N++;else if(($[N]&224)===192){if(N+1===J||($[N+1]&192)!==128||($[N]&254)===192)return!1;N+=2}else if(($[N]&240)===224){if(N+2>=J||($[N+1]&192)!==128||($[N+2]&192)!==128||$[N]===224&&($[N+1]&224)===128||$[N]===237&&($[N+1]&224)===160)return!1;N+=3}else if(($[N]&248)===240){if(N+3>=J||($[N+1]&192)!==128||($[N+2]&192)!==128||($[N+3]&192)!==128||$[N]===240&&($[N+1]&240)===128||$[N]===244&&$[N+1]>143||$[N]>244)return!1;N+=4}else return!1;return!0}function W7($){return A7&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}x$.exports={isBlob:W7,isValidStatusCode:P7,isValidUTF8:O2,tokenChars:D7};if(I3)x$.exports.isValidUTF8=function($){return $.length<24?O2($):I3($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();x$.exports.isValidUTF8=function(J){return J.length<32?O2(J):$(J)}}catch($){}});var f2=u((MZ,R3)=>{var{Writable:S7}=f("stream"),Y3=T0(),{BINARY_TYPES:F7,EMPTY_BUFFER:K3,kStatusCode:O7,kWebSocket:g7}=_1(),{concat:g2,toArrayBuffer:f7,unmask:y7}=B0(),{isValidStatusCode:E7,isValidUTF8:j3}=t1(),R$=Buffer[Symbol.species];class x3 extends S7{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||F7[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[g7]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,J,N){if(this._opcode===8&&this._state==0)return N();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(N)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let N=this._buffers[0];return this._buffers[0]=new R$(N.buffer,N.byteOffset+$,N.length-$),new R$(N.buffer,N.byteOffset,$)}let J=Buffer.allocUnsafe($);do{let N=this._buffers[0],G=J.length-$;if($>=N.length)J.set(this._buffers.shift(),G);else J.set(new Uint8Array(N.buffer,N.byteOffset,$),G),this._buffers[0]=new R$(N.buffer,N.byteOffset+$,N.length-$);$-=N.length}while($>0);return J}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let J=this.consume(2);if((J[0]&48)!==0){let G=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(G);return}let N=(J[0]&64)===64;if(N&&!this._extensions[Y3.extensionName]){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._fin=(J[0]&128)===128,this._opcode=J[0]&15,this._payloadLength=J[1]&127,this._opcode===0){if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(!this._fragmented){let G=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._compressed=N}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let G=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(G);return}if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let G=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(G);return}}else{let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(J[1]&128)===128,this._isServer){if(!this._masked){let G=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(G);return}}else if(this._masked){let G=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(G);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let J=this.consume(8),N=J.readUInt32BE(0);if(N>Math.pow(2,21)-1){let G=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(G);return}this._payloadLength=N*Math.pow(2,32)+J.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let J=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(J);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let J=K3;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(J=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)y7(J,this._mask)}if(this._opcode>7){this.controlMessage(J,$);return}if(this._compressed){this._state=5,this.decompress(J,$);return}if(J.length)this._messageLength=this._totalPayloadLength,this._fragments.push(J);this.dataMessage($)}decompress($,J){this._extensions[Y3.extensionName].decompress($,this._fin,(G,Z)=>{if(G)return J(G);if(Z.length){if(this._messageLength+=Z.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");J(z);return}this._fragments.push(Z)}if(this.dataMessage(J),this._state===0)this.startLoop(J)})}dataMessage($){if(!this._fin){this._state=0;return}let J=this._messageLength,N=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let G;if(this._binaryType==="nodebuffer")G=g2(N,J);else if(this._binaryType==="arraybuffer")G=f7(g2(N,J));else if(this._binaryType==="blob")G=new Blob(N);else G=N;if(this._allowSynchronousEvents)this.emit("message",G,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!0),this._state=0,this.startLoop($)})}else{let G=g2(N,J);if(!this._skipUTF8Validation&&!j3(G)){let Z=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(Z);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",G,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!1),this._state=0,this.startLoop($)})}}controlMessage($,J){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,K3),this.end();else{let N=$.readUInt16BE(0);if(!E7(N)){let Z=this.createError(RangeError,`invalid status code ${N}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");J(Z);return}let G=new R$($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!j3(G)){let Z=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");J(Z);return}this._loop=!1,this.emit("conclude",N,G),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(J)})}createError($,J,N,G,Z){this._loop=!1,this._errored=!0;let z=new $(N?`Invalid WebSocket frame: ${J}`:J);return Error.captureStackTrace(z,this.createError),z.code=Z,z[O7]=G,z}}R3.exports=x3});var E2=u((YZ,U3)=>{var{Duplex:IZ}=f("stream"),{randomFillSync:w7}=f("crypto"),H3=T0(),{EMPTY_BUFFER:v7,kWebSocket:u7,NOOP:b7}=_1(),{isBlob:e1,isValidStatusCode:l7}=t1(),{mask:q3,toBuffer:b1}=B0(),X1=Symbol("kByteLength"),k7=Buffer.alloc(4),l1,$0=8192,j1=0,m7=1,h7=2;class S1{constructor($,J,N){if(this._extensions=J||{},N)this._generateMask=N,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=j1,this.onerror=b7,this[u7]=void 0}static frame($,J){let N,G=!1,Z=2,z=!1;if(J.mask){if(N=J.maskBuffer||k7,J.generateMask)J.generateMask(N);else{if($0===8192){if(l1===void 0)l1=Buffer.alloc(8192);w7(l1,0,8192),$0=0}N[0]=l1[$0++],N[1]=l1[$0++],N[2]=l1[$0++],N[3]=l1[$0++]}z=(N[0]|N[1]|N[2]|N[3])===0,Z=6}let X;if(typeof $==="string")if((!J.mask||z)&&J[X1]!==void 0)X=J[X1];else $=Buffer.from($),X=$.length;else X=$.length,G=J.mask&&J.readOnly&&!z;let Q=X;if(X>=65536)Z+=8,Q=127;else if(X>125)Z+=2,Q=126;let M=Buffer.allocUnsafe(G?X+Z:Z);if(M[0]=J.fin?J.opcode|128:J.opcode,J.rsv1)M[0]|=64;if(M[1]=Q,Q===126)M.writeUInt16BE(X,2);else if(Q===127)M[2]=M[3]=0,M.writeUIntBE(X,4,6);if(!J.mask)return[M,$];if(M[1]|=128,M[Z-4]=N[0],M[Z-3]=N[1],M[Z-2]=N[2],M[Z-1]=N[3],z)return[M,$];if(G)return q3($,N,M,Z,X),[M];return q3($,N,$,0,X),[M,$]}close($,J,N,G){let Z;if($===void 0)Z=v7;else if(typeof $!=="number"||!l7($))throw TypeError("First argument must be a valid error code number");else if(J===void 0||!J.length)Z=Buffer.allocUnsafe(2),Z.writeUInt16BE($,0);else{let X=Buffer.byteLength(J);if(X>123)throw RangeError("The message must not be greater than 123 bytes");if(Z=Buffer.allocUnsafe(2+X),Z.writeUInt16BE($,0),typeof J==="string")Z.write(J,2);else Z.set(J,2)}let z={[X1]:Z.length,fin:!0,generateMask:this._generateMask,mask:N,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==j1)this.enqueue([this.dispatch,Z,!1,z,G]);else this.sendFrame(S1.frame(Z,z),G)}ping($,J,N){let G,Z;if(typeof $==="string")G=Buffer.byteLength($),Z=!1;else if(e1($))G=$.size,Z=!1;else $=b1($),G=$.length,Z=b1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[X1]:G,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:9,readOnly:Z,rsv1:!1};if(e1($))if(this._state!==j1)this.enqueue([this.getBlobData,$,!1,z,N]);else this.getBlobData($,!1,z,N);else if(this._state!==j1)this.enqueue([this.dispatch,$,!1,z,N]);else this.sendFrame(S1.frame($,z),N)}pong($,J,N){let G,Z;if(typeof $==="string")G=Buffer.byteLength($),Z=!1;else if(e1($))G=$.size,Z=!1;else $=b1($),G=$.length,Z=b1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[X1]:G,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:10,readOnly:Z,rsv1:!1};if(e1($))if(this._state!==j1)this.enqueue([this.getBlobData,$,!1,z,N]);else this.getBlobData($,!1,z,N);else if(this._state!==j1)this.enqueue([this.dispatch,$,!1,z,N]);else this.sendFrame(S1.frame($,z),N)}send($,J,N){let G=this._extensions[H3.extensionName],Z=J.binary?2:1,z=J.compress,X,Q;if(typeof $==="string")X=Buffer.byteLength($),Q=!1;else if(e1($))X=$.size,Q=!1;else $=b1($),X=$.length,Q=b1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,z&&G&&G.params[G._isServer?"server_no_context_takeover":"client_no_context_takeover"])z=X>=G._threshold;this._compress=z}else z=!1,Z=0;if(J.fin)this._firstFragment=!0;let M={[X1]:X,fin:J.fin,generateMask:this._generateMask,mask:J.mask,maskBuffer:this._maskBuffer,opcode:Z,readOnly:Q,rsv1:z};if(e1($))if(this._state!==j1)this.enqueue([this.getBlobData,$,this._compress,M,N]);else this.getBlobData($,this._compress,M,N);else if(this._state!==j1)this.enqueue([this.dispatch,$,this._compress,M,N]);else this.dispatch($,this._compress,M,N)}getBlobData($,J,N,G){this._bufferedBytes+=N[X1],this._state=h7,$.arrayBuffer().then((Z)=>{if(this._socket.destroyed){let X=Error("The socket was closed while the blob was being read");process.nextTick(y2,this,X,G);return}this._bufferedBytes-=N[X1];let z=b1(Z);if(!J)this._state=j1,this.sendFrame(S1.frame(z,N),G),this.dequeue();else this.dispatch(z,J,N,G)}).catch((Z)=>{process.nextTick(c7,this,Z,G)})}dispatch($,J,N,G){if(!J){this.sendFrame(S1.frame($,N),G);return}let Z=this._extensions[H3.extensionName];this._bufferedBytes+=N[X1],this._state=m7,Z.compress($,N.fin,(z,X)=>{if(this._socket.destroyed){let Q=Error("The socket was closed while data was being compressed");y2(this,Q,G);return}this._bufferedBytes-=N[X1],this._state=j1,N.readOnly=!1,this.sendFrame(S1.frame(X,N),G),this.dequeue()})}dequeue(){while(this._state===j1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][X1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][X1],this._queue.push($)}sendFrame($,J){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],J),this._socket.uncork();else this._socket.write($[0],J)}}U3.exports=S1;function y2($,J,N){if(typeof N==="function")N(J);for(let G=0;G<$._queue.length;G++){let Z=$._queue[G],z=Z[Z.length-1];if(typeof z==="function")z(J)}}function c7($,J,N){y2($,J,N),$.onerror(J)}});var P3=u((KZ,D3)=>{var{kForOnEventAttribute:_0,kListener:w2}=_1(),B3=Symbol("kCode"),V3=Symbol("kData"),T3=Symbol("kError"),_3=Symbol("kMessage"),C3=Symbol("kReason"),J0=Symbol("kTarget"),L3=Symbol("kType"),A3=Symbol("kWasClean");class F1{constructor($){this[J0]=null,this[L3]=$}get target(){return this[J0]}get type(){return this[L3]}}Object.defineProperty(F1.prototype,"target",{enumerable:!0});Object.defineProperty(F1.prototype,"type",{enumerable:!0});class N0 extends F1{constructor($,J={}){super($);this[B3]=J.code===void 0?0:J.code,this[C3]=J.reason===void 0?"":J.reason,this[A3]=J.wasClean===void 0?!1:J.wasClean}get code(){return this[B3]}get reason(){return this[C3]}get wasClean(){return this[A3]}}Object.defineProperty(N0.prototype,"code",{enumerable:!0});Object.defineProperty(N0.prototype,"reason",{enumerable:!0});Object.defineProperty(N0.prototype,"wasClean",{enumerable:!0});class C0 extends F1{constructor($,J={}){super($);this[T3]=J.error===void 0?null:J.error,this[_3]=J.message===void 0?"":J.message}get error(){return this[T3]}get message(){return this[_3]}}Object.defineProperty(C0.prototype,"error",{enumerable:!0});Object.defineProperty(C0.prototype,"message",{enumerable:!0});class q$ extends F1{constructor($,J={}){super($);this[V3]=J.data===void 0?null:J.data}get data(){return this[V3]}}Object.defineProperty(q$.prototype,"data",{enumerable:!0});var d7={addEventListener($,J,N={}){for(let Z of this.listeners($))if(!N[_0]&&Z[w2]===J&&!Z[_0])return;let G;if($==="message")G=function(z,X){let Q=new q$("message",{data:X?z:z.toString()});Q[J0]=this,H$(J,this,Q)};else if($==="close")G=function(z,X){let Q=new N0("close",{code:z,reason:X.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});Q[J0]=this,H$(J,this,Q)};else if($==="error")G=function(z){let X=new C0("error",{error:z,message:z.message});X[J0]=this,H$(J,this,X)};else if($==="open")G=function(){let z=new F1("open");z[J0]=this,H$(J,this,z)};else return;if(G[_0]=!!N[_0],G[w2]=J,N.once)this.once($,G);else this.on($,G)},removeEventListener($,J){for(let N of this.listeners($))if(N[w2]===J&&!N[_0]){this.removeListener($,N);break}}};D3.exports={CloseEvent:N0,ErrorEvent:C0,Event:F1,EventTarget:d7,MessageEvent:q$};function H$($,J,N){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,N);else $.call(J,N)}});var v2=u((jZ,W3)=>{var{tokenChars:L0}=t1();function q1($,J,N){if($[J]===void 0)$[J]=[N];else $[J].push(N)}function i7($){let J=Object.create(null),N=Object.create(null),G=!1,Z=!1,z=!1,X,Q,M=-1,I=-1,K=-1,Y=0;for(;Y<$.length;Y++)if(I=$.charCodeAt(Y),X===void 0)if(K===-1&&L0[I]===1){if(M===-1)M=Y}else if(Y!==0&&(I===32||I===9)){if(K===-1&&M!==-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;let R=$.slice(M,K);if(I===44)q1(J,R,N),N=Object.create(null);else X=R;M=K=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);else if(Q===void 0)if(K===-1&&L0[I]===1){if(M===-1)M=Y}else if(I===32||I===9){if(K===-1&&M!==-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;if(q1(N,$.slice(M,K),!0),I===44)q1(J,X,N),N=Object.create(null),X=void 0;M=K=-1}else if(I===61&&M!==-1&&K===-1)Q=$.slice(M,Y),M=K=-1;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(Z){if(L0[I]!==1)throw SyntaxError(`Unexpected character at index ${Y}`);if(M===-1)M=Y;else if(!G)G=!0;Z=!1}else if(z)if(L0[I]===1){if(M===-1)M=Y}else if(I===34&&M!==-1)z=!1,K=Y;else if(I===92)Z=!0;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(I===34&&$.charCodeAt(Y-1)===61)z=!0;else if(K===-1&&L0[I]===1){if(M===-1)M=Y}else if(M!==-1&&(I===32||I===9)){if(K===-1)K=Y}else if(I===59||I===44){if(M===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(K===-1)K=Y;let R=$.slice(M,K);if(G)R=R.replace(/\\/g,""),G=!1;if(q1(N,Q,R),I===44)q1(J,X,N),N=Object.create(null),X=void 0;Q=void 0,M=K=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);if(M===-1||z||I===32||I===9)throw SyntaxError("Unexpected end of input");if(K===-1)K=Y;let H=$.slice(M,K);if(X===void 0)q1(J,H,N);else{if(Q===void 0)q1(N,H,!0);else if(G)q1(N,Q,H.replace(/\\/g,""));else q1(N,Q,H);q1(J,X,N)}return J}function n7($){return Object.keys($).map((J)=>{let N=$[J];if(!Array.isArray(N))N=[N];return N.map((G)=>{return[J].concat(Object.keys(G).map((Z)=>{let z=G[Z];if(!Array.isArray(z))z=[z];return z.map((X)=>X===!0?Z:`${Z}=${X}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}W3.exports={format:n7,parse:i7}});var T$=u((HZ,l3)=>{var p7=f("events"),s7=f("https"),o7=f("http"),O3=f("net"),r7=f("tls"),{randomBytes:a7,createHash:t7}=f("crypto"),{Duplex:xZ,Readable:RZ}=f("stream"),{URL:u2}=f("url"),O1=T0(),e7=f2(),$J=E2(),{isBlob:JJ}=t1(),{BINARY_TYPES:S3,CLOSE_TIMEOUT:NJ,EMPTY_BUFFER:U$,GUID:GJ,kForOnEventAttribute:b2,kListener:ZJ,kStatusCode:zJ,kWebSocket:h,NOOP:g3}=_1(),{EventTarget:{addEventListener:XJ,removeEventListener:QJ}}=P3(),{format:MJ,parse:IJ}=v2(),{toBuffer:YJ}=B0(),f3=Symbol("kAborted"),l2=[8,13],L1=["CONNECTING","OPEN","CLOSING","CLOSED"],KJ=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class P extends p7{constructor($,J,N){super();if(this._binaryType=S3[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=U$,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=P.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,J===void 0)J=[];else if(!Array.isArray(J))if(typeof J==="object"&&J!==null)N=J,J=[];else J=[J];y3(this,$,J,N)}else this._autoPong=N.autoPong,this._closeTimeout=N.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!S3.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,J,N){let G=new e7({allowSynchronousEvents:N.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:N.maxPayload,skipUTF8Validation:N.skipUTF8Validation}),Z=new $J($,this._extensions,N.generateMask);if(this._receiver=G,this._sender=Z,this._socket=$,G[h]=this,Z[h]=this,$[h]=this,G.on("conclude",RJ),G.on("drain",HJ),G.on("error",qJ),G.on("message",UJ),G.on("ping",BJ),G.on("pong",VJ),Z.onerror=TJ,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(J.length>0)$.unshift(J);$.on("close",v3),$.on("data",V$),$.on("end",u3),$.on("error",b3),this._readyState=P.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=P.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[O1.extensionName])this._extensions[O1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=P.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,J){if(this.readyState===P.CLOSED)return;if(this.readyState===P.CONNECTING){$1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===P.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=P.CLOSING,this._sender.close($,J,!this._isServer,(N)=>{if(N)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),w3(this)}pause(){if(this.readyState===P.CONNECTING||this.readyState===P.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=J=void 0;else if(typeof J==="function")N=J,J=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}if(J===void 0)J=!this._isServer;this._sender.ping($||U$,J,N)}pong($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=J=void 0;else if(typeof J==="function")N=J,J=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}if(J===void 0)J=!this._isServer;this._sender.pong($||U$,J,N)}resume(){if(this.readyState===P.CONNECTING||this.readyState===P.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,J,N){if(this.readyState===P.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")N=J,J={};if(typeof $==="number")$=$.toString();if(this.readyState!==P.OPEN){k2(this,$,N);return}let G={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...J};if(!this._extensions[O1.extensionName])G.compress=!1;this._sender.send($||U$,G,N)}terminate(){if(this.readyState===P.CLOSED)return;if(this.readyState===P.CONNECTING){$1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=P.CLOSING,this._socket.destroy()}}Object.defineProperty(P,"CONNECTING",{enumerable:!0,value:L1.indexOf("CONNECTING")});Object.defineProperty(P.prototype,"CONNECTING",{enumerable:!0,value:L1.indexOf("CONNECTING")});Object.defineProperty(P,"OPEN",{enumerable:!0,value:L1.indexOf("OPEN")});Object.defineProperty(P.prototype,"OPEN",{enumerable:!0,value:L1.indexOf("OPEN")});Object.defineProperty(P,"CLOSING",{enumerable:!0,value:L1.indexOf("CLOSING")});Object.defineProperty(P.prototype,"CLOSING",{enumerable:!0,value:L1.indexOf("CLOSING")});Object.defineProperty(P,"CLOSED",{enumerable:!0,value:L1.indexOf("CLOSED")});Object.defineProperty(P.prototype,"CLOSED",{enumerable:!0,value:L1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(P.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(P.prototype,`on${$}`,{enumerable:!0,get(){for(let J of this.listeners($))if(J[b2])return J[ZJ];return null},set(J){for(let N of this.listeners($))if(N[b2]){this.removeListener($,N);break}if(typeof J!=="function")return;this.addEventListener($,J,{[b2]:!0})}})});P.prototype.addEventListener=XJ;P.prototype.removeEventListener=QJ;l3.exports=P;function y3($,J,N,G){let Z={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:NJ,protocolVersion:l2[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...G,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=Z.autoPong,$._closeTimeout=Z.closeTimeout,!l2.includes(Z.protocolVersion))throw RangeError(`Unsupported protocol version: ${Z.protocolVersion} (supported versions: ${l2.join(", ")})`);let z;if(J instanceof u2)z=J;else try{z=new u2(J)}catch(x){throw SyntaxError(`Invalid URL: ${J}`)}if(z.protocol==="http:")z.protocol="ws:";else if(z.protocol==="https:")z.protocol="wss:";$._url=z.href;let X=z.protocol==="wss:",Q=z.protocol==="ws+unix:",M;if(z.protocol!=="ws:"&&!X&&!Q)M=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(Q&&!z.pathname)M="The URL's pathname is empty";else if(z.hash)M="The URL contains a fragment identifier";if(M){let x=SyntaxError(M);if($._redirects===0)throw x;else{B$($,x);return}}let I=X?443:80,K=a7(16).toString("base64"),Y=X?s7.request:o7.request,H=new Set,R;if(Z.createConnection=Z.createConnection||(X?xJ:jJ),Z.defaultPort=Z.defaultPort||I,Z.port=z.port||I,Z.host=z.hostname.startsWith("[")?z.hostname.slice(1,-1):z.hostname,Z.headers={...Z.headers,"Sec-WebSocket-Version":Z.protocolVersion,"Sec-WebSocket-Key":K,Connection:"Upgrade",Upgrade:"websocket"},Z.path=z.pathname+z.search,Z.timeout=Z.handshakeTimeout,Z.perMessageDeflate)R=new O1(Z.perMessageDeflate!==!0?Z.perMessageDeflate:{},!1,Z.maxPayload),Z.headers["Sec-WebSocket-Extensions"]=MJ({[O1.extensionName]:R.offer()});if(N.length){for(let x of N){if(typeof x!=="string"||!KJ.test(x)||H.has(x))throw SyntaxError("An invalid or duplicated subprotocol was specified");H.add(x)}Z.headers["Sec-WebSocket-Protocol"]=N.join(",")}if(Z.origin)if(Z.protocolVersion<13)Z.headers["Sec-WebSocket-Origin"]=Z.origin;else Z.headers.Origin=Z.origin;if(z.username||z.password)Z.auth=`${z.username}:${z.password}`;if(Q){let x=Z.path.split(":");Z.socketPath=x[0],Z.path=x[1]}let j;if(Z.followRedirects){if($._redirects===0){$._originalIpc=Q,$._originalSecure=X,$._originalHostOrSocketPath=Q?Z.socketPath:z.host;let x=G&&G.headers;if(G={...G,headers:{}},x)for(let[U,B]of Object.entries(x))G.headers[U.toLowerCase()]=B}else if($.listenerCount("redirect")===0){let x=Q?$._originalIpc?Z.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:z.host===$._originalHostOrSocketPath;if(!x||$._originalSecure&&!X){if(delete Z.headers.authorization,delete Z.headers.cookie,!x)delete Z.headers.host;Z.auth=void 0}}if(Z.auth&&!G.headers.authorization)G.headers.authorization="Basic "+Buffer.from(Z.auth).toString("base64");if(j=$._req=Y(Z),$._redirects)$.emit("redirect",$.url,j)}else j=$._req=Y(Z);if(Z.timeout)j.on("timeout",()=>{$1($,j,"Opening handshake has timed out")});if(j.on("error",(x)=>{if(j===null||j[f3])return;j=$._req=null,B$($,x)}),j.on("response",(x)=>{let U=x.headers.location,B=x.statusCode;if(U&&Z.followRedirects&&B>=300&&B<400){if(++$._redirects>Z.maxRedirects){$1($,j,"Maximum redirects exceeded");return}j.abort();let V;try{V=new u2(U,J)}catch(_){let L=SyntaxError(`Invalid URL: ${U}`);B$($,L);return}y3($,V,N,G)}else if(!$.emit("unexpected-response",j,x))$1($,j,`Unexpected server response: ${x.statusCode}`)}),j.on("upgrade",(x,U,B)=>{if($.emit("upgrade",x),$.readyState!==P.CONNECTING)return;j=$._req=null;let V=x.headers.upgrade;if(V===void 0||V.toLowerCase()!=="websocket"){$1($,U,"Invalid Upgrade header");return}let _=t7("sha1").update(K+GJ).digest("base64");if(x.headers["sec-websocket-accept"]!==_){$1($,U,"Invalid Sec-WebSocket-Accept header");return}let L=x.headers["sec-websocket-protocol"],A;if(L!==void 0){if(!H.size)A="Server sent a subprotocol but none was requested";else if(!H.has(L))A="Server sent an invalid subprotocol"}else if(H.size)A="Server sent no subprotocol";if(A){$1($,U,A);return}if(L)$._protocol=L;let D=x.headers["sec-websocket-extensions"];if(D!==void 0){if(!R){$1($,U,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=IJ(D)}catch(l){$1($,U,"Invalid Sec-WebSocket-Extensions header");return}let C=Object.keys(T);if(C.length!==1||C[0]!==O1.extensionName){$1($,U,"Server indicated an extension that was not requested");return}try{R.accept(T[O1.extensionName])}catch(l){$1($,U,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[O1.extensionName]=R}$.setSocket(U,B,{allowSynchronousEvents:Z.allowSynchronousEvents,generateMask:Z.generateMask,maxPayload:Z.maxPayload,skipUTF8Validation:Z.skipUTF8Validation})}),Z.finishRequest)Z.finishRequest(j,$);else j.end()}function B$($,J){$._readyState=P.CLOSING,$._errorEmitted=!0,$.emit("error",J),$.emitClose()}function jJ($){return $.path=$.socketPath,O3.connect($)}function xJ($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=O3.isIP($.host)?"":$.host;return r7.connect($)}function $1($,J,N){$._readyState=P.CLOSING;let G=Error(N);if(Error.captureStackTrace(G,$1),J.setHeader){if(J[f3]=!0,J.abort(),J.socket&&!J.socket.destroyed)J.socket.destroy();process.nextTick(B$,$,G)}else J.destroy(G),J.once("error",$.emit.bind($,"error")),J.once("close",$.emitClose.bind($))}function k2($,J,N){if(J){let G=JJ(J)?J.size:YJ(J).length;if($._socket)$._sender._bufferedBytes+=G;else $._bufferedAmount+=G}if(N){let G=Error(`WebSocket is not open: readyState ${$.readyState} (${L1[$.readyState]})`);process.nextTick(N,G)}}function RJ($,J){let N=this[h];if(N._closeFrameReceived=!0,N._closeMessage=J,N._closeCode=$,N._socket[h]===void 0)return;if(N._socket.removeListener("data",V$),process.nextTick(E3,N._socket),$===1005)N.close();else N.close($,J)}function HJ(){let $=this[h];if(!$.isPaused)$._socket.resume()}function qJ($){let J=this[h];if(J._socket[h]!==void 0)J._socket.removeListener("data",V$),process.nextTick(E3,J._socket),J.close($[zJ]);if(!J._errorEmitted)J._errorEmitted=!0,J.emit("error",$)}function F3(){this[h].emitClose()}function UJ($,J){this[h].emit("message",$,J)}function BJ($){let J=this[h];if(J._autoPong)J.pong($,!this._isServer,g3);J.emit("ping",$)}function VJ($){this[h].emit("pong",$)}function E3($){$.resume()}function TJ($){let J=this[h];if(J.readyState===P.CLOSED)return;if(J.readyState===P.OPEN)J._readyState=P.CLOSING,w3(J);if(this._socket.end(),!J._errorEmitted)J._errorEmitted=!0,J.emit("error",$)}function w3($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function v3(){let $=this[h];if(this.removeListener("close",v3),this.removeListener("data",V$),this.removeListener("end",u3),$._readyState=P.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let J=this.read(this._readableState.length);$._receiver.write(J)}if($._receiver.end(),this[h]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",F3),$._receiver.on("finish",F3)}function V$($){if(!this[h]._receiver.write($))this.pause()}function u3(){let $=this[h];$._readyState=P.CLOSING,$._receiver.end(),this.end()}function b3(){let $=this[h];if(this.removeListener("error",b3),this.on("error",g3),$)$._readyState=P.CLOSING,this.destroy()}});var c3=u((UZ,h3)=>{var qZ=T$(),{Duplex:_J}=f("stream");function k3($){$.emit("close")}function CJ(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function m3($){if(this.removeListener("error",m3),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function LJ($,J){let N=!0,G=new _J({...J,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(z,X){let Q=!X&&G._readableState.objectMode?z.toString():z;if(!G.push(Q))$.pause()}),$.once("error",function(z){if(G.destroyed)return;N=!1,G.destroy(z)}),$.once("close",function(){if(G.destroyed)return;G.push(null)}),G._destroy=function(Z,z){if($.readyState===$.CLOSED){z(Z),process.nextTick(k3,G);return}let X=!1;if($.once("error",function(M){X=!0,z(M)}),$.once("close",function(){if(!X)z(Z);process.nextTick(k3,G)}),N)$.terminate()},G._final=function(Z){if($.readyState===$.CONNECTING){$.once("open",function(){G._final(Z)});return}if($._socket===null)return;if($._socket._writableState.finished){if(Z(),G._readableState.endEmitted)G.destroy()}else $._socket.once("finish",function(){Z()}),$.close()},G._read=function(){if($.isPaused)$.resume()},G._write=function(Z,z,X){if($.readyState===$.CONNECTING){$.once("open",function(){G._write(Z,z,X)});return}$.send(Z,X)},G.on("end",CJ),G.on("error",m3),G}h3.exports=LJ});var i3=u((BZ,d3)=>{var{tokenChars:AJ}=t1();function DJ($){let J=new Set,N=-1,G=-1,Z=0;for(Z;Z<$.length;Z++){let X=$.charCodeAt(Z);if(G===-1&&AJ[X]===1){if(N===-1)N=Z}else if(Z!==0&&(X===32||X===9)){if(G===-1&&N!==-1)G=Z}else if(X===44){if(N===-1)throw SyntaxError(`Unexpected character at index ${Z}`);if(G===-1)G=Z;let Q=$.slice(N,G);if(J.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);J.add(Q),N=G=-1}else throw SyntaxError(`Unexpected character at index ${Z}`)}if(N===-1||G!==-1)throw SyntaxError("Unexpected end of input");let z=$.slice(N,Z);if(J.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);return J.add(z),J}d3.exports={parse:DJ}});var r3=u((TZ,o3)=>{var PJ=f("events"),_$=f("http"),{Duplex:VZ}=f("stream"),{createHash:WJ}=f("crypto"),n3=v2(),k1=T0(),SJ=i3(),FJ=T$(),{CLOSE_TIMEOUT:OJ,GUID:gJ,kWebSocket:fJ}=_1(),yJ=/^[+/0-9A-Za-z]{22}==$/;class s3 extends PJ{constructor($,J){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:OJ,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:FJ,...$},$.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=_$.createServer((N,G)=>{let Z=_$.STATUS_CODES[426];G.writeHead(426,{"Content-Length":Z.length,"Content-Type":"text/plain"}),G.end(Z)}),this._server.listen($.port,$.host,$.backlog,J);else if($.server)this._server=$.server;if(this._server){let N=this.emit.bind(this,"connection");this._removeListeners=EJ(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(G,Z,z)=>{this.handleUpgrade(G,Z,z,N)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(A0,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(A0,this);else this._shouldEmitClose=!0;else process.nextTick(A0,this)}else{let J=this._server;this._removeListeners(),this._removeListeners=this._server=null,J.close(()=>{A0(this)})}}shouldHandle($){if(this.options.path){let J=$.url.indexOf("?");if((J!==-1?$.url.slice(0,J):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,J,N,G){J.on("error",p3);let Z=$.headers["sec-websocket-key"],z=$.headers.upgrade,X=+$.headers["sec-websocket-version"];if($.method!=="GET"){m1(this,$,J,405,"Invalid HTTP method");return}if(z===void 0||z.toLowerCase()!=="websocket"){m1(this,$,J,400,"Invalid Upgrade header");return}if(Z===void 0||!yJ.test(Z)){m1(this,$,J,400,"Missing or invalid Sec-WebSocket-Key header");return}if(X!==13&&X!==8){m1(this,$,J,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){D0(J,400);return}let Q=$.headers["sec-websocket-protocol"],M=new Set;if(Q!==void 0)try{M=SJ.parse(Q)}catch(Y){m1(this,$,J,400,"Invalid Sec-WebSocket-Protocol header");return}let I=$.headers["sec-websocket-extensions"],K={};if(this.options.perMessageDeflate&&I!==void 0){let Y=new k1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let H=n3.parse(I);if(H[k1.extensionName])Y.accept(H[k1.extensionName]),K[k1.extensionName]=Y}catch(H){m1(this,$,J,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Y={origin:$.headers[`${X===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(Y,(H,R,j,x)=>{if(!H)return D0(J,R||401,j,x);this.completeUpgrade(K,Z,M,$,J,N,G)});return}if(!this.options.verifyClient(Y))return D0(J,401)}this.completeUpgrade(K,Z,M,$,J,N,G)}completeUpgrade($,J,N,G,Z,z,X){if(!Z.readable||!Z.writable)return Z.destroy();if(Z[fJ])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return D0(Z,503);let M=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${WJ("sha1").update(J+gJ).digest("base64")}`],I=new this.options.WebSocket(null,void 0,this.options);if(N.size){let K=this.options.handleProtocols?this.options.handleProtocols(N,G):N.values().next().value;if(K)M.push(`Sec-WebSocket-Protocol: ${K}`),I._protocol=K}if($[k1.extensionName]){let K=$[k1.extensionName].params,Y=n3.format({[k1.extensionName]:[K]});M.push(`Sec-WebSocket-Extensions: ${Y}`),I._extensions=$}if(this.emit("headers",M,G),Z.write(M.concat(`\r
24
24
  `).join(`\r
25
- `)),Z.removeListener("error",i3),I.setSocket(Z,z,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(I),I.on("close",()=>{if(this.clients.delete(I),this._shouldEmitClose&&!this.clients.size)process.nextTick(_0,this)});X(I,G)}}p3.exports=n3;function fJ($,J){for(let N of Object.keys(J))$.on(N,J[N]);return function(){for(let G of Object.keys(J))$.removeListener(G,J[G])}}function _0($){$._state=2,$.emit("close")}function i3(){this.destroy()}function C0($,J,N,G){N=N||V$.STATUS_CODES[J],G={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(N),...G},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${J} ${V$.STATUS_CODES[J]}\r
25
+ `)),Z.removeListener("error",p3),I.setSocket(Z,z,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(I),I.on("close",()=>{if(this.clients.delete(I),this._shouldEmitClose&&!this.clients.size)process.nextTick(A0,this)});X(I,G)}}o3.exports=s3;function EJ($,J){for(let N of Object.keys(J))$.on(N,J[N]);return function(){for(let G of Object.keys(J))$.removeListener(G,J[G])}}function A0($){$._state=2,$.emit("close")}function p3(){this.destroy()}function D0($,J,N,G){N=N||_$.STATUS_CODES[J],G={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(N),...G},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${J} ${_$.STATUS_CODES[J]}\r
26
26
  `+Object.keys(G).map((Z)=>`${Z}: ${G[Z]}`).join(`\r
27
27
  `)+`\r
28
28
  \r
29
- `+N)}function m1($,J,N,G,Z,z){if($.listenerCount("wsClientError")){let X=Error(Z);Error.captureStackTrace(X,m1),$.emit("wsClientError",X,N,J)}else C0(N,G,Z,z)}});var I4=k(M4(),1),{program:TN,createCommand:VN,createArgument:_N,createOption:CN,CommanderError:LN,InvalidArgumentError:AN,InvalidOptionArgumentError:DN,Command:Y4,Argument:PN,Option:SN,Help:WN}=I4.default;var V1=k(N1(),1);import{spawn as t5}from"node:child_process";import r from"node:fs";import O$ from"node:path";function x4($){try{return process.kill($,0),!0}catch(J){return!1}}async function H4($,J,N,G){let Z=O$.resolve(J),z=O$.resolve(G);if(!r.existsSync(Z))console.error(V1.default.red(`ERROR: Prompt file not found: ${Z}`)),process.exit(1);if(!r.existsSync(z))console.error(V1.default.red(`ERROR: Workspace directory not found: ${z}`)),process.exit(1);let X=`/tmp/subagent-${N}-${$}.log`,Q=`/tmp/subagent-${N}-${$}.pid`,M=r.readFileSync(Z,"utf-8"),I=r.openSync(X,"w");console.log(V1.default.blue(`[${$}] Spawning subagent...`)),console.log(V1.default.dim(` Workspace: ${z}`)),console.log(V1.default.dim(` Log: ${X}`));let K=t5("gemini",["-p",M,"--yolo"],{cwd:z,stdio:["ignore",I,I],detached:!1});if(!K.pid)console.error(V1.default.red(`[${$}] Failed to spawn process`)),process.exit(1);r.writeFileSync(Q,K.pid.toString()),console.log(V1.default.green(`[${$}] Started with PID ${K.pid}`));let Y=()=>{try{if(r.existsSync(Q))r.unlinkSync(Q);if(r.existsSync(X))r.unlinkSync(X)}catch(R){}},H=()=>{if(K.pid&&x4(K.pid))process.kill(K.pid);Y(),process.exit()};process.on("SIGINT",H),process.on("SIGTERM",H),K.on("exit",(R)=>{console.log(V1.default.blue(`[${$}] Exited with code ${R}`)),Y(),process.exit(R??0)})}async function R4($,J,N=process.cwd()){let G={};for(let Z of J){let z=O$.join(N,".serena","memories",`result-${Z}.md`),X=`/tmp/subagent-${$}-${Z}.pid`;if(r.existsSync(z)){let M=r.readFileSync(z,"utf-8").match(/^## Status:\s*(\S+)/m);if(M?.[1])G[Z]=M[1];else G[Z]="completed"}else if(r.existsSync(X)){let Q=r.readFileSync(X,"utf-8").trim(),M=parseInt(Q,10);if(!Number.isNaN(M)&&x4(M))G[Z]="running";else G[Z]="crashed"}else G[Z]="crashed"}for(let[Z,z]of Object.entries(G))console.log(`${Z}:${z}`)}import{spawn as e5}from"node:child_process";import $6 from"node:http";import J6 from"node:https";var N6="http://localhost:12341/sse";async function q4($){let J=$||N6,N=J.replace("/sse","/mcp"),G=new URL(J),z=G.protocol==="https:"?J6:$6,X=null,Q=!1;async function M(){return new Promise((U)=>{let T=z.get(J,(B)=>{U(!0),T.destroy()});T.on("error",()=>{U(!1)}),T.end()})}async function I(){let U=G.port||"12341",T=G.hostname||"0.0.0.0";if(console.error(`Starting Serena server on ${T}:${U}...`),X=e5("uvx",["--from","git+https://github.com/oraios/serena","serena-mcp-server","--host",T,"--port",U,"--context","ide","--open-web-dashboard","false"],{stdio:"pipe",detached:!1}),X.stderr)X.stderr.on("data",(_)=>{process.stderr.write(`[Serena] ${_}`)});X.on("error",(_)=>{console.error("Failed to start Serena server:",_),process.exit(1)}),X.on("exit",(_,A)=>{if(console.error(`Serena server exited with code ${_} signal ${A}`),!Q)process.exit(_||1)}),console.error("Waiting for Serena to be ready...");for(let _=0;_<30;_++){if(await M()){console.error("Serena server is ready!");return}await new Promise((A)=>setTimeout(A,1000))}console.error("Timed out waiting for Serena server to start."),process.exit(1)}if(!await M())await I();else console.error(`Connected to existing Serena server at ${J}`);function Y(){let U={method:"GET",headers:{Accept:"text/event-stream","Cache-Control":"no-cache"}},T=z.request(J,U,(B)=>{if(B.statusCode!==200){console.error(`SSE connection failed: ${B.statusCode}`);return}let _="";B.on("data",(A)=>{_+=A.toString();let L=_.split(`
30
- `);_=L.pop()||"";let D="message",V="";for(let C of L)if(C.startsWith("event:"))D=C.slice(6).trim();else if(C.startsWith("data:"))V=C.slice(5).trim();else if(C===""&&V)H(D,V),D="message",V=""}),B.on("end",()=>{console.error("SSE connection closed, reconnecting..."),setTimeout(Y,1000)}),B.on("error",(A)=>{console.error("SSE error:",A.message),setTimeout(Y,1000)})});T.on("error",(B)=>{console.error("SSE connection error:",B.message),setTimeout(Y,1000)}),T.end()}function H(U,T){try{if(U==="message"||U==="endpoint")return;let B=JSON.parse(T);process.stdout.write(`${JSON.stringify(B)}
31
- `)}catch(B){}}let R="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(U)=>{R+=U.toString();let T=R.split(`
32
- `);R=T.pop()||"";for(let B of T)if(B.trim())x(B.trim())});function x(U){try{let T=JSON.parse(U),B=JSON.stringify(T),_=new URL(N),A={hostname:_.hostname,port:_.port,path:_.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(B)}},L=z.request(A,(D)=>{let V="";D.on("data",(C)=>{V+=C.toString()}),D.on("end",()=>{if(V.trim())process.stdout.write(`${V}
33
- `)})});L.on("error",(D)=>{let V={jsonrpc:"2.0",id:T.id,error:{code:-32603,message:`Bridge error: ${D.message}`}};process.stdout.write(`${JSON.stringify(V)}
34
- `)}),L.write(B),L.end()}catch(T){let B=T instanceof Error?T.message:String(T);console.error("Failed to parse IDE message:",B)}}Y(),process.stdin.resume();let j=()=>{if(Q=!0,X)console.error("Stopping Serena server..."),X.kill("SIGTERM");process.exit(0)};process.on("SIGINT",j),process.on("SIGTERM",j)}import{execSync as s}from"node:child_process";import{existsSync as J2,readdirSync as N2,readFileSync as G2}from"node:fs";import{join as I0}from"node:path";var G0=k(N1(),1),i=k(f$(),1);import{stdout as b$,stdin as C4}from"node:process";import*as A1 from"node:readline";import z6 from"node:readline";import{ReadStream as B4}from"node:tty";var X6=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,Q6=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,M6=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,y$=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,g0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,f0=/\t{1,1000}/y,E$=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,y0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,I6=/\p{M}+/gu,Y6={limit:1/0,ellipsis:""},L4=($,J={},N={})=>{let G=J.limit??1/0,Z=J.ellipsis??"",z=J?.ellipsisWidth??(Z?L4(Z,Y6,N).width:0),X=N.ansiWidth??0,Q=N.controlWidth??0,M=N.tabWidth??8,I=N.ambiguousWidth??1,K=N.emojiWidth??2,Y=N.fullWidthWidth??2,H=N.regularWidth??1,R=N.wideWidth??2,x=0,j=0,U=$.length,T=0,B=!1,_=U,A=Math.max(0,G-z),L=0,D=0,V=0,C=0;$:for(;;){if(D>L||j>=U&&j>x){let l=$.slice(L,D)||$.slice(x,j);T=0;for(let p of l.replaceAll(I6,"")){let o=p.codePointAt(0)||0;if(Q6(o)?C=Y:M6(o)?C=R:I!==H&&X6(o)?C=I:C=H,V+C>A&&(_=Math.min(_,Math.max(L,x)+T)),V+C>G){B=!0;break $}T+=p.length,V+=C}L=D=0}if(j>=U)break;if(y0.lastIndex=j,y0.test($)){if(T=y0.lastIndex-j,C=T*H,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/H))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=y0.lastIndex;continue}if(y$.lastIndex=j,y$.test($)){if(V+X>A&&(_=Math.min(_,j)),V+X>G){B=!0;break}V+=X,L=x,D=j,j=x=y$.lastIndex;continue}if(g0.lastIndex=j,g0.test($)){if(T=g0.lastIndex-j,C=T*Q,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/Q))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=g0.lastIndex;continue}if(f0.lastIndex=j,f0.test($)){if(T=f0.lastIndex-j,C=T*M,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/M))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=f0.lastIndex;continue}if(E$.lastIndex=j,E$.test($)){if(V+K>A&&(_=Math.min(_,j)),V+K>G){B=!0;break}V+=K,L=x,D=j,j=x=E$.lastIndex;continue}j+=1}return{width:B?A:V,index:B?_:U,truncated:B,ellipsed:B&&G>=z}},K6={limit:1/0,ellipsis:"",ellipsisWidth:0},Z0=($,J={})=>L4($,K6,J).width,w0="\x1B",A4="›",j6=39,l$="\x07",D4="[",x6="]",P4="m",k$=`${x6}8;;`,T4=new RegExp(`(?:\\${D4}(?<code>\\d+)m|\\${k$}(?<uri>.*)${l$})`,"y"),H6=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},V4=($)=>`${w0}${D4}${$}${P4}`,_4=($)=>`${w0}${k$}${$}${l$}`,R6=($)=>$.map((J)=>Z0(J)),w$=($,J,N)=>{let G=J[Symbol.iterator](),Z=!1,z=!1,X=$.at(-1),Q=X===void 0?0:Z0(X),M=G.next(),I=G.next(),K=0;for(;!M.done;){let Y=M.value,H=Z0(Y);Q+H<=N?$[$.length-1]+=Y:($.push(Y),Q=0),(Y===w0||Y===A4)&&(Z=!0,z=J.startsWith(k$,K+1)),Z?z?Y===l$&&(Z=!1,z=!1):Y===P4&&(Z=!1):(Q+=H,Q===N&&!I.done&&($.push(""),Q=0)),M=I,I=G.next(),K+=Y.length}X=$.at(-1),!Q&&X!==void 0&&X.length>0&&$.length>1&&($[$.length-2]+=$.pop())},q6=($)=>{let J=$.split(" "),N=J.length;for(;N>0&&!(Z0(J[N-1])>0);)N--;return N===J.length?$:J.slice(0,N).join(" ")+J.slice(N).join("")},U6=($,J,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",Z,z,X=$.split(" "),Q=R6(X),M=[""];for(let[x,j]of X.entries()){N.trim!==!1&&(M[M.length-1]=(M.at(-1)??"").trimStart());let U=Z0(M.at(-1)??"");if(x!==0&&(U>=J&&(N.wordWrap===!1||N.trim===!1)&&(M.push(""),U=0),(U>0||N.trim===!1)&&(M[M.length-1]+=" ",U++)),N.hard&&Q[x]>J){let T=J-U,B=1+Math.floor((Q[x]-T-1)/J);Math.floor((Q[x]-1)/J)<B&&M.push(""),w$(M,j,J);continue}if(U+Q[x]>J&&U>0&&Q[x]>0){if(N.wordWrap===!1&&U<J){w$(M,j,J);continue}M.push("")}if(U+Q[x]>J&&N.wordWrap===!1){w$(M,j,J);continue}M[M.length-1]+=j}N.trim!==!1&&(M=M.map((x)=>q6(x)));let I=M.join(`
35
- `),K=I[Symbol.iterator](),Y=K.next(),H=K.next(),R=0;for(;!Y.done;){let x=Y.value,j=H.value;if(G+=x,x===w0||x===A4){T4.lastIndex=R+1;let T=T4.exec(I)?.groups;if(T?.code!==void 0){let B=Number.parseFloat(T.code);Z=B===j6?void 0:B}else T?.uri!==void 0&&(z=T.uri.length===0?void 0:T.uri)}let U=Z?H6(Z):void 0;j===`
36
- `?(z&&(G+=_4("")),Z&&U&&(G+=V4(U))):x===`
37
- `&&(Z&&U&&(G+=V4(Z)),z&&(G+=_4(z))),R+=x.length,Y=H,H=K.next()}return G};function v$($,J,N){return String($).normalize().replaceAll(`\r
29
+ `+N)}function m1($,J,N,G,Z,z){if($.listenerCount("wsClientError")){let X=Error(Z);Error.captureStackTrace(X,m1),$.emit("wsClientError",X,N,J)}else D0(N,G,Z,z)}});var I4=k(M4(),1),{program:_N,createCommand:CN,createArgument:LN,createOption:AN,CommanderError:DN,InvalidArgumentError:PN,InvalidOptionArgumentError:WN,Command:Y4,Argument:SN,Option:FN,Help:ON}=I4.default;var T1=k(N1(),1);import{spawn as $6}from"node:child_process";import r from"node:fs";import g$ from"node:path";function x4($){try{return process.kill($,0),!0}catch(J){return!1}}async function R4($,J,N,G){let Z=g$.resolve(J),z=g$.resolve(G);if(!r.existsSync(Z))console.error(T1.default.red(`ERROR: Prompt file not found: ${Z}`)),process.exit(1);if(!r.existsSync(z))console.error(T1.default.red(`ERROR: Workspace directory not found: ${z}`)),process.exit(1);let X=`/tmp/subagent-${N}-${$}.log`,Q=`/tmp/subagent-${N}-${$}.pid`,M=r.readFileSync(Z,"utf-8"),I=r.openSync(X,"w");console.log(T1.default.blue(`[${$}] Spawning subagent...`)),console.log(T1.default.dim(` Workspace: ${z}`)),console.log(T1.default.dim(` Log: ${X}`));let K=$6("gemini",["-p",M,"--yolo"],{cwd:z,stdio:["ignore",I,I],detached:!1});if(!K.pid)console.error(T1.default.red(`[${$}] Failed to spawn process`)),process.exit(1);r.writeFileSync(Q,K.pid.toString()),console.log(T1.default.green(`[${$}] Started with PID ${K.pid}`));let Y=()=>{try{if(r.existsSync(Q))r.unlinkSync(Q);if(r.existsSync(X))r.unlinkSync(X)}catch(R){}},H=()=>{if(K.pid&&x4(K.pid))process.kill(K.pid);Y(),process.exit()};process.on("SIGINT",H),process.on("SIGTERM",H),K.on("exit",(R)=>{console.log(T1.default.blue(`[${$}] Exited with code ${R}`)),Y(),process.exit(R??0)})}async function H4($,J,N=process.cwd()){let G={};for(let Z of J){let z=g$.join(N,".serena","memories",`result-${Z}.md`),X=`/tmp/subagent-${$}-${Z}.pid`;if(r.existsSync(z)){let M=r.readFileSync(z,"utf-8").match(/^## Status:\s*(\S+)/m);if(M?.[1])G[Z]=M[1];else G[Z]="completed"}else if(r.existsSync(X)){let Q=r.readFileSync(X,"utf-8").trim(),M=parseInt(Q,10);if(!Number.isNaN(M)&&x4(M))G[Z]="running";else G[Z]="crashed"}else G[Z]="crashed"}for(let[Z,z]of Object.entries(G))console.log(`${Z}:${z}`)}import{spawn as J6}from"node:child_process";import N6 from"node:http";import G6 from"node:https";var Z6="http://localhost:12341/sse";async function q4($){let J=$||Z6,N=J.replace("/sse","/mcp"),G=new URL(J),z=G.protocol==="https:"?G6:N6,X=null,Q=!1;async function M(){return new Promise((U)=>{let B=z.get(J,(V)=>{U(!0),B.destroy()});B.on("error",()=>{U(!1)}),B.end()})}async function I(){let U=G.port||"12341",B=G.hostname||"0.0.0.0";if(console.error(`Starting Serena server on ${B}:${U}...`),X=J6("uvx",["--from","git+https://github.com/oraios/serena","serena-mcp-server","--host",B,"--port",U,"--context","ide","--open-web-dashboard","false"],{stdio:"pipe",detached:!1}),X.stderr)X.stderr.on("data",(_)=>{process.stderr.write(`[Serena] ${_}`)});X.on("error",(_)=>{console.error("Failed to start Serena server:",_),process.exit(1)}),X.on("exit",(_,L)=>{if(console.error(`Serena server exited with code ${_} signal ${L}`),!Q)process.exit(_||1)}),console.error("Waiting for Serena to be ready...");for(let _=0;_<30;_++){if(await M()){console.error("Serena server is ready!");return}await new Promise((L)=>setTimeout(L,1000))}console.error("Timed out waiting for Serena server to start."),process.exit(1)}if(!await M())await I();else console.error(`Connected to existing Serena server at ${J}`);function Y(){let U={method:"GET",headers:{Accept:"text/event-stream","Cache-Control":"no-cache"}},B=z.request(J,U,(V)=>{if(V.statusCode!==200){console.error(`SSE connection failed: ${V.statusCode}`);return}let _="";V.on("data",(L)=>{_+=L.toString();let A=_.split(`
30
+ `);_=A.pop()||"";let D="message",T="";for(let C of A)if(C.startsWith("event:"))D=C.slice(6).trim();else if(C.startsWith("data:"))T=C.slice(5).trim();else if(C===""&&T)H(D,T),D="message",T=""}),V.on("end",()=>{console.error("SSE connection closed, reconnecting..."),setTimeout(Y,1000)}),V.on("error",(L)=>{console.error("SSE error:",L.message),setTimeout(Y,1000)})});B.on("error",(V)=>{console.error("SSE connection error:",V.message),setTimeout(Y,1000)}),B.end()}function H(U,B){try{if(U==="message"||U==="endpoint")return;let V=JSON.parse(B);process.stdout.write(`${JSON.stringify(V)}
31
+ `)}catch(V){}}let R="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(U)=>{R+=U.toString();let B=R.split(`
32
+ `);R=B.pop()||"";for(let V of B)if(V.trim())j(V.trim())});function j(U){try{let B=JSON.parse(U),V=JSON.stringify(B),_=new URL(N),L={hostname:_.hostname,port:_.port,path:_.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(V)}},A=z.request(L,(D)=>{let T="";D.on("data",(C)=>{T+=C.toString()}),D.on("end",()=>{if(T.trim())process.stdout.write(`${T}
33
+ `)})});A.on("error",(D)=>{let T={jsonrpc:"2.0",id:B.id,error:{code:-32603,message:`Bridge error: ${D.message}`}};process.stdout.write(`${JSON.stringify(T)}
34
+ `)}),A.write(V),A.end()}catch(B){let V=B instanceof Error?B.message:String(B);console.error("Failed to parse IDE message:",V)}}Y(),process.stdin.resume();let x=()=>{if(Q=!0,X)console.error("Stopping Serena server..."),X.kill("SIGTERM");process.exit(0)};process.on("SIGINT",x),process.on("SIGTERM",x)}import{execSync as s}from"node:child_process";import{existsSync as N2,readdirSync as G2,readFileSync as Z2}from"node:fs";import{join as K0}from"node:path";var z0=k(N1(),1),i=k(y$(),1);import{stdout as l$,stdin as C4}from"node:process";import*as A1 from"node:readline";import Q6 from"node:readline";import{ReadStream as B4}from"node:tty";var M6=($)=>$===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,I6=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,Y6=($)=>$>=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,E$=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,E0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,w0=/\t{1,1000}/y,w$=/[\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,v0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,K6=/\p{M}+/gu,j6={limit:1/0,ellipsis:""},L4=($,J={},N={})=>{let G=J.limit??1/0,Z=J.ellipsis??"",z=J?.ellipsisWidth??(Z?L4(Z,j6,N).width:0),X=N.ansiWidth??0,Q=N.controlWidth??0,M=N.tabWidth??8,I=N.ambiguousWidth??1,K=N.emojiWidth??2,Y=N.fullWidthWidth??2,H=N.regularWidth??1,R=N.wideWidth??2,j=0,x=0,U=$.length,B=0,V=!1,_=U,L=Math.max(0,G-z),A=0,D=0,T=0,C=0;$:for(;;){if(D>A||x>=U&&x>j){let l=$.slice(A,D)||$.slice(j,x);B=0;for(let p of l.replaceAll(K6,"")){let o=p.codePointAt(0)||0;if(I6(o)?C=Y:Y6(o)?C=R:I!==H&&M6(o)?C=I:C=H,T+C>L&&(_=Math.min(_,Math.max(A,j)+B)),T+C>G){V=!0;break $}B+=p.length,T+=C}A=D=0}if(x>=U)break;if(v0.lastIndex=x,v0.test($)){if(B=v0.lastIndex-x,C=B*H,T+C>L&&(_=Math.min(_,x+Math.floor((L-T)/H))),T+C>G){V=!0;break}T+=C,A=j,D=x,x=j=v0.lastIndex;continue}if(E$.lastIndex=x,E$.test($)){if(T+X>L&&(_=Math.min(_,x)),T+X>G){V=!0;break}T+=X,A=j,D=x,x=j=E$.lastIndex;continue}if(E0.lastIndex=x,E0.test($)){if(B=E0.lastIndex-x,C=B*Q,T+C>L&&(_=Math.min(_,x+Math.floor((L-T)/Q))),T+C>G){V=!0;break}T+=C,A=j,D=x,x=j=E0.lastIndex;continue}if(w0.lastIndex=x,w0.test($)){if(B=w0.lastIndex-x,C=B*M,T+C>L&&(_=Math.min(_,x+Math.floor((L-T)/M))),T+C>G){V=!0;break}T+=C,A=j,D=x,x=j=w0.lastIndex;continue}if(w$.lastIndex=x,w$.test($)){if(T+K>L&&(_=Math.min(_,x)),T+K>G){V=!0;break}T+=K,A=j,D=x,x=j=w$.lastIndex;continue}x+=1}return{width:V?L:T,index:V?_:U,truncated:V,ellipsed:V&&G>=z}},x6={limit:1/0,ellipsis:"",ellipsisWidth:0},X0=($,J={})=>L4($,x6,J).width,b0="\x1B",A4="›",R6=39,k$="\x07",D4="[",H6="]",P4="m",m$=`${H6}8;;`,V4=new RegExp(`(?:\\${D4}(?<code>\\d+)m|\\${m$}(?<uri>.*)${k$})`,"y"),q6=($)=>{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},T4=($)=>`${b0}${D4}${$}${P4}`,_4=($)=>`${b0}${m$}${$}${k$}`,U6=($)=>$.map((J)=>X0(J)),v$=($,J,N)=>{let G=J[Symbol.iterator](),Z=!1,z=!1,X=$.at(-1),Q=X===void 0?0:X0(X),M=G.next(),I=G.next(),K=0;for(;!M.done;){let Y=M.value,H=X0(Y);Q+H<=N?$[$.length-1]+=Y:($.push(Y),Q=0),(Y===b0||Y===A4)&&(Z=!0,z=J.startsWith(m$,K+1)),Z?z?Y===k$&&(Z=!1,z=!1):Y===P4&&(Z=!1):(Q+=H,Q===N&&!I.done&&($.push(""),Q=0)),M=I,I=G.next(),K+=Y.length}X=$.at(-1),!Q&&X!==void 0&&X.length>0&&$.length>1&&($[$.length-2]+=$.pop())},B6=($)=>{let J=$.split(" "),N=J.length;for(;N>0&&!(X0(J[N-1])>0);)N--;return N===J.length?$:J.slice(0,N).join(" ")+J.slice(N).join("")},V6=($,J,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",Z,z,X=$.split(" "),Q=U6(X),M=[""];for(let[j,x]of X.entries()){N.trim!==!1&&(M[M.length-1]=(M.at(-1)??"").trimStart());let U=X0(M.at(-1)??"");if(j!==0&&(U>=J&&(N.wordWrap===!1||N.trim===!1)&&(M.push(""),U=0),(U>0||N.trim===!1)&&(M[M.length-1]+=" ",U++)),N.hard&&Q[j]>J){let B=J-U,V=1+Math.floor((Q[j]-B-1)/J);Math.floor((Q[j]-1)/J)<V&&M.push(""),v$(M,x,J);continue}if(U+Q[j]>J&&U>0&&Q[j]>0){if(N.wordWrap===!1&&U<J){v$(M,x,J);continue}M.push("")}if(U+Q[j]>J&&N.wordWrap===!1){v$(M,x,J);continue}M[M.length-1]+=x}N.trim!==!1&&(M=M.map((j)=>B6(j)));let I=M.join(`
35
+ `),K=I[Symbol.iterator](),Y=K.next(),H=K.next(),R=0;for(;!Y.done;){let j=Y.value,x=H.value;if(G+=j,j===b0||j===A4){V4.lastIndex=R+1;let B=V4.exec(I)?.groups;if(B?.code!==void 0){let V=Number.parseFloat(B.code);Z=V===R6?void 0:V}else B?.uri!==void 0&&(z=B.uri.length===0?void 0:B.uri)}let U=Z?q6(Z):void 0;x===`
36
+ `?(z&&(G+=_4("")),Z&&U&&(G+=T4(U))):j===`
37
+ `&&(Z&&U&&(G+=T4(Z)),z&&(G+=_4(z))),R+=j.length,Y=H,H=K.next()}return G};function u$($,J,N){return String($).normalize().replaceAll(`\r
38
38
  `,`
39
39
  `).split(`
40
- `).map((G)=>U6(G,J,N)).join(`
41
- `)}var B6=["up","down","left","right","space","enter","cancel"],Q1={actions:new Set(B6),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function m$($,J){if(typeof $=="string")return Q1.aliases.get($)===J;for(let N of $)if(N!==void 0&&m$(N,J))return!0;return!1}function T6($,J){if($===J)return;let N=$.split(`
40
+ `).map((G)=>V6(G,J,N)).join(`
41
+ `)}var T6=["up","down","left","right","space","enter","cancel"],M1={actions:new Set(T6),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 h$($,J){if(typeof $=="string")return M1.aliases.get($)===J;for(let N of $)if(N!==void 0&&h$(N,J))return!0;return!1}function _6($,J){if($===J)return;let N=$.split(`
42
42
  `),G=J.split(`
43
- `),Z=Math.max(N.length,G.length),z=[];for(let X=0;X<Z;X++)N[X]!==G[X]&&z.push(X);return{lines:z,numLinesBefore:N.length,numLinesAfter:G.length,numLines:Z}}var V6=globalThis.process.platform.startsWith("win"),u$=Symbol("clack:cancel");function c($){return $===u$}function E0($,J){let N=$;N.isTTY&&N.setRawMode(J)}function S4({input:$=C4,output:J=b$,overwrite:N=!0,hideCursor:G=!0}={}){let Z=A1.createInterface({input:$,output:J,prompt:"",tabSize:1});A1.emitKeypressEvents($,Z),$ instanceof B4&&$.isTTY&&$.setRawMode(!0);let z=(X,{name:Q,sequence:M})=>{let I=String(X);if(m$([I,Q,M],"cancel")){G&&J.write(i.cursor.show),process.exit(0);return}if(!N)return;A1.moveCursor(J,Q==="return"?0:-1,Q==="return"?-1:0,()=>{A1.clearLine(J,1,()=>{$.once("keypress",z)})})};return G&&J.write(i.cursor.hide),$.once("keypress",z),()=>{$.off("keypress",z),G&&J.write(i.cursor.show),$ instanceof B4&&$.isTTY&&!V6&&$.setRawMode(!1),Z.terminal=!1,Z.close()}}var z0=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,h$=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20;function y1($,J,N,G=N){let Z=z0($??b$);return v$(J,Z-N.length,{hard:!0,trim:!1}).split(`
43
+ `),Z=Math.max(N.length,G.length),z=[];for(let X=0;X<Z;X++)N[X]!==G[X]&&z.push(X);return{lines:z,numLinesBefore:N.length,numLinesAfter:G.length,numLines:Z}}var C6=globalThis.process.platform.startsWith("win"),b$=Symbol("clack:cancel");function c($){return $===b$}function u0($,J){let N=$;N.isTTY&&N.setRawMode(J)}function W4({input:$=C4,output:J=l$,overwrite:N=!0,hideCursor:G=!0}={}){let Z=A1.createInterface({input:$,output:J,prompt:"",tabSize:1});A1.emitKeypressEvents($,Z),$ instanceof B4&&$.isTTY&&$.setRawMode(!0);let z=(X,{name:Q,sequence:M})=>{let I=String(X);if(h$([I,Q,M],"cancel")){G&&J.write(i.cursor.show),process.exit(0);return}if(!N)return;A1.moveCursor(J,Q==="return"?0:-1,Q==="return"?-1:0,()=>{A1.clearLine(J,1,()=>{$.once("keypress",z)})})};return G&&J.write(i.cursor.hide),$.once("keypress",z),()=>{$.off("keypress",z),G&&J.write(i.cursor.show),$ instanceof B4&&$.isTTY&&!C6&&$.setRawMode(!1),Z.terminal=!1,Z.close()}}var Q0=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,c$=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20;function y1($,J,N,G=N){let Z=Q0($??l$);return u$(J,Z-N.length,{hard:!0,trim:!1}).split(`
44
44
  `).map((z,X)=>`${X===0?G:N}${z}`).join(`
45
- `)}class E1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,J=!0){let{input:N=C4,output:G=b$,render:Z,signal:z,...X}=$;this.opts=X,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Z.bind(this),this._track=J,this._abortSignal=z,this.input=N,this.output=G}unsubscribe(){this._subscribers.clear()}setSubscriber($,J){let N=this._subscribers.get($)??[];N.push(J),this._subscribers.set($,N)}on($,J){this.setSubscriber($,{cb:J})}once($,J){this.setSubscriber($,{cb:J,once:!0})}emit($,...J){let N=this._subscribers.get($)??[],G=[];for(let Z of N)Z.cb(...J),Z.once&&G.push(()=>N.splice(N.indexOf(Z),1));for(let Z of G)Z()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(u$);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=z6.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),E0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(i.cursor.show),this.output.off("resize",this.render),E0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(i.cursor.show),this.output.off("resize",this.render),E0(this.input,!1),$(u$)})})}_isActionKey($,J){return $==="\t"}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,J){this.userInput=$??"",this.emit("userInput",this.userInput),J&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,J){if(this._track&&J.name!=="return"&&(J.name&&this._isActionKey($,J)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),J?.name&&(!this._track&&Q1.aliases.has(J.name)&&this.emit("cursor",Q1.aliases.get(J.name)),Q1.actions.has(J.name)&&this.emit("cursor",J.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$?.toLowerCase(),J),J?.name==="return"){if(this.opts.validate){let N=this.opts.validate(this.value);N&&(this.error=N instanceof Error?N.message:N,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}m$([$,J?.name,J?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
46
- `),E0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=v$(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
47
- `).length-1;this.output.write(i.cursor.move(-999,$*-1))}render(){let $=v$(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(i.cursor.hide);else{let J=T6(this._prevFrame,$),N=h$(this.output);if(this.restoreCursor(),J){let G=Math.max(0,J.numLinesAfter-N),Z=Math.max(0,J.numLinesBefore-N),z=J.lines.find((X)=>X>=G);if(z===void 0){this._prevFrame=$;return}if(J.lines.length===1){this.output.write(i.cursor.move(0,z-Z)),this.output.write(i.erase.lines(1));let X=$.split(`
45
+ `)}class E1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,J=!0){let{input:N=C4,output:G=l$,render:Z,signal:z,...X}=$;this.opts=X,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Z.bind(this),this._track=J,this._abortSignal=z,this.input=N,this.output=G}unsubscribe(){this._subscribers.clear()}setSubscriber($,J){let N=this._subscribers.get($)??[];N.push(J),this._subscribers.set($,N)}on($,J){this.setSubscriber($,{cb:J})}once($,J){this.setSubscriber($,{cb:J,once:!0})}emit($,...J){let N=this._subscribers.get($)??[],G=[];for(let Z of N)Z.cb(...J),Z.once&&G.push(()=>N.splice(N.indexOf(Z),1));for(let Z of G)Z()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(b$);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Q6.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),u0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(i.cursor.show),this.output.off("resize",this.render),u0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(i.cursor.show),this.output.off("resize",this.render),u0(this.input,!1),$(b$)})})}_isActionKey($,J){return $==="\t"}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,J){this.userInput=$??"",this.emit("userInput",this.userInput),J&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,J){if(this._track&&J.name!=="return"&&(J.name&&this._isActionKey($,J)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),J?.name&&(!this._track&&M1.aliases.has(J.name)&&this.emit("cursor",M1.aliases.get(J.name)),M1.actions.has(J.name)&&this.emit("cursor",J.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$?.toLowerCase(),J),J?.name==="return"){if(this.opts.validate){let N=this.opts.validate(this.value);N&&(this.error=N instanceof Error?N.message:N,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}h$([$,J?.name,J?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
46
+ `),u0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=u$(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
47
+ `).length-1;this.output.write(i.cursor.move(-999,$*-1))}render(){let $=u$(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(i.cursor.hide);else{let J=_6(this._prevFrame,$),N=c$(this.output);if(this.restoreCursor(),J){let G=Math.max(0,J.numLinesAfter-N),Z=Math.max(0,J.numLinesBefore-N),z=J.lines.find((X)=>X>=G);if(z===void 0){this._prevFrame=$;return}if(J.lines.length===1){this.output.write(i.cursor.move(0,z-Z)),this.output.write(i.erase.lines(1));let X=$.split(`
48
48
  `);this.output.write(X[z]),this._prevFrame=$,this.output.write(i.cursor.move(0,X.length-z-1));return}else if(J.lines.length>1){if(G<Z)z=G;else{let Q=z-Z;Q>0&&this.output.write(i.cursor.move(0,Q))}this.output.write(i.erase.down());let X=$.split(`
49
49
  `).slice(z);this.output.write(X.join(`
50
- `)),this._prevFrame=$;return}}this.output.write(i.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function _6($,J){if($===void 0||J.length===0)return 0;let N=J.findIndex((G)=>G.value===$);return N!==-1?N:0}function C6($,J){return(J.label??String(J.value)).toLowerCase().includes($.toLowerCase())}function L6($,J){if(J)return $?J:J[0]}class W4 extends E1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#N="";#G;#J;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return G0.default.inverse(G0.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[J,...N]=this.userInput.slice(this._cursor);return`${$}${G0.default.inverse(J)}${N.join("")}`}get options(){return typeof this.#J=="function"?this.#J():this.#J}constructor($){super($),this.#J=$.options;let J=this.options;this.filteredOptions=[...J],this.multiple=$.multiple===!0,this.#G=$.filter??C6;let N;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?N=$.initialValue:N=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(N=[this.options[0].value]),N)for(let G of N){let Z=J.findIndex((z)=>z.value===G);Z!==-1&&(this.toggleSelected(G),this.#$=Z)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(G,Z)=>this.#Z(G,Z)),this.on("userInput",(G)=>this.#z(G))}_isActionKey($,J){return $==="\t"||this.multiple&&this.isNavigating&&J.name==="space"&&$!==void 0&&$!==""}#Z($,J){let N=J.name==="up",G=J.name==="down",Z=J.name==="return";N||G?(this.#$=Math.max(0,Math.min(this.#$+(N?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Z?this.value=L6(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(J.name==="tab"||this.isNavigating&&J.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected($){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes($)?this.selectedValues=this.selectedValues.filter((J)=>J!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#z($){if($!==this.#N){this.#N=$;let J=this.options;$?this.filteredOptions=J.filter((N)=>this.#G($,N)):this.filteredOptions=[...J],this.#$=_6(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class c$ extends E1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(J)=>{this.output.write(i.cursor.move(0,-1)),this.value=J,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class F4 extends E1{options;cursor=0;#$;getGroupItems($){return this.options.filter((J)=>J.group===$)}isGroupSelected($){let J=this.getGroupItems($),N=this.value;return N===void 0?!1:J.every((G)=>N.includes(G.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let J=$.value,N=this.getGroupItems(J);this.isGroupSelected(J)?this.value=this.value.filter((G)=>N.findIndex((Z)=>Z.value===G)===-1):this.value=[...this.value,...N.map((G)=>G.value)],this.value=Array.from(new Set(this.value))}else{let J=this.value.includes($.value);this.value=J?this.value.filter((N)=>N!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:J}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(J).flatMap(([N,G])=>[{value:N,group:!0,label:N},...G.map((Z)=>({...Z,group:N}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),this.#$?0:1),this.on("cursor",(N)=>{switch(N){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function f1($,J,N){let G=$+J,Z=Math.max(N.length-1,0),z=G<0?Z:G>Z?0:G;return N[z].disabled?f1(z,J<0?-1:1,N):z}class d$ extends E1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,J=this.value!==void 0&&this.value.length===$.length;this.value=J?[]:$.map((N)=>N.value)}toggleInvert(){let $=this.value;if(!$)return;let J=this._enabledOptions.filter((N)=>!$.includes(N.value));this.value=J.map((N)=>N.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((J)=>J!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let J=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),0);this.cursor=this.options[J].disabled?f1(J,1,this.options):J,this.on("key",(N)=>{N==="a"&&this.toggleAll(),N==="i"&&this.toggleInvert()}),this.on("cursor",(N)=>{switch(N){case"left":case"up":this.cursor=f1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=f1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class i$ extends E1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let J=this.options.findIndex(({value:G})=>G===$.initialValue),N=J===-1?0:J;this.cursor=this.options[N].disabled?f1(N,1,this.options):N,this.changeValue(),this.on("cursor",(G)=>{switch(G){case"left":case"up":this.cursor=f1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=f1(this.cursor,1,this.options);break}this.changeValue()})}}class n$ extends E1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let J=$.slice(0,this.cursor),[N,...G]=$.slice(this.cursor);return`${J}${G0.default.inverse(N)}${G.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var q=k(N1(),1);import G1 from"node:process";var Q0=k(f$(),1);function A6(){return G1.platform!=="win32"?G1.env.TERM!=="linux":!!G1.env.CI||!!G1.env.WT_SESSION||!!G1.env.TERMINUS_SUBLIME||G1.env.ConEmuTask==="{cmd::Cmder}"||G1.env.TERM_PROGRAM==="Terminus-Sublime"||G1.env.TERM_PROGRAM==="vscode"||G1.env.TERM==="xterm-256color"||G1.env.TERM==="alacritty"||G1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var r$=A6(),D6=()=>process.env.CI==="true";var g=($,J)=>r$?$:J,P6=g("◆","*"),v4=g("■","x"),u4=g("▲","x"),m0=g("◇","o"),S6=g("┌","T"),W=g("│","|"),D1=g("└","—"),oN=g("┐","T"),rN=g("┘","—"),a$=g("●",">"),k0=g("○"," "),W6=g("◻","[•]"),O4=g("◼","[+]"),g4=g("◻","[ ]"),aN=g("▪","•"),f4=g("─","-"),F6=g("╮","+"),O6=g("├","+"),g6=g("╯","+"),f6=g("╰","+"),tN=g("╭","+"),y6=g("●","•"),E6=g("◆","*"),w6=g("▲","!"),v6=g("■","x"),h0=($)=>{switch($){case"initial":case"active":return q.default.cyan(P6);case"cancel":return q.default.red(v4);case"error":return q.default.yellow(u4);case"submit":return q.default.green(m0)}},b4=($)=>{switch($){case"initial":case"active":return q.default.cyan(W);case"cancel":return q.default.red(W);case"error":return q.default.yellow(W);case"submit":return q.default.green(W)}},u6=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,b6=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,l6=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,p$=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,v0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,u0=/\t{1,1000}/y,s$=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,b0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,k6=/\p{M}+/gu,m6={limit:1/0,ellipsis:""},l4=($,J={},N={})=>{let G=J.limit??1/0,Z=J.ellipsis??"",z=J?.ellipsisWidth??(Z?l4(Z,m6,N).width:0),X=N.ansiWidth??0,Q=N.controlWidth??0,M=N.tabWidth??8,I=N.ambiguousWidth??1,K=N.emojiWidth??2,Y=N.fullWidthWidth??2,H=N.regularWidth??1,R=N.wideWidth??2,x=0,j=0,U=$.length,T=0,B=!1,_=U,A=Math.max(0,G-z),L=0,D=0,V=0,C=0;$:for(;;){if(D>L||j>=U&&j>x){let l=$.slice(L,D)||$.slice(x,j);T=0;for(let p of l.replaceAll(k6,"")){let o=p.codePointAt(0)||0;if(b6(o)?C=Y:l6(o)?C=R:I!==H&&u6(o)?C=I:C=H,V+C>A&&(_=Math.min(_,Math.max(L,x)+T)),V+C>G){B=!0;break $}T+=p.length,V+=C}L=D=0}if(j>=U)break;if(b0.lastIndex=j,b0.test($)){if(T=b0.lastIndex-j,C=T*H,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/H))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=b0.lastIndex;continue}if(p$.lastIndex=j,p$.test($)){if(V+X>A&&(_=Math.min(_,j)),V+X>G){B=!0;break}V+=X,L=x,D=j,j=x=p$.lastIndex;continue}if(v0.lastIndex=j,v0.test($)){if(T=v0.lastIndex-j,C=T*Q,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/Q))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=v0.lastIndex;continue}if(u0.lastIndex=j,u0.test($)){if(T=u0.lastIndex-j,C=T*M,V+C>A&&(_=Math.min(_,j+Math.floor((A-V)/M))),V+C>G){B=!0;break}V+=C,L=x,D=j,j=x=u0.lastIndex;continue}if(s$.lastIndex=j,s$.test($)){if(V+K>A&&(_=Math.min(_,j)),V+K>G){B=!0;break}V+=K,L=x,D=j,j=x=s$.lastIndex;continue}j+=1}return{width:B?A:V,index:B?_:U,truncated:B,ellipsed:B&&G>=z}},h6={limit:1/0,ellipsis:"",ellipsisWidth:0},H1=($,J={})=>l4($,h6,J).width,c0="\x1B",k4="›",c6=39,e$="\x07",m4="[",d6="]",h4="m",$2=`${d6}8;;`,y4=new RegExp(`(?:\\${m4}(?<code>\\d+)m|\\${$2}(?<uri>.*)${e$})`,"y"),i6=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},E4=($)=>`${c0}${m4}${$}${h4}`,w4=($)=>`${c0}${$2}${$}${e$}`,n6=($)=>$.map((J)=>H1(J)),o$=($,J,N)=>{let G=J[Symbol.iterator](),Z=!1,z=!1,X=$.at(-1),Q=X===void 0?0:H1(X),M=G.next(),I=G.next(),K=0;for(;!M.done;){let Y=M.value,H=H1(Y);Q+H<=N?$[$.length-1]+=Y:($.push(Y),Q=0),(Y===c0||Y===k4)&&(Z=!0,z=J.startsWith($2,K+1)),Z?z?Y===e$&&(Z=!1,z=!1):Y===h4&&(Z=!1):(Q+=H,Q===N&&!I.done&&($.push(""),Q=0)),M=I,I=G.next(),K+=Y.length}X=$.at(-1),!Q&&X!==void 0&&X.length>0&&$.length>1&&($[$.length-2]+=$.pop())},p6=($)=>{let J=$.split(" "),N=J.length;for(;N>0&&!(H1(J[N-1])>0);)N--;return N===J.length?$:J.slice(0,N).join(" ")+J.slice(N).join("")},s6=($,J,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",Z,z,X=$.split(" "),Q=n6(X),M=[""];for(let[x,j]of X.entries()){N.trim!==!1&&(M[M.length-1]=(M.at(-1)??"").trimStart());let U=H1(M.at(-1)??"");if(x!==0&&(U>=J&&(N.wordWrap===!1||N.trim===!1)&&(M.push(""),U=0),(U>0||N.trim===!1)&&(M[M.length-1]+=" ",U++)),N.hard&&Q[x]>J){let T=J-U,B=1+Math.floor((Q[x]-T-1)/J);Math.floor((Q[x]-1)/J)<B&&M.push(""),o$(M,j,J);continue}if(U+Q[x]>J&&U>0&&Q[x]>0){if(N.wordWrap===!1&&U<J){o$(M,j,J);continue}M.push("")}if(U+Q[x]>J&&N.wordWrap===!1){o$(M,j,J);continue}M[M.length-1]+=j}N.trim!==!1&&(M=M.map((x)=>p6(x)));let I=M.join(`
51
- `),K=I[Symbol.iterator](),Y=K.next(),H=K.next(),R=0;for(;!Y.done;){let x=Y.value,j=H.value;if(G+=x,x===c0||x===k4){y4.lastIndex=R+1;let T=y4.exec(I)?.groups;if(T?.code!==void 0){let B=Number.parseFloat(T.code);Z=B===c6?void 0:B}else T?.uri!==void 0&&(z=T.uri.length===0?void 0:T.uri)}let U=Z?i6(Z):void 0;j===`
52
- `?(z&&(G+=w4("")),Z&&U&&(G+=E4(U))):x===`
53
- `&&(Z&&U&&(G+=E4(Z)),z&&(G+=w4(z))),R+=x.length,Y=H,H=K.next()}return G};function M0($,J,N){return String($).normalize().replaceAll(`\r
50
+ `)),this._prevFrame=$;return}}this.output.write(i.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function L6($,J){if($===void 0||J.length===0)return 0;let N=J.findIndex((G)=>G.value===$);return N!==-1?N:0}function A6($,J){return(J.label??String(J.value)).toLowerCase().includes($.toLowerCase())}function D6($,J){if(J)return $?J:J[0]}class S4 extends E1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#N="";#G;#J;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return z0.default.inverse(z0.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[J,...N]=this.userInput.slice(this._cursor);return`${$}${z0.default.inverse(J)}${N.join("")}`}get options(){return typeof this.#J=="function"?this.#J():this.#J}constructor($){super($),this.#J=$.options;let J=this.options;this.filteredOptions=[...J],this.multiple=$.multiple===!0,this.#G=$.filter??A6;let N;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?N=$.initialValue:N=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(N=[this.options[0].value]),N)for(let G of N){let Z=J.findIndex((z)=>z.value===G);Z!==-1&&(this.toggleSelected(G),this.#$=Z)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(G,Z)=>this.#Z(G,Z)),this.on("userInput",(G)=>this.#z(G))}_isActionKey($,J){return $==="\t"||this.multiple&&this.isNavigating&&J.name==="space"&&$!==void 0&&$!==""}#Z($,J){let N=J.name==="up",G=J.name==="down",Z=J.name==="return";N||G?(this.#$=Math.max(0,Math.min(this.#$+(N?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Z?this.value=D6(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(J.name==="tab"||this.isNavigating&&J.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected($){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes($)?this.selectedValues=this.selectedValues.filter((J)=>J!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#z($){if($!==this.#N){this.#N=$;let J=this.options;$?this.filteredOptions=J.filter((N)=>this.#G($,N)):this.filteredOptions=[...J],this.#$=L6(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class d$ extends E1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(J)=>{this.output.write(i.cursor.move(0,-1)),this.value=J,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class F4 extends E1{options;cursor=0;#$;getGroupItems($){return this.options.filter((J)=>J.group===$)}isGroupSelected($){let J=this.getGroupItems($),N=this.value;return N===void 0?!1:J.every((G)=>N.includes(G.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let J=$.value,N=this.getGroupItems(J);this.isGroupSelected(J)?this.value=this.value.filter((G)=>N.findIndex((Z)=>Z.value===G)===-1):this.value=[...this.value,...N.map((G)=>G.value)],this.value=Array.from(new Set(this.value))}else{let J=this.value.includes($.value);this.value=J?this.value.filter((N)=>N!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:J}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(J).flatMap(([N,G])=>[{value:N,group:!0,label:N},...G.map((Z)=>({...Z,group:N}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),this.#$?0:1),this.on("cursor",(N)=>{switch(N){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function f1($,J,N){let G=$+J,Z=Math.max(N.length-1,0),z=G<0?Z:G>Z?0:G;return N[z].disabled?f1(z,J<0?-1:1,N):z}class i$ extends E1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,J=this.value!==void 0&&this.value.length===$.length;this.value=J?[]:$.map((N)=>N.value)}toggleInvert(){let $=this.value;if(!$)return;let J=this._enabledOptions.filter((N)=>!$.includes(N.value));this.value=J.map((N)=>N.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((J)=>J!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let J=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),0);this.cursor=this.options[J].disabled?f1(J,1,this.options):J,this.on("key",(N)=>{N==="a"&&this.toggleAll(),N==="i"&&this.toggleInvert()}),this.on("cursor",(N)=>{switch(N){case"left":case"up":this.cursor=f1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=f1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class n$ extends E1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let J=this.options.findIndex(({value:G})=>G===$.initialValue),N=J===-1?0:J;this.cursor=this.options[N].disabled?f1(N,1,this.options):N,this.changeValue(),this.on("cursor",(G)=>{switch(G){case"left":case"up":this.cursor=f1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=f1(this.cursor,1,this.options);break}this.changeValue()})}}class p$ extends E1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let J=$.slice(0,this.cursor),[N,...G]=$.slice(this.cursor);return`${J}${z0.default.inverse(N)}${G.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var q=k(N1(),1);import G1 from"node:process";var I0=k(y$(),1);function P6(){return G1.platform!=="win32"?G1.env.TERM!=="linux":!!G1.env.CI||!!G1.env.WT_SESSION||!!G1.env.TERMINUS_SUBLIME||G1.env.ConEmuTask==="{cmd::Cmder}"||G1.env.TERM_PROGRAM==="Terminus-Sublime"||G1.env.TERM_PROGRAM==="vscode"||G1.env.TERM==="xterm-256color"||G1.env.TERM==="alacritty"||G1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var a$=P6(),W6=()=>process.env.CI==="true";var g=($,J)=>a$?$:J,S6=g("◆","*"),v4=g("■","x"),u4=g("▲","x"),d0=g("◇","o"),F6=g("┌","T"),F=g("│","|"),D1=g("└","—"),aN=g("┐","T"),tN=g("┘","—"),t$=g("●",">"),c0=g("○"," "),O6=g("◻","[•]"),O4=g("◼","[+]"),g4=g("◻","[ ]"),eN=g("▪","•"),f4=g("─","-"),g6=g("╮","+"),f6=g("├","+"),y6=g("╯","+"),E6=g("╰","+"),$G=g("╭","+"),w6=g("●","•"),v6=g("◆","*"),u6=g("▲","!"),b6=g("■","x"),i0=($)=>{switch($){case"initial":case"active":return q.default.cyan(S6);case"cancel":return q.default.red(v4);case"error":return q.default.yellow(u4);case"submit":return q.default.green(d0)}},b4=($)=>{switch($){case"initial":case"active":return q.default.cyan(F);case"cancel":return q.default.red(F);case"error":return q.default.yellow(F);case"submit":return q.default.green(F)}},l6=($)=>$===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,k6=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,m6=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,s$=/[\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,k0=/\t{1,1000}/y,o$=/[\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,m0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,h6=/\p{M}+/gu,c6={limit:1/0,ellipsis:""},l4=($,J={},N={})=>{let G=J.limit??1/0,Z=J.ellipsis??"",z=J?.ellipsisWidth??(Z?l4(Z,c6,N).width:0),X=N.ansiWidth??0,Q=N.controlWidth??0,M=N.tabWidth??8,I=N.ambiguousWidth??1,K=N.emojiWidth??2,Y=N.fullWidthWidth??2,H=N.regularWidth??1,R=N.wideWidth??2,j=0,x=0,U=$.length,B=0,V=!1,_=U,L=Math.max(0,G-z),A=0,D=0,T=0,C=0;$:for(;;){if(D>A||x>=U&&x>j){let l=$.slice(A,D)||$.slice(j,x);B=0;for(let p of l.replaceAll(h6,"")){let o=p.codePointAt(0)||0;if(k6(o)?C=Y:m6(o)?C=R:I!==H&&l6(o)?C=I:C=H,T+C>L&&(_=Math.min(_,Math.max(A,j)+B)),T+C>G){V=!0;break $}B+=p.length,T+=C}A=D=0}if(x>=U)break;if(m0.lastIndex=x,m0.test($)){if(B=m0.lastIndex-x,C=B*H,T+C>L&&(_=Math.min(_,x+Math.floor((L-T)/H))),T+C>G){V=!0;break}T+=C,A=j,D=x,x=j=m0.lastIndex;continue}if(s$.lastIndex=x,s$.test($)){if(T+X>L&&(_=Math.min(_,x)),T+X>G){V=!0;break}T+=X,A=j,D=x,x=j=s$.lastIndex;continue}if(l0.lastIndex=x,l0.test($)){if(B=l0.lastIndex-x,C=B*Q,T+C>L&&(_=Math.min(_,x+Math.floor((L-T)/Q))),T+C>G){V=!0;break}T+=C,A=j,D=x,x=j=l0.lastIndex;continue}if(k0.lastIndex=x,k0.test($)){if(B=k0.lastIndex-x,C=B*M,T+C>L&&(_=Math.min(_,x+Math.floor((L-T)/M))),T+C>G){V=!0;break}T+=C,A=j,D=x,x=j=k0.lastIndex;continue}if(o$.lastIndex=x,o$.test($)){if(T+K>L&&(_=Math.min(_,x)),T+K>G){V=!0;break}T+=K,A=j,D=x,x=j=o$.lastIndex;continue}x+=1}return{width:V?L:T,index:V?_:U,truncated:V,ellipsed:V&&G>=z}},d6={limit:1/0,ellipsis:"",ellipsisWidth:0},H1=($,J={})=>l4($,d6,J).width,n0="\x1B",k4="›",i6=39,$2="\x07",m4="[",n6="]",h4="m",J2=`${n6}8;;`,y4=new RegExp(`(?:\\${m4}(?<code>\\d+)m|\\${J2}(?<uri>.*)${$2})`,"y"),p6=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},E4=($)=>`${n0}${m4}${$}${h4}`,w4=($)=>`${n0}${J2}${$}${$2}`,s6=($)=>$.map((J)=>H1(J)),r$=($,J,N)=>{let G=J[Symbol.iterator](),Z=!1,z=!1,X=$.at(-1),Q=X===void 0?0:H1(X),M=G.next(),I=G.next(),K=0;for(;!M.done;){let Y=M.value,H=H1(Y);Q+H<=N?$[$.length-1]+=Y:($.push(Y),Q=0),(Y===n0||Y===k4)&&(Z=!0,z=J.startsWith(J2,K+1)),Z?z?Y===$2&&(Z=!1,z=!1):Y===h4&&(Z=!1):(Q+=H,Q===N&&!I.done&&($.push(""),Q=0)),M=I,I=G.next(),K+=Y.length}X=$.at(-1),!Q&&X!==void 0&&X.length>0&&$.length>1&&($[$.length-2]+=$.pop())},o6=($)=>{let J=$.split(" "),N=J.length;for(;N>0&&!(H1(J[N-1])>0);)N--;return N===J.length?$:J.slice(0,N).join(" ")+J.slice(N).join("")},r6=($,J,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",Z,z,X=$.split(" "),Q=s6(X),M=[""];for(let[j,x]of X.entries()){N.trim!==!1&&(M[M.length-1]=(M.at(-1)??"").trimStart());let U=H1(M.at(-1)??"");if(j!==0&&(U>=J&&(N.wordWrap===!1||N.trim===!1)&&(M.push(""),U=0),(U>0||N.trim===!1)&&(M[M.length-1]+=" ",U++)),N.hard&&Q[j]>J){let B=J-U,V=1+Math.floor((Q[j]-B-1)/J);Math.floor((Q[j]-1)/J)<V&&M.push(""),r$(M,x,J);continue}if(U+Q[j]>J&&U>0&&Q[j]>0){if(N.wordWrap===!1&&U<J){r$(M,x,J);continue}M.push("")}if(U+Q[j]>J&&N.wordWrap===!1){r$(M,x,J);continue}M[M.length-1]+=x}N.trim!==!1&&(M=M.map((j)=>o6(j)));let I=M.join(`
51
+ `),K=I[Symbol.iterator](),Y=K.next(),H=K.next(),R=0;for(;!Y.done;){let j=Y.value,x=H.value;if(G+=j,j===n0||j===k4){y4.lastIndex=R+1;let B=y4.exec(I)?.groups;if(B?.code!==void 0){let V=Number.parseFloat(B.code);Z=V===i6?void 0:V}else B?.uri!==void 0&&(z=B.uri.length===0?void 0:B.uri)}let U=Z?p6(Z):void 0;x===`
52
+ `?(z&&(G+=w4("")),Z&&U&&(G+=E4(U))):j===`
53
+ `&&(Z&&U&&(G+=E4(Z)),z&&(G+=w4(z))),R+=j.length,Y=H,H=K.next()}return G};function Y0($,J,N){return String($).normalize().replaceAll(`\r
54
54
  `,`
55
55
  `).split(`
56
- `).map((G)=>s6(G,J,N)).join(`
57
- `)}var o6=($,J,N,G,Z)=>{let z=J,X=0;for(let Q=N;Q<G;Q++){let M=$[Q];if(z=z-M.length,X++,z<=Z)break}return{lineCount:z,removals:X}},t$=($)=>{let{cursor:J,options:N,style:G}=$,Z=$.output??process.stdout,z=z0(Z),X=$.columnPadding??0,Q=$.rowPadding??4,M=z-X,I=h$(Z),K=q.default.dim("..."),Y=$.maxItems??Number.POSITIVE_INFINITY,H=Math.max(I-Q,0),R=Math.max(Math.min(Y,H),5),x=0;J>=R-3&&(x=Math.max(Math.min(J-R+3,N.length-R),0));let j=R<N.length&&x>0,U=R<N.length&&x+R<N.length,T=Math.min(x+R,N.length),B=[],_=0;j&&_++,U&&_++;let A=x+(j?1:0),L=T-(U?1:0);for(let V=A;V<L;V++){let C=M0(G(N[V],V===J),M,{hard:!0,trim:!1}).split(`
58
- `);B.push(C),_+=C.length}if(_>H){let V=0,C=0,l=_,p=J-A,o=(g1,w)=>o6(B,l,g1,w,H);j?({lineCount:l,removals:V}=o(0,p),l>H&&({lineCount:l,removals:C}=o(p+1,B.length))):({lineCount:l,removals:C}=o(p+1,B.length),l>H&&({lineCount:l,removals:V}=o(0,p))),V>0&&(j=!0,B.splice(0,V)),C>0&&(U=!0,B.splice(B.length-C,C))}let D=[];j&&D.push(K);for(let V of B)for(let C of V)D.push(C);return U&&D.push(K),D};var w1=($)=>{let J=$.active??"Yes",N=$.inactive??"No";return new c$({active:J,inactive:N,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let G=`${q.default.gray(W)}
59
- ${h0(this.state)} ${$.message}
60
- `,Z=this.value?J:N;switch(this.state){case"submit":return`${G}${q.default.gray(W)} ${q.default.dim(Z)}`;case"cancel":return`${G}${q.default.gray(W)} ${q.default.strikethrough(q.default.dim(Z))}
61
- ${q.default.gray(W)}`;default:return`${G}${q.default.cyan(W)} ${this.value?`${q.default.green(a$)} ${J}`:`${q.default.dim(k0)} ${q.default.dim(J)}`} ${q.default.dim("/")} ${this.value?`${q.default.dim(k0)} ${q.default.dim(N)}`:`${q.default.green(a$)} ${N}`}
56
+ `).map((G)=>r6(G,J,N)).join(`
57
+ `)}var a6=($,J,N,G,Z)=>{let z=J,X=0;for(let Q=N;Q<G;Q++){let M=$[Q];if(z=z-M.length,X++,z<=Z)break}return{lineCount:z,removals:X}},e$=($)=>{let{cursor:J,options:N,style:G}=$,Z=$.output??process.stdout,z=Q0(Z),X=$.columnPadding??0,Q=$.rowPadding??4,M=z-X,I=c$(Z),K=q.default.dim("..."),Y=$.maxItems??Number.POSITIVE_INFINITY,H=Math.max(I-Q,0),R=Math.max(Math.min(Y,H),5),j=0;J>=R-3&&(j=Math.max(Math.min(J-R+3,N.length-R),0));let x=R<N.length&&j>0,U=R<N.length&&j+R<N.length,B=Math.min(j+R,N.length),V=[],_=0;x&&_++,U&&_++;let L=j+(x?1:0),A=B-(U?1:0);for(let T=L;T<A;T++){let C=Y0(G(N[T],T===J),M,{hard:!0,trim:!1}).split(`
58
+ `);V.push(C),_+=C.length}if(_>H){let T=0,C=0,l=_,p=J-L,o=(g1,w)=>a6(V,l,g1,w,H);x?({lineCount:l,removals:T}=o(0,p),l>H&&({lineCount:l,removals:C}=o(p+1,V.length))):({lineCount:l,removals:C}=o(p+1,V.length),l>H&&({lineCount:l,removals:T}=o(0,p))),T>0&&(x=!0,V.splice(0,T)),C>0&&(U=!0,V.splice(V.length-C,C))}let D=[];x&&D.push(K);for(let T of V)for(let C of T)D.push(C);return U&&D.push(K),D};var w1=($)=>{let J=$.active??"Yes",N=$.inactive??"No";return new d$({active:J,inactive:N,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let G=`${q.default.gray(F)}
59
+ ${i0(this.state)} ${$.message}
60
+ `,Z=this.value?J:N;switch(this.state){case"submit":return`${G}${q.default.gray(F)} ${q.default.dim(Z)}`;case"cancel":return`${G}${q.default.gray(F)} ${q.default.strikethrough(q.default.dim(Z))}
61
+ ${q.default.gray(F)}`;default:return`${G}${q.default.cyan(F)} ${this.value?`${q.default.green(t$)} ${J}`:`${q.default.dim(c0)} ${q.default.dim(J)}`} ${q.default.dim("/")} ${this.value?`${q.default.dim(c0)} ${q.default.dim(N)}`:`${q.default.green(t$)} ${N}`}
62
62
  ${q.default.cyan(D1)}
63
- `}}}).prompt()};var d={message:($=[],{symbol:J=q.default.gray(W),secondarySymbol:N=q.default.gray(W),output:G=process.stdout,spacing:Z=1,withGuide:z}={})=>{let X=[],Q=(z??Q1.withGuide)!==!1,M=Q?N:"",I=Q?`${J} `:"",K=Q?`${N} `:"";for(let H=0;H<Z;H++)X.push(M);let Y=Array.isArray($)?$:$.split(`
64
- `);if(Y.length>0){let[H,...R]=Y;H.length>0?X.push(`${I}${H}`):X.push(Q?J:"");for(let x of R)x.length>0?X.push(`${K}${x}`):X.push(Q?N:"")}G.write(`${X.join(`
63
+ `}}}).prompt()};var d={message:($=[],{symbol:J=q.default.gray(F),secondarySymbol:N=q.default.gray(F),output:G=process.stdout,spacing:Z=1,withGuide:z}={})=>{let X=[],Q=(z??M1.withGuide)!==!1,M=Q?N:"",I=Q?`${J} `:"",K=Q?`${N} `:"";for(let H=0;H<Z;H++)X.push(M);let Y=Array.isArray($)?$:$.split(`
64
+ `);if(Y.length>0){let[H,...R]=Y;H.length>0?X.push(`${I}${H}`):X.push(Q?J:"");for(let j of R)j.length>0?X.push(`${K}${j}`):X.push(Q?N:"")}G.write(`${X.join(`
65
65
  `)}
66
- `)},info:($,J)=>{d.message($,{...J,symbol:q.default.blue(y6)})},success:($,J)=>{d.message($,{...J,symbol:q.default.green(E6)})},step:($,J)=>{d.message($,{...J,symbol:q.default.green(m0)})},warn:($,J)=>{d.message($,{...J,symbol:q.default.yellow(w6)})},warning:($,J)=>{d.warn($,J)},error:($,J)=>{d.message($,{...J,symbol:q.default.red(v6)})}},Z1=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(D1)} ${q.default.red($)}
66
+ `)},info:($,J)=>{d.message($,{...J,symbol:q.default.blue(w6)})},success:($,J)=>{d.message($,{...J,symbol:q.default.green(v6)})},step:($,J)=>{d.message($,{...J,symbol:q.default.green(d0)})},warn:($,J)=>{d.message($,{...J,symbol:q.default.yellow(u6)})},warning:($,J)=>{d.warn($,J)},error:($,J)=>{d.message($,{...J,symbol:q.default.red(b6)})}},Z1=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(D1)} ${q.default.red($)}
67
67
 
68
- `)},a=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(S6)} ${$}
69
- `)},m=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(W)}
68
+ `)},a=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(F6)} ${$}
69
+ `)},m=($="",J)=>{(J?.output??process.stdout).write(`${q.default.gray(F)}
70
70
  ${q.default.gray(D1)} ${$}
71
71
 
72
- `)},X0=($,J)=>$.split(`
72
+ `)},M0=($,J)=>$.split(`
73
73
  `).map((N)=>J(N)).join(`
74
- `),d0=($)=>{let J=(G,Z)=>{let z=G.label??String(G.value);return Z==="disabled"?`${q.default.gray(g4)} ${X0(z,(X)=>q.default.strikethrough(q.default.gray(X)))}${G.hint?` ${q.default.dim(`(${G.hint??"disabled"})`)}`:""}`:Z==="active"?`${q.default.cyan(W6)} ${z}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="selected"?`${q.default.green(O4)} ${X0(z,q.default.dim)}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="cancelled"?`${X0(z,(X)=>q.default.strikethrough(q.default.dim(X)))}`:Z==="active-selected"?`${q.default.green(O4)} ${z}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="submitted"?`${X0(z,q.default.dim)}`:`${q.default.dim(g4)} ${X0(z,q.default.dim)}`},N=$.required??!0;return new d$({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:N,cursorAt:$.cursorAt,validate(G){if(N&&(G===void 0||G.length===0))return`Please select at least one option.
75
- ${q.default.reset(q.default.dim(`Press ${q.default.gray(q.default.bgWhite(q.default.inverse(" space ")))} to select, ${q.default.gray(q.default.bgWhite(q.default.inverse(" enter ")))} to submit`))}`},render(){let G=y1($.output,$.message,`${b4(this.state)} `,`${h0(this.state)} `),Z=`${q.default.gray(W)}
74
+ `),p0=($)=>{let J=(G,Z)=>{let z=G.label??String(G.value);return Z==="disabled"?`${q.default.gray(g4)} ${M0(z,(X)=>q.default.strikethrough(q.default.gray(X)))}${G.hint?` ${q.default.dim(`(${G.hint??"disabled"})`)}`:""}`:Z==="active"?`${q.default.cyan(O6)} ${z}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="selected"?`${q.default.green(O4)} ${M0(z,q.default.dim)}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="cancelled"?`${M0(z,(X)=>q.default.strikethrough(q.default.dim(X)))}`:Z==="active-selected"?`${q.default.green(O4)} ${z}${G.hint?` ${q.default.dim(`(${G.hint})`)}`:""}`:Z==="submitted"?`${M0(z,q.default.dim)}`:`${q.default.dim(g4)} ${M0(z,q.default.dim)}`},N=$.required??!0;return new i$({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:N,cursorAt:$.cursorAt,validate(G){if(N&&(G===void 0||G.length===0))return`Please select at least one option.
75
+ ${q.default.reset(q.default.dim(`Press ${q.default.gray(q.default.bgWhite(q.default.inverse(" space ")))} to select, ${q.default.gray(q.default.bgWhite(q.default.inverse(" enter ")))} to submit`))}`},render(){let G=y1($.output,$.message,`${b4(this.state)} `,`${i0(this.state)} `),Z=`${q.default.gray(F)}
76
76
  ${G}
77
- `,z=this.value??[],X=(Q,M)=>{if(Q.disabled)return J(Q,"disabled");let I=z.includes(Q.value);return M&&I?J(Q,"active-selected"):I?J(Q,"selected"):J(Q,M?"active":"inactive")};switch(this.state){case"submit":{let Q=this.options.filter(({value:I})=>z.includes(I)).map((I)=>J(I,"submitted")).join(q.default.dim(", "))||q.default.dim("none"),M=y1($.output,Q,`${q.default.gray(W)} `);return`${Z}${M}`}case"cancel":{let Q=this.options.filter(({value:I})=>z.includes(I)).map((I)=>J(I,"cancelled")).join(q.default.dim(", "));if(Q.trim()==="")return`${Z}${q.default.gray(W)}`;let M=y1($.output,Q,`${q.default.gray(W)} `);return`${Z}${M}
78
- ${q.default.gray(W)}`}case"error":{let Q=`${q.default.yellow(W)} `,M=this.error.split(`
77
+ `,z=this.value??[],X=(Q,M)=>{if(Q.disabled)return J(Q,"disabled");let I=z.includes(Q.value);return M&&I?J(Q,"active-selected"):I?J(Q,"selected"):J(Q,M?"active":"inactive")};switch(this.state){case"submit":{let Q=this.options.filter(({value:I})=>z.includes(I)).map((I)=>J(I,"submitted")).join(q.default.dim(", "))||q.default.dim("none"),M=y1($.output,Q,`${q.default.gray(F)} `);return`${Z}${M}`}case"cancel":{let Q=this.options.filter(({value:I})=>z.includes(I)).map((I)=>J(I,"cancelled")).join(q.default.dim(", "));if(Q.trim()==="")return`${Z}${q.default.gray(F)}`;let M=y1($.output,Q,`${q.default.gray(F)} `);return`${Z}${M}
78
+ ${q.default.gray(F)}`}case"error":{let Q=`${q.default.yellow(F)} `,M=this.error.split(`
79
79
  `).map((Y,H)=>H===0?`${q.default.yellow(D1)} ${q.default.yellow(Y)}`:` ${Y}`).join(`
80
80
  `),I=Z.split(`
81
81
  `).length,K=M.split(`
82
- `).length+1;return`${Z}${Q}${t$({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:I+K,style:X}).join(`
82
+ `).length+1;return`${Z}${Q}${e$({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:I+K,style:X}).join(`
83
83
  ${Q}`)}
84
84
  ${M}
85
- `}default:{let Q=`${q.default.cyan(W)} `,M=Z.split(`
86
- `).length;return`${Z}${Q}${t$({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:M+2,style:X}).join(`
85
+ `}default:{let Q=`${q.default.cyan(F)} `,M=Z.split(`
86
+ `).length;return`${Z}${Q}${e$({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:M+2,style:X}).join(`
87
87
  ${Q}`)}
88
88
  ${q.default.cyan(D1)}
89
- `}}}}).prompt()},r6=($)=>q.default.dim($),a6=($,J,N)=>{let G={hard:!0,trim:!1},Z=M0($,J,G).split(`
90
- `),z=Z.reduce((M,I)=>Math.max(H1(I),M),0),X=Z.map(N).reduce((M,I)=>Math.max(H1(I),M),0),Q=J-(X-z);return M0($,Q,G)},O=($="",J="",N)=>{let G=N?.output??G1.stdout,Z=(N?.withGuide??Q1.withGuide)!==!1,z=N?.format??r6,X=["",...a6($,z0(G)-6,z).split(`
91
- `).map(z),""],Q=H1(J),M=Math.max(X.reduce((H,R)=>{let x=H1(R);return x>H?x:H},0),Q)+2,I=X.map((H)=>`${q.default.gray(W)} ${H}${" ".repeat(M-H1(H))}${q.default.gray(W)}`).join(`
92
- `),K=Z?`${q.default.gray(W)}
93
- `:"",Y=Z?O6:f6;G.write(`${K}${q.default.green(m0)} ${q.default.reset(J)} ${q.default.gray(f4.repeat(Math.max(M-Q-1,1))+F6)}
89
+ `}}}}).prompt()},t6=($)=>q.default.dim($),e6=($,J,N)=>{let G={hard:!0,trim:!1},Z=Y0($,J,G).split(`
90
+ `),z=Z.reduce((M,I)=>Math.max(H1(I),M),0),X=Z.map(N).reduce((M,I)=>Math.max(H1(I),M),0),Q=J-(X-z);return Y0($,Q,G)},O=($="",J="",N)=>{let G=N?.output??G1.stdout,Z=(N?.withGuide??M1.withGuide)!==!1,z=N?.format??t6,X=["",...e6($,Q0(G)-6,z).split(`
91
+ `).map(z),""],Q=H1(J),M=Math.max(X.reduce((H,R)=>{let j=H1(R);return j>H?j:H},0),Q)+2,I=X.map((H)=>`${q.default.gray(F)} ${H}${" ".repeat(M-H1(H))}${q.default.gray(F)}`).join(`
92
+ `),K=Z?`${q.default.gray(F)}
93
+ `:"",Y=Z?f6:E6;G.write(`${K}${q.default.green(d0)} ${q.default.reset(J)} ${q.default.gray(f4.repeat(Math.max(M-Q-1,1))+g6)}
94
94
  ${I}
95
- ${q.default.gray(Y+f4.repeat(M+2)+g6)}
96
- `)};var t6=q.default.magenta,h1=({indicator:$="dots",onCancel:J,output:N=process.stdout,cancelMessage:G,errorMessage:Z,frames:z=r$?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=r$?80:120,signal:Q,...M}={})=>{let I=D6(),K,Y,H=!1,R=!1,x="",j,U=performance.now(),T=z0(N),B=M?.styleFrame??t6,_=(w)=>{let J1=w>1?Z??Q1.messages.error:G??Q1.messages.cancel;R=w===1,H&&(g1(J1,w),R&&typeof J=="function"&&J())},A=()=>_(2),L=()=>_(1),D=()=>{process.on("uncaughtExceptionMonitor",A),process.on("unhandledRejection",A),process.on("SIGINT",L),process.on("SIGTERM",L),process.on("exit",_),Q&&Q.addEventListener("abort",L)},V=()=>{process.removeListener("uncaughtExceptionMonitor",A),process.removeListener("unhandledRejection",A),process.removeListener("SIGINT",L),process.removeListener("SIGTERM",L),process.removeListener("exit",_),Q&&Q.removeEventListener("abort",L)},C=()=>{if(j===void 0)return;I&&N.write(`
97
- `);let w=M0(j,T,{hard:!0,trim:!1}).split(`
98
- `);w.length>1&&N.write(Q0.cursor.up(w.length-1)),N.write(Q0.cursor.to(0)),N.write(Q0.erase.down())},l=(w)=>w.replace(/\.+$/,""),p=(w)=>{let J1=(performance.now()-w)/1000,U1=Math.floor(J1/60),B1=Math.floor(J1%60);return U1>0?`[${U1}m ${B1}s]`:`[${B1}s]`},o=(w="")=>{H=!0,K=S4({output:N}),x=l(w),U=performance.now(),N.write(`${q.default.gray(W)}
99
- `);let J1=0,U1=0;D(),Y=setInterval(()=>{if(I&&x===j)return;C(),j=x;let B1=B(z[J1]),S0;if(I)S0=`${B1} ${x}...`;else if($==="timer")S0=`${B1} ${x} ${p(U)}`;else{let J5=".".repeat(Math.floor(U1)).slice(0,3);S0=`${B1} ${x}${J5}`}let $5=M0(S0,T,{hard:!0,trim:!1});N.write($5),J1=J1+1<z.length?J1+1:0,U1=U1<4?U1+0.125:0},X)},g1=(w="",J1=0,U1=!1)=>{if(!H)return;H=!1,clearInterval(Y),C();let B1=J1===0?q.default.green(m0):J1===1?q.default.red(v4):q.default.red(u4);x=w??x,U1||($==="timer"?N.write(`${B1} ${x} ${p(U)}
100
- `):N.write(`${B1} ${x}
101
- `)),V(),K()};return{start:o,stop:(w="")=>g1(w,0),message:(w="")=>{x=l(w??x)},cancel:(w="")=>g1(w,1),error:(w="")=>g1(w,2),clear:()=>g1("",0,!0),get isCancelled(){return R}}},eN={light:g("─","-"),heavy:g("━","="),block:g("█","#")};var l0=($,J)=>$.includes(`
95
+ ${q.default.gray(Y+f4.repeat(M+2)+y6)}
96
+ `)};var $9=q.default.magenta,h1=({indicator:$="dots",onCancel:J,output:N=process.stdout,cancelMessage:G,errorMessage:Z,frames:z=a$?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=a$?80:120,signal:Q,...M}={})=>{let I=W6(),K,Y,H=!1,R=!1,j="",x,U=performance.now(),B=Q0(N),V=M?.styleFrame??$9,_=(w)=>{let J1=w>1?Z??M1.messages.error:G??M1.messages.cancel;R=w===1,H&&(g1(J1,w),R&&typeof J=="function"&&J())},L=()=>_(2),A=()=>_(1),D=()=>{process.on("uncaughtExceptionMonitor",L),process.on("unhandledRejection",L),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",_),Q&&Q.addEventListener("abort",A)},T=()=>{process.removeListener("uncaughtExceptionMonitor",L),process.removeListener("unhandledRejection",L),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",_),Q&&Q.removeEventListener("abort",A)},C=()=>{if(x===void 0)return;I&&N.write(`
97
+ `);let w=Y0(x,B,{hard:!0,trim:!1}).split(`
98
+ `);w.length>1&&N.write(I0.cursor.up(w.length-1)),N.write(I0.cursor.to(0)),N.write(I0.erase.down())},l=(w)=>w.replace(/\.+$/,""),p=(w)=>{let J1=(performance.now()-w)/1000,U1=Math.floor(J1/60),B1=Math.floor(J1%60);return U1>0?`[${U1}m ${B1}s]`:`[${B1}s]`},o=(w="")=>{H=!0,K=W4({output:N}),j=l(w),U=performance.now(),N.write(`${q.default.gray(F)}
99
+ `);let J1=0,U1=0;D(),Y=setInterval(()=>{if(I&&j===x)return;C(),x=j;let B1=V(z[J1]),O0;if(I)O0=`${B1} ${j}...`;else if($==="timer")O0=`${B1} ${j} ${p(U)}`;else{let G5=".".repeat(Math.floor(U1)).slice(0,3);O0=`${B1} ${j}${G5}`}let N5=Y0(O0,B,{hard:!0,trim:!1});N.write(N5),J1=J1+1<z.length?J1+1:0,U1=U1<4?U1+0.125:0},X)},g1=(w="",J1=0,U1=!1)=>{if(!H)return;H=!1,clearInterval(Y),C();let B1=J1===0?q.default.green(d0):J1===1?q.default.red(v4):q.default.red(u4);j=w??j,U1||($==="timer"?N.write(`${B1} ${j} ${p(U)}
100
+ `):N.write(`${B1} ${j}
101
+ `)),T(),K()};return{start:o,stop:(w="")=>g1(w,0),message:(w="")=>{j=l(w??j)},cancel:(w="")=>g1(w,1),error:(w="")=>g1(w,2),clear:()=>g1("",0,!0),get isCancelled(){return R}}},JG={light:g("─","-"),heavy:g("━","="),block:g("█","#")};var h0=($,J)=>$.includes(`
102
102
  `)?$.split(`
103
103
  `).map((N)=>J(N)).join(`
104
- `):J($),c1=($)=>{let J=(N,G)=>{let Z=N.label??String(N.value);switch(G){case"disabled":return`${q.default.gray(k0)} ${l0(Z,q.default.gray)}${N.hint?` ${q.default.dim(`(${N.hint??"disabled"})`)}`:""}`;case"selected":return`${l0(Z,q.default.dim)}`;case"active":return`${q.default.green(a$)} ${Z}${N.hint?` ${q.default.dim(`(${N.hint})`)}`:""}`;case"cancelled":return`${l0(Z,(z)=>q.default.strikethrough(q.default.dim(z)))}`;default:return`${q.default.dim(k0)} ${l0(Z,q.default.dim)}`}};return new i$({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let N=`${h0(this.state)} `,G=`${b4(this.state)} `,Z=y1($.output,$.message,G,N),z=`${q.default.gray(W)}
104
+ `):J($),c1=($)=>{let J=(N,G)=>{let Z=N.label??String(N.value);switch(G){case"disabled":return`${q.default.gray(c0)} ${h0(Z,q.default.gray)}${N.hint?` ${q.default.dim(`(${N.hint??"disabled"})`)}`:""}`;case"selected":return`${h0(Z,q.default.dim)}`;case"active":return`${q.default.green(t$)} ${Z}${N.hint?` ${q.default.dim(`(${N.hint})`)}`:""}`;case"cancelled":return`${h0(Z,(z)=>q.default.strikethrough(q.default.dim(z)))}`;default:return`${q.default.dim(c0)} ${h0(Z,q.default.dim)}`}};return new n$({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let N=`${i0(this.state)} `,G=`${b4(this.state)} `,Z=y1($.output,$.message,G,N),z=`${q.default.gray(F)}
105
105
  ${Z}
106
- `;switch(this.state){case"submit":{let X=`${q.default.gray(W)} `,Q=y1($.output,J(this.options[this.cursor],"selected"),X);return`${z}${Q}`}case"cancel":{let X=`${q.default.gray(W)} `,Q=y1($.output,J(this.options[this.cursor],"cancelled"),X);return`${z}${Q}
107
- ${q.default.gray(W)}`}default:{let X=`${q.default.cyan(W)} `,Q=z.split(`
108
- `).length;return`${z}${X}${t$({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:X.length,rowPadding:Q+2,style:(M,I)=>J(M,M.disabled?"disabled":I?"active":"inactive")}).join(`
106
+ `;switch(this.state){case"submit":{let X=`${q.default.gray(F)} `,Q=y1($.output,J(this.options[this.cursor],"selected"),X);return`${z}${Q}`}case"cancel":{let X=`${q.default.gray(F)} `,Q=y1($.output,J(this.options[this.cursor],"cancelled"),X);return`${z}${Q}
107
+ ${q.default.gray(F)}`}default:{let X=`${q.default.cyan(F)} `,Q=z.split(`
108
+ `).length;return`${z}${X}${e$({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:X.length,rowPadding:Q+2,style:(M,I)=>J(M,M.disabled?"disabled":I?"active":"inactive")}).join(`
109
109
  ${X}`)}
110
110
  ${q.default.cyan(D1)}
111
- `}}}}).prompt()};var $G=`${q.default.gray(W)} `;var i0=($)=>new n$({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let J=($?.withGuide??Q1.withGuide)!==!1,N=`${`${J?`${q.default.gray(W)}
112
- `:""}${h0(this.state)} `}${$.message}
113
- `,G=$.placeholder?q.default.inverse($.placeholder[0])+q.default.dim($.placeholder.slice(1)):q.default.inverse(q.default.hidden("_")),Z=this.userInput?this.userInputWithCursor:G,z=this.value??"";switch(this.state){case"error":{let X=this.error?` ${q.default.yellow(this.error)}`:"",Q=J?`${q.default.yellow(W)} `:"",M=J?q.default.yellow(D1):"";return`${N.trim()}
111
+ `}}}}).prompt()};var NG=`${q.default.gray(F)} `;var s0=($)=>new p$({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let J=($?.withGuide??M1.withGuide)!==!1,N=`${`${J?`${q.default.gray(F)}
112
+ `:""}${i0(this.state)} `}${$.message}
113
+ `,G=$.placeholder?q.default.inverse($.placeholder[0])+q.default.dim($.placeholder.slice(1)):q.default.inverse(q.default.hidden("_")),Z=this.userInput?this.userInputWithCursor:G,z=this.value??"";switch(this.state){case"error":{let X=this.error?` ${q.default.yellow(this.error)}`:"",Q=J?`${q.default.yellow(F)} `:"",M=J?q.default.yellow(D1):"";return`${N.trim()}
114
114
  ${Q}${Z}
115
115
  ${M}${X}
116
- `}case"submit":{let X=z?` ${q.default.dim(z)}`:"",Q=J?q.default.gray(W):"";return`${N}${Q}${X}`}case"cancel":{let X=z?` ${q.default.strikethrough(q.default.dim(z))}`:"",Q=J?q.default.gray(W):"";return`${N}${Q}${X}${z.trim()?`
117
- ${Q}`:""}`}default:{let X=J?`${q.default.cyan(W)} `:"",Q=J?q.default.cyan(D1):"";return`${N}${X}${Z}
116
+ `}case"submit":{let X=z?` ${q.default.dim(z)}`:"",Q=J?q.default.gray(F):"";return`${N}${Q}${X}`}case"cancel":{let X=z?` ${q.default.strikethrough(q.default.dim(z))}`:"",Q=J?q.default.gray(F):"";return`${N}${Q}${X}${z.trim()?`
117
+ ${Q}`:""}`}default:{let X=J?`${q.default.cyan(F)} `:"",Q=J?q.default.cyan(D1):"";return`${N}${X}${Z}
118
118
  ${Q}
119
- `}}}}).prompt();var t=k(N1(),1);async function c4($=!1,J=!1){let N=process.cwd(),G=I0(N,".agent","results"),Z="/tmp",z={cleaned:0,skipped:0,details:[]},X=(I)=>{z.details.push($?`[DRY-RUN] ${I}`:`[CLEAN] ${I}`),z.cleaned++},Q=(I)=>{z.details.push(`[SKIP] ${I}`),z.skipped++};try{let I=N2("/tmp").filter((K)=>K.startsWith("subagent-")&&K.endsWith(".pid"));for(let K of I){let Y=I0("/tmp",K),H=G2(Y,"utf-8").trim();if(!H){if(X(`Removing empty PID file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}continue}let R=parseInt(H,10);if(Number.isNaN(R)){if(X(`Removing invalid PID file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}continue}try{if(s(`kill -0 ${R} 2>/dev/null`),X(`Killing orphaned process PID=${R} (from ${Y})`),!$)try{s(`kill ${R} 2>/dev/null || true`),await new Promise((x)=>setTimeout(x,1000));try{s(`kill -0 ${R} 2>/dev/null`),s(`kill -9 ${R} 2>/dev/null || true`)}catch{}s(`rm -f "${Y}"`)}catch{}}catch{if(X(`Removing stale PID file (process gone): ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}}}catch{}try{let I=N2("/tmp").filter((K)=>K.startsWith("subagent-")&&K.endsWith(".log"));for(let K of I){let Y=I0("/tmp",K),H=K.replace(".log",".pid"),R=I0("/tmp",H);if(J2(R))try{let x=G2(R,"utf-8").trim(),j=parseInt(x,10);if(!Number.isNaN(j)){s(`kill -0 ${j} 2>/dev/null`),Q(`Log file has active process: ${Y}`);continue}}catch{}if(X(`Removing stale log file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}}catch{}if(J2(G))try{let I=N2(G).filter((K)=>K.startsWith("parallel-"));for(let K of I){let Y=I0(G,K,"pids.txt");if(!J2(Y))continue;let R=G2(Y,"utf-8").split(`
120
- `).filter((j)=>j.trim()),x=!1;for(let j of R){let[U,T]=j.split(":"),B=parseInt(U?.trim()||"",10);if(Number.isNaN(B))continue;try{if(s(`kill -0 ${B} 2>/dev/null`),x=!0,X(`Killing orphaned parallel agent PID=${B} (${T?.trim()||"unknown"})`),!$)try{s(`kill ${B} 2>/dev/null || true`),s(`rm -f "${Y}"`)}catch{}}catch{}}if(!x){if(X(`Removing stale PID list: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}else if(!$){await new Promise((j)=>setTimeout(j,1000));try{s(`rm -f "${Y}"`)}catch{}}}}catch{}else Q(`No results directory found: ${G}`);if(J){console.log(JSON.stringify(z,null,2));return}if(console.clear(),a(t.default.bgMagenta(t.default.white(" \uD83E\uDDF9 oh-my-ag cleanup "))),$)O(t.default.yellow("Dry-run mode — no changes will be made"),"Mode");if(z.details.length>0){let I=[t.default.bold("Cleanup Details"),...z.details.map((K)=>{if(K.startsWith("[DRY-RUN]"))return t.default.yellow(K);if(K.startsWith("[CLEAN]"))return t.default.green(K);return t.default.cyan(K)})].join(`
119
+ `}}}}).prompt();var t=k(N1(),1);async function c4($=!1,J=!1){let N=process.cwd(),G=K0(N,".agent","results"),Z="/tmp",z={cleaned:0,skipped:0,details:[]},X=(I)=>{z.details.push($?`[DRY-RUN] ${I}`:`[CLEAN] ${I}`),z.cleaned++},Q=(I)=>{z.details.push(`[SKIP] ${I}`),z.skipped++};try{let I=G2("/tmp").filter((K)=>K.startsWith("subagent-")&&K.endsWith(".pid"));for(let K of I){let Y=K0("/tmp",K),H=Z2(Y,"utf-8").trim();if(!H){if(X(`Removing empty PID file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}continue}let R=parseInt(H,10);if(Number.isNaN(R)){if(X(`Removing invalid PID file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}continue}try{if(s(`kill -0 ${R} 2>/dev/null`),X(`Killing orphaned process PID=${R} (from ${Y})`),!$)try{s(`kill ${R} 2>/dev/null || true`),await new Promise((j)=>setTimeout(j,1000));try{s(`kill -0 ${R} 2>/dev/null`),s(`kill -9 ${R} 2>/dev/null || true`)}catch{}s(`rm -f "${Y}"`)}catch{}}catch{if(X(`Removing stale PID file (process gone): ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}}}catch{}try{let I=G2("/tmp").filter((K)=>K.startsWith("subagent-")&&K.endsWith(".log"));for(let K of I){let Y=K0("/tmp",K),H=K.replace(".log",".pid"),R=K0("/tmp",H);if(N2(R))try{let j=Z2(R,"utf-8").trim(),x=parseInt(j,10);if(!Number.isNaN(x)){s(`kill -0 ${x} 2>/dev/null`),Q(`Log file has active process: ${Y}`);continue}}catch{}if(X(`Removing stale log file: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}}catch{}if(N2(G))try{let I=G2(G).filter((K)=>K.startsWith("parallel-"));for(let K of I){let Y=K0(G,K,"pids.txt");if(!N2(Y))continue;let R=Z2(Y,"utf-8").split(`
120
+ `).filter((x)=>x.trim()),j=!1;for(let x of R){let[U,B]=x.split(":"),V=parseInt(U?.trim()||"",10);if(Number.isNaN(V))continue;try{if(s(`kill -0 ${V} 2>/dev/null`),j=!0,X(`Killing orphaned parallel agent PID=${V} (${B?.trim()||"unknown"})`),!$)try{s(`kill ${V} 2>/dev/null || true`),s(`rm -f "${Y}"`)}catch{}}catch{}}if(!j){if(X(`Removing stale PID list: ${Y}`),!$)try{s(`rm -f "${Y}"`)}catch{}}else if(!$){await new Promise((x)=>setTimeout(x,1000));try{s(`rm -f "${Y}"`)}catch{}}}}catch{}else Q(`No results directory found: ${G}`);if(J){console.log(JSON.stringify(z,null,2));return}if(console.clear(),a(t.default.bgMagenta(t.default.white(" \uD83E\uDDF9 oh-my-ag cleanup "))),$)O(t.default.yellow("Dry-run mode — no changes will be made"),"Mode");if(z.details.length>0){let I=[t.default.bold("Cleanup Details"),...z.details.map((K)=>{if(K.startsWith("[DRY-RUN]"))return t.default.yellow(K);if(K.startsWith("[CLEAN]"))return t.default.green(K);return t.default.cyan(K)})].join(`
121
121
  `);O(I,"Details")}let M=[t.default.bold("Summary"),"┌─────────┬────────┐",`│ ${t.default.bold("Action")} │ ${t.default.bold("Count")} │`,"├─────────┼────────┤",`│ Cleaned │ ${String(z.cleaned).padEnd(6)} │`,`│ Skipped │ ${String(z.skipped).padEnd(6)} │`,"└─────────┴────────┘"].join(`
122
- `);if(O(M,"Results"),$)m(t.default.yellow("Run without --dry-run to apply changes"));else m(t.default.green("Cleanup complete!"))}import{execSync as J9}from"node:child_process";import{existsSync as j0,readdirSync as N9,readFileSync as G9}from"node:fs";import{join as a0}from"node:path";var F=k(N1(),1);import{existsSync as n0,mkdirSync as p0,writeFileSync as Y0}from"node:fs";import{dirname as e6,join as R1}from"node:path";var K0="first-fluke/oh-my-ag",z2=`https://raw.githubusercontent.com/${K0}/main/.agent/skills`,Z2=`https://raw.githubusercontent.com/${K0}/main/.agent`,i1={domain:[{name:"frontend-agent",desc:"React/Next.js UI specialist"},{name:"backend-agent",desc:"FastAPI/SQLAlchemy API specialist"},{name:"mobile-agent",desc:"Flutter/Dart mobile specialist"}],coordination:[{name:"pm-agent",desc:"Product manager - task decomposition"},{name:"qa-agent",desc:"QA - OWASP, Lighthouse, WCAG"},{name:"workflow-guide",desc:"Manual multi-agent orchestration"},{name:"orchestrator",desc:"Automated parallel CLI execution"}],utility:[{name:"debug-agent",desc:"Bug fixing specialist"},{name:"commit",desc:"Conventional Commits helper"}]},d4={fullstack:["frontend-agent","backend-agent","pm-agent","qa-agent","debug-agent","commit"],frontend:["frontend-agent","pm-agent","qa-agent","debug-agent","commit"],backend:["backend-agent","pm-agent","qa-agent","debug-agent","commit"],mobile:["mobile-agent","pm-agent","qa-agent","debug-agent","commit"],all:[...i1.domain,...i1.coordination,...i1.utility].map(($)=>$.name)};async function $9($){let J=["SKILL.md"],N=["resources/execution-protocol.md","resources/tech-stack.md","resources/checklist.md","resources/templates.md","resources/error-playbook.md"];for(let G of N){let Z=`${z2}/${$}/${G}`;if((await fetch(Z,{method:"HEAD"})).ok)J.push(G)}return J}async function s0($,J){let N=R1(J,".agent","skills",$),G=await $9($);for(let Z of G){let z=`${z2}/${$}/${Z}`,X=await fetch(z);if(!X.ok)continue;let Q=await X.text(),M=R1(N,Z),I=e6(M);if(!n0(I))p0(I,{recursive:!0});Y0(M,Q,"utf-8")}return!0}async function o0($){let J=R1($,".agent","skills","_shared"),N=["reasoning-templates.md","clarification-protocol.md","context-loading.md","skill-routing.md"];if(!n0(J))p0(J,{recursive:!0});for(let G of N){let Z=`${z2}/_shared/${G}`,z=await fetch(Z);if(!z.ok)continue;let X=await z.text();Y0(R1(J,G),X,"utf-8")}}async function i4($){let J=R1($,".agent","workflows"),N=["coordinate.md","debug.md","orchestrate.md","plan.md","review.md","setup.md","tools.md"];if(!n0(J))p0(J,{recursive:!0});for(let G of N){let Z=`${Z2}/workflows/${G}`,z=await fetch(Z);if(!z.ok)continue;let X=await z.text();Y0(R1(J,G),X,"utf-8")}}async function n4($){let J=R1($,".agent","config"),N=R1($,".agent");if(!n0(J))p0(J,{recursive:!0});let G="user-preferences.yaml",Z=`${Z2}/config/${G}`,z=await fetch(Z);if(z.ok){let I=await z.text();Y0(R1(J,G),I,"utf-8")}let X="mcp.json",Q=`${Z2}/${X}`,M=await fetch(Q);if(M.ok){let I=await M.text();Y0(R1(N,X),I,"utf-8")}}function n1(){return[...i1.domain,...i1.coordination,...i1.utility]}async function r0($,J,N){try{let G=J9(`${J} --version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();return{name:$,installed:!0,version:G,installCmd:N}}catch{return{name:$,installed:!1,installCmd:N}}}async function Z9($){let J=process.env.HOME||process.env.USERPROFILE||"",G={gemini:{path:`${J}/.gemini/settings.json`,type:"json"},claude:{path:`${J}/.claude.json`,type:"json"},codex:{path:`${J}/.codex/config.toml`,type:"toml"}}[$];if(!G)return{configured:!1};if(j0(G.path))try{let Z=G9(G.path,"utf-8");if(G.type==="json"){let z=JSON.parse(Z);return{configured:!!(z.mcpServers||z.mcp),path:G.path}}return{configured:!0,path:G.path}}catch{return{configured:!1}}return{configured:!1}}async function z9(){let $=a0(process.cwd(),".agent","skills");if(!j0($))return[];let J=n1(),N=[];for(let G of J){let Z=a0($,G.name),z=a0(Z,"SKILL.md");N.push({name:G.name,installed:j0(Z),hasSkillMd:j0(z)})}return N}async function p4($=!1){let J=process.cwd(),N=await Promise.all([r0("gemini","gemini","bun install --global @anthropic-ai/gemini-cli"),r0("claude","claude","bun install --global @anthropic-ai/claude-code"),r0("codex","codex","bun install --global @openai/codex"),r0("qwen","qwen","bun install --global @qwen-code/qwen-code")]),G=await Promise.all(N.filter((H)=>H.installed).map(async(H)=>{let R=await Z9(H.name);return{...H,mcp:R}})),Z=await z9(),z=a0(J,".serena","memories"),X=j0(z),Q=0;if(X)try{Q=N9(z).length}catch{}let M=N.filter((H)=>!H.installed),I=Z.length>0?Z.filter((H)=>!H.installed||!H.hasSkillMd):n1().map((H)=>({name:H.name,installed:!1,hasSkillMd:!1})),K=M.length+G.filter((H)=>!H.mcp.configured).length+I.length;if($){let H={ok:K===0,issues:K,clis:N.map((R)=>({name:R.name,installed:R.installed,version:R.version||null})),mcp:G.map((R)=>({name:R.name,configured:R.mcp.configured,path:R.mcp.path||null})),skills:Z.length>0?Z.map((R)=>({name:R.name,installed:R.installed,complete:R.hasSkillMd})):[],missingSkills:I.map((R)=>R.name),serena:{exists:X,fileCount:Q}};console.log(JSON.stringify(H,null,2)),process.exit(K===0?0:1)}console.clear(),a(F.default.bgMagenta(F.default.white(" \uD83E\uDE7A oh-my-ag doctor ")));let Y=h1();try{let H=[F.default.bold("\uD83D\uDD0D CLI Installation Status"),"┌─────────┬──────────┬─────────────┐",`│ ${F.default.bold("CLI")} │ ${F.default.bold("Status")} │ ${F.default.bold("Version")} │`,"├─────────┼──────────┼─────────────┤",...N.map((j)=>{let U=j.installed?F.default.green("✅ Installed"):F.default.red("❌ Missing"),T=j.version||"-";return`│ ${j.name.padEnd(7)} │ ${U.padEnd(8)} │ ${T.padEnd(11)} │`}),"└─────────┴──────────┴─────────────┘"].join(`
123
- `);if(O(H,"CLI Status"),M.length>0)O(M.map((j)=>`${F.default.yellow("→")} ${j.name}: ${F.default.dim(j.installCmd)}`).join(`
124
- `),"Install missing CLIs");if(G.length>0){let j=[F.default.bold("\uD83D\uDD17 MCP Connection Status"),"┌─────────┬──────────┬─────────────────────┐",`│ ${F.default.bold("CLI")} │ ${F.default.bold("MCP Config")} │ ${F.default.bold("Path")} │`,"├─────────┼──────────┼─────────────────────┤",...G.map((U)=>{let T=U.mcp.configured?F.default.green("✅ Configured"):F.default.yellow("⚠️ Not configured"),B=U.mcp.path?U.mcp.path.split("/").pop()||"":"-";return`│ ${U.name.padEnd(7)} │ ${T.padEnd(8)} │ ${B.padEnd(19)} │`}),"└─────────┴──────────┴─────────────────────┘"].join(`
125
- `);O(j,"MCP Status")}let R=Z.filter((j)=>j.installed).length,x=Z.filter((j)=>j.hasSkillMd).length;if(Z.length>0){let j=[F.default.bold(`\uD83D\uDCE6 Skills (${R}/${Z.length} installed, ${x} complete)`),"┌────────────────────┬──────────┬─────────────┐",`│ ${F.default.bold("Skill")} │ ${F.default.bold("Installed")} │ ${F.default.bold("SKILL.md")} │`,"├────────────────────┼──────────┼─────────────┤",...Z.map((U)=>{let T=U.installed?F.default.green("✅"):F.default.red("❌"),B=U.hasSkillMd?F.default.green("✅"):F.default.red("❌");return`│ ${U.name.padEnd(18)} │ ${T.padEnd(8)} │ ${B.padEnd(11)} │`}),"└────────────────────┴──────────┴─────────────┘"].join(`
126
- `);O(j,"Skills Status")}else O(F.default.yellow("No skills installed."),"Skills Status");if(I.length>0){let j=await w1({message:`Found ${I.length} missing/incomplete skill(s). Install them?`,initialValue:!0});if(c(j))Z1("Cancelled."),process.exit(0);if(j){let U=I.map((_)=>_.name),T=await c1({message:"Which skills to install?",options:[{value:"all",label:`✨ All (${U.length} skills)`,hint:"Recommended"},{value:"select",label:"\uD83D\uDD27 Select individually"}]});if(c(T))Z1("Cancelled."),process.exit(0);let B;if(T==="select"){let _=n1(),A=await d0({message:"Select skills to install:",options:I.map((L)=>{let D=_.find((V)=>V.name===L.name);return{value:L.name,label:L.name,hint:D?.desc||""}}),required:!0});if(c(A))Z1("Cancelled."),process.exit(0);B=A}else B=U;Y.start("Installing skills...");try{await o0(J);for(let _ of B)Y.message(`Installing ${F.default.cyan(_)}...`),await s0(_,J);Y.stop(`Installed ${B.length} skill(s)!`),O(B.map((_)=>`${F.default.green("✓")} ${_}`).join(`
127
- `),"Installed Skills")}catch(_){Y.stop("Installation failed"),d.error(_ instanceof Error?_.message:String(_))}}}if(X)O(`${F.default.green("✅")} Serena memory directory exists
128
- ${F.default.dim(`${Q} memory files found`)}`,"Serena Memory");else O(`${F.default.yellow("⚠️")} Serena memory directory not found
129
- ${F.default.dim("Dashboard will show 'No agents detected'")}`,"Serena Memory");if(K===0)m(F.default.green("✅ All checks passed! Ready to use."));else m(F.default.yellow(`⚠️ Found ${K} issue(s). See details above.`))}catch(H){if(Y)Y.stop("Check failed");d.error(H instanceof Error?H.message:String(H)),process.exit(1)}}import{existsSync as s4,readFileSync as o4,writeFileSync as r4}from"node:fs";import{join as X2}from"node:path";var M1=k(N1(),1);async function a4(){console.clear(),a(M1.default.bgMagenta(M1.default.white(" \uD83D\uDEF8 oh-my-ag ")));let $=await c1({message:"What type of project?",options:[{value:"all",label:"✨ All",hint:"Install everything"},{value:"fullstack",label:"\uD83C\uDF10 Fullstack",hint:"Frontend + Backend + PM + QA"},{value:"frontend",label:"\uD83C\uDFA8 Frontend",hint:"React/Next.js"},{value:"backend",label:"⚙️ Backend",hint:"FastAPI/Python"},{value:"mobile",label:"\uD83D\uDCF1 Mobile",hint:"Flutter/Dart"},{value:"custom",label:"\uD83D\uDD27 Custom",hint:"Choose skills"}]});if(c($))Z1("Cancelled."),process.exit(0);let J;if($==="custom"){let Z=n1(),z=await d0({message:"Select skills:",options:Z.map((X)=>({value:X.name,label:X.name,hint:X.desc})),required:!0});if(c(z))Z1("Cancelled."),process.exit(0);J=z}else J=d4[$]??[];let N=process.cwd(),G=h1();G.start("Installing skills...");try{await o0(N),await i4(N),await n4(N);for(let Y of J)G.message(`Installing ${M1.default.cyan(Y)}...`),await s0(Y,N);G.stop("Skills installed!"),O([...J.map((Y)=>`${M1.default.green("")} ${Y}`),"",M1.default.dim(`Location: ${X2(N,".agent","skills")}`)].join(`
130
- `),"Installed"),m(M1.default.green("Done! Open your project in your IDE to use the skills.")),O(`${M1.default.yellow("❤️")} Enjoying oh-my-ag? Give it a star!
131
- ${M1.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Support");let Z=process.env.HOME||process.env.USERPROFILE||"",z=X2(Z,".gemini","antigravity","mcp_config.json"),X=null,Q=!1;try{if(s4(z)){let Y=o4(z,"utf-8");X=JSON.parse(Y),Q=!0}}catch(Y){}if(Q&&X&&X.mcpServers){let Y=X.mcpServers.serena,H="oh-my-ag@latest";if(!(Y&&Y.command==="npx"&&Array.isArray(Y.args)&&Y.args.includes("oh-my-ag@latest")&&Y.args.includes("bridge"))){let x=await w1({message:"Configure Serena MCP with bridge? (Required for full functionality)",initialValue:!0});if(c(x));else if(x){X.mcpServers.serena={command:"npx",args:["-y","oh-my-ag@latest","bridge","http://localhost:12341/sse"],disabled:!1};try{r4(z,JSON.stringify(X,null,2)),d.success(M1.default.green("Serena MCP configured successfully!"))}catch(j){d.error(`Failed to update MCP config: ${j}`)}}}}let M=X2(Z,".gemini","settings.json"),I=null,K=!1;try{if(s4(M)){let Y=o4(M,"utf-8");I=JSON.parse(Y),K=!0}}catch(Y){}if(K&&I&&I.mcpServers){let Y=I.mcpServers.serena;if(!(Y&&Y.url==="http://localhost:12341/sse")){let R=await w1({message:"Configure Serena for Gemini CLI? (SSE Mode)",initialValue:!0});if(c(R));else if(R){I.mcpServers.serena={url:"http://localhost:12341/sse"};try{r4(M,JSON.stringify(I,null,2)),d.success(M1.default.green("Gemini CLI configured successfully!"))}catch(x){d.error(`Failed to update Gemini config: ${x}`)}}}}}catch(Z){G.stop("Installation failed"),d.error(Z instanceof Error?Z.message:String(Z)),process.exit(1)}}import{existsSync as I8,mkdirSync as Q9,readdirSync as M9,readFileSync as I9,writeFileSync as Y9}from"node:fs";import{join as K2}from"node:path";var y=k(N1(),1);import{execSync as v1}from"node:child_process";function t0($){try{let N=v1("git diff --stat HEAD~10 2>/dev/null || git diff --stat",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
132
- `),G=N[N.length-1]||"",Z=G.match(/(\d+) files? changed/),z=G.match(/(\d+) insertions?\(\+\)/),X=G.match(/(\d+) deletions?\(-\)/);return{filesChanged:Z?.[1]?parseInt(Z[1],10):0,linesAdded:z?.[1]?parseInt(z[1],10):0,linesRemoved:X?.[1]?parseInt(X[1],10):0}}catch{return{filesChanged:0,linesAdded:0,linesRemoved:0}}}function e4($,J=5){try{return v1(`git log --oneline -${J} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
133
- `).filter(Boolean)}catch{return[]}}function e0($){try{return v1("git diff --name-only HEAD~5 2>/dev/null || git diff --name-only",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
134
- `).filter(Boolean).slice(0,10)}catch{return[]}}function t4($,J=10){try{return v1(`git log --format="%s" -${J} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
135
- `).filter(Boolean)}catch{return[]}}function $8($){let J={},N=/^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\(.+\))?:/;for(let G of $){let Z=G.match(N);if(Z){let z=Z[1];if(z)J[z]=(J[z]||0)+1}}return J}function J8($){try{let J=`${$}/.serena/retrospectives`,N=v1(`ls -t "${J}"/*.json 2>/dev/null | head -1`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();if(!N)return null;let G=v1(`cat "${N}"`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]});return JSON.parse(G).date||null}catch{return null}}function N8($,J){if(!J)return t4($,10);try{let G=new Date(J).toISOString().split("T")[0];return v1(`git log --format="%s" --since="${G}" 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
136
- `).filter(Boolean)}catch{return t4($,10)}}import{existsSync as M2,readdirSync as X9,readFileSync as Q2}from"node:fs";import{join as $$}from"node:path";function I2($){return $$($,".serena","memories")}function G8($){let J=I2($);if(!M2(J))return[];try{return X9(J).filter((N)=>N.endsWith(".md")&&N!==".gitkeep")}catch{return[]}}function Z8($,J){let N=$.match(/^progress-(\w+)\.md$/),G=$.match(/^result-(\w+)\.md$/);if(N?.[1])return{agent:N[1],type:"progress",content:J.slice(0,500)};if(G?.[1])return{agent:G[1],type:"result",content:J.slice(0,500)};return null}function z8($){let J=I2($),N={agents:[],activities:[],completedTasks:[],inProgressTasks:[]};if(!M2(J))return N;let G=G8($);for(let Z of G){if(Z==="orchestrator-session.md"){try{let X=Q2($$(J,Z),"utf-8").match(/session[:\s]+(\S+)/i);if(X)N.sessionId=X[1]}catch{}continue}try{let z=Q2($$(J,Z),"utf-8"),X=Z8(Z,z);if(X){if(N.activities.push(X),!N.agents.includes(X.agent))N.agents.push(X.agent);if(X.type==="result"){let Q=z.match(/task[:\s]+(.+)/i)||z.match(/##\s*(.+)/);if(Q?.[1])N.completedTasks.push(Q[1].trim())}else if(X.type==="progress"){let Q=z.match(/current[:\s]+(.+)/i)||z.match(/working on[:\s]+(.+)/i);if(Q?.[1]&&!N.completedTasks.includes(Q[1].trim()))N.inProgressTasks.push(Q[1].trim())}}}catch{}}return N}function X8($,J){let N=[],G=I2($);if(!M2(G))return N;let Z=J?new Date(J).getTime():0,z=G8($);for(let X of z){if(X==="orchestrator-session.md")continue;try{let Q=$$(G,X),M=Q2(Q,"utf-8"),I=Z8(X,M);if(I)N.push(I)}catch{}}return N}function Q8($){let J=[];for(let N of $){let G=N.content.toLowerCase();if(G.includes("error")||G.includes("fail"))J.push(`${N.agent}: Error handling improved`);if(G.includes("refactor"))J.push(`${N.agent}: Code structure refactored`);if(G.includes("test"))J.push(`${N.agent}: Test coverage added`);if(G.includes("performance")||G.includes("optimize"))J.push(`${N.agent}: Performance optimized`)}return[...new Set(J)].slice(0,5)}function j2($){return K2($,".serena","retrospectives")}function K9($){let J=j2($);if(!I8(J))return[];try{return M9(J).filter((G)=>G.endsWith(".json")).sort().reverse().slice(0,10).map((G)=>JSON.parse(I9(K2(J,G),"utf-8")))}catch{return[]}}function Y2($,J){let N=j2($);if(!I8(N))Q9(N,{recursive:!0});let G=`${J.date.replace(/[:.]/g,"-")}_${J.id}.json`;Y9(K2(N,G),JSON.stringify(J,null,2),"utf-8")}function M8($){let J=J8($),N=N8($,J),G=$8(N),Z=t0($),z=z8($),X=X8($,J||void 0),Q=Object.entries(G).sort(([,Y],[,H])=>H-Y)[0],M="Development session";if(Q){let[Y]=Q;M={feat:"Feature development",fix:"Bug fixes and improvements",refactor:"Code refactoring",docs:"Documentation updates",test:"Testing improvements",chore:"Maintenance tasks",build:"Build system updates",perf:"Performance improvements"}[Y]||"Development session"}if(Z.filesChanged>0)M+=` (${Z.filesChanged} files, +${Z.linesAdded}/-${Z.linesRemoved})`;if(z.agents.length>0)M+=` with ${z.agents.join(", ")}`;let I=Q8(X);if(N.length>0&&I.length===0){if(G.refactor||G.perf)I.push("Code quality and performance improvements");if(G.test)I.push("Enhanced test coverage");if(G.fix)I.push("Issue resolution and stability improvements")}let K=[];if(z.inProgressTasks.length>0)K.push(...z.inProgressTasks.slice(0,3));if(N.length>0){let Y=N[0]?.toLowerCase()||"";if(Y.includes("wip")||Y.includes("todo"))K.push("Complete work-in-progress items")}if(K.length===0)K.push("Continue development","Review and test changes");return{summary:M,learnings:I.slice(0,5),nextSteps:K.slice(0,5)}}async function Y8($=!1,J=!1){let N=process.cwd(),G=j2(N),Z=K9(N);if($){console.log(JSON.stringify({retrospectives:Z},null,2));return}if(!J){let{summary:R,learnings:x,nextSteps:j}=M8(N),U=e0(N),T={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:R,keyLearnings:x,filesChanged:U,nextSteps:j};Y2(N,T),console.clear(),a(y.default.bgMagenta(y.default.white(" \uD83D\uDD04 oh-my-ag retro "))),O([y.default.green("✅ Auto-generated retrospective saved!"),"",y.default.bold("Summary:"),R,"",y.default.bold("Key Learnings:"),...x.map((B)=>` • ${B}`),"",y.default.bold("Next Steps:"),...j.map((B)=>` → ${B}`)].join(`
122
+ `);if(O(M,"Results"),$)m(t.default.yellow("Run without --dry-run to apply changes"));else m(t.default.green("Cleanup complete!"))}import{execSync as G9}from"node:child_process";import{existsSync as s1,readdirSync as s4,readFileSync as Z9}from"node:fs";import{join as H0}from"node:path";var W=k(N1(),1);import{existsSync as j0,mkdirSync as x0,writeFileSync as n1}from"node:fs";import{dirname as J9,join as z1}from"node:path";var R0="first-fluke/oh-my-ag",z2=`https://raw.githubusercontent.com/${R0}/main/.agent/skills`,o0=`https://raw.githubusercontent.com/${R0}/main/.agent`,i1={domain:[{name:"frontend-agent",desc:"React/Next.js UI specialist"},{name:"backend-agent",desc:"FastAPI/SQLAlchemy API specialist"},{name:"mobile-agent",desc:"Flutter/Dart mobile specialist"}],coordination:[{name:"pm-agent",desc:"Product manager - task decomposition"},{name:"qa-agent",desc:"QA - OWASP, Lighthouse, WCAG"},{name:"workflow-guide",desc:"Manual multi-agent orchestration"},{name:"orchestrator",desc:"Automated parallel CLI execution"}],utility:[{name:"debug-agent",desc:"Bug fixing specialist"},{name:"commit",desc:"Conventional Commits helper"}]},d4={fullstack:["frontend-agent","backend-agent","pm-agent","qa-agent","debug-agent","commit"],frontend:["frontend-agent","pm-agent","qa-agent","debug-agent","commit"],backend:["backend-agent","pm-agent","qa-agent","debug-agent","commit"],mobile:["mobile-agent","pm-agent","qa-agent","debug-agent","commit"],all:[...i1.domain,...i1.coordination,...i1.utility].map(($)=>$.name)};async function N9($){let J=["SKILL.md"],N=["resources/execution-protocol.md","resources/tech-stack.md","resources/checklist.md","resources/templates.md","resources/error-playbook.md"];for(let G of N){let Z=`${z2}/${$}/${G}`;if((await fetch(Z,{method:"HEAD"})).ok)J.push(G)}return J}async function r0($,J){let N=z1(J,".agent","skills",$),G=await N9($);for(let Z of G){let z=`${z2}/${$}/${Z}`,X=await fetch(z);if(!X.ok)continue;let Q=await X.text(),M=z1(N,Z),I=J9(M);if(!j0(I))x0(I,{recursive:!0});n1(M,Q,"utf-8")}return!0}async function a0($){let J=z1($,".agent","skills","_shared"),N=["reasoning-templates.md","clarification-protocol.md","context-loading.md","skill-routing.md"];if(!j0(J))x0(J,{recursive:!0});for(let G of N){let Z=`${z2}/_shared/${G}`,z=await fetch(Z);if(!z.ok)continue;let X=await z.text();n1(z1(J,G),X,"utf-8")}}async function i4($){let J=z1($,".agent","workflows"),N=["coordinate.md","debug.md","orchestrate.md","plan.md","review.md","setup.md","tools.md"];if(!j0(J))x0(J,{recursive:!0});for(let G of N){let Z=`${o0}/workflows/${G}`,z=await fetch(Z);if(!z.ok)continue;let X=await z.text();n1(z1(J,G),X,"utf-8")}}async function n4($){let J=z1($,".agent","config"),N=z1($,".agent");if(!j0(J))x0(J,{recursive:!0});let G="user-preferences.yaml",Z=`${o0}/config/${G}`,z=await fetch(Z);if(z.ok){let I=await z.text();n1(z1(J,G),I,"utf-8")}let X="mcp.json",Q=`${o0}/${X}`,M=await fetch(Q);if(M.ok){let I=await M.text();n1(z1(N,X),I,"utf-8")}}function p1(){return[...i1.domain,...i1.coordination,...i1.utility]}async function p4(){let $=process.env.HOME||process.env.USERPROFILE||"",J=z1($,".gemini","antigravity","global_workflows");if(!j0(J))x0(J,{recursive:!0});let N=["coordinate.md","debug.md","orchestrate.md","plan.md","review.md","setup.md","tools.md"];for(let G of N){let Z=`${o0}/workflows/${G}`,z=await fetch(Z);if(!z.ok)continue;let X=await z.text();n1(z1(J,G),X,"utf-8")}}async function t0($,J,N){try{let G=G9(`${J} --version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();return{name:$,installed:!0,version:G,installCmd:N}}catch{return{name:$,installed:!1,installCmd:N}}}async function z9($){let J=process.env.HOME||process.env.USERPROFILE||"",G={gemini:{path:`${J}/.gemini/settings.json`,type:"json"},claude:{path:`${J}/.claude.json`,type:"json"},codex:{path:`${J}/.codex/config.toml`,type:"toml"}}[$];if(!G)return{configured:!1};if(s1(G.path))try{let Z=Z9(G.path,"utf-8");if(G.type==="json"){let z=JSON.parse(Z);return{configured:!!(z.mcpServers||z.mcp),path:G.path}}return{configured:!0,path:G.path}}catch{return{configured:!1}}return{configured:!1}}async function X9(){let $=H0(process.cwd(),".agent","skills");if(!s1($))return[];let J=p1(),N=[];for(let G of J){let Z=H0($,G.name),z=H0(Z,"SKILL.md");N.push({name:G.name,installed:s1(Z),hasSkillMd:s1(z)})}return N}async function Q9(){let $=process.env.HOME||process.env.USERPROFILE||"",J=H0($,".gemini","antigravity","global_workflows");if(!s1(J))return{installed:!1,count:0};try{return{installed:!0,count:s4(J).filter((G)=>G.endsWith(".md")).length}}catch{return{installed:!1,count:0}}}async function o4($=!1){let J=process.cwd(),N=await Promise.all([t0("gemini","gemini","bun install --global @google/gemini-cli"),t0("claude","claude","bun install --global @anthropic-ai/claude-code"),t0("codex","codex","bun install --global @openai/codex"),t0("qwen","qwen","bun install --global @qwen-code/qwen-code")]),G=await Promise.all(N.filter((R)=>R.installed).map(async(R)=>{let j=await z9(R.name);return{...R,mcp:j}})),Z=await X9(),z=await Q9(),X=H0(J,".serena","memories"),Q=s1(X),M=0;if(Q)try{M=s4(X).length}catch{}let I=N.filter((R)=>!R.installed),K=Z.length>0?Z.filter((R)=>!R.installed||!R.hasSkillMd):p1().map((R)=>({name:R.name,installed:!1,hasSkillMd:!1})),Y=I.length+K.length+(z.installed?0:1);if($){let R={ok:Y===0,issues:Y,clis:N.map((j)=>({name:j.name,installed:j.installed,version:j.version||null})),mcp:G.map((j)=>({name:j.name,configured:j.mcp.configured,path:j.mcp.path||null})),skills:Z.length>0?Z.map((j)=>({name:j.name,installed:j.installed,complete:j.hasSkillMd})):[],missingSkills:K.map((j)=>j.name),globalWorkflows:{installed:z.installed,count:z.count},serena:{exists:Q,fileCount:M}};console.log(JSON.stringify(R,null,2)),process.exit(Y===0?0:1)}console.clear(),a(W.default.bgMagenta(W.default.white(" \uD83E\uDE7A oh-my-ag doctor ")));let H=h1();try{let R=[W.default.bold("\uD83D\uDD0D CLI Installation Status"),"┌─────────┬──────────┬─────────────┐",`│ ${W.default.bold("CLI")} │ ${W.default.bold("Status")} │ ${W.default.bold("Version")} │`,"├─────────┼──────────┼─────────────┤",...N.map((U)=>{let B=U.installed?W.default.green("✅ Installed"):W.default.red("❌ Missing"),V=U.version||"-";return`│ ${U.name.padEnd(7)} │ ${B.padEnd(8)} │ ${V.padEnd(11)} │`}),"└─────────┴──────────┴─────────────┘"].join(`
123
+ `);if(O(R,"CLI Status"),I.length>0)O(I.map((U)=>`${W.default.yellow("→")} ${U.name}: ${W.default.dim(U.installCmd)}`).join(`
124
+ `),"Install missing CLIs");if(G.length>0){let U=[W.default.bold("\uD83D\uDD17 MCP Connection Status"),"┌─────────┬──────────┬─────────────────────┐",`│ ${W.default.bold("CLI")} │ ${W.default.bold("MCP Config")} │ ${W.default.bold("Path")} │`,"├─────────┼──────────┼─────────────────────┤",...G.map((B)=>{let V=B.mcp.configured?W.default.green("✅ Configured"):W.default.yellow("⚠️ Not configured"),_=B.mcp.path?B.mcp.path.split("/").pop()||"":"-";return`│ ${B.name.padEnd(7)} │ ${V.padEnd(8)} │ ${_.padEnd(19)} │`}),"└─────────┴──────────┴─────────────────────┘"].join(`
125
+ `);O(U,"MCP Status")}let j=Z.filter((U)=>U.installed).length,x=Z.filter((U)=>U.hasSkillMd).length;if(Z.length>0){let U=[W.default.bold(`\uD83D\uDCE6 Skills (${j}/${Z.length} installed, ${x} complete)`),"┌────────────────────┬──────────┬─────────────┐",`│ ${W.default.bold("Skill")} │ ${W.default.bold("Installed")} │ ${W.default.bold("SKILL.md")} │`,"├────────────────────┼──────────┼─────────────┤",...Z.map((B)=>{let V=B.installed?W.default.green("✅"):W.default.red("❌"),_=B.hasSkillMd?W.default.green("✅"):W.default.red("❌");return`│ ${B.name.padEnd(18)} │ ${V.padEnd(8)} │ ${_.padEnd(11)} │`}),"└────────────────────┴──────────┴─────────────┘"].join(`
126
+ `);O(U,"Skills Status")}else O(W.default.yellow("No skills installed."),"Skills Status");if(K.length>0){let U=await w1({message:`Found ${K.length} missing/incomplete skill(s). Install them?`,initialValue:!0});if(c(U))Z1("Cancelled."),process.exit(0);if(U){let B=K.map((L)=>L.name),V=await c1({message:"Which skills to install?",options:[{value:"all",label:`✨ All (${B.length} skills)`,hint:"Recommended"},{value:"select",label:"\uD83D\uDD27 Select individually"}]});if(c(V))Z1("Cancelled."),process.exit(0);let _;if(V==="select"){let L=p1(),A=await p0({message:"Select skills to install:",options:K.map((D)=>{let T=L.find((C)=>C.name===D.name);return{value:D.name,label:D.name,hint:T?.desc||""}}),required:!0});if(c(A))Z1("Cancelled."),process.exit(0);_=A}else _=B;H.start("Installing skills...");try{await a0(J);for(let L of _)H.message(`Installing ${W.default.cyan(L)}...`),await r0(L,J);H.stop(`Installed ${_.length} skill(s)!`),O(_.map((L)=>`${W.default.green("✓")} ${L}`).join(`
127
+ `),"Installed Skills")}catch(L){H.stop("Installation failed"),d.error(L instanceof Error?L.message:String(L))}}}if(Q)O(`${W.default.green("✅")} Serena memory directory exists
128
+ ${W.default.dim(`${M} memory files found`)}`,"Serena Memory");else O(`${W.default.yellow("⚠️")} Serena memory directory not found
129
+ ${W.default.dim("Dashboard will show 'No agents detected'")}`,"Serena Memory");if(z.installed)O(`${W.default.green("")} Global workflows installed
130
+ ${W.default.dim(`${z.count} workflow files found`)}`,"Global Workflows");else O(`${W.default.red("")} Global workflows missing
131
+ ${W.default.dim("Run 'oh-my-ag' to install or reinstall global workflows")}`,"Global Workflows");if(Y===0)m(W.default.green("✅ All checks passed! Ready to use."));else m(W.default.yellow(`⚠️ Found ${Y} issue(s). See details above.`))}catch(R){if(H)H.stop("Check failed");d.error(R instanceof Error?R.message:String(R)),process.exit(1)}}import{existsSync as r4,readFileSync as a4,writeFileSync as t4}from"node:fs";import{join as X2}from"node:path";var I1=k(N1(),1);async function e4(){console.clear(),a(I1.default.bgMagenta(I1.default.white(" \uD83D\uDEF8 oh-my-ag ")));let $=await c1({message:"What type of project?",options:[{value:"all",label:"✨ All",hint:"Install everything"},{value:"fullstack",label:"\uD83C\uDF10 Fullstack",hint:"Frontend + Backend + PM + QA"},{value:"frontend",label:"\uD83C\uDFA8 Frontend",hint:"React/Next.js"},{value:"backend",label:"⚙️ Backend",hint:"FastAPI/Python"},{value:"mobile",label:"\uD83D\uDCF1 Mobile",hint:"Flutter/Dart"},{value:"custom",label:"\uD83D\uDD27 Custom",hint:"Choose skills"}]});if(c($))Z1("Cancelled."),process.exit(0);let J;if($==="custom"){let Z=p1(),z=await p0({message:"Select skills:",options:Z.map((X)=>({value:X.name,label:X.name,hint:X.desc})),required:!0});if(c(z))Z1("Cancelled."),process.exit(0);J=z}else J=d4[$]??[];let N=process.cwd(),G=h1();G.start("Installing skills...");try{await a0(N),await i4(N),await n4(N),await p4();for(let Y of J)G.message(`Installing ${I1.default.cyan(Y)}...`),await r0(Y,N);G.stop("Skills installed!"),O([...J.map((Y)=>`${I1.default.green("✓")} ${Y}`),"",I1.default.dim(`Location: ${X2(N,".agent","skills")}`)].join(`
132
+ `),"Installed"),m(I1.default.green("Done! Open your project in your IDE to use the skills.")),O(`${I1.default.yellow("❤️")} Enjoying oh-my-ag? Give it a star!
133
+ ${I1.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Support");let Z=process.env.HOME||process.env.USERPROFILE||"",z=X2(Z,".gemini","antigravity","mcp_config.json"),X=null,Q=!1;try{if(r4(z)){let Y=a4(z,"utf-8");X=JSON.parse(Y),Q=!0}}catch(Y){}if(Q&&X&&X.mcpServers){let Y=X.mcpServers.serena,H="oh-my-ag@latest";if(!(Y&&Y.command==="npx"&&Array.isArray(Y.args)&&Y.args.includes("oh-my-ag@latest")&&Y.args.includes("bridge"))){let j=await w1({message:"Configure Serena MCP with bridge? (Required for full functionality)",initialValue:!0});if(c(j));else if(j){X.mcpServers.serena={command:"npx",args:["-y","oh-my-ag@latest","bridge","http://localhost:12341/sse"],disabled:!1};try{t4(z,JSON.stringify(X,null,2)),d.success(I1.default.green("Serena MCP configured successfully!"))}catch(x){d.error(`Failed to update MCP config: ${x}`)}}}}let M=X2(Z,".gemini","settings.json"),I=null,K=!1;try{if(r4(M)){let Y=a4(M,"utf-8");I=JSON.parse(Y),K=!0}}catch(Y){}if(K&&I&&I.mcpServers){let Y=I.mcpServers.serena;if(!(Y&&Y.url==="http://localhost:12341/sse")){let R=await w1({message:"Configure Serena for Gemini CLI? (SSE Mode)",initialValue:!0});if(c(R));else if(R){I.mcpServers.serena={url:"http://localhost:12341/sse"};try{t4(M,JSON.stringify(I,null,2)),d.success(I1.default.green("Gemini CLI configured successfully!"))}catch(j){d.error(`Failed to update Gemini config: ${j}`)}}}}}catch(Z){G.stop("Installation failed"),d.error(Z instanceof Error?Z.message:String(Z)),process.exit(1)}}import{existsSync as K8,mkdirSync as I9,readdirSync as Y9,readFileSync as K9,writeFileSync as j9}from"node:fs";import{join as K2}from"node:path";var y=k(N1(),1);import{execSync as v1}from"node:child_process";function e0($){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(`
134
+ `),G=N[N.length-1]||"",Z=G.match(/(\d+) files? changed/),z=G.match(/(\d+) insertions?\(\+\)/),X=G.match(/(\d+) deletions?\(-\)/);return{filesChanged:Z?.[1]?parseInt(Z[1],10):0,linesAdded:z?.[1]?parseInt(z[1],10):0,linesRemoved:X?.[1]?parseInt(X[1],10):0}}catch{return{filesChanged:0,linesAdded:0,linesRemoved:0}}}function J8($,J=5){try{return v1(`git log --oneline -${J} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
135
+ `).filter(Boolean)}catch{return[]}}function $$($){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(`
136
+ `).filter(Boolean).slice(0,10)}catch{return[]}}function $8($,J=10){try{return v1(`git log --format="%s" -${J} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
137
+ `).filter(Boolean)}catch{return[]}}function N8($){let J={},N=/^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\(.+\))?:/;for(let G of $){let Z=G.match(N);if(Z){let z=Z[1];if(z)J[z]=(J[z]||0)+1}}return J}function G8($){try{let J=`${$}/.serena/retrospectives`,N=v1(`ls -t "${J}"/*.json 2>/dev/null | head -1`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();if(!N)return null;let G=v1(`cat "${N}"`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]});return JSON.parse(G).date||null}catch{return null}}function Z8($,J){if(!J)return $8($,10);try{let G=new Date(J).toISOString().split("T")[0];return v1(`git log --format="%s" --since="${G}" 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
138
+ `).filter(Boolean)}catch{return $8($,10)}}import{existsSync as M2,readdirSync as M9,readFileSync as Q2}from"node:fs";import{join as J$}from"node:path";function I2($){return J$($,".serena","memories")}function z8($){let J=I2($);if(!M2(J))return[];try{return M9(J).filter((N)=>N.endsWith(".md")&&N!==".gitkeep")}catch{return[]}}function X8($,J){let N=$.match(/^progress-(\w+)\.md$/),G=$.match(/^result-(\w+)\.md$/);if(N?.[1])return{agent:N[1],type:"progress",content:J.slice(0,500)};if(G?.[1])return{agent:G[1],type:"result",content:J.slice(0,500)};return null}function Q8($){let J=I2($),N={agents:[],activities:[],completedTasks:[],inProgressTasks:[]};if(!M2(J))return N;let G=z8($);for(let Z of G){if(Z==="orchestrator-session.md"){try{let X=Q2(J$(J,Z),"utf-8").match(/session[:\s]+(\S+)/i);if(X)N.sessionId=X[1]}catch{}continue}try{let z=Q2(J$(J,Z),"utf-8"),X=X8(Z,z);if(X){if(N.activities.push(X),!N.agents.includes(X.agent))N.agents.push(X.agent);if(X.type==="result"){let Q=z.match(/task[:\s]+(.+)/i)||z.match(/##\s*(.+)/);if(Q?.[1])N.completedTasks.push(Q[1].trim())}else if(X.type==="progress"){let Q=z.match(/current[:\s]+(.+)/i)||z.match(/working on[:\s]+(.+)/i);if(Q?.[1]&&!N.completedTasks.includes(Q[1].trim()))N.inProgressTasks.push(Q[1].trim())}}}catch{}}return N}function M8($,J){let N=[],G=I2($);if(!M2(G))return N;let Z=J?new Date(J).getTime():0,z=z8($);for(let X of z){if(X==="orchestrator-session.md")continue;try{let Q=J$(G,X),M=Q2(Q,"utf-8"),I=X8(X,M);if(I)N.push(I)}catch{}}return N}function I8($){let J=[];for(let N of $){let G=N.content.toLowerCase();if(G.includes("error")||G.includes("fail"))J.push(`${N.agent}: Error handling improved`);if(G.includes("refactor"))J.push(`${N.agent}: Code structure refactored`);if(G.includes("test"))J.push(`${N.agent}: Test coverage added`);if(G.includes("performance")||G.includes("optimize"))J.push(`${N.agent}: Performance optimized`)}return[...new Set(J)].slice(0,5)}function j2($){return K2($,".serena","retrospectives")}function x9($){let J=j2($);if(!K8(J))return[];try{return Y9(J).filter((G)=>G.endsWith(".json")).sort().reverse().slice(0,10).map((G)=>JSON.parse(K9(K2(J,G),"utf-8")))}catch{return[]}}function Y2($,J){let N=j2($);if(!K8(N))I9(N,{recursive:!0});let G=`${J.date.replace(/[:.]/g,"-")}_${J.id}.json`;j9(K2(N,G),JSON.stringify(J,null,2),"utf-8")}function Y8($){let J=G8($),N=Z8($,J),G=N8(N),Z=e0($),z=Q8($),X=M8($,J||void 0),Q=Object.entries(G).sort(([,Y],[,H])=>H-Y)[0],M="Development session";if(Q){let[Y]=Q;M={feat:"Feature development",fix:"Bug fixes and improvements",refactor:"Code refactoring",docs:"Documentation updates",test:"Testing improvements",chore:"Maintenance tasks",build:"Build system updates",perf:"Performance improvements"}[Y]||"Development session"}if(Z.filesChanged>0)M+=` (${Z.filesChanged} files, +${Z.linesAdded}/-${Z.linesRemoved})`;if(z.agents.length>0)M+=` with ${z.agents.join(", ")}`;let I=I8(X);if(N.length>0&&I.length===0){if(G.refactor||G.perf)I.push("Code quality and performance improvements");if(G.test)I.push("Enhanced test coverage");if(G.fix)I.push("Issue resolution and stability improvements")}let K=[];if(z.inProgressTasks.length>0)K.push(...z.inProgressTasks.slice(0,3));if(N.length>0){let Y=N[0]?.toLowerCase()||"";if(Y.includes("wip")||Y.includes("todo"))K.push("Complete work-in-progress items")}if(K.length===0)K.push("Continue development","Review and test changes");return{summary:M,learnings:I.slice(0,5),nextSteps:K.slice(0,5)}}async function j8($=!1,J=!1){let N=process.cwd(),G=j2(N),Z=x9(N);if($){console.log(JSON.stringify({retrospectives:Z},null,2));return}if(!J){let{summary:R,learnings:j,nextSteps:x}=Y8(N),U=$$(N),B={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:R,keyLearnings:j,filesChanged:U,nextSteps:x};Y2(N,B),console.clear(),a(y.default.bgMagenta(y.default.white(" \uD83D\uDD04 oh-my-ag retro "))),O([y.default.green("✅ Auto-generated retrospective saved!"),"",y.default.bold("Summary:"),R,"",y.default.bold("Key Learnings:"),...j.map((V)=>` • ${V}`),"",y.default.bold("Next Steps:"),...x.map((V)=>` → ${V}`)].join(`
137
139
  `),"Saved"),m(y.default.dim(`Stored in: ${G}`));return}console.clear(),a(y.default.bgMagenta(y.default.white(" \uD83D\uDD04 oh-my-ag retro (interactive) ")));let z=Z[0];if(z)O([y.default.bold("\uD83D\uDCC5 Last Retrospective"),`Date: ${z.date}`,"",y.default.bold("Summary:"),z.summary,"",y.default.bold("Key Learnings:"),...z.keyLearnings.map((R)=>` • ${R}`),"",y.default.bold("Next Steps:"),...z.nextSteps.map((R)=>` → ${R}`)].join(`
138
- `),"Previous Session");let X=await c1({message:"What would you like to do?",options:[{value:"auto",label:"✨ Auto-generate from git history",hint:"Analyze commits and agent activity"},{value:"manual",label:"\uD83D\uDCDD Create manually",hint:"Write your own retrospective"},{value:"list",label:"\uD83D\uDCCB View past retrospectives"},{value:"exit",label:"\uD83D\uDC4B Exit"}]});if(c(X)||X==="exit"){m(y.default.dim("Goodbye!"));return}if(X==="list"){if(Z.length===0)O(y.default.yellow("No retrospectives found."),"History");else{let R=Z.map((x,j)=>`${j+1}. [${x.date.split("T")[0]}] ${x.summary.slice(0,50)}...`).join(`
139
- `);O(R,`\uD83D\uDCDA Past Retrospectives (${Z.length})`)}m(y.default.dim(`Stored in: ${G}`));return}if(X==="auto"){let{summary:R,learnings:x,nextSteps:j}=M8(N),U=e0(N);O([y.default.bold("\uD83E\uDD16 Auto-generated Content"),"",y.default.bold("Summary:"),R,"",y.default.bold("Key Learnings:"),...x.map((_)=>` • ${_}`),"",y.default.bold("Next Steps:"),...j.map((_)=>` → ${_}`)].join(`
140
- `),"Preview");let T=await w1({message:"Save this retrospective?",initialValue:!0});if(c(T)||!T){Z1("Cancelled.");return}let B={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:R,keyLearnings:x,filesChanged:U,nextSteps:j};Y2(N,B),O([y.default.green("✅ Retrospective saved!"),"",`Summary: ${B.summary}`,`Learnings: ${B.keyLearnings.length} items`,`Next steps: ${B.nextSteps.length} items`].join(`
141
- `),"Saved"),m(y.default.dim(`Stored in: ${G}`));return}let Q=e4(N),M=e0(N);if(Q.length>0)O(Q.join(`
140
+ `),"Previous Session");let X=await c1({message:"What would you like to do?",options:[{value:"auto",label:"✨ Auto-generate from git history",hint:"Analyze commits and agent activity"},{value:"manual",label:"\uD83D\uDCDD Create manually",hint:"Write your own retrospective"},{value:"list",label:"\uD83D\uDCCB View past retrospectives"},{value:"exit",label:"\uD83D\uDC4B Exit"}]});if(c(X)||X==="exit"){m(y.default.dim("Goodbye!"));return}if(X==="list"){if(Z.length===0)O(y.default.yellow("No retrospectives found."),"History");else{let R=Z.map((j,x)=>`${x+1}. [${j.date.split("T")[0]}] ${j.summary.slice(0,50)}...`).join(`
141
+ `);O(R,`\uD83D\uDCDA Past Retrospectives (${Z.length})`)}m(y.default.dim(`Stored in: ${G}`));return}if(X==="auto"){let{summary:R,learnings:j,nextSteps:x}=Y8(N),U=$$(N);O([y.default.bold("\uD83E\uDD16 Auto-generated Content"),"",y.default.bold("Summary:"),R,"",y.default.bold("Key Learnings:"),...j.map((_)=>` • ${_}`),"",y.default.bold("Next Steps:"),...x.map((_)=>` → ${_}`)].join(`
142
+ `),"Preview");let B=await w1({message:"Save this retrospective?",initialValue:!0});if(c(B)||!B){Z1("Cancelled.");return}let V={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:R,keyLearnings:j,filesChanged:U,nextSteps:x};Y2(N,V),O([y.default.green("✅ Retrospective saved!"),"",`Summary: ${V.summary}`,`Learnings: ${V.keyLearnings.length} items`,`Next steps: ${V.nextSteps.length} items`].join(`
143
+ `),"Saved"),m(y.default.dim(`Stored in: ${G}`));return}let Q=J8(N),M=$$(N);if(Q.length>0)O(Q.join(`
142
144
  `),"Recent Commits");if(M.length>0)O(M.join(`
143
- `),"Changed Files");let I=await i0({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(c(I)){Z1("Cancelled.");return}let K=await i0({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(c(K)){Z1("Cancelled.");return}let Y=await i0({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(c(Y)){Z1("Cancelled.");return}let H={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:I,keyLearnings:K.split(",").map((R)=>R.trim()).filter(Boolean),filesChanged:M,nextSteps:Y.split(",").map((R)=>R.trim()).filter(Boolean)};Y2(N,H),O([y.default.green("✅ Retrospective saved!"),"",`Summary: ${H.summary}`,`Learnings: ${H.keyLearnings.length} items`,`Next steps: ${H.nextSteps.length} items`].join(`
144
- `),"Saved"),m(y.default.dim(`Stored in: ${G}`))}import{existsSync as J$,mkdirSync as j9,readdirSync as x9,readFileSync as H9,writeFileSync as K8}from"node:fs";import{dirname as R9,join as j8}from"node:path";var I1=k(N1(),1);function H2($){return j8($,".serena","metrics.json")}function x2(){return{sessions:0,skillsUsed:{},tasksCompleted:0,totalSessionTime:0,filesChanged:0,linesAdded:0,linesRemoved:0,lastUpdated:new Date().toISOString(),startDate:new Date().toISOString()}}function q9($){let J=H2($);if(J$(J))try{return JSON.parse(H9(J,"utf-8"))}catch{return x2()}return x2()}function U9($,J){let N=H2($),G=R9(N);if(!J$(G))j9(G,{recursive:!0});J.lastUpdated=new Date().toISOString(),K8(N,JSON.stringify(J,null,2),"utf-8")}function B9($){let J=j8($,".serena","memories"),N={};if(!J$(J))return N;try{let G=x9(J);for(let Z of G){let z=Z.match(/(?:progress|result)-(\w+)/);if(z?.[1]){let X=z[1];N[X]=(N[X]||0)+1}}}catch{}return N}async function x8($=!1,J=!1){let N=process.cwd(),G=H2(N);if(J){if(J$(G))K8(G,JSON.stringify(x2(),null,2),"utf-8");if($)console.log(JSON.stringify({reset:!0}));else console.log(I1.default.green("✅ Metrics reset successfully."));return}let Z=q9(N),z=t0(N),X=B9(N);for(let[Y,H]of Object.entries(X))Z.skillsUsed[Y]=(Z.skillsUsed[Y]||0)+H;Z.filesChanged+=z.filesChanged,Z.linesAdded+=z.linesAdded,Z.linesRemoved+=z.linesRemoved,Z.sessions+=1,U9(N,Z);let Q=Math.max(1,Math.ceil((Date.now()-new Date(Z.startDate).getTime())/86400000)),M=Z.sessions>0?Math.round(Z.totalSessionTime/Z.sessions):0;if($){console.log(JSON.stringify({...Z,gitStats:z,daysSinceStart:Q,avgSessionTime:M},null,2));return}console.clear(),a(I1.default.bgMagenta(I1.default.white(" \uD83D\uDCCA oh-my-ag stats ")));let I=[I1.default.bold(`\uD83D\uDCC8 Productivity Metrics (${Q} days)`),"┌─────────────────────┬──────────────┐",`│ ${I1.default.bold("Metric")} │ ${I1.default.bold("Value")} │`,"├─────────────────────┼──────────────┤",`│ Sessions │ ${String(Z.sessions).padEnd(12)} │`,`│ Tasks Completed │ ${String(Z.tasksCompleted).padEnd(12)} │`,`│ Files Changed │ ${String(Z.filesChanged).padEnd(12)} │`,`│ Lines Added │ ${I1.default.green(`+${Z.linesAdded}`).padEnd(12)} │`,`│ Lines Removed │ ${I1.default.red(`-${Z.linesRemoved}`).padEnd(12)} │`,"└─────────────────────┴──────────────┘"].join(`
145
- `);O(I,"Overview");let K=Object.entries(Z.skillsUsed).sort(([,Y],[,H])=>H-Y).slice(0,5);if(K.length>0){let Y=[I1.default.bold("\uD83C\uDFC6 Top Skills Used"),...K.map(([H,R],x)=>` ${x+1}. ${H} (${R})`)].join(`
146
- `);O(Y,"Skills")}m(I1.default.dim(`Data stored in: ${G}`))}async function R2($,J,{concurrency:N=Number.POSITIVE_INFINITY,stopOnError:G=!0,signal:Z}={}){return new Promise((z,X)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof J!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(N)&&N>=1||N===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${N}\` (${typeof N})`);let Q=[],M=[],I=new Map,K=!1,Y=!1,H=!1,R=0,x=0,j=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),U=()=>{_(Z.reason)},T=()=>{Z?.removeEventListener("abort",U)},B=(L)=>{z(L),T()},_=(L)=>{K=!0,Y=!0,X(L),T()};if(Z){if(Z.aborted)_(Z.reason);Z.addEventListener("abort",U,{once:!0})}let A=async()=>{if(Y)return;let L=await j.next(),D=x;if(x++,L.done){if(H=!0,R===0&&!Y){if(!G&&M.length>0){_(AggregateError(M));return}if(Y=!0,I.size===0){B(Q);return}let V=[];for(let[C,l]of Q.entries()){if(I.get(C)===H8)continue;V.push(l)}B(V)}return}R++,(async()=>{try{let V=await L.value;if(Y)return;let C=await J(V,D);if(C===H8)I.set(D,C);Q[D]=C,R--,await A()}catch(V){if(G)_(V);else{M.push(V),R--;try{await A()}catch(C){_(C)}}}})()};(async()=>{for(let L=0;L<N;L++){try{await A()}catch(D){_(D);break}if(H||K)break}})()})}var H8=Symbol("skip");var P1=k(N1(),1);import{createHash as T9}from"node:crypto";import{existsSync as q2,mkdirSync as R8,readFileSync as V9,writeFileSync as q8}from"node:fs";import{dirname as U8,join as U2}from"node:path";function _9($){return T9("sha256").update($,"utf-8").digest("hex")}async function B8($){let J=U2($,".agent","skills","_version.json");if(!q2(J))return null;try{let N=V9(J,"utf-8");return JSON.parse(N).version||null}catch{return null}}async function T8($,J){let N=U2($,".agent","skills","_version.json"),G=U8(N);if(!q2(G))R8(G,{recursive:!0});q8(N,JSON.stringify({version:J},null,2),"utf-8")}async function V8(){let $=`https://raw.githubusercontent.com/${K0}/main/prompt-manifest.json`,J=await fetch($);if(!J.ok)throw Error("Failed to fetch remote manifest");return await J.json()}async function _8($){let J=`https://raw.githubusercontent.com/${K0}/main/${$.path}`,N=await fetch(J);if(!N.ok)return{path:$.path,success:!1,error:`HTTP ${N.status}`};let G=await N.text();if(_9(G)!==$.sha256)return{path:$.path,success:!1,error:"SHA256 mismatch"};let z=U2(process.cwd(),$.path),X=U8(z);if(!q2(X))R8(X,{recursive:!0});return q8(z,G,"utf-8"),{path:$.path,success:!0}}async function C8(){console.clear(),a(P1.default.bgMagenta(P1.default.white(" \uD83D\uDEF8 oh-my-ag update ")));let $=process.cwd(),J=h1();try{J.start("Checking for updates...");let N=await V8(),G=await B8($);if(G===N.version){J.stop(P1.default.green("Already up to date!")),m(`Current version: ${P1.default.cyan(G)}`);return}J.message(`Updating from ${G||"not installed"} to ${P1.default.cyan(N.version)}...`);let Z=await R2(N.files,async(Q)=>_8(Q),{concurrency:10}),z=Z.filter((Q)=>!Q.success);if(z.length>0)J.stop("Update completed with errors"),O(z.map((Q)=>`${P1.default.red("✗")} ${Q.path}: ${Q.error}`).join(`
147
- `),`${z.length} files failed`);else J.stop(`Updated to version ${P1.default.cyan(N.version)}!`);await T8($,N.version);let X=Z.length-z.length;m(z.length>0?`${X} files updated, ${z.length} failed`:`${X} files updated successfully`)}catch(N){J.stop("Update failed"),d.error(N instanceof Error?N.message:String(N)),process.exit(1)}}import{existsSync as vJ,mkdirSync as uJ,readdirSync as L0,readFileSync as bJ,statSync as i2}from"node:fs";import{createServer as lJ}from"node:http";import{basename as r3,join as j1}from"node:path";import{stat as a9}from"fs";import{stat as t9,readdir as e9}from"fs/promises";import{EventEmitter as $7}from"events";import*as S from"path";import{stat as C9,lstat as L8,readdir as L9,realpath as A9}from"node:fs/promises";import{Readable as D9}from"node:stream";import{resolve as A8,relative as P9,join as S9,sep as W9}from"node:path";var e={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},B2={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:e.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(B2);var W8="READDIRP_RECURSIVE_ERROR",F9=new Set(["ENOENT","EPERM","EACCES","ELOOP",W8]),D8=[e.DIR_TYPE,e.EVERYTHING_TYPE,e.FILE_DIR_TYPE,e.FILE_TYPE],O9=new Set([e.DIR_TYPE,e.EVERYTHING_TYPE,e.FILE_DIR_TYPE]),g9=new Set([e.EVERYTHING_TYPE,e.FILE_DIR_TYPE,e.FILE_TYPE]),f9=($)=>F9.has($.code),y9=process.platform==="win32",P8=($)=>!0,S8=($)=>{if($===void 0)return P8;if(typeof $==="function")return $;if(typeof $==="string"){let J=$.trim();return(N)=>N.basename===J}if(Array.isArray($)){let J=$.map((N)=>N.trim());return(N)=>J.some((G)=>N.basename===G)}return P8};class F8 extends D9{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let J={...B2,...$},{root:N,type:G}=J;this._fileFilter=S8(J.fileFilter),this._directoryFilter=S8(J.directoryFilter);let Z=J.lstat?L8:C9;if(y9)this._stat=(z)=>Z(z,{bigint:!0});else this._stat=Z;this._maxDepth=J.depth??B2.depth,this._wantsDir=G?O9.has(G):!1,this._wantsFile=G?g9.has(G):!1,this._wantsEverything=G===e.EVERYTHING_TYPE,this._root=A8(N),this._isDirent=!J.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(N,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let J=this.parent,N=J&&J.files;if(N&&N.length>0){let{path:G,depth:Z}=J,z=N.splice(0,$).map((Q)=>this._formatEntry(Q,G)),X=await Promise.all(z);for(let Q of X){if(!Q)continue;if(this.destroyed)return;let M=await this._getEntryType(Q);if(M==="directory"&&this._directoryFilter(Q)){if(Z<=this._maxDepth)this.parents.push(this._exploreDir(Q.fullPath,Z+1));if(this._wantsDir)this.push(Q),$--}else if((M==="file"||this._includeAsFile(Q))&&this._fileFilter(Q)){if(this._wantsFile)this.push(Q),$--}}}else{let G=this.parents.pop();if(!G){this.push(null);break}if(this.parent=await G,this.destroyed)return}}}catch(J){this.destroy(J)}finally{this.reading=!1}}async _exploreDir($,J){let N;try{N=await L9($,this._rdOptions)}catch(G){this._onError(G)}return{files:N,depth:J,path:$}}async _formatEntry($,J){let N,G=this._isDirent?$.name:$;try{let Z=A8(S9(J,G));N={path:P9(this._root,Z),fullPath:Z,basename:G},N[this._statsProp]=this._isDirent?$:await this._stat(Z)}catch(Z){this._onError(Z);return}return N}_onError($){if(f9($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let J=$[this._statsProp];if(J.isFile())return"file";if(J.isDirectory())return"directory";if(J&&J.isSymbolicLink()){let N=$.fullPath;try{let G=await A9(N),Z=await L8(G);if(Z.isFile())return"file";if(Z.isDirectory()){let z=G.length;if(N.startsWith(G)&&N.substr(z,1)===W9){let X=Error(`Circular symlink detected: "${N}" points to "${G}"`);return X.code=W8,this._onError(X)}return"directory"}}catch(G){return this._onError(G),""}}}_includeAsFile($){let J=$&&$[this._statsProp];return J&&this._wantsEverything&&!J.isDirectory()}}function O8($,J={}){let N=J.entryType||J.type;if(N==="both")N=e.FILE_DIR_TYPE;if(N)J.type=N;if(!$)throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");else if(typeof $!=="string")throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(N&&!D8.includes(N))throw Error(`readdirp: Invalid type passed. Use one of ${D8.join(", ")}`);return J.root=$,new F8(J)}import{watchFile as E9,unwatchFile as g8,watch as w9}from"fs";import{open as v9,stat as y8,lstat as u9,realpath as T2}from"fs/promises";import*as v from"path";import{type as b9}from"os";var l9="data",C2="end",E8="close",z$=()=>{};var X$=process.platform,L2=X$==="win32",k9=X$==="darwin",m9=X$==="linux",h9=X$==="freebsd",w8=b9()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},Y1=E,c9="watch",d9={lstat:u9,stat:y8},u1="listeners",N$="errHandlers",p1="rawEmitters",i9=[u1,N$,p1],n9=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),p9=($)=>n9.has(v.extname($).slice(1).toLowerCase()),_2=($,J)=>{if($ instanceof Set)$.forEach(J);else J($)},x0=($,J,N)=>{let G=$[J];if(!(G instanceof Set))$[J]=G=new Set([G]);G.add(N)},s9=($)=>(J)=>{let N=$[J];if(N instanceof Set)N.clear();else delete $[J]},H0=($,J,N)=>{let G=$[J];if(G instanceof Set)G.delete(N);else if(G===N)delete $[J]},v8=($)=>$ instanceof Set?$.size===0:!$,G$=new Map;function f8($,J,N,G,Z){let z=(X,Q)=>{if(N($),Z(X,Q,{watchedPath:$}),Q&&$!==Q)Z$(v.resolve($,Q),u1,v.join($,Q))};try{return w9($,{persistent:J.persistent},z)}catch(X){G(X);return}}var Z$=($,J,N,G,Z)=>{let z=G$.get($);if(!z)return;_2(z[J],(X)=>{X(N,G,Z)})},o9=($,J,N,G)=>{let{listener:Z,errHandler:z,rawEmitter:X}=G,Q=G$.get(J),M;if(!N.persistent){if(M=f8($,N,Z,z,X),!M)return;return M.close.bind(M)}if(Q)x0(Q,u1,Z),x0(Q,N$,z),x0(Q,p1,X);else{if(M=f8($,N,Z$.bind(null,J,u1),z,Z$.bind(null,J,p1)),!M)return;M.on(Y1.ERROR,async(I)=>{let K=Z$.bind(null,J,N$);if(Q)Q.watcherUnusable=!0;if(L2&&I.code==="EPERM")try{await(await v9($,"r")).close(),K(I)}catch(Y){}else K(I)}),Q={listeners:Z,errHandlers:z,rawEmitters:X,watcher:M},G$.set(J,Q)}return()=>{if(H0(Q,u1,Z),H0(Q,N$,z),H0(Q,p1,X),v8(Q.listeners))Q.watcher.close(),G$.delete(J),i9.forEach(s9(Q)),Q.watcher=void 0,Object.freeze(Q)}},V2=new Map,r9=($,J,N,G)=>{let{listener:Z,rawEmitter:z}=G,X=V2.get(J),Q=X&&X.options;if(Q&&(Q.persistent<N.persistent||Q.interval>N.interval))g8(J),X=void 0;if(X)x0(X,u1,Z),x0(X,p1,z);else X={listeners:Z,rawEmitters:z,options:N,watcher:E9(J,N,(M,I)=>{_2(X.rawEmitters,(Y)=>{Y(Y1.CHANGE,J,{curr:M,prev:I})});let K=M.mtimeMs;if(M.size!==I.size||K>I.mtimeMs||K===0)_2(X.listeners,(Y)=>Y($,M))})},V2.set(J,X);return()=>{if(H0(X,u1,Z),H0(X,p1,z),v8(X.listeners))V2.delete(J),g8(J),X.options=X.watcher=void 0,Object.freeze(X)}};class A2{constructor($){this.fsw=$,this._boundHandleError=(J)=>$._handleError(J)}_watchWithNodeFs($,J){let N=this.fsw.options,G=v.dirname($),Z=v.basename($);this.fsw._getWatchedDir(G).add(Z);let X=v.resolve($),Q={persistent:N.persistent};if(!J)J=z$;let M;if(N.usePolling){let I=N.interval!==N.binaryInterval;Q.interval=I&&p9(Z)?N.binaryInterval:N.interval,M=r9($,X,Q,{listener:J,rawEmitter:this.fsw._emitRaw})}else M=o9($,X,Q,{listener:J,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return M}_handleFile($,J,N){if(this.fsw.closed)return;let G=v.dirname($),Z=v.basename($),z=this.fsw._getWatchedDir(G),X=J;if(z.has(Z))return;let Q=async(I,K)=>{if(!this.fsw._throttle(c9,$,5))return;if(!K||K.mtimeMs===0)try{let Y=await y8($);if(this.fsw.closed)return;let{atimeMs:H,mtimeMs:R}=Y;if(!H||H<=R||R!==X.mtimeMs)this.fsw._emit(Y1.CHANGE,$,Y);if((k9||m9||h9)&&X.ino!==Y.ino){this.fsw._closeFile(I),X=Y;let x=this._watchWithNodeFs($,Q);if(x)this.fsw._addPathCloser(I,x)}else X=Y}catch(Y){this.fsw._remove(G,Z)}else if(z.has(Z)){let{atimeMs:Y,mtimeMs:H}=K;if(!Y||Y<=H||H!==X.mtimeMs)this.fsw._emit(Y1.CHANGE,$,K);X=K}},M=this._watchWithNodeFs($,Q);if(!(N&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(Y1.ADD,$,0))return;this.fsw._emit(Y1.ADD,$,J)}return M}async _handleSymlink($,J,N,G){if(this.fsw.closed)return;let Z=$.fullPath,z=this.fsw._getWatchedDir(J);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let X;try{X=await T2(N)}catch(Q){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(z.has(G)){if(this.fsw._symlinkPaths.get(Z)!==X)this.fsw._symlinkPaths.set(Z,X),this.fsw._emit(Y1.CHANGE,N,$.stats)}else z.add(G),this.fsw._symlinkPaths.set(Z,X),this.fsw._emit(Y1.ADD,N,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(Z))return!0;this.fsw._symlinkPaths.set(Z,!0)}_handleRead($,J,N,G,Z,z,X){if($=v.join($,""),X=this.fsw._throttle("readdir",$,1000),!X)return;let Q=this.fsw._getWatchedDir(N.path),M=new Set,I=this.fsw._readdirp($,{fileFilter:(K)=>N.filterPath(K),directoryFilter:(K)=>N.filterDir(K)});if(!I)return;return I.on(l9,async(K)=>{if(this.fsw.closed){I=void 0;return}let Y=K.path,H=v.join($,Y);if(M.add(Y),K.stats.isSymbolicLink()&&await this._handleSymlink(K,$,H,Y))return;if(this.fsw.closed){I=void 0;return}if(Y===G||!G&&!Q.has(Y))this.fsw._incrReadyCount(),H=v.join(Z,v.relative(Z,H)),this._addToNodeFs(H,J,N,z+1)}).on(Y1.ERROR,this._boundHandleError),new Promise((K,Y)=>{if(!I)return Y();I.once(C2,()=>{if(this.fsw.closed){I=void 0;return}let H=X?X.clear():!1;if(K(void 0),Q.getChildren().filter((R)=>{return R!==$&&!M.has(R)}).forEach((R)=>{this.fsw._remove($,R)}),I=void 0,H)this._handleRead($,!1,N,G,Z,z,X)})})}async _handleDir($,J,N,G,Z,z,X){let Q=this.fsw._getWatchedDir(v.dirname($)),M=Q.has(v.basename($));if(!(N&&this.fsw.options.ignoreInitial)&&!Z&&!M)this.fsw._emit(Y1.ADD_DIR,$,J);Q.add(v.basename($)),this.fsw._getWatchedDir($);let I,K,Y=this.fsw.options.depth;if((Y==null||G<=Y)&&!this.fsw._symlinkPaths.has(X)){if(!Z){if(await this._handleRead($,N,z,Z,$,G,I),this.fsw.closed)return}K=this._watchWithNodeFs($,(H,R)=>{if(R&&R.mtimeMs===0)return;this._handleRead(H,!1,z,Z,$,G,I)})}return K}async _addToNodeFs($,J,N,G,Z){let z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return z(),!1;let X=this.fsw._getWatchHelpers($);if(N)X.filterPath=(Q)=>N.filterPath(Q),X.filterDir=(Q)=>N.filterDir(Q);try{let Q=await d9[X.statMethod](X.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(X.watchPath,Q))return z(),!1;let M=this.fsw.options.followSymlinks,I;if(Q.isDirectory()){let K=v.resolve($),Y=M?await T2($):$;if(this.fsw.closed)return;if(I=await this._handleDir(X.watchPath,Q,J,G,Z,X,Y),this.fsw.closed)return;if(K!==Y&&Y!==void 0)this.fsw._symlinkPaths.set(K,Y)}else if(Q.isSymbolicLink()){let K=M?await T2($):$;if(this.fsw.closed)return;let Y=v.dirname(X.watchPath);if(this.fsw._getWatchedDir(Y).add(X.watchPath),this.fsw._emit(Y1.ADD,X.watchPath,Q),I=await this._handleDir(Y,Q,J,G,$,X,K),this.fsw.closed)return;if(K!==void 0)this.fsw._symlinkPaths.set(v.resolve($),K)}else I=this._handleFile(X.watchPath,Q,J);if(z(),I)this.fsw._addPathCloser($,I);return!1}catch(Q){if(this.fsw._handleError(Q))return z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var D2="/",J7="//",h8=".",N7="..",G7="string",Z7=/\\/g,u8=/\/\//,z7=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,X7=/^\.[/\\]/;function Q$($){return Array.isArray($)?$:[$]}var P2=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function Q7($){if(typeof $==="function")return $;if(typeof $==="string")return(J)=>$===J;if($ instanceof RegExp)return(J)=>$.test(J);if(typeof $==="object"&&$!==null)return(J)=>{if($.path===J)return!0;if($.recursive){let N=S.relative($.path,J);if(!N)return!1;return!N.startsWith("..")&&!S.isAbsolute(N)}return!1};return()=>!1}function M7($){if(typeof $!=="string")throw Error("string expected");$=S.normalize($),$=$.replace(/\\/g,"/");let J=!1;if($.startsWith("//"))J=!0;let N=/\/\//;while($.match(N))$=$.replace(N,"/");if(J)$="/"+$;return $}function b8($,J,N){let G=M7(J);for(let Z=0;Z<$.length;Z++){let z=$[Z];if(z(G,N))return!0}return!1}function I7($,J){if($==null)throw TypeError("anymatch: specify first argument");let G=Q$($).map((Z)=>Q7(Z));if(J==null)return(Z,z)=>{return b8(G,Z,z)};return b8(G,J)}var l8=($)=>{let J=Q$($).flat();if(!J.every((N)=>typeof N===G7))throw TypeError(`Non-string provided as watch path: ${J}`);return J.map(c8)},k8=($)=>{let J=$.replace(Z7,D2),N=!1;if(J.startsWith(J7))N=!0;while(J.match(u8))J=J.replace(u8,D2);if(N)J=D2+J;return J},c8=($)=>k8(S.normalize(k8($))),m8=($="")=>(J)=>{if(typeof J==="string")return c8(S.isAbsolute(J)?J:S.join($,J));else return J},Y7=($,J)=>{if(S.isAbsolute($))return $;return S.join(J,$)},K7=Object.freeze(new Set);class d8{constructor($,J){this.path=$,this._removeWatcher=J,this.items=new Set}add($){let{items:J}=this;if(!J)return;if($!==h8&&$!==N7)J.add($)}async remove($){let{items:J}=this;if(!J)return;if(J.delete($),J.size>0)return;let N=this.path;try{await e9(N)}catch(G){if(this._removeWatcher)this._removeWatcher(S.dirname(N),S.basename(N))}}has($){let{items:J}=this;if(!J)return;return J.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=z$,this.items=K7,Object.freeze(this)}}var j7="stat",x7="lstat";class i8{constructor($,J,N){this.fsw=N;let G=$;this.path=$=$.replace(X7,""),this.watchPath=G,this.fullWatchPath=S.resolve(G),this.dirParts=[],this.dirParts.forEach((Z)=>{if(Z.length>1)Z.pop()}),this.followSymlinks=J,this.statMethod=J?j7:x7}entryPath($){return S.join(this.watchPath,S.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:J}=$;if(J&&J.isSymbolicLink())return this.filterDir($);let N=this.entryPath($);return this.fsw._isntIgnored(N,J)&&this.fsw._hasReadPermissions(J)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class n8 extends $7{constructor($={}){super();this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let J=$.awaitWriteFinish,N={stabilityThreshold:2000,pollInterval:100},G={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?Q$($.ignored):Q$([]),awaitWriteFinish:J===!0?N:typeof J==="object"?{...N,...J}:!1};if(w8)G.usePolling=!0;if(G.atomic===void 0)G.atomic=!G.usePolling;let Z=process.env.CHOKIDAR_USEPOLLING;if(Z!==void 0){let Q=Z.toLowerCase();if(Q==="false"||Q==="0")G.usePolling=!1;else if(Q==="true"||Q==="1")G.usePolling=!0;else G.usePolling=!!Q}let z=process.env.CHOKIDAR_INTERVAL;if(z)G.interval=Number.parseInt(z,10);let X=0;this._emitReady=()=>{if(X++,X>=this._readyCount)this._emitReady=z$,this._readyEmitted=!0,process.nextTick(()=>this.emit(E.READY))},this._emitRaw=(...Q)=>this.emit(E.RAW,...Q),this._boundRemove=this._remove.bind(this),this.options=G,this._nodeFsHandler=new A2(this),Object.freeze(G)}_addIgnoredPath($){if(P2($)){for(let J of this._ignoredPaths)if(P2(J)&&J.path===$.path&&J.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let J of this._ignoredPaths)if(P2(J)&&J.path===$)this._ignoredPaths.delete(J)}}add($,J,N){let{cwd:G}=this.options;this.closed=!1,this._closePromise=void 0;let Z=l8($);if(G)Z=Z.map((z)=>{return Y7(z,G)});if(Z.forEach((z)=>{this._removeIgnoredPath(z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=Z.length,Promise.all(Z.map(async(z)=>{let X=await this._nodeFsHandler._addToNodeFs(z,!N,void 0,0,J);if(X)this._emitReady();return X})).then((z)=>{if(this.closed)return;z.forEach((X)=>{if(X)this.add(S.dirname(X),S.basename(J||X))})}),this}unwatch($){if(this.closed)return this;let J=l8($),{cwd:N}=this.options;return J.forEach((G)=>{if(!S.isAbsolute(G)&&!this._closers.has(G)){if(N)G=S.join(N,G);G=S.resolve(G)}if(this._closePath(G),this._addIgnoredPath(G),this._watched.has(G))this._addIgnoredPath({path:G,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((J)=>J.forEach((N)=>{let G=N();if(G instanceof Promise)$.push(G)})),this._streams.forEach((J)=>J.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((J)=>J.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=$.length?Promise.all($).then(()=>{return}):Promise.resolve(),this._closePromise}getWatched(){let $={};return this._watched.forEach((J,N)=>{let Z=(this.options.cwd?S.relative(this.options.cwd,N):N)||h8;$[Z]=J.getChildren().sort()}),$}emitWithAll($,J){if(this.emit($,...J),$!==E.ERROR)this.emit(E.ALL,$,...J)}async _emit($,J,N){if(this.closed)return;let G=this.options;if(L2)J=S.normalize(J);if(G.cwd)J=S.relative(G.cwd,J);let Z=[J];if(N!=null)Z.push(N);let z=G.awaitWriteFinish,X;if(z&&(X=this._pendingWrites.get(J)))return X.lastChange=new Date,this;if(G.atomic){if($===E.UNLINK)return this._pendingUnlinks.set(J,[$,...Z]),setTimeout(()=>{this._pendingUnlinks.forEach((Q,M)=>{this.emit(...Q),this.emit(E.ALL,...Q),this._pendingUnlinks.delete(M)})},typeof G.atomic==="number"?G.atomic:100),this;if($===E.ADD&&this._pendingUnlinks.has(J))$=E.CHANGE,this._pendingUnlinks.delete(J)}if(z&&($===E.ADD||$===E.CHANGE)&&this._readyEmitted){let Q=(M,I)=>{if(M)$=E.ERROR,Z[0]=M,this.emitWithAll($,Z);else if(I){if(Z.length>1)Z[1]=I;else Z.push(I);this.emitWithAll($,Z)}};return this._awaitWriteFinish(J,z.stabilityThreshold,$,Q),this}if($===E.CHANGE){if(!this._throttle(E.CHANGE,J,50))return this}if(G.alwaysStat&&N===void 0&&($===E.ADD||$===E.ADD_DIR||$===E.CHANGE)){let Q=G.cwd?S.join(G.cwd,J):J,M;try{M=await t9(Q)}catch(I){}if(!M||this.closed)return;Z.push(M)}return this.emitWithAll($,Z),this}_handleError($){let J=$&&$.code;if($&&J!=="ENOENT"&&J!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||J!=="EPERM"&&J!=="EACCES"))this.emit(E.ERROR,$);return $||this.closed}_throttle($,J,N){if(!this._throttled.has($))this._throttled.set($,new Map);let G=this._throttled.get($);if(!G)throw Error("invalid throttle");let Z=G.get(J);if(Z)return Z.count++,!1;let z,X=()=>{let M=G.get(J),I=M?M.count:0;if(G.delete(J),clearTimeout(z),M)clearTimeout(M.timeoutObject);return I};z=setTimeout(X,N);let Q={timeoutObject:z,clear:X,count:0};return G.set(J,Q),Q}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,J,N,G){let Z=this.options.awaitWriteFinish;if(typeof Z!=="object")return;let z=Z.pollInterval,X,Q=$;if(this.options.cwd&&!S.isAbsolute($))Q=S.join(this.options.cwd,$);let M=new Date,I=this._pendingWrites;function K(Y){a9(Q,(H,R)=>{if(H||!I.has($)){if(H&&H.code!=="ENOENT")G(H);return}let x=Number(new Date);if(Y&&R.size!==Y.size)I.get($).lastChange=x;let j=I.get($);if(x-j.lastChange>=J)I.delete($),G(void 0,R);else X=setTimeout(K,z,R)})}if(!I.has($))I.set($,{lastChange:M,cancelWait:()=>{return I.delete($),clearTimeout(X),N}}),X=setTimeout(K,z)}_isIgnored($,J){if(this.options.atomic&&z7.test($))return!0;if(!this._userIgnored){let{cwd:N}=this.options,Z=(this.options.ignored||[]).map(m8(N)),X=[...[...this._ignoredPaths].map(m8(N)),...Z];this._userIgnored=I7(X,void 0)}return this._userIgnored($,J)}_isntIgnored($,J){return!this._isIgnored($,J)}_getWatchHelpers($){return new i8($,this.options.followSymlinks,this)}_getWatchedDir($){let J=S.resolve($);if(!this._watched.has(J))this._watched.set(J,new d8(J,this._boundRemove));return this._watched.get(J)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,J,N){let G=S.join($,J),Z=S.resolve(G);if(N=N!=null?N:this._watched.has(G)||this._watched.has(Z),!this._throttle("remove",G,100))return;if(!N&&this._watched.size===1)this.add($,J,!0);this._getWatchedDir(G).getChildren().forEach((Y)=>this._remove(G,Y));let Q=this._getWatchedDir($),M=Q.has(J);if(Q.remove(J),this._symlinkPaths.has(Z))this._symlinkPaths.delete(Z);let I=G;if(this.options.cwd)I=S.relative(this.options.cwd,G);if(this.options.awaitWriteFinish&&this._pendingWrites.has(I)){if(this._pendingWrites.get(I).cancelWait()===E.ADD)return}this._watched.delete(G),this._watched.delete(Z);let K=N?E.UNLINK_DIR:E.UNLINK;if(M&&!this._isIgnored(G))this._emit(K,G);this._closePath(G)}_closePath($){this._closeFile($);let J=S.dirname($);this._getWatchedDir(J).remove(S.basename($))}_closeFile($){let J=this._closers.get($);if(!J)return;J.forEach((N)=>N()),this._closers.delete($)}_addPathCloser($,J){if(!J)return;let N=this._closers.get($);if(!N)N=[],this._closers.set($,N);N.push(J)}_readdirp($,J){if(this.closed)return;let N={type:E.ALL,alwaysStat:!0,lstat:!0,...J,depth:0},G=O8($,N);return this._streams.add(G),G.once(E8,()=>{G=void 0}),G.once(C2,()=>{if(G)this._streams.delete(G),G=void 0}),G}}function M$($,J={}){let N=new n8(J);return N.add($),N}var J0=k(N1(),1);var yJ=k(m3(),1),EJ=k(f2(),1),wJ=k(E2(),1),m2=k(T$(),1),h2=k(s3(),1);var o3=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT||"9847",10):9847;function kJ(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return j1($,".serena","memories");return j1(process.cwd(),".serena","memories")}function A0($){try{return bJ($,"utf-8")}catch{return""}}function mJ($){try{let J=L0($);if(J.includes("orchestrator-session.md"))return j1($,"orchestrator-session.md");let N=J.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:i2(j1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime);if(N.length>0&&N[0])return j1($,N[0].name)}catch{}return null}function hJ($){let J=mJ($);if(!J)return{id:"N/A",status:"UNKNOWN"};let N=A0(J);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||r3(J,".md")||"N/A",Z="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))Z="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))Z="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))Z="FAILED";else if(/Step \d+:.*\[/i.test(N))Z="RUNNING";return{id:G.trim(),status:Z}}function cJ($){let J=A0(j1($,"task-board.md"));if(!J)return[];let N=[],G=J.split(`
148
- `);for(let Z of G){if(!Z.startsWith("|")||/^\|\s*-+/.test(Z))continue;let z=Z.split("|").map((Q)=>Q.trim()).filter(Boolean),X=z[0];if(z.length<2||!X||/^agent$/i.test(X))continue;N.push({agent:z[0]||"",status:z[1]||"pending",task:z[2]||""})}return N}function d2($,J){try{let N=L0($).filter((z)=>z.startsWith(`progress-${J}`)&&z.endsWith(".md")).sort().reverse();if(N.length===0)return null;let Z=(N[0]?A0(j1($,N[0])):"").match(/turn[:\s]*(\d+)/i);return Z?.[1]?parseInt(Z[1],10):null}catch{return null}}function dJ($){try{return L0($).filter((N)=>N.endsWith(".md")&&N!==".gitkeep").map((N)=>({name:N,mtime:i2(j1($,N)).mtimeMs})).sort((N,G)=>G.mtime-N.mtime).slice(0,10).map((N)=>{let G=N.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||N.name.replace(/\.md$/,""),z=A0(j1($,N.name)).split(`
149
- `).map((Q)=>Q.trim()).filter((Q)=>Q&&!Q.startsWith("---")&&Q.length>3),X="";for(let Q=z.length-1;Q>=0;Q--){let M=z[Q];if(M){if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(M)){if(X=M.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),X.length>5)break}}}if(X.length>80)X=`${X.substring(0,77)}...`;return{agent:G,message:X,file:N.name}}).filter((N)=>N.message)}catch{return[]}}function iJ($){let J=[],N=new Set;try{let G=L0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:i2(j1($,Z)).mtimeMs})).sort((Z,z)=>z.mtime-Z.mtime);for(let Z of G){let z=A0(j1($,Z.name)),X=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(X?.[1])Q=X[1].trim();else if(/_agent|agent_|-agent/i.test(Z.name))Q=Z.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!N.has(Q.toLowerCase())){N.add(Q.toLowerCase());let M="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))M="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))M="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))M="failed";let I=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),K=I?.[1]?I[1].trim().substring(0,60):"";J.push({agent:Q,status:M,task:K,turn:d2($,Q)})}}}catch{}return J}function c2($){let J=hJ($),G=cJ($).map((Z)=>({...Z,turn:d2($,Z.agent)}));if(G.length===0)G=iJ($);if(G.length===0)try{let Z=L0($).filter((z)=>z.startsWith("progress-")&&z.endsWith(".md"));for(let z of Z){let X=z.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:X,status:"running",task:"",turn:d2($,X)})}}catch{}return{session:J,agents:G,activity:dJ($),memoriesDir:$,updatedAt:new Date().toISOString()}}var nJ=`<!DOCTYPE html>
145
+ `),"Changed Files");let I=await s0({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(c(I)){Z1("Cancelled.");return}let K=await s0({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(c(K)){Z1("Cancelled.");return}let Y=await s0({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(c(Y)){Z1("Cancelled.");return}let H={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:I,keyLearnings:K.split(",").map((R)=>R.trim()).filter(Boolean),filesChanged:M,nextSteps:Y.split(",").map((R)=>R.trim()).filter(Boolean)};Y2(N,H),O([y.default.green("✅ Retrospective saved!"),"",`Summary: ${H.summary}`,`Learnings: ${H.keyLearnings.length} items`,`Next steps: ${H.nextSteps.length} items`].join(`
146
+ `),"Saved"),m(y.default.dim(`Stored in: ${G}`))}import{existsSync as N$,mkdirSync as R9,readdirSync as H9,readFileSync as q9,writeFileSync as x8}from"node:fs";import{dirname as U9,join as R8}from"node:path";var Y1=k(N1(),1);function R2($){return R8($,".serena","metrics.json")}function x2(){return{sessions:0,skillsUsed:{},tasksCompleted:0,totalSessionTime:0,filesChanged:0,linesAdded:0,linesRemoved:0,lastUpdated:new Date().toISOString(),startDate:new Date().toISOString()}}function B9($){let J=R2($);if(N$(J))try{return JSON.parse(q9(J,"utf-8"))}catch{return x2()}return x2()}function V9($,J){let N=R2($),G=U9(N);if(!N$(G))R9(G,{recursive:!0});J.lastUpdated=new Date().toISOString(),x8(N,JSON.stringify(J,null,2),"utf-8")}function T9($){let J=R8($,".serena","memories"),N={};if(!N$(J))return N;try{let G=H9(J);for(let Z of G){let z=Z.match(/(?:progress|result)-(\w+)/);if(z?.[1]){let X=z[1];N[X]=(N[X]||0)+1}}}catch{}return N}async function H8($=!1,J=!1){let N=process.cwd(),G=R2(N);if(J){if(N$(G))x8(G,JSON.stringify(x2(),null,2),"utf-8");if($)console.log(JSON.stringify({reset:!0}));else console.log(Y1.default.green("✅ Metrics reset successfully."));return}let Z=B9(N),z=e0(N),X=T9(N);for(let[Y,H]of Object.entries(X))Z.skillsUsed[Y]=(Z.skillsUsed[Y]||0)+H;Z.filesChanged+=z.filesChanged,Z.linesAdded+=z.linesAdded,Z.linesRemoved+=z.linesRemoved,Z.sessions+=1,V9(N,Z);let Q=Math.max(1,Math.ceil((Date.now()-new Date(Z.startDate).getTime())/86400000)),M=Z.sessions>0?Math.round(Z.totalSessionTime/Z.sessions):0;if($){console.log(JSON.stringify({...Z,gitStats:z,daysSinceStart:Q,avgSessionTime:M},null,2));return}console.clear(),a(Y1.default.bgMagenta(Y1.default.white(" \uD83D\uDCCA oh-my-ag stats ")));let I=[Y1.default.bold(`\uD83D\uDCC8 Productivity Metrics (${Q} days)`),"┌─────────────────────┬──────────────┐",`│ ${Y1.default.bold("Metric")} │ ${Y1.default.bold("Value")} │`,"├─────────────────────┼──────────────┤",`│ Sessions │ ${String(Z.sessions).padEnd(12)} │`,`│ Tasks Completed │ ${String(Z.tasksCompleted).padEnd(12)} │`,`│ Files Changed │ ${String(Z.filesChanged).padEnd(12)} │`,`│ Lines Added │ ${Y1.default.green(`+${Z.linesAdded}`).padEnd(12)} │`,`│ Lines Removed │ ${Y1.default.red(`-${Z.linesRemoved}`).padEnd(12)} │`,"└─────────────────────┴──────────────┘"].join(`
147
+ `);O(I,"Overview");let K=Object.entries(Z.skillsUsed).sort(([,Y],[,H])=>H-Y).slice(0,5);if(K.length>0){let Y=[Y1.default.bold("\uD83C\uDFC6 Top Skills Used"),...K.map(([H,R],j)=>` ${j+1}. ${H} (${R})`)].join(`
148
+ `);O(Y,"Skills")}m(Y1.default.dim(`Data stored in: ${G}`))}async function H2($,J,{concurrency:N=Number.POSITIVE_INFINITY,stopOnError:G=!0,signal:Z}={}){return new Promise((z,X)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof J!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(N)&&N>=1||N===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${N}\` (${typeof N})`);let Q=[],M=[],I=new Map,K=!1,Y=!1,H=!1,R=0,j=0,x=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),U=()=>{_(Z.reason)},B=()=>{Z?.removeEventListener("abort",U)},V=(A)=>{z(A),B()},_=(A)=>{K=!0,Y=!0,X(A),B()};if(Z){if(Z.aborted)_(Z.reason);Z.addEventListener("abort",U,{once:!0})}let L=async()=>{if(Y)return;let A=await x.next(),D=j;if(j++,A.done){if(H=!0,R===0&&!Y){if(!G&&M.length>0){_(AggregateError(M));return}if(Y=!0,I.size===0){V(Q);return}let T=[];for(let[C,l]of Q.entries()){if(I.get(C)===q8)continue;T.push(l)}V(T)}return}R++,(async()=>{try{let T=await A.value;if(Y)return;let C=await J(T,D);if(C===q8)I.set(D,C);Q[D]=C,R--,await L()}catch(T){if(G)_(T);else{M.push(T),R--;try{await L()}catch(C){_(C)}}}})()};(async()=>{for(let A=0;A<N;A++){try{await L()}catch(D){_(D);break}if(H||K)break}})()})}var q8=Symbol("skip");var P1=k(N1(),1);import{createHash as _9}from"node:crypto";import{existsSync as q2,mkdirSync as U8,readFileSync as C9,writeFileSync as B8}from"node:fs";import{dirname as V8,join as U2}from"node:path";function L9($){return _9("sha256").update($,"utf-8").digest("hex")}async function T8($){let J=U2($,".agent","skills","_version.json");if(!q2(J))return null;try{let N=C9(J,"utf-8");return JSON.parse(N).version||null}catch{return null}}async function _8($,J){let N=U2($,".agent","skills","_version.json"),G=V8(N);if(!q2(G))U8(G,{recursive:!0});B8(N,JSON.stringify({version:J},null,2),"utf-8")}async function C8(){let $=`https://raw.githubusercontent.com/${R0}/main/prompt-manifest.json`,J=await fetch($);if(!J.ok)throw Error("Failed to fetch remote manifest");return await J.json()}async function L8($){let J=`https://raw.githubusercontent.com/${R0}/main/${$.path}`,N=await fetch(J);if(!N.ok)return{path:$.path,success:!1,error:`HTTP ${N.status}`};let G=await N.text();if(L9(G)!==$.sha256)return{path:$.path,success:!1,error:"SHA256 mismatch"};let z=U2(process.cwd(),$.path),X=V8(z);if(!q2(X))U8(X,{recursive:!0});return B8(z,G,"utf-8"),{path:$.path,success:!0}}async function A8(){console.clear(),a(P1.default.bgMagenta(P1.default.white(" \uD83D\uDEF8 oh-my-ag update ")));let $=process.cwd(),J=h1();try{J.start("Checking for updates...");let N=await C8(),G=await T8($);if(G===N.version){J.stop(P1.default.green("Already up to date!")),m(`Current version: ${P1.default.cyan(G)}`);return}J.message(`Updating from ${G||"not installed"} to ${P1.default.cyan(N.version)}...`);let Z=await H2(N.files,async(Q)=>L8(Q),{concurrency:10}),z=Z.filter((Q)=>!Q.success);if(z.length>0)J.stop("Update completed with errors"),O(z.map((Q)=>`${P1.default.red("✗")} ${Q.path}: ${Q.error}`).join(`
149
+ `),`${z.length} files failed`);else J.stop(`Updated to version ${P1.default.cyan(N.version)}!`);await _8($,N.version);let X=Z.length-z.length;m(z.length>0?`${X} files updated, ${z.length} failed`:`${X} files updated successfully`)}catch(N){J.stop("Update failed"),d.error(N instanceof Error?N.message:String(N)),process.exit(1)}}import{existsSync as bJ,mkdirSync as lJ,readdirSync as P0,readFileSync as kJ,statSync as i2}from"node:fs";import{createServer as mJ}from"node:http";import{basename as t3,join as x1}from"node:path";import{stat as e9}from"fs";import{stat as $7,readdir as J7}from"fs/promises";import{EventEmitter as N7}from"events";import*as S from"path";import{stat as A9,lstat as D8,readdir as D9,realpath as P9}from"node:fs/promises";import{Readable as W9}from"node:stream";import{resolve as P8,relative as S9,join as F9,sep as O9}from"node:path";var e={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},B2={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:e.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(B2);var O8="READDIRP_RECURSIVE_ERROR",g9=new Set(["ENOENT","EPERM","EACCES","ELOOP",O8]),W8=[e.DIR_TYPE,e.EVERYTHING_TYPE,e.FILE_DIR_TYPE,e.FILE_TYPE],f9=new Set([e.DIR_TYPE,e.EVERYTHING_TYPE,e.FILE_DIR_TYPE]),y9=new Set([e.EVERYTHING_TYPE,e.FILE_DIR_TYPE,e.FILE_TYPE]),E9=($)=>g9.has($.code),w9=process.platform==="win32",S8=($)=>!0,F8=($)=>{if($===void 0)return S8;if(typeof $==="function")return $;if(typeof $==="string"){let J=$.trim();return(N)=>N.basename===J}if(Array.isArray($)){let J=$.map((N)=>N.trim());return(N)=>J.some((G)=>N.basename===G)}return S8};class g8 extends W9{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let J={...B2,...$},{root:N,type:G}=J;this._fileFilter=F8(J.fileFilter),this._directoryFilter=F8(J.directoryFilter);let Z=J.lstat?D8:A9;if(w9)this._stat=(z)=>Z(z,{bigint:!0});else this._stat=Z;this._maxDepth=J.depth??B2.depth,this._wantsDir=G?f9.has(G):!1,this._wantsFile=G?y9.has(G):!1,this._wantsEverything=G===e.EVERYTHING_TYPE,this._root=P8(N),this._isDirent=!J.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(N,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let J=this.parent,N=J&&J.files;if(N&&N.length>0){let{path:G,depth:Z}=J,z=N.splice(0,$).map((Q)=>this._formatEntry(Q,G)),X=await Promise.all(z);for(let Q of X){if(!Q)continue;if(this.destroyed)return;let M=await this._getEntryType(Q);if(M==="directory"&&this._directoryFilter(Q)){if(Z<=this._maxDepth)this.parents.push(this._exploreDir(Q.fullPath,Z+1));if(this._wantsDir)this.push(Q),$--}else if((M==="file"||this._includeAsFile(Q))&&this._fileFilter(Q)){if(this._wantsFile)this.push(Q),$--}}}else{let G=this.parents.pop();if(!G){this.push(null);break}if(this.parent=await G,this.destroyed)return}}}catch(J){this.destroy(J)}finally{this.reading=!1}}async _exploreDir($,J){let N;try{N=await D9($,this._rdOptions)}catch(G){this._onError(G)}return{files:N,depth:J,path:$}}async _formatEntry($,J){let N,G=this._isDirent?$.name:$;try{let Z=P8(F9(J,G));N={path:S9(this._root,Z),fullPath:Z,basename:G},N[this._statsProp]=this._isDirent?$:await this._stat(Z)}catch(Z){this._onError(Z);return}return N}_onError($){if(E9($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let J=$[this._statsProp];if(J.isFile())return"file";if(J.isDirectory())return"directory";if(J&&J.isSymbolicLink()){let N=$.fullPath;try{let G=await P9(N),Z=await D8(G);if(Z.isFile())return"file";if(Z.isDirectory()){let z=G.length;if(N.startsWith(G)&&N.substr(z,1)===O9){let X=Error(`Circular symlink detected: "${N}" points to "${G}"`);return X.code=O8,this._onError(X)}return"directory"}}catch(G){return this._onError(G),""}}}_includeAsFile($){let J=$&&$[this._statsProp];return J&&this._wantsEverything&&!J.isDirectory()}}function f8($,J={}){let N=J.entryType||J.type;if(N==="both")N=e.FILE_DIR_TYPE;if(N)J.type=N;if(!$)throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");else if(typeof $!=="string")throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(N&&!W8.includes(N))throw Error(`readdirp: Invalid type passed. Use one of ${W8.join(", ")}`);return J.root=$,new g8(J)}import{watchFile as v9,unwatchFile as y8,watch as u9}from"fs";import{open as b9,stat as w8,lstat as l9,realpath as V2}from"fs/promises";import*as v from"path";import{type as k9}from"os";var m9="data",C2="end",v8="close",X$=()=>{};var Q$=process.platform,L2=Q$==="win32",h9=Q$==="darwin",c9=Q$==="linux",d9=Q$==="freebsd",u8=k9()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},K1=E,i9="watch",n9={lstat:l9,stat:w8},u1="listeners",G$="errHandlers",o1="rawEmitters",p9=[u1,G$,o1],s9=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"]),o9=($)=>s9.has(v.extname($).slice(1).toLowerCase()),_2=($,J)=>{if($ instanceof Set)$.forEach(J);else J($)},q0=($,J,N)=>{let G=$[J];if(!(G instanceof Set))$[J]=G=new Set([G]);G.add(N)},r9=($)=>(J)=>{let N=$[J];if(N instanceof Set)N.clear();else delete $[J]},U0=($,J,N)=>{let G=$[J];if(G instanceof Set)G.delete(N);else if(G===N)delete $[J]},b8=($)=>$ instanceof Set?$.size===0:!$,Z$=new Map;function E8($,J,N,G,Z){let z=(X,Q)=>{if(N($),Z(X,Q,{watchedPath:$}),Q&&$!==Q)z$(v.resolve($,Q),u1,v.join($,Q))};try{return u9($,{persistent:J.persistent},z)}catch(X){G(X);return}}var z$=($,J,N,G,Z)=>{let z=Z$.get($);if(!z)return;_2(z[J],(X)=>{X(N,G,Z)})},a9=($,J,N,G)=>{let{listener:Z,errHandler:z,rawEmitter:X}=G,Q=Z$.get(J),M;if(!N.persistent){if(M=E8($,N,Z,z,X),!M)return;return M.close.bind(M)}if(Q)q0(Q,u1,Z),q0(Q,G$,z),q0(Q,o1,X);else{if(M=E8($,N,z$.bind(null,J,u1),z,z$.bind(null,J,o1)),!M)return;M.on(K1.ERROR,async(I)=>{let K=z$.bind(null,J,G$);if(Q)Q.watcherUnusable=!0;if(L2&&I.code==="EPERM")try{await(await b9($,"r")).close(),K(I)}catch(Y){}else K(I)}),Q={listeners:Z,errHandlers:z,rawEmitters:X,watcher:M},Z$.set(J,Q)}return()=>{if(U0(Q,u1,Z),U0(Q,G$,z),U0(Q,o1,X),b8(Q.listeners))Q.watcher.close(),Z$.delete(J),p9.forEach(r9(Q)),Q.watcher=void 0,Object.freeze(Q)}},T2=new Map,t9=($,J,N,G)=>{let{listener:Z,rawEmitter:z}=G,X=T2.get(J),Q=X&&X.options;if(Q&&(Q.persistent<N.persistent||Q.interval>N.interval))y8(J),X=void 0;if(X)q0(X,u1,Z),q0(X,o1,z);else X={listeners:Z,rawEmitters:z,options:N,watcher:v9(J,N,(M,I)=>{_2(X.rawEmitters,(Y)=>{Y(K1.CHANGE,J,{curr:M,prev:I})});let K=M.mtimeMs;if(M.size!==I.size||K>I.mtimeMs||K===0)_2(X.listeners,(Y)=>Y($,M))})},T2.set(J,X);return()=>{if(U0(X,u1,Z),U0(X,o1,z),b8(X.listeners))T2.delete(J),y8(J),X.options=X.watcher=void 0,Object.freeze(X)}};class A2{constructor($){this.fsw=$,this._boundHandleError=(J)=>$._handleError(J)}_watchWithNodeFs($,J){let N=this.fsw.options,G=v.dirname($),Z=v.basename($);this.fsw._getWatchedDir(G).add(Z);let X=v.resolve($),Q={persistent:N.persistent};if(!J)J=X$;let M;if(N.usePolling){let I=N.interval!==N.binaryInterval;Q.interval=I&&o9(Z)?N.binaryInterval:N.interval,M=t9($,X,Q,{listener:J,rawEmitter:this.fsw._emitRaw})}else M=a9($,X,Q,{listener:J,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return M}_handleFile($,J,N){if(this.fsw.closed)return;let G=v.dirname($),Z=v.basename($),z=this.fsw._getWatchedDir(G),X=J;if(z.has(Z))return;let Q=async(I,K)=>{if(!this.fsw._throttle(i9,$,5))return;if(!K||K.mtimeMs===0)try{let Y=await w8($);if(this.fsw.closed)return;let{atimeMs:H,mtimeMs:R}=Y;if(!H||H<=R||R!==X.mtimeMs)this.fsw._emit(K1.CHANGE,$,Y);if((h9||c9||d9)&&X.ino!==Y.ino){this.fsw._closeFile(I),X=Y;let j=this._watchWithNodeFs($,Q);if(j)this.fsw._addPathCloser(I,j)}else X=Y}catch(Y){this.fsw._remove(G,Z)}else if(z.has(Z)){let{atimeMs:Y,mtimeMs:H}=K;if(!Y||Y<=H||H!==X.mtimeMs)this.fsw._emit(K1.CHANGE,$,K);X=K}},M=this._watchWithNodeFs($,Q);if(!(N&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(K1.ADD,$,0))return;this.fsw._emit(K1.ADD,$,J)}return M}async _handleSymlink($,J,N,G){if(this.fsw.closed)return;let Z=$.fullPath,z=this.fsw._getWatchedDir(J);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let X;try{X=await V2(N)}catch(Q){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(z.has(G)){if(this.fsw._symlinkPaths.get(Z)!==X)this.fsw._symlinkPaths.set(Z,X),this.fsw._emit(K1.CHANGE,N,$.stats)}else z.add(G),this.fsw._symlinkPaths.set(Z,X),this.fsw._emit(K1.ADD,N,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(Z))return!0;this.fsw._symlinkPaths.set(Z,!0)}_handleRead($,J,N,G,Z,z,X){if($=v.join($,""),X=this.fsw._throttle("readdir",$,1000),!X)return;let Q=this.fsw._getWatchedDir(N.path),M=new Set,I=this.fsw._readdirp($,{fileFilter:(K)=>N.filterPath(K),directoryFilter:(K)=>N.filterDir(K)});if(!I)return;return I.on(m9,async(K)=>{if(this.fsw.closed){I=void 0;return}let Y=K.path,H=v.join($,Y);if(M.add(Y),K.stats.isSymbolicLink()&&await this._handleSymlink(K,$,H,Y))return;if(this.fsw.closed){I=void 0;return}if(Y===G||!G&&!Q.has(Y))this.fsw._incrReadyCount(),H=v.join(Z,v.relative(Z,H)),this._addToNodeFs(H,J,N,z+1)}).on(K1.ERROR,this._boundHandleError),new Promise((K,Y)=>{if(!I)return Y();I.once(C2,()=>{if(this.fsw.closed){I=void 0;return}let H=X?X.clear():!1;if(K(void 0),Q.getChildren().filter((R)=>{return R!==$&&!M.has(R)}).forEach((R)=>{this.fsw._remove($,R)}),I=void 0,H)this._handleRead($,!1,N,G,Z,z,X)})})}async _handleDir($,J,N,G,Z,z,X){let Q=this.fsw._getWatchedDir(v.dirname($)),M=Q.has(v.basename($));if(!(N&&this.fsw.options.ignoreInitial)&&!Z&&!M)this.fsw._emit(K1.ADD_DIR,$,J);Q.add(v.basename($)),this.fsw._getWatchedDir($);let I,K,Y=this.fsw.options.depth;if((Y==null||G<=Y)&&!this.fsw._symlinkPaths.has(X)){if(!Z){if(await this._handleRead($,N,z,Z,$,G,I),this.fsw.closed)return}K=this._watchWithNodeFs($,(H,R)=>{if(R&&R.mtimeMs===0)return;this._handleRead(H,!1,z,Z,$,G,I)})}return K}async _addToNodeFs($,J,N,G,Z){let z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return z(),!1;let X=this.fsw._getWatchHelpers($);if(N)X.filterPath=(Q)=>N.filterPath(Q),X.filterDir=(Q)=>N.filterDir(Q);try{let Q=await n9[X.statMethod](X.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(X.watchPath,Q))return z(),!1;let M=this.fsw.options.followSymlinks,I;if(Q.isDirectory()){let K=v.resolve($),Y=M?await V2($):$;if(this.fsw.closed)return;if(I=await this._handleDir(X.watchPath,Q,J,G,Z,X,Y),this.fsw.closed)return;if(K!==Y&&Y!==void 0)this.fsw._symlinkPaths.set(K,Y)}else if(Q.isSymbolicLink()){let K=M?await V2($):$;if(this.fsw.closed)return;let Y=v.dirname(X.watchPath);if(this.fsw._getWatchedDir(Y).add(X.watchPath),this.fsw._emit(K1.ADD,X.watchPath,Q),I=await this._handleDir(Y,Q,J,G,$,X,K),this.fsw.closed)return;if(K!==void 0)this.fsw._symlinkPaths.set(v.resolve($),K)}else I=this._handleFile(X.watchPath,Q,J);if(z(),I)this.fsw._addPathCloser($,I);return!1}catch(Q){if(this.fsw._handleError(Q))return z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var D2="/",G7="//",d8=".",Z7="..",z7="string",X7=/\\/g,l8=/\/\//,Q7=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,M7=/^\.[/\\]/;function M$($){return Array.isArray($)?$:[$]}var P2=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function I7($){if(typeof $==="function")return $;if(typeof $==="string")return(J)=>$===J;if($ instanceof RegExp)return(J)=>$.test(J);if(typeof $==="object"&&$!==null)return(J)=>{if($.path===J)return!0;if($.recursive){let N=S.relative($.path,J);if(!N)return!1;return!N.startsWith("..")&&!S.isAbsolute(N)}return!1};return()=>!1}function Y7($){if(typeof $!=="string")throw Error("string expected");$=S.normalize($),$=$.replace(/\\/g,"/");let J=!1;if($.startsWith("//"))J=!0;let N=/\/\//;while($.match(N))$=$.replace(N,"/");if(J)$="/"+$;return $}function k8($,J,N){let G=Y7(J);for(let Z=0;Z<$.length;Z++){let z=$[Z];if(z(G,N))return!0}return!1}function K7($,J){if($==null)throw TypeError("anymatch: specify first argument");let G=M$($).map((Z)=>I7(Z));if(J==null)return(Z,z)=>{return k8(G,Z,z)};return k8(G,J)}var m8=($)=>{let J=M$($).flat();if(!J.every((N)=>typeof N===z7))throw TypeError(`Non-string provided as watch path: ${J}`);return J.map(i8)},h8=($)=>{let J=$.replace(X7,D2),N=!1;if(J.startsWith(G7))N=!0;while(J.match(l8))J=J.replace(l8,D2);if(N)J=D2+J;return J},i8=($)=>h8(S.normalize(h8($))),c8=($="")=>(J)=>{if(typeof J==="string")return i8(S.isAbsolute(J)?J:S.join($,J));else return J},j7=($,J)=>{if(S.isAbsolute($))return $;return S.join(J,$)},x7=Object.freeze(new Set);class n8{constructor($,J){this.path=$,this._removeWatcher=J,this.items=new Set}add($){let{items:J}=this;if(!J)return;if($!==d8&&$!==Z7)J.add($)}async remove($){let{items:J}=this;if(!J)return;if(J.delete($),J.size>0)return;let N=this.path;try{await J7(N)}catch(G){if(this._removeWatcher)this._removeWatcher(S.dirname(N),S.basename(N))}}has($){let{items:J}=this;if(!J)return;return J.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=X$,this.items=x7,Object.freeze(this)}}var R7="stat",H7="lstat";class p8{constructor($,J,N){this.fsw=N;let G=$;this.path=$=$.replace(M7,""),this.watchPath=G,this.fullWatchPath=S.resolve(G),this.dirParts=[],this.dirParts.forEach((Z)=>{if(Z.length>1)Z.pop()}),this.followSymlinks=J,this.statMethod=J?R7:H7}entryPath($){return S.join(this.watchPath,S.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:J}=$;if(J&&J.isSymbolicLink())return this.filterDir($);let N=this.entryPath($);return this.fsw._isntIgnored(N,J)&&this.fsw._hasReadPermissions(J)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class s8 extends N7{constructor($={}){super();this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let J=$.awaitWriteFinish,N={stabilityThreshold:2000,pollInterval:100},G={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?M$($.ignored):M$([]),awaitWriteFinish:J===!0?N:typeof J==="object"?{...N,...J}:!1};if(u8)G.usePolling=!0;if(G.atomic===void 0)G.atomic=!G.usePolling;let Z=process.env.CHOKIDAR_USEPOLLING;if(Z!==void 0){let Q=Z.toLowerCase();if(Q==="false"||Q==="0")G.usePolling=!1;else if(Q==="true"||Q==="1")G.usePolling=!0;else G.usePolling=!!Q}let z=process.env.CHOKIDAR_INTERVAL;if(z)G.interval=Number.parseInt(z,10);let X=0;this._emitReady=()=>{if(X++,X>=this._readyCount)this._emitReady=X$,this._readyEmitted=!0,process.nextTick(()=>this.emit(E.READY))},this._emitRaw=(...Q)=>this.emit(E.RAW,...Q),this._boundRemove=this._remove.bind(this),this.options=G,this._nodeFsHandler=new A2(this),Object.freeze(G)}_addIgnoredPath($){if(P2($)){for(let J of this._ignoredPaths)if(P2(J)&&J.path===$.path&&J.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let J of this._ignoredPaths)if(P2(J)&&J.path===$)this._ignoredPaths.delete(J)}}add($,J,N){let{cwd:G}=this.options;this.closed=!1,this._closePromise=void 0;let Z=m8($);if(G)Z=Z.map((z)=>{return j7(z,G)});if(Z.forEach((z)=>{this._removeIgnoredPath(z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=Z.length,Promise.all(Z.map(async(z)=>{let X=await this._nodeFsHandler._addToNodeFs(z,!N,void 0,0,J);if(X)this._emitReady();return X})).then((z)=>{if(this.closed)return;z.forEach((X)=>{if(X)this.add(S.dirname(X),S.basename(J||X))})}),this}unwatch($){if(this.closed)return this;let J=m8($),{cwd:N}=this.options;return J.forEach((G)=>{if(!S.isAbsolute(G)&&!this._closers.has(G)){if(N)G=S.join(N,G);G=S.resolve(G)}if(this._closePath(G),this._addIgnoredPath(G),this._watched.has(G))this._addIgnoredPath({path:G,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((J)=>J.forEach((N)=>{let G=N();if(G instanceof Promise)$.push(G)})),this._streams.forEach((J)=>J.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((J)=>J.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=$.length?Promise.all($).then(()=>{return}):Promise.resolve(),this._closePromise}getWatched(){let $={};return this._watched.forEach((J,N)=>{let Z=(this.options.cwd?S.relative(this.options.cwd,N):N)||d8;$[Z]=J.getChildren().sort()}),$}emitWithAll($,J){if(this.emit($,...J),$!==E.ERROR)this.emit(E.ALL,$,...J)}async _emit($,J,N){if(this.closed)return;let G=this.options;if(L2)J=S.normalize(J);if(G.cwd)J=S.relative(G.cwd,J);let Z=[J];if(N!=null)Z.push(N);let z=G.awaitWriteFinish,X;if(z&&(X=this._pendingWrites.get(J)))return X.lastChange=new Date,this;if(G.atomic){if($===E.UNLINK)return this._pendingUnlinks.set(J,[$,...Z]),setTimeout(()=>{this._pendingUnlinks.forEach((Q,M)=>{this.emit(...Q),this.emit(E.ALL,...Q),this._pendingUnlinks.delete(M)})},typeof G.atomic==="number"?G.atomic:100),this;if($===E.ADD&&this._pendingUnlinks.has(J))$=E.CHANGE,this._pendingUnlinks.delete(J)}if(z&&($===E.ADD||$===E.CHANGE)&&this._readyEmitted){let Q=(M,I)=>{if(M)$=E.ERROR,Z[0]=M,this.emitWithAll($,Z);else if(I){if(Z.length>1)Z[1]=I;else Z.push(I);this.emitWithAll($,Z)}};return this._awaitWriteFinish(J,z.stabilityThreshold,$,Q),this}if($===E.CHANGE){if(!this._throttle(E.CHANGE,J,50))return this}if(G.alwaysStat&&N===void 0&&($===E.ADD||$===E.ADD_DIR||$===E.CHANGE)){let Q=G.cwd?S.join(G.cwd,J):J,M;try{M=await $7(Q)}catch(I){}if(!M||this.closed)return;Z.push(M)}return this.emitWithAll($,Z),this}_handleError($){let J=$&&$.code;if($&&J!=="ENOENT"&&J!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||J!=="EPERM"&&J!=="EACCES"))this.emit(E.ERROR,$);return $||this.closed}_throttle($,J,N){if(!this._throttled.has($))this._throttled.set($,new Map);let G=this._throttled.get($);if(!G)throw Error("invalid throttle");let Z=G.get(J);if(Z)return Z.count++,!1;let z,X=()=>{let M=G.get(J),I=M?M.count:0;if(G.delete(J),clearTimeout(z),M)clearTimeout(M.timeoutObject);return I};z=setTimeout(X,N);let Q={timeoutObject:z,clear:X,count:0};return G.set(J,Q),Q}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,J,N,G){let Z=this.options.awaitWriteFinish;if(typeof Z!=="object")return;let z=Z.pollInterval,X,Q=$;if(this.options.cwd&&!S.isAbsolute($))Q=S.join(this.options.cwd,$);let M=new Date,I=this._pendingWrites;function K(Y){e9(Q,(H,R)=>{if(H||!I.has($)){if(H&&H.code!=="ENOENT")G(H);return}let j=Number(new Date);if(Y&&R.size!==Y.size)I.get($).lastChange=j;let x=I.get($);if(j-x.lastChange>=J)I.delete($),G(void 0,R);else X=setTimeout(K,z,R)})}if(!I.has($))I.set($,{lastChange:M,cancelWait:()=>{return I.delete($),clearTimeout(X),N}}),X=setTimeout(K,z)}_isIgnored($,J){if(this.options.atomic&&Q7.test($))return!0;if(!this._userIgnored){let{cwd:N}=this.options,Z=(this.options.ignored||[]).map(c8(N)),X=[...[...this._ignoredPaths].map(c8(N)),...Z];this._userIgnored=K7(X,void 0)}return this._userIgnored($,J)}_isntIgnored($,J){return!this._isIgnored($,J)}_getWatchHelpers($){return new p8($,this.options.followSymlinks,this)}_getWatchedDir($){let J=S.resolve($);if(!this._watched.has(J))this._watched.set(J,new n8(J,this._boundRemove));return this._watched.get(J)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,J,N){let G=S.join($,J),Z=S.resolve(G);if(N=N!=null?N:this._watched.has(G)||this._watched.has(Z),!this._throttle("remove",G,100))return;if(!N&&this._watched.size===1)this.add($,J,!0);this._getWatchedDir(G).getChildren().forEach((Y)=>this._remove(G,Y));let Q=this._getWatchedDir($),M=Q.has(J);if(Q.remove(J),this._symlinkPaths.has(Z))this._symlinkPaths.delete(Z);let I=G;if(this.options.cwd)I=S.relative(this.options.cwd,G);if(this.options.awaitWriteFinish&&this._pendingWrites.has(I)){if(this._pendingWrites.get(I).cancelWait()===E.ADD)return}this._watched.delete(G),this._watched.delete(Z);let K=N?E.UNLINK_DIR:E.UNLINK;if(M&&!this._isIgnored(G))this._emit(K,G);this._closePath(G)}_closePath($){this._closeFile($);let J=S.dirname($);this._getWatchedDir(J).remove(S.basename($))}_closeFile($){let J=this._closers.get($);if(!J)return;J.forEach((N)=>N()),this._closers.delete($)}_addPathCloser($,J){if(!J)return;let N=this._closers.get($);if(!N)N=[],this._closers.set($,N);N.push(J)}_readdirp($,J){if(this.closed)return;let N={type:E.ALL,alwaysStat:!0,lstat:!0,...J,depth:0},G=f8($,N);return this._streams.add(G),G.once(v8,()=>{G=void 0}),G.once(C2,()=>{if(G)this._streams.delete(G),G=void 0}),G}}function I$($,J={}){let N=new s8(J);return N.add($),N}var G0=k(N1(),1);var wJ=k(c3(),1),vJ=k(f2(),1),uJ=k(E2(),1),m2=k(T$(),1),h2=k(r3(),1);var a3=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT||"9847",10):9847;function hJ(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return x1($,".serena","memories");return x1(process.cwd(),".serena","memories")}function W0($){try{return kJ($,"utf-8")}catch{return""}}function cJ($){try{let J=P0($);if(J.includes("orchestrator-session.md"))return x1($,"orchestrator-session.md");let N=J.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:i2(x1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime);if(N.length>0&&N[0])return x1($,N[0].name)}catch{}return null}function dJ($){let J=cJ($);if(!J)return{id:"N/A",status:"UNKNOWN"};let N=W0(J);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||t3(J,".md")||"N/A",Z="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))Z="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))Z="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))Z="FAILED";else if(/Step \d+:.*\[/i.test(N))Z="RUNNING";return{id:G.trim(),status:Z}}function iJ($){let J=W0(x1($,"task-board.md"));if(!J)return[];let N=[],G=J.split(`
150
+ `);for(let Z of G){if(!Z.startsWith("|")||/^\|\s*-+/.test(Z))continue;let z=Z.split("|").map((Q)=>Q.trim()).filter(Boolean),X=z[0];if(z.length<2||!X||/^agent$/i.test(X))continue;N.push({agent:z[0]||"",status:z[1]||"pending",task:z[2]||""})}return N}function d2($,J){try{let N=P0($).filter((z)=>z.startsWith(`progress-${J}`)&&z.endsWith(".md")).sort().reverse();if(N.length===0)return null;let Z=(N[0]?W0(x1($,N[0])):"").match(/turn[:\s]*(\d+)/i);return Z?.[1]?parseInt(Z[1],10):null}catch{return null}}function nJ($){try{return P0($).filter((N)=>N.endsWith(".md")&&N!==".gitkeep").map((N)=>({name:N,mtime:i2(x1($,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=W0(x1($,N.name)).split(`
151
+ `).map((Q)=>Q.trim()).filter((Q)=>Q&&!Q.startsWith("---")&&Q.length>3),X="";for(let Q=z.length-1;Q>=0;Q--){let M=z[Q];if(M){if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(M)){if(X=M.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),X.length>5)break}}}if(X.length>80)X=`${X.substring(0,77)}...`;return{agent:G,message:X,file:N.name}}).filter((N)=>N.message)}catch{return[]}}function pJ($){let J=[],N=new Set;try{let G=P0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:i2(x1($,Z)).mtimeMs})).sort((Z,z)=>z.mtime-Z.mtime);for(let Z of G){let z=W0(x1($,Z.name)),X=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(X?.[1])Q=X[1].trim();else if(/_agent|agent_|-agent/i.test(Z.name))Q=Z.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!N.has(Q.toLowerCase())){N.add(Q.toLowerCase());let M="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))M="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))M="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))M="failed";let I=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),K=I?.[1]?I[1].trim().substring(0,60):"";J.push({agent:Q,status:M,task:K,turn:d2($,Q)})}}}catch{}return J}function c2($){let J=dJ($),G=iJ($).map((Z)=>({...Z,turn:d2($,Z.agent)}));if(G.length===0)G=pJ($);if(G.length===0)try{let Z=P0($).filter((z)=>z.startsWith("progress-")&&z.endsWith(".md"));for(let z of Z){let X=z.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:X,status:"running",task:"",turn:d2($,X)})}}catch{}return{session:J,agents:G,activity:nJ($),memoriesDir:$,updatedAt:new Date().toISOString()}}var sJ=`<!DOCTYPE html>
150
152
  <html lang="en">
151
153
  <head>
152
154
  <meta charset="UTF-8">
@@ -203,12 +205,12 @@ ${M1.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Su
203
205
  fetch('/api/state').then(r=>r.json()).then(renderState).catch(()=>{});connect();
204
206
  </script>
205
207
  </body>
206
- </html>`;function a3(){let $=kJ();if(!vJ($))uJ($,{recursive:!0});let J=lJ((X,Q)=>{if(X.url==="/api/state")Q.writeHead(200,{"Content-Type":"application/json"}),Q.end(JSON.stringify(c2($)));else Q.writeHead(200,{"Content-Type":"text/html"}),Q.end(nJ)}),N=new h2.default({server:J}),G=null;function Z(X,Q){if(G)clearTimeout(G);G=setTimeout(()=>{let M=JSON.stringify({type:"update",event:X,file:Q,data:c2($)});N.clients.forEach((I)=>{if(I.readyState===m2.default.OPEN)I.send(M)})},100)}let z=M$($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});z.on("all",(X,Q)=>Z(X,r3(Q))),N.on("connection",(X)=>{X.send(JSON.stringify({type:"full",data:c2($)})),X.on("error",()=>X.terminate())}),process.on("SIGINT",()=>{console.log(`
207
- Shutting down...`),z.close(),N.clients.forEach((X)=>{X.terminate()}),N.close(()=>J.close(()=>process.exit(0))),setTimeout(()=>process.exit(1),3000).unref()}),process.on("SIGTERM",()=>process.emit("SIGINT")),J.listen(o3,()=>{console.log(J0.magenta(`
208
- \uD83D\uDEF8 Serena Memory Dashboard`)),console.log(J0.white(` http://localhost:${o3}`)),console.log(J0.dim(` Watching: ${$}
209
- `))})}import{existsSync as pJ,mkdirSync as sJ,readdirSync as D0,readFileSync as oJ,statSync as p2}from"node:fs";import{basename as rJ,join as x1}from"node:path";var n=k(N1(),1),aJ="●",tJ="✓",eJ="✗",$N="○",JN="◌";function NN(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return x1($,".serena","memories");return x1(process.cwd(),".serena","memories")}function P0($){try{return oJ($,"utf-8")}catch{return""}}function GN($){try{let J=D0($);if(J.includes("orchestrator-session.md"))return x1($,"orchestrator-session.md");let N=J.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:p2(x1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime);if(N.length>0&&N[0])return x1($,N[0].name)}catch{}return null}function ZN($){let J=GN($);if(!J)return{id:"N/A",status:"UNKNOWN"};let N=P0(J);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||rJ(J,".md"),Z="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))Z="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))Z="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))Z="FAILED";else if(/Step \d+:.*\[/i.test(N))Z="RUNNING";return{id:(G||"N/A").trim(),status:Z}}function zN($){let J=P0(x1($,"task-board.md"));if(!J)return[];let N=[],G=J.split(`
210
- `);for(let Z of G){if(!Z.startsWith("|")||/^\|\s*-+/.test(Z))continue;let z=Z.split("|").map((I)=>I.trim()).filter(Boolean),X=z[0];if(z.length<2||!X||/^agent$/i.test(X))continue;let Q=z[1],M=z[2];N.push({agent:X,status:Q||"pending",task:M||""})}return N}function n2($,J){try{let N=D0($).filter((z)=>z.startsWith(`progress-${J}`)&&z.endsWith(".md")).sort().reverse();if(N.length===0||!N[0])return null;let Z=P0(x1($,N[0])).match(/turn[:\s]*(\d+)/i);return Z?.[1]?parseInt(Z[1],10):null}catch{return null}}function XN($){try{let J=D0($).filter((G)=>G.endsWith(".md")&&G!==".gitkeep").map((G)=>({name:G,mtime:p2(x1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime).slice(0,5),N=[];for(let G of J){let Z=G.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||G.name.replace(/\.md$/,""),X=P0(x1($,G.name)).split(`
211
- `).map((M)=>M.trim()).filter((M)=>M&&!M.startsWith("---")&&M.length>3),Q="";for(let M=X.length-1;M>=0;M--){let I=X[M];if(!I)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(I)){if(Q=I.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),Q.length>5)break}}if(Q.length>52)Q=`${Q.substring(0,49)}...`;if(Q)N.push({agent:Z,message:Q})}return N}catch{return[]}}function QN($){let J=[],N=new Set;try{let G=D0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:p2(x1($,Z)).mtimeMs})).sort((Z,z)=>z.mtime-Z.mtime);for(let Z of G){let z=P0(x1($,Z.name)),X=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(X?.[1])Q=X[1].trim();else if(/_agent|agent_|-agent/i.test(Z.name))Q=Z.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!N.has(Q.toLowerCase())){N.add(Q.toLowerCase());let M="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))M="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))M="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))M="failed";let I=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),K=I?.[1]?I[1].trim().substring(0,20):"";J.push({agent:Q,status:M,task:K,turn:n2($,Q)})}}}catch{}return J}function MN($){let J=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(J))return`${n.default.green(aJ)} running`;else if(["completed","done","finished"].includes(J))return`${n.default.cyan(tJ)} completed`;else if(["failed","error"].includes(J))return`${n.default.red(eJ)} failed`;else if(["blocked","waiting"].includes(J))return`${n.default.yellow($N)} blocked`;return`${n.default.dim(JN)} pending`}function t3($){console.clear();let J=ZN($),G=zN($).map((j)=>({...j,turn:n2($,j.agent)}));if(G.length===0)G=QN($);if(G.length===0)try{let j=D0($).filter((U)=>U.startsWith("progress-")&&U.endsWith(".md"));for(let U of j){let T=U.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:T,status:"running",task:"",turn:n2($,T)})}}catch{}let Z=56,z="═".repeat(Z),X=(j)=>" ".repeat(Math.max(0,j)),Q=(j)=>n.default.magenta(j),M=(j)=>n.default.bold(j),I=(j)=>n.default.dim(j),K=n.default.yellow;if(J.status==="RUNNING")K=n.default.green;else if(J.status==="COMPLETED")K=n.default.cyan;else if(J.status==="FAILED")K=n.default.red;console.log(`${Q(`╔${z}╗`)}`),console.log(`${Q("║")} ${M(Q("Serena Memory Dashboard"))}${X(Z-25)}${Q("║")}`);let Y=`Session: ${M(J.id.padEnd(20))} [${K(J.status)}]`;if(console.log(`${Q("║")} ${Y}${X(Z-4-Y.length-9)}${Q("║")}`),console.log(`${Q(`╠${z}╣`)}`),console.log(`${Q("║")} ${M(`${"Agent".padEnd(12)} ${"Status".padEnd(12)} ${"Turn".padEnd(6)} ${"Task".padEnd(20)}`)} ${Q("║")}`),console.log(`${Q("║")} ${I(`${"──────────".padEnd(12)} ${"──────────".padEnd(12)} ${"────".padEnd(6)} ${"──────────────────".padEnd(20)}`)} ${Q("║")}`),G.length===0)console.log(`${Q("║")} ${I(`No agents detected yet${X(32)}`)}${Q("║")}`);else for(let j of G){let U=MN(j.status),T=j.turn!=null?String(j.turn):"-",B=j.task.substring(0,20);console.log(`${Q("║")} ${j.agent.padEnd(12)} ${U.padEnd(22)} ${T.padEnd(6)} ${B.padEnd(20)}${Q("║")}`)}console.log(`${Q(`╠${z}╣`)}`),console.log(`${Q("║")} ${M("Latest Activity:")}${X(Z-18)}${Q("║")}`);let H=XN($);if(H.length===0)console.log(`${Q("║")} ${I(`No activity yet${X(38)}`)}${Q("║")}`);else for(let j of H){let U=`[${j.agent}] ${j.message}`;console.log(`${Q("║")} ${I(U.substring(0,52).padEnd(52))}${Q("║")}`)}console.log(`${Q(`╠${z}╣`)}`);let x=`Updated: ${new Date().toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})} | Ctrl+C to exit`;console.log(`${Q("║")} ${I(x)}${X(Z-4-x.length)}${Q("║")}`),console.log(`${Q(`╚${z}╝`)}`)}function e3(){let $=NN();if(!pJ($))sJ($,{recursive:!0}),console.log(n.default.yellow(`Created ${$} — waiting for memory files...`));console.log(n.default.magenta(`
208
+ </html>`;function e3(){let $=hJ();if(!bJ($))lJ($,{recursive:!0});let J=mJ((X,Q)=>{if(X.url==="/api/state")Q.writeHead(200,{"Content-Type":"application/json"}),Q.end(JSON.stringify(c2($)));else Q.writeHead(200,{"Content-Type":"text/html"}),Q.end(sJ)}),N=new h2.default({server:J}),G=null;function Z(X,Q){if(G)clearTimeout(G);G=setTimeout(()=>{let M=JSON.stringify({type:"update",event:X,file:Q,data:c2($)});N.clients.forEach((I)=>{if(I.readyState===m2.default.OPEN)I.send(M)})},100)}let z=I$($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});z.on("all",(X,Q)=>Z(X,t3(Q))),N.on("connection",(X)=>{X.send(JSON.stringify({type:"full",data:c2($)})),X.on("error",()=>X.terminate())}),process.on("SIGINT",()=>{console.log(`
209
+ Shutting down...`),z.close(),N.clients.forEach((X)=>{X.terminate()}),N.close(()=>J.close(()=>process.exit(0))),setTimeout(()=>process.exit(1),3000).unref()}),process.on("SIGTERM",()=>process.emit("SIGINT")),J.listen(a3,()=>{console.log(G0.magenta(`
210
+ \uD83D\uDEF8 Serena Memory Dashboard`)),console.log(G0.white(` http://localhost:${a3}`)),console.log(G0.dim(` Watching: ${$}
211
+ `))})}import{existsSync as oJ,mkdirSync as rJ,readdirSync as S0,readFileSync as aJ,statSync as p2}from"node:fs";import{basename as tJ,join as R1}from"node:path";var n=k(N1(),1),eJ="●",$N="✓",JN="✗",NN="○",GN="◌";function ZN(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return R1($,".serena","memories");return R1(process.cwd(),".serena","memories")}function F0($){try{return aJ($,"utf-8")}catch{return""}}function zN($){try{let J=S0($);if(J.includes("orchestrator-session.md"))return R1($,"orchestrator-session.md");let N=J.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:p2(R1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime);if(N.length>0&&N[0])return R1($,N[0].name)}catch{}return null}function XN($){let J=zN($);if(!J)return{id:"N/A",status:"UNKNOWN"};let N=F0(J);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||tJ(J,".md"),Z="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))Z="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))Z="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))Z="FAILED";else if(/Step \d+:.*\[/i.test(N))Z="RUNNING";return{id:(G||"N/A").trim(),status:Z}}function QN($){let J=F0(R1($,"task-board.md"));if(!J)return[];let N=[],G=J.split(`
212
+ `);for(let Z of G){if(!Z.startsWith("|")||/^\|\s*-+/.test(Z))continue;let z=Z.split("|").map((I)=>I.trim()).filter(Boolean),X=z[0];if(z.length<2||!X||/^agent$/i.test(X))continue;let Q=z[1],M=z[2];N.push({agent:X,status:Q||"pending",task:M||""})}return N}function n2($,J){try{let N=S0($).filter((z)=>z.startsWith(`progress-${J}`)&&z.endsWith(".md")).sort().reverse();if(N.length===0||!N[0])return null;let Z=F0(R1($,N[0])).match(/turn[:\s]*(\d+)/i);return Z?.[1]?parseInt(Z[1],10):null}catch{return null}}function MN($){try{let J=S0($).filter((G)=>G.endsWith(".md")&&G!==".gitkeep").map((G)=>({name:G,mtime:p2(R1($,G)).mtimeMs})).sort((G,Z)=>Z.mtime-G.mtime).slice(0,5),N=[];for(let G of J){let Z=G.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||G.name.replace(/\.md$/,""),X=F0(R1($,G.name)).split(`
213
+ `).map((M)=>M.trim()).filter((M)=>M&&!M.startsWith("---")&&M.length>3),Q="";for(let M=X.length-1;M>=0;M--){let I=X[M];if(!I)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(I)){if(Q=I.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),Q.length>5)break}}if(Q.length>52)Q=`${Q.substring(0,49)}...`;if(Q)N.push({agent:Z,message:Q})}return N}catch{return[]}}function IN($){let J=[],N=new Set;try{let G=S0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:p2(R1($,Z)).mtimeMs})).sort((Z,z)=>z.mtime-Z.mtime);for(let Z of G){let z=F0(R1($,Z.name)),X=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(X?.[1])Q=X[1].trim();else if(/_agent|agent_|-agent/i.test(Z.name))Q=Z.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!N.has(Q.toLowerCase())){N.add(Q.toLowerCase());let M="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))M="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))M="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))M="failed";let I=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),K=I?.[1]?I[1].trim().substring(0,20):"";J.push({agent:Q,status:M,task:K,turn:n2($,Q)})}}}catch{}return J}function YN($){let J=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(J))return`${n.default.green(eJ)} running`;else if(["completed","done","finished"].includes(J))return`${n.default.cyan($N)} completed`;else if(["failed","error"].includes(J))return`${n.default.red(JN)} failed`;else if(["blocked","waiting"].includes(J))return`${n.default.yellow(NN)} blocked`;return`${n.default.dim(GN)} pending`}function $5($){console.clear();let J=XN($),G=QN($).map((x)=>({...x,turn:n2($,x.agent)}));if(G.length===0)G=IN($);if(G.length===0)try{let x=S0($).filter((U)=>U.startsWith("progress-")&&U.endsWith(".md"));for(let U of x){let B=U.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:B,status:"running",task:"",turn:n2($,B)})}}catch{}let Z=56,z="═".repeat(Z),X=(x)=>" ".repeat(Math.max(0,x)),Q=(x)=>n.default.magenta(x),M=(x)=>n.default.bold(x),I=(x)=>n.default.dim(x),K=n.default.yellow;if(J.status==="RUNNING")K=n.default.green;else if(J.status==="COMPLETED")K=n.default.cyan;else if(J.status==="FAILED")K=n.default.red;console.log(`${Q(`╔${z}╗`)}`),console.log(`${Q("║")} ${M(Q("Serena Memory Dashboard"))}${X(Z-25)}${Q("║")}`);let Y=`Session: ${M(J.id.padEnd(20))} [${K(J.status)}]`;if(console.log(`${Q("║")} ${Y}${X(Z-4-Y.length-9)}${Q("║")}`),console.log(`${Q(`╠${z}╣`)}`),console.log(`${Q("║")} ${M(`${"Agent".padEnd(12)} ${"Status".padEnd(12)} ${"Turn".padEnd(6)} ${"Task".padEnd(20)}`)} ${Q("║")}`),console.log(`${Q("║")} ${I(`${"──────────".padEnd(12)} ${"──────────".padEnd(12)} ${"────".padEnd(6)} ${"──────────────────".padEnd(20)}`)} ${Q("║")}`),G.length===0)console.log(`${Q("║")} ${I(`No agents detected yet${X(32)}`)}${Q("║")}`);else for(let x of G){let U=YN(x.status),B=x.turn!=null?String(x.turn):"-",V=x.task.substring(0,20);console.log(`${Q("║")} ${x.agent.padEnd(12)} ${U.padEnd(22)} ${B.padEnd(6)} ${V.padEnd(20)}${Q("║")}`)}console.log(`${Q(`╠${z}╣`)}`),console.log(`${Q("║")} ${M("Latest Activity:")}${X(Z-18)}${Q("║")}`);let H=MN($);if(H.length===0)console.log(`${Q("║")} ${I(`No activity yet${X(38)}`)}${Q("║")}`);else for(let x of H){let U=`[${x.agent}] ${x.message}`;console.log(`${Q("║")} ${I(U.substring(0,52).padEnd(52))}${Q("║")}`)}console.log(`${Q(`╠${z}╣`)}`);let j=`Updated: ${new Date().toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})} | Ctrl+C to exit`;console.log(`${Q("║")} ${I(j)}${X(Z-4-j.length)}${Q("║")}`),console.log(`${Q(`╚${z}╝`)}`)}function J5(){let $=ZN();if(!oJ($))rJ($,{recursive:!0}),console.log(n.default.yellow(`Created ${$} — waiting for memory files...`));console.log(n.default.magenta(`
212
214
  \uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(n.default.dim(` Watching: ${$}
213
- `)),t3($);let J=M$($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});J.on("all",()=>t3($)),process.on("SIGINT",()=>{console.log(`
214
- `),J.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var IN="1.1.1",X1=new Y4;X1.name("oh-my-ag").description("Multi-Agent Skills for Antigravity IDE").version(IN).action(()=>{a4().catch(console.error)});X1.command("dashboard").description("Start terminal dashboard (real-time agent monitoring)").action(()=>{e3()});X1.command("dashboard:web").description("Start web dashboard on http://localhost:9847").action(()=>{a3()});X1.command("update").description("Update skills to latest version from registry").action(()=>{C8().catch(console.error)});X1.command("doctor").description("Check CLI installations, MCP configs, and skill status").option("--json","Output as JSON for CI/CD").action(($)=>{p4($.json).catch(console.error)});X1.command("stats").description("View productivity metrics").option("--json","Output as JSON").option("--reset","Reset metrics data").action(($)=>{x8($.json,$.reset).catch(console.error)});X1.command("retro").description("Session retrospective (learnings & next steps)").option("--json","Output as JSON").option("--interactive","Interactive mode (manual entry)").action(($)=>{Y8($.json,$.interactive).catch(console.error)});X1.command("cleanup").description("Clean up orphaned subagent processes and temp files").option("--dry-run","Show what would be cleaned without making changes").option("--json","Output as JSON").action(($)=>{c4($.dryRun,$.json).catch(console.error)});X1.command("bridge [url]").description("Bridge MCP stdio to SSE (for Serena)").action(($)=>{q4($).catch(console.error)});X1.command("agent:spawn <agent-id> <prompt-file> <session-id> <workspace>").description("Spawn a subagent (wraps gemini with logging and PID tracking)").action(($,J,N,G)=>{H4($,J,N,G).catch(console.error)});X1.command("agent:status <session-id> [agent-ids...]").description("Check status of subagents").option("-r, --root <path>","Root path for memory checks",process.cwd()).action(($,J,N)=>{R4($,J,N.root).catch(console.error)});X1.parse();
215
+ `)),$5($);let J=I$($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});J.on("all",()=>$5($)),process.on("SIGINT",()=>{console.log(`
216
+ `),J.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var KN="1.1.1",Q1=new Y4;Q1.name("oh-my-ag").description("Multi-Agent Skills for Antigravity IDE").version(KN).action(()=>{e4().catch(console.error)});Q1.command("dashboard").description("Start terminal dashboard (real-time agent monitoring)").action(()=>{J5()});Q1.command("dashboard:web").description("Start web dashboard on http://localhost:9847").action(()=>{e3()});Q1.command("update").description("Update skills to latest version from registry").action(()=>{A8().catch(console.error)});Q1.command("doctor").description("Check CLI installations, MCP configs, and skill status").option("--json","Output as JSON for CI/CD").action(($)=>{o4($.json).catch(console.error)});Q1.command("stats").description("View productivity metrics").option("--json","Output as JSON").option("--reset","Reset metrics data").action(($)=>{H8($.json,$.reset).catch(console.error)});Q1.command("retro").description("Session retrospective (learnings & next steps)").option("--json","Output as JSON").option("--interactive","Interactive mode (manual entry)").action(($)=>{j8($.json,$.interactive).catch(console.error)});Q1.command("cleanup").description("Clean up orphaned subagent processes and temp files").option("--dry-run","Show what would be cleaned without making changes").option("--json","Output as JSON").action(($)=>{c4($.dryRun,$.json).catch(console.error)});Q1.command("bridge [url]").description("Bridge MCP stdio to SSE (for Serena)").action(($)=>{q4($).catch(console.error)});Q1.command("agent:spawn <agent-id> <prompt-file> <session-id> <workspace>").description("Spawn a subagent (wraps gemini with logging and PID tracking)").action(($,J,N,G)=>{R4($,J,N,G).catch(console.error)});Q1.command("agent:status <session-id> [agent-ids...]").description("Check status of subagents").option("-r, --root <path>","Root path for memory checks",process.cwd()).action(($,J,N)=>{H4($,J,N.root).catch(console.error)});Q1.parse();