oh-my-ag 1.4.1 → 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.
package/bin/cli.js CHANGED
@@ -1,34 +1,154 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as d3}from"node:module";var k3=Object.create;var{getPrototypeOf:h3,defineProperty:m2,getOwnPropertyNames:n3}=Object;var c3=Object.prototype.hasOwnProperty;var i=($,I,N)=>{N=$!=null?k3(h3($)):{};let G=I||!$||!$.__esModule?m2(N,"default",{value:$,enumerable:!0}):N;for(let J of n3($))if(!c3.call(G,J))m2(G,J,{get:()=>$[J],enumerable:!0});return G};var v=($,I)=>()=>(I||$((I={exports:{}}).exports,I),I.exports);var O=d3(import.meta.url);var a1=v((p3)=>{class T$ extends Error{constructor($,I,N){super(N);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=I,this.exitCode=$,this.nestedError=void 0}}class i2 extends T${constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}p3.CommanderError=T$;p3.InvalidArgumentError=i2});var B0=v((t3)=>{var{InvalidArgumentError:r3}=a1();class k2{constructor($,I){switch(this.description=I||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,I){if(I===this.defaultValue||!Array.isArray(I))return[$];return I.concat($)}default($,I){return this.defaultValue=$,this.defaultValueDescription=I,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(I,N)=>{if(!this.argChoices.includes(I))throw new r3(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(I,N);return I},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function a3($){let I=$.name()+($.variadic===!0?"...":"");return $.required?"<"+I+">":"["+I+"]"}t3.Argument=k2;t3.humanReadableArgName=a3});var U$=v((N5)=>{var{humanReadableArgName:I5}=B0();class h2{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let I=$.commands.filter((G)=>!G._hidden),N=$._getHelpCommand();if(N&&!N._hidden)I.push(N);if(this.sortSubcommands)I.sort((G,J)=>{return G.name().localeCompare(J.name())});return I}compareOptions($,I){let N=(G)=>{return G.short?G.short.replace(/^-/,""):G.long.replace(/^--/,"")};return N($).localeCompare(N(I))}visibleOptions($){let I=$.options.filter((G)=>!G.hidden),N=$._getHelpOption();if(N&&!N.hidden){let G=N.short&&$._findOption(N.short),J=N.long&&$._findOption(N.long);if(!G&&!J)I.push(N);else if(N.long&&!J)I.push($.createOption(N.long,N.description));else if(N.short&&!G)I.push($.createOption(N.short,N.description))}if(this.sortOptions)I.sort(this.compareOptions);return I}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let I=[];for(let N=$.parent;N;N=N.parent){let G=N.options.filter((J)=>!J.hidden);I.push(...G)}if(this.sortOptions)I.sort(this.compareOptions);return I}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((I)=>{I.description=I.description||$._argsDescription[I.name()]||""});if($.registeredArguments.find((I)=>I.description))return $.registeredArguments;return[]}subcommandTerm($){let I=$.registeredArguments.map((N)=>I5(N)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(I?" "+I:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,I){return I.visibleCommands($).reduce((N,G)=>{return Math.max(N,I.subcommandTerm(G).length)},0)}longestOptionTermLength($,I){return I.visibleOptions($).reduce((N,G)=>{return Math.max(N,I.optionTerm(G).length)},0)}longestGlobalOptionTermLength($,I){return I.visibleGlobalOptions($).reduce((N,G)=>{return Math.max(N,I.optionTerm(G).length)},0)}longestArgumentTermLength($,I){return I.visibleArguments($).reduce((N,G)=>{return Math.max(N,I.argumentTerm(G).length)},0)}commandUsage($){let I=$._name;if($._aliases[0])I=I+"|"+$._aliases[0];let N="";for(let G=$.parent;G;G=G.parent)N=G.name()+" "+N;return N+I+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let I=[];if($.argChoices)I.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")I.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)I.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)I.push(`env: ${$.envVar}`);if(I.length>0)return`${$.description} (${I.join(", ")})`;return $.description}argumentDescription($){let I=[];if($.argChoices)I.push(`choices: ${$.argChoices.map((N)=>JSON.stringify(N)).join(", ")}`);if($.defaultValue!==void 0)I.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(I.length>0){let N=`(${I.join(", ")})`;if($.description)return`${$.description} ${N}`;return N}return $.description}formatHelp($,I){let N=I.padWidth($,I),G=I.helpWidth||80,J=2,Z=2;function z(S,Y){if(Y){let K=`${S.padEnd(N+2)}${Y}`;return I.wrap(K,G-2,N+2)}return S}function x(S){return S.join(`
3
- `).replace(/^/gm," ".repeat(2))}let Q=[`Usage: ${I.commandUsage($)}`,""],X=I.commandDescription($);if(X.length>0)Q=Q.concat([I.wrap(X,G,0),""]);let j=I.visibleArguments($).map((S)=>{return z(I.argumentTerm(S),I.argumentDescription(S))});if(j.length>0)Q=Q.concat(["Arguments:",x(j),""]);let M=I.visibleOptions($).map((S)=>{return z(I.optionTerm(S),I.optionDescription(S))});if(M.length>0)Q=Q.concat(["Options:",x(M),""]);if(this.showGlobalOptions){let S=I.visibleGlobalOptions($).map((Y)=>{return z(I.optionTerm(Y),I.optionDescription(Y))});if(S.length>0)Q=Q.concat(["Global Options:",x(S),""])}let R=I.visibleCommands($).map((S)=>{return z(I.subcommandTerm(S),I.subcommandDescription(S))});if(R.length>0)Q=Q.concat(["Commands:",x(R),""]);return Q.join(`
4
- `)}padWidth($,I){return Math.max(I.longestOptionTermLength($,I),I.longestGlobalOptionTermLength($,I),I.longestSubcommandTermLength($,I),I.longestArgumentTermLength($,I))}wrap($,I,N,G=40){let Z=new RegExp(`[\\n][${" \\f\\t\\v   -    \uFEFF"}]+`);if($.match(Z))return $;let z=I-N;if(z<G)return $;let x=$.slice(0,N),Q=$.slice(N).replace(`\r
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
+ `)}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
- `),X=" ".repeat(N),M=`\\s${"​"}`,R=new RegExp(`
7
- |.{1,${z-1}}([${M}]|$)|[^${M}]+?([${M}]|$)`,"g"),S=Q.match(R)||[];return x+S.map((Y,K)=>{if(Y===`
8
- `)return"";return(K>0?X:"")+Y.trimEnd()}).join(`
9
- `)}}N5.Help=h2});var q$=v((z5)=>{var{InvalidArgumentError:J5}=a1();class n2{constructor($,I){this.flags=$,this.description=I||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let N=x5($);if(this.short=N.shortFlag,this.long=N.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default($,I){return this.defaultValue=$,this.defaultValueDescription=I,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let I=$;if(typeof $==="string")I={[$]:!0};return this.implied=Object.assign(this.implied||{},I),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,I){if(I===this.defaultValue||!Array.isArray(I))return[$];return I.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(I,N)=>{if(!this.argChoices.includes(I))throw new J5(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(I,N);return I},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return Z5(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class c2{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((I)=>{if(I.negate)this.negativeOptions.set(I.attributeName(),I);else this.positiveOptions.set(I.attributeName(),I)}),this.negativeOptions.forEach((I,N)=>{if(this.positiveOptions.has(N))this.dualOptions.add(N)})}valueFromOption($,I){let N=I.attributeName();if(!this.dualOptions.has(N))return!0;let G=this.negativeOptions.get(N).presetArg,J=G!==void 0?G:!1;return I.negate===(J===$)}}function Z5($){return $.split("-").reduce((I,N)=>{return I+N[0].toUpperCase()+N.slice(1)})}function x5($){let I,N,G=$.split(/[ |,]+/);if(G.length>1&&!/^[[<]/.test(G[1]))I=G.shift();if(N=G.shift(),!I&&/^-[^-]$/.test(N))I=N,N=void 0;return{shortFlag:I,longFlag:N}}z5.Option=n2;z5.DualOptions=c2});var d2=v((K5)=>{function M5($,I){if(Math.abs($.length-I.length)>3)return Math.max($.length,I.length);let N=[];for(let G=0;G<=$.length;G++)N[G]=[G];for(let G=0;G<=I.length;G++)N[0][G]=G;for(let G=1;G<=I.length;G++)for(let J=1;J<=$.length;J++){let Z=1;if($[J-1]===I[G-1])Z=0;else Z=1;if(N[J][G]=Math.min(N[J-1][G]+1,N[J][G-1]+1,N[J-1][G-1]+Z),J>1&&G>1&&$[J-1]===I[G-2]&&$[J-2]===I[G-1])N[J][G]=Math.min(N[J][G],N[J-2][G-2]+1)}return N[$.length][I.length]}function j5($,I){if(!I||I.length===0)return"";I=Array.from(new Set(I));let N=$.startsWith("--");if(N)$=$.slice(2),I=I.map((z)=>z.slice(2));let G=[],J=3,Z=0.4;if(I.forEach((z)=>{if(z.length<=1)return;let x=M5($,z),Q=Math.max($.length,z.length);if((Q-x)/Q>Z){if(x<J)J=x,G=[z];else if(x===J)G.push(z)}}),G.sort((z,x)=>z.localeCompare(x)),N)G=G.map((z)=>`--${z}`);if(G.length>1)return`
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((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""}K5.suggestSimilar=j5});var r2=v((q5)=>{var R5=O("node:events").EventEmitter,C$=O("node:child_process"),S1=O("node:path"),B$=O("node:fs"),w=O("node:process"),{Argument:S5,humanReadableArgName:H5}=B0(),{CommanderError:g$}=a1(),{Help:T5}=U$(),{Option:p2,DualOptions:U5}=q$(),{suggestSimilar:s2}=d2();class L$ extends R5{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(I)=>w.stdout.write(I),writeErr:(I)=>w.stderr.write(I),getOutHelpWidth:()=>w.stdout.isTTY?w.stdout.columns:void 0,getErrHelpWidth:()=>w.stderr.isTTY?w.stderr.columns:void 0,outputError:(I,N)=>N(I)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let I=this;I;I=I.parent)$.push(I);return $}command($,I,N){let G=I,J=N;if(typeof G==="object"&&G!==null)J=G,G=null;J=J||{};let[,Z,z]=$.match(/([^ ]+) *(.*)/),x=this.createCommand(Z);if(G)x.description(G),x._executableHandler=!0;if(J.isDefault)this._defaultCommandName=x._name;if(x._hidden=!!(J.noHelp||J.hidden),x._executableFile=J.executableFile||null,z)x.arguments(z);if(this._registerCommand(x),x.parent=this,x.copyInheritedSettings(this),G)return this;return x}createCommand($){return new L$($)}createHelp(){return Object.assign(new T5,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,I){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
12
- - specify the name in Command constructor or using .name()`);if(I=I||{},I.isDefault)this._defaultCommandName=$._name;if(I.noHelp||I.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,I){return new S5($,I)}argument($,I,N,G){let J=this.createArgument($,I);if(typeof N==="function")J.default(G).argParser(N);else J.default(N);return this.addArgument(J),this}arguments($){return $.trim().split(/ +/).forEach((I)=>{this.argument(I)}),this}addArgument($){let I=this.registeredArguments.slice(-1)[0];if(I&&I.variadic)throw Error(`only the last argument can be variadic '${I.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,I){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,N,G]=$.match(/([^ ]+) *(.*)/),J=I??"display help for command",Z=this.createCommand(N);if(Z.helpOption(!1),G)Z.arguments(G);if(J)Z.description(J);return this._addImplicitHelpCommand=!0,this._helpCommand=Z,this}addHelpCommand($,I){if(typeof $!=="object")return this.helpCommand($,I),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,I){let N=["preSubcommand","preAction","postAction"];if(!N.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
13
- Expecting one of '${N.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(I);else this._lifeCycleHooks[$]=[I];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(I)=>{if(I.code!=="commander.executeSubCommandAsync")throw I};return this}_exit($,I,N){if(this._exitCallback)this._exitCallback(new g$($,I,N));w.exit($)}action($){let I=(N)=>{let G=this.registeredArguments.length,J=N.slice(0,G);if(this._storeOptionsAsProperties)J[G]=this;else J[G]=this.opts();return J.push(this),$.apply(this,J)};return this._actionHandler=I,this}createOption($,I){return new p2($,I)}_callParseArg($,I,N,G){try{return $.parseArg(I,N)}catch(J){if(J.code==="commander.invalidArgument"){let Z=`${G} ${J.message}`;this.error(Z,{exitCode:J.exitCode,code:J.code})}throw J}}_registerOption($){let I=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(I){let N=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${N}'
14
- - already used by option '${I.flags}'`)}this.options.push($)}_registerCommand($){let I=(G)=>{return[G.name()].concat(G.aliases())},N=I($).find((G)=>this._findCommand(G));if(N){let G=I(this._findCommand(N)).join("|"),J=I($).join("|");throw Error(`cannot add command '${J}' as already have command '${G}'`)}this.commands.push($)}addOption($){this._registerOption($);let I=$.name(),N=$.attributeName();if($.negate){let J=$.long.replace(/^--no-/,"--");if(!this._findOption(J))this.setOptionValueWithSource(N,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(N,$.defaultValue,"default");let G=(J,Z,z)=>{if(J==null&&$.presetArg!==void 0)J=$.presetArg;let x=this.getOptionValue(N);if(J!==null&&$.parseArg)J=this._callParseArg($,J,x,Z);else if(J!==null&&$.variadic)J=$._concatValue(J,x);if(J==null)if($.negate)J=!1;else if($.isBoolean()||$.optional)J=!0;else J="";this.setOptionValueWithSource(N,J,z)};if(this.on("option:"+I,(J)=>{let Z=`error: option '${$.flags}' argument '${J}' is invalid.`;G(J,Z,"cli")}),$.envVar)this.on("optionEnv:"+I,(J)=>{let Z=`error: option '${$.flags}' value '${J}' from env '${$.envVar}' is invalid.`;G(J,Z,"env")});return this}_optionEx($,I,N,G,J){if(typeof I==="object"&&I instanceof p2)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Z=this.createOption(I,N);if(Z.makeOptionMandatory(!!$.mandatory),typeof G==="function")Z.default(J).argParser(G);else if(G instanceof RegExp){let z=G;G=(x,Q)=>{let X=z.exec(x);return X?X[0]:Q},Z.default(J).argParser(G)}else Z.default(G);return this.addOption(Z)}option($,I,N,G){return this._optionEx({},$,I,N,G)}requiredOption($,I,N,G){return this._optionEx({mandatory:!0},$,I,N,G)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,I){return this.setOptionValueWithSource($,I,void 0)}setOptionValueWithSource($,I,N){if(this._storeOptionsAsProperties)this[$]=I;else this._optionValues[$]=I;return this._optionValueSources[$]=N,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let I;return this._getCommandAndAncestors().forEach((N)=>{if(N.getOptionValueSource($)!==void 0)I=N.getOptionValueSource($)}),I}_prepareUserArgs($,I){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(I=I||{},$===void 0&&I.from===void 0){if(w.versions?.electron)I.from="electron";let G=w.execArgv??[];if(G.includes("-e")||G.includes("--eval")||G.includes("-p")||G.includes("--print"))I.from="eval"}if($===void 0)$=w.argv;this.rawArgs=$.slice();let N;switch(I.from){case void 0:case"node":this._scriptPath=$[1],N=$.slice(2);break;case"electron":if(w.defaultApp)this._scriptPath=$[1],N=$.slice(2);else N=$.slice(1);break;case"user":N=$.slice(0);break;case"eval":N=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${I.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",N}parse($,I){let N=this._prepareUserArgs($,I);return this._parseCommand([],N),this}async parseAsync($,I){let N=this._prepareUserArgs($,I);return await this._parseCommand([],N),this}_executeSubCommand($,I){I=I.slice();let N=!1,G=[".js",".ts",".tsx",".mjs",".cjs"];function J(X,j){let M=S1.resolve(X,j);if(B$.existsSync(M))return M;if(G.includes(S1.extname(j)))return;let R=G.find((S)=>B$.existsSync(`${M}${S}`));if(R)return`${M}${R}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Z=$._executableFile||`${this._name}-${$._name}`,z=this._executableDir||"";if(this._scriptPath){let X;try{X=B$.realpathSync(this._scriptPath)}catch(j){X=this._scriptPath}z=S1.resolve(S1.dirname(X),z)}if(z){let X=J(z,Z);if(!X&&!$._executableFile&&this._scriptPath){let j=S1.basename(this._scriptPath,S1.extname(this._scriptPath));if(j!==this._name)X=J(z,`${j}-${$._name}`)}Z=X||Z}N=G.includes(S1.extname(Z));let x;if(w.platform!=="win32")if(N)I.unshift(Z),I=o2(w.execArgv).concat(I),x=C$.spawn(w.argv[0],I,{stdio:"inherit"});else x=C$.spawn(Z,I,{stdio:"inherit"});else I.unshift(Z),I=o2(w.execArgv).concat(I),x=C$.spawn(w.execPath,I,{stdio:"inherit"});if(!x.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((j)=>{w.on(j,()=>{if(x.killed===!1&&x.exitCode===null)x.kill(j)})});let Q=this._exitCallback;x.on("close",(X)=>{if(X=X??1,!Q)w.exit(X);else Q(new g$(X,"commander.executeSubCommandAsync","(close)"))}),x.on("error",(X)=>{if(X.code==="ENOENT"){let j=z?`searched for local subcommand relative to directory '${z}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",M=`'${Z}' does not exist
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
- - ${j}`;throw Error(M)}else if(X.code==="EACCES")throw Error(`'${Z}' not executable`);if(!Q)w.exit(1);else{let j=new g$(1,"commander.executeSubCommandAsync","(error)");j.nestedError=X,Q(j)}}),this.runningCommand=x}_dispatchSubcommand($,I,N){let G=this._findCommand($);if(!G)this.help({error:!0});let J;return J=this._chainOrCallSubCommandHook(J,G,"preSubcommand"),J=this._chainOrCall(J,()=>{if(G._executableHandler)this._executeSubCommand(G,I.concat(N));else return G._parseCommand(I,N)}),J}_dispatchHelpCommand($){if(!$)this.help();let I=this._findCommand($);if(I&&!I._executableHandler)I.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,I)=>{if($.required&&this.args[I]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(N,G,J)=>{let Z=G;if(G!==null&&N.parseArg){let z=`error: command-argument value '${G}' is invalid for argument '${N.name()}'.`;Z=this._callParseArg(N,G,J,z)}return Z};this._checkNumberOfArguments();let I=[];this.registeredArguments.forEach((N,G)=>{let J=N.defaultValue;if(N.variadic){if(G<this.args.length){if(J=this.args.slice(G),N.parseArg)J=J.reduce((Z,z)=>{return $(N,z,Z)},N.defaultValue)}else if(J===void 0)J=[]}else if(G<this.args.length){if(J=this.args[G],N.parseArg)J=$(N,J,N.defaultValue)}I[G]=J}),this.processedArgs=I}_chainOrCall($,I){if($&&$.then&&typeof $.then==="function")return $.then(()=>I());return I()}_chainOrCallHooks($,I){let N=$,G=[];if(this._getCommandAndAncestors().reverse().filter((J)=>J._lifeCycleHooks[I]!==void 0).forEach((J)=>{J._lifeCycleHooks[I].forEach((Z)=>{G.push({hookedCommand:J,callback:Z})})}),I==="postAction")G.reverse();return G.forEach((J)=>{N=this._chainOrCall(N,()=>{return J.callback(J.hookedCommand,this)})}),N}_chainOrCallSubCommandHook($,I,N){let G=$;if(this._lifeCycleHooks[N]!==void 0)this._lifeCycleHooks[N].forEach((J)=>{G=this._chainOrCall(G,()=>{return J(this,I)})});return G}_parseCommand($,I){let N=this.parseOptions(I);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(N.operands),I=N.unknown,this.args=$.concat(I),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),I);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(I),this._dispatchSubcommand(this._defaultCommandName,$,I);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(N.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=()=>{if(N.unknown.length>0)this.unknownOption(N.unknown[0])},J=`command:${this.name()}`;if(this._actionHandler){G(),this._processArguments();let Z;if(Z=this._chainOrCallHooks(Z,"preAction"),Z=this._chainOrCall(Z,()=>this._actionHandler(this.processedArgs)),this.parent)Z=this._chainOrCall(Z,()=>{this.parent.emit(J,$,I)});return Z=this._chainOrCallHooks(Z,"postAction"),Z}if(this.parent&&this.parent.listenerCount(J))G(),this._processArguments(),this.parent.emit(J,$,I);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,I);if(this.listenerCount("command:*"))this.emit("command:*",$,I);else if(this.commands.length)this.unknownCommand();else G(),this._processArguments()}else if(this.commands.length)G(),this.help({error:!0});else G(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((I)=>I._name===$||I._aliases.includes($))}_findOption($){return this.options.find((I)=>I.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((I)=>{if(I.mandatory&&$.getOptionValue(I.attributeName())===void 0)$.missingMandatoryOptionValue(I)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((N)=>{let G=N.attributeName();if(this.getOptionValue(G)===void 0)return!1;return this.getOptionValueSource(G)!=="default"});$.filter((N)=>N.conflictsWith.length>0).forEach((N)=>{let G=$.find((J)=>N.conflictsWith.includes(J.attributeName()));if(G)this._conflictingOption(N,G)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let I=[],N=[],G=I,J=$.slice();function Z(x){return x.length>1&&x[0]==="-"}let z=null;while(J.length){let x=J.shift();if(x==="--"){if(G===N)G.push(x);G.push(...J);break}if(z&&!Z(x)){this.emit(`option:${z.name()}`,x);continue}if(z=null,Z(x)){let Q=this._findOption(x);if(Q){if(Q.required){let X=J.shift();if(X===void 0)this.optionMissingArgument(Q);this.emit(`option:${Q.name()}`,X)}else if(Q.optional){let X=null;if(J.length>0&&!Z(J[0]))X=J.shift();this.emit(`option:${Q.name()}`,X)}else this.emit(`option:${Q.name()}`);z=Q.variadic?Q:null;continue}}if(x.length>2&&x[0]==="-"&&x[1]!=="-"){let Q=this._findOption(`-${x[1]}`);if(Q){if(Q.required||Q.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Q.name()}`,x.slice(2));else this.emit(`option:${Q.name()}`),J.unshift(`-${x.slice(2)}`);continue}}if(/^--[^=]+=/.test(x)){let Q=x.indexOf("="),X=this._findOption(x.slice(0,Q));if(X&&(X.required||X.optional)){this.emit(`option:${X.name()}`,x.slice(Q+1));continue}}if(Z(x))G=N;if((this._enablePositionalOptions||this._passThroughOptions)&&I.length===0&&N.length===0){if(this._findCommand(x)){if(I.push(x),J.length>0)N.push(...J);break}else if(this._getHelpCommand()&&x===this._getHelpCommand().name()){if(I.push(x),J.length>0)I.push(...J);break}else if(this._defaultCommandName){if(N.push(x),J.length>0)N.push(...J);break}}if(this._passThroughOptions){if(G.push(x),J.length>0)G.push(...J);break}G.push(x)}return{operands:I,unknown:N}}opts(){if(this._storeOptionsAsProperties){let $={},I=this.options.length;for(let N=0;N<I;N++){let G=this.options[N].attributeName();$[G]=G===this._versionOptionName?this._version:this[G]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,I)=>Object.assign($,I.opts()),{})}error($,I){if(this._outputConfiguration.outputError(`${$}
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=I||{},G=N.exitCode||1,J=N.code||"commander.error";this._exit(G,J,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in w.env){let I=$.attributeName();if(this.getOptionValue(I)===void 0||["default","config","env"].includes(this.getOptionValueSource(I)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,w.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new U5(this.options),I=(N)=>{return this.getOptionValue(N)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(N))};this.options.filter((N)=>N.implied!==void 0&&I(N.attributeName())&&$.valueFromOption(this.getOptionValue(N.attributeName()),N)).forEach((N)=>{Object.keys(N.implied).filter((G)=>!I(G)).forEach((G)=>{this.setOptionValueWithSource(G,N.implied[G],"implied")})})}missingArgument($){let I=`error: missing required argument '${$}'`;this.error(I,{code:"commander.missingArgument"})}optionMissingArgument($){let I=`error: option '${$.flags}' argument missing`;this.error(I,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let I=`error: required option '${$.flags}' not specified`;this.error(I,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,I){let N=(Z)=>{let z=Z.attributeName(),x=this.getOptionValue(z),Q=this.options.find((j)=>j.negate&&z===j.attributeName()),X=this.options.find((j)=>!j.negate&&z===j.attributeName());if(Q&&(Q.presetArg===void 0&&x===!1||Q.presetArg!==void 0&&x===Q.presetArg))return Q;return X||Z},G=(Z)=>{let z=N(Z),x=z.attributeName();if(this.getOptionValueSource(x)==="env")return`environment variable '${z.envVar}'`;return`option '${z.flags}'`},J=`error: ${G($)} cannot be used with ${G(I)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let I="";if($.startsWith("--")&&this._showSuggestionAfterError){let G=[],J=this;do{let Z=J.createHelp().visibleOptions(J).filter((z)=>z.long).map((z)=>z.long);G=G.concat(Z),J=J.parent}while(J&&!J._enablePositionalOptions);I=s2($,G)}let N=`error: unknown option '${$}'${I}`;this.error(N,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let I=this.registeredArguments.length,N=I===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${I} argument${N} but got ${$.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],I="";if(this._showSuggestionAfterError){let G=[];this.createHelp().visibleCommands(this).forEach((J)=>{if(G.push(J.name()),J.alias())G.push(J.alias())}),I=s2($,G)}let N=`error: unknown command '${$}'${I}`;this.error(N,{code:"commander.unknownCommand"})}version($,I,N){if($===void 0)return this._version;this._version=$,I=I||"-V, --version",N=N||"output the version number";let G=this.createOption(I,N);return this._versionOptionName=G.attributeName(),this._registerOption(G),this.on("option:"+G.name(),()=>{this._outputConfiguration.writeOut(`${$}
21
- `),this._exit(0,"commander.version",$)}),this}description($,I){if($===void 0&&I===void 0)return this._description;if(this._description=$,I)this._argsDescription=I;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let I=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)I=this.commands[this.commands.length-1];if($===I._name)throw Error("Command alias can't be the same as its name");let N=this.parent?._findCommand($);if(N){let G=[N.name()].concat(N.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${G}'`)}return I._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((I)=>this.alias(I)),this}usage($){if($===void 0){if(this._usage)return this._usage;let I=this.registeredArguments.map((N)=>{return H5(N)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?I:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=S1.basename($,S1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let I=this.createHelp();if(I.helpWidth===void 0)I.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return I.formatHelp(this,I)}_getHelpContext($){$=$||{};let I={error:!!$.error},N;if(I.error)N=(G)=>this._outputConfiguration.writeErr(G);else N=(G)=>this._outputConfiguration.writeOut(G);return I.write=$.write||N,I.command=this,I}outputHelp($){let I;if(typeof $==="function")I=$,$=void 0;let N=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((J)=>J.emit("beforeAllHelp",N)),this.emit("beforeHelp",N);let G=this.helpInformation(N);if(I){if(G=I(G),typeof G!=="string"&&!Buffer.isBuffer(G))throw Error("outputHelp callback must return a string or a Buffer")}if(N.write(G),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",N),this._getCommandAndAncestors().forEach((J)=>J.emit("afterAllHelp",N))}helpOption($,I){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",I=I??"display help for command",this._helpOption=this.createOption($,I),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let I=w.exitCode||0;if(I===0&&$&&typeof $!=="function"&&$.error)I=1;this._exit(I,"commander.help","(outputHelp)")}addHelpText($,I){let N=["beforeAll","before","after","afterAll"];if(!N.includes($))throw Error(`Unexpected value for position to addHelpText.
22
- Expecting one of '${N.join("', '")}'`);let G=`${$}Help`;return this.on(G,(J)=>{let Z;if(typeof I==="function")Z=I({error:J.error,command:J.command});else Z=I;if(Z)J.write(`${Z}
23
- `)}),this}_outputHelpIfRequested($){let I=this._getHelpOption();if(I&&$.find((G)=>I.is(G)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function o2($){return $.map((I)=>{if(!I.startsWith("--inspect"))return I;let N,G="127.0.0.1",J="9229",Z;if((Z=I.match(/^(--inspect(-brk)?)$/))!==null)N=Z[1];else if((Z=I.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(N=Z[1],/^\d+$/.test(Z[3]))J=Z[3];else G=Z[3];else if((Z=I.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)N=Z[1],G=Z[3],J=Z[4];if(N&&J!=="0")return`${N}=${G}:${parseInt(J)+1}`;return I})}q5.Command=L$});var $4=v((L5)=>{var{Argument:a2}=B0(),{Command:D$}=r2(),{CommanderError:B5,InvalidArgumentError:t2}=a1(),{Help:g5}=U$(),{Option:e2}=q$();L5.program=new D$;L5.createCommand=($)=>new D$($);L5.createOption=($,I)=>new e2($,I);L5.createArgument=($,I)=>new a2($,I);L5.Command=D$;L5.Option=e2;L5.Argument=a2;L5.Help=g5;L5.CommanderError=B5;L5.InvalidArgumentError=t2;L5.InvalidOptionArgumentError=t2});var H1=v((V7,P4)=>{var f4=["nodebuffer","arraybuffer","fragments"],A4=typeof Blob<"u";if(A4)f4.push("blob");P4.exports={BINARY_TYPES:f4,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:A4,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var $0=v((f7,P0)=>{var{EMPTY_BUFFER:f6}=H1(),E$=Buffer[Symbol.species];function A6($,I){if($.length===0)return f6;if($.length===1)return $[0];let N=Buffer.allocUnsafe(I),G=0;for(let J=0;J<$.length;J++){let Z=$[J];N.set(Z,G),G+=Z.length}if(G<I)return new E$(N.buffer,N.byteOffset,G);return N}function F4($,I,N,G,J){for(let Z=0;Z<J;Z++)N[G+Z]=$[Z]^I[Z&3]}function W4($,I){for(let N=0;N<$.length;N++)$[N]^=I[N&3]}function P6($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function l$($){if(l$.readOnly=!0,Buffer.isBuffer($))return $;let I;if($ instanceof ArrayBuffer)I=new E$($);else if(ArrayBuffer.isView($))I=new E$($.buffer,$.byteOffset,$.byteLength);else I=Buffer.from($),l$.readOnly=!1;return I}P0.exports={concat:A6,mask:F4,toArrayBuffer:P6,toBuffer:l$,unmask:W4};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();P0.exports.mask=function(I,N,G,J,Z){if(Z<48)F4(I,N,G,J,Z);else $.mask(I,N,G,J,Z)},P0.exports.unmask=function(I,N){if(I.length<32)W4(I,N);else $.unmask(I,N)}}catch($){}});var l4=v((A7,E4)=>{var O4=Symbol("kDone"),u$=Symbol("kRun");class y4{constructor($){this[O4]=()=>{this.pending--,this[u$]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[u$]()}[u$](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[O4])}}}E4.exports=y4});var N0=v((P7,m4)=>{var I0=O("zlib"),u4=$0(),F6=l4(),{kStatusCode:v4}=H1(),W6=Buffer[Symbol.species],O6=Buffer.from([0,0,255,255]),W0=Symbol("permessage-deflate"),T1=Symbol("total-length"),b1=Symbol("callback"),B1=Symbol("buffers"),m1=Symbol("error"),F0;class w4{constructor($,I,N){if(this._maxPayload=N|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!I,this._deflate=null,this._inflate=null,this.params=null,!F0){let G=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;F0=new F6(G)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[b1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let I=this._options,N=$.find((G)=>{if(I.serverNoContextTakeover===!1&&G.server_no_context_takeover||G.server_max_window_bits&&(I.serverMaxWindowBits===!1||typeof I.serverMaxWindowBits==="number"&&I.serverMaxWindowBits>G.server_max_window_bits)||typeof I.clientMaxWindowBits==="number"&&!G.client_max_window_bits)return!1;return!0});if(!N)throw Error("None of the extension offers can be accepted");if(I.serverNoContextTakeover)N.server_no_context_takeover=!0;if(I.clientNoContextTakeover)N.client_no_context_takeover=!0;if(typeof I.serverMaxWindowBits==="number")N.server_max_window_bits=I.serverMaxWindowBits;if(typeof I.clientMaxWindowBits==="number")N.client_max_window_bits=I.clientMaxWindowBits;else if(N.client_max_window_bits===!0||I.clientMaxWindowBits===!1)delete N.client_max_window_bits;return N}acceptAsClient($){let I=$[0];if(this._options.clientNoContextTakeover===!1&&I.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!I.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")I.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&I.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return I}normalizeParams($){return $.forEach((I)=>{Object.keys(I).forEach((N)=>{let G=I[N];if(G.length>1)throw Error(`Parameter "${N}" must have only a single value`);if(G=G[0],N==="client_max_window_bits"){if(G!==!0){let J=+G;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=J}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else if(N==="server_max_window_bits"){let J=+G;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${N}": ${G}`);G=J}else if(N==="client_no_context_takeover"||N==="server_no_context_takeover"){if(G!==!0)throw TypeError(`Invalid value for parameter "${N}": ${G}`)}else throw Error(`Unknown parameter "${N}"`);I[N]=G})}),$}decompress($,I,N){F0.add((G)=>{this._decompress($,I,(J,Z)=>{G(),N(J,Z)})})}compress($,I,N){F0.add((G)=>{this._compress($,I,(J,Z)=>{G(),N(J,Z)})})}_decompress($,I,N){let G=this._isServer?"client":"server";if(!this._inflate){let J=`${G}_max_window_bits`,Z=typeof this.params[J]!=="number"?I0.Z_DEFAULT_WINDOWBITS:this.params[J];this._inflate=I0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Z}),this._inflate[W0]=this,this._inflate[T1]=0,this._inflate[B1]=[],this._inflate.on("error",E6),this._inflate.on("data",b4)}if(this._inflate[b1]=N,this._inflate.write($),I)this._inflate.write(O6);this._inflate.flush(()=>{let J=this._inflate[m1];if(J){this._inflate.close(),this._inflate=null,N(J);return}let Z=u4.concat(this._inflate[B1],this._inflate[T1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[T1]=0,this._inflate[B1]=[],I&&this.params[`${G}_no_context_takeover`])this._inflate.reset();N(null,Z)})}_compress($,I,N){let G=this._isServer?"server":"client";if(!this._deflate){let J=`${G}_max_window_bits`,Z=typeof this.params[J]!=="number"?I0.Z_DEFAULT_WINDOWBITS:this.params[J];this._deflate=I0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Z}),this._deflate[T1]=0,this._deflate[B1]=[],this._deflate.on("data",y6)}this._deflate[b1]=N,this._deflate.write($),this._deflate.flush(I0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let J=u4.concat(this._deflate[B1],this._deflate[T1]);if(I)J=new W6(J.buffer,J.byteOffset,J.length-4);if(this._deflate[b1]=null,this._deflate[T1]=0,this._deflate[B1]=[],I&&this.params[`${G}_no_context_takeover`])this._deflate.reset();N(null,J)})}}m4.exports=w4;function y6($){this[B1].push($),this[T1]+=$.length}function b4($){if(this[T1]+=$.length,this[W0]._maxPayload<1||this[T1]<=this[W0]._maxPayload){this[B1].push($);return}this[m1]=RangeError("Max payload size exceeded"),this[m1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[m1][v4]=1009,this.removeListener("data",b4),this.reset()}function E6($){if(this[W0]._inflate=null,this[m1]){this[b1](this[m1]);return}$[v4]=1007,this[b1]($)}});var i1=v((F7,O0)=>{var{isUtf8:i4}=O("buffer"),{hasBlob:l6}=H1(),u6=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function v6($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function v$($){let I=$.length,N=0;while(N<I)if(($[N]&128)===0)N++;else if(($[N]&224)===192){if(N+1===I||($[N+1]&192)!==128||($[N]&254)===192)return!1;N+=2}else if(($[N]&240)===224){if(N+2>=I||($[N+1]&192)!==128||($[N+2]&192)!==128||$[N]===224&&($[N+1]&224)===128||$[N]===237&&($[N+1]&224)===160)return!1;N+=3}else if(($[N]&248)===240){if(N+3>=I||($[N+1]&192)!==128||($[N+2]&192)!==128||($[N+3]&192)!==128||$[N]===240&&($[N+1]&240)===128||$[N]===244&&$[N+1]>143||$[N]>244)return!1;N+=4}else return!1;return!0}function w6($){return l6&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}O0.exports={isBlob:w6,isValidStatusCode:v6,isValidUTF8:v$,tokenChars:u6};if(i4)O0.exports.isValidUTF8=function($){return $.length<24?v$($):i4($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();O0.exports.isValidUTF8=function(I){return I.length<32?v$(I):$(I)}}catch($){}});var b$=v((W7,d4)=>{var{Writable:b6}=O("stream"),k4=N0(),{BINARY_TYPES:m6,EMPTY_BUFFER:h4,kStatusCode:i6,kWebSocket:k6}=H1(),{concat:w$,toArrayBuffer:h6,unmask:n6}=$0(),{isValidStatusCode:c6,isValidUTF8:n4}=i1(),y0=Buffer[Symbol.species];class c4 extends b6{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||m6[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[k6]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,I,N){if(this._opcode===8&&this._state==0)return N();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(N)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let N=this._buffers[0];return this._buffers[0]=new y0(N.buffer,N.byteOffset+$,N.length-$),new y0(N.buffer,N.byteOffset,$)}let I=Buffer.allocUnsafe($);do{let N=this._buffers[0],G=I.length-$;if($>=N.length)I.set(this._buffers.shift(),G);else I.set(new Uint8Array(N.buffer,N.byteOffset,$),G),this._buffers[0]=new y0(N.buffer,N.byteOffset+$,N.length-$);$-=N.length}while($>0);return I}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let I=this.consume(2);if((I[0]&48)!==0){let G=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(G);return}let N=(I[0]&64)===64;if(N&&!this._extensions[k4.extensionName]){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._fin=(I[0]&128)===128,this._opcode=I[0]&15,this._payloadLength=I[1]&127,this._opcode===0){if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(!this._fragmented){let G=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}this._compressed=N}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let G=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(G);return}if(N){let G=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(G);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let G=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(G);return}}else{let G=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(G);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(I[1]&128)===128,this._isServer){if(!this._masked){let G=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(G);return}}else if(this._masked){let G=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(G);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let I=this.consume(8),N=I.readUInt32BE(0);if(N>Math.pow(2,21)-1){let G=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(G);return}this._payloadLength=N*Math.pow(2,32)+I.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let I=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(I);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let I=h4;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(I=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)n6(I,this._mask)}if(this._opcode>7){this.controlMessage(I,$);return}if(this._compressed){this._state=5,this.decompress(I,$);return}if(I.length)this._messageLength=this._totalPayloadLength,this._fragments.push(I);this.dataMessage($)}decompress($,I){this._extensions[k4.extensionName].decompress($,this._fin,(G,J)=>{if(G)return I(G);if(J.length){if(this._messageLength+=J.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");I(Z);return}this._fragments.push(J)}if(this.dataMessage(I),this._state===0)this.startLoop(I)})}dataMessage($){if(!this._fin){this._state=0;return}let I=this._messageLength,N=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let G;if(this._binaryType==="nodebuffer")G=w$(N,I);else if(this._binaryType==="arraybuffer")G=h6(w$(N,I));else if(this._binaryType==="blob")G=new Blob(N);else G=N;if(this._allowSynchronousEvents)this.emit("message",G,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!0),this._state=0,this.startLoop($)})}else{let G=w$(N,I);if(!this._skipUTF8Validation&&!n4(G)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(J);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",G,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",G,!1),this._state=0,this.startLoop($)})}}controlMessage($,I){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,h4),this.end();else{let N=$.readUInt16BE(0);if(!c6(N)){let J=this.createError(RangeError,`invalid status code ${N}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");I(J);return}let G=new y0($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!n4(G)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");I(J);return}this._loop=!1,this.emit("conclude",N,G),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(I)})}createError($,I,N,G,J){this._loop=!1,this._errored=!0;let Z=new $(N?`Invalid WebSocket frame: ${I}`:I);return Error.captureStackTrace(Z,this.createError),Z.code=J,Z[i6]=G,Z}}d4.exports=c4});var i$=v((y7,o4)=>{var{Duplex:O7}=O("stream"),{randomFillSync:d6}=O("crypto"),p4=N0(),{EMPTY_BUFFER:p6,kWebSocket:s6,NOOP:o6}=H1(),{isBlob:k1,isValidStatusCode:r6}=i1(),{mask:s4,toBuffer:F1}=$0(),I1=Symbol("kByteLength"),a6=Buffer.alloc(4),W1,h1=8192,Z1=0,t6=1,e6=2;class g1{constructor($,I,N){if(this._extensions=I||{},N)this._generateMask=N,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Z1,this.onerror=o6,this[s6]=void 0}static frame($,I){let N,G=!1,J=2,Z=!1;if(I.mask){if(N=I.maskBuffer||a6,I.generateMask)I.generateMask(N);else{if(h1===8192){if(W1===void 0)W1=Buffer.alloc(8192);d6(W1,0,8192),h1=0}N[0]=W1[h1++],N[1]=W1[h1++],N[2]=W1[h1++],N[3]=W1[h1++]}Z=(N[0]|N[1]|N[2]|N[3])===0,J=6}let z;if(typeof $==="string")if((!I.mask||Z)&&I[I1]!==void 0)z=I[I1];else $=Buffer.from($),z=$.length;else z=$.length,G=I.mask&&I.readOnly&&!Z;let x=z;if(z>=65536)J+=8,x=127;else if(z>125)J+=2,x=126;let Q=Buffer.allocUnsafe(G?z+J:J);if(Q[0]=I.fin?I.opcode|128:I.opcode,I.rsv1)Q[0]|=64;if(Q[1]=x,x===126)Q.writeUInt16BE(z,2);else if(x===127)Q[2]=Q[3]=0,Q.writeUIntBE(z,4,6);if(!I.mask)return[Q,$];if(Q[1]|=128,Q[J-4]=N[0],Q[J-3]=N[1],Q[J-2]=N[2],Q[J-1]=N[3],Z)return[Q,$];if(G)return s4($,N,Q,J,z),[Q];return s4($,N,$,0,z),[Q,$]}close($,I,N,G){let J;if($===void 0)J=p6;else if(typeof $!=="number"||!r6($))throw TypeError("First argument must be a valid error code number");else if(I===void 0||!I.length)J=Buffer.allocUnsafe(2),J.writeUInt16BE($,0);else{let z=Buffer.byteLength(I);if(z>123)throw RangeError("The message must not be greater than 123 bytes");if(J=Buffer.allocUnsafe(2+z),J.writeUInt16BE($,0),typeof I==="string")J.write(I,2);else J.set(I,2)}let Z={[I1]:J.length,fin:!0,generateMask:this._generateMask,mask:N,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==Z1)this.enqueue([this.dispatch,J,!1,Z,G]);else this.sendFrame(g1.frame(J,Z),G)}ping($,I,N){let G,J;if(typeof $==="string")G=Buffer.byteLength($),J=!1;else if(k1($))G=$.size,J=!1;else $=F1($),G=$.length,J=F1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let Z={[I1]:G,fin:!0,generateMask:this._generateMask,mask:I,maskBuffer:this._maskBuffer,opcode:9,readOnly:J,rsv1:!1};if(k1($))if(this._state!==Z1)this.enqueue([this.getBlobData,$,!1,Z,N]);else this.getBlobData($,!1,Z,N);else if(this._state!==Z1)this.enqueue([this.dispatch,$,!1,Z,N]);else this.sendFrame(g1.frame($,Z),N)}pong($,I,N){let G,J;if(typeof $==="string")G=Buffer.byteLength($),J=!1;else if(k1($))G=$.size,J=!1;else $=F1($),G=$.length,J=F1.readOnly;if(G>125)throw RangeError("The data size must not be greater than 125 bytes");let Z={[I1]:G,fin:!0,generateMask:this._generateMask,mask:I,maskBuffer:this._maskBuffer,opcode:10,readOnly:J,rsv1:!1};if(k1($))if(this._state!==Z1)this.enqueue([this.getBlobData,$,!1,Z,N]);else this.getBlobData($,!1,Z,N);else if(this._state!==Z1)this.enqueue([this.dispatch,$,!1,Z,N]);else this.sendFrame(g1.frame($,Z),N)}send($,I,N){let G=this._extensions[p4.extensionName],J=I.binary?2:1,Z=I.compress,z,x;if(typeof $==="string")z=Buffer.byteLength($),x=!1;else if(k1($))z=$.size,x=!1;else $=F1($),z=$.length,x=F1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Z&&G&&G.params[G._isServer?"server_no_context_takeover":"client_no_context_takeover"])Z=z>=G._threshold;this._compress=Z}else Z=!1,J=0;if(I.fin)this._firstFragment=!0;let Q={[I1]:z,fin:I.fin,generateMask:this._generateMask,mask:I.mask,maskBuffer:this._maskBuffer,opcode:J,readOnly:x,rsv1:Z};if(k1($))if(this._state!==Z1)this.enqueue([this.getBlobData,$,this._compress,Q,N]);else this.getBlobData($,this._compress,Q,N);else if(this._state!==Z1)this.enqueue([this.dispatch,$,this._compress,Q,N]);else this.dispatch($,this._compress,Q,N)}getBlobData($,I,N,G){this._bufferedBytes+=N[I1],this._state=e6,$.arrayBuffer().then((J)=>{if(this._socket.destroyed){let z=Error("The socket was closed while the blob was being read");process.nextTick(m$,this,z,G);return}this._bufferedBytes-=N[I1];let Z=F1(J);if(!I)this._state=Z1,this.sendFrame(g1.frame(Z,N),G),this.dequeue();else this.dispatch(Z,I,N,G)}).catch((J)=>{process.nextTick($9,this,J,G)})}dispatch($,I,N,G){if(!I){this.sendFrame(g1.frame($,N),G);return}let J=this._extensions[p4.extensionName];this._bufferedBytes+=N[I1],this._state=t6,J.compress($,N.fin,(Z,z)=>{if(this._socket.destroyed){let x=Error("The socket was closed while data was being compressed");m$(this,x,G);return}this._bufferedBytes-=N[I1],this._state=Z1,N.readOnly=!1,this.sendFrame(g1.frame(z,N),G),this.dequeue()})}dequeue(){while(this._state===Z1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][I1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][I1],this._queue.push($)}sendFrame($,I){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],I),this._socket.uncork();else this._socket.write($[0],I)}}o4.exports=g1;function m$($,I,N){if(typeof N==="function")N(I);for(let G=0;G<$._queue.length;G++){let J=$._queue[G],Z=J[J.length-1];if(typeof Z==="function")Z(I)}}function $9($,I,N){m$($,I,N),$.onerror(I)}});var J8=v((E7,G8)=>{var{kForOnEventAttribute:G0,kListener:k$}=H1(),r4=Symbol("kCode"),a4=Symbol("kData"),t4=Symbol("kError"),e4=Symbol("kMessage"),$8=Symbol("kReason"),n1=Symbol("kTarget"),I8=Symbol("kType"),N8=Symbol("kWasClean");class L1{constructor($){this[n1]=null,this[I8]=$}get target(){return this[n1]}get type(){return this[I8]}}Object.defineProperty(L1.prototype,"target",{enumerable:!0});Object.defineProperty(L1.prototype,"type",{enumerable:!0});class c1 extends L1{constructor($,I={}){super($);this[r4]=I.code===void 0?0:I.code,this[$8]=I.reason===void 0?"":I.reason,this[N8]=I.wasClean===void 0?!1:I.wasClean}get code(){return this[r4]}get reason(){return this[$8]}get wasClean(){return this[N8]}}Object.defineProperty(c1.prototype,"code",{enumerable:!0});Object.defineProperty(c1.prototype,"reason",{enumerable:!0});Object.defineProperty(c1.prototype,"wasClean",{enumerable:!0});class J0 extends L1{constructor($,I={}){super($);this[t4]=I.error===void 0?null:I.error,this[e4]=I.message===void 0?"":I.message}get error(){return this[t4]}get message(){return this[e4]}}Object.defineProperty(J0.prototype,"error",{enumerable:!0});Object.defineProperty(J0.prototype,"message",{enumerable:!0});class l0 extends L1{constructor($,I={}){super($);this[a4]=I.data===void 0?null:I.data}get data(){return this[a4]}}Object.defineProperty(l0.prototype,"data",{enumerable:!0});var I9={addEventListener($,I,N={}){for(let J of this.listeners($))if(!N[G0]&&J[k$]===I&&!J[G0])return;let G;if($==="message")G=function(Z,z){let x=new l0("message",{data:z?Z:Z.toString()});x[n1]=this,E0(I,this,x)};else if($==="close")G=function(Z,z){let x=new c1("close",{code:Z,reason:z.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});x[n1]=this,E0(I,this,x)};else if($==="error")G=function(Z){let z=new J0("error",{error:Z,message:Z.message});z[n1]=this,E0(I,this,z)};else if($==="open")G=function(){let Z=new L1("open");Z[n1]=this,E0(I,this,Z)};else return;if(G[G0]=!!N[G0],G[k$]=I,N.once)this.once($,G);else this.on($,G)},removeEventListener($,I){for(let N of this.listeners($))if(N[k$]===I&&!N[G0]){this.removeListener($,N);break}}};G8.exports={CloseEvent:c1,ErrorEvent:J0,Event:L1,EventTarget:I9,MessageEvent:l0};function E0($,I,N){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,N);else $.call(I,N)}});var h$=v((l7,Z8)=>{var{tokenChars:Z0}=i1();function j1($,I,N){if($[I]===void 0)$[I]=[N];else $[I].push(N)}function N9($){let I=Object.create(null),N=Object.create(null),G=!1,J=!1,Z=!1,z,x,Q=-1,X=-1,j=-1,M=0;for(;M<$.length;M++)if(X=$.charCodeAt(M),z===void 0)if(j===-1&&Z0[X]===1){if(Q===-1)Q=M}else if(M!==0&&(X===32||X===9)){if(j===-1&&Q!==-1)j=M}else if(X===59||X===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${M}`);if(j===-1)j=M;let S=$.slice(Q,j);if(X===44)j1(I,S,N),N=Object.create(null);else z=S;Q=j=-1}else throw SyntaxError(`Unexpected character at index ${M}`);else if(x===void 0)if(j===-1&&Z0[X]===1){if(Q===-1)Q=M}else if(X===32||X===9){if(j===-1&&Q!==-1)j=M}else if(X===59||X===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${M}`);if(j===-1)j=M;if(j1(N,$.slice(Q,j),!0),X===44)j1(I,z,N),N=Object.create(null),z=void 0;Q=j=-1}else if(X===61&&Q!==-1&&j===-1)x=$.slice(Q,M),Q=j=-1;else throw SyntaxError(`Unexpected character at index ${M}`);else if(J){if(Z0[X]!==1)throw SyntaxError(`Unexpected character at index ${M}`);if(Q===-1)Q=M;else if(!G)G=!0;J=!1}else if(Z)if(Z0[X]===1){if(Q===-1)Q=M}else if(X===34&&Q!==-1)Z=!1,j=M;else if(X===92)J=!0;else throw SyntaxError(`Unexpected character at index ${M}`);else if(X===34&&$.charCodeAt(M-1)===61)Z=!0;else if(j===-1&&Z0[X]===1){if(Q===-1)Q=M}else if(Q!==-1&&(X===32||X===9)){if(j===-1)j=M}else if(X===59||X===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${M}`);if(j===-1)j=M;let S=$.slice(Q,j);if(G)S=S.replace(/\\/g,""),G=!1;if(j1(N,x,S),X===44)j1(I,z,N),N=Object.create(null),z=void 0;x=void 0,Q=j=-1}else throw SyntaxError(`Unexpected character at index ${M}`);if(Q===-1||Z||X===32||X===9)throw SyntaxError("Unexpected end of input");if(j===-1)j=M;let R=$.slice(Q,j);if(z===void 0)j1(I,R,N);else{if(x===void 0)j1(N,R,!0);else if(G)j1(N,x,R.replace(/\\/g,""));else j1(N,x,R);j1(I,z,N)}return I}function G9($){return Object.keys($).map((I)=>{let N=$[I];if(!Array.isArray(N))N=[N];return N.map((G)=>{return[I].concat(Object.keys(G).map((J)=>{let Z=G[J];if(!Array.isArray(Z))Z=[Z];return Z.map((z)=>z===!0?J:`${J}=${z}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}Z8.exports={format:G9,parse:N9}});var b0=v((w7,T8)=>{var J9=O("events"),Z9=O("https"),x9=O("http"),Q8=O("net"),z9=O("tls"),{randomBytes:Q9,createHash:X9}=O("crypto"),{Duplex:u7,Readable:v7}=O("stream"),{URL:n$}=O("url"),D1=N0(),M9=b$(),j9=i$(),{isBlob:K9}=i1(),{BINARY_TYPES:x8,CLOSE_TIMEOUT:Y9,EMPTY_BUFFER:u0,GUID:R9,kForOnEventAttribute:c$,kListener:S9,kStatusCode:H9,kWebSocket:k,NOOP:X8}=H1(),{EventTarget:{addEventListener:T9,removeEventListener:U9}}=J8(),{format:q9,parse:C9}=h$(),{toBuffer:B9}=$0(),M8=Symbol("kAborted"),d$=[8,13],U1=["CONNECTING","OPEN","CLOSING","CLOSED"],g9=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class D extends J9{constructor($,I,N){super();if(this._binaryType=x8[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=u0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=D.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,I===void 0)I=[];else if(!Array.isArray(I))if(typeof I==="object"&&I!==null)N=I,I=[];else I=[I];j8(this,$,I,N)}else this._autoPong=N.autoPong,this._closeTimeout=N.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!x8.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,I,N){let G=new M9({allowSynchronousEvents:N.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:N.maxPayload,skipUTF8Validation:N.skipUTF8Validation}),J=new j9($,this._extensions,N.generateMask);if(this._receiver=G,this._sender=J,this._socket=$,G[k]=this,J[k]=this,$[k]=this,G.on("conclude",_9),G.on("drain",V9),G.on("error",f9),G.on("message",A9),G.on("ping",P9),G.on("pong",F9),J.onerror=W9,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(I.length>0)$.unshift(I);$.on("close",R8),$.on("data",w0),$.on("end",S8),$.on("error",H8),this._readyState=D.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=D.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[D1.extensionName])this._extensions[D1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=D.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,I){if(this.readyState===D.CLOSED)return;if(this.readyState===D.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===D.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=D.CLOSING,this._sender.close($,I,!this._isServer,(N)=>{if(N)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),Y8(this)}pause(){if(this.readyState===D.CONNECTING||this.readyState===D.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,I,N){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=I=void 0;else if(typeof I==="function")N=I,I=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){p$(this,$,N);return}if(I===void 0)I=!this._isServer;this._sender.ping($||u0,I,N)}pong($,I,N){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")N=$,$=I=void 0;else if(typeof I==="function")N=I,I=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){p$(this,$,N);return}if(I===void 0)I=!this._isServer;this._sender.pong($||u0,I,N)}resume(){if(this.readyState===D.CONNECTING||this.readyState===D.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,I,N){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof I==="function")N=I,I={};if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){p$(this,$,N);return}let G={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...I};if(!this._extensions[D1.extensionName])G.compress=!1;this._sender.send($||u0,G,N)}terminate(){if(this.readyState===D.CLOSED)return;if(this.readyState===D.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=D.CLOSING,this._socket.destroy()}}Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:U1.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:U1.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:U1.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:U1.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:U1.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:U1.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:U1.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:U1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(D.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(D.prototype,`on${$}`,{enumerable:!0,get(){for(let I of this.listeners($))if(I[c$])return I[S9];return null},set(I){for(let N of this.listeners($))if(N[c$]){this.removeListener($,N);break}if(typeof I!=="function")return;this.addEventListener($,I,{[c$]:!0})}})});D.prototype.addEventListener=T9;D.prototype.removeEventListener=U9;T8.exports=D;function j8($,I,N,G){let J={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Y9,protocolVersion:d$[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...G,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=J.autoPong,$._closeTimeout=J.closeTimeout,!d$.includes(J.protocolVersion))throw RangeError(`Unsupported protocol version: ${J.protocolVersion} (supported versions: ${d$.join(", ")})`);let Z;if(I instanceof n$)Z=I;else try{Z=new n$(I)}catch(K){throw SyntaxError(`Invalid URL: ${I}`)}if(Z.protocol==="http:")Z.protocol="ws:";else if(Z.protocol==="https:")Z.protocol="wss:";$._url=Z.href;let z=Z.protocol==="wss:",x=Z.protocol==="ws+unix:",Q;if(Z.protocol!=="ws:"&&!z&&!x)Q=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(x&&!Z.pathname)Q="The URL's pathname is empty";else if(Z.hash)Q="The URL contains a fragment identifier";if(Q){let K=SyntaxError(Q);if($._redirects===0)throw K;else{v0($,K);return}}let X=z?443:80,j=Q9(16).toString("base64"),M=z?Z9.request:x9.request,R=new Set,S;if(J.createConnection=J.createConnection||(z?D9:L9),J.defaultPort=J.defaultPort||X,J.port=Z.port||X,J.host=Z.hostname.startsWith("[")?Z.hostname.slice(1,-1):Z.hostname,J.headers={...J.headers,"Sec-WebSocket-Version":J.protocolVersion,"Sec-WebSocket-Key":j,Connection:"Upgrade",Upgrade:"websocket"},J.path=Z.pathname+Z.search,J.timeout=J.handshakeTimeout,J.perMessageDeflate)S=new D1(J.perMessageDeflate!==!0?J.perMessageDeflate:{},!1,J.maxPayload),J.headers["Sec-WebSocket-Extensions"]=q9({[D1.extensionName]:S.offer()});if(N.length){for(let K of N){if(typeof K!=="string"||!g9.test(K)||R.has(K))throw SyntaxError("An invalid or duplicated subprotocol was specified");R.add(K)}J.headers["Sec-WebSocket-Protocol"]=N.join(",")}if(J.origin)if(J.protocolVersion<13)J.headers["Sec-WebSocket-Origin"]=J.origin;else J.headers.Origin=J.origin;if(Z.username||Z.password)J.auth=`${Z.username}:${Z.password}`;if(x){let K=J.path.split(":");J.socketPath=K[0],J.path=K[1]}let Y;if(J.followRedirects){if($._redirects===0){$._originalIpc=x,$._originalSecure=z,$._originalHostOrSocketPath=x?J.socketPath:Z.host;let K=G&&G.headers;if(G={...G,headers:{}},K)for(let[T,C]of Object.entries(K))G.headers[T.toLowerCase()]=C}else if($.listenerCount("redirect")===0){let K=x?$._originalIpc?J.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:Z.host===$._originalHostOrSocketPath;if(!K||$._originalSecure&&!z){if(delete J.headers.authorization,delete J.headers.cookie,!K)delete J.headers.host;J.auth=void 0}}if(J.auth&&!G.headers.authorization)G.headers.authorization="Basic "+Buffer.from(J.auth).toString("base64");if(Y=$._req=M(J),$._redirects)$.emit("redirect",$.url,Y)}else Y=$._req=M(J);if(J.timeout)Y.on("timeout",()=>{r($,Y,"Opening handshake has timed out")});if(Y.on("error",(K)=>{if(Y===null||Y[M8])return;Y=$._req=null,v0($,K)}),Y.on("response",(K)=>{let T=K.headers.location,C=K.statusCode;if(T&&J.followRedirects&&C>=300&&C<400){if(++$._redirects>J.maxRedirects){r($,Y,"Maximum redirects exceeded");return}Y.abort();let U;try{U=new n$(T,I)}catch(B){let _=SyntaxError(`Invalid URL: ${T}`);v0($,_);return}j8($,U,N,G)}else if(!$.emit("unexpected-response",Y,K))r($,Y,`Unexpected server response: ${K.statusCode}`)}),Y.on("upgrade",(K,T,C)=>{if($.emit("upgrade",K),$.readyState!==D.CONNECTING)return;Y=$._req=null;let U=K.headers.upgrade;if(U===void 0||U.toLowerCase()!=="websocket"){r($,T,"Invalid Upgrade header");return}let B=X9("sha1").update(j+R9).digest("base64");if(K.headers["sec-websocket-accept"]!==B){r($,T,"Invalid Sec-WebSocket-Accept header");return}let _=K.headers["sec-websocket-protocol"],L;if(_!==void 0){if(!R.size)L="Server sent a subprotocol but none was requested";else if(!R.has(_))L="Server sent an invalid subprotocol"}else if(R.size)L="Server sent no subprotocol";if(L){r($,T,L);return}if(_)$._protocol=_;let f=K.headers["sec-websocket-extensions"];if(f!==void 0){if(!S){r($,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let q;try{q=C9(f)}catch(b){r($,T,"Invalid Sec-WebSocket-Extensions header");return}let g=Object.keys(q);if(g.length!==1||g[0]!==D1.extensionName){r($,T,"Server indicated an extension that was not requested");return}try{S.accept(q[D1.extensionName])}catch(b){r($,T,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[D1.extensionName]=S}$.setSocket(T,C,{allowSynchronousEvents:J.allowSynchronousEvents,generateMask:J.generateMask,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation})}),J.finishRequest)J.finishRequest(Y,$);else Y.end()}function v0($,I){$._readyState=D.CLOSING,$._errorEmitted=!0,$.emit("error",I),$.emitClose()}function L9($){return $.path=$.socketPath,Q8.connect($)}function D9($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=Q8.isIP($.host)?"":$.host;return z9.connect($)}function r($,I,N){$._readyState=D.CLOSING;let G=Error(N);if(Error.captureStackTrace(G,r),I.setHeader){if(I[M8]=!0,I.abort(),I.socket&&!I.socket.destroyed)I.socket.destroy();process.nextTick(v0,$,G)}else I.destroy(G),I.once("error",$.emit.bind($,"error")),I.once("close",$.emitClose.bind($))}function p$($,I,N){if(I){let G=K9(I)?I.size:B9(I).length;if($._socket)$._sender._bufferedBytes+=G;else $._bufferedAmount+=G}if(N){let G=Error(`WebSocket is not open: readyState ${$.readyState} (${U1[$.readyState]})`);process.nextTick(N,G)}}function _9($,I){let N=this[k];if(N._closeFrameReceived=!0,N._closeMessage=I,N._closeCode=$,N._socket[k]===void 0)return;if(N._socket.removeListener("data",w0),process.nextTick(K8,N._socket),$===1005)N.close();else N.close($,I)}function V9(){let $=this[k];if(!$.isPaused)$._socket.resume()}function f9($){let I=this[k];if(I._socket[k]!==void 0)I._socket.removeListener("data",w0),process.nextTick(K8,I._socket),I.close($[H9]);if(!I._errorEmitted)I._errorEmitted=!0,I.emit("error",$)}function z8(){this[k].emitClose()}function A9($,I){this[k].emit("message",$,I)}function P9($){let I=this[k];if(I._autoPong)I.pong($,!this._isServer,X8);I.emit("ping",$)}function F9($){this[k].emit("pong",$)}function K8($){$.resume()}function W9($){let I=this[k];if(I.readyState===D.CLOSED)return;if(I.readyState===D.OPEN)I._readyState=D.CLOSING,Y8(I);if(this._socket.end(),!I._errorEmitted)I._errorEmitted=!0,I.emit("error",$)}function Y8($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function R8(){let $=this[k];if(this.removeListener("close",R8),this.removeListener("data",w0),this.removeListener("end",S8),$._readyState=D.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let I=this.read(this._readableState.length);$._receiver.write(I)}if($._receiver.end(),this[k]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",z8),$._receiver.on("finish",z8)}function w0($){if(!this[k]._receiver.write($))this.pause()}function S8(){let $=this[k];$._readyState=D.CLOSING,$._receiver.end(),this.end()}function H8(){let $=this[k];if(this.removeListener("error",H8),this.on("error",X8),$)$._readyState=D.CLOSING,this.destroy()}});var B8=v((m7,C8)=>{var b7=b0(),{Duplex:O9}=O("stream");function U8($){$.emit("close")}function y9(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function q8($){if(this.removeListener("error",q8),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function E9($,I){let N=!0,G=new O9({...I,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(Z,z){let x=!z&&G._readableState.objectMode?Z.toString():Z;if(!G.push(x))$.pause()}),$.once("error",function(Z){if(G.destroyed)return;N=!1,G.destroy(Z)}),$.once("close",function(){if(G.destroyed)return;G.push(null)}),G._destroy=function(J,Z){if($.readyState===$.CLOSED){Z(J),process.nextTick(U8,G);return}let z=!1;if($.once("error",function(Q){z=!0,Z(Q)}),$.once("close",function(){if(!z)Z(J);process.nextTick(U8,G)}),N)$.terminate()},G._final=function(J){if($.readyState===$.CONNECTING){$.once("open",function(){G._final(J)});return}if($._socket===null)return;if($._socket._writableState.finished){if(J(),G._readableState.endEmitted)G.destroy()}else $._socket.once("finish",function(){J()}),$.close()},G._read=function(){if($.isPaused)$.resume()},G._write=function(J,Z,z){if($.readyState===$.CONNECTING){$.once("open",function(){G._write(J,Z,z)});return}$.send(J,z)},G.on("end",y9),G.on("error",q8),G}C8.exports=E9});var L8=v((i7,g8)=>{var{tokenChars:l9}=i1();function u9($){let I=new Set,N=-1,G=-1,J=0;for(J;J<$.length;J++){let z=$.charCodeAt(J);if(G===-1&&l9[z]===1){if(N===-1)N=J}else if(J!==0&&(z===32||z===9)){if(G===-1&&N!==-1)G=J}else if(z===44){if(N===-1)throw SyntaxError(`Unexpected character at index ${J}`);if(G===-1)G=J;let x=$.slice(N,G);if(I.has(x))throw SyntaxError(`The "${x}" subprotocol is duplicated`);I.add(x),N=G=-1}else throw SyntaxError(`Unexpected character at index ${J}`)}if(N===-1||G!==-1)throw SyntaxError("Unexpected end of input");let Z=$.slice(N,J);if(I.has(Z))throw SyntaxError(`The "${Z}" subprotocol is duplicated`);return I.add(Z),I}g8.exports={parse:u9}});var A8=v((h7,f8)=>{var v9=O("events"),m0=O("http"),{Duplex:k7}=O("stream"),{createHash:w9}=O("crypto"),D8=h$(),O1=N0(),b9=L8(),m9=b0(),{CLOSE_TIMEOUT:i9,GUID:k9,kWebSocket:h9}=H1(),n9=/^[+/0-9A-Za-z]{22}==$/;class V8 extends v9{constructor($,I){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:i9,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:m9,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=m0.createServer((N,G)=>{let J=m0.STATUS_CODES[426];G.writeHead(426,{"Content-Length":J.length,"Content-Type":"text/plain"}),G.end(J)}),this._server.listen($.port,$.host,$.backlog,I);else if($.server)this._server=$.server;if(this._server){let N=this.emit.bind(this,"connection");this._removeListeners=c9(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(G,J,Z)=>{this.handleUpgrade(G,J,Z,N)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(x0,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(x0,this);else this._shouldEmitClose=!0;else process.nextTick(x0,this)}else{let I=this._server;this._removeListeners(),this._removeListeners=this._server=null,I.close(()=>{x0(this)})}}shouldHandle($){if(this.options.path){let I=$.url.indexOf("?");if((I!==-1?$.url.slice(0,I):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,I,N,G){I.on("error",_8);let J=$.headers["sec-websocket-key"],Z=$.headers.upgrade,z=+$.headers["sec-websocket-version"];if($.method!=="GET"){y1(this,$,I,405,"Invalid HTTP method");return}if(Z===void 0||Z.toLowerCase()!=="websocket"){y1(this,$,I,400,"Invalid Upgrade header");return}if(J===void 0||!n9.test(J)){y1(this,$,I,400,"Missing or invalid Sec-WebSocket-Key header");return}if(z!==13&&z!==8){y1(this,$,I,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){z0(I,400);return}let x=$.headers["sec-websocket-protocol"],Q=new Set;if(x!==void 0)try{Q=b9.parse(x)}catch(M){y1(this,$,I,400,"Invalid Sec-WebSocket-Protocol header");return}let X=$.headers["sec-websocket-extensions"],j={};if(this.options.perMessageDeflate&&X!==void 0){let M=new O1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let R=D8.parse(X);if(R[O1.extensionName])M.accept(R[O1.extensionName]),j[O1.extensionName]=M}catch(R){y1(this,$,I,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let M={origin:$.headers[`${z===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(M,(R,S,Y,K)=>{if(!R)return z0(I,S||401,Y,K);this.completeUpgrade(j,J,Q,$,I,N,G)});return}if(!this.options.verifyClient(M))return z0(I,401)}this.completeUpgrade(j,J,Q,$,I,N,G)}completeUpgrade($,I,N,G,J,Z,z){if(!J.readable||!J.writable)return J.destroy();if(J[h9])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return z0(J,503);let Q=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${w9("sha1").update(I+k9).digest("base64")}`],X=new this.options.WebSocket(null,void 0,this.options);if(N.size){let j=this.options.handleProtocols?this.options.handleProtocols(N,G):N.values().next().value;if(j)Q.push(`Sec-WebSocket-Protocol: ${j}`),X._protocol=j}if($[O1.extensionName]){let j=$[O1.extensionName].params,M=D8.format({[O1.extensionName]:[j]});Q.push(`Sec-WebSocket-Extensions: ${M}`),X._extensions=$}if(this.emit("headers",Q,G),J.write(Q.concat(`\r
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
+ 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})}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
- `)),J.removeListener("error",_8),X.setSocket(J,Z,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(X),X.on("close",()=>{if(this.clients.delete(X),this._shouldEmitClose&&!this.clients.size)process.nextTick(x0,this)});z(X,G)}}f8.exports=V8;function c9($,I){for(let N of Object.keys(I))$.on(N,I[N]);return function(){for(let G of Object.keys(I))$.removeListener(G,I[G])}}function x0($){$._state=2,$.emit("close")}function _8(){this.destroy()}function z0($,I,N,G){N=N||m0.STATUS_CODES[I],G={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(N),...G},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${I} ${m0.STATUS_CODES[I]}\r
26
- `+Object.keys(G).map((J)=>`${J}: ${G[J]}`).join(`\r
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
+ `+Object.keys(G).map((Z)=>`${Z}: ${G[Z]}`).join(`\r
27
27
  `)+`\r
28
28
  \r
29
- `+N)}function y1($,I,N,G,J,Z){if($.listenerCount("wsClientError")){let z=Error(J);Error.captureStackTrace(z,y1),$.emit("wsClientError",z,N,I)}else z0(N,G,J,Z)}});var x1=v((c7,r$)=>{var k0=process||{},P8=k0.argv||[],i0=k0.env||{},o9=!(!!i0.NO_COLOR||P8.includes("--no-color"))&&(!!i0.FORCE_COLOR||P8.includes("--color")||k0.platform==="win32"||(k0.stdout||{}).isTTY&&i0.TERM!=="dumb"||!!i0.CI),r9=($,I,N=$)=>(G)=>{let J=""+G,Z=J.indexOf(I,$.length);return~Z?$+a9(J,I,N,Z)+I:$+J+I},a9=($,I,N,G)=>{let J="",Z=0;do J+=$.substring(Z,G)+N,Z=G+I.length,G=$.indexOf(I,Z);while(~G);return J+$.substring(Z)},F8=($=o9)=>{let I=$?r9:()=>String;return{isColorSupported:$,reset:I("\x1B[0m","\x1B[0m"),bold:I("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:I("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:I("\x1B[3m","\x1B[23m"),underline:I("\x1B[4m","\x1B[24m"),inverse:I("\x1B[7m","\x1B[27m"),hidden:I("\x1B[8m","\x1B[28m"),strikethrough:I("\x1B[9m","\x1B[29m"),black:I("\x1B[30m","\x1B[39m"),red:I("\x1B[31m","\x1B[39m"),green:I("\x1B[32m","\x1B[39m"),yellow:I("\x1B[33m","\x1B[39m"),blue:I("\x1B[34m","\x1B[39m"),magenta:I("\x1B[35m","\x1B[39m"),cyan:I("\x1B[36m","\x1B[39m"),white:I("\x1B[37m","\x1B[39m"),gray:I("\x1B[90m","\x1B[39m"),bgBlack:I("\x1B[40m","\x1B[49m"),bgRed:I("\x1B[41m","\x1B[49m"),bgGreen:I("\x1B[42m","\x1B[49m"),bgYellow:I("\x1B[43m","\x1B[49m"),bgBlue:I("\x1B[44m","\x1B[49m"),bgMagenta:I("\x1B[45m","\x1B[49m"),bgCyan:I("\x1B[46m","\x1B[49m"),bgWhite:I("\x1B[47m","\x1B[49m"),blackBright:I("\x1B[90m","\x1B[39m"),redBright:I("\x1B[91m","\x1B[39m"),greenBright:I("\x1B[92m","\x1B[39m"),yellowBright:I("\x1B[93m","\x1B[39m"),blueBright:I("\x1B[94m","\x1B[39m"),magentaBright:I("\x1B[95m","\x1B[39m"),cyanBright:I("\x1B[96m","\x1B[39m"),whiteBright:I("\x1B[97m","\x1B[39m"),bgBlackBright:I("\x1B[100m","\x1B[49m"),bgRedBright:I("\x1B[101m","\x1B[49m"),bgGreenBright:I("\x1B[102m","\x1B[49m"),bgYellowBright:I("\x1B[103m","\x1B[49m"),bgBlueBright:I("\x1B[104m","\x1B[49m"),bgMagentaBright:I("\x1B[105m","\x1B[49m"),bgCyanBright:I("\x1B[106m","\x1B[49m"),bgWhiteBright:I("\x1B[107m","\x1B[49m")}};r$.exports=F8();r$.exports.createColors=F8});var G2=v((NG,u8)=>{var N2={to($,I){if(!I)return`\x1B[${$+1}G`;return`\x1B[${I+1};${$+1}H`},move($,I){let N="";if($<0)N+=`\x1B[${-$}D`;else if($>0)N+=`\x1B[${$}C`;if(I<0)N+=`\x1B[${-I}A`;else if(I>0)N+=`\x1B[${I}B`;return N},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},_I={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},VI={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let I="";for(let N=0;N<$;N++)I+=this.line+(N<$-1?N2.up():"");if($)I+=N2.left;return I}};u8.exports={cursor:N2,scroll:_I,erase:VI,beep:"\x07"}});var I4=i($4(),1),{program:I7,createCommand:N7,createArgument:G7,createOption:J7,CommanderError:Z7,InvalidArgumentError:x7,InvalidOptionArgumentError:z7,Command:N4,Argument:Q7,Option:X7,Help:M7}=I4.default;import{stat as M6}from"fs";import{stat as j6,readdir as K6}from"fs/promises";import{EventEmitter as Y6}from"events";import*as V from"path";import{stat as l5,lstat as G4,readdir as u5,realpath as v5}from"node:fs/promises";import{Readable as w5}from"node:stream";import{resolve as J4,relative as b5,join as m5,sep as i5}from"node:path";var o={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},_$={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:o.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(_$);var Q4="READDIRP_RECURSIVE_ERROR",k5=new Set(["ENOENT","EPERM","EACCES","ELOOP",Q4]),Z4=[o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE],h5=new Set([o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE]),n5=new Set([o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE]),c5=($)=>k5.has($.code),d5=process.platform==="win32",x4=($)=>!0,z4=($)=>{if($===void 0)return x4;if(typeof $==="function")return $;if(typeof $==="string"){let I=$.trim();return(N)=>N.basename===I}if(Array.isArray($)){let I=$.map((N)=>N.trim());return(N)=>I.some((G)=>N.basename===G)}return x4};class X4 extends w5{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let I={..._$,...$},{root:N,type:G}=I;this._fileFilter=z4(I.fileFilter),this._directoryFilter=z4(I.directoryFilter);let J=I.lstat?G4:l5;if(d5)this._stat=(Z)=>J(Z,{bigint:!0});else this._stat=J;this._maxDepth=I.depth??_$.depth,this._wantsDir=G?h5.has(G):!1,this._wantsFile=G?n5.has(G):!1,this._wantsEverything=G===o.EVERYTHING_TYPE,this._root=J4(N),this._isDirent=!I.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(N,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let I=this.parent,N=I&&I.files;if(N&&N.length>0){let{path:G,depth:J}=I,Z=N.splice(0,$).map((x)=>this._formatEntry(x,G)),z=await Promise.all(Z);for(let x of z){if(!x)continue;if(this.destroyed)return;let Q=await this._getEntryType(x);if(Q==="directory"&&this._directoryFilter(x)){if(J<=this._maxDepth)this.parents.push(this._exploreDir(x.fullPath,J+1));if(this._wantsDir)this.push(x),$--}else if((Q==="file"||this._includeAsFile(x))&&this._fileFilter(x)){if(this._wantsFile)this.push(x),$--}}}else{let G=this.parents.pop();if(!G){this.push(null);break}if(this.parent=await G,this.destroyed)return}}}catch(I){this.destroy(I)}finally{this.reading=!1}}async _exploreDir($,I){let N;try{N=await u5($,this._rdOptions)}catch(G){this._onError(G)}return{files:N,depth:I,path:$}}async _formatEntry($,I){let N,G=this._isDirent?$.name:$;try{let J=J4(m5(I,G));N={path:b5(this._root,J),fullPath:J,basename:G},N[this._statsProp]=this._isDirent?$:await this._stat(J)}catch(J){this._onError(J);return}return N}_onError($){if(c5($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let I=$[this._statsProp];if(I.isFile())return"file";if(I.isDirectory())return"directory";if(I&&I.isSymbolicLink()){let N=$.fullPath;try{let G=await v5(N),J=await G4(G);if(J.isFile())return"file";if(J.isDirectory()){let Z=G.length;if(N.startsWith(G)&&N.substr(Z,1)===i5){let z=Error(`Circular symlink detected: "${N}" points to "${G}"`);return z.code=Q4,this._onError(z)}return"directory"}}catch(G){return this._onError(G),""}}}_includeAsFile($){let I=$&&$[this._statsProp];return I&&this._wantsEverything&&!I.isDirectory()}}function M4($,I={}){let N=I.entryType||I.type;if(N==="both")N=o.FILE_DIR_TYPE;if(N)I.type=N;if(!$)throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");else if(typeof $!=="string")throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(N&&!Z4.includes(N))throw Error(`readdirp: Invalid type passed. Use one of ${Z4.join(", ")}`);return I.root=$,new X4(I)}import{watchFile as p5,unwatchFile as j4,watch as s5}from"fs";import{open as o5,stat as Y4,lstat as r5,realpath as V$}from"fs/promises";import*as u from"path";import{type as a5}from"os";var t5="data",P$="end",R4="close",_0=()=>{};var V0=process.platform,F$=V0==="win32",e5=V0==="darwin",$6=V0==="linux",I6=V0==="freebsd",S4=a5()==="OS400",y={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},J1=y,N6="watch",G6={lstat:r5,stat:Y4},P1="listeners",g0="errHandlers",w1="rawEmitters",J6=[P1,g0,w1],Z6=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),x6=($)=>Z6.has(u.extname($).slice(1).toLowerCase()),A$=($,I)=>{if($ instanceof Set)$.forEach(I);else I($)},t1=($,I,N)=>{let G=$[I];if(!(G instanceof Set))$[I]=G=new Set([G]);G.add(N)},z6=($)=>(I)=>{let N=$[I];if(N instanceof Set)N.clear();else delete $[I]},e1=($,I,N)=>{let G=$[I];if(G instanceof Set)G.delete(N);else if(G===N)delete $[I]},H4=($)=>$ instanceof Set?$.size===0:!$,L0=new Map;function K4($,I,N,G,J){let Z=(z,x)=>{if(N($),J(z,x,{watchedPath:$}),x&&$!==x)D0(u.resolve($,x),P1,u.join($,x))};try{return s5($,{persistent:I.persistent},Z)}catch(z){G(z);return}}var D0=($,I,N,G,J)=>{let Z=L0.get($);if(!Z)return;A$(Z[I],(z)=>{z(N,G,J)})},Q6=($,I,N,G)=>{let{listener:J,errHandler:Z,rawEmitter:z}=G,x=L0.get(I),Q;if(!N.persistent){if(Q=K4($,N,J,Z,z),!Q)return;return Q.close.bind(Q)}if(x)t1(x,P1,J),t1(x,g0,Z),t1(x,w1,z);else{if(Q=K4($,N,D0.bind(null,I,P1),Z,D0.bind(null,I,w1)),!Q)return;Q.on(J1.ERROR,async(X)=>{let j=D0.bind(null,I,g0);if(x)x.watcherUnusable=!0;if(F$&&X.code==="EPERM")try{await(await o5($,"r")).close(),j(X)}catch(M){}else j(X)}),x={listeners:J,errHandlers:Z,rawEmitters:z,watcher:Q},L0.set(I,x)}return()=>{if(e1(x,P1,J),e1(x,g0,Z),e1(x,w1,z),H4(x.listeners))x.watcher.close(),L0.delete(I),J6.forEach(z6(x)),x.watcher=void 0,Object.freeze(x)}},f$=new Map,X6=($,I,N,G)=>{let{listener:J,rawEmitter:Z}=G,z=f$.get(I),x=z&&z.options;if(x&&(x.persistent<N.persistent||x.interval>N.interval))j4(I),z=void 0;if(z)t1(z,P1,J),t1(z,w1,Z);else z={listeners:J,rawEmitters:Z,options:N,watcher:p5(I,N,(Q,X)=>{A$(z.rawEmitters,(M)=>{M(J1.CHANGE,I,{curr:Q,prev:X})});let j=Q.mtimeMs;if(Q.size!==X.size||j>X.mtimeMs||j===0)A$(z.listeners,(M)=>M($,Q))})},f$.set(I,z);return()=>{if(e1(z,P1,J),e1(z,w1,Z),H4(z.listeners))f$.delete(I),j4(I),z.options=z.watcher=void 0,Object.freeze(z)}};class W${constructor($){this.fsw=$,this._boundHandleError=(I)=>$._handleError(I)}_watchWithNodeFs($,I){let N=this.fsw.options,G=u.dirname($),J=u.basename($);this.fsw._getWatchedDir(G).add(J);let z=u.resolve($),x={persistent:N.persistent};if(!I)I=_0;let Q;if(N.usePolling){let X=N.interval!==N.binaryInterval;x.interval=X&&x6(J)?N.binaryInterval:N.interval,Q=X6($,z,x,{listener:I,rawEmitter:this.fsw._emitRaw})}else Q=Q6($,z,x,{listener:I,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return Q}_handleFile($,I,N){if(this.fsw.closed)return;let G=u.dirname($),J=u.basename($),Z=this.fsw._getWatchedDir(G),z=I;if(Z.has(J))return;let x=async(X,j)=>{if(!this.fsw._throttle(N6,$,5))return;if(!j||j.mtimeMs===0)try{let M=await Y4($);if(this.fsw.closed)return;let{atimeMs:R,mtimeMs:S}=M;if(!R||R<=S||S!==z.mtimeMs)this.fsw._emit(J1.CHANGE,$,M);if((e5||$6||I6)&&z.ino!==M.ino){this.fsw._closeFile(X),z=M;let Y=this._watchWithNodeFs($,x);if(Y)this.fsw._addPathCloser(X,Y)}else z=M}catch(M){this.fsw._remove(G,J)}else if(Z.has(J)){let{atimeMs:M,mtimeMs:R}=j;if(!M||M<=R||R!==z.mtimeMs)this.fsw._emit(J1.CHANGE,$,j);z=j}},Q=this._watchWithNodeFs($,x);if(!(N&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(J1.ADD,$,0))return;this.fsw._emit(J1.ADD,$,I)}return Q}async _handleSymlink($,I,N,G){if(this.fsw.closed)return;let J=$.fullPath,Z=this.fsw._getWatchedDir(I);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let z;try{z=await V$(N)}catch(x){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(Z.has(G)){if(this.fsw._symlinkPaths.get(J)!==z)this.fsw._symlinkPaths.set(J,z),this.fsw._emit(J1.CHANGE,N,$.stats)}else Z.add(G),this.fsw._symlinkPaths.set(J,z),this.fsw._emit(J1.ADD,N,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(J))return!0;this.fsw._symlinkPaths.set(J,!0)}_handleRead($,I,N,G,J,Z,z){if($=u.join($,""),z=this.fsw._throttle("readdir",$,1000),!z)return;let x=this.fsw._getWatchedDir(N.path),Q=new Set,X=this.fsw._readdirp($,{fileFilter:(j)=>N.filterPath(j),directoryFilter:(j)=>N.filterDir(j)});if(!X)return;return X.on(t5,async(j)=>{if(this.fsw.closed){X=void 0;return}let M=j.path,R=u.join($,M);if(Q.add(M),j.stats.isSymbolicLink()&&await this._handleSymlink(j,$,R,M))return;if(this.fsw.closed){X=void 0;return}if(M===G||!G&&!x.has(M))this.fsw._incrReadyCount(),R=u.join(J,u.relative(J,R)),this._addToNodeFs(R,I,N,Z+1)}).on(J1.ERROR,this._boundHandleError),new Promise((j,M)=>{if(!X)return M();X.once(P$,()=>{if(this.fsw.closed){X=void 0;return}let R=z?z.clear():!1;if(j(void 0),x.getChildren().filter((S)=>{return S!==$&&!Q.has(S)}).forEach((S)=>{this.fsw._remove($,S)}),X=void 0,R)this._handleRead($,!1,N,G,J,Z,z)})})}async _handleDir($,I,N,G,J,Z,z){let x=this.fsw._getWatchedDir(u.dirname($)),Q=x.has(u.basename($));if(!(N&&this.fsw.options.ignoreInitial)&&!J&&!Q)this.fsw._emit(J1.ADD_DIR,$,I);x.add(u.basename($)),this.fsw._getWatchedDir($);let X,j,M=this.fsw.options.depth;if((M==null||G<=M)&&!this.fsw._symlinkPaths.has(z)){if(!J){if(await this._handleRead($,N,Z,J,$,G,X),this.fsw.closed)return}j=this._watchWithNodeFs($,(R,S)=>{if(S&&S.mtimeMs===0)return;this._handleRead(R,!1,Z,J,$,G,X)})}return j}async _addToNodeFs($,I,N,G,J){let Z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return Z(),!1;let z=this.fsw._getWatchHelpers($);if(N)z.filterPath=(x)=>N.filterPath(x),z.filterDir=(x)=>N.filterDir(x);try{let x=await G6[z.statMethod](z.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(z.watchPath,x))return Z(),!1;let Q=this.fsw.options.followSymlinks,X;if(x.isDirectory()){let j=u.resolve($),M=Q?await V$($):$;if(this.fsw.closed)return;if(X=await this._handleDir(z.watchPath,x,I,G,J,z,M),this.fsw.closed)return;if(j!==M&&M!==void 0)this.fsw._symlinkPaths.set(j,M)}else if(x.isSymbolicLink()){let j=Q?await V$($):$;if(this.fsw.closed)return;let M=u.dirname(z.watchPath);if(this.fsw._getWatchedDir(M).add(z.watchPath),this.fsw._emit(J1.ADD,z.watchPath,x),X=await this._handleDir(M,x,I,G,$,z,j),this.fsw.closed)return;if(j!==void 0)this.fsw._symlinkPaths.set(u.resolve($),j)}else X=this._handleFile(z.watchPath,x,I);if(Z(),X)this.fsw._addPathCloser($,X);return!1}catch(x){if(this.fsw._handleError(x))return Z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var O$="/",R6="//",g4=".",S6="..",H6="string",T6=/\\/g,T4=/\/\//,U6=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,q6=/^\.[/\\]/;function f0($){return Array.isArray($)?$:[$]}var y$=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function C6($){if(typeof $==="function")return $;if(typeof $==="string")return(I)=>$===I;if($ instanceof RegExp)return(I)=>$.test(I);if(typeof $==="object"&&$!==null)return(I)=>{if($.path===I)return!0;if($.recursive){let N=V.relative($.path,I);if(!N)return!1;return!N.startsWith("..")&&!V.isAbsolute(N)}return!1};return()=>!1}function B6($){if(typeof $!=="string")throw Error("string expected");$=V.normalize($),$=$.replace(/\\/g,"/");let I=!1;if($.startsWith("//"))I=!0;let N=/\/\//;while($.match(N))$=$.replace(N,"/");if(I)$="/"+$;return $}function U4($,I,N){let G=B6(I);for(let J=0;J<$.length;J++){let Z=$[J];if(Z(G,N))return!0}return!1}function g6($,I){if($==null)throw TypeError("anymatch: specify first argument");let G=f0($).map((J)=>C6(J));if(I==null)return(J,Z)=>{return U4(G,J,Z)};return U4(G,I)}var q4=($)=>{let I=f0($).flat();if(!I.every((N)=>typeof N===H6))throw TypeError(`Non-string provided as watch path: ${I}`);return I.map(L4)},C4=($)=>{let I=$.replace(T6,O$),N=!1;if(I.startsWith(R6))N=!0;while(I.match(T4))I=I.replace(T4,O$);if(N)I=O$+I;return I},L4=($)=>C4(V.normalize(C4($))),B4=($="")=>(I)=>{if(typeof I==="string")return L4(V.isAbsolute(I)?I:V.join($,I));else return I},L6=($,I)=>{if(V.isAbsolute($))return $;return V.join(I,$)},D6=Object.freeze(new Set);class D4{constructor($,I){this.path=$,this._removeWatcher=I,this.items=new Set}add($){let{items:I}=this;if(!I)return;if($!==g4&&$!==S6)I.add($)}async remove($){let{items:I}=this;if(!I)return;if(I.delete($),I.size>0)return;let N=this.path;try{await K6(N)}catch(G){if(this._removeWatcher)this._removeWatcher(V.dirname(N),V.basename(N))}}has($){let{items:I}=this;if(!I)return;return I.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=_0,this.items=D6,Object.freeze(this)}}var _6="stat",V6="lstat";class _4{constructor($,I,N){this.fsw=N;let G=$;this.path=$=$.replace(q6,""),this.watchPath=G,this.fullWatchPath=V.resolve(G),this.dirParts=[],this.dirParts.forEach((J)=>{if(J.length>1)J.pop()}),this.followSymlinks=I,this.statMethod=I?_6:V6}entryPath($){return V.join(this.watchPath,V.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:I}=$;if(I&&I.isSymbolicLink())return this.filterDir($);let N=this.entryPath($);return this.fsw._isntIgnored(N,I)&&this.fsw._hasReadPermissions(I)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class V4 extends Y6{constructor($={}){super();this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let I=$.awaitWriteFinish,N={stabilityThreshold:2000,pollInterval:100},G={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?f0($.ignored):f0([]),awaitWriteFinish:I===!0?N:typeof I==="object"?{...N,...I}:!1};if(S4)G.usePolling=!0;if(G.atomic===void 0)G.atomic=!G.usePolling;let J=process.env.CHOKIDAR_USEPOLLING;if(J!==void 0){let x=J.toLowerCase();if(x==="false"||x==="0")G.usePolling=!1;else if(x==="true"||x==="1")G.usePolling=!0;else G.usePolling=!!x}let Z=process.env.CHOKIDAR_INTERVAL;if(Z)G.interval=Number.parseInt(Z,10);let z=0;this._emitReady=()=>{if(z++,z>=this._readyCount)this._emitReady=_0,this._readyEmitted=!0,process.nextTick(()=>this.emit(y.READY))},this._emitRaw=(...x)=>this.emit(y.RAW,...x),this._boundRemove=this._remove.bind(this),this.options=G,this._nodeFsHandler=new W$(this),Object.freeze(G)}_addIgnoredPath($){if(y$($)){for(let I of this._ignoredPaths)if(y$(I)&&I.path===$.path&&I.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let I of this._ignoredPaths)if(y$(I)&&I.path===$)this._ignoredPaths.delete(I)}}add($,I,N){let{cwd:G}=this.options;this.closed=!1,this._closePromise=void 0;let J=q4($);if(G)J=J.map((Z)=>{return L6(Z,G)});if(J.forEach((Z)=>{this._removeIgnoredPath(Z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=J.length,Promise.all(J.map(async(Z)=>{let z=await this._nodeFsHandler._addToNodeFs(Z,!N,void 0,0,I);if(z)this._emitReady();return z})).then((Z)=>{if(this.closed)return;Z.forEach((z)=>{if(z)this.add(V.dirname(z),V.basename(I||z))})}),this}unwatch($){if(this.closed)return this;let I=q4($),{cwd:N}=this.options;return I.forEach((G)=>{if(!V.isAbsolute(G)&&!this._closers.has(G)){if(N)G=V.join(N,G);G=V.resolve(G)}if(this._closePath(G),this._addIgnoredPath(G),this._watched.has(G))this._addIgnoredPath({path:G,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((I)=>I.forEach((N)=>{let G=N();if(G instanceof Promise)$.push(G)})),this._streams.forEach((I)=>I.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((I)=>I.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=$.length?Promise.all($).then(()=>{return}):Promise.resolve(),this._closePromise}getWatched(){let $={};return this._watched.forEach((I,N)=>{let J=(this.options.cwd?V.relative(this.options.cwd,N):N)||g4;$[J]=I.getChildren().sort()}),$}emitWithAll($,I){if(this.emit($,...I),$!==y.ERROR)this.emit(y.ALL,$,...I)}async _emit($,I,N){if(this.closed)return;let G=this.options;if(F$)I=V.normalize(I);if(G.cwd)I=V.relative(G.cwd,I);let J=[I];if(N!=null)J.push(N);let Z=G.awaitWriteFinish,z;if(Z&&(z=this._pendingWrites.get(I)))return z.lastChange=new Date,this;if(G.atomic){if($===y.UNLINK)return this._pendingUnlinks.set(I,[$,...J]),setTimeout(()=>{this._pendingUnlinks.forEach((x,Q)=>{this.emit(...x),this.emit(y.ALL,...x),this._pendingUnlinks.delete(Q)})},typeof G.atomic==="number"?G.atomic:100),this;if($===y.ADD&&this._pendingUnlinks.has(I))$=y.CHANGE,this._pendingUnlinks.delete(I)}if(Z&&($===y.ADD||$===y.CHANGE)&&this._readyEmitted){let x=(Q,X)=>{if(Q)$=y.ERROR,J[0]=Q,this.emitWithAll($,J);else if(X){if(J.length>1)J[1]=X;else J.push(X);this.emitWithAll($,J)}};return this._awaitWriteFinish(I,Z.stabilityThreshold,$,x),this}if($===y.CHANGE){if(!this._throttle(y.CHANGE,I,50))return this}if(G.alwaysStat&&N===void 0&&($===y.ADD||$===y.ADD_DIR||$===y.CHANGE)){let x=G.cwd?V.join(G.cwd,I):I,Q;try{Q=await j6(x)}catch(X){}if(!Q||this.closed)return;J.push(Q)}return this.emitWithAll($,J),this}_handleError($){let I=$&&$.code;if($&&I!=="ENOENT"&&I!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||I!=="EPERM"&&I!=="EACCES"))this.emit(y.ERROR,$);return $||this.closed}_throttle($,I,N){if(!this._throttled.has($))this._throttled.set($,new Map);let G=this._throttled.get($);if(!G)throw Error("invalid throttle");let J=G.get(I);if(J)return J.count++,!1;let Z,z=()=>{let Q=G.get(I),X=Q?Q.count:0;if(G.delete(I),clearTimeout(Z),Q)clearTimeout(Q.timeoutObject);return X};Z=setTimeout(z,N);let x={timeoutObject:Z,clear:z,count:0};return G.set(I,x),x}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,I,N,G){let J=this.options.awaitWriteFinish;if(typeof J!=="object")return;let Z=J.pollInterval,z,x=$;if(this.options.cwd&&!V.isAbsolute($))x=V.join(this.options.cwd,$);let Q=new Date,X=this._pendingWrites;function j(M){M6(x,(R,S)=>{if(R||!X.has($)){if(R&&R.code!=="ENOENT")G(R);return}let Y=Number(new Date);if(M&&S.size!==M.size)X.get($).lastChange=Y;let K=X.get($);if(Y-K.lastChange>=I)X.delete($),G(void 0,S);else z=setTimeout(j,Z,S)})}if(!X.has($))X.set($,{lastChange:Q,cancelWait:()=>{return X.delete($),clearTimeout(z),N}}),z=setTimeout(j,Z)}_isIgnored($,I){if(this.options.atomic&&U6.test($))return!0;if(!this._userIgnored){let{cwd:N}=this.options,J=(this.options.ignored||[]).map(B4(N)),z=[...[...this._ignoredPaths].map(B4(N)),...J];this._userIgnored=g6(z,void 0)}return this._userIgnored($,I)}_isntIgnored($,I){return!this._isIgnored($,I)}_getWatchHelpers($){return new _4($,this.options.followSymlinks,this)}_getWatchedDir($){let I=V.resolve($);if(!this._watched.has(I))this._watched.set(I,new D4(I,this._boundRemove));return this._watched.get(I)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,I,N){let G=V.join($,I),J=V.resolve(G);if(N=N!=null?N:this._watched.has(G)||this._watched.has(J),!this._throttle("remove",G,100))return;if(!N&&this._watched.size===1)this.add($,I,!0);this._getWatchedDir(G).getChildren().forEach((M)=>this._remove(G,M));let x=this._getWatchedDir($),Q=x.has(I);if(x.remove(I),this._symlinkPaths.has(J))this._symlinkPaths.delete(J);let X=G;if(this.options.cwd)X=V.relative(this.options.cwd,G);if(this.options.awaitWriteFinish&&this._pendingWrites.has(X)){if(this._pendingWrites.get(X).cancelWait()===y.ADD)return}this._watched.delete(G),this._watched.delete(J);let j=N?y.UNLINK_DIR:y.UNLINK;if(Q&&!this._isIgnored(G))this._emit(j,G);this._closePath(G)}_closePath($){this._closeFile($);let I=V.dirname($);this._getWatchedDir(I).remove(V.basename($))}_closeFile($){let I=this._closers.get($);if(!I)return;I.forEach((N)=>N()),this._closers.delete($)}_addPathCloser($,I){if(!I)return;let N=this._closers.get($);if(!N)N=[],this._closers.set($,N);N.push(I)}_readdirp($,I){if(this.closed)return;let N={type:y.ALL,alwaysStat:!0,lstat:!0,...I,depth:0},G=M4($,N);return this._streams.add(G),G.once(R4,()=>{G=void 0}),G.once(P$,()=>{if(G)this._streams.delete(G),G=void 0}),G}}function A0($,I={}){let N=new V4(I);return N.add($),N}import{createServer as t9}from"node:http";import{readFileSync as e9,existsSync as $I,readdirSync as Q0,statSync as e$,mkdirSync as II}from"node:fs";import{join as z1,basename as O8}from"node:path";var d9=i(B8(),1),p9=i(b$(),1),s9=i(i$(),1),s$=i(b0(),1),o$=i(A8(),1);var h0=i(x1(),1),W8=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT):9847;function NI(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return z1($,".serena","memories");return z1(process.cwd(),".serena","memories")}function X0($){try{return e9($,"utf-8")}catch{return""}}function GI($){try{let I=Q0($);if(I.includes("orchestrator-session.md"))return z1($,"orchestrator-session.md");let N=I.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:e$(z1($,G)).mtimeMs})).sort((G,J)=>J.mtime-G.mtime);if(N.length>0)return z1($,N[0].name)}catch{}return null}function JI($){let I=GI($);if(!I)return{id:"N/A",status:"UNKNOWN"};let N=X0(I);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||O8(I,".md")||"N/A",J="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))J="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))J="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))J="FAILED";else if(/Step \d+:.*\[/i.test(N))J="RUNNING";return{id:G.trim(),status:J}}function ZI($){let I=X0(z1($,"task-board.md"));if(!I)return[];let N=[],G=I.split(`
30
- `);for(let J of G){if(!J.startsWith("|")||/^\|\s*-+/.test(J))continue;let Z=J.split("|").map((z)=>z.trim()).filter(Boolean);if(Z.length<2||/^agent$/i.test(Z[0]))continue;N.push({agent:Z[0]||"",status:Z[1]||"pending",task:Z[2]||""})}return N}function t$($,I){try{let N=Q0($).filter((Z)=>Z.startsWith(`progress-${I}`)&&Z.endsWith(".md")).sort().reverse();if(N.length===0)return null;let J=X0(z1($,N[0])).match(/turn[:\s]*(\d+)/i);return J?parseInt(J[1],10):null}catch{return null}}function xI($){try{return Q0($).filter((N)=>N.endsWith(".md")&&N!==".gitkeep").map((N)=>({name:N,mtime:e$(z1($,N)).mtimeMs})).sort((N,G)=>G.mtime-N.mtime).slice(0,10).map((N)=>{let G=N.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||N.name.replace(/\.md$/,""),Z=X0(z1($,N.name)).split(`
31
- `).map((x)=>x.trim()).filter((x)=>x&&!x.startsWith("---")&&x.length>3),z="";for(let x=Z.length-1;x>=0;x--){let Q=Z[x];if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(Q)){if(z=Q.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),z.length>5)break}}if(z.length>80)z=z.substring(0,77)+"...";return{agent:G,message:z,file:N.name}}).filter((N)=>N.message)}catch{return[]}}function zI($){let I=[],N=new Set;try{let G=Q0($).filter((J)=>J.endsWith(".md")&&J!==".gitkeep").map((J)=>({name:J,mtime:e$(z1($,J)).mtimeMs})).sort((J,Z)=>Z.mtime-J.mtime);for(let J of G){let Z=X0(z1($,J.name)),z=Z.match(/\*\*Agent\*\*:\s*(.+)/i)||Z.match(/Agent:\s*(.+)/i)||Z.match(/^#+\s*(.+?)\s*Agent/im),x=null;if(z)x=z[1].trim();else if(/_agent|agent_|-agent/i.test(J.name))x=J.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(x&&!N.has(x.toLowerCase())){N.add(x.toLowerCase());let Q="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(Z))Q="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(Z))Q="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(Z))Q="failed";let X=Z.match(/## Task\s*\n+(.+)/i)||Z.match(/\*\*Task\*\*:\s*(.+)/i),j=X?X[1].trim().substring(0,60):"";I.push({agent:x,status:Q,task:j,turn:t$($,x)})}}}catch{}return I}function a$($){let I=JI($),G=ZI($).map((J)=>({...J,turn:t$($,J.agent)}));if(G.length===0)G=zI($);if(G.length===0)try{let J=Q0($).filter((Z)=>Z.startsWith("progress-")&&Z.endsWith(".md"));for(let Z of J){let z=Z.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:z,status:"running",task:"",turn:t$($,z)})}}catch{}return{session:I,agents:G,activity:xI($),memoriesDir:$,updatedAt:new Date().toISOString()}}var QI=`<!DOCTYPE html>
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
+ `,`
39
+ `).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
+ `),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 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
+ `).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=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
+ `);this.output.write(X[z]),this._prevFrame=$,this.output.write(i.cursor.move(0,X.length-z-1));return}else if(J.lines.length>1){if(G<Z)z=G;else{let Q=z-Z;Q>0&&this.output.write(i.cursor.move(0,Q))}this.output.write(i.erase.down());let X=$.split(`
49
+ `).slice(z);this.output.write(X.join(`
50
+ `)),this._prevFrame=$;return}}this.output.write(i.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function 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
+ `,`
55
+ `).split(`
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
+ ${q.default.cyan(D1)}
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
+ `)}
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
+
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
+ ${q.default.gray(D1)} ${$}
71
+
72
+ `)},M0=($,J)=>$.split(`
73
+ `).map((N)=>J(N)).join(`
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
+ ${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(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
+ `).map((Y,H)=>H===0?`${q.default.yellow(D1)} ${q.default.yellow(Y)}`:` ${Y}`).join(`
80
+ `),I=Z.split(`
81
+ `).length,K=M.split(`
82
+ `).length+1;return`${Z}${Q}${e$({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:I+K,style:X}).join(`
83
+ ${Q}`)}
84
+ ${M}
85
+ `}default:{let Q=`${q.default.cyan(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
+ ${Q}`)}
88
+ ${q.default.cyan(D1)}
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
+ ${I}
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
+ `)?$.split(`
103
+ `).map((N)=>J(N)).join(`
104
+ `):J($),c1=($)=>{let J=(N,G)=>{let Z=N.label??String(N.value);switch(G){case"disabled":return`${q.default.gray(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
+ ${Z}
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
+ ${X}`)}
110
+ ${q.default.cyan(D1)}
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
+ ${Q}${Z}
115
+ ${M}${X}
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
+ ${Q}
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
+ `);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 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(`
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(`
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(`
144
+ `),"Recent Commits");if(M.length>0)O(M.join(`
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>
32
152
  <html lang="en">
33
153
  <head>
34
154
  <meta charset="UTF-8">
@@ -85,125 +205,12 @@ Expecting one of '${N.join("', '")}'`);let G=`${$}Help`;return this.on(G,(J)=>{l
85
205
  fetch('/api/state').then(r=>r.json()).then(renderState).catch(()=>{});connect();
86
206
  </script>
87
207
  </body>
88
- </html>`;function y8(){let $=NI();if(!$I($))II($,{recursive:!0});let I=t9((z,x)=>{if(z.url==="/api/state")x.writeHead(200,{"Content-Type":"application/json"}),x.end(JSON.stringify(a$($)));else x.writeHead(200,{"Content-Type":"text/html"}),x.end(QI)}),N=new o$.default({server:I}),G=null;function J(z,x){if(G)clearTimeout(G);G=setTimeout(()=>{let Q=JSON.stringify({type:"update",event:z,file:x,data:a$($)});N.clients.forEach((X)=>{if(X.readyState===s$.default.OPEN)X.send(Q)})},100)}let Z=A0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});Z.on("all",(z,x)=>J(z,O8(x))),N.on("connection",(z)=>{z.send(JSON.stringify({type:"full",data:a$($)})),z.on("error",()=>z.terminate())}),process.on("SIGINT",()=>{console.log(`
89
- Shutting down...`),Z.close(),N.clients.forEach((z)=>z.terminate()),N.close(()=>I.close(()=>process.exit(0))),setTimeout(()=>process.exit(1),3000).unref()}),process.on("SIGTERM",()=>process.emit("SIGINT")),I.listen(W8,()=>{console.log(h0.default.magenta(`
90
- \uD83D\uDEF8 Serena Memory Dashboard`)),console.log(h0.default.white(` http://localhost:${W8}`)),console.log(h0.default.dim(` Watching: ${$}
91
- `))})}var h=i(x1(),1);import{readFileSync as XI,existsSync as MI,readdirSync as M0,statSync as I2,mkdirSync as jI}from"node:fs";import{join as Q1,basename as KI}from"node:path";var YI="●",RI="✓",SI="✗",HI="○",TI="◌";function UI(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return Q1($,".serena","memories");return Q1(process.cwd(),".serena","memories")}function j0($){try{return XI($,"utf-8")}catch{return""}}function qI($){try{let I=M0($);if(I.includes("orchestrator-session.md"))return Q1($,"orchestrator-session.md");let N=I.filter((G)=>/^session-.*\.md$/.test(G)).map((G)=>({name:G,mtime:I2(Q1($,G)).mtimeMs})).sort((G,J)=>J.mtime-G.mtime);if(N.length>0&&N[0])return Q1($,N[0].name)}catch{}return null}function CI($){let I=qI($);if(!I)return{id:"N/A",status:"UNKNOWN"};let N=j0(I);if(!N)return{id:"N/A",status:"UNKNOWN"};let G=(N.match(/session-id:\s*(.+)/i)||[])[1]||(N.match(/# Session:\s*(.+)/i)||[])[1]||N.match(/(session-\d{8}-\d{6})/)?.[1]||KI(I,".md"),J="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(N))J="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(N))J="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(N))J="FAILED";else if(/Step \d+:.*\[/i.test(N))J="RUNNING";return{id:(G||"N/A").trim(),status:J}}function BI($){let I=j0(Q1($,"task-board.md"));if(!I)return[];let N=[],G=I.split(`
92
- `);for(let J of G){if(!J.startsWith("|")||/^\|\s*-+/.test(J))continue;let Z=J.split("|").map((X)=>X.trim()).filter(Boolean),z=Z[0];if(Z.length<2||!z||/^agent$/i.test(z))continue;let x=Z[1],Q=Z[2];N.push({agent:z,status:x||"pending",task:Q||""})}return N}function $2($,I){try{let N=M0($).filter((Z)=>Z.startsWith(`progress-${I}`)&&Z.endsWith(".md")).sort().reverse();if(N.length===0||!N[0])return null;let J=j0(Q1($,N[0])).match(/turn[:\s]*(\d+)/i);return J&&J[1]?parseInt(J[1],10):null}catch{return null}}function gI($){try{let I=M0($).filter((G)=>G.endsWith(".md")&&G!==".gitkeep").map((G)=>({name:G,mtime:I2(Q1($,G)).mtimeMs})).sort((G,J)=>J.mtime-G.mtime).slice(0,5),N=[];for(let G of I){let J=G.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||G.name.replace(/\.md$/,""),z=j0(Q1($,G.name)).split(`
93
- `).map((Q)=>Q.trim()).filter((Q)=>Q&&!Q.startsWith("---")&&Q.length>3),x="";for(let Q=z.length-1;Q>=0;Q--){let X=z[Q];if(!X)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(X)){if(x=X.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),x.length>5)break}}if(x.length>52)x=x.substring(0,49)+"...";if(x)N.push({agent:J,message:x})}return N}catch{return[]}}function LI($){let I=[],N=new Set;try{let G=M0($).filter((J)=>J.endsWith(".md")&&J!==".gitkeep").map((J)=>({name:J,mtime:I2(Q1($,J)).mtimeMs})).sort((J,Z)=>Z.mtime-J.mtime);for(let J of G){let Z=j0(Q1($,J.name)),z=Z.match(/\*\*Agent\*\*:\s*(.+)/i)||Z.match(/Agent:\s*(.+)/i)||Z.match(/^#+\s*(.+?)\s*Agent/im),x=null;if(z&&z[1])x=z[1].trim();else if(/_agent|agent_|-agent/i.test(J.name))x=J.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(x&&!N.has(x.toLowerCase())){N.add(x.toLowerCase());let Q="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(Z))Q="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(Z))Q="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(Z))Q="failed";let X=Z.match(/## Task\s*\n+(.+)/i)||Z.match(/\*\*Task\*\*:\s*(.+)/i),j=X&&X[1]?X[1].trim().substring(0,20):"";I.push({agent:x,status:Q,task:j,turn:$2($,x)})}}}catch{}return I}function DI($){let I=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(I))return`${h.default.green(YI)} running`;else if(["completed","done","finished"].includes(I))return`${h.default.cyan(RI)} completed`;else if(["failed","error"].includes(I))return`${h.default.red(SI)} failed`;else if(["blocked","waiting"].includes(I))return`${h.default.yellow(HI)} blocked`;return`${h.default.dim(TI)} pending`}function E8($){console.clear();let I=CI($),G=BI($).map((K)=>({...K,turn:$2($,K.agent)}));if(G.length===0)G=LI($);if(G.length===0)try{let K=M0($).filter((T)=>T.startsWith("progress-")&&T.endsWith(".md"));for(let T of K){let C=T.replace(/^progress-/,"").replace(/\.md$/,"");G.push({agent:C,status:"running",task:"",turn:$2($,C)})}}catch{}let J=56,Z="═".repeat(J),z=(K)=>" ".repeat(Math.max(0,K)),x=(K)=>h.default.magenta(K),Q=(K)=>h.default.bold(K),X=(K)=>h.default.dim(K),j=h.default.yellow;if(I.status==="RUNNING")j=h.default.green;else if(I.status==="COMPLETED")j=h.default.cyan;else if(I.status==="FAILED")j=h.default.red;console.log(`${x("╔"+Z+"╗")}`),console.log(`${x("║")} ${Q(x("Serena Memory Dashboard"))}${z(J-25)}${x("║")}`);let M=`Session: ${Q(I.id.padEnd(20))} [${j(I.status)}]`;if(console.log(`${x("║")} ${M}${z(J-4-M.length-9)}${x("║")}`),console.log(`${x("╠"+Z+"╣")}`),console.log(`${x("║")} ${Q("Agent".padEnd(12)+" "+"Status".padEnd(12)+" "+"Turn".padEnd(6)+" "+"Task".padEnd(20))} ${x("║")}`),console.log(`${x("║")} ${X("──────────".padEnd(12)+" "+"──────────".padEnd(12)+" "+"────".padEnd(6)+" "+"──────────────────".padEnd(20))} ${x("║")}`),G.length===0)console.log(`${x("║")} ${X("No agents detected yet"+z(32))}${x("║")}`);else for(let K of G){let T=DI(K.status),C=K.turn!=null?String(K.turn):"-",U=K.task.substring(0,20);console.log(`${x("║")} ${K.agent.padEnd(12)} ${T.padEnd(22)} ${C.padEnd(6)} ${U.padEnd(20)}${x("║")}`)}console.log(`${x("╠"+Z+"╣")}`),console.log(`${x("║")} ${Q("Latest Activity:")}${z(J-18)}${x("║")}`);let R=gI($);if(R.length===0)console.log(`${x("║")} ${X("No activity yet"+z(38))}${x("║")}`);else for(let K of R){let T=`[${K.agent}] ${K.message}`;console.log(`${x("║")} ${X(T.substring(0,52).padEnd(52))}${x("║")}`)}console.log(`${x("╠"+Z+"╣")}`);let Y=`Updated: ${new Date().toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})} | Ctrl+C to exit`;console.log(`${x("║")} ${X(Y)}${z(J-4-Y.length)}${x("║")}`),console.log(`${x("╚"+Z+"╝")}`)}function l8(){let $=UI();if(!MI($))jI($,{recursive:!0}),console.log(h.default.yellow(`Created ${$} — waiting for memory files...`));console.log(h.default.magenta(`
94
- \uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(h.default.dim(` Watching: ${$}
95
- `)),E8($);let I=A0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});I.on("all",()=>E8($)),process.on("SIGINT",()=>{console.log(`
96
- `),I.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var K0=i(x1(),1),n=i(G2(),1);import{stdout as X2,stdin as i8}from"node:process";import*as _1 from"node:readline";import fI from"node:readline";import{ReadStream as v8}from"node:tty";var AI=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,PI=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,FI=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,J2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,n0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,c0=/\t{1,1000}/y,Z2=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,d0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,WI=/\p{M}+/gu,OI={limit:1/0,ellipsis:""},k8=($,I={},N={})=>{let G=I.limit??1/0,J=I.ellipsis??"",Z=I?.ellipsisWidth??(J?k8(J,OI,N).width:0),z=N.ansiWidth??0,x=N.controlWidth??0,Q=N.tabWidth??8,X=N.ambiguousWidth??1,j=N.emojiWidth??2,M=N.fullWidthWidth??2,R=N.regularWidth??1,S=N.wideWidth??2,Y=0,K=0,T=$.length,C=0,U=!1,B=T,_=Math.max(0,G-Z),L=0,f=0,q=0,g=0;$:for(;;){if(f>L||K>=T&&K>Y){let b=$.slice(L,f)||$.slice(Y,K);C=0;for(let c of b.replaceAll(WI,"")){let s=c.codePointAt(0)||0;if(PI(s)?g=M:FI(s)?g=S:X!==R&&AI(s)?g=X:g=R,q+g>_&&(B=Math.min(B,Math.max(L,Y)+C)),q+g>G){U=!0;break $}C+=c.length,q+=g}L=f=0}if(K>=T)break;if(d0.lastIndex=K,d0.test($)){if(C=d0.lastIndex-K,g=C*R,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/R))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=d0.lastIndex;continue}if(J2.lastIndex=K,J2.test($)){if(q+z>_&&(B=Math.min(B,K)),q+z>G){U=!0;break}q+=z,L=Y,f=K,K=Y=J2.lastIndex;continue}if(n0.lastIndex=K,n0.test($)){if(C=n0.lastIndex-K,g=C*x,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/x))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=n0.lastIndex;continue}if(c0.lastIndex=K,c0.test($)){if(C=c0.lastIndex-K,g=C*Q,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/Q))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=c0.lastIndex;continue}if(Z2.lastIndex=K,Z2.test($)){if(q+j>_&&(B=Math.min(B,K)),q+j>G){U=!0;break}q+=j,L=Y,f=K,K=Y=Z2.lastIndex;continue}K+=1}return{width:U?_:q,index:U?B:T,truncated:U,ellipsed:U&&G>=Z}},yI={limit:1/0,ellipsis:"",ellipsisWidth:0},Y0=($,I={})=>k8($,yI,I).width,s0="\x1B",h8="›",EI=39,M2="\x07",n8="[",lI="]",c8="m",j2=`${lI}8;;`,w8=new RegExp(`(?:\\${n8}(?<code>\\d+)m|\\${j2}(?<uri>.*)${M2})`,"y"),uI=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},b8=($)=>`${s0}${n8}${$}${c8}`,m8=($)=>`${s0}${j2}${$}${M2}`,vI=($)=>$.map((I)=>Y0(I)),x2=($,I,N)=>{let G=I[Symbol.iterator](),J=!1,Z=!1,z=$.at(-1),x=z===void 0?0:Y0(z),Q=G.next(),X=G.next(),j=0;for(;!Q.done;){let M=Q.value,R=Y0(M);x+R<=N?$[$.length-1]+=M:($.push(M),x=0),(M===s0||M===h8)&&(J=!0,Z=I.startsWith(j2,j+1)),J?Z?M===M2&&(J=!1,Z=!1):M===c8&&(J=!1):(x+=R,x===N&&!X.done&&($.push(""),x=0)),Q=X,X=G.next(),j+=M.length}z=$.at(-1),!x&&z!==void 0&&z.length>0&&$.length>1&&($[$.length-2]+=$.pop())},wI=($)=>{let I=$.split(" "),N=I.length;for(;N>0&&!(Y0(I[N-1])>0);)N--;return N===I.length?$:I.slice(0,N).join(" ")+I.slice(N).join("")},bI=($,I,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",J,Z,z=$.split(" "),x=vI(z),Q=[""];for(let[Y,K]of z.entries()){N.trim!==!1&&(Q[Q.length-1]=(Q.at(-1)??"").trimStart());let T=Y0(Q.at(-1)??"");if(Y!==0&&(T>=I&&(N.wordWrap===!1||N.trim===!1)&&(Q.push(""),T=0),(T>0||N.trim===!1)&&(Q[Q.length-1]+=" ",T++)),N.hard&&x[Y]>I){let C=I-T,U=1+Math.floor((x[Y]-C-1)/I);Math.floor((x[Y]-1)/I)<U&&Q.push(""),x2(Q,K,I);continue}if(T+x[Y]>I&&T>0&&x[Y]>0){if(N.wordWrap===!1&&T<I){x2(Q,K,I);continue}Q.push("")}if(T+x[Y]>I&&N.wordWrap===!1){x2(Q,K,I);continue}Q[Q.length-1]+=K}N.trim!==!1&&(Q=Q.map((Y)=>wI(Y)));let X=Q.join(`
97
- `),j=X[Symbol.iterator](),M=j.next(),R=j.next(),S=0;for(;!M.done;){let Y=M.value,K=R.value;if(G+=Y,Y===s0||Y===h8){w8.lastIndex=S+1;let C=w8.exec(X)?.groups;if(C?.code!==void 0){let U=Number.parseFloat(C.code);J=U===EI?void 0:U}else C?.uri!==void 0&&(Z=C.uri.length===0?void 0:C.uri)}let T=J?uI(J):void 0;K===`
98
- `?(Z&&(G+=m8("")),J&&T&&(G+=b8(T))):Y===`
99
- `&&(J&&T&&(G+=b8(J)),Z&&(G+=m8(Z))),S+=Y.length,M=R,R=j.next()}return G};function z2($,I,N){return String($).normalize().replaceAll(`\r
100
- `,`
101
- `).split(`
102
- `).map((G)=>bI(G,I,N)).join(`
103
- `)}var mI=["up","down","left","right","space","enter","cancel"],X1={actions:new Set(mI),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function K2($,I){if(typeof $=="string")return X1.aliases.get($)===I;for(let N of $)if(N!==void 0&&K2(N,I))return!0;return!1}function iI($,I){if($===I)return;let N=$.split(`
104
- `),G=I.split(`
105
- `),J=Math.max(N.length,G.length),Z=[];for(let z=0;z<J;z++)N[z]!==G[z]&&Z.push(z);return{lines:Z,numLinesBefore:N.length,numLinesAfter:G.length,numLines:J}}var kI=globalThis.process.platform.startsWith("win"),Q2=Symbol("clack:cancel");function d($){return $===Q2}function p0($,I){let N=$;N.isTTY&&N.setRawMode(I)}function d8({input:$=i8,output:I=X2,overwrite:N=!0,hideCursor:G=!0}={}){let J=_1.createInterface({input:$,output:I,prompt:"",tabSize:1});_1.emitKeypressEvents($,J),$ instanceof v8&&$.isTTY&&$.setRawMode(!0);let Z=(z,{name:x,sequence:Q})=>{let X=String(z);if(K2([X,x,Q],"cancel")){G&&I.write(n.cursor.show),process.exit(0);return}if(!N)return;_1.moveCursor(I,x==="return"?0:-1,x==="return"?-1:0,()=>{_1.clearLine(I,1,()=>{$.once("keypress",Z)})})};return G&&I.write(n.cursor.hide),$.once("keypress",Z),()=>{$.off("keypress",Z),G&&I.write(n.cursor.show),$ instanceof v8&&$.isTTY&&!kI&&$.setRawMode(!1),J.terminal=!1,J.close()}}var R0=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,Y2=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20;function l1($,I,N,G=N){let J=R0($??X2);return z2(I,J-N.length,{hard:!0,trim:!1}).split(`
106
- `).map((Z,z)=>`${z===0?G:N}${Z}`).join(`
107
- `)}class u1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,I=!0){let{input:N=i8,output:G=X2,render:J,signal:Z,...z}=$;this.opts=z,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=J.bind(this),this._track=I,this._abortSignal=Z,this.input=N,this.output=G}unsubscribe(){this._subscribers.clear()}setSubscriber($,I){let N=this._subscribers.get($)??[];N.push(I),this._subscribers.set($,N)}on($,I){this.setSubscriber($,{cb:I})}once($,I){this.setSubscriber($,{cb:I,once:!0})}emit($,...I){let N=this._subscribers.get($)??[],G=[];for(let J of N)J.cb(...I),J.once&&G.push(()=>N.splice(N.indexOf(J),1));for(let J of G)J()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(Q2);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=fI.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),p0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(n.cursor.show),this.output.off("resize",this.render),p0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(n.cursor.show),this.output.off("resize",this.render),p0(this.input,!1),$(Q2)})})}_isActionKey($,I){return $==="\t"}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,I){this.userInput=$??"",this.emit("userInput",this.userInput),I&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,I){if(this._track&&I.name!=="return"&&(I.name&&this._isActionKey($,I)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),I?.name&&(!this._track&&X1.aliases.has(I.name)&&this.emit("cursor",X1.aliases.get(I.name)),X1.actions.has(I.name)&&this.emit("cursor",I.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$?.toLowerCase(),I),I?.name==="return"){if(this.opts.validate){let N=this.opts.validate(this.value);N&&(this.error=N instanceof Error?N.message:N,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}K2([$,I?.name,I?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
108
- `),p0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=z2(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
109
- `).length-1;this.output.write(n.cursor.move(-999,$*-1))}render(){let $=z2(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(n.cursor.hide);else{let I=iI(this._prevFrame,$),N=Y2(this.output);if(this.restoreCursor(),I){let G=Math.max(0,I.numLinesAfter-N),J=Math.max(0,I.numLinesBefore-N),Z=I.lines.find((z)=>z>=G);if(Z===void 0){this._prevFrame=$;return}if(I.lines.length===1){this.output.write(n.cursor.move(0,Z-J)),this.output.write(n.erase.lines(1));let z=$.split(`
110
- `);this.output.write(z[Z]),this._prevFrame=$,this.output.write(n.cursor.move(0,z.length-Z-1));return}else if(I.lines.length>1){if(G<J)Z=G;else{let x=Z-J;x>0&&this.output.write(n.cursor.move(0,x))}this.output.write(n.erase.down());let z=$.split(`
111
- `).slice(Z);this.output.write(z.join(`
112
- `)),this._prevFrame=$;return}}this.output.write(n.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function hI($,I){if($===void 0||I.length===0)return 0;let N=I.findIndex((G)=>G.value===$);return N!==-1?N:0}function nI($,I){return(I.label??String(I.value)).toLowerCase().includes($.toLowerCase())}function cI($,I){if(I)return $?I:I[0]}class p8 extends u1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#N="";#G;#I;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return K0.default.inverse(K0.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[I,...N]=this.userInput.slice(this._cursor);return`${$}${K0.default.inverse(I)}${N.join("")}`}get options(){return typeof this.#I=="function"?this.#I():this.#I}constructor($){super($),this.#I=$.options;let I=this.options;this.filteredOptions=[...I],this.multiple=$.multiple===!0,this.#G=$.filter??nI;let N;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?N=$.initialValue:N=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(N=[this.options[0].value]),N)for(let G of N){let J=I.findIndex((Z)=>Z.value===G);J!==-1&&(this.toggleSelected(G),this.#$=J)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(G,J)=>this.#J(G,J)),this.on("userInput",(G)=>this.#Z(G))}_isActionKey($,I){return $==="\t"||this.multiple&&this.isNavigating&&I.name==="space"&&$!==void 0&&$!==""}#J($,I){let N=I.name==="up",G=I.name==="down",J=I.name==="return";N||G?(this.#$=Math.max(0,Math.min(this.#$+(N?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):J?this.value=cI(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(I.name==="tab"||this.isNavigating&&I.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected($){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes($)?this.selectedValues=this.selectedValues.filter((I)=>I!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#Z($){if($!==this.#N){this.#N=$;let I=this.options;$?this.filteredOptions=I.filter((N)=>this.#G($,N)):this.filteredOptions=[...I],this.#$=hI(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class R2 extends u1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(I)=>{this.output.write(n.cursor.move(0,-1)),this.value=I,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class s8 extends u1{options;cursor=0;#$;getGroupItems($){return this.options.filter((I)=>I.group===$)}isGroupSelected($){let I=this.getGroupItems($),N=this.value;return N===void 0?!1:I.every((G)=>N.includes(G.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let I=$.value,N=this.getGroupItems(I);this.isGroupSelected(I)?this.value=this.value.filter((G)=>N.findIndex((J)=>J.value===G)===-1):this.value=[...this.value,...N.map((G)=>G.value)],this.value=Array.from(new Set(this.value))}else{let I=this.value.includes($.value);this.value=I?this.value.filter((N)=>N!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:I}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(I).flatMap(([N,G])=>[{value:N,group:!0,label:N},...G.map((J)=>({...J,group:N}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),this.#$?0:1),this.on("cursor",(N)=>{switch(N){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let G=this.options[this.cursor]?.group===!0;!this.#$&&G&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function E1($,I,N){let G=$+I,J=Math.max(N.length-1,0),Z=G<0?J:G>J?0:G;return N[Z].disabled?E1(Z,I<0?-1:1,N):Z}class S2 extends u1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,I=this.value!==void 0&&this.value.length===$.length;this.value=I?[]:$.map((N)=>N.value)}toggleInvert(){let $=this.value;if(!$)return;let I=this._enabledOptions.filter((N)=>!$.includes(N.value));this.value=I.map((N)=>N.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((I)=>I!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let I=Math.max(this.options.findIndex(({value:N})=>N===$.cursorAt),0);this.cursor=this.options[I].disabled?E1(I,1,this.options):I,this.on("key",(N)=>{N==="a"&&this.toggleAll(),N==="i"&&this.toggleInvert()}),this.on("cursor",(N)=>{switch(N){case"left":case"up":this.cursor=E1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=E1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class H2 extends u1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let I=this.options.findIndex(({value:G})=>G===$.initialValue),N=I===-1?0:I;this.cursor=this.options[N].disabled?E1(N,1,this.options):N,this.changeValue(),this.on("cursor",(G)=>{switch(G){case"left":case"up":this.cursor=E1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=E1(this.cursor,1,this.options);break}this.changeValue()})}}class T2 extends u1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let I=$.slice(0,this.cursor),[N,...G]=$.slice(this.cursor);return`${I}${K0.default.inverse(N)}${G.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(I)=>{this._setValue(I)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var H=i(x1(),1);import N1 from"node:process";var H0=i(G2(),1);function dI(){return N1.platform!=="win32"?N1.env.TERM!=="linux":!!N1.env.CI||!!N1.env.WT_SESSION||!!N1.env.TERMINUS_SUBLIME||N1.env.ConEmuTask==="{cmd::Cmder}"||N1.env.TERM_PROGRAM==="Terminus-Sublime"||N1.env.TERM_PROGRAM==="vscode"||N1.env.TERM==="xterm-256color"||N1.env.TERM==="alacritty"||N1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var B2=dI(),pI=()=>process.env.CI==="true";var W=($,I)=>B2?$:I,sI=W("◆","*"),I3=W("■","x"),N3=W("▲","x"),$$=W("◇","o"),oI=W("┌","T"),A=W("│","|"),V1=W("└","—"),KG=W("┐","T"),YG=W("┘","—"),g2=W("●",">"),e0=W("○"," "),rI=W("◻","[•]"),o8=W("◼","[+]"),r8=W("◻","[ ]"),RG=W("▪","•"),a8=W("─","-"),aI=W("╮","+"),tI=W("├","+"),eI=W("╯","+"),$N=W("╰","+"),SG=W("╭","+"),IN=W("●","•"),NN=W("◆","*"),GN=W("▲","!"),JN=W("■","x"),I$=($)=>{switch($){case"initial":case"active":return H.default.cyan(sI);case"cancel":return H.default.red(I3);case"error":return H.default.yellow(N3);case"submit":return H.default.green($$)}},G3=($)=>{switch($){case"initial":case"active":return H.default.cyan(A);case"cancel":return H.default.red(A);case"error":return H.default.yellow(A);case"submit":return H.default.green(A)}},ZN=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,xN=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,zN=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,U2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,o0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,r0=/\t{1,1000}/y,q2=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,a0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,QN=/\p{M}+/gu,XN={limit:1/0,ellipsis:""},J3=($,I={},N={})=>{let G=I.limit??1/0,J=I.ellipsis??"",Z=I?.ellipsisWidth??(J?J3(J,XN,N).width:0),z=N.ansiWidth??0,x=N.controlWidth??0,Q=N.tabWidth??8,X=N.ambiguousWidth??1,j=N.emojiWidth??2,M=N.fullWidthWidth??2,R=N.regularWidth??1,S=N.wideWidth??2,Y=0,K=0,T=$.length,C=0,U=!1,B=T,_=Math.max(0,G-Z),L=0,f=0,q=0,g=0;$:for(;;){if(f>L||K>=T&&K>Y){let b=$.slice(L,f)||$.slice(Y,K);C=0;for(let c of b.replaceAll(QN,"")){let s=c.codePointAt(0)||0;if(xN(s)?g=M:zN(s)?g=S:X!==R&&ZN(s)?g=X:g=R,q+g>_&&(B=Math.min(B,Math.max(L,Y)+C)),q+g>G){U=!0;break $}C+=c.length,q+=g}L=f=0}if(K>=T)break;if(a0.lastIndex=K,a0.test($)){if(C=a0.lastIndex-K,g=C*R,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/R))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=a0.lastIndex;continue}if(U2.lastIndex=K,U2.test($)){if(q+z>_&&(B=Math.min(B,K)),q+z>G){U=!0;break}q+=z,L=Y,f=K,K=Y=U2.lastIndex;continue}if(o0.lastIndex=K,o0.test($)){if(C=o0.lastIndex-K,g=C*x,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/x))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=o0.lastIndex;continue}if(r0.lastIndex=K,r0.test($)){if(C=r0.lastIndex-K,g=C*Q,q+g>_&&(B=Math.min(B,K+Math.floor((_-q)/Q))),q+g>G){U=!0;break}q+=g,L=Y,f=K,K=Y=r0.lastIndex;continue}if(q2.lastIndex=K,q2.test($)){if(q+j>_&&(B=Math.min(B,K)),q+j>G){U=!0;break}q+=j,L=Y,f=K,K=Y=q2.lastIndex;continue}K+=1}return{width:U?_:q,index:U?B:T,truncated:U,ellipsed:U&&G>=Z}},MN={limit:1/0,ellipsis:"",ellipsisWidth:0},K1=($,I={})=>J3($,MN,I).width,N$="\x1B",Z3="›",jN=39,D2="\x07",x3="[",KN="]",z3="m",_2=`${KN}8;;`,t8=new RegExp(`(?:\\${x3}(?<code>\\d+)m|\\${_2}(?<uri>.*)${D2})`,"y"),YN=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},e8=($)=>`${N$}${x3}${$}${z3}`,$3=($)=>`${N$}${_2}${$}${D2}`,RN=($)=>$.map((I)=>K1(I)),C2=($,I,N)=>{let G=I[Symbol.iterator](),J=!1,Z=!1,z=$.at(-1),x=z===void 0?0:K1(z),Q=G.next(),X=G.next(),j=0;for(;!Q.done;){let M=Q.value,R=K1(M);x+R<=N?$[$.length-1]+=M:($.push(M),x=0),(M===N$||M===Z3)&&(J=!0,Z=I.startsWith(_2,j+1)),J?Z?M===D2&&(J=!1,Z=!1):M===z3&&(J=!1):(x+=R,x===N&&!X.done&&($.push(""),x=0)),Q=X,X=G.next(),j+=M.length}z=$.at(-1),!x&&z!==void 0&&z.length>0&&$.length>1&&($[$.length-2]+=$.pop())},SN=($)=>{let I=$.split(" "),N=I.length;for(;N>0&&!(K1(I[N-1])>0);)N--;return N===I.length?$:I.slice(0,N).join(" ")+I.slice(N).join("")},HN=($,I,N={})=>{if(N.trim!==!1&&$.trim()==="")return"";let G="",J,Z,z=$.split(" "),x=RN(z),Q=[""];for(let[Y,K]of z.entries()){N.trim!==!1&&(Q[Q.length-1]=(Q.at(-1)??"").trimStart());let T=K1(Q.at(-1)??"");if(Y!==0&&(T>=I&&(N.wordWrap===!1||N.trim===!1)&&(Q.push(""),T=0),(T>0||N.trim===!1)&&(Q[Q.length-1]+=" ",T++)),N.hard&&x[Y]>I){let C=I-T,U=1+Math.floor((x[Y]-C-1)/I);Math.floor((x[Y]-1)/I)<U&&Q.push(""),C2(Q,K,I);continue}if(T+x[Y]>I&&T>0&&x[Y]>0){if(N.wordWrap===!1&&T<I){C2(Q,K,I);continue}Q.push("")}if(T+x[Y]>I&&N.wordWrap===!1){C2(Q,K,I);continue}Q[Q.length-1]+=K}N.trim!==!1&&(Q=Q.map((Y)=>SN(Y)));let X=Q.join(`
113
- `),j=X[Symbol.iterator](),M=j.next(),R=j.next(),S=0;for(;!M.done;){let Y=M.value,K=R.value;if(G+=Y,Y===N$||Y===Z3){t8.lastIndex=S+1;let C=t8.exec(X)?.groups;if(C?.code!==void 0){let U=Number.parseFloat(C.code);J=U===jN?void 0:U}else C?.uri!==void 0&&(Z=C.uri.length===0?void 0:C.uri)}let T=J?YN(J):void 0;K===`
114
- `?(Z&&(G+=$3("")),J&&T&&(G+=e8(T))):Y===`
115
- `&&(J&&T&&(G+=e8(J)),Z&&(G+=$3(Z))),S+=Y.length,M=R,R=j.next()}return G};function T0($,I,N){return String($).normalize().replaceAll(`\r
116
- `,`
117
- `).split(`
118
- `).map((G)=>HN(G,I,N)).join(`
119
- `)}var TN=($,I,N,G,J)=>{let Z=I,z=0;for(let x=N;x<G;x++){let Q=$[x];if(Z=Z-Q.length,z++,Z<=J)break}return{lineCount:Z,removals:z}},L2=($)=>{let{cursor:I,options:N,style:G}=$,J=$.output??process.stdout,Z=R0(J),z=$.columnPadding??0,x=$.rowPadding??4,Q=Z-z,X=Y2(J),j=H.default.dim("..."),M=$.maxItems??Number.POSITIVE_INFINITY,R=Math.max(X-x,0),S=Math.max(Math.min(M,R),5),Y=0;I>=S-3&&(Y=Math.max(Math.min(I-S+3,N.length-S),0));let K=S<N.length&&Y>0,T=S<N.length&&Y+S<N.length,C=Math.min(Y+S,N.length),U=[],B=0;K&&B++,T&&B++;let _=Y+(K?1:0),L=C-(T?1:0);for(let q=_;q<L;q++){let g=T0(G(N[q],q===I),Q,{hard:!0,trim:!1}).split(`
120
- `);U.push(g),B+=g.length}if(B>R){let q=0,g=0,b=B,c=I-_,s=(A1,l)=>TN(U,b,A1,l,R);K?({lineCount:b,removals:q}=s(0,c),b>R&&({lineCount:b,removals:g}=s(c+1,U.length))):({lineCount:b,removals:g}=s(c+1,U.length),b>R&&({lineCount:b,removals:q}=s(0,c))),q>0&&(K=!0,U.splice(0,q)),g>0&&(T=!0,U.splice(U.length-g,g))}let f=[];K&&f.push(j);for(let q of U)for(let g of q)f.push(g);return T&&f.push(j),f};var G$=($)=>{let I=$.active??"Yes",N=$.inactive??"No";return new R2({active:I,inactive:N,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let G=`${H.default.gray(A)}
121
- ${I$(this.state)} ${$.message}
122
- `,J=this.value?I:N;switch(this.state){case"submit":return`${G}${H.default.gray(A)} ${H.default.dim(J)}`;case"cancel":return`${G}${H.default.gray(A)} ${H.default.strikethrough(H.default.dim(J))}
123
- ${H.default.gray(A)}`;default:return`${G}${H.default.cyan(A)} ${this.value?`${H.default.green(g2)} ${I}`:`${H.default.dim(e0)} ${H.default.dim(I)}`} ${H.default.dim("/")} ${this.value?`${H.default.dim(e0)} ${H.default.dim(N)}`:`${H.default.green(g2)} ${N}`}
124
- ${H.default.cyan(V1)}
125
- `}}}).prompt()};var a={message:($=[],{symbol:I=H.default.gray(A),secondarySymbol:N=H.default.gray(A),output:G=process.stdout,spacing:J=1,withGuide:Z}={})=>{let z=[],x=(Z??X1.withGuide)!==!1,Q=x?N:"",X=x?`${I} `:"",j=x?`${N} `:"";for(let R=0;R<J;R++)z.push(Q);let M=Array.isArray($)?$:$.split(`
126
- `);if(M.length>0){let[R,...S]=M;R.length>0?z.push(`${X}${R}`):z.push(x?I:"");for(let Y of S)Y.length>0?z.push(`${j}${Y}`):z.push(x?N:"")}G.write(`${z.join(`
127
- `)}
128
- `)},info:($,I)=>{a.message($,{...I,symbol:H.default.blue(IN)})},success:($,I)=>{a.message($,{...I,symbol:H.default.green(NN)})},step:($,I)=>{a.message($,{...I,symbol:H.default.green($$)})},warn:($,I)=>{a.message($,{...I,symbol:H.default.yellow(GN)})},warning:($,I)=>{a.warn($,I)},error:($,I)=>{a.message($,{...I,symbol:H.default.red(JN)})}},G1=($="",I)=>{(I?.output??process.stdout).write(`${H.default.gray(V1)} ${H.default.red($)}
129
-
130
- `)},t=($="",I)=>{(I?.output??process.stdout).write(`${H.default.gray(oI)} ${$}
131
- `)},m=($="",I)=>{(I?.output??process.stdout).write(`${H.default.gray(A)}
132
- ${H.default.gray(V1)} ${$}
133
-
134
- `)},S0=($,I)=>$.split(`
135
- `).map((N)=>I(N)).join(`
136
- `),J$=($)=>{let I=(G,J)=>{let Z=G.label??String(G.value);return J==="disabled"?`${H.default.gray(r8)} ${S0(Z,(z)=>H.default.strikethrough(H.default.gray(z)))}${G.hint?` ${H.default.dim(`(${G.hint??"disabled"})`)}`:""}`:J==="active"?`${H.default.cyan(rI)} ${Z}${G.hint?` ${H.default.dim(`(${G.hint})`)}`:""}`:J==="selected"?`${H.default.green(o8)} ${S0(Z,H.default.dim)}${G.hint?` ${H.default.dim(`(${G.hint})`)}`:""}`:J==="cancelled"?`${S0(Z,(z)=>H.default.strikethrough(H.default.dim(z)))}`:J==="active-selected"?`${H.default.green(o8)} ${Z}${G.hint?` ${H.default.dim(`(${G.hint})`)}`:""}`:J==="submitted"?`${S0(Z,H.default.dim)}`:`${H.default.dim(r8)} ${S0(Z,H.default.dim)}`},N=$.required??!0;return new S2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:N,cursorAt:$.cursorAt,validate(G){if(N&&(G===void 0||G.length===0))return`Please select at least one option.
137
- ${H.default.reset(H.default.dim(`Press ${H.default.gray(H.default.bgWhite(H.default.inverse(" space ")))} to select, ${H.default.gray(H.default.bgWhite(H.default.inverse(" enter ")))} to submit`))}`},render(){let G=l1($.output,$.message,`${G3(this.state)} `,`${I$(this.state)} `),J=`${H.default.gray(A)}
138
- ${G}
139
- `,Z=this.value??[],z=(x,Q)=>{if(x.disabled)return I(x,"disabled");let X=Z.includes(x.value);return Q&&X?I(x,"active-selected"):X?I(x,"selected"):I(x,Q?"active":"inactive")};switch(this.state){case"submit":{let x=this.options.filter(({value:X})=>Z.includes(X)).map((X)=>I(X,"submitted")).join(H.default.dim(", "))||H.default.dim("none"),Q=l1($.output,x,`${H.default.gray(A)} `);return`${J}${Q}`}case"cancel":{let x=this.options.filter(({value:X})=>Z.includes(X)).map((X)=>I(X,"cancelled")).join(H.default.dim(", "));if(x.trim()==="")return`${J}${H.default.gray(A)}`;let Q=l1($.output,x,`${H.default.gray(A)} `);return`${J}${Q}
140
- ${H.default.gray(A)}`}case"error":{let x=`${H.default.yellow(A)} `,Q=this.error.split(`
141
- `).map((M,R)=>R===0?`${H.default.yellow(V1)} ${H.default.yellow(M)}`:` ${M}`).join(`
142
- `),X=J.split(`
143
- `).length,j=Q.split(`
144
- `).length+1;return`${J}${x}${L2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:x.length,rowPadding:X+j,style:z}).join(`
145
- ${x}`)}
146
- ${Q}
147
- `}default:{let x=`${H.default.cyan(A)} `,Q=J.split(`
148
- `).length;return`${J}${x}${L2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:x.length,rowPadding:Q+2,style:z}).join(`
149
- ${x}`)}
150
- ${H.default.cyan(V1)}
151
- `}}}}).prompt()},UN=($)=>H.default.dim($),qN=($,I,N)=>{let G={hard:!0,trim:!1},J=T0($,I,G).split(`
152
- `),Z=J.reduce((Q,X)=>Math.max(K1(X),Q),0),z=J.map(N).reduce((Q,X)=>Math.max(K1(X),Q),0),x=I-(z-Z);return T0($,x,G)},F=($="",I="",N)=>{let G=N?.output??N1.stdout,J=(N?.withGuide??X1.withGuide)!==!1,Z=N?.format??UN,z=["",...qN($,R0(G)-6,Z).split(`
153
- `).map(Z),""],x=K1(I),Q=Math.max(z.reduce((R,S)=>{let Y=K1(S);return Y>R?Y:R},0),x)+2,X=z.map((R)=>`${H.default.gray(A)} ${R}${" ".repeat(Q-K1(R))}${H.default.gray(A)}`).join(`
154
- `),j=J?`${H.default.gray(A)}
155
- `:"",M=J?tI:$N;G.write(`${j}${H.default.green($$)} ${H.default.reset(I)} ${H.default.gray(a8.repeat(Math.max(Q-x-1,1))+aI)}
156
- ${X}
157
- ${H.default.gray(M+a8.repeat(Q+2)+eI)}
158
- `)};var CN=H.default.magenta,d1=({indicator:$="dots",onCancel:I,output:N=process.stdout,cancelMessage:G,errorMessage:J,frames:Z=B2?["◒","◐","◓","◑"]:["•","o","O","0"],delay:z=B2?80:120,signal:x,...Q}={})=>{let X=pI(),j,M,R=!1,S=!1,Y="",K,T=performance.now(),C=R0(N),U=Q?.styleFrame??CN,B=(l)=>{let $1=l>1?J??X1.messages.error:G??X1.messages.cancel;S=l===1,R&&(A1($1,l),S&&typeof I=="function"&&I())},_=()=>B(2),L=()=>B(1),f=()=>{process.on("uncaughtExceptionMonitor",_),process.on("unhandledRejection",_),process.on("SIGINT",L),process.on("SIGTERM",L),process.on("exit",B),x&&x.addEventListener("abort",L)},q=()=>{process.removeListener("uncaughtExceptionMonitor",_),process.removeListener("unhandledRejection",_),process.removeListener("SIGINT",L),process.removeListener("SIGTERM",L),process.removeListener("exit",B),x&&x.removeEventListener("abort",L)},g=()=>{if(K===void 0)return;X&&N.write(`
159
- `);let l=T0(K,C,{hard:!0,trim:!1}).split(`
160
- `);l.length>1&&N.write(H0.cursor.up(l.length-1)),N.write(H0.cursor.to(0)),N.write(H0.erase.down())},b=(l)=>l.replace(/\.+$/,""),c=(l)=>{let $1=(performance.now()-l)/1000,Y1=Math.floor($1/60),R1=Math.floor($1%60);return Y1>0?`[${Y1}m ${R1}s]`:`[${R1}s]`},s=(l="")=>{R=!0,j=d8({output:N}),Y=b(l),T=performance.now(),N.write(`${H.default.gray(A)}
161
- `);let $1=0,Y1=0;f(),M=setInterval(()=>{if(X&&Y===K)return;g(),K=Y;let R1=U(Z[$1]),C0;if(X)C0=`${R1} ${Y}...`;else if($==="timer")C0=`${R1} ${Y} ${c(T)}`;else{let i3=".".repeat(Math.floor(Y1)).slice(0,3);C0=`${R1} ${Y}${i3}`}let m3=T0(C0,C,{hard:!0,trim:!1});N.write(m3),$1=$1+1<Z.length?$1+1:0,Y1=Y1<4?Y1+0.125:0},z)},A1=(l="",$1=0,Y1=!1)=>{if(!R)return;R=!1,clearInterval(M),g();let R1=$1===0?H.default.green($$):$1===1?H.default.red(I3):H.default.red(N3);Y=l??Y,Y1||($==="timer"?N.write(`${R1} ${Y} ${c(T)}
162
- `):N.write(`${R1} ${Y}
163
- `)),q(),j()};return{start:s,stop:(l="")=>A1(l,0),message:(l="")=>{Y=b(l??Y)},cancel:(l="")=>A1(l,1),error:(l="")=>A1(l,2),clear:()=>A1("",0,!0),get isCancelled(){return S}}},HG={light:W("─","-"),heavy:W("━","="),block:W("█","#")};var t0=($,I)=>$.includes(`
164
- `)?$.split(`
165
- `).map((N)=>I(N)).join(`
166
- `):I($),p1=($)=>{let I=(N,G)=>{let J=N.label??String(N.value);switch(G){case"disabled":return`${H.default.gray(e0)} ${t0(J,H.default.gray)}${N.hint?` ${H.default.dim(`(${N.hint??"disabled"})`)}`:""}`;case"selected":return`${t0(J,H.default.dim)}`;case"active":return`${H.default.green(g2)} ${J}${N.hint?` ${H.default.dim(`(${N.hint})`)}`:""}`;case"cancelled":return`${t0(J,(Z)=>H.default.strikethrough(H.default.dim(Z)))}`;default:return`${H.default.dim(e0)} ${t0(J,H.default.dim)}`}};return new H2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let N=`${I$(this.state)} `,G=`${G3(this.state)} `,J=l1($.output,$.message,G,N),Z=`${H.default.gray(A)}
167
- ${J}
168
- `;switch(this.state){case"submit":{let z=`${H.default.gray(A)} `,x=l1($.output,I(this.options[this.cursor],"selected"),z);return`${Z}${x}`}case"cancel":{let z=`${H.default.gray(A)} `,x=l1($.output,I(this.options[this.cursor],"cancelled"),z);return`${Z}${x}
169
- ${H.default.gray(A)}`}default:{let z=`${H.default.cyan(A)} `,x=Z.split(`
170
- `).length;return`${Z}${z}${L2({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:z.length,rowPadding:x+2,style:(Q,X)=>I(Q,Q.disabled?"disabled":X?"active":"inactive")}).join(`
171
- ${z}`)}
172
- ${H.default.cyan(V1)}
173
- `}}}}).prompt()};var TG=`${H.default.gray(A)} `;var Z$=($)=>new T2({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let I=($?.withGuide??X1.withGuide)!==!1,N=`${`${I?`${H.default.gray(A)}
174
- `:""}${I$(this.state)} `}${$.message}
175
- `,G=$.placeholder?H.default.inverse($.placeholder[0])+H.default.dim($.placeholder.slice(1)):H.default.inverse(H.default.hidden("_")),J=this.userInput?this.userInputWithCursor:G,Z=this.value??"";switch(this.state){case"error":{let z=this.error?` ${H.default.yellow(this.error)}`:"",x=I?`${H.default.yellow(A)} `:"",Q=I?H.default.yellow(V1):"";return`${N.trim()}
176
- ${x}${J}
177
- ${Q}${z}
178
- `}case"submit":{let z=Z?` ${H.default.dim(Z)}`:"",x=I?H.default.gray(A):"";return`${N}${x}${z}`}case"cancel":{let z=Z?` ${H.default.strikethrough(H.default.dim(Z))}`:"",x=I?H.default.gray(A):"";return`${N}${x}${z}${Z.trim()?`
179
- ${x}`:""}`}default:{let z=I?`${H.default.cyan(A)} `:"",x=I?H.default.cyan(V1):"";return`${N}${z}${J}
180
- ${x}
181
- `}}}}).prompt();var q1=i(x1(),1);import{join as LN}from"node:path";import{existsSync as Q3,mkdirSync as X3,writeFileSync as M3}from"node:fs";import{dirname as BN,join as x$}from"node:path";var z$="first-fluke/oh-my-ag",V2=`https://raw.githubusercontent.com/${z$}/main/.agent/skills`,o1={domain:[{name:"frontend-agent",desc:"React/Next.js UI specialist"},{name:"backend-agent",desc:"FastAPI/SQLAlchemy API specialist"},{name:"mobile-agent",desc:"Flutter/Dart mobile specialist"}],coordination:[{name:"pm-agent",desc:"Product manager - task decomposition"},{name:"qa-agent",desc:"QA - OWASP, Lighthouse, WCAG"},{name:"workflow-guide",desc:"Manual multi-agent orchestration"},{name:"orchestrator",desc:"Automated parallel CLI execution"}],utility:[{name:"debug-agent",desc:"Bug fixing specialist"},{name:"commit",desc:"Conventional Commits helper"}]},j3={fullstack:["frontend-agent","backend-agent","pm-agent","qa-agent","debug-agent","commit"],frontend:["frontend-agent","pm-agent","qa-agent","debug-agent","commit"],backend:["backend-agent","pm-agent","qa-agent","debug-agent","commit"],mobile:["mobile-agent","pm-agent","qa-agent","debug-agent","commit"],all:[...o1.domain,...o1.coordination,...o1.utility].map(($)=>$.name)};async function gN($){let I=["SKILL.md"],N=["resources/execution-protocol.md","resources/tech-stack.md","resources/checklist.md","resources/templates.md","resources/error-playbook.md"];for(let G of N){let J=`${V2}/${$}/${G}`;if((await fetch(J,{method:"HEAD"})).ok)I.push(G)}return I}async function Q$($,I){let N=x$(I,".agent","skills",$),G=await gN($);for(let J of G){let Z=`${V2}/${$}/${J}`,z=await fetch(Z);if(!z.ok)continue;let x=await z.text(),Q=x$(N,J),X=BN(Q);if(!Q3(X))X3(X,{recursive:!0});M3(Q,x,"utf-8")}return!0}async function X$($){let I=x$($,".agent","skills","_shared"),N=["reasoning-templates.md","clarification-protocol.md","context-loading.md","skill-routing.md"];if(!Q3(I))X3(I,{recursive:!0});for(let G of N){let J=`${V2}/_shared/${G}`,Z=await fetch(J);if(!Z.ok)continue;let z=await Z.text();M3(x$(I,G),z,"utf-8")}}function r1(){return[...o1.domain,...o1.coordination,...o1.utility]}async function K3(){console.clear(),t(q1.default.bgMagenta(q1.default.white(" \uD83D\uDEF8 oh-my-ag ")));let $=await p1({message:"What type of project?",options:[{value:"all",label:"✨ All",hint:"Install everything"},{value:"fullstack",label:"\uD83C\uDF10 Fullstack",hint:"Frontend + Backend + PM + QA"},{value:"frontend",label:"\uD83C\uDFA8 Frontend",hint:"React/Next.js"},{value:"backend",label:"⚙️ Backend",hint:"FastAPI/Python"},{value:"mobile",label:"\uD83D\uDCF1 Mobile",hint:"Flutter/Dart"},{value:"custom",label:"\uD83D\uDD27 Custom",hint:"Choose skills"}]});if(d($))G1("Cancelled."),process.exit(0);let I;if($==="custom"){let J=r1(),Z=await J$({message:"Select skills:",options:J.map((z)=>({value:z.name,label:z.name,hint:z.desc})),required:!0});if(d(Z))G1("Cancelled."),process.exit(0);I=Z}else I=j3[$]??[];let N=process.cwd(),G=d1();G.start("Installing skills...");try{await X$(N);for(let J of I)G.message(`Installing ${q1.default.cyan(J)}...`),await Q$(J,N);G.stop("Skills installed!"),F([...I.map((J)=>`${q1.default.green("✓")} ${J}`),"",q1.default.dim(`Location: ${LN(N,".agent","skills")}`)].join(`
182
- `),"Installed"),m(q1.default.green("Done! Open your project in your IDE to use the skills.")),F(`${q1.default.yellow("❤️")} Enjoying oh-my-ag? Give it a star!
183
- ${q1.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Support")}catch(J){G.stop("Installation failed"),a.error(J instanceof Error?J.message:String(J)),process.exit(1)}}var f1=i(x1(),1);async function f2($,I,{concurrency:N=Number.POSITIVE_INFINITY,stopOnError:G=!0,signal:J}={}){return new Promise((Z,z)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof I!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(N)&&N>=1||N===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${N}\` (${typeof N})`);let x=[],Q=[],X=new Map,j=!1,M=!1,R=!1,S=0,Y=0,K=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),T=()=>{B(J.reason)},C=()=>{J?.removeEventListener("abort",T)},U=(L)=>{Z(L),C()},B=(L)=>{j=!0,M=!0,z(L),C()};if(J){if(J.aborted)B(J.reason);J.addEventListener("abort",T,{once:!0})}let _=async()=>{if(M)return;let L=await K.next(),f=Y;if(Y++,L.done){if(R=!0,S===0&&!M){if(!G&&Q.length>0){B(AggregateError(Q));return}if(M=!0,X.size===0){U(x);return}let q=[];for(let[g,b]of x.entries()){if(X.get(g)===Y3)continue;q.push(b)}U(q)}return}S++,(async()=>{try{let q=await L.value;if(M)return;let g=await I(q,f);if(g===Y3)X.set(f,g);x[f]=g,S--,await _()}catch(q){if(G)B(q);else{Q.push(q),S--;try{await _()}catch(g){B(g)}}}})()};(async()=>{for(let L=0;L<N;L++){try{await _()}catch(f){B(f);break}if(R||j)break}})()})}var Y3=Symbol("skip");import{existsSync as A2,mkdirSync as R3,readFileSync as DN,writeFileSync as S3}from"node:fs";import{dirname as H3,join as P2}from"node:path";import{createHash as _N}from"node:crypto";function VN($){return _N("sha256").update($,"utf-8").digest("hex")}async function T3($){let I=P2($,".agent","skills","_version.json");if(!A2(I))return null;try{let N=DN(I,"utf-8");return JSON.parse(N).version||null}catch{return null}}async function U3($,I){let N=P2($,".agent","skills","_version.json"),G=H3(N);if(!A2(G))R3(G,{recursive:!0});S3(N,JSON.stringify({version:I},null,2),"utf-8")}async function q3(){let $=`https://raw.githubusercontent.com/${z$}/main/prompt-manifest.json`,I=await fetch($);if(!I.ok)throw Error("Failed to fetch remote manifest");return await I.json()}async function C3($){let I=`https://raw.githubusercontent.com/${z$}/main/${$.path}`,N=await fetch(I);if(!N.ok)return{path:$.path,success:!1,error:`HTTP ${N.status}`};let G=await N.text();if(VN(G)!==$.sha256)return{path:$.path,success:!1,error:"SHA256 mismatch"};let Z=P2(process.cwd(),$.path),z=H3(Z);if(!A2(z))R3(z,{recursive:!0});return S3(Z,G,"utf-8"),{path:$.path,success:!0}}async function B3(){console.clear(),t(f1.default.bgMagenta(f1.default.white(" \uD83D\uDEF8 oh-my-ag update ")));let $=process.cwd(),I=d1();try{I.start("Checking for updates...");let N=await q3(),G=await T3($);if(G===N.version){I.stop(f1.default.green("Already up to date!")),m(`Current version: ${f1.default.cyan(G)}`);return}I.message(`Updating from ${G||"not installed"} to ${f1.default.cyan(N.version)}...`);let J=await f2(N.files,async(x)=>C3(x),{concurrency:10}),Z=J.filter((x)=>!x.success);if(Z.length>0)I.stop("Update completed with errors"),F(Z.map((x)=>`${f1.default.red("✗")} ${x.path}: ${x.error}`).join(`
184
- `),`${Z.length} files failed`);else I.stop(`Updated to version ${f1.default.cyan(N.version)}!`);await U3($,N.version);let z=J.length-Z.length;m(Z.length>0?`${z} files updated, ${Z.length} failed`:`${z} files updated successfully`)}catch(N){I.stop("Update failed"),a.error(N instanceof Error?N.message:String(N)),process.exit(1)}}import{existsSync as U0,readFileSync as fN,readdirSync as AN}from"node:fs";import{execSync as PN}from"node:child_process";import{join as j$}from"node:path";var P=i(x1(),1);async function M$($,I,N){try{let G=PN(`${I} --version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();return{name:$,installed:!0,version:G,installCmd:N}}catch{return{name:$,installed:!1,installCmd:N}}}async function FN($){let I=process.env.HOME||process.env.USERPROFILE||"",G={gemini:{path:`${I}/.gemini/settings.json`,type:"json"},claude:{path:`${I}/.claude.json`,type:"json"},codex:{path:`${I}/.codex/config.toml`,type:"toml"}}[$];if(!G)return{configured:!1};if(U0(G.path))try{let J=fN(G.path,"utf-8");if(G.type==="json"){let Z=JSON.parse(J);return{configured:!!(Z.mcpServers||Z.mcp),path:G.path}}return{configured:!0,path:G.path}}catch{return{configured:!1}}return{configured:!1}}async function WN(){let $=j$(process.cwd(),".agent","skills");if(!U0($))return[];let I=r1(),N=[];for(let G of I){let J=j$($,G.name),Z=j$(J,"SKILL.md");N.push({name:G.name,installed:U0(J),hasSkillMd:U0(Z)})}return N}async function g3($=!1){let I=process.cwd(),N=await Promise.all([M$("gemini","gemini","bun install --global @anthropic-ai/gemini-cli"),M$("claude","claude","bun install --global @anthropic-ai/claude-code"),M$("codex","codex","bun install --global @openai/codex"),M$("qwen","qwen","bun install --global @qwen-code/qwen-code")]),G=await Promise.all(N.filter((R)=>R.installed).map(async(R)=>{let S=await FN(R.name);return{...R,mcp:S}})),J=await WN(),Z=j$(I,".serena","memories"),z=U0(Z),x=0;if(z)try{x=AN(Z).length}catch{}let Q=N.filter((R)=>!R.installed),X=J.length>0?J.filter((R)=>!R.installed||!R.hasSkillMd):r1().map((R)=>({name:R.name,installed:!1,hasSkillMd:!1})),j=Q.length+G.filter((R)=>!R.mcp.configured).length+X.length;if($){let R={ok:j===0,issues:j,clis:N.map((S)=>({name:S.name,installed:S.installed,version:S.version||null})),mcp:G.map((S)=>({name:S.name,configured:S.mcp.configured,path:S.mcp.path||null})),skills:J.length>0?J.map((S)=>({name:S.name,installed:S.installed,complete:S.hasSkillMd})):[],missingSkills:X.map((S)=>S.name),serena:{exists:z,fileCount:x}};console.log(JSON.stringify(R,null,2)),process.exit(j===0?0:1)}console.clear(),t(P.default.bgMagenta(P.default.white(" \uD83E\uDE7A oh-my-ag doctor ")));let M=d1();try{let R=[P.default.bold("\uD83D\uDD0D CLI Installation Status"),"┌─────────┬──────────┬─────────────┐",`│ ${P.default.bold("CLI")} │ ${P.default.bold("Status")} │ ${P.default.bold("Version")} │`,"├─────────┼──────────┼─────────────┤",...N.map((K)=>{let T=K.installed?P.default.green("✅ Installed"):P.default.red("❌ Missing"),C=K.version||"-";return`│ ${K.name.padEnd(7)} │ ${T.padEnd(8)} │ ${C.padEnd(11)} │`}),"└─────────┴──────────┴─────────────┘"].join(`
185
- `);if(F(R,"CLI Status"),Q.length>0)F(Q.map((K)=>`${P.default.yellow("→")} ${K.name}: ${P.default.dim(K.installCmd)}`).join(`
186
- `),"Install missing CLIs");if(G.length>0){let K=[P.default.bold("\uD83D\uDD17 MCP Connection Status"),"┌─────────┬──────────┬─────────────────────┐",`│ ${P.default.bold("CLI")} │ ${P.default.bold("MCP Config")} │ ${P.default.bold("Path")} │`,"├─────────┼──────────┼─────────────────────┤",...G.map((T)=>{let C=T.mcp.configured?P.default.green("✅ Configured"):P.default.yellow("⚠️ Not configured"),U=T.mcp.path?T.mcp.path.split("/").pop()||"":"-";return`│ ${T.name.padEnd(7)} │ ${C.padEnd(8)} │ ${U.padEnd(19)} │`}),"└─────────┴──────────┴─────────────────────┘"].join(`
187
- `);F(K,"MCP Status")}let S=J.filter((K)=>K.installed).length,Y=J.filter((K)=>K.hasSkillMd).length;if(J.length>0){let K=[P.default.bold(`\uD83D\uDCE6 Skills (${S}/${J.length} installed, ${Y} complete)`),"┌────────────────────┬──────────┬─────────────┐",`│ ${P.default.bold("Skill")} │ ${P.default.bold("Installed")} │ ${P.default.bold("SKILL.md")} │`,"├────────────────────┼──────────┼─────────────┤",...J.map((T)=>{let C=T.installed?P.default.green("✅"):P.default.red("❌"),U=T.hasSkillMd?P.default.green("✅"):P.default.red("❌");return`│ ${T.name.padEnd(18)} │ ${C.padEnd(8)} │ ${U.padEnd(11)} │`}),"└────────────────────┴──────────┴─────────────┘"].join(`
188
- `);F(K,"Skills Status")}else F(P.default.yellow("No skills installed."),"Skills Status");if(X.length>0){let K=await G$({message:`Found ${X.length} missing/incomplete skill(s). Install them?`,initialValue:!0});if(d(K))G1("Cancelled."),process.exit(0);if(K){let T=X.map((B)=>B.name),C=await p1({message:"Which skills to install?",options:[{value:"all",label:`✨ All (${T.length} skills)`,hint:"Recommended"},{value:"select",label:"\uD83D\uDD27 Select individually"}]});if(d(C))G1("Cancelled."),process.exit(0);let U;if(C==="select"){let B=r1(),_=await J$({message:"Select skills to install:",options:X.map((L)=>{let f=B.find((q)=>q.name===L.name);return{value:L.name,label:L.name,hint:f?.desc||""}}),required:!0});if(d(_))G1("Cancelled."),process.exit(0);U=_}else U=T;M.start("Installing skills...");try{await X$(I);for(let B of U)M.message(`Installing ${P.default.cyan(B)}...`),await Q$(B,I);M.stop(`Installed ${U.length} skill(s)!`),F(U.map((B)=>`${P.default.green("✓")} ${B}`).join(`
189
- `),"Installed Skills")}catch(B){M.stop("Installation failed"),a.error(B instanceof Error?B.message:String(B))}}}if(z)F(`${P.default.green("✅")} Serena memory directory exists
190
- ${P.default.dim(`${x} memory files found`)}`,"Serena Memory");else F(`${P.default.yellow("⚠️")} Serena memory directory not found
191
- ${P.default.dim("Dashboard will show 'No agents detected'")}`,"Serena Memory");if(j===0)m(P.default.green("✅ All checks passed! Ready to use."));else m(P.default.yellow(`⚠️ Found ${j} issue(s). See details above.`))}catch(R){if(M)M.stop("Check failed");a.error(R instanceof Error?R.message:String(R)),process.exit(1)}}import{existsSync as R$,mkdirSync as ON,readFileSync as yN,writeFileSync as A3,readdirSync as EN}from"node:fs";import{dirname as lN,join as P3}from"node:path";var M1=i(x1(),1);import{execSync as v1}from"node:child_process";function K$($){try{let N=v1("git diff --stat HEAD~10 2>/dev/null || git diff --stat",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
192
- `),G=N[N.length-1]||"",J=G.match(/(\d+) files? changed/),Z=G.match(/(\d+) insertions?\(\+\)/),z=G.match(/(\d+) deletions?\(-\)/);return{filesChanged:J?.[1]?parseInt(J[1],10):0,linesAdded:Z?.[1]?parseInt(Z[1],10):0,linesRemoved:z?.[1]?parseInt(z[1],10):0}}catch{return{filesChanged:0,linesAdded:0,linesRemoved:0}}}function D3($,I=5){try{return v1(`git log --oneline -${I} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
193
- `).filter(Boolean)}catch{return[]}}function Y$($){try{return v1("git diff --name-only HEAD~5 2>/dev/null || git diff --name-only",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
194
- `).filter(Boolean).slice(0,10)}catch{return[]}}function L3($,I=10){try{return v1(`git log --format="%s" -${I} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
195
- `).filter(Boolean)}catch{return[]}}function _3($){let I={},N=/^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\(.+\))?:/;for(let G of $){let J=G.match(N);if(J){let Z=J[1];I[Z]=(I[Z]||0)+1}}return I}function V3($){try{let I=`${$}/.serena/retrospectives`,N=v1(`ls -t "${I}"/*.json 2>/dev/null | head -1`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();if(!N)return null;let G=v1(`cat "${N}"`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]});return JSON.parse(G).date||null}catch{return null}}function f3($,I){if(!I)return L3($,10);try{let G=new Date(I).toISOString().split("T")[0];return v1(`git log --format="%s" --since="${G}" 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
196
- `).filter(Boolean)}catch{return L3($,10)}}function W2($){return P3($,".serena","metrics.json")}function F2(){return{sessions:0,skillsUsed:{},tasksCompleted:0,totalSessionTime:0,filesChanged:0,linesAdded:0,linesRemoved:0,lastUpdated:new Date().toISOString(),startDate:new Date().toISOString()}}function uN($){let I=W2($);if(R$(I))try{return JSON.parse(yN(I,"utf-8"))}catch{return F2()}return F2()}function vN($,I){let N=W2($),G=lN(N);if(!R$(G))ON(G,{recursive:!0});I.lastUpdated=new Date().toISOString(),A3(N,JSON.stringify(I,null,2),"utf-8")}function wN($){let I=P3($,".serena","memories"),N={};if(!R$(I))return N;try{let G=EN(I);for(let J of G){let Z=J.match(/(?:progress|result)-(\w+)/);if(Z?.[1]){let z=Z[1];N[z]=(N[z]||0)+1}}}catch{}return N}async function F3($=!1,I=!1){let N=process.cwd(),G=W2(N);if(I){if(R$(G))A3(G,JSON.stringify(F2(),null,2),"utf-8");if($)console.log(JSON.stringify({reset:!0}));else console.log(M1.default.green("✅ Metrics reset successfully."));return}let J=uN(N),Z=K$(N),z=wN(N);for(let[M,R]of Object.entries(z))J.skillsUsed[M]=(J.skillsUsed[M]||0)+R;J.filesChanged+=Z.filesChanged,J.linesAdded+=Z.linesAdded,J.linesRemoved+=Z.linesRemoved,J.sessions+=1,vN(N,J);let x=Math.max(1,Math.ceil((Date.now()-new Date(J.startDate).getTime())/86400000)),Q=J.sessions>0?Math.round(J.totalSessionTime/J.sessions):0;if($){console.log(JSON.stringify({...J,gitStats:Z,daysSinceStart:x,avgSessionTime:Q},null,2));return}console.clear(),t(M1.default.bgMagenta(M1.default.white(" \uD83D\uDCCA oh-my-ag stats ")));let X=[M1.default.bold(`\uD83D\uDCC8 Productivity Metrics (${x} days)`),"┌─────────────────────┬──────────────┐",`│ ${M1.default.bold("Metric")} │ ${M1.default.bold("Value")} │`,"├─────────────────────┼──────────────┤",`│ Sessions │ ${String(J.sessions).padEnd(12)} │`,`│ Tasks Completed │ ${String(J.tasksCompleted).padEnd(12)} │`,`│ Files Changed │ ${String(J.filesChanged).padEnd(12)} │`,`│ Lines Added │ ${M1.default.green("+"+J.linesAdded).padEnd(12)} │`,`│ Lines Removed │ ${M1.default.red("-"+J.linesRemoved).padEnd(12)} │`,"└─────────────────────┴──────────────┘"].join(`
197
- `);F(X,"Overview");let j=Object.entries(J.skillsUsed).sort(([,M],[,R])=>R-M).slice(0,5);if(j.length>0){let M=[M1.default.bold("\uD83C\uDFC6 Top Skills Used"),...j.map(([R,S],Y)=>` ${Y+1}. ${R} (${S})`)].join(`
198
- `);F(M,"Skills")}m(M1.default.dim(`Data stored in: ${G}`))}import{existsSync as v3,mkdirSync as mN,writeFileSync as iN,readdirSync as kN,readFileSync as hN}from"node:fs";import{join as l2}from"node:path";var E=i(x1(),1);import{existsSync as O2,readdirSync as bN,readFileSync as S$}from"node:fs";import{join as H$}from"node:path";function y2($){return H$($,".serena","memories")}function W3($){let I=y2($);if(!O2(I))return[];try{return bN(I).filter((N)=>N.endsWith(".md")&&N!==".gitkeep")}catch{return[]}}function O3($,I){let N=$.match(/^progress-(\w+)\.md$/),G=$.match(/^result-(\w+)\.md$/);if(N)return{agent:N[1],type:"progress",content:I.slice(0,500)};if(G)return{agent:G[1],type:"result",content:I.slice(0,500)};return null}function y3($){let I=y2($),N={agents:[],activities:[],completedTasks:[],inProgressTasks:[]};if(!O2(I))return N;let G=W3($);for(let J of G){if(J==="orchestrator-session.md"){try{let z=S$(H$(I,J),"utf-8").match(/session[:\s]+(\S+)/i);if(z)N.sessionId=z[1]}catch{}continue}try{let Z=S$(H$(I,J),"utf-8"),z=O3(J,Z);if(z){if(N.activities.push(z),!N.agents.includes(z.agent))N.agents.push(z.agent);if(z.type==="result"){let x=Z.match(/task[:\s]+(.+)/i)||Z.match(/##\s*(.+)/);if(x)N.completedTasks.push(x[1].trim())}else if(z.type==="progress"){let x=Z.match(/current[:\s]+(.+)/i)||Z.match(/working on[:\s]+(.+)/i);if(x&&!N.completedTasks.includes(x[1].trim()))N.inProgressTasks.push(x[1].trim())}}}catch{}}return N}function E3($,I){let N=[],G=y2($);if(!O2(G))return N;let J=I?new Date(I).getTime():0,Z=W3($);for(let z of Z){if(z==="orchestrator-session.md")continue;try{let x=H$(G,z),Q=S$(x),X=S$(x,"utf-8"),j=O3(z,X);if(j)N.push(j)}catch{}}return N}function l3($){let I=[];for(let N of $){let G=N.content.toLowerCase();if(G.includes("error")||G.includes("fail"))I.push(`${N.agent}: Error handling improved`);if(G.includes("refactor"))I.push(`${N.agent}: Code structure refactored`);if(G.includes("test"))I.push(`${N.agent}: Test coverage added`);if(G.includes("performance")||G.includes("optimize"))I.push(`${N.agent}: Performance optimized`)}return[...new Set(I)].slice(0,5)}function u2($){return l2($,".serena","retrospectives")}function nN($){let I=u2($);if(!v3(I))return[];try{return kN(I).filter((G)=>G.endsWith(".json")).sort().reverse().slice(0,10).map((G)=>JSON.parse(hN(l2(I,G),"utf-8")))}catch{return[]}}function E2($,I){let N=u2($);if(!v3(N))mN(N,{recursive:!0});let G=`${I.date.replace(/[:.]/g,"-")}_${I.id}.json`;iN(l2(N,G),JSON.stringify(I,null,2),"utf-8")}function u3($){let I=V3($),N=f3($,I),G=_3(N),J=K$($),Z=y3($),z=E3($,I||void 0),x=Object.entries(G).sort(([,M],[,R])=>R-M)[0],Q="Development session";if(x){let[M]=x;Q={feat:"Feature development",fix:"Bug fixes and improvements",refactor:"Code refactoring",docs:"Documentation updates",test:"Testing improvements",chore:"Maintenance tasks",build:"Build system updates",perf:"Performance improvements"}[M]||"Development session"}if(J.filesChanged>0)Q+=` (${J.filesChanged} files, +${J.linesAdded}/-${J.linesRemoved})`;if(Z.agents.length>0)Q+=` with ${Z.agents.join(", ")}`;let X=l3(z);if(N.length>0&&X.length===0){if(G.refactor||G.perf)X.push("Code quality and performance improvements");if(G.test)X.push("Enhanced test coverage");if(G.fix)X.push("Issue resolution and stability improvements")}let j=[];if(Z.inProgressTasks.length>0)j.push(...Z.inProgressTasks.slice(0,3));if(N.length>0){let M=N[0]?.toLowerCase()||"";if(M.includes("wip")||M.includes("todo"))j.push("Complete work-in-progress items")}if(j.length===0)j.push("Continue development","Review and test changes");return{summary:Q,learnings:X.slice(0,5),nextSteps:j.slice(0,5)}}async function w3($=!1,I=!1){let N=process.cwd(),G=u2(N),J=nN(N);if($){console.log(JSON.stringify({retrospectives:J},null,2));return}if(!I){let{summary:S,learnings:Y,nextSteps:K}=u3(N),T=Y$(N),C={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:S,keyLearnings:Y,filesChanged:T,nextSteps:K};E2(N,C),console.clear(),t(E.default.bgMagenta(E.default.white(" \uD83D\uDD04 oh-my-ag retro "))),F([E.default.green("✅ Auto-generated retrospective saved!"),"",E.default.bold("Summary:"),S,"",E.default.bold("Key Learnings:"),...Y.map((U)=>` • ${U}`),"",E.default.bold("Next Steps:"),...K.map((U)=>` → ${U}`)].join(`
199
- `),"Saved"),m(E.default.dim(`Stored in: ${G}`));return}console.clear(),t(E.default.bgMagenta(E.default.white(" \uD83D\uDD04 oh-my-ag retro (interactive) ")));let Z=J[0];if(Z)F([E.default.bold("\uD83D\uDCC5 Last Retrospective"),`Date: ${Z.date}`,"",E.default.bold("Summary:"),Z.summary,"",E.default.bold("Key Learnings:"),...Z.keyLearnings.map((S)=>` • ${S}`),"",E.default.bold("Next Steps:"),...Z.nextSteps.map((S)=>` → ${S}`)].join(`
200
- `),"Previous Session");let z=await p1({message:"What would you like to do?",options:[{value:"auto",label:"✨ Auto-generate from git history",hint:"Analyze commits and agent activity"},{value:"manual",label:"\uD83D\uDCDD Create manually",hint:"Write your own retrospective"},{value:"list",label:"\uD83D\uDCCB View past retrospectives"},{value:"exit",label:"\uD83D\uDC4B Exit"}]});if(d(z)||z==="exit"){m(E.default.dim("Goodbye!"));return}if(z==="list"){if(J.length===0)F(E.default.yellow("No retrospectives found."),"History");else{let S=J.map((Y,K)=>`${K+1}. [${Y.date.split("T")[0]}] ${Y.summary.slice(0,50)}...`).join(`
201
- `);F(S,`\uD83D\uDCDA Past Retrospectives (${J.length})`)}m(E.default.dim(`Stored in: ${G}`));return}if(z==="auto"){let{summary:S,learnings:Y,nextSteps:K}=u3(N),T=Y$(N);F([E.default.bold("\uD83E\uDD16 Auto-generated Content"),"",E.default.bold("Summary:"),S,"",E.default.bold("Key Learnings:"),...Y.map((B)=>` • ${B}`),"",E.default.bold("Next Steps:"),...K.map((B)=>` → ${B}`)].join(`
202
- `),"Preview");let C=await G$({message:"Save this retrospective?",initialValue:!0});if(d(C)||!C){G1("Cancelled.");return}let U={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:S,keyLearnings:Y,filesChanged:T,nextSteps:K};E2(N,U),F([E.default.green("✅ Retrospective saved!"),"",`Summary: ${U.summary}`,`Learnings: ${U.keyLearnings.length} items`,`Next steps: ${U.nextSteps.length} items`].join(`
203
- `),"Saved"),m(E.default.dim(`Stored in: ${G}`));return}let x=D3(N),Q=Y$(N);if(x.length>0)F(x.join(`
204
- `),"Recent Commits");if(Q.length>0)F(Q.join(`
205
- `),"Changed Files");let X=await Z$({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(d(X)){G1("Cancelled.");return}let j=await Z$({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(d(j)){G1("Cancelled.");return}let M=await Z$({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(d(M)){G1("Cancelled.");return}let R={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:X,keyLearnings:j.split(",").map((S)=>S.trim()).filter(Boolean),filesChanged:Q,nextSteps:M.split(",").map((S)=>S.trim()).filter(Boolean)};E2(N,R),F([E.default.green("✅ Retrospective saved!"),"",`Summary: ${R.summary}`,`Learnings: ${R.keyLearnings.length} items`,`Next steps: ${R.nextSteps.length} items`].join(`
206
- `),"Saved"),m(E.default.dim(`Stored in: ${G}`))}import{existsSync as v2,readFileSync as w2,readdirSync as b2}from"node:fs";import{execSync as p}from"node:child_process";import{join as q0}from"node:path";var e=i(x1(),1);async function b3($=!1,I=!1){let N=process.cwd(),G=q0(N,".agent","results"),J="/tmp",Z={cleaned:0,skipped:0,details:[]},z=(X)=>{Z.details.push($?`[DRY-RUN] ${X}`:`[CLEAN] ${X}`),Z.cleaned++},x=(X)=>{Z.details.push(`[SKIP] ${X}`),Z.skipped++};try{let X=b2("/tmp").filter((j)=>j.startsWith("subagent-")&&j.endsWith(".pid"));for(let j of X){let M=q0("/tmp",j),R=w2(M,"utf-8").trim();if(!R){if(z(`Removing empty PID file: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}continue}let S=parseInt(R,10);if(isNaN(S)){if(z(`Removing invalid PID file: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}continue}try{if(p(`kill -0 ${S} 2>/dev/null`),z(`Killing orphaned process PID=${S} (from ${M})`),!$)try{p(`kill ${S} 2>/dev/null || true`),await new Promise((Y)=>setTimeout(Y,1000));try{p(`kill -0 ${S} 2>/dev/null`),p(`kill -9 ${S} 2>/dev/null || true`)}catch{}p(`rm -f "${M}"`)}catch{}}catch{if(z(`Removing stale PID file (process gone): ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}}}}catch{}try{let X=b2("/tmp").filter((j)=>j.startsWith("subagent-")&&j.endsWith(".log"));for(let j of X){let M=q0("/tmp",j),R=j.replace(".log",".pid"),S=q0("/tmp",R);if(v2(S))try{let Y=w2(S,"utf-8").trim(),K=parseInt(Y,10);if(!isNaN(K)){p(`kill -0 ${K} 2>/dev/null`),x(`Log file has active process: ${M}`);continue}}catch{}if(z(`Removing stale log file: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}}}catch{}if(v2(G))try{let X=b2(G).filter((j)=>j.startsWith("parallel-"));for(let j of X){let M=q0(G,j,"pids.txt");if(!v2(M))continue;let S=w2(M,"utf-8").split(`
207
- `).filter((K)=>K.trim()),Y=!1;for(let K of S){let[T,C]=K.split(":"),U=parseInt(T?.trim()||"",10);if(isNaN(U))continue;try{if(p(`kill -0 ${U} 2>/dev/null`),Y=!0,z(`Killing orphaned parallel agent PID=${U} (${C?.trim()||"unknown"})`),!$)try{p(`kill ${U} 2>/dev/null || true`),p(`rm -f "${M}"`)}catch{}}catch{}}if(!Y){if(z(`Removing stale PID list: ${M}`),!$)try{p(`rm -f "${M}"`)}catch{}}else if(!$){await new Promise((K)=>setTimeout(K,1000));try{p(`rm -f "${M}"`)}catch{}}}}catch{}else x(`No results directory found: ${G}`);if(I){console.log(JSON.stringify(Z,null,2));return}if(console.clear(),t(e.default.bgMagenta(e.default.white(" \uD83E\uDDF9 oh-my-ag cleanup "))),$)F(e.default.yellow("Dry-run mode — no changes will be made"),"Mode");if(Z.details.length>0){let X=[e.default.bold("Cleanup Details"),...Z.details.map((j)=>{if(j.startsWith("[DRY-RUN]"))return e.default.yellow(j);if(j.startsWith("[CLEAN]"))return e.default.green(j);return e.default.cyan(j)})].join(`
208
- `);F(X,"Details")}let Q=[e.default.bold("Summary"),"┌─────────┬────────┐",`│ ${e.default.bold("Action")} │ ${e.default.bold("Count")} │`,"├─────────┼────────┤",`│ Cleaned │ ${String(Z.cleaned).padEnd(6)} │`,`│ Skipped │ ${String(Z.skipped).padEnd(6)} │`,"└─────────┴────────┘"].join(`
209
- `);if(F(Q,"Results"),$)m(e.default.yellow("Run without --dry-run to apply changes"));else m(e.default.green("Cleanup complete!"))}var cN="1.1.1",C1=new N4;C1.name("oh-my-ag").description("Multi-Agent Skills for Antigravity IDE").version(cN).action(()=>{K3().catch(console.error)});C1.command("dashboard").description("Start terminal dashboard (real-time agent monitoring)").action(()=>{l8()});C1.command("dashboard:web").description("Start web dashboard on http://localhost:9847").action(()=>{y8()});C1.command("update").description("Update skills to latest version from registry").action(()=>{B3().catch(console.error)});C1.command("doctor").description("Check CLI installations, MCP configs, and skill status").option("--json","Output as JSON for CI/CD").action(($)=>{g3($.json).catch(console.error)});C1.command("stats").description("View productivity metrics").option("--json","Output as JSON").option("--reset","Reset metrics data").action(($)=>{F3($.json,$.reset).catch(console.error)});C1.command("retro").description("Session retrospective (learnings & next steps)").option("--json","Output as JSON").option("--interactive","Interactive mode (manual entry)").action(($)=>{w3($.json,$.interactive).catch(console.error)});C1.command("cleanup").description("Clean up orphaned subagent processes and temp files").option("--dry-run","Show what would be cleaned without making changes").option("--json","Output as JSON").action(($)=>{b3($.dryRun,$.json).catch(console.error)});C1.parse();
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(`
214
+ \uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(n.default.dim(` Watching: ${$}
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();