@holdyourvoice/hyv 0.7.3 → 0.7.4

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/dist/index.js CHANGED
@@ -1,342 +1,242 @@
1
- #!/usr/bin/env node
2
- "use strict";var Zo=Object.create;var As=Object.defineProperty;var Qo=Object.getOwnPropertyDescriptor;var ea=Object.getOwnPropertyNames;var ta=Object.getPrototypeOf,sa=Object.prototype.hasOwnProperty;var Ui=(n,e)=>()=>(n&&(e=n(n=0)),e);var A=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ia=(n,e)=>{for(var t in e)As(n,t,{get:e[t],enumerable:!0})},na=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ea(e))!sa.call(n,i)&&i!==t&&As(n,i,{get:()=>e[i],enumerable:!(s=Qo(e,i))||s.enumerable});return n};var _=(n,e,t)=>(t=n!=null?Zo(ta(n)):{},na(e||!n||!n.__esModule?As(t,"default",{value:n,enumerable:!0}):t,n));var ct=A(js=>{var Lt=class extends Error{constructor(e,t,s){super(s),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Fs=class extends Lt{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};js.CommanderError=Lt;js.InvalidArgumentError=Fs});var Dt=A(Ps=>{var{InvalidArgumentError:ra}=ct(),Rs=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new ra(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,s):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function oa(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}Ps.Argument=Rs;Ps.humanReadableArgName=oa});var Ms=A(zi=>{var{humanReadableArgName:aa}=Dt(),Ts=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),s=e._getHelpCommand();return s&&!s._hidden&&t.push(s),this.sortSubcommands&&t.sort((i,r)=>i.name().localeCompare(r.name())),t}compareOptions(e,t){let s=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return s(e).localeCompare(s(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),s=e._getHelpOption();if(s&&!s.hidden){let i=s.short&&e._findOption(s.short),r=s.long&&e._findOption(s.long);!i&&!r?t.push(s):s.long&&!r?t.push(e.createOption(s.long,s.description)):s.short&&!i&&t.push(e.createOption(s.short,s.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let s=e.parent;s;s=s.parent){let i=s.options.filter(r=>!r.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(s=>aa(s)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((s,i)=>Math.max(s,t.subcommandTerm(i).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((s,i)=>Math.max(s,t.optionTerm(i).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((s,i)=>Math.max(s,t.optionTerm(i).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((s,i)=>Math.max(s,t.argumentTerm(i).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let s="";for(let i=e.parent;i;i=i.parent)s=i.name()+" "+s;return s+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let s=`(${t.join(", ")})`;return e.description?`${e.description} ${s}`:s}return e.description}formatHelp(e,t){let s=t.padWidth(e,t),i=t.helpWidth||80,r=2,o=2;function a(m,g){if(g){let b=`${m.padEnd(s+o)}${g}`;return t.wrap(b,i-r,s+o)}return m}function l(m){return m.join(`
3
- `).replace(/^/gm," ".repeat(r))}let c=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(c=c.concat([t.wrap(u,i,0),""]));let f=t.visibleArguments(e).map(m=>a(t.argumentTerm(m),t.argumentDescription(m)));f.length>0&&(c=c.concat(["Arguments:",l(f),""]));let p=t.visibleOptions(e).map(m=>a(t.optionTerm(m),t.optionDescription(m)));if(p.length>0&&(c=c.concat(["Options:",l(p),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(g=>a(t.optionTerm(g),t.optionDescription(g)));m.length>0&&(c=c.concat(["Global Options:",l(m),""]))}let d=t.visibleCommands(e).map(m=>a(t.subcommandTerm(m),t.subcommandDescription(m)));return d.length>0&&(c=c.concat(["Commands:",l(d),""])),c.join(`
4
- `)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,s,i=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${r}]+`);if(e.match(o))return e;let a=t-s;if(a<i)return e;let l=e.slice(0,s),c=e.slice(s).replace(`\r
1
+ "use strict";var dr=Object.create;var Et=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var pr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var x=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var yr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of mr(e))!gr.call(r,o)&&o!==t&&Et(r,o,{get:()=>e[o],enumerable:!(n=fr(e,o))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?dr(pr(r)):{},yr(e||!r||!r.__esModule?Et(t,"default",{value:r,enumerable:!0}):t,r));var fe=x(Le=>{var xe=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},De=class extends xe{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Le.CommanderError=xe;Le.InvalidArgumentError=De});var Ce=x(Be=>{var{InvalidArgumentError:br}=fe(),We=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new br(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function wr(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}Be.Argument=We;Be.humanReadableArgName=wr});var Ge=x(Pt=>{var{humanReadableArgName:_r}=Ce(),Ue=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(o=>!o._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((o,s)=>o.name().localeCompare(s.name())),t}compareOptions(e,t){let n=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(o=>!o.hidden),n=e._getHelpOption();if(n&&!n.hidden){let o=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!o&&!s?t.push(n):n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!o&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let o=n.options.filter(s=>!s.hidden);t.push(...o)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>_r(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,o)=>Math.max(n,t.subcommandTerm(o).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,o)=>Math.max(n,t.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,o)=>Math.max(n,t.optionTerm(o).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,o)=>Math.max(n,t.argumentTerm(o).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let o=e.parent;o;o=o.parent)n=o.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatHelp(e,t){let n=t.padWidth(e,t),o=t.helpWidth||80,s=2,i=2;function a(p,P){if(P){let te=`${p.padEnd(n+i)}${P}`;return t.wrap(te,o-s,n+i)}return p}function l(p){return p.join(`
2
+ `).replace(/^/gm," ".repeat(s))}let u=[`Usage: ${t.commandUsage(e)}`,""],h=t.commandDescription(e);h.length>0&&(u=u.concat([t.wrap(h,o,0),""]));let f=t.visibleArguments(e).map(p=>a(t.argumentTerm(p),t.argumentDescription(p)));f.length>0&&(u=u.concat(["Arguments:",l(f),""]));let w=t.visibleOptions(e).map(p=>a(t.optionTerm(p),t.optionDescription(p)));if(w.length>0&&(u=u.concat(["Options:",l(w),""])),this.showGlobalOptions){let p=t.visibleGlobalOptions(e).map(P=>a(t.optionTerm(P),t.optionDescription(P)));p.length>0&&(u=u.concat(["Global Options:",l(p),""]))}let R=t.visibleCommands(e).map(p=>a(t.subcommandTerm(p),t.subcommandDescription(p)));return R.length>0&&(u=u.concat(["Commands:",l(R),""])),u.join(`
3
+ `)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,n,o=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",i=new RegExp(`[\\n][${s}]+`);if(e.match(i))return e;let a=t-n;if(a<o)return e;let l=e.slice(0,n),u=e.slice(n).replace(`\r
5
4
  `,`
6
- `),u=" ".repeat(s),p="\\s\u200B",d=new RegExp(`
7
- |.{1,${a-1}}([${p}]|$)|[^${p}]+?([${p}]|$)`,"g"),m=c.match(d)||[];return l+m.map((g,b)=>g===`
8
- `?"":(b>0?u:"")+g.trimEnd()).join(`
9
- `)}};zi.Help=Ts});var Ds=A(Ls=>{var{InvalidArgumentError:la}=ct(),Ns=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let s=ha(e);this.short=s.shortFlag,this.long=s.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new la(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,s):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return ca(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Is=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,s)=>{this.positiveOptions.has(s)&&this.dualOptions.add(s)})}valueFromOption(e,t){let s=t.attributeName();if(!this.dualOptions.has(s))return!0;let i=this.negativeOptions.get(s).presetArg,r=i!==void 0?i:!1;return t.negate===(r===e)}};function ca(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ha(n){let e,t,s=n.split(/[ |,]+/);return s.length>1&&!/^[[<]/.test(s[1])&&(e=s.shift()),t=s.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}Ls.Option=Ns;Ls.DualOptions=Is});var Ji=A(Gi=>{function ua(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let s=0;s<=n.length;s++)t[s]=[s];for(let s=0;s<=e.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let i=1;i<=n.length;i++){let r=1;n[i-1]===e[s-1]?r=0:r=1,t[i][s]=Math.min(t[i-1][s]+1,t[i][s-1]+1,t[i-1][s-1]+r),i>1&&s>1&&n[i-1]===e[s-2]&&n[i-2]===e[s-1]&&(t[i][s]=Math.min(t[i][s],t[i-2][s-2]+1))}return t[n.length][e.length]}function fa(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(o=>o.slice(2)));let s=[],i=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let a=ua(n,o),l=Math.max(n.length,o.length);(l-a)/l>r&&(a<i?(i=a,s=[o]):a===i&&s.push(o))}),s.sort((o,a)=>o.localeCompare(a)),t&&(s=s.map(o=>`--${o}`)),s.length>1?`
10
- (Did you mean one of ${s.join(", ")}?)`:s.length===1?`
11
- (Did you mean ${s[0]}?)`:""}Gi.suggestSimilar=fa});var Qi=A(Zi=>{var da=require("node:events").EventEmitter,Ws=require("node:child_process"),de=require("node:path"),Vs=require("node:fs"),O=require("node:process"),{Argument:pa,humanReadableArgName:ga}=Dt(),{CommanderError:Hs}=ct(),{Help:ma}=Ms(),{Option:Yi,DualOptions:ya}=Ds(),{suggestSimilar:Ki}=Ji(),qs=class n extends da{constructor(e){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=e||"",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:t=>O.stdout.write(t),writeErr:t=>O.stderr.write(t),getOutHelpWidth:()=>O.stdout.isTTY?O.stdout.columns:void 0,getErrHelpWidth:()=>O.stderr.isTTY?O.stderr.columns:void 0,outputError:(t,s)=>s(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,s){let i=t,r=s;typeof i=="object"&&i!==null&&(r=i,i=null),r=r||{};let[,o,a]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),r.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(r.noHelp||r.hidden),l._executableFile=r.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new n(e)}createHelp(){return Object.assign(new ma,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
12
- - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new pa(e,t)}argument(e,t,s,i){let r=this.createArgument(e,t);return typeof s=="function"?r.default(i).argParser(s):r.default(s),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,s,i]=e.match(/([^ ]+) *(.*)/),r=t??"display help for command",o=this.createCommand(s);return o.helpOption(!1),i&&o.arguments(i),r&&o.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let s=["preSubcommand","preAction","postAction"];if(!s.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
13
- Expecting one of '${s.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,s){this._exitCallback&&this._exitCallback(new Hs(e,t,s)),O.exit(e)}action(e){let t=s=>{let i=this.registeredArguments.length,r=s.slice(0,i);return this._storeOptionsAsProperties?r[i]=this:r[i]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new Yi(e,t)}_callParseArg(e,t,s,i){try{return e.parseArg(t,s)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${i} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let s=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${s}'
14
- - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),s=t(e).find(i=>this._findCommand(i));if(s){let i=t(this._findCommand(s)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${i}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),s=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(s,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(s,e.defaultValue,"default");let i=(r,o,a)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let l=this.getOptionValue(s);r!==null&&e.parseArg?r=this._callParseArg(e,r,l,o):r!==null&&e.variadic&&(r=e._concatValue(r,l)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(s,r,a)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;i(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;i(r,o,"env")}),this}_optionEx(e,t,s,i,r){if(typeof t=="object"&&t instanceof Yi)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,s);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(r).argParser(i);else if(i instanceof RegExp){let a=i;i=(l,c)=>{let u=a.exec(l);return u?u[0]:c},o.default(r).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,s,i){return this._optionEx({},e,t,s,i)}requiredOption(e,t,s,i){return this._optionEx({mandatory:!0},e,t,s,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,s){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=s,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(s=>{s.getOptionValueSource(e)!==void 0&&(t=s.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){O.versions?.electron&&(t.from="electron");let i=O.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=O.argv),this.rawArgs=e.slice();let s;switch(t.from){case void 0:case"node":this._scriptPath=e[1],s=e.slice(2);break;case"electron":O.defaultApp?(this._scriptPath=e[1],s=e.slice(2)):s=e.slice(1);break;case"user":s=e.slice(0);break;case"eval":s=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",s}parse(e,t){let s=this._prepareUserArgs(e,t);return this._parseCommand([],s),this}async parseAsync(e,t){let s=this._prepareUserArgs(e,t);return await this._parseCommand([],s),this}_executeSubCommand(e,t){t=t.slice();let s=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function r(u,f){let p=de.resolve(u,f);if(Vs.existsSync(p))return p;if(i.includes(de.extname(f)))return;let d=i.find(m=>Vs.existsSync(`${p}${m}`));if(d)return`${p}${d}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let u;try{u=Vs.realpathSync(this._scriptPath)}catch{u=this._scriptPath}a=de.resolve(de.dirname(u),a)}if(a){let u=r(a,o);if(!u&&!e._executableFile&&this._scriptPath){let f=de.basename(this._scriptPath,de.extname(this._scriptPath));f!==this._name&&(u=r(a,`${f}-${e._name}`))}o=u||o}s=i.includes(de.extname(o));let l;O.platform!=="win32"?s?(t.unshift(o),t=Xi(O.execArgv).concat(t),l=Ws.spawn(O.argv[0],t,{stdio:"inherit"})):l=Ws.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=Xi(O.execArgv).concat(t),l=Ws.spawn(O.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{O.on(f,()=>{l.killed===!1&&l.exitCode===null&&l.kill(f)})});let c=this._exitCallback;l.on("close",u=>{u=u??1,c?c(new Hs(u,"commander.executeSubCommandAsync","(close)")):O.exit(u)}),l.on("error",u=>{if(u.code==="ENOENT"){let f=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",p=`'${o}' does not exist
5
+ `),h=" ".repeat(n),w="\\s\u200B",R=new RegExp(`
6
+ |.{1,${a-1}}([${w}]|$)|[^${w}]+?([${w}]|$)`,"g"),p=u.match(R)||[];return l+p.map((P,te)=>P===`
7
+ `?"":(te>0?h:"")+P.trimEnd()).join(`
8
+ `)}};Pt.Help=Ue});var Ke=x(Je=>{var{InvalidArgumentError:vr}=fe(),ze=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=Cr(e);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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new vr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return xr(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Ye=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let o=this.negativeOptions.get(n).presetArg,s=o!==void 0?o:!1;return t.negate===(s===e)}};function xr(r){return r.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Cr(r){let e,t,n=r.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(e=n.shift()),t=n.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}Je.Option=ze;Je.DualOptions=Ye});var Tt=x(Rt=>{function Or(r,e){if(Math.abs(r.length-e.length)>3)return Math.max(r.length,e.length);let t=[];for(let n=0;n<=r.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let o=1;o<=r.length;o++){let s=1;r[o-1]===e[n-1]?s=0:s=1,t[o][n]=Math.min(t[o-1][n]+1,t[o][n-1]+1,t[o-1][n-1]+s),o>1&&n>1&&r[o-1]===e[n-2]&&r[o-2]===e[n-1]&&(t[o][n]=Math.min(t[o][n],t[o-2][n-2]+1))}return t[r.length][e.length]}function Sr(r,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=r.startsWith("--");t&&(r=r.slice(2),e=e.map(i=>i.slice(2)));let n=[],o=3,s=.4;return e.forEach(i=>{if(i.length<=1)return;let a=Or(r,i),l=Math.max(r.length,i.length);(l-a)/l>s&&(a<o?(o=a,n=[i]):a===o&&n.push(i))}),n.sort((i,a)=>i.localeCompare(a)),t&&(n=n.map(i=>`--${i}`)),n.length>1?`
9
+ (Did you mean one of ${n.join(", ")}?)`:n.length===1?`
10
+ (Did you mean ${n[0]}?)`:""}Rt.suggestSimilar=Sr});var Mt=x(jt=>{var kr=require("node:events").EventEmitter,Qe=require("node:child_process"),W=require("node:path"),Xe=require("node:fs"),_=require("node:process"),{Argument:Ar,humanReadableArgName:$r}=Ce(),{CommanderError:Ze}=fe(),{Help:Er}=Ge(),{Option:It,DualOptions:Pr}=Ke(),{suggestSimilar:Ft}=Tt(),et=class r extends kr{constructor(e){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=e||"",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:t=>_.stdout.write(t),writeErr:t=>_.stderr.write(t),getOutHelpWidth:()=>_.stdout.isTTY?_.stdout.columns:void 0,getErrHelpWidth:()=>_.stderr.isTTY?_.stderr.columns:void 0,outputError:(t,n)=>n(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let o=t,s=n;typeof o=="object"&&o!==null&&(s=o,o=null),s=s||{};let[,i,a]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(i);return o&&(l.description(o),l._executableHandler=!0),s.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(s.noHelp||s.hidden),l._executableFile=s.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),o?this:l}createCommand(e){return new r(e)}createHelp(){return Object.assign(new Er,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
11
+ - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Ar(e,t)}argument(e,t,n,o){let s=this.createArgument(e,t);return typeof n=="function"?s.default(o).argParser(n):s.default(n),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,n,o]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",i=this.createCommand(n);return i.helpOption(!1),o&&i.arguments(o),s&&i.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=i,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
12
+ Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new Ze(e,t,n)),_.exit(e)}action(e){let t=n=>{let o=this.registeredArguments.length,s=n.slice(0,o);return this._storeOptionsAsProperties?s[o]=this:s[o]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new It(e,t)}_callParseArg(e,t,n,o){try{return e.parseArg(t,n)}catch(s){if(s.code==="commander.invalidArgument"){let i=`${o} ${s.message}`;this.error(i,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
13
+ - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=o=>[o.name()].concat(o.aliases()),n=t(e).find(o=>this._findCommand(o));if(n){let o=t(this._findCommand(n)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${o}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let o=(s,i,a)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let l=this.getOptionValue(n);s!==null&&e.parseArg?s=this._callParseArg(e,s,l,i):s!==null&&e.variadic&&(s=e._concatValue(s,l)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(n,s,a)};return this.on("option:"+t,s=>{let i=`error: option '${e.flags}' argument '${s}' is invalid.`;o(s,i,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let i=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;o(s,i,"env")}),this}_optionEx(e,t,n,o,s){if(typeof t=="object"&&t instanceof It)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let i=this.createOption(t,n);if(i.makeOptionMandatory(!!e.mandatory),typeof o=="function")i.default(s).argParser(o);else if(o instanceof RegExp){let a=o;o=(l,u)=>{let h=a.exec(l);return h?h[0]:u},i.default(s).argParser(o)}else i.default(o);return this.addOption(i)}option(e,t,n,o){return this._optionEx({},e,t,n,o)}requiredOption(e,t,n,o){return this._optionEx({mandatory:!0},e,t,n,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){_.versions?.electron&&(t.from="electron");let o=_.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(t.from="eval")}e===void 0&&(e=_.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":_.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_executeSubCommand(e,t){t=t.slice();let n=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function s(h,f){let w=W.resolve(h,f);if(Xe.existsSync(w))return w;if(o.includes(W.extname(f)))return;let R=o.find(p=>Xe.existsSync(`${w}${p}`));if(R)return`${w}${R}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let h;try{h=Xe.realpathSync(this._scriptPath)}catch{h=this._scriptPath}a=W.resolve(W.dirname(h),a)}if(a){let h=s(a,i);if(!h&&!e._executableFile&&this._scriptPath){let f=W.basename(this._scriptPath,W.extname(this._scriptPath));f!==this._name&&(h=s(a,`${f}-${e._name}`))}i=h||i}n=o.includes(W.extname(i));let l;_.platform!=="win32"?n?(t.unshift(i),t=Ht(_.execArgv).concat(t),l=Qe.spawn(_.argv[0],t,{stdio:"inherit"})):l=Qe.spawn(i,t,{stdio:"inherit"}):(t.unshift(i),t=Ht(_.execArgv).concat(t),l=Qe.spawn(_.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{_.on(f,()=>{l.killed===!1&&l.exitCode===null&&l.kill(f)})});let u=this._exitCallback;l.on("close",h=>{h=h??1,u?u(new Ze(h,"commander.executeSubCommandAsync","(close)")):_.exit(h)}),l.on("error",h=>{if(h.code==="ENOENT"){let f=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",w=`'${i}' does not exist
15
14
  - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16
15
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
- - ${f}`;throw new Error(p)}else if(u.code==="EACCES")throw new Error(`'${o}' not executable`);if(!c)O.exit(1);else{let f=new Hs(1,"commander.executeSubCommandAsync","(error)");f.nestedError=u,c(f)}}),this.runningCommand=l}_dispatchSubcommand(e,t,s){let i=this._findCommand(e);i||this.help({error:!0});let r;return r=this._chainOrCallSubCommandHook(r,i,"preSubcommand"),r=this._chainOrCall(r,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(s));else return i._parseCommand(t,s)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(s,i,r)=>{let o=i;if(i!==null&&s.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${s.name()}'.`;o=this._callParseArg(s,i,r,a)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((s,i)=>{let r=s.defaultValue;s.variadic?i<this.args.length?(r=this.args.slice(i),s.parseArg&&(r=r.reduce((o,a)=>e(s,a,o),s.defaultValue))):r===void 0&&(r=[]):i<this.args.length&&(r=this.args[i],s.parseArg&&(r=e(s,r,s.defaultValue))),t[i]=r}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let s=e,i=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{i.push({hookedCommand:r,callback:o})})}),t==="postAction"&&i.reverse(),i.forEach(r=>{s=this._chainOrCall(s,()=>r.callback(r.hookedCommand,this))}),s}_chainOrCallSubCommandHook(e,t,s){let i=e;return this._lifeCycleHooks[s]!==void 0&&this._lifeCycleHooks[s].forEach(r=>{i=this._chainOrCall(i,()=>r(this,t))}),i}_parseCommand(e,t){let s=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(s.operands),t=s.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(s.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{s.unknown.length>0&&this.unknownOption(s.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(r))i(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(s=>{let i=s.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(s=>s.conflictsWith.length>0).forEach(s=>{let i=e.find(r=>s.conflictsWith.includes(r.attributeName()));i&&this._conflictingOption(s,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],s=[],i=t,r=e.slice();function o(l){return l.length>1&&l[0]==="-"}let a=null;for(;r.length;){let l=r.shift();if(l==="--"){i===s&&i.push(l),i.push(...r);break}if(a&&!o(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let c=this._findOption(l);if(c){if(c.required){let u=r.shift();u===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,u)}else if(c.optional){let u=null;r.length>0&&!o(r[0])&&(u=r.shift()),this.emit(`option:${c.name()}`,u)}else this.emit(`option:${c.name()}`);a=c.variadic?c:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let c=this._findOption(`-${l[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,l.slice(2)):(this.emit(`option:${c.name()}`),r.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let c=l.indexOf("="),u=this._findOption(l.slice(0,c));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,l.slice(c+1));continue}}if(o(l)&&(i=s),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&s.length===0){if(this._findCommand(l)){t.push(l),r.length>0&&s.push(...r);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),r.length>0&&t.push(...r);break}else if(this._defaultCommandName){s.push(l),r.length>0&&s.push(...r);break}}if(this._passThroughOptions){i.push(l),r.length>0&&i.push(...r);break}i.push(l)}return{operands:t,unknown:s}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let s=0;s<t;s++){let i=this.options[s].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
16
+ - ${f}`;throw new Error(w)}else if(h.code==="EACCES")throw new Error(`'${i}' not executable`);if(!u)_.exit(1);else{let f=new Ze(1,"commander.executeSubCommandAsync","(error)");f.nestedError=h,u(f)}}),this.runningCommand=l}_dispatchSubcommand(e,t,n){let o=this._findCommand(e);o||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,o,"preSubcommand"),s=this._chainOrCall(s,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(n));else return o._parseCommand(t,n)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,o,s)=>{let i=o;if(o!==null&&n.parseArg){let a=`error: command-argument value '${o}' is invalid for argument '${n.name()}'.`;i=this._callParseArg(n,o,s,a)}return i};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,o)=>{let s=n.defaultValue;n.variadic?o<this.args.length?(s=this.args.slice(o),n.parseArg&&(s=s.reduce((i,a)=>e(n,a,i),n.defaultValue))):s===void 0&&(s=[]):o<this.args.length&&(s=this.args[o],n.parseArg&&(s=e(n,s,n.defaultValue))),t[o]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,o=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(i=>{o.push({hookedCommand:s,callback:i})})}),t==="postAction"&&o.reverse(),o.forEach(s=>{n=this._chainOrCall(n,()=>s.callback(s.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let o=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(s=>{o=this._chainOrCall(o,()=>s(this,t))}),o}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let i;return i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,()=>this._actionHandler(this.processedArgs)),this.parent&&(i=this._chainOrCall(i,()=>{this.parent.emit(s,e,t)})),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(s))o(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let o=n.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let o=e.find(s=>n.conflictsWith.includes(s.attributeName()));o&&this._conflictingOption(n,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],o=t,s=e.slice();function i(l){return l.length>1&&l[0]==="-"}let a=null;for(;s.length;){let l=s.shift();if(l==="--"){o===n&&o.push(l),o.push(...s);break}if(a&&!i(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,i(l)){let u=this._findOption(l);if(u){if(u.required){let h=s.shift();h===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,h)}else if(u.optional){let h=null;s.length>0&&!i(s[0])&&(h=s.shift()),this.emit(`option:${u.name()}`,h)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),s.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),h=this._findOption(l.slice(0,u));if(h&&(h.required||h.optional)){this.emit(`option:${h.name()}`,l.slice(u+1));continue}}if(i(l)&&(o=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),s.length>0&&n.push(...s);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),s.length>0&&t.push(...s);break}else if(this._defaultCommandName){n.push(l),s.length>0&&n.push(...s);break}}if(this._passThroughOptions){o.push(l),s.length>0&&o.push(...s);break}o.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let o=this.options[n].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
18
17
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
19
18
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
20
- `),this.outputHelp({error:!0}));let s=t||{},i=s.exitCode||1,r=s.code||"commander.error";this._exit(i,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in O.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,O.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new ya(this.options),t=s=>this.getOptionValue(s)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(s));this.options.filter(s=>s.implied!==void 0&&t(s.attributeName())&&e.valueFromOption(this.getOptionValue(s.attributeName()),s)).forEach(s=>{Object.keys(s.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,s.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let s=o=>{let a=o.attributeName(),l=this.getOptionValue(a),c=this.options.find(f=>f.negate&&a===f.attributeName()),u=this.options.find(f=>!f.negate&&a===f.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:u||o},i=o=>{let a=s(o),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},r=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(a=>a.long).map(a=>a.long);i=i.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=Ki(e,i)}let s=`error: unknown option '${e}'${t}`;this.error(s,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,s=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${s} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(r=>{i.push(r.name()),r.alias()&&i.push(r.alias())}),t=Ki(e,i)}let s=`error: unknown command '${e}'${t}`;this.error(s,{code:"commander.unknownCommand"})}version(e,t,s){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",s=s||"output the version number";let i=this.createOption(t,s);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
21
- `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let s=this.parent?._findCommand(e);if(s){let i=[s.name()].concat(s.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(s=>ga(s));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=de.basename(e,de.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},s;return t.error?s=i=>this._outputConfiguration.writeErr(i):s=i=>this._outputConfiguration.writeOut(i),t.write=e.write||s,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let s=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let i=this.helpInformation(s);if(t&&(i=t(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");s.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",s))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=O.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let s=["beforeAll","before","after","afterAll"];if(!s.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
- Expecting one of '${s.join("', '")}'`);let i=`${e}Help`;return this.on(i,r=>{let o;typeof t=="function"?o=t({error:r.error,command:r.command}):o=t,o&&r.write(`${o}
23
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Xi(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,s="127.0.0.1",i="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:s=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],s=r[3],i=r[4]),t&&i!=="0"?`${t}=${s}:${parseInt(i)+1}`:e})}Zi.Command=qs});var nn=A(K=>{var{Argument:en}=Dt(),{Command:Bs}=Qi(),{CommanderError:ba,InvalidArgumentError:tn}=ct(),{Help:wa}=Ms(),{Option:sn}=Ds();K.program=new Bs;K.createCommand=n=>new Bs(n);K.createOption=(n,e)=>new sn(n,e);K.createArgument=(n,e)=>new en(n,e);K.Command=Bs;K.Option=sn;K.Argument=en;K.Help=wa;K.CommanderError=ba;K.InvalidArgumentError=tn;K.InvalidOptionArgumentError=tn});var zs=A((wu,ln)=>{"use strict";var an=require("fs"),Us;function va(){try{return an.statSync("/.dockerenv"),!0}catch{return!1}}function xa(){try{return an.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}ln.exports=()=>(Us===void 0&&(Us=va()||xa()),Us)});var un=A((vu,Gs)=>{"use strict";var Sa=require("os"),$a=require("fs"),cn=zs(),hn=()=>{if(process.platform!=="linux")return!1;if(Sa.release().toLowerCase().includes("microsoft"))return!cn();try{return $a.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!cn():!1}catch{return!1}};process.env.__IS_WSL_TEST__?Gs.exports=hn:Gs.exports=hn()});var dn=A((xu,fn)=>{"use strict";fn.exports=(n,e,t)=>{let s=i=>Object.defineProperty(n,e,{value:i,enumerable:!0,writable:!0});return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get(){let i=t();return s(i),i},set(i){s(i)}}),n}});var We=A((Su,wn)=>{var _a=require("path"),Ca=require("child_process"),{promises:Vt,constants:bn}=require("fs"),Wt=un(),Ea=zs(),Ys=dn(),pn=_a.join(__dirname,"xdg-open"),{platform:De,arch:gn}=process,ka=()=>{try{return Vt.statSync("/run/.containerenv"),!0}catch{return!1}},Js;function Oa(){return Js===void 0&&(Js=ka()||Ea()),Js}var Aa=(()=>{let n="/mnt/",e;return async function(){if(e)return e;let t="/etc/wsl.conf",s=!1;try{await Vt.access(t,bn.F_OK),s=!0}catch{}if(!s)return n;let i=await Vt.readFile(t,{encoding:"utf8"}),r=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return r?(e=r.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):n}})(),mn=async(n,e)=>{let t;for(let s of n)try{return await e(s)}catch(i){t=i}throw t},Ht=async n=>{if(n={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...n},Array.isArray(n.app))return mn(n.app,a=>Ht({...n,app:a}));let{name:e,arguments:t=[]}=n.app||{};if(t=[...t],Array.isArray(e))return mn(e,a=>Ht({...n,app:{name:a,arguments:t}}));let s,i=[],r={};if(De==="darwin")s="open",n.wait&&i.push("--wait-apps"),n.background&&i.push("--background"),n.newInstance&&i.push("--new"),e&&i.push("-a",e);else if(De==="win32"||Wt&&!Oa()&&!e){let a=await Aa();s=Wt?`${a}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:`${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`,i.push("-NoProfile","-NonInteractive","\u2013ExecutionPolicy","Bypass","-EncodedCommand"),Wt||(r.windowsVerbatimArguments=!0);let l=["Start"];n.wait&&l.push("-Wait"),e?(l.push(`"\`"${e}\`""`,"-ArgumentList"),n.target&&t.unshift(n.target)):n.target&&l.push(`"${n.target}"`),t.length>0&&(t=t.map(c=>`"\`"${c}\`""`),l.push(t.join(","))),n.target=Buffer.from(l.join(" "),"utf16le").toString("base64")}else{if(e)s=e;else{let a=!__dirname||__dirname==="/",l=!1;try{await Vt.access(pn,bn.X_OK),l=!0}catch{}s=process.versions.electron||De==="android"||a||!l?"xdg-open":pn}t.length>0&&i.push(...t),n.wait||(r.stdio="ignore",r.detached=!0)}n.target&&i.push(n.target),De==="darwin"&&t.length>0&&i.push("--args",...t);let o=Ca.spawn(s,i,r);return n.wait?new Promise((a,l)=>{o.once("error",l),o.once("close",c=>{if(!n.allowNonzeroExitCode&&c>0){l(new Error(`Exited with code ${c}`));return}a(o)})}):(o.unref(),o)},Ks=(n,e)=>{if(typeof n!="string")throw new TypeError("Expected a `target`");return Ht({...e,target:n})},Fa=(n,e)=>{if(typeof n!="string")throw new TypeError("Expected a `name`");let{arguments:t=[]}=e||{};if(t!=null&&!Array.isArray(t))throw new TypeError("Expected `appArguments` as Array type");return Ht({...e,app:{name:n,arguments:t}})};function yn(n){if(typeof n=="string"||Array.isArray(n))return n;let{[gn]:e}=n;if(!e)throw new Error(`${gn} is not supported`);return e}function Xs({[De]:n},{wsl:e}){if(e&&Wt)return yn(e);if(!n)throw new Error(`${De} is not supported`);return yn(n)}var qt={};Ys(qt,"chrome",()=>Xs({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Ys(qt,"firefox",()=>Xs({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Ys(qt,"edge",()=>Xs({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Ks.apps=qt;Ks.openApp=Fa;wn.exports=Ks});function Ra(n){G.existsSync(n)||G.mkdirSync(n,{recursive:!0})}function xe(){let n=process.env.HYV_API_KEY;if(n)return{api_key:n,base_url:process.env.HYV_BASE_URL||"https://holdyourvoice.com"};try{let e=G.readFileSync(xn,"utf-8"),t=JSON.parse(e);return t.api_key?t:null}catch{return null}}function Bt(n){Ra(Zs),G.writeFileSync(xn,JSON.stringify(n,null,2))}function Ut(){let n=Fe.join(process.cwd(),".hyv.yml");if(!G.existsSync(n))return{};try{let e=G.readFileSync(n,"utf-8"),t={};for(let s of e.split(`
24
- `)){let i=s.trim();if(!i||i.startsWith("#"))continue;let r=i.indexOf(":");if(r===-1)continue;let o=i.slice(0,r).trim(),a=i.slice(r+1).trim();o==="profile"?t.profile=a:o==="scan_paths"?t.scan_paths=a.split(",").map(l=>l.trim()):o==="ignore"&&(t.ignore=a.split(",").map(l=>l.trim()))}return t}catch{return{}}}function Qs(n){let e=Fe.join(process.cwd(),".hyv.yml"),t=["# hold your voice \u2014 project config"];n.profile&&t.push(`profile: ${n.profile}`),n.scan_paths?.length&&t.push(`scan_paths: ${n.scan_paths.join(", ")}`),G.writeFileSync(e,t.join(`
25
- `)+`
26
- `)}function Sn(n){let e=Fe.join(ja,`${n}.md`);try{return G.readFileSync(e,"utf-8")}catch{return null}}var G,Fe,vn,Zs,xn,ja,je=Ui(()=>{"use strict";G=_(require("fs")),Fe=_(require("path")),vn=_(require("os")),Zs=Fe.join(vn.homedir(),".hyv"),xn=Fe.join(Zs,"credentials.json"),ja=Fe.join(Zs,"profiles")});var zt={};ia(zt,{apiGet:()=>k,apiPost:()=>T,requireSubscription:()=>ht});async function $n(n,e,t){let s=xe();if(!s)throw new Error("you're not signed in yet. run: hyv init");let i=`${s.base_url||Pa}${e}`,r={method:n,headers:{Authorization:`Bearer ${s.api_key}`,"Content-Type":"application/json"}};t&&(r.body=JSON.stringify(t));let o;try{o=await fetch(i,r)}catch{throw new Error("Can't reach the server. Check your internet connection and try again.")}if(o.status===401)throw new Error("your session expired. run: hyv init to sign in again.");if(o.status===403)throw new Error("you don't have access to this feature. check your plan at holdyourvoice.com/dashboard");if(!o.ok){let a=await o.text().catch(()=>"");throw new Error(`something went wrong (${o.status}). ${a.slice(0,150)}`)}return o.json()}function k(n){return $n("GET",n)}function T(n,e){return $n("POST",n,e)}async function ht(){let n;try{n=await k("/cli/heartbeat")}catch(e){let t=e.message||"";throw t.includes("not signed in")||t.includes("session expired")||t.includes("don't have access")?e:new Error("Can't reach the server. Check your internet connection and try again.")}if(!n.plan||n.plan.toLowerCase()==="none"||n.status==="none")throw new Error("You don't have an active subscription yet. Run: hyv plan --upgrade to start for $1.")}var Pa,V=Ui(()=>{"use strict";je();Pa="https://holdyourvoice.com"});var Cn=A((Cu,_n)=>{"use strict";_n.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var ei=A((Eu,kn)=>{var ut=Cn(),En={};for(let n of Object.keys(ut))En[ut[n]]=n;var w={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};kn.exports=w;for(let n of Object.keys(w)){if(!("channels"in w[n]))throw new Error("missing channels property: "+n);if(!("labels"in w[n]))throw new Error("missing channel labels property: "+n);if(w[n].labels.length!==w[n].channels)throw new Error("channel and label counts mismatch: "+n);let{channels:e,labels:t}=w[n];delete w[n].channels,delete w[n].labels,Object.defineProperty(w[n],"channels",{value:e}),Object.defineProperty(w[n],"labels",{value:t})}w.rgb.hsl=function(n){let e=n[0]/255,t=n[1]/255,s=n[2]/255,i=Math.min(e,t,s),r=Math.max(e,t,s),o=r-i,a,l;r===i?a=0:e===r?a=(t-s)/o:t===r?a=2+(s-e)/o:s===r&&(a=4+(e-t)/o),a=Math.min(a*60,360),a<0&&(a+=360);let c=(i+r)/2;return r===i?l=0:c<=.5?l=o/(r+i):l=o/(2-r-i),[a,l*100,c*100]};w.rgb.hsv=function(n){let e,t,s,i,r,o=n[0]/255,a=n[1]/255,l=n[2]/255,c=Math.max(o,a,l),u=c-Math.min(o,a,l),f=function(p){return(c-p)/6/u+1/2};return u===0?(i=0,r=0):(r=u/c,e=f(o),t=f(a),s=f(l),o===c?i=s-t:a===c?i=1/3+e-s:l===c&&(i=2/3+t-e),i<0?i+=1:i>1&&(i-=1)),[i*360,r*100,c*100]};w.rgb.hwb=function(n){let e=n[0],t=n[1],s=n[2],i=w.rgb.hsl(n)[0],r=1/255*Math.min(e,Math.min(t,s));return s=1-1/255*Math.max(e,Math.max(t,s)),[i,r*100,s*100]};w.rgb.cmyk=function(n){let e=n[0]/255,t=n[1]/255,s=n[2]/255,i=Math.min(1-e,1-t,1-s),r=(1-e-i)/(1-i)||0,o=(1-t-i)/(1-i)||0,a=(1-s-i)/(1-i)||0;return[r*100,o*100,a*100,i*100]};function Ta(n,e){return(n[0]-e[0])**2+(n[1]-e[1])**2+(n[2]-e[2])**2}w.rgb.keyword=function(n){let e=En[n];if(e)return e;let t=1/0,s;for(let i of Object.keys(ut)){let r=ut[i],o=Ta(n,r);o<t&&(t=o,s=i)}return s};w.keyword.rgb=function(n){return ut[n]};w.rgb.xyz=function(n){let e=n[0]/255,t=n[1]/255,s=n[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92;let i=e*.4124+t*.3576+s*.1805,r=e*.2126+t*.7152+s*.0722,o=e*.0193+t*.1192+s*.9505;return[i*100,r*100,o*100]};w.rgb.lab=function(n){let e=w.rgb.xyz(n),t=e[0],s=e[1],i=e[2];t/=95.047,s/=100,i/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;let r=116*s-16,o=500*(t-s),a=200*(s-i);return[r,o,a]};w.hsl.rgb=function(n){let e=n[0]/360,t=n[1]/100,s=n[2]/100,i,r,o;if(t===0)return o=s*255,[o,o,o];s<.5?i=s*(1+t):i=s+t-s*t;let a=2*s-i,l=[0,0,0];for(let c=0;c<3;c++)r=e+1/3*-(c-1),r<0&&r++,r>1&&r--,6*r<1?o=a+(i-a)*6*r:2*r<1?o=i:3*r<2?o=a+(i-a)*(2/3-r)*6:o=a,l[c]=o*255;return l};w.hsl.hsv=function(n){let e=n[0],t=n[1]/100,s=n[2]/100,i=t,r=Math.max(s,.01);s*=2,t*=s<=1?s:2-s,i*=r<=1?r:2-r;let o=(s+t)/2,a=s===0?2*i/(r+i):2*t/(s+t);return[e,a*100,o*100]};w.hsv.rgb=function(n){let e=n[0]/60,t=n[1]/100,s=n[2]/100,i=Math.floor(e)%6,r=e-Math.floor(e),o=255*s*(1-t),a=255*s*(1-t*r),l=255*s*(1-t*(1-r));switch(s*=255,i){case 0:return[s,l,o];case 1:return[a,s,o];case 2:return[o,s,l];case 3:return[o,a,s];case 4:return[l,o,s];case 5:return[s,o,a]}};w.hsv.hsl=function(n){let e=n[0],t=n[1]/100,s=n[2]/100,i=Math.max(s,.01),r,o;o=(2-t)*s;let a=(2-t)*i;return r=t*i,r/=a<=1?a:2-a,r=r||0,o/=2,[e,r*100,o*100]};w.hwb.rgb=function(n){let e=n[0]/360,t=n[1]/100,s=n[2]/100,i=t+s,r;i>1&&(t/=i,s/=i);let o=Math.floor(6*e),a=1-s;r=6*e-o,o&1&&(r=1-r);let l=t+r*(a-t),c,u,f;switch(o){default:case 6:case 0:c=a,u=l,f=t;break;case 1:c=l,u=a,f=t;break;case 2:c=t,u=a,f=l;break;case 3:c=t,u=l,f=a;break;case 4:c=l,u=t,f=a;break;case 5:c=a,u=t,f=l;break}return[c*255,u*255,f*255]};w.cmyk.rgb=function(n){let e=n[0]/100,t=n[1]/100,s=n[2]/100,i=n[3]/100,r=1-Math.min(1,e*(1-i)+i),o=1-Math.min(1,t*(1-i)+i),a=1-Math.min(1,s*(1-i)+i);return[r*255,o*255,a*255]};w.xyz.rgb=function(n){let e=n[0]/100,t=n[1]/100,s=n[2]/100,i,r,o;return i=e*3.2406+t*-1.5372+s*-.4986,r=e*-.9689+t*1.8758+s*.0415,o=e*.0557+t*-.204+s*1.057,i=i>.0031308?1.055*i**(1/2.4)-.055:i*12.92,r=r>.0031308?1.055*r**(1/2.4)-.055:r*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,i=Math.min(Math.max(0,i),1),r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),[i*255,r*255,o*255]};w.xyz.lab=function(n){let e=n[0],t=n[1],s=n[2];e/=95.047,t/=100,s/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,t=t>.008856?t**(1/3):7.787*t+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let i=116*t-16,r=500*(e-t),o=200*(t-s);return[i,r,o]};w.lab.xyz=function(n){let e=n[0],t=n[1],s=n[2],i,r,o;r=(e+16)/116,i=t/500+r,o=r-s/200;let a=r**3,l=i**3,c=o**3;return r=a>.008856?a:(r-16/116)/7.787,i=l>.008856?l:(i-16/116)/7.787,o=c>.008856?c:(o-16/116)/7.787,i*=95.047,r*=100,o*=108.883,[i,r,o]};w.lab.lch=function(n){let e=n[0],t=n[1],s=n[2],i;i=Math.atan2(s,t)*360/2/Math.PI,i<0&&(i+=360);let o=Math.sqrt(t*t+s*s);return[e,o,i]};w.lch.lab=function(n){let e=n[0],t=n[1],i=n[2]/360*2*Math.PI,r=t*Math.cos(i),o=t*Math.sin(i);return[e,r,o]};w.rgb.ansi16=function(n,e=null){let[t,s,i]=n,r=e===null?w.rgb.hsv(n)[2]:e;if(r=Math.round(r/50),r===0)return 30;let o=30+(Math.round(i/255)<<2|Math.round(s/255)<<1|Math.round(t/255));return r===2&&(o+=60),o};w.hsv.ansi16=function(n){return w.rgb.ansi16(w.hsv.rgb(n),n[2])};w.rgb.ansi256=function(n){let e=n[0],t=n[1],s=n[2];return e===t&&t===s?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(s/255*5)};w.ansi16.rgb=function(n){let e=n%10;if(e===0||e===7)return n>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let t=(~~(n>50)+1)*.5,s=(e&1)*t*255,i=(e>>1&1)*t*255,r=(e>>2&1)*t*255;return[s,i,r]};w.ansi256.rgb=function(n){if(n>=232){let r=(n-232)*10+8;return[r,r,r]}n-=16;let e,t=Math.floor(n/36)/5*255,s=Math.floor((e=n%36)/6)/5*255,i=e%6/5*255;return[t,s,i]};w.rgb.hex=function(n){let t=(((Math.round(n[0])&255)<<16)+((Math.round(n[1])&255)<<8)+(Math.round(n[2])&255)).toString(16).toUpperCase();return"000000".substring(t.length)+t};w.hex.rgb=function(n){let e=n.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let t=e[0];e[0].length===3&&(t=t.split("").map(a=>a+a).join(""));let s=parseInt(t,16),i=s>>16&255,r=s>>8&255,o=s&255;return[i,r,o]};w.rgb.hcg=function(n){let e=n[0]/255,t=n[1]/255,s=n[2]/255,i=Math.max(Math.max(e,t),s),r=Math.min(Math.min(e,t),s),o=i-r,a,l;return o<1?a=r/(1-o):a=0,o<=0?l=0:i===e?l=(t-s)/o%6:i===t?l=2+(s-e)/o:l=4+(e-t)/o,l/=6,l%=1,[l*360,o*100,a*100]};w.hsl.hcg=function(n){let e=n[1]/100,t=n[2]/100,s=t<.5?2*e*t:2*e*(1-t),i=0;return s<1&&(i=(t-.5*s)/(1-s)),[n[0],s*100,i*100]};w.hsv.hcg=function(n){let e=n[1]/100,t=n[2]/100,s=e*t,i=0;return s<1&&(i=(t-s)/(1-s)),[n[0],s*100,i*100]};w.hcg.rgb=function(n){let e=n[0]/360,t=n[1]/100,s=n[2]/100;if(t===0)return[s*255,s*255,s*255];let i=[0,0,0],r=e%1*6,o=r%1,a=1-o,l=0;switch(Math.floor(r)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=a,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=a,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=a}return l=(1-t)*s,[(t*i[0]+l)*255,(t*i[1]+l)*255,(t*i[2]+l)*255]};w.hcg.hsv=function(n){let e=n[1]/100,t=n[2]/100,s=e+t*(1-e),i=0;return s>0&&(i=e/s),[n[0],i*100,s*100]};w.hcg.hsl=function(n){let e=n[1]/100,s=n[2]/100*(1-e)+.5*e,i=0;return s>0&&s<.5?i=e/(2*s):s>=.5&&s<1&&(i=e/(2*(1-s))),[n[0],i*100,s*100]};w.hcg.hwb=function(n){let e=n[1]/100,t=n[2]/100,s=e+t*(1-e);return[n[0],(s-e)*100,(1-s)*100]};w.hwb.hcg=function(n){let e=n[1]/100,s=1-n[2]/100,i=s-e,r=0;return i<1&&(r=(s-i)/(1-i)),[n[0],i*100,r*100]};w.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]};w.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]};w.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]};w.gray.hsl=function(n){return[0,0,n[0]]};w.gray.hsv=w.gray.hsl;w.gray.hwb=function(n){return[0,100,n[0]]};w.gray.cmyk=function(n){return[0,0,0,n[0]]};w.gray.lab=function(n){return[n[0],0,0]};w.gray.hex=function(n){let e=Math.round(n[0]/100*255)&255,s=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(s.length)+s};w.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]}});var An=A((ku,On)=>{var Gt=ei();function Ma(){let n={},e=Object.keys(Gt);for(let t=e.length,s=0;s<t;s++)n[e[s]]={distance:-1,parent:null};return n}function Na(n){let e=Ma(),t=[n];for(e[n].distance=0;t.length;){let s=t.pop(),i=Object.keys(Gt[s]);for(let r=i.length,o=0;o<r;o++){let a=i[o],l=e[a];l.distance===-1&&(l.distance=e[s].distance+1,l.parent=s,t.unshift(a))}}return e}function Ia(n,e){return function(t){return e(n(t))}}function La(n,e){let t=[e[n].parent,n],s=Gt[e[n].parent][n],i=e[n].parent;for(;e[i].parent;)t.unshift(e[i].parent),s=Ia(Gt[e[i].parent][i],s),i=e[i].parent;return s.conversion=t,s}On.exports=function(n){let e=Na(n),t={},s=Object.keys(e);for(let i=s.length,r=0;r<i;r++){let o=s[r];e[o].parent!==null&&(t[o]=La(o,e))}return t}});var jn=A((Ou,Fn)=>{var ti=ei(),Da=An(),Ve={},Wa=Object.keys(ti);function Va(n){let e=function(...t){let s=t[0];return s==null?s:(s.length>1&&(t=s),n(t))};return"conversion"in n&&(e.conversion=n.conversion),e}function Ha(n){let e=function(...t){let s=t[0];if(s==null)return s;s.length>1&&(t=s);let i=n(t);if(typeof i=="object")for(let r=i.length,o=0;o<r;o++)i[o]=Math.round(i[o]);return i};return"conversion"in n&&(e.conversion=n.conversion),e}Wa.forEach(n=>{Ve[n]={},Object.defineProperty(Ve[n],"channels",{value:ti[n].channels}),Object.defineProperty(Ve[n],"labels",{value:ti[n].labels});let e=Da(n);Object.keys(e).forEach(s=>{let i=e[s];Ve[n][s]=Ha(i),Ve[n][s].raw=Va(i)})});Fn.exports=Ve});var In=A((Au,Nn)=>{"use strict";var Rn=(n,e)=>(...t)=>`\x1B[${n(...t)+e}m`,Pn=(n,e)=>(...t)=>{let s=n(...t);return`\x1B[${38+e};5;${s}m`},Tn=(n,e)=>(...t)=>{let s=n(...t);return`\x1B[${38+e};2;${s[0]};${s[1]};${s[2]}m`},Jt=n=>n,Mn=(n,e,t)=>[n,e,t],He=(n,e,t)=>{Object.defineProperty(n,e,{get:()=>{let s=t();return Object.defineProperty(n,e,{value:s,enumerable:!0,configurable:!0}),s},enumerable:!0,configurable:!0})},si,qe=(n,e,t,s)=>{si===void 0&&(si=jn());let i=s?10:0,r={};for(let[o,a]of Object.entries(si)){let l=o==="ansi16"?"ansi":o;o===e?r[l]=n(t,i):typeof a=="object"&&(r[l]=n(a[e],i))}return r};function qa(){let n=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[t,s]of Object.entries(e)){for(let[i,r]of Object.entries(s))e[i]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},s[i]=e[i],n.set(r[0],r[1]);Object.defineProperty(e,t,{value:s,enumerable:!1})}return Object.defineProperty(e,"codes",{value:n,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",He(e.color,"ansi",()=>qe(Rn,"ansi16",Jt,!1)),He(e.color,"ansi256",()=>qe(Pn,"ansi256",Jt,!1)),He(e.color,"ansi16m",()=>qe(Tn,"rgb",Mn,!1)),He(e.bgColor,"ansi",()=>qe(Rn,"ansi16",Jt,!0)),He(e.bgColor,"ansi256",()=>qe(Pn,"ansi256",Jt,!0)),He(e.bgColor,"ansi16m",()=>qe(Tn,"rgb",Mn,!0)),e}Object.defineProperty(Nn,"exports",{enumerable:!0,get:qa})});var Dn=A((Fu,Ln)=>{"use strict";Ln.exports=(n,e=process.argv)=>{let t=n.startsWith("-")?"":n.length===1?"-":"--",s=e.indexOf(t+n),i=e.indexOf("--");return s!==-1&&(i===-1||s<i)}});var Hn=A((ju,Vn)=>{"use strict";var Ba=require("os"),Wn=require("tty"),X=Dn(),{env:M}=process,Se;X("no-color")||X("no-colors")||X("color=false")||X("color=never")?Se=0:(X("color")||X("colors")||X("color=true")||X("color=always"))&&(Se=1);"FORCE_COLOR"in M&&(M.FORCE_COLOR==="true"?Se=1:M.FORCE_COLOR==="false"?Se=0:Se=M.FORCE_COLOR.length===0?1:Math.min(parseInt(M.FORCE_COLOR,10),3));function ii(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}function ni(n,e){if(Se===0)return 0;if(X("color=16m")||X("color=full")||X("color=truecolor"))return 3;if(X("color=256"))return 2;if(n&&!e&&Se===void 0)return 0;let t=Se||0;if(M.TERM==="dumb")return t;if(process.platform==="win32"){let s=Ba.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in M)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(s=>s in M)||M.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in M)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(M.TEAMCITY_VERSION)?1:0;if(M.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in M){let s=parseInt((M.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(M.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(M.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(M.TERM)||"COLORTERM"in M?1:t}function Ua(n){let e=ni(n,n&&n.isTTY);return ii(e)}Vn.exports={supportsColor:Ua,stdout:ii(ni(!0,Wn.isatty(1))),stderr:ii(ni(!0,Wn.isatty(2)))}});var Bn=A((Ru,qn)=>{"use strict";var za=(n,e,t)=>{let s=n.indexOf(e);if(s===-1)return n;let i=e.length,r=0,o="";do o+=n.substr(r,s-r)+e+t,r=s+i,s=n.indexOf(e,r);while(s!==-1);return o+=n.substr(r),o},Ga=(n,e,t,s)=>{let i=0,r="";do{let o=n[s-1]==="\r";r+=n.substr(i,(o?s-1:s)-i)+e+(o?`\r
19
+ `),this.outputHelp({error:!0}));let n=t||{},o=n.exitCode||1,s=n.code||"commander.error";this._exit(o,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in _.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,_.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Pr(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,n.implied[o],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=i=>{let a=i.attributeName(),l=this.getOptionValue(a),u=this.options.find(f=>f.negate&&a===f.attributeName()),h=this.options.find(f=>!f.negate&&a===f.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:h||i},o=i=>{let a=n(i),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],s=this;do{let i=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);o=o.concat(i),s=s.parent}while(s&&!s._enablePositionalOptions);t=Ft(e,o)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(s=>{o.push(s.name()),s.alias()&&o.push(s.alias())}),t=Ft(e,o)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let o=this.createOption(t,n);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
20
+ `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let o=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${o}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>$r(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=W.basename(e,W.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},n;return t.error?n=o=>this._outputConfiguration.writeErr(o):n=o=>this._outputConfiguration.writeOut(o),t.write=e.write||n,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let o=this.helpInformation(n);if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",n))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=_.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
21
+ Expecting one of '${n.join("', '")}'`);let o=`${e}Help`;return this.on(o,s=>{let i;typeof t=="function"?i=t({error:s.error,command:s.command}):i=t,i&&s.write(`${i}
22
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Ht(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",o="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?o=s[3]:n=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],n=s[3],o=s[4]),t&&o!=="0"?`${t}=${n}:${parseInt(o)+1}`:e})}jt.Command=et});var Dt=x(j=>{var{Argument:Nt}=Ce(),{Command:tt}=Mt(),{CommanderError:Rr,InvalidArgumentError:qt}=fe(),{Help:Tr}=Ge(),{Option:Vt}=Ke();j.program=new tt;j.createCommand=r=>new tt(r);j.createOption=(r,e)=>new Vt(r,e);j.createArgument=(r,e)=>new Nt(r,e);j.Command=tt;j.Option=Vt;j.Argument=Nt;j.Help=Tr;j.CommanderError=Rr;j.InvalidArgumentError=qt;j.InvalidOptionArgumentError=qt});var Ut=x((ns,Bt)=>{"use strict";Bt.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var nt=x((rs,zt)=>{var me=Ut(),Gt={};for(let r of Object.keys(me))Gt[me[r]]=r;var d={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};zt.exports=d;for(let r of Object.keys(d)){if(!("channels"in d[r]))throw new Error("missing channels property: "+r);if(!("labels"in d[r]))throw new Error("missing channel labels property: "+r);if(d[r].labels.length!==d[r].channels)throw new Error("channel and label counts mismatch: "+r);let{channels:e,labels:t}=d[r];delete d[r].channels,delete d[r].labels,Object.defineProperty(d[r],"channels",{value:e}),Object.defineProperty(d[r],"labels",{value:t})}d.rgb.hsl=function(r){let e=r[0]/255,t=r[1]/255,n=r[2]/255,o=Math.min(e,t,n),s=Math.max(e,t,n),i=s-o,a,l;s===o?a=0:e===s?a=(t-n)/i:t===s?a=2+(n-e)/i:n===s&&(a=4+(e-t)/i),a=Math.min(a*60,360),a<0&&(a+=360);let u=(o+s)/2;return s===o?l=0:u<=.5?l=i/(s+o):l=i/(2-s-o),[a,l*100,u*100]};d.rgb.hsv=function(r){let e,t,n,o,s,i=r[0]/255,a=r[1]/255,l=r[2]/255,u=Math.max(i,a,l),h=u-Math.min(i,a,l),f=function(w){return(u-w)/6/h+1/2};return h===0?(o=0,s=0):(s=h/u,e=f(i),t=f(a),n=f(l),i===u?o=n-t:a===u?o=1/3+e-n:l===u&&(o=2/3+t-e),o<0?o+=1:o>1&&(o-=1)),[o*360,s*100,u*100]};d.rgb.hwb=function(r){let e=r[0],t=r[1],n=r[2],o=d.rgb.hsl(r)[0],s=1/255*Math.min(e,Math.min(t,n));return n=1-1/255*Math.max(e,Math.max(t,n)),[o,s*100,n*100]};d.rgb.cmyk=function(r){let e=r[0]/255,t=r[1]/255,n=r[2]/255,o=Math.min(1-e,1-t,1-n),s=(1-e-o)/(1-o)||0,i=(1-t-o)/(1-o)||0,a=(1-n-o)/(1-o)||0;return[s*100,i*100,a*100,o*100]};function Ir(r,e){return(r[0]-e[0])**2+(r[1]-e[1])**2+(r[2]-e[2])**2}d.rgb.keyword=function(r){let e=Gt[r];if(e)return e;let t=1/0,n;for(let o of Object.keys(me)){let s=me[o],i=Ir(r,s);i<t&&(t=i,n=o)}return n};d.keyword.rgb=function(r){return me[r]};d.rgb.xyz=function(r){let e=r[0]/255,t=r[1]/255,n=r[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;let o=e*.4124+t*.3576+n*.1805,s=e*.2126+t*.7152+n*.0722,i=e*.0193+t*.1192+n*.9505;return[o*100,s*100,i*100]};d.rgb.lab=function(r){let e=d.rgb.xyz(r),t=e[0],n=e[1],o=e[2];t/=95.047,n/=100,o/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;let s=116*n-16,i=500*(t-n),a=200*(n-o);return[s,i,a]};d.hsl.rgb=function(r){let e=r[0]/360,t=r[1]/100,n=r[2]/100,o,s,i;if(t===0)return i=n*255,[i,i,i];n<.5?o=n*(1+t):o=n+t-n*t;let a=2*n-o,l=[0,0,0];for(let u=0;u<3;u++)s=e+1/3*-(u-1),s<0&&s++,s>1&&s--,6*s<1?i=a+(o-a)*6*s:2*s<1?i=o:3*s<2?i=a+(o-a)*(2/3-s)*6:i=a,l[u]=i*255;return l};d.hsl.hsv=function(r){let e=r[0],t=r[1]/100,n=r[2]/100,o=t,s=Math.max(n,.01);n*=2,t*=n<=1?n:2-n,o*=s<=1?s:2-s;let i=(n+t)/2,a=n===0?2*o/(s+o):2*t/(n+t);return[e,a*100,i*100]};d.hsv.rgb=function(r){let e=r[0]/60,t=r[1]/100,n=r[2]/100,o=Math.floor(e)%6,s=e-Math.floor(e),i=255*n*(1-t),a=255*n*(1-t*s),l=255*n*(1-t*(1-s));switch(n*=255,o){case 0:return[n,l,i];case 1:return[a,n,i];case 2:return[i,n,l];case 3:return[i,a,n];case 4:return[l,i,n];case 5:return[n,i,a]}};d.hsv.hsl=function(r){let e=r[0],t=r[1]/100,n=r[2]/100,o=Math.max(n,.01),s,i;i=(2-t)*n;let a=(2-t)*o;return s=t*o,s/=a<=1?a:2-a,s=s||0,i/=2,[e,s*100,i*100]};d.hwb.rgb=function(r){let e=r[0]/360,t=r[1]/100,n=r[2]/100,o=t+n,s;o>1&&(t/=o,n/=o);let i=Math.floor(6*e),a=1-n;s=6*e-i,i&1&&(s=1-s);let l=t+s*(a-t),u,h,f;switch(i){default:case 6:case 0:u=a,h=l,f=t;break;case 1:u=l,h=a,f=t;break;case 2:u=t,h=a,f=l;break;case 3:u=t,h=l,f=a;break;case 4:u=l,h=t,f=a;break;case 5:u=a,h=t,f=l;break}return[u*255,h*255,f*255]};d.cmyk.rgb=function(r){let e=r[0]/100,t=r[1]/100,n=r[2]/100,o=r[3]/100,s=1-Math.min(1,e*(1-o)+o),i=1-Math.min(1,t*(1-o)+o),a=1-Math.min(1,n*(1-o)+o);return[s*255,i*255,a*255]};d.xyz.rgb=function(r){let e=r[0]/100,t=r[1]/100,n=r[2]/100,o,s,i;return o=e*3.2406+t*-1.5372+n*-.4986,s=e*-.9689+t*1.8758+n*.0415,i=e*.0557+t*-.204+n*1.057,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,i=i>.0031308?1.055*i**(1/2.4)-.055:i*12.92,o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),i=Math.min(Math.max(0,i),1),[o*255,s*255,i*255]};d.xyz.lab=function(r){let e=r[0],t=r[1],n=r[2];e/=95.047,t/=100,n/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let o=116*t-16,s=500*(e-t),i=200*(t-n);return[o,s,i]};d.lab.xyz=function(r){let e=r[0],t=r[1],n=r[2],o,s,i;s=(e+16)/116,o=t/500+s,i=s-n/200;let a=s**3,l=o**3,u=i**3;return s=a>.008856?a:(s-16/116)/7.787,o=l>.008856?l:(o-16/116)/7.787,i=u>.008856?u:(i-16/116)/7.787,o*=95.047,s*=100,i*=108.883,[o,s,i]};d.lab.lch=function(r){let e=r[0],t=r[1],n=r[2],o;o=Math.atan2(n,t)*360/2/Math.PI,o<0&&(o+=360);let i=Math.sqrt(t*t+n*n);return[e,i,o]};d.lch.lab=function(r){let e=r[0],t=r[1],o=r[2]/360*2*Math.PI,s=t*Math.cos(o),i=t*Math.sin(o);return[e,s,i]};d.rgb.ansi16=function(r,e=null){let[t,n,o]=r,s=e===null?d.rgb.hsv(r)[2]:e;if(s=Math.round(s/50),s===0)return 30;let i=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(t/255));return s===2&&(i+=60),i};d.hsv.ansi16=function(r){return d.rgb.ansi16(d.hsv.rgb(r),r[2])};d.rgb.ansi256=function(r){let e=r[0],t=r[1],n=r[2];return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)};d.ansi16.rgb=function(r){let e=r%10;if(e===0||e===7)return r>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let t=(~~(r>50)+1)*.5,n=(e&1)*t*255,o=(e>>1&1)*t*255,s=(e>>2&1)*t*255;return[n,o,s]};d.ansi256.rgb=function(r){if(r>=232){let s=(r-232)*10+8;return[s,s,s]}r-=16;let e,t=Math.floor(r/36)/5*255,n=Math.floor((e=r%36)/6)/5*255,o=e%6/5*255;return[t,n,o]};d.rgb.hex=function(r){let t=(((Math.round(r[0])&255)<<16)+((Math.round(r[1])&255)<<8)+(Math.round(r[2])&255)).toString(16).toUpperCase();return"000000".substring(t.length)+t};d.hex.rgb=function(r){let e=r.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let t=e[0];e[0].length===3&&(t=t.split("").map(a=>a+a).join(""));let n=parseInt(t,16),o=n>>16&255,s=n>>8&255,i=n&255;return[o,s,i]};d.rgb.hcg=function(r){let e=r[0]/255,t=r[1]/255,n=r[2]/255,o=Math.max(Math.max(e,t),n),s=Math.min(Math.min(e,t),n),i=o-s,a,l;return i<1?a=s/(1-i):a=0,i<=0?l=0:o===e?l=(t-n)/i%6:o===t?l=2+(n-e)/i:l=4+(e-t)/i,l/=6,l%=1,[l*360,i*100,a*100]};d.hsl.hcg=function(r){let e=r[1]/100,t=r[2]/100,n=t<.5?2*e*t:2*e*(1-t),o=0;return n<1&&(o=(t-.5*n)/(1-n)),[r[0],n*100,o*100]};d.hsv.hcg=function(r){let e=r[1]/100,t=r[2]/100,n=e*t,o=0;return n<1&&(o=(t-n)/(1-n)),[r[0],n*100,o*100]};d.hcg.rgb=function(r){let e=r[0]/360,t=r[1]/100,n=r[2]/100;if(t===0)return[n*255,n*255,n*255];let o=[0,0,0],s=e%1*6,i=s%1,a=1-i,l=0;switch(Math.floor(s)){case 0:o[0]=1,o[1]=i,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=i;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=i,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return l=(1-t)*n,[(t*o[0]+l)*255,(t*o[1]+l)*255,(t*o[2]+l)*255]};d.hcg.hsv=function(r){let e=r[1]/100,t=r[2]/100,n=e+t*(1-e),o=0;return n>0&&(o=e/n),[r[0],o*100,n*100]};d.hcg.hsl=function(r){let e=r[1]/100,n=r[2]/100*(1-e)+.5*e,o=0;return n>0&&n<.5?o=e/(2*n):n>=.5&&n<1&&(o=e/(2*(1-n))),[r[0],o*100,n*100]};d.hcg.hwb=function(r){let e=r[1]/100,t=r[2]/100,n=e+t*(1-e);return[r[0],(n-e)*100,(1-n)*100]};d.hwb.hcg=function(r){let e=r[1]/100,n=1-r[2]/100,o=n-e,s=0;return o<1&&(s=(n-o)/(1-o)),[r[0],o*100,s*100]};d.apple.rgb=function(r){return[r[0]/65535*255,r[1]/65535*255,r[2]/65535*255]};d.rgb.apple=function(r){return[r[0]/255*65535,r[1]/255*65535,r[2]/255*65535]};d.gray.rgb=function(r){return[r[0]/100*255,r[0]/100*255,r[0]/100*255]};d.gray.hsl=function(r){return[0,0,r[0]]};d.gray.hsv=d.gray.hsl;d.gray.hwb=function(r){return[0,100,r[0]]};d.gray.cmyk=function(r){return[0,0,0,r[0]]};d.gray.lab=function(r){return[r[0],0,0]};d.gray.hex=function(r){let e=Math.round(r[0]/100*255)&255,n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n};d.rgb.gray=function(r){return[(r[0]+r[1]+r[2])/3/255*100]}});var Jt=x((os,Yt)=>{var Oe=nt();function Fr(){let r={},e=Object.keys(Oe);for(let t=e.length,n=0;n<t;n++)r[e[n]]={distance:-1,parent:null};return r}function Hr(r){let e=Fr(),t=[r];for(e[r].distance=0;t.length;){let n=t.pop(),o=Object.keys(Oe[n]);for(let s=o.length,i=0;i<s;i++){let a=o[i],l=e[a];l.distance===-1&&(l.distance=e[n].distance+1,l.parent=n,t.unshift(a))}}return e}function jr(r,e){return function(t){return e(r(t))}}function Mr(r,e){let t=[e[r].parent,r],n=Oe[e[r].parent][r],o=e[r].parent;for(;e[o].parent;)t.unshift(e[o].parent),n=jr(Oe[e[o].parent][o],n),o=e[o].parent;return n.conversion=t,n}Yt.exports=function(r){let e=Hr(r),t={},n=Object.keys(e);for(let o=n.length,s=0;s<o;s++){let i=n[s];e[i].parent!==null&&(t[i]=Mr(i,e))}return t}});var Qt=x((ss,Kt)=>{var rt=nt(),Nr=Jt(),re={},qr=Object.keys(rt);function Vr(r){let e=function(...t){let n=t[0];return n==null?n:(n.length>1&&(t=n),r(t))};return"conversion"in r&&(e.conversion=r.conversion),e}function Dr(r){let e=function(...t){let n=t[0];if(n==null)return n;n.length>1&&(t=n);let o=r(t);if(typeof o=="object")for(let s=o.length,i=0;i<s;i++)o[i]=Math.round(o[i]);return o};return"conversion"in r&&(e.conversion=r.conversion),e}qr.forEach(r=>{re[r]={},Object.defineProperty(re[r],"channels",{value:rt[r].channels}),Object.defineProperty(re[r],"labels",{value:rt[r].labels});let e=Nr(r);Object.keys(e).forEach(n=>{let o=e[n];re[r][n]=Dr(o),re[r][n].raw=Vr(o)})});Kt.exports=re});var rn=x((is,nn)=>{"use strict";var Xt=(r,e)=>(...t)=>`\x1B[${r(...t)+e}m`,Zt=(r,e)=>(...t)=>{let n=r(...t);return`\x1B[${38+e};5;${n}m`},en=(r,e)=>(...t)=>{let n=r(...t);return`\x1B[${38+e};2;${n[0]};${n[1]};${n[2]}m`},Se=r=>r,tn=(r,e,t)=>[r,e,t],oe=(r,e,t)=>{Object.defineProperty(r,e,{get:()=>{let n=t();return Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0}),n},enumerable:!0,configurable:!0})},ot,se=(r,e,t,n)=>{ot===void 0&&(ot=Qt());let o=n?10:0,s={};for(let[i,a]of Object.entries(ot)){let l=i==="ansi16"?"ansi":i;i===e?s[l]=r(t,o):typeof a=="object"&&(s[l]=r(a[e],o))}return s};function Lr(){let r=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[t,n]of Object.entries(e)){for(let[o,s]of Object.entries(n))e[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=e[o],r.set(s[0],s[1]);Object.defineProperty(e,t,{value:n,enumerable:!1})}return Object.defineProperty(e,"codes",{value:r,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",oe(e.color,"ansi",()=>se(Xt,"ansi16",Se,!1)),oe(e.color,"ansi256",()=>se(Zt,"ansi256",Se,!1)),oe(e.color,"ansi16m",()=>se(en,"rgb",tn,!1)),oe(e.bgColor,"ansi",()=>se(Xt,"ansi16",Se,!0)),oe(e.bgColor,"ansi256",()=>se(Zt,"ansi256",Se,!0)),oe(e.bgColor,"ansi16m",()=>se(en,"rgb",tn,!0)),e}Object.defineProperty(nn,"exports",{enumerable:!0,get:Lr})});var sn=x((as,on)=>{"use strict";on.exports=(r,e=process.argv)=>{let t=r.startsWith("-")?"":r.length===1?"-":"--",n=e.indexOf(t+r),o=e.indexOf("--");return n!==-1&&(o===-1||n<o)}});var cn=x((ls,ln)=>{"use strict";var Wr=require("os"),an=require("tty"),M=sn(),{env:O}=process,z;M("no-color")||M("no-colors")||M("color=false")||M("color=never")?z=0:(M("color")||M("colors")||M("color=true")||M("color=always"))&&(z=1);"FORCE_COLOR"in O&&(O.FORCE_COLOR==="true"?z=1:O.FORCE_COLOR==="false"?z=0:z=O.FORCE_COLOR.length===0?1:Math.min(parseInt(O.FORCE_COLOR,10),3));function st(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function it(r,e){if(z===0)return 0;if(M("color=16m")||M("color=full")||M("color=truecolor"))return 3;if(M("color=256"))return 2;if(r&&!e&&z===void 0)return 0;let t=z||0;if(O.TERM==="dumb")return t;if(process.platform==="win32"){let n=Wr.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in O)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in O)||O.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in O)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(O.TEAMCITY_VERSION)?1:0;if(O.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in O){let n=parseInt((O.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(O.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(O.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(O.TERM)||"COLORTERM"in O?1:t}function Br(r){let e=it(r,r&&r.isTTY);return st(e)}ln.exports={supportsColor:Br,stdout:st(it(!0,an.isatty(1))),stderr:st(it(!0,an.isatty(2)))}});var hn=x((cs,un)=>{"use strict";var Ur=(r,e,t)=>{let n=r.indexOf(e);if(n===-1)return r;let o=e.length,s=0,i="";do i+=r.substr(s,n-s)+e+t,s=n+o,n=r.indexOf(e,s);while(n!==-1);return i+=r.substr(s),i},Gr=(r,e,t,n)=>{let o=0,s="";do{let i=r[n-1]==="\r";s+=r.substr(o,(i?n-1:n)-o)+e+(i?`\r
27
23
  `:`
28
- `)+t,i=s+1,s=n.indexOf(`
29
- `,i)}while(s!==-1);return r+=n.substr(i),r};qn.exports={stringReplaceAll:za,stringEncaseCRLFWithFirstIndex:Ga}});var Yn=A((Pu,Jn)=>{"use strict";var Ja=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,Un=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,Ya=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Ka=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,Xa=new Map([["n",`
30
- `],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1B"],["a","\x07"]]);function Gn(n){let e=n[0]==="u",t=n[1]==="{";return e&&!t&&n.length===5||n[0]==="x"&&n.length===3?String.fromCharCode(parseInt(n.slice(1),16)):e&&t?String.fromCodePoint(parseInt(n.slice(2,-1),16)):Xa.get(n)||n}function Za(n,e){let t=[],s=e.trim().split(/\s*,\s*/g),i;for(let r of s){let o=Number(r);if(!Number.isNaN(o))t.push(o);else if(i=r.match(Ya))t.push(i[2].replace(Ka,(a,l,c)=>l?Gn(l):c));else throw new Error(`Invalid Chalk template style argument: ${r} (in style '${n}')`)}return t}function Qa(n){Un.lastIndex=0;let e=[],t;for(;(t=Un.exec(n))!==null;){let s=t[1];if(t[2]){let i=Za(s,t[2]);e.push([s].concat(i))}else e.push([s])}return e}function zn(n,e){let t={};for(let i of e)for(let r of i.styles)t[r[0]]=i.inverse?null:r.slice(1);let s=n;for(let[i,r]of Object.entries(t))if(Array.isArray(r)){if(!(i in s))throw new Error(`Unknown Chalk style: ${i}`);s=r.length>0?s[i](...r):s[i]}return s}Jn.exports=(n,e)=>{let t=[],s=[],i=[];if(e.replace(Ja,(r,o,a,l,c,u)=>{if(o)i.push(Gn(o));else if(l){let f=i.join("");i=[],s.push(t.length===0?f:zn(n,t)(f)),t.push({inverse:a,styles:Qa(l)})}else if(c){if(t.length===0)throw new Error("Found extraneous } in Chalk template literal");s.push(zn(n,t)(i.join(""))),i=[],t.pop()}else i.push(u)}),s.push(i.join("")),t.length>0){let r=`Chalk template literal is missing ${t.length} closing bracket${t.length===1?"":"s"} (\`}\`)`;throw new Error(r)}return s.join("")}});var sr=A((Tu,tr)=>{"use strict";var ft=In(),{stdout:oi,stderr:ai}=Hn(),{stringReplaceAll:el,stringEncaseCRLFWithFirstIndex:tl}=Bn(),{isArray:Yt}=Array,Xn=["ansi","ansi","ansi256","ansi16m"],Be=Object.create(null),sl=(n,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=oi?oi.level:0;n.level=e.level===void 0?t:e.level},li=class{constructor(e){return Zn(e)}},Zn=n=>{let e={};return sl(e,n),e.template=(...t)=>er(e.template,...t),Object.setPrototypeOf(e,Kt.prototype),Object.setPrototypeOf(e.template,e),e.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},e.template.Instance=li,e.template};function Kt(n){return Zn(n)}for(let[n,e]of Object.entries(ft))Be[n]={get(){let t=Xt(this,ci(e.open,e.close,this._styler),this._isEmpty);return Object.defineProperty(this,n,{value:t}),t}};Be.visible={get(){let n=Xt(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:n}),n}};var Qn=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let n of Qn)Be[n]={get(){let{level:e}=this;return function(...t){let s=ci(ft.color[Xn[e]][n](...t),ft.color.close,this._styler);return Xt(this,s,this._isEmpty)}}};for(let n of Qn){let e="bg"+n[0].toUpperCase()+n.slice(1);Be[e]={get(){let{level:t}=this;return function(...s){let i=ci(ft.bgColor[Xn[t]][n](...s),ft.bgColor.close,this._styler);return Xt(this,i,this._isEmpty)}}}}var il=Object.defineProperties(()=>{},{...Be,level:{enumerable:!0,get(){return this._generator.level},set(n){this._generator.level=n}}}),ci=(n,e,t)=>{let s,i;return t===void 0?(s=n,i=e):(s=t.openAll+n,i=e+t.closeAll),{open:n,close:e,openAll:s,closeAll:i,parent:t}},Xt=(n,e,t)=>{let s=(...i)=>Yt(i[0])&&Yt(i[0].raw)?Kn(s,er(s,...i)):Kn(s,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(s,il),s._generator=n,s._styler=e,s._isEmpty=t,s},Kn=(n,e)=>{if(n.level<=0||!e)return n._isEmpty?"":e;let t=n._styler;if(t===void 0)return e;let{openAll:s,closeAll:i}=t;if(e.indexOf("\x1B")!==-1)for(;t!==void 0;)e=el(e,t.close,t.open),t=t.parent;let r=e.indexOf(`
31
- `);return r!==-1&&(e=tl(e,i,s,r)),s+e+i},ri,er=(n,...e)=>{let[t]=e;if(!Yt(t)||!Yt(t.raw))return e.join(" ");let s=e.slice(1),i=[t.raw[0]];for(let r=1;r<t.length;r++)i.push(String(s[r-1]).replace(/[{}\\]/g,"\\$&"),String(t.raw[r]));return ri===void 0&&(ri=Yn()),ri(n,i.join(""))};Object.defineProperties(Kt.prototype,Be);var Zt=Kt();Zt.supportsColor=oi;Zt.stderr=Kt({level:ai?ai.level:0});Zt.stderr.supportsColor=ai;tr.exports=Zt});var rn=_(nn(),1),{program:lu,createCommand:cu,createArgument:hu,createOption:uu,CommanderError:fu,InvalidArgumentError:du,InvalidOptionArgumentError:pu,Command:on,Argument:gu,Option:mu,Help:yu}=rn.default;var or=_(require("http")),P=_(require("fs")),R=_(require("path")),ar=_(require("os")),lr=_(We());je();V();var pe=_(sr()),h={dim:n=>pe.default.dim(n),bold:n=>pe.default.bold(n),accent:n=>pe.default.hex("#C4441A")(n),green:n=>pe.default.green(n),red:n=>pe.default.red(n),yellow:n=>pe.default.yellow(n),cyan:n=>pe.default.cyan(n),white:n=>pe.default.white(n)};function E(){return`${h.bold("hold your ")}${h.accent("voice")}`}function ir(n){let e=n.severity==="red"?h.red("\u25CF"):h.yellow("\u25CF"),t=h.dim(`${n.file}:${n.line}`),s=h.dim(n.pattern);console.log(` ${e} ${t} ${s}`),console.log(` ${n.excerpt}`)}function nr(n){if(console.log(""),console.log(` ${h.bold("scanned")} ${h.cyan(String(n.files))} files, ${h.cyan(String(n.total_lines))} lines`),n.red+n.yellow===0)console.log(` ${h.green("\u2713 clean \u2014 no issues found")}`);else{let e=[];n.red&&e.push(h.red(`${n.red} critical`)),n.yellow&&e.push(h.yellow(`${n.yellow} advisory`)),console.log(` ${e.join(", ")}`)}}var Re=process.env.HYV_BASE_URL||"https://holdyourvoice.com",Ue=ar.homedir(),rr=process.platform==="win32",ui=R.join(Ue,".hyv"),ze=R.join(ui,"voice.md"),dt=`# Hold Your Voice
32
-
33
- The user's voice profile is at \`~/.hyv/voice.md\`. Read it before rewriting.
34
-
35
- When the user mentions "voice", "brand voice", "hyv", "write in my voice", or "rewrite in my voice":
36
-
37
- 1. Read the voice profile: \`~/.hyv/voice.md\`
38
- 2. Capture the text to rewrite (previous message, code block, file, etc.)
39
- 3. Run: \`hyv rewrite --text "the captured text"\`
40
- 4. Read the structured prompt from stdout
41
- 5. Execute the rewrite following the prompt's instructions
42
- 6. Present the rewritten text directly
43
-
44
- ## File rewrite
45
- \`\`\`bash
46
- hyv rewrite <file.md>
47
- \`\`\`
48
-
49
- ## Scan for issues
50
- \`\`\`bash
51
- hyv scan <file.md>
52
- \`\`\`
53
-
54
- ## Rules
55
- - The CLI generates prompts. **You** execute the rewrite.
56
- - Preserve original meaning. Match the voice profile's rhythm, vocabulary, patterns.
57
- - If no profile specified, check \`.hyv.yml\` or ask the user.
58
- - If CLI not installed: \`npm i -g @holdyourvoice/hyv\` then \`hyv init\`
59
- `;function Ge(n){P.existsSync(n)||P.mkdirSync(n,{recursive:!0})}function pt(n,e,t="Hold Your Voice"){return P.existsSync(n)?P.readFileSync(n,"utf-8").includes(t)?!1:(P.appendFileSync(n,`
60
-
61
- `+e),!0):(Ge(R.dirname(n)),P.writeFileSync(n,e),!0)}async function nl(){Ge(ui);try{let e=(await k("/cli/profiles")).profiles||[];if(e.length===0)return!1;let t=[`# Voice Profile
62
- `];for(let s of e)t.push(`## ${s.name}${s.is_default?" (default)":""}`),s.brand&&t.push(`Brand: ${s.brand}`),s.description&&t.push(s.description),s.keywords?.length&&t.push(`Keywords: ${s.keywords.join(", ")}`),t.push("");return P.writeFileSync(ze,t.join(`
63
- `)),!0}catch{return!1}}function rl(){if(P.existsSync(ze))return;Ge(ui);let n=`# Voice Profile
64
-
65
- This file is your cross-platform voice profile.
66
- All agents (Claude, ChatGPT, Codex, Cursor) read this file when rewriting in your voice.
67
-
68
- Run \`hyv export claude -o ~/.hyv/voice.md\` to populate with your actual voice profile.
69
- Or create a voice profile at: ${Re}/app/voice
70
-
71
- ## Instructions for agents
72
-
73
- When the user asks to rewrite text "in my voice":
74
- 1. Read this file for voice context
75
- 2. Run: hyv rewrite --text "text to rewrite"
76
- 3. Execute the rewrite from the prompt output
77
- `;P.writeFileSync(ze,n)}function ol(){let n=R.join(Ue,"Library","Application Support","Claude"),e=R.join(n,"claude_desktop_config.json"),t=R.join(Ue,"AppData","Roaming","Claude"),s=R.join(t,"claude_desktop_config.json"),i=rr?s:e;if(!P.existsSync(rr?t:n))return!1;let o={};if(P.existsSync(i))try{o=JSON.parse(P.readFileSync(i,"utf-8"))}catch{o={}}if(o.mcpServers||(o.mcpServers={}),o.mcpServers.hyv)return!1;o.mcpServers.hyv={command:"hyv",args:["mcp"]};try{return P.writeFileSync(i,JSON.stringify(o,null,2)),!0}catch{return!1}}function al(){let n=R.join(Ue,".chatgpt");Ge(n);let e=`Hold Your Voice \u2014 Voice Profile Integration
78
-
79
- The user's voice profile is at: ${ze}
80
-
81
- When the user says "rewrite in my voice" or mentions "hyv" or "brand voice":
82
- 1. Ask the user to paste their voice profile from ${ze}
83
- 2. Rewrite their text matching the profile's rhythm, vocabulary, and patterns
84
- 3. Never use AI-slop words (delve, leverage, tapestry, foster, harness, pivotal)
85
- 4. Preserve original meaning exactly
86
- 5. Remove patterns like "not just X, but Y" and "the truth is"
87
- `,t=R.join(n,"hyv-instructions.txt");return P.writeFileSync(t,e),!0}function ll(){let n=process.cwd(),e=[],t=[],s=[{dir:R.join(n,".claude","commands"),scope:"project"},{dir:R.join(Ue,".claude","commands"),scope:"global"}];for(let{dir:l,scope:c}of s){Ge(l);let u=R.join(l,"hyv.md");pt(u,dt)&&e.push(`claude-code (${c})`)}let i=R.join(n,"CLAUDE.md");pt(i,dt)&&e.push("CLAUDE.md");let r=[{file:R.join(n,"AGENTS.md"),scope:"project"},{file:R.join(Ue,".codex","AGENTS.md"),scope:"global"}];for(let{file:l,scope:c}of r)Ge(R.dirname(l)),pt(l,dt)&&e.push(`codex (${c})`);let o=R.join(n,".cursorrules");pt(o,dt)&&e.push("cursor");let a=R.join(n,".windsurfrules");return pt(a,dt)&&e.push("windsurf"),ol()&&e.push("claude-desktop (mcp)"),al()&&t.push("chatgpt"),{installed:e,needsConfig:t}}async function cr(n,e){if(e?.quiet||console.log(`
88
- ${E()}
89
- `),e?.key){await cl(e.key),await hi(n,e?.quiet);return}let t=xe();if(t)try{await k("/cli/heartbeat"),e?.quiet||console.log(` ${h.green("\u2713")} already authenticated as ${h.dim(t.user_email||"unknown")}`),n&&(Qs({profile:n}),e?.quiet||console.log(` ${h.green("\u2713")} default profile set to ${h.bold(n)}`)),await hi(n,e?.quiet);return}catch{e?.quiet||console.log(` ${h.dim("credentials expired, re-authenticating...")}`)}let s=or.createServer(),i=await new Promise(a=>{s.listen(0,"127.0.0.1",()=>{a(s.address().port)})});e?.quiet||(console.log(" opening browser for authentication..."),console.log(` ${h.dim("if the browser doesn't open, visit the URL manually")}
90
- `));let r=`${Re}/api/cli/auth?port=${i}`,o=new Promise((a,l)=>{let c=setTimeout(()=>{s.close(),l(new Error("Authentication timed out (5 minutes)"))},3e5);s.on("request",(u,f)=>{let p=new URL(u.url||"/",`http://127.0.0.1:${i}`),d=p.searchParams.get("token"),m=p.searchParams.get("email"),g=p.searchParams.get("name"),b=p.searchParams.get("error");if(b){f.writeHead(302,{Location:`${Re}/dashboard?cli_error=${encodeURIComponent(b)}`}),f.end(),clearTimeout(c),s.close(),l(new Error(b));return}if(d){f.writeHead(200,{"Content-Type":"text/html"}),f.end(`<!DOCTYPE html><html><body style="font-family:sans-serif;text-align:center;padding:60px">
91
- <h2 style="color:#1A7A4A">\u2713 authenticated</h2>
92
- <p>you can close this tab and return to your terminal.</p>
93
- <script>setTimeout(() => window.close(), 2000)</script>
94
- </body></html>`),clearTimeout(c),s.close(),a({api_key:d,email:m||"",name:g||""});return}f.writeHead(302,{Location:r}),f.end()})});try{await(0,lr.default)(r)}catch{e?.quiet||(console.log(` ${h.yellow("!")} couldn't open browser. visit:`),console.log(` ${h.cyan(r)}
95
- `))}try{let{api_key:a,email:l,name:c}=await o;Bt({api_key:a,base_url:Re,user_email:l,user_name:c}),e?.quiet||console.log(` ${h.green("\u2713")} authenticated as ${h.bold(l||c)}`);try{let u=await k("/cli/heartbeat");e?.quiet||(u.plan==="none"||u.status==="none"?(console.log(` ${h.yellow("!")} no active subscription`),console.log(` ${h.dim("visit")} ${h.cyan(`${Re}/dashboard`)} ${h.dim("to subscribe")}`)):console.log(` ${h.green("\u2713")} plan: ${h.bold(u.plan)}`))}catch{}n&&(Qs({profile:n}),e?.quiet||console.log(` ${h.green("\u2713")} default profile set to ${h.bold(n)}`)),await hi(n,e?.quiet)}catch(a){console.log(`
96
- ${h.red("\u2717")} authentication failed: ${a.message}`),process.exit(1)}}async function hi(n,e){await nl()||rl(),e||console.log(` ${h.green("\u2713")} voice profile: ${h.dim(ze)}`);let{installed:s,needsConfig:i}=ll();if(!e){if(s.length>0){console.log(`
97
- ${h.green("\u2713")} connected to:`);for(let r of s)console.log(` ${h.dim("\u2192")} ${r}`)}if(i.includes("chatgpt")){console.log(`
98
- ${h.cyan("\u2192")} opening chatgpt connector settings...`),console.log(` ${h.dim("add server:")} ${h.cyan("https://holdyourvoice.com/mcp")}`),console.log(` ${h.dim("auth: your CLI key will be used automatically")}`);try{let r=(await Promise.resolve().then(()=>_(We()))).default;await r("https://chatgpt.com/#settings/Connectors")}catch{}}console.log(`
99
- ${h.dim('say "rewrite in my voice" in any connected agent to get started')}`)}}async function cl(n){Bt({api_key:n,base_url:Re});try{let e=await k("/cli/heartbeat");Bt({api_key:n,base_url:Re,user_email:e.email,user_name:e.name}),console.log(` ${h.green("\u2713")} authenticated with license key`)}catch(e){console.log(` ${h.red("\u2717")} invalid license key: ${e.message}`),process.exit(1)}}var it=_(require("fs")),Ri=_(require("path"));var fi=(n,e,t)=>{let s=n instanceof RegExp?hr(n,t):n,i=e instanceof RegExp?hr(e,t):e,r=s!==null&&i!=null&&hl(s,i,t);return r&&{start:r[0],end:r[1],pre:t.slice(0,r[0]),body:t.slice(r[0]+s.length,r[1]),post:t.slice(r[1]+i.length)}},hr=(n,e)=>{let t=e.match(n);return t?t[0]:null},hl=(n,e,t)=>{let s,i,r,o,a,l=t.indexOf(n),c=t.indexOf(e,l+1),u=l;if(l>=0&&c>0){if(n===e)return[l,c];for(s=[],r=t.length;u>=0&&!a;){if(u===l)s.push(u),l=t.indexOf(n,u+1);else if(s.length===1){let f=s.pop();f!==void 0&&(a=[f,c])}else i=s.pop(),i!==void 0&&i<r&&(r=i,o=c),c=t.indexOf(e,u+1);u=l<c&&l>=0?l:c}s.length&&o!==void 0&&(a=[r,o])}return a};var ur="\0SLASH"+Math.random()+"\0",fr="\0OPEN"+Math.random()+"\0",pi="\0CLOSE"+Math.random()+"\0",dr="\0COMMA"+Math.random()+"\0",pr="\0PERIOD"+Math.random()+"\0",ul=new RegExp(ur,"g"),fl=new RegExp(fr,"g"),dl=new RegExp(pi,"g"),pl=new RegExp(dr,"g"),gl=new RegExp(pr,"g"),ml=/\\\\/g,yl=/\\{/g,bl=/\\}/g,wl=/\\,/g,vl=/\\\./g,xl=1e5;function di(n){return isNaN(n)?n.charCodeAt(0):parseInt(n,10)}function Sl(n){return n.replace(ml,ur).replace(yl,fr).replace(bl,pi).replace(wl,dr).replace(vl,pr)}function $l(n){return n.replace(ul,"\\").replace(fl,"{").replace(dl,"}").replace(pl,",").replace(gl,".")}function gr(n){if(!n)return[""];let e=[],t=fi("{","}",n);if(!t)return n.split(",");let{pre:s,body:i,post:r}=t,o=s.split(",");o[o.length-1]+="{"+i+"}";let a=gr(r);return r.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),e.push.apply(e,o),e}function mr(n,e={}){if(!n)return[];let{max:t=xl}=e;return n.slice(0,2)==="{}"&&(n="\\{\\}"+n.slice(2)),gt(Sl(n),t,!0).map($l)}function _l(n){return"{"+n+"}"}function Cl(n){return/^-?0\d/.test(n)}function El(n,e){return n<=e}function kl(n,e){return n>=e}function gt(n,e,t){let s=[],i=fi("{","}",n);if(!i)return[n];let r=i.pre,o=i.post.length?gt(i.post,e,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a<o.length&&a<e;a++){let l=r+"{"+i.body+"}"+o[a];s.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=a||l,u=i.body.indexOf(",")>=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(n=i.pre+"{"+i.body+pi+i.post,gt(n,e,!0)):[n];let f;if(c)f=i.body.split(/\.\./);else if(f=gr(i.body),f.length===1&&f[0]!==void 0&&(f=gt(f[0],e,!1).map(_l),f.length===1))return o.map(d=>i.pre+f[0]+d);let p;if(c&&f[0]!==void 0&&f[1]!==void 0){let d=di(f[0]),m=di(f[1]),g=Math.max(f[0].length,f[1].length),b=f.length===3&&f[2]!==void 0?Math.max(Math.abs(di(f[2])),1):1,y=El;m<d&&(b*=-1,y=kl);let S=f.some(Cl);p=[];for(let $=d;y($,m)&&p.length<e;$+=b){let x;if(l)x=String.fromCharCode($),x==="\\"&&(x="");else if(x=String($),S){let ae=g-x.length;if(ae>0){let fe=new Array(ae+1).join("0");$<0?x="-"+fe+x.slice(1):x=fe+x}}p.push(x)}}else{p=[];for(let d=0;d<f.length;d++)p.push.apply(p,gt(f[d],e,!1))}for(let d=0;d<p.length;d++)for(let m=0;m<o.length&&s.length<e;m++){let g=r+p[d]+o[m];(!t||c||g)&&s.push(g)}}return s}var mt=n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")};var Ol={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},yt=n=>n.replace(/[[\]\\-]/g,"\\$&"),Al=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),yr=n=>n.join(""),br=(n,e)=>{let t=e;if(n.charAt(t)!=="[")throw new Error("not in a brace expression");let s=[],i=[],r=t+1,o=!1,a=!1,l=!1,c=!1,u=t,f="";e:for(;r<n.length;){let g=n.charAt(r);if((g==="!"||g==="^")&&r===t+1){c=!0,r++;continue}if(g==="]"&&o&&!l){u=r+1;break}if(o=!0,g==="\\"&&!l){l=!0,r++;continue}if(g==="["&&!l){for(let[b,[y,v,S]]of Object.entries(Ol))if(n.startsWith(b,r)){if(f)return["$.",!1,n.length-t,!0];r+=b.length,S?i.push(y):s.push(y),a=a||v;continue e}}if(l=!1,f){g>f?s.push(yt(f)+"-"+yt(g)):g===f&&s.push(yt(g)),f="",r++;continue}if(n.startsWith("-]",r+1)){s.push(yt(g+"-")),r+=2;continue}if(n.startsWith("-",r+1)){f=g,r+=2;continue}s.push(yt(g)),r++}if(u<r)return["",!1,0,!1];if(!s.length&&!i.length)return["$.",!1,n.length-t,!0];if(i.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!c){let g=s[0].length===2?s[0].slice(-1):s[0];return[Al(g),!1,u-t,!1]}let p="["+(c?"^":"")+yr(s)+"]",d="["+(c?"":"^")+yr(i)+"]";return[s.length&&i.length?"("+p+"|"+d+")":s.length?p:d,a,u-t,!0]};var se=(n,{windowsPathsNoEscape:e=!1,magicalBraces:t=!0}={})=>t?e?n.replace(/\[([^/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?n.replace(/\[([^/\\{}])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var z,Fl=new Set(["!","?","+","*","@"]),gi=n=>Fl.has(n),wr=n=>gi(n.type),jl=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Rl=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Pl=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),vr=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Tl="(?!(?:^|/)\\.\\.?(?:$|/))",Qt="(?!\\.)",Ml=new Set(["[","."]),Nl=new Set(["..","."]),Il=new Set("().*{}+?[]^$\\!"),Ll=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),mi="[^/]",xr=mi+"*?",Sr=mi+"+?",Dl=0,Pe=class{type;#e;#i;#n=!1;#t=[];#o;#$;#b;#u=!1;#a;#f;#h=!1;id=++Dl;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(e,t,s={}){this.type=e,e&&(this.#i=!0),this.#o=t,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?s:this.#e.#a,this.#b=this.#e===this?[]:this.#e.#b,e==="!"&&!this.#e.#u&&this.#b.push(this),this.#$=this.#o?this.#o.#t.length:0}get hasMagic(){if(this.#i!==void 0)return this.#i;for(let e of this.#t)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#i=!0;return this.#i}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#f=this.#t.map(e=>String(e)).join("")}#c(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let e;for(;e=this.#b.pop();){if(e.type!=="!")continue;let t=e,s=t.#o;for(;s;){for(let i=t.#$+1;!s.type&&i<s.#t.length;i++)for(let r of e.#t){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(s.#t[i])}t=s,s=t.#o}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof z&&t.#o===this))throw new Error("invalid part: "+t);this.#t.push(t)}}toJSON(){let e=this.type===null?this.#t.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#t.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#o?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#$===0)return!0;let e=this.#o;for(let t=0;t<this.#$;t++){let s=e.#t[t];if(!(s instanceof z&&s.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let e=this.#o?this.#o.#t.length:0;return this.#$===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new z(this.type,e);for(let s of this.#t)t.copyIn(s);return t}static#r(e,t,s,i,r){let o=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(t.type===null){let g=s,b="";for(;g<e.length;){let y=e.charAt(g++);if(a||y==="\\"){a=!a,b+=y;continue}if(l){g===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(g===c+2&&u)&&(l=!1),b+=y;continue}else if(y==="["){l=!0,c=g,u=!1,b+=y;continue}if(!i.noext&&gi(y)&&e.charAt(g)==="("&&r<=o){t.push(b),b="";let S=new z(y,t);g=z.#r(e,S,g,i,r+1),t.push(S);continue}b+=y}return t.push(b),g}let f=s+1,p=new z(null,t),d=[],m="";for(;f<e.length;){let g=e.charAt(f++);if(a||g==="\\"){a=!a,m+=g;continue}if(l){f===c+1?(g==="^"||g==="!")&&(u=!0):g==="]"&&!(f===c+2&&u)&&(l=!1),m+=g;continue}else if(g==="["){l=!0,c=f,u=!1,m+=g;continue}if(!i.noext&&gi(g)&&e.charAt(f)==="("&&(r<=o||t&&t.#p(g))){let y=t&&t.#p(g)?0:1;p.push(m),m="";let v=new z(g,p);p.push(v),f=z.#r(e,v,f,i,r+y);continue}if(g==="|"){p.push(m),m="",d.push(p),p=new z(null,t);continue}if(g===")")return m===""&&t.#t.length===0&&(t.#h=!0),p.push(m),m="",t.push(...d,p),f;m+=g}return t.type=null,t.#i=void 0,t.#t=[e.substring(s-1)],f}#w(e){return this.#x(e,Rl)}#x(e,t=jl){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null)return!1;let s=e.#t[0];return!s||typeof s!="object"||s.type===null?!1:this.#p(s.type,t)}#p(e,t=Pl){return!!t.get(this.type)?.includes(e)}#g(e,t){let s=e.#t[0],i=new z(null,s,this.options);i.#t.push(""),s.push(i),this.#E(e,t)}#E(e,t){let s=e.#t[0];this.#t.splice(t,1,...s.#t);for(let i of s.#t)typeof i=="object"&&(i.#o=this);this.#f=void 0}#m(e){return!!vr.get(this.type)?.has(e)}#S(e){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let t=e.#t[0];return!t||typeof t!="object"||t.type===null?!1:this.#m(t.type)}#_(e){let t=vr.get(this.type),s=e.#t[0],i=t?.get(s.type);if(!i)return!1;this.#t=s.#t;for(let r of this.#t)typeof r=="object"&&(r.#o=this);this.type=i,this.#f=void 0,this.#h=!1}static fromGlob(e,t={}){let s=new z(null,void 0,t);return z.#r(e,s,0,t,0),s}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,s,i,r]=this.toRegExpSource();if(!(i||this.#i||this.#a.nocase&&!this.#a.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return s;let a=(this.#a.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#a}toRegExpSource(e){let t=e??!!this.#a.dot;if(this.#e===this&&(this.#d(),this.#c()),!wr(this)){let l=this.isStart()&&this.isEnd()&&!this.#t.some(d=>typeof d!="string"),c=this.#t.map(d=>{let[m,g,b,y]=typeof d=="string"?z.#v(d,this.#i,l):d.toRegExpSource(e);return this.#i=this.#i||b,this.#n=this.#n||y,m}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Nl.has(this.#t[0]))){let m=Ml,g=t&&m.has(c.charAt(0))||c.startsWith("\\.")&&m.has(c.charAt(2))||c.startsWith("\\.\\.")&&m.has(c.charAt(4)),b=!t&&!e&&m.has(c.charAt(0));u=g?Tl:b?Qt:""}let f="";return this.isEnd()&&this.#e.#u&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,se(c),this.#i=!!this.#i,this.#n]}let s=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#y(t);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let l=this.toString(),c=this;return c.#t=[l],c.type=null,c.#i=void 0,[l,se(this.toString()),!1,!1]}let o=!s||e||t||!Qt?"":this.#y(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let a="";if(this.type==="!"&&this.#h)a=(this.isStart()&&!t?Qt:"")+Sr;else{let l=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Qt:"")+xr+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+r+l}return[a,se(r),this.#i=!!this.#i,this.#n]}#d(){if(wr(this)){let e=0,t=!1;do{t=!0;for(let s=0;s<this.#t.length;s++){let i=this.#t[s];typeof i=="object"&&(i.#d(),this.#x(i)?(t=!1,this.#E(i,s)):this.#w(i)?(t=!1,this.#g(i,s)):this.#S(i)&&(t=!1,this.#_(i)))}}while(!t&&++e<10)}else for(let e of this.#t)typeof e=="object"&&e.#d();this.#f=void 0}#y(e){return this.#t.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[s,i,r,o]=t.toRegExpSource(e);return this.#n=this.#n||o,s}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#v(e,t,s=!1){let i=!1,r="",o=!1,a=!1;for(let l=0;l<e.length;l++){let c=e.charAt(l);if(i){i=!1,r+=(Il.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,r+=s&&/^[*]+$/.test(e)?Sr:xr,t=!0;continue}else a=!1;if(c==="\\"){l===e.length-1?r+="\\\\":i=!0;continue}if(c==="["){let[u,f,p,d]=br(e,l);if(p){r+=u,o=o||f,l+=p-1,t=t||d;continue}}if(c==="?"){r+=mi,t=!0;continue}r+=Ll(c)}return[r,se(e),!!t,o]}};z=Pe;var Je=(n,{windowsPathsNoEscape:e=!1,magicalBraces:t=!1}={})=>t?e?n.replace(/[?*()[\]{}]/g,"[$&]"):n.replace(/[?*()[\]\\{}]/g,"\\$&"):e?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&");var B=(n,e,t={})=>(mt(e),!t.nocomment&&e.charAt(0)==="#"?!1:new J(e,t).match(n)),Wl=/^\*+([^+@!?*[(]*)$/,Vl=n=>e=>!e.startsWith(".")&&e.endsWith(n),Hl=n=>e=>e.endsWith(n),ql=n=>(n=n.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(n)),Bl=n=>(n=n.toLowerCase(),e=>e.toLowerCase().endsWith(n)),Ul=/^\*+\.\*+$/,zl=n=>!n.startsWith(".")&&n.includes("."),Gl=n=>n!=="."&&n!==".."&&n.includes("."),Jl=/^\.\*+$/,Yl=n=>n!=="."&&n!==".."&&n.startsWith("."),Kl=/^\*+$/,Xl=n=>n.length!==0&&!n.startsWith("."),Zl=n=>n.length!==0&&n!=="."&&n!=="..",Ql=/^\?+([^+@!?*[(]*)?$/,ec=([n,e=""])=>{let t=Cr([n]);return e?(e=e.toLowerCase(),s=>t(s)&&s.toLowerCase().endsWith(e)):t},tc=([n,e=""])=>{let t=Er([n]);return e?(e=e.toLowerCase(),s=>t(s)&&s.toLowerCase().endsWith(e)):t},sc=([n,e=""])=>{let t=Er([n]);return e?s=>t(s)&&s.endsWith(e):t},ic=([n,e=""])=>{let t=Cr([n]);return e?s=>t(s)&&s.endsWith(e):t},Cr=([n])=>{let e=n.length;return t=>t.length===e&&!t.startsWith(".")},Er=([n])=>{let e=n.length;return t=>t.length===e&&t!=="."&&t!==".."},kr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",$r={win32:{sep:"\\"},posix:{sep:"/"}},nc=kr==="win32"?$r.win32.sep:$r.posix.sep;B.sep=nc;var F=Symbol("globstar **");B.GLOBSTAR=F;var rc="[^/]",oc=rc+"*?",ac="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",lc="(?:(?!(?:\\/|^)\\.).)*?",cc=(n,e={})=>t=>B(t,n,e);B.filter=cc;var Z=(n,e={})=>Object.assign({},n,e),hc=n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return B;let e=B;return Object.assign((s,i,r={})=>e(s,i,Z(n,r)),{Minimatch:class extends e.Minimatch{constructor(i,r={}){super(i,Z(n,r))}static defaults(i){return e.defaults(Z(n,i)).Minimatch}},AST:class extends e.AST{constructor(i,r,o={}){super(i,r,Z(n,o))}static fromGlob(i,r={}){return e.AST.fromGlob(i,Z(n,r))}},unescape:(s,i={})=>e.unescape(s,Z(n,i)),escape:(s,i={})=>e.escape(s,Z(n,i)),filter:(s,i={})=>e.filter(s,Z(n,i)),defaults:s=>e.defaults(Z(n,s)),makeRe:(s,i={})=>e.makeRe(s,Z(n,i)),braceExpand:(s,i={})=>e.braceExpand(s,Z(n,i)),match:(s,i,r={})=>e.match(s,i,Z(n,r)),sep:e.sep,GLOBSTAR:F})};B.defaults=hc;var Or=(n,e={})=>(mt(n),e.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:mr(n,{max:e.braceExpandMax}));B.braceExpand=Or;var uc=(n,e={})=>new J(n,e).makeRe();B.makeRe=uc;var fc=(n,e,t={})=>{let s=new J(e,t);return n=n.filter(i=>s.match(i)),s.options.nonull&&!n.length&&n.push(e),n};B.match=fc;var _r=/[?*]|[+@!]\(.*?\)|\[|\]/,dc=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),J=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){mt(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||kr,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=r[0]===""&&r[1]===""&&(r[2]==="?"||!_r.test(r[2]))&&!_r.test(r[3]),c=/^[a-z]:/i.test(r[0]);if(l)return[...r.slice(0,4),...r.slice(4).map(u=>this.parse(u))];if(c)return[r[0],...r.slice(1).map(u=>this.parse(u))]}return r.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let s of e)for(let i=0;i<s.length;i++)s[i]==="**"&&(s[i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let i=s;for(;t[i+1]==="**";)i++;i!==s&&t.splice(s,i-s)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,i)=>{let r=s[s.length-1];return i==="**"&&r==="**"?s:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(i),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let r=e[i];i===1&&r===""&&e[0]===""||(r==="."||r==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){let i=e[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(t=!0,e.splice(s-1,2),s-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let s of e){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let a=s[i+1],l=s[i+2],c=s[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;t=!0,s.splice(i,1);let u=s.slice(0);u[i]="**",e.push(u),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(t=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let o=s[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let l=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...l),s.length===0&&s.push(""),r-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){let i=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(i){e[t]=[],e[s]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,s=!1){let i=0,r=0,o=[],a="";for(;i<e.length&&r<t.length;)if(e[i]===t[r])o.push(a==="b"?t[r]:e[i]),i++,r++;else if(s&&e[i]==="**"&&t[r]===e[i+1])o.push(e[i]),i++;else if(s&&t[r]==="**"&&e[i]===t[r+1])o.push(t[r]),r++;else if(e[i]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="b")return!1;a="a",o.push(e[i]),i++,r++}else if(t[r]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",o.push(t[r]),i++,r++}else return!1;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,s=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t}matchOne(e,t,s=!1){let i=0,r=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),l=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),c=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),u=!c&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),f=l?3:a?0:void 0,p=u?3:c?0:void 0;if(typeof f=="number"&&typeof p=="number"){let[d,m]=[e[f],t[p]];d.toLowerCase()===m.toLowerCase()&&(t[p]=d,r=p,i=f)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(F)?this.#e(e,t,s,i,r):this.#n(e,t,s,i,r)}#e(e,t,s,i,r){let o=t.indexOf(F,r),a=t.lastIndexOf(F),[l,c,u]=s?[t.slice(r,o),t.slice(o+1),[]]:[t.slice(r,o),t.slice(o+1,a),t.slice(a+1)];if(l.length){let v=e.slice(i,i+l.length);if(!this.#n(v,l,s,0,0))return!1;i+=l.length,r+=l.length}let f=0;if(u.length){if(u.length+i>e.length)return!1;let v=e.length-u.length;if(this.#n(e,u,s,v,0))f=u.length;else{if(e[e.length-1]!==""||i+u.length===e.length||(v--,!this.#n(e,u,s,v,0)))return!1;f=u.length+1}}if(!c.length){let v=!!f;for(let S=i;S<e.length-f;S++){let $=String(e[S]);if(v=!0,$==="."||$===".."||!this.options.dot&&$.startsWith("."))return!1}return s||v}let p=[[[],0]],d=p[0],m=0,g=[0];for(let v of c)v===F?(g.push(m),d=[[],0],p.push(d)):(d[0].push(v),m++);let b=p.length-1,y=e.length-f;for(let v of p)v[1]=y-(g[b--]+v[0].length);return!!this.#i(e,p,i,0,s,0,!!f)}#i(e,t,s,i,r,o,a){let l=t[i];if(!l){for(let f=s;f<e.length;f++){a=!0;let p=e[f];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[c,u]=l;for(;s<=u;){if(this.#n(e.slice(0,s+c.length),c,r,s,0)&&o<this.maxGlobstarRecursion){let d=this.#i(e,t,s+c.length,i+1,r,o+1,a);if(d!==!1)return d}let p=e[s];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;s++}return r||null}#n(e,t,s,i,r){let o,a,l,c;for(o=i,a=r,c=e.length,l=t.length;o<c&&a<l;o++,a++){this.debug("matchOne loop");let u=t[a],f=e[o];if(this.debug(t,u,f),u===!1||u===F)return!1;let p;if(typeof u=="string"?(p=f===u,this.debug("string match",u,f,p)):(p=u.test(f),this.debug("pattern match",u,f,p)),!p)return!1}if(o===c&&a===l)return!0;if(o===c)return s;if(a===l)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Or(this.pattern,this.options)}parse(e){mt(e);let t=this.options;if(e==="**")return F;if(e==="")return"";let s,i=null;(s=e.match(Kl))?i=t.dot?Zl:Xl:(s=e.match(Wl))?i=(t.nocase?t.dot?Bl:ql:t.dot?Hl:Vl)(s[1]):(s=e.match(Ql))?i=(t.nocase?t.dot?tc:ec:t.dot?sc:ic)(s):(s=e.match(Ul))?i=t.dot?Gl:zl:(s=e.match(Jl))&&(i=Yl);let r=Pe.fromGlob(e,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,s=t.noglobstar?oc:t.dot?ac:lc,i=new Set(t.nocase?["i"]:[]),r=e.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?dc(f):f===F?F:f._src});c.forEach((f,p)=>{let d=c[p+1],m=c[p-1];f!==F||m===F||(m===void 0?d!==void 0&&d!==F?c[p+1]="(?:\\/|"+s+"\\/)?"+d:c[p]=s:d===void 0?c[p-1]=m+"(?:\\/|\\/"+s+")?":d!==F&&(c[p-1]=m+"(?:\\/|\\/"+s+"\\/)"+d,c[p+1]=F))});let u=c.filter(f=>f!==F);if(this.partial&&u.length>=1){let f=[];for(let p=1;p<=u.length;p++)f.push(u.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];r="^"+o+r+a+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+a+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a of r){let l=i;if(s.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,t))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(e){return B.defaults(e).Minimatch}};B.AST=Pe;B.Minimatch=J;B.escape=Je;B.unescape=se;var Zr=require("node:url");var ts=require("node:diagnostics_channel"),D=(0,ts.channel)("lru-cache:metrics"),bt=(0,ts.tracingChannel)("lru-cache"),pc=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,yi=()=>D.hasSubscribers||bt.hasSubscribers,Fr=new Set,Ar=typeof process=="object"&&process?process:{},gc=(n,e,t,s)=>{typeof Ar.emitWarning=="function"?Ar.emitWarning(n,e,t,s):console.error(`[${t}] ${e}: ${n}`)},mc=n=>!Fr.has(n),$e=n=>!!n&&n===Math.floor(n)&&n>0&&isFinite(n),jr=n=>$e(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?es:null:null,es=class extends Array{constructor(n){super(n),this.fill(0)}},yc=class wt{heap;length;static#e=!1;static create(e){let t=jr(e);if(!t)return[];wt.#e=!0;let s=new wt(e,t);return wt.#e=!1,s}constructor(e,t){if(!wt.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},vt=class Rr{#e;#i;#n;#t;#o;#$;#b;#u;get perf(){return this.#u}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;backgroundFetchSize;#a;#f;#h;#c;#r;#w;#x;#p;#g;#E;#m;#S;#_;#d;#y;#v;#O;#s;#j;static unsafeExposeInternals(e){return{starts:e.#_,ttls:e.#d,autopurgeTimers:e.#y,sizes:e.#S,keyMap:e.#h,keyList:e.#c,valList:e.#r,next:e.#w,prev:e.#x,get head(){return e.#p},get tail(){return e.#g},free:e.#E,isBackgroundFetch:t=>e.#l(t),backgroundFetch:(t,s,i,r)=>e.#I(t,s,i,r),moveToTail:t=>e.#J(t),indexes:t=>e.#A(t),rindexes:t=>e.#F(t),isStale:t=>e.#C(t)}}get max(){return this.#e}get maxSize(){return this.#i}get calculatedSize(){return this.#f}get size(){return this.#a}get fetchMethod(){return this.#$}get memoMethod(){return this.#b}get dispose(){return this.#n}get onInsert(){return this.#t}get disposeAfter(){return this.#o}constructor(e){let{max:t=0,ttl:s,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:l,dispose:c,onInsert:u,disposeAfter:f,noDisposeOnSet:p,noUpdateTTL:d,maxSize:m=0,maxEntrySize:g=0,sizeCalculation:b,fetchMethod:y,memoMethod:v,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:$,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:ae,ignoreFetchAbort:fe,backgroundFetchSize:It=1,perf:Le}=e;if(this.backgroundFetchSize=It,Le!==void 0&&typeof Le?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#u=Le??pc,t!==0&&!$e(t))throw new TypeError("max option must be a nonnegative integer");let ks=t?jr(t):Array;if(!ks)throw new Error("invalid max value: "+t);if(this.#e=t,this.#i=m,this.maxEntrySize=g||this.#i,this.sizeCalculation=b,this.sizeCalculation){if(!this.#i&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(v!==void 0&&typeof v!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#b=v,y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#$=y,this.#O=!!y,this.#h=new Map,this.#c=Array.from({length:t}).fill(void 0),this.#r=Array.from({length:t}).fill(void 0),this.#w=new ks(t),this.#x=new ks(t),this.#p=0,this.#g=0,this.#E=yc.create(t),this.#a=0,this.#f=0,typeof c=="function"&&(this.#n=c),typeof u=="function"&&(this.#t=u),typeof f=="function"?(this.#o=f,this.#m=[]):(this.#o=void 0,this.#m=void 0),this.#v=!!this.#n,this.#j=!!this.#t,this.#s=!!this.#o,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!ae,this.ignoreFetchAbort=!!fe,this.maxEntrySize!==0){if(this.#i!==0&&!$e(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!$e(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#B()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!$,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=$e(i)||i===0?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!$e(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(this.#e===0&&this.ttl===0&&this.#i===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#i){let Os="LRU_CACHE_UNBOUNDED";mc(Os)&&(Fr.add(Os),gc("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Os,Rr))}}getRemainingTTL(e){return this.#h.has(e)?1/0:0}#R(){let e=new es(this.#e),t=new es(this.#e);this.#d=e,this.#_=t;let s=this.ttlAutopurge?Array.from({length:this.#e}):void 0;this.#y=s,this.#D=(a,l,c=this.#u.now())=>{t[a]=l!==0?c:0,e[a]=l,i(a,l)},this.#k=a=>{t[a]=e[a]!==0?this.#u.now():0,i(a,e[a])};let i=this.ttlAutopurge?(a,l)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),l&&l!==0&&s){let c=setTimeout(()=>{this.#C(a)&&this.#L(this.#c[a],"expire")},l+1);c.unref&&c.unref(),s[a]=c}}:()=>{};this.#P=(a,l)=>{if(e[l]){let c=e[l],u=t[l];if(!c||!u)return;a.ttl=c,a.start=u,a.now=r||o();let f=a.now-u;a.remainingTTL=c-f}};let r=0,o=()=>{let a=this.#u.now();if(this.ttlResolution>0){r=a;let l=setTimeout(()=>r=0,this.ttlResolution);l.unref&&l.unref()}return a};this.getRemainingTTL=a=>{let l=this.#h.get(a);if(l===void 0)return 0;let c=e[l],u=t[l];if(!c||!u)return 1/0;let f=(r||o())-u;return c-f},this.#C=a=>{let l=t[a],c=e[a];return!!c&&!!l&&(r||o())-l>c}}#k=()=>{};#P=()=>{};#D=()=>{};#C=()=>!1;#B(){let e=new es(this.#e);this.#f=0,this.#S=e,this.#M=t=>{this.#f-=e[t],e[t]=0},this.#W=(t,s,i,r)=>{if(!$e(i)){if(this.#l(s))return this.backgroundFetchSize;if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(s,t),!$e(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return i},this.#T=(t,s,i)=>{if(e[t]=s,this.#i){let r=this.#i-e[t];for(;this.#f>r;)this.#q(!0)}this.#f+=e[t],i&&(i.entrySize=s,i.totalCalculatedSize=this.#f)}}#M=e=>{};#T=(e,t,s)=>{};#W=(e,t,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#g;this.#V(t)&&((e||!this.#C(t))&&(yield t),t!==this.#p);)t=this.#x[t]}*#F({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#p;this.#V(t)&&((e||!this.#C(t))&&(yield t),t!==this.#g);)t=this.#w[t]}#V(e){return e!==void 0&&this.#h.get(this.#c[e])===e}*entries(){for(let e of this.#A())this.#r[e]!==void 0&&this.#c[e]!==void 0&&!this.#l(this.#r[e])&&(yield[this.#c[e],this.#r[e]])}*rentries(){for(let e of this.#F())this.#r[e]!==void 0&&this.#c[e]!==void 0&&!this.#l(this.#r[e])&&(yield[this.#c[e],this.#r[e]])}*keys(){for(let e of this.#A()){let t=this.#c[e];t!==void 0&&!this.#l(this.#r[e])&&(yield t)}}*rkeys(){for(let e of this.#F()){let t=this.#c[e];t!==void 0&&!this.#l(this.#r[e])&&(yield t)}}*values(){for(let e of this.#A())this.#r[e]!==void 0&&!this.#l(this.#r[e])&&(yield this.#r[e])}*rvalues(){for(let e of this.#F())this.#r[e]!==void 0&&!this.#l(this.#r[e])&&(yield this.#r[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let s of this.#A()){let i=this.#r[s],r=this.#l(i)?i.__staleWhileFetching:i;if(r!==void 0&&e(r,this.#c[s],this))return this.#G(this.#c[s],t)}}forEach(e,t=this){for(let s of this.#A()){let i=this.#r[s],r=this.#l(i)?i.__staleWhileFetching:i;r!==void 0&&e.call(t,r,this.#c[s],this)}}rforEach(e,t=this){for(let s of this.#F()){let i=this.#r[s],r=this.#l(i)?i.__staleWhileFetching:i;r!==void 0&&e.call(t,r,this.#c[s],this)}}purgeStale(){let e=!1;for(let t of this.#F({allowStale:!0}))this.#C(t)&&(this.#L(this.#c[t],"expire"),e=!0);return e}info(e){let t=this.#h.get(e);if(t===void 0)return;let s=this.#r[t],i=this.#l(s)?s.__staleWhileFetching:s;if(i===void 0)return;let r={value:i};if(this.#d&&this.#_){let o=this.#d[t],a=this.#_[t];if(o&&a){let l=o-(this.#u.now()-a);r.ttl=l,r.start=Date.now()}}return this.#S&&(r.size=this.#S[t]),r}dump(){let e=[];for(let t of this.#A({allowStale:!0})){let s=this.#c[t],i=this.#r[t],r=this.#l(i)?i.__staleWhileFetching:i;if(r===void 0||s===void 0)continue;let o={value:r};if(this.#d&&this.#_){o.ttl=this.#d[t];let a=this.#u.now()-this.#_[t];o.start=Math.floor(Date.now()-a)}this.#S&&(o.size=this.#S[t]),e.unshift([s,o])}return e}load(e){this.clear();for(let[t,s]of e){if(s.start){let i=Date.now()-s.start;s.start=this.#u.now()-i}this.#N(t,s.value,s)}}set(e,t,s={}){let{status:i=D.hasSubscribers?{}:void 0}=s;s.status=i,i&&(i.op="set",i.key=e,t!==void 0&&(i.value=t),i.cache=this);let r=this.#N(e,t,s);return i&&D.hasSubscribers&&D.publish(i),r}#N(e,t,s,i){let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=s,u=this.#l(t);if(t===void 0)return c&&(c.set="deleted"),this.delete(e),this;let{noUpdateTTL:f=this.noUpdateTTL}=s;c&&!u&&(c.value=t);let p=this.#W(e,t,s.size||0,l,c);if(this.maxEntrySize&&p>this.maxEntrySize)return this.#L(e,"set"),c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this;let d=this.#a===0?void 0:this.#h.get(e);if(d===void 0)d=this.#a===0?this.#g:this.#E.length!==0?this.#E.pop():this.#a===this.#e?this.#q(!1):this.#a,this.#c[d]=e,this.#r[d]=t,this.#h.set(e,d),this.#w[this.#g]=d,this.#x[d]=this.#g,this.#g=d,this.#a++,this.#T(d,p,c),c&&(c.set="add"),f=!1,this.#j&&!u&&this.#t?.(t,e,"add");else{this.#J(d);let m=this.#r[d];if(t!==m){if(!a)if(this.#l(m)){m!==i&&m.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=m;g!==void 0&&g!==t&&(this.#v&&this.#n?.(g,e,"set"),this.#s&&this.#m?.push([g,e,"set"]))}else this.#v&&this.#n?.(m,e,"set"),this.#s&&this.#m?.push([m,e,"set"]);if(this.#M(d),this.#T(d,p,c),this.#r[d]=t,!u){let g=m&&this.#l(m)?m.__staleWhileFetching:m,b=g===void 0?"add":t!==g?"replace":"update";c&&(c.set=b,g!==void 0&&(c.oldValue=g)),this.#j&&this.onInsert?.(t,e,b)}}else u||(c&&(c.set="update"),this.#j&&this.onInsert?.(t,e,"update"))}if(r!==0&&!this.#d&&this.#R(),this.#d&&(f||this.#D(d,r,o),c&&this.#P(c,d)),!a&&this.#s&&this.#m){let m=this.#m,g;for(;g=m?.shift();)this.#o?.(...g)}return this}pop(){try{for(;this.#a;){let e=this.#r[this.#p];if(this.#q(!0),this.#l(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#s&&this.#m){let e=this.#m,t;for(;t=e?.shift();)this.#o?.(...t)}}}#q(e){let t=this.#p,s=this.#c[t],i=this.#r[t],r=this.#l(i);r&&i.__abortController.abort(new Error("evicted"));let o=r?i.__staleWhileFetching:i;return(this.#v||this.#s)&&o!==void 0&&(this.#v&&this.#n?.(o,s,"evict"),this.#s&&this.#m?.push([o,s,"evict"])),this.#M(t),this.#y?.[t]&&(clearTimeout(this.#y[t]),this.#y[t]=void 0),e&&(this.#c[t]=void 0,this.#r[t]=void 0,this.#E.push(t)),this.#a===1?(this.#p=this.#g=0,this.#E.length=0):this.#p=this.#w[t],this.#h.delete(s),this.#a--,t}has(e,t={}){let{status:s=D.hasSubscribers?{}:void 0}=t;t.status=s,s&&(s.op="has",s.key=e,s.cache=this);let i=this.#Y(e,t);return D.hasSubscribers&&D.publish(s),i}#Y(e,t={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=t,r=this.#h.get(e);if(r!==void 0){let o=this.#r[r];if(this.#l(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#C(r))i&&(i.has="stale",this.#P(i,r));else return s&&this.#k(r),i&&(i.has="hit",this.#P(i,r)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{status:s=yi()?{}:void 0}=t;s&&(s.op="peek",s.key=e,s.cache=this),t.status=s;let i=this.#U(e,t);return D.hasSubscribers&&D.publish(s),i}#U(e,t){let{status:s,allowStale:i=this.allowStale}=t,r=this.#h.get(e);if(r===void 0||!i&&this.#C(r)){s&&(s.peek=r===void 0?"miss":"stale");return}let o=this.#r[r],a=this.#l(o)?o.__staleWhileFetching:o;return s&&(a!==void 0?(s.peek="hit",s.value=a):s.peek="miss"),a}#I(e,t,s,i){let r=t===void 0?void 0:this.#r[t];if(this.#l(r))return r;let o=new AbortController,{signal:a}=s;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let l={signal:o.signal,options:s,context:i},c=(g,b=!1)=>{let{aborted:y}=o.signal,v=s.ignoreFetchAbort&&g!==void 0,S=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&g!==void 0);if(s.status&&(y&&!b?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,v&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),y&&!v&&!b)return f(o.signal.reason,S);let $=d,x=this.#r[t];return(x===d||x===void 0&&v&&b)&&(g===void 0?$.__staleWhileFetching!==void 0?this.#r[t]=$.__staleWhileFetching:this.#L(e,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.#N(e,g,l.options,$))),g},u=g=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=g),f(g,!1)),f=(g,b)=>{let{aborted:y}=o.signal,v=y&&s.allowStaleOnFetchAbort,S=v||s.allowStaleOnFetchRejection,$=S||s.noDeleteOnFetchRejection,x=d;if(this.#r[t]===d&&(!$||!b&&x.__staleWhileFetching===void 0?this.#L(e,"fetch"):v||(this.#r[t]=x.__staleWhileFetching)),S)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),x.__staleWhileFetching;if(x.__returned===x)throw g},p=(g,b)=>{let y=this.#$?.(e,r,l);o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(g(void 0),s.allowStaleOnFetchAbort&&(g=v=>c(v,!0)))}),y&&y instanceof Promise?y.then(v=>g(v===void 0?void 0:v),b):y!==void 0&&g(y)};s.status&&(s.status.fetchDispatched=!0);let d=new Promise(p).then(c,u),m=Object.assign(d,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return t===void 0?(this.#N(e,m,{...l.options,status:void 0}),t=this.#h.get(e)):this.#r[t]=m,m}#l(e){if(!this.#O)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController}fetch(e,t={}){let s=bt.hasSubscribers,{status:i=yi()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let r=this.#z(e,t);return i&&s&&(i.trace=!0,bt.tracePromise(()=>r,i).catch(()=>{})),r}async#z(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:g,forceRefresh:b=!1,status:y,signal:v}=t;if(y&&(y.op="fetch",y.key=e,b&&(y.forceRefresh=!0),y.cache=this),!this.#O)return y&&(y.fetch="get"),this.#G(e,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:y});let S={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:a,size:l,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:m,ignoreFetchAbort:d,status:y,signal:v},$=this.#h.get(e);if($===void 0){y&&(y.fetch="miss");let x=this.#I(e,$,S,g);return x.__returned=x}else{let x=this.#r[$];if(this.#l(x)){let Le=s&&x.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",Le&&(y.returnedStale=!0)),Le?x.__staleWhileFetching:x.__returned=x}let ae=this.#C($);if(!b&&!ae)return y&&(y.fetch="hit"),this.#J($),i&&this.#k($),y&&this.#P(y,$),x;let fe=this.#I(e,$,S,g),It=fe.__staleWhileFetching!==void 0&&s;return y&&(y.fetch=ae?"stale":"refresh",It&&ae&&(y.returnedStale=!0)),It?fe.__staleWhileFetching:fe.__returned=fe}}forceFetch(e,t={}){let s=bt.hasSubscribers,{status:i=yi()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let r=this.#H(e,t);return i&&s&&(i.trace=!0,bt.tracePromise(()=>r,i).catch(()=>{})),r}async#H(e,t={}){let s=await this.#z(e,t);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,t={}){let{status:s=D.hasSubscribers?{}:void 0}=t;t.status=s,s&&(s.op="memo",s.key=e,t.context&&(s.context=t.context),s.cache=this);let i=this.#Z(e,t);return s&&(s.value=i),D.hasSubscribers&&D.publish(s),i}#Z(e,t={}){let s=this.#b;if(!s)throw new Error("no memoMethod provided to constructor");let{context:i,status:r,forceRefresh:o,...a}=t;r&&o&&(r.forceRefresh=!0);let l=this.#G(e,a),c=o||l===void 0;if(r&&(r.memo=c?"miss":"hit",c||(r.value=l)),!c)return l;let u=s(e,l,{options:a,context:i});return r&&(r.value=u),this.#N(e,u,a),u}get(e,t={}){let{status:s=D.hasSubscribers?{}:void 0}=t;t.status=s,s&&(s.op="get",s.key=e,s.cache=this);let i=this.#G(e,t);return s&&(i!==void 0&&(s.value=i),D.hasSubscribers&&D.publish(s)),i}#G(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=t,a=this.#h.get(e);if(a===void 0){o&&(o.get="miss");return}let l=this.#r[a],c=this.#l(l);return o&&this.#P(o,a),this.#C(a)?c?(o&&(o.get="stale-fetching"),s&&l.__staleWhileFetching!==void 0?(o&&(o.returnedStale=!0),l.__staleWhileFetching):void 0):(r||this.#L(e,"expire"),o&&(o.get="stale"),s?(o&&(o.returnedStale=!0),l):void 0):(o&&(o.get=c?"fetching":"hit"),this.#J(a),i&&this.#k(a),c?l.__staleWhileFetching:l)}#K(e,t){this.#x[t]=e,this.#w[e]=t}#J(e){e!==this.#g&&(e===this.#p?this.#p=this.#w[e]:this.#K(this.#x[e],this.#w[e]),this.#K(this.#g,e),this.#g=e)}delete(e){return this.#L(e,"delete")}#L(e,t){D.hasSubscribers&&D.publish({op:"delete",delete:t,key:e,cache:this});let s=!1;if(this.#a!==0){let i=this.#h.get(e);if(i!==void 0)if(this.#y?.[i]&&(clearTimeout(this.#y?.[i]),this.#y[i]=void 0),s=!0,this.#a===1)this.#X(t);else{this.#M(i);let r=this.#r[i];if(this.#l(r)?r.__abortController.abort(new Error("deleted")):(this.#v||this.#s)&&(this.#v&&this.#n?.(r,e,t),this.#s&&this.#m?.push([r,e,t])),this.#h.delete(e),this.#c[i]=void 0,this.#r[i]=void 0,i===this.#g)this.#g=this.#x[i];else if(i===this.#p)this.#p=this.#w[i];else{let o=this.#x[i];this.#w[o]=this.#w[i];let a=this.#w[i];this.#x[a]=this.#x[i]}this.#a--,this.#E.push(i)}}if(this.#s&&this.#m?.length){let i=this.#m,r;for(;r=i?.shift();)this.#o?.(...r)}return s}clear(){return this.#X("delete")}#X(e){for(let t of this.#F({allowStale:!0})){let s=this.#r[t];if(this.#l(s))s.__abortController.abort(new Error("deleted"));else{let i=this.#c[t];this.#v&&this.#n?.(s,i,e),this.#s&&this.#m?.push([s,i,e])}}if(this.#h.clear(),this.#r.fill(void 0),this.#c.fill(void 0),this.#d&&this.#_){this.#d.fill(0),this.#_.fill(0);for(let t of this.#y??[])t!==void 0&&clearTimeout(t);this.#y?.fill(void 0)}if(this.#S&&this.#S.fill(0),this.#p=0,this.#g=0,this.#E.length=0,this.#f=0,this.#a=0,this.#s&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#o?.(...s)}}};var Xe=require("node:path"),Hr=require("node:url"),he=require("fs"),kc=_(require("node:fs"),1),Ee=require("node:fs/promises");var ls=require("node:events"),_i=_(require("node:stream"),1),Ir=require("node:string_decoder"),Pr=typeof process=="object"&&process?process:{stdout:null,stderr:null},bc=n=>!!n&&typeof n=="object"&&(n instanceof Ce||n instanceof _i.default||wc(n)||vc(n)),wc=n=>!!n&&typeof n=="object"&&n instanceof ls.EventEmitter&&typeof n.pipe=="function"&&n.pipe!==_i.default.Writable.prototype.pipe,vc=n=>!!n&&typeof n=="object"&&n instanceof ls.EventEmitter&&typeof n.write=="function"&&typeof n.end=="function",ge=Symbol("EOF"),me=Symbol("maybeEmitEnd"),_e=Symbol("emittedEnd"),ss=Symbol("emittingEnd"),xt=Symbol("emittedError"),is=Symbol("closed"),Tr=Symbol("read"),ns=Symbol("flush"),Mr=Symbol("flushChunk"),ie=Symbol("encoding"),Ye=Symbol("decoder"),N=Symbol("flowing"),St=Symbol("paused"),Ke=Symbol("resume"),I=Symbol("buffer"),U=Symbol("pipes"),L=Symbol("bufferLength"),bi=Symbol("bufferPush"),rs=Symbol("bufferShift"),H=Symbol("objectMode"),j=Symbol("destroyed"),wi=Symbol("error"),vi=Symbol("emitData"),Nr=Symbol("emitEnd"),xi=Symbol("emitEnd2"),le=Symbol("async"),Si=Symbol("abort"),os=Symbol("aborted"),$t=Symbol("signal"),Te=Symbol("dataListeners"),Y=Symbol("discarded"),_t=n=>Promise.resolve().then(n),xc=n=>n(),Sc=n=>n==="end"||n==="finish"||n==="prefinish",$c=n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,_c=n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),as=class{src;dest;opts;ondrain;constructor(e,t,s){this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Ke](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},$i=class extends as{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>this.dest.emit("error",i),e.on("error",this.proxyErrors)}},Cc=n=>!!n.objectMode,Ec=n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer",Ce=class extends ls.EventEmitter{[N]=!1;[St]=!1;[U]=[];[I]=[];[H];[ie];[le];[Ye];[ge]=!1;[_e]=!1;[ss]=!1;[is]=!1;[xt]=null;[L]=0;[j]=!1;[$t];[os]=!1;[Te]=0;[Y]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Cc(t)?(this[H]=!0,this[ie]=null):Ec(t)?(this[ie]=t.encoding,this[H]=!1):(this[H]=!1,this[ie]=null),this[le]=!!t.async,this[Ye]=this[ie]?new Ir.StringDecoder(this[ie]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[I]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[U]});let{signal:s}=t;s&&(this[$t]=s,s.aborted?this[Si]():s.addEventListener("abort",()=>this[Si]()))}get bufferLength(){return this[L]}get encoding(){return this[ie]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[H]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[le]}set async(e){this[le]=this[le]||!!e}[Si](){this[os]=!0,this.emit("abort",this[$t]?.reason),this.destroy(this[$t]?.reason)}get aborted(){return this[os]}set aborted(e){}write(e,t,s){if(this[os])return!1;if(this[ge])throw new Error("write after end");if(this[j])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let i=this[le]?_t:xc;if(!this[H]&&!Buffer.isBuffer(e)){if(_c(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if($c(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[H]?(this[N]&&this[L]!==0&&this[ns](!0),this[N]?this.emit("data",e):this[bi](e),this[L]!==0&&this.emit("readable"),s&&i(s),this[N]):e.length?(typeof e=="string"&&!(t===this[ie]&&!this[Ye]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[ie]&&(e=this[Ye].write(e)),this[N]&&this[L]!==0&&this[ns](!0),this[N]?this.emit("data",e):this[bi](e),this[L]!==0&&this.emit("readable"),s&&i(s),this[N]):(this[L]!==0&&this.emit("readable"),s&&i(s),this[N])}read(e){if(this[j])return null;if(this[Y]=!1,this[L]===0||e===0||e&&e>this[L])return this[me](),null;this[H]&&(e=null),this[I].length>1&&!this[H]&&(this[I]=[this[ie]?this[I].join(""):Buffer.concat(this[I],this[L])]);let t=this[Tr](e||null,this[I][0]);return this[me](),t}[Tr](e,t){if(this[H])this[rs]();else{let s=t;e===s.length||e===null?this[rs]():typeof s=="string"?(this[I][0]=s.slice(e),t=s.slice(0,e),this[L]-=e):(this[I][0]=s.subarray(e),t=s.subarray(0,e),this[L]-=e)}return this.emit("data",t),!this[I].length&&!this[ge]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[ge]=!0,this.writable=!1,(this[N]||!this[St])&&this[me](),this}[Ke](){this[j]||(!this[Te]&&!this[U].length&&(this[Y]=!0),this[St]=!1,this[N]=!0,this.emit("resume"),this[I].length?this[ns]():this[ge]?this[me]():this.emit("drain"))}resume(){return this[Ke]()}pause(){this[N]=!1,this[St]=!0,this[Y]=!1}get destroyed(){return this[j]}get flowing(){return this[N]}get paused(){return this[St]}[bi](e){this[H]?this[L]+=1:this[L]+=e.length,this[I].push(e)}[rs](){return this[H]?this[L]-=1:this[L]-=this[I][0].length,this[I].shift()}[ns](e=!1){do;while(this[Mr](this[rs]())&&this[I].length);!e&&!this[I].length&&!this[ge]&&this.emit("drain")}[Mr](e){return this.emit("data",e),this[N]}pipe(e,t){if(this[j])return e;this[Y]=!1;let s=this[_e];return t=t||{},e===Pr.stdout||e===Pr.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[U].push(t.proxyErrors?new $i(this,e,t):new as(this,e,t)),this[le]?_t(()=>this[Ke]()):this[Ke]()),e}unpipe(e){let t=this[U].find(s=>s.dest===e);t&&(this[U].length===1?(this[N]&&this[Te]===0&&(this[N]=!1),this[U]=[]):this[U].splice(this[U].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[Y]=!1,this[Te]++,!this[U].length&&!this[N]&&this[Ke]();else if(e==="readable"&&this[L]!==0)super.emit("readable");else if(Sc(e)&&this[_e])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[xt]){let i=t;this[le]?_t(()=>i.call(this,this[xt])):i.call(this,this[xt])}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[Te]=this.listeners("data").length,this[Te]===0&&!this[Y]&&!this[U].length&&(this[N]=!1)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Te]=0,!this[Y]&&!this[U].length&&(this[N]=!1)),t}get emittedEnd(){return this[_e]}[me](){!this[ss]&&!this[_e]&&!this[j]&&this[I].length===0&&this[ge]&&(this[ss]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[is]&&this.emit("close"),this[ss]=!1)}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==j&&this[j])return!1;if(e==="data")return!this[H]&&!s?!1:this[le]?(_t(()=>this[vi](s)),!0):this[vi](s);if(e==="end")return this[Nr]();if(e==="close"){if(this[is]=!0,!this[_e]&&!this[j])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(e==="error"){this[xt]=s,super.emit(wi,s);let r=!this[$t]||this.listeners("error").length?super.emit("error",s):!1;return this[me](),r}else if(e==="resume"){let r=super.emit("resume");return this[me](),r}else if(e==="finish"||e==="prefinish"){let r=super.emit(e);return this.removeAllListeners(e),r}let i=super.emit(e,...t);return this[me](),i}[vi](e){for(let s of this[U])s.dest.write(e)===!1&&this.pause();let t=this[Y]?!1:super.emit("data",e);return this[me](),t}[Nr](){return this[_e]?!1:(this[_e]=!0,this.readable=!1,this[le]?(_t(()=>this[xi]()),!0):this[xi]())}[xi](){if(this[Ye]){let t=this[Ye].end();if(t){for(let s of this[U])s.dest.write(t);this[Y]||super.emit("data",t)}}for(let t of this[U])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[H]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[H]||(e.dataLength+=s.length)}),await t,e}async concat(){if(this[H])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[ie]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(j,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Y]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[ge])return t();let r,o,a=f=>{this.off("data",l),this.off("end",c),this.off(j,u),t(),o(f)},l=f=>{this.off("error",a),this.off("end",c),this.off(j,u),this.pause(),r({value:f,done:!!this[ge]})},c=()=>{this.off("error",a),this.off("data",l),this.off(j,u),t(),r({done:!0,value:void 0})},u=()=>a(new Error("stream destroyed"));return new Promise((f,p)=>{o=p,r=f,this.once(j,u),this.once("error",a),this.once("end",c),this.once("data",l)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Y]=!1;let e=!1,t=()=>(this.pause(),this.off(wi,t),this.off(j,t),this.off("end",t),e=!0,{done:!0,value:void 0}),s=()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}};return this.once("end",t),this.once(wi,t),this.once(j,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[j])return e?this.emit("error",e):this.emit(j),this;this[j]=!0,this[Y]=!0,this[I].length=0,this[L]=0;let t=this;return typeof t.close=="function"&&!this[is]&&t.close(),e?this.emit("error",e):this.emit(j),this}static get isStream(){return bc}};var Oc=he.realpathSync.native,Et={lstatSync:he.lstatSync,readdir:he.readdir,readdirSync:he.readdirSync,readlinkSync:he.readlinkSync,realpathSync:Oc,promises:{lstat:Ee.lstat,readdir:Ee.readdir,readlink:Ee.readlink,realpath:Ee.realpath}},qr=n=>!n||n===Et||n===kc?Et:{...Et,...n,promises:{...Et.promises,...n.promises||{}}},Br=/^\\\\\?\\([a-z]:)\\?$/i,Ac=n=>n.replace(/\//g,"\\").replace(Br,"$1\\"),Fc=/[\\\/]/,ee=0,Ur=1,zr=2,ce=4,Gr=6,Jr=8,Me=10,Yr=12,Q=15,Ct=~Q,Ci=16,Lr=32,kt=64,ne=128,cs=256,us=512,Dr=kt|ne|us,jc=1023,Ei=n=>n.isFile()?Jr:n.isDirectory()?ce:n.isSymbolicLink()?Me:n.isCharacterDevice()?zr:n.isBlockDevice()?Gr:n.isSocket()?Yr:n.isFIFO()?Ur:ee,Wr=new vt({max:2**12}),Ot=n=>{let e=Wr.get(n);if(e)return e;let t=n.normalize("NFKD");return Wr.set(n,t),t},Vr=new vt({max:2**12}),hs=n=>{let e=Vr.get(n);if(e)return e;let t=Ot(n.toLowerCase());return Vr.set(n,t),t},fs=class extends vt{constructor(){super({max:256})}},ki=class extends vt{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},Kr=Symbol("PathScurry setAsCwd"),q=class{name;root;roots;parent;nocase;isCWD=!1;#e;#i;get dev(){return this.#i}#n;get mode(){return this.#n}#t;get nlink(){return this.#t}#o;get uid(){return this.#o}#$;get gid(){return this.#$}#b;get rdev(){return this.#b}#u;get blksize(){return this.#u}#a;get ino(){return this.#a}#f;get size(){return this.#f}#h;get blocks(){return this.#h}#c;get atimeMs(){return this.#c}#r;get mtimeMs(){return this.#r}#w;get ctimeMs(){return this.#w}#x;get birthtimeMs(){return this.#x}#p;get atime(){return this.#p}#g;get mtime(){return this.#g}#E;get ctime(){return this.#E}#m;get birthtime(){return this.#m}#S;#_;#d;#y;#v;#O;#s;#j;#R;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=ee,s,i,r,o,a){this.name=e,this.#S=r?hs(e):Ot(e),this.#s=t&jc,this.nocase=r,this.roots=i,this.root=s||this,this.#j=o,this.#d=a.fullpath,this.#v=a.relative,this.#O=a.relativePosix,this.parent=a.parent,this.parent?this.#e=this.parent.#e:this.#e=qr(a.fs)}depth(){return this.#_!==void 0?this.#_:this.parent?this.#_=this.parent.depth()+1:this.#_=0}childrenCache(){return this.#j}resolve(e){if(!e)return this;let t=this.getRootString(e),i=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#P(i):this.#P(i)}#P(e){let t=this;for(let s of e)t=t.child(s);return t}children(){let e=this.#j.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#j.set(this,t),this.#s&=~Ci,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?hs(e):Ot(e);for(let l of s)if(l.#S===i)return l;let r=this.parent?this.sep:"",o=this.#d?this.#d+r+e:void 0,a=this.newChild(e,ee,{...t,parent:this,fullpath:o});return this.canReaddir()||(a.#s|=ne),s.push(a),a}relative(){if(this.isCWD)return"";if(this.#v!==void 0)return this.#v;let e=this.name,t=this.parent;if(!t)return this.#v=this.name;let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let e=this.name,t=this.parent;if(!t)return this.#O=this.fullpathPosix();let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(this.#d!==void 0)return this.#d;let e=this.name,t=this.parent;if(!t)return this.#d=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#d=i}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#y=`//?/${i}`:this.#y=i}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return this.#y=s}isUnknown(){return(this.#s&Q)===ee}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#s&Q)===Jr}isDirectory(){return(this.#s&Q)===ce}isCharacterDevice(){return(this.#s&Q)===zr}isBlockDevice(){return(this.#s&Q)===Gr}isFIFO(){return(this.#s&Q)===Ur}isSocket(){return(this.#s&Q)===Yr}isSymbolicLink(){return(this.#s&Me)===Me}lstatCached(){return this.#s&Lr?this:void 0}readlinkCached(){return this.#R}realpathCached(){return this.#k}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#R)return!0;if(!this.parent)return!1;let e=this.#s&Q;return!(e!==ee&&e!==Me||this.#s&cs||this.#s&ne)}calledReaddir(){return!!(this.#s&Ci)}isENOENT(){return!!(this.#s&ne)}isNamed(e){return this.nocase?this.#S===hs(e):this.#S===Ot(e)}async readlink(){let e=this.#R;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return this.#R=s}catch(t){this.#F(t.code);return}}readlinkSync(){let e=this.#R;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return this.#R=s}catch(t){this.#F(t.code);return}}#D(e){this.#s|=Ci;for(let t=e.provisional;t<e.length;t++){let s=e[t];s&&s.#C()}}#C(){this.#s&ne||(this.#s=(this.#s|ne)&Ct,this.#B())}#B(){let e=this.children();e.provisional=0;for(let t of e)t.#C()}#M(){this.#s|=us,this.#T()}#T(){if(this.#s&kt)return;let e=this.#s;(e&Q)===ce&&(e&=Ct),this.#s=e|kt,this.#B()}#W(e=""){e==="ENOTDIR"||e==="EPERM"?this.#T():e==="ENOENT"?this.#C():this.children().provisional=0}#A(e=""){e==="ENOTDIR"?this.parent.#T():e==="ENOENT"&&this.#C()}#F(e=""){let t=this.#s;t|=cs,e==="ENOENT"&&(t|=ne),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Ct),this.#s=t,e==="ENOTDIR"&&this.parent&&this.parent.#T()}#V(e,t){return this.#q(e,t)||this.#N(e,t)}#N(e,t){let s=Ei(e),i=this.newChild(e.name,s,{parent:this}),r=i.#s&Q;return r!==ce&&r!==Me&&r!==ee&&(i.#s|=kt),t.unshift(i),t.provisional++,i}#q(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?hs(e.name):Ot(e.name))===i.#S)return this.#Y(e,i,s,t)}}#Y(e,t,s,i){let r=t.name;return t.#s=t.#s&Ct|Ei(e),r!==e.name&&(t.name=e.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(t)),i.provisional++,t}async lstat(){if(!(this.#s&ne))try{return this.#U(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#A(e.code)}}lstatSync(){if(!(this.#s&ne))try{return this.#U(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#A(e.code)}}#U(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:o,blocks:a,ctime:l,ctimeMs:c,dev:u,gid:f,ino:p,mode:d,mtime:m,mtimeMs:g,nlink:b,rdev:y,size:v,uid:S}=e;this.#p=t,this.#c=s,this.#m=i,this.#x=r,this.#u=o,this.#h=a,this.#E=l,this.#w=c,this.#i=u,this.#$=f,this.#a=p,this.#n=d,this.#g=m,this.#r=g,this.#t=b,this.#b=y,this.#f=v,this.#o=S;let $=Ei(e);this.#s=this.#s&Ct|$|Lr,$!==ee&&$!==ce&&$!==Me&&(this.#s|=kt)}#I=[];#l=!1;#z(e){this.#l=!1;let t=this.#I.slice();this.#I.length=0,t.forEach(s=>s(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);t?e(null,r):queueMicrotask(()=>e(null,r));return}if(this.#I.push(e),this.#l)return;this.#l=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(r,o)=>{if(r)this.#W(r.code),s.provisional=0;else{for(let a of o)this.#V(a,s);this.#D(s)}this.#z(s.slice(0,s.provisional))})}#H;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#H)await this.#H;else{let s=()=>{};this.#H=new Promise(i=>s=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#V(i,e);this.#D(e)}catch(i){this.#W(i.code),e.provisional=0}this.#H=void 0,s()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of this.#e.readdirSync(t,{withFileTypes:!0}))this.#V(s,e);this.#D(e)}catch(s){this.#W(s.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#s&Dr)return!1;let e=Q&this.#s;return e===ee||e===ce||e===Me}shouldWalk(e,t){return(this.#s&ce)===ce&&!(this.#s&Dr)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#k)return this.#k;if(!((us|cs|ne)&this.#s))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#k=this.resolve(e)}catch{this.#M()}}realpathSync(){if(this.#k)return this.#k;if(!((us|cs|ne)&this.#s))try{let e=this.#e.realpathSync(this.fullpath());return this.#k=this.resolve(e)}catch{this.#M()}}[Kr](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),s=[],i=this;for(;i&&i.parent;)t.add(i),i.#v=s.join(this.sep),i.#O=s.join("/"),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#v=void 0,i.#O=void 0,i=i.parent}},ds=class n extends q{sep="\\";splitSep=Fc;constructor(e,t=ee,s,i,r,o,a){super(e,t,s,i,r,o,a)}newChild(e,t=ee,s={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(e){return Xe.win32.parse(e).root}getRoot(e){if(e=Ac(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,s]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=s;return this.roots[e]=new Ze(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(Br,"$1\\"),e===t}},ps=class n extends q{splitSep="/";sep="/";constructor(e,t=ee,s,i,r,o,a){super(e,t,s,i,r,o,a)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=ee,s={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),s)}},gs=class{root;rootPath;roots;cwd;#e;#i;#n;nocase;#t;constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:r=16*1024,fs:o=Et}={}){this.#t=qr(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,Hr.fileURLToPath)(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#e=new fs,this.#i=new fs,this.#n=new ki(r);let l=a.substring(this.rootPath.length).split(s);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#t),this.roots[this.rootPath]=this.root;let c=this.root,u=l.length-1,f=t.sep,p=this.rootPath,d=!1;for(let m of l){let g=u--;c=c.child(m,{relative:new Array(g).fill("..").join(f),relativePosix:new Array(g).fill("..").join("/"),fullpath:p+=(d?"":f)+m}),d=!0}this.cwd=c}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let t="";for(let r=e.length-1;r>=0;r--){let o=e[r];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#e.get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return this.#e.set(t,i),i}resolvePosix(...e){let t="";for(let r=e.length-1;r>=0;r--){let o=e[r];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#i.get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return this.#i.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let i=await e.readdir();return s?i:i.map(r=>r.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:s=!0}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,a=[];(!r||r(e))&&a.push(s?e:e.fullpath());let l=new Set,c=(f,p)=>{l.add(f),f.readdirCB((d,m)=>{if(d)return p(d);let g=m.length;if(!g)return p();let b=()=>{--g===0&&p()};for(let y of m)(!r||r(y))&&a.push(s?y:y.fullpath()),i&&y.isSymbolicLink()?y.realpath().then(v=>v?.isUnknown()?v.lstat():v).then(v=>v?.shouldWalk(l,o)?c(v,b):b()):y.shouldWalk(l,o)?c(y,b):b()},!0)},u=e;return new Promise((f,p)=>{c(u,d=>{if(d)return p(d);f(a)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,a=[];(!r||r(e))&&a.push(s?e:e.fullpath());let l=new Set([e]);for(let c of l){let u=c.readdirSync();for(let f of u){(!r||r(f))&&a.push(s?f:f.fullpath());let p=f;if(f.isSymbolicLink()){if(!(i&&(p=f.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(l,o)&&l.add(p)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t;(!r||r(e))&&(yield s?e:e.fullpath());let a=new Set([e]);for(let l of a){let c=l.readdirSync();for(let u of c){(!r||r(u))&&(yield s?u:u.fullpath());let f=u;if(u.isSymbolicLink()){if(!(i&&(f=u.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(a,o)&&a.add(f)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,a=new Ce({objectMode:!0});(!r||r(e))&&a.write(s?e:e.fullpath());let l=new Set,c=[e],u=0,f=()=>{let p=!1;for(;!p;){let d=c.shift();if(!d){u===0&&a.end();return}u++,l.add(d);let m=(b,y,v=!1)=>{if(b)return a.emit("error",b);if(i&&!v){let S=[];for(let $ of y)$.isSymbolicLink()&&S.push($.realpath().then(x=>x?.isUnknown()?x.lstat():x));if(S.length){Promise.all(S).then(()=>m(null,y,!0));return}}for(let S of y)S&&(!r||r(S))&&(a.write(s?S:S.fullpath())||(p=!0));u--;for(let S of y){let $=S.realpathCached()||S;$.shouldWalk(l,o)&&c.push($)}p&&!a.flowing?a.once("drain",f):g||f()},g=!0;d.readdirCB(m,!0),g=!1}};return f(),a}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,a=new Ce({objectMode:!0}),l=new Set;(!r||r(e))&&a.write(s?e:e.fullpath());let c=[e],u=0,f=()=>{let p=!1;for(;!p;){let d=c.shift();if(!d){u===0&&a.end();return}u++,l.add(d);let m=d.readdirSync();for(let g of m)(!r||r(g))&&(a.write(s?g:g.fullpath())||(p=!0));u--;for(let g of m){let b=g;if(g.isSymbolicLink()){if(!(i&&(b=g.realpathSync())))continue;b.isUnknown()&&b.lstatSync()}b.shouldWalk(l,o)&&c.push(b)}}p&&!a.flowing&&a.once("drain",f)};return f(),a}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[Kr](t)}},Ze=class extends gs{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,Xe.win32,"\\",{...t,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return Xe.win32.parse(e).root.toUpperCase()}newRoot(e){return new ds(this.rootPath,ce,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Qe=class extends gs{sep="/";constructor(e=process.cwd(),t={}){let{nocase:s=!1}=t;super(e,Xe.posix,"/",{...t,nocase:s}),this.nocase=s}parseRootPath(e){return"/"}newRoot(e){return new ps(this.rootPath,ce,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},At=class extends Qe{constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,{...t,nocase:s})}},df=process.platform==="win32"?ds:ps,Xr=process.platform==="win32"?Ze:process.platform==="darwin"?At:Qe;var Rc=n=>n.length>=1,Pc=n=>n.length>=1,et=class n{#e;#i;#n;length;#t;#o;#$;#b;#u;#a;#f=!0;constructor(e,t,s,i){if(!Rc(e))throw new TypeError("empty pattern list");if(!Pc(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#i=t,this.#n=s,this.#t=i,this.#n===0){if(this.isUNC()){let[r,o,a,l,...c]=this.#e,[u,f,p,d,...m]=this.#i;c[0]===""&&(c.shift(),m.shift());let g=[r,o,a,l,""].join("/"),b=[u,f,p,d,""].join("/");this.#e=[g,...c],this.#i=[b,...m],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[r,...o]=this.#e,[a,...l]=this.#i;o[0]===""&&(o.shift(),l.shift());let c=r+"/",u=a+"/";this.#e=[c,...o],this.#i=[u,...l],this.length=this.#e.length}}}pattern(){return this.#e[this.#n]}isString(){return typeof this.#e[this.#n]=="string"}isGlobstar(){return this.#e[this.#n]===F}isRegExp(){return this.#e[this.#n]instanceof RegExp}globString(){return this.#$=this.#$||(this.#n===0?this.isAbsolute()?this.#i[0]+this.#i.slice(1).join("/"):this.#i.join("/"):this.#i.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new n(this.#e,this.#i,this.#n+1,this.#t),this.#o.#a=this.#a,this.#o.#u=this.#u,this.#o.#b=this.#b,this.#o):this.#o=null}isUNC(){let e=this.#e;return this.#u!==void 0?this.#u:this.#u=this.#t==="win32"&&this.#n===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#b!==void 0?this.#b:this.#b=this.#t==="win32"&&this.#n===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#a!==void 0?this.#a:this.#a=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#n===0?e:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}};var Tc=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",tt=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:r,platform:o=Tc}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let a of e)this.add(a)}add(e){let t=new J(e,this.mmopts);for(let s=0;s<t.set.length;s++){let i=t.set[s],r=t.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let o=new et(i,r,0,this.platform),a=new J(o.globString(),this.mmopts),l=r[r.length-1]==="**",c=o.isAbsolute();c?this.absolute.push(a):this.relative.push(a),l&&(c?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(e){let t=e.fullpath(),s=`${t}/`,i=e.relative()||".",r=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(r))return!0;for(let o of this.absolute)if(o.match(t)||o.match(s))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",s=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}};var Oi=class n{store;constructor(e=new Map){this.store=e}copy(){return new n(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let s=e.fullpath(),i=this.store.get(s);i?i.add(t.globString()):this.store.set(s,new Set([t.globString()]))}},Ai=class{store=new Map;add(e,t,s){let i=(t?2:0)|(s?1:0),r=this.store.get(e);this.store.set(e,r===void 0?i:i&r)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},Fi=class{store=new Map;add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(i=>i.globString()===t.globString())||s.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},Ft=class n{hasWalkedCache;matches=new Ai;subwalks=new Fi;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Oi}processPatterns(e,t){this.patterns=t;let s=t.map(i=>[e,i]);for(let[i,r]of s){this.hasWalkedCache.storeWalked(i,r);let o=r.root(),a=r.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=r.rest();if(f)r=f;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let l,c,u=!1;for(;typeof(l=r.pattern())=="string"&&(c=r.rest());)i=i.resolve(l),r=c,u=!0;if(l=r.pattern(),c=r.rest(),u){if(this.hasWalkedCache.hasWalked(i,r))continue;this.hasWalkedCache.storeWalked(i,r)}if(typeof l=="string"){let f=l===".."||l===""||l===".";this.matches.add(i.resolve(l),a,f);continue}else if(l===F){(!i.isSymbolicLink()||this.follow||r.checkFollowGlobstar())&&this.subwalks.add(i,r);let f=c?.pattern(),p=c?.rest();if(!c||(f===""||f===".")&&!p)this.matches.add(i,a,f===""||f===".");else if(f===".."){let d=i.parent||i;p?this.hasWalkedCache.hasWalked(d,p)||this.subwalks.add(d,p):this.matches.add(d,a,!0)}}else l instanceof RegExp&&this.subwalks.add(i,r)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new n(this.opts,this.hasWalkedCache)}filterEntries(e,t){let s=this.subwalks.get(e),i=this.child();for(let r of t)for(let o of s){let a=o.isAbsolute(),l=o.pattern(),c=o.rest();l===F?i.testGlobstar(r,o,c,a):l instanceof RegExp?i.testRegExp(r,l,c,a):i.testString(r,l,c,a)}return i}testGlobstar(e,t,s,i){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(s&&t.checkFollowGlobstar()?this.subwalks.add(e,s):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),s){let r=s.pattern();if(typeof r=="string"&&r!==".."&&r!==""&&r!==".")this.testString(e,r,s.rest(),i);else if(r===".."){let o=e.parent||e;this.subwalks.add(o,s)}else r instanceof RegExp&&this.testRegExp(e,r,s.rest(),i)}}testRegExp(e,t,s,i){t.test(e.name)&&(s?this.subwalks.add(e,s):this.matches.add(e,i,!1))}testString(e,t,s,i){e.isNamed(t)&&(s?this.subwalks.add(e,s):this.matches.add(e,i,!1))}};var Mc=(n,e)=>typeof n=="string"?new tt([n],e):Array.isArray(n)?new tt(n,e):n,ms=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#i;#n;signal;maxDepth;includeChildMatches;constructor(e,t,s){if(this.patterns=e,this.path=t,this.opts=s,this.#n=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#i=Mc(s.ignore??[],s),!this.includeChildMatches&&typeof this.#i.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#t(e){return this.seen.has(e)||!!this.#i?.ignored?.(e)}#o(e){return!!this.#i?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=await r.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(r,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#t(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=r.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(r,t)}matchFinish(e,t){if(this.#t(e))return;if(!this.includeChildMatches&&this.#i?.add){let r=`${e.relativePosix()}/**`;this.#i.add(r)}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let r=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(r+i)}else{let r=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(r?o+r+i:"."+i)}}async match(e,t,s){let i=await this.matchCheck(e,s);i&&this.matchFinish(i,t)}matchSync(e,t,s){let i=this.matchCheckSync(e,s);i&&this.matchFinish(i,t)}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new Ft(this.opts),s)}walkCB2(e,t,s,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,i));return}s.processPatterns(e,t);let r=1,o=()=>{--r===0&&i()};for(let[a,l,c]of s.matches.entries())this.#t(a)||(r++,this.match(a,l,c).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,s,o):a.readdirCB((c,u)=>this.walkCB3(a,u,s,o),!0)}o()}walkCB3(e,t,s,i){s=s.filterEntries(e,t);let r=1,o=()=>{--r===0&&i()};for(let[a,l,c]of s.matches.entries())this.#t(a)||(r++,this.match(a,l,c).then(()=>o()));for(let[a,l]of s.subwalks.entries())r++,this.walkCB2(a,l,s.child(),o);o()}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new Ft(this.opts),s)}walkCB2Sync(e,t,s,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,i));return}s.processPatterns(e,t);let r=1,o=()=>{--r===0&&i()};for(let[a,l,c]of s.matches.entries())this.#t(a)||this.matchSync(a,l,c);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let l=a.readdirSync();this.walkCB3Sync(a,l,s,o)}o()}walkCB3Sync(e,t,s,i){s=s.filterEntries(e,t);let r=1,o=()=>{--r===0&&i()};for(let[a,l,c]of s.matches.entries())this.#t(a)||this.matchSync(a,l,c);for(let[a,l]of s.subwalks.entries())r++,this.walkCB2Sync(a,l,s.child(),o);o()}},jt=class extends ms{matches=new Set;constructor(e,t,s){super(e,t,s)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Rt=class extends ms{results;constructor(e,t,s){super(e,t,s),this.results=new Ce({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var Nc=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",re=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,Zr.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(l=>l.includes("/")?l:`./**/${l}`)}if(this.pattern=e,this.platform=t.platform||Nc,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let l=t.platform==="win32"?Ze:t.platform==="darwin"?At:t.platform?Qe:Xr;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(l=>new J(l,i)),[o,a]=r.reduce((l,c)=>(l[0].push(...c.set),l[1].push(...c.globParts),l),[[],[]]);this.patterns=o.map((l,c)=>{let u=a[c];if(!u)throw new Error("invalid pattern object");return new et(l,u,0,this.platform)})}async walk(){return[...await new jt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new jt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Rt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Rt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var ji=(n,e={})=>{Array.isArray(n)||(n=[n]);for(let t of n)if(new J(t,e).hasMagic())return!0;return!1};function ys(n,e={}){return new re(n,e).streamSync()}function eo(n,e={}){return new re(n,e).stream()}function to(n,e={}){return new re(n,e).walkSync()}async function Qr(n,e={}){return new re(n,e).walk()}function bs(n,e={}){return new re(n,e).iterateSync()}function so(n,e={}){return new re(n,e).iterate()}var Ic=ys,Lc=Object.assign(eo,{sync:ys}),Dc=bs,Wc=Object.assign(so,{sync:bs}),Vc=Object.assign(to,{stream:ys,iterate:bs}),st=Object.assign(Qr,{glob:Qr,globSync:to,sync:Vc,globStream:eo,stream:Lc,globStreamSync:ys,streamSync:Ic,globIterate:so,iterate:Wc,globIterateSync:bs,iterateSync:Dc,Glob:re,hasMagic:ji,escape:Je,unescape:se});st.glob=st;var Hc=[{id:"ai.delve",category:"ai-slop",severity:"red",regex:/\bdelve\b/gi,suggestion:"use a specific verb: dig, explore, look at"},{id:"ai.leverage",category:"ai-slop",severity:"red",regex:/\bleverage\b/gi,suggestion:"use: use, apply, build on"},{id:"ai.tapestry",category:"ai-slop",severity:"red",regex:/\btapestry\b/gi,suggestion:"be specific about what you mean"},{id:"ai.holistic",category:"ai-slop",severity:"red",regex:/\bholistic\b/gi,suggestion:"describe the actual approach"},{id:"ai.robust",category:"ai-slop",severity:"yellow",regex:/\brobust\b/gi,suggestion:"say what actually makes it strong"},{id:"ai.pivotal",category:"ai-slop",severity:"yellow",regex:/\bpivotal\b/gi,suggestion:"say why it matters specifically"},{id:"ai.foster",category:"ai-slop",severity:"yellow",regex:/\bfoster\b/gi,suggestion:"use: build, grow, encourage, support"},{id:"ai.harness",category:"ai-slop",severity:"yellow",regex:/\bharness\b/gi,suggestion:"use: use, apply, work with"},{id:"ai.illuminate",category:"ai-slop",severity:"yellow",regex:/\billuminate\b/gi,suggestion:"use: show, explain, highlight"},{id:"ai.ever-evolving",category:"ai-slop",severity:"red",regex:/\b(?:ever[\s-]evolving|ever[\s-]changing)\b/gi,suggestion:"cut this \u2014 it says nothing"},{id:"ai.fast-paced",category:"ai-slop",severity:"red",regex:/\bfast[\s-]paced\b/gi,suggestion:"cut this \u2014 every industry says this"},{id:"ai.game-changer",category:"ai-slop",severity:"red",regex:/\bgame[\s-]changer\b/gi,suggestion:"explain what actually changed"},{id:"ai.paradigm",category:"ai-slop",severity:"red",regex:/\bparadigm\b/gi,suggestion:"describe the actual shift"},{id:"ai.synergy",category:"ai-slop",severity:"red",regex:/\bsynergy\b/gi,suggestion:"describe what works together and why"},{id:"ai.ecosystem",category:"ai-slop",severity:"yellow",regex:/\becosystem\b/gi,suggestion:"name the specific tools/partners/platforms"},{id:"ai.seamless",category:"ai-slop",severity:"yellow",regex:/\bseamless\b/gi,suggestion:"describe how it actually works"},{id:"ai.actionable",category:"ai-slop",severity:"yellow",regex:/\bactionable\b/gi,suggestion:"just give the action, don't label it"},{id:"ai.granular",category:"ai-slop",severity:"yellow",regex:/\bgranular\b/gi,suggestion:"say: specific, detailed, or name the level"},{id:"ai.impactful",category:"ai-slop",severity:"yellow",regex:/\bimpactful\b/gi,suggestion:"describe the actual impact"}],qc=[{id:"formula.firstly",category:"ai-slop",severity:"yellow",regex:/\bfirstly\b/gi,suggestion:'just start \u2014 "firstly" is filler'},{id:"formula.in-conclusion",category:"ai-slop",severity:"red",regex:/\bin conclusion\b/gi,suggestion:"just end. readers know it's the end."},{id:"formula.it-is-important",category:"ai-slop",severity:"yellow",regex:/\bit is important to note\b/gi,suggestion:"just note it. skip the preamble."},{id:"formula.at-the-end",category:"ai-slop",severity:"yellow",regex:/\bat the end of the day\b/gi,suggestion:"cut this \u2014 it means nothing"},{id:"formula.needless-to-say",category:"ai-slop",severity:"yellow",regex:/\bneedless to say\b/gi,suggestion:"if it's needless, don't say it"},{id:"formula.it-goes-without",category:"ai-slop",severity:"yellow",regex:/\bit goes without saying\b/gi,suggestion:"then don't say it"},{id:"formula.in-today",category:"ai-slop",severity:"red",regex:/\bin today'?s\b/gi,suggestion:"start with your actual point instead"},{id:"formula.lets-dive",category:"ai-slop",severity:"red",regex:/\blet'?s (?:dive|jump|dig|delve)\b/gi,suggestion:"just start. no diving needed."},{id:"formula.without-further",category:"ai-slop",severity:"red",regex:/\bwithout further ado\b/gi,suggestion:"cut this \u2014 just get to it"}],Bc=[{id:"hedge.some-might",category:"voice-drift",severity:"yellow",regex:/\bsome might say\b/gi,suggestion:"commit to the claim or drop it"},{id:"hedge.arguably",category:"voice-drift",severity:"yellow",regex:/\barguably\b/gi,suggestion:"commit. say it or don't."},{id:"hedge.worth-noting",category:"voice-drift",severity:"yellow",regex:/\bit'?s worth noting\b/gi,suggestion:"just note it directly"},{id:"hedge.to-some-extent",category:"voice-drift",severity:"yellow",regex:/\bto some extent\b/gi,suggestion:"be specific about the extent"}],Uc=[{id:"struct.antithesis",category:"structure",severity:"yellow",regex:/\bnot (?:just|only) .{3,50}, but .{3,50}/gi,suggestion:"this antithesis pattern is an AI tell \u2014 restructure"},{id:"struct.more-than-just",category:"structure",severity:"yellow",regex:/\bmore than just\b/gi,suggestion:"say what it IS, not what it isn't"},{id:"struct.in-order-to",category:"structure",severity:"yellow",regex:/\bin order to\b/gi,suggestion:'just use "to"'},{id:"struct.due-to-the-fact",category:"structure",severity:"yellow",regex:/\bdue to the fact that\b/gi,suggestion:'use "because"'},{id:"struct.for-the-purpose",category:"structure",severity:"yellow",regex:/\bfor the purpose of\b/gi,suggestion:'use "to"'},{id:"struct.which-is-another",category:"structure",severity:"red",regex:/\bwhich is another way of saying\b/gi,suggestion:"just say the thing directly"}],zc=[...Hc,...qc,...Bc,...Uc];function io(n,e,t){let s=[];for(let i of zc){i.regex.lastIndex=0;let r;for(;(r=i.regex.exec(n))!==null;)s.push({file:t,line:e,column:r.index+1,pattern:i.id,category:i.category,severity:i.severity,excerpt:Gc(n.trim(),r.index,r[0].length),suggestion:i.suggestion})}return s}function Gc(n,e,t){let s=n.slice(0,e),i=n.slice(e,e+t),r=n.slice(e+t);return`${s}\xAB${i}\xBB${r}`.slice(0,120)}async function Pt(n,e=[]){let t=[];for(let o of n)if(it.existsSync(o)&&it.statSync(o).isFile())t.push(o);else{let a=await st("**/*.md",{cwd:o,ignore:["node_modules/**",".git/**",...e],absolute:!0});t.push(...a)}let s=[...new Set(t)],i=[],r={files:0,total_lines:0,red:0,yellow:0,clean:0};for(let o of s){if(!o.endsWith(".md"))continue;let a;try{a=it.readFileSync(o,"utf-8")}catch{continue}let l=a.split(`
100
- `),c=[];for(let p=0;p<l.length;p++){let d=l[p];d.startsWith("```")||d.startsWith("---")||d.startsWith("#")||d.trim().length<10||c.push(...io(d,p+1,Ri.relative(process.cwd(),o)))}r.files++,r.total_lines+=l.length;let u=c.filter(p=>p.severity==="red").length,f=c.filter(p=>p.severity==="yellow").length;r.red+=u,r.yellow+=f,u+f===0&&r.clean++,i.push({file:Ri.relative(process.cwd(),o),findings:c,lines:l.length})}return{results:i,summary:r}}je();var C=_(require("fs")),Ne=_(require("path")),ao=_(require("os"));V();var be=Ne.join(ao.homedir(),".hyv","learning"),ye=Ne.join(be,"events.jsonl"),Pi=Ne.join(be,".last-sync"),no=Ne.join(be,".last-cleanup"),zf=5*1024*1024;function ro(n){try{C.existsSync(be)||C.mkdirSync(be,{recursive:!0});let e=JSON.stringify({...n,timestamp:n.timestamp||Date.now()})+`
101
- `;C.appendFileSync(ye,e,"utf-8")}catch{}}function lo(n,e,t,s){if(ro({timestamp:Date.now(),type:s?"accept":"reject",ruleId:"algorithm.overall",original:n.slice(0,500),edited:s?void 0:e.slice(0,500),context:`score:${t}`}),s&&n!==e){let i=Qc(n,e);for(let r of i)ro({timestamp:Date.now(),type:"accept",ruleId:"algorithm.change",original:r.before.slice(0,200),edited:r.after.slice(0,200),context:`line:${r.line}`})}}var ke=Ne.join(be,"ignored-rules.json"),Jc=3;function co(n){if(n.length)try{C.existsSync(be)||C.mkdirSync(be,{recursive:!0});let e={};C.existsSync(ke)&&(e=JSON.parse(C.readFileSync(ke,"utf-8")));let t=Date.now();for(let s of n){let i=s.ruleId||s.pattern||"unknown";e[i]||(e[i]={ruleId:i,count:0,firstSeen:t,lastSeen:t}),e[i].count++,e[i].lastSeen=t}C.writeFileSync(ke,JSON.stringify(e,null,2),"utf-8")}catch{}}function Mt(){try{if(!C.existsSync(ke))return[];let n=JSON.parse(C.readFileSync(ke,"utf-8")),e=[];for(let[t,s]of Object.entries(n))if(s.count>=Jc){let i=t.replace(/\./g," ").replace(/-/g," ");e.push({ruleId:t,count:s.count,suggestion:`You've ignored "${i}" flags ${s.count} times. Want us to stop flagging it?`})}return e.sort((t,s)=>s.count-t.count)}catch{return[]}}function ho(n){try{if(!C.existsSync(ke))return;let e=JSON.parse(C.readFileSync(ke,"utf-8"));delete e[n],C.writeFileSync(ke,JSON.stringify(e,null,2),"utf-8")}catch{}}var Tt=Ne.join(be,"consolidated.md"),Yc=7;function Kc(){try{if(C.existsSync(Tt))return C.readFileSync(Tt,"utf-8")}catch{}return""}function oo(n){let e=Kc(),s=`
102
-
103
- ## Consolidated ${new Date().toISOString().split("T")[0]}
104
-
105
- ${n}`;C.writeFileSync(Tt,e+s,"utf-8")}function Xc(){if(!C.existsSync(ye))return{events:[],rawLines:[]};let e=C.readFileSync(ye,"utf-8").trim().split(`
106
- `).filter(o=>o.length>0),t=Date.now()-Yc*24*60*60*1e3,s=[],i=[],r=[];for(let o of e)try{let a=JSON.parse(o);a.timestamp&&a.timestamp<t?(s.push(a),i.push(o)):r.push(o)}catch{r.push(o)}return C.writeFileSync(ye,r.join(`
107
- `)+(r.length?`
108
- `:""),"utf-8"),{events:s,rawLines:i}}function uo(n){let e=new Map;for(let s of n){let i=s.ruleId;e.has(i)||e.set(i,{accepts:0,rejects:0,edits:[]});let r=e.get(i);s.type==="accept"&&r.accepts++,s.type==="reject"&&r.rejects++,s.type==="edit"&&s.edited&&r.edits.push(`${s.original.slice(0,60)} \u2192 ${s.edited.slice(0,60)}`)}let t=[];for(let[s,i]of e)t.push(`- ${s}: ${i.accepts} accepts, ${i.rejects} rejects`),i.edits.length>0&&t.push(` edits: ${i.edits.slice(0,3).join("; ")}`);return t.join(`
109
- `)}async function Zc(n){if(n.length===0)return null;try{let{apiPost:e}=await Promise.resolve().then(()=>(V(),zt)),t=uo(n);return(await e("/api/llm",{model:"free",system:`You extract voice patterns from a user's editing behavior.
110
- Return a concise bullet list of their preferences. No commentary. Max 10 bullets.`,prompt:`User learning signals over the past month:
111
-
112
- ${t}
113
-
114
- Extract their voice preferences as bullet points.`,maxTokens:200,action:"free"}))?.text||null}catch{return null}}async function fo(){let{events:n}=Xc();if(n.length===0)return C.writeFileSync(no,new Date().toISOString(),"utf-8"),{consolidated:0,kept:0};let e=await Zc(n);if(e)oo(e);else{let t=uo(n);oo(`Raw summary (${n.length} events):
115
- ${t}`)}return C.writeFileSync(no,new Date().toISOString(),"utf-8"),{consolidated:n.length,kept:0}}function po(){try{if(C.existsSync(Tt))return C.readFileSync(Tt,"utf-8")}catch{}return""}async function go(){if(!C.existsSync(ye))return{synced:0,errors:0};try{let e=C.readFileSync(ye,"utf-8").trim().split(`
116
- `).filter(o=>o.length>0);if(e.length===0)return{synced:0,errors:0};let t=[];for(let o of e)try{t.push(JSON.parse(o))}catch{}if(t.length===0)return{synced:0,errors:0};let s=0,i=0,r=20;for(let o=0;o<t.length;o+=r){let a=t.slice(o,o+r);try{await T("/cli/learning/batch",{events:a}),s+=a.length}catch{i+=a.length}}return i===0&&(C.writeFileSync(ye,"","utf-8"),C.writeFileSync(Pi,new Date().toISOString(),"utf-8")),{synced:s,errors:i}}catch{return{synced:0,errors:1}}}function mo(){let n={total:0,byType:{},lastSync:void 0};if(C.existsSync(ye)){let t=C.readFileSync(ye,"utf-8").trim().split(`
117
- `).filter(s=>s.length>0);n.total=t.length;for(let s of t)try{let i=JSON.parse(s);n.byType[i.type]=(n.byType[i.type]||0)+1}catch{}}return C.existsSync(Pi)&&(n.lastSync=C.readFileSync(Pi,"utf-8").trim()),n}function Qc(n,e){let t=n.split(`
118
- `),s=e.split(`
119
- `),i=[],r=Math.max(t.length,s.length);for(let o=0;o<r;o++){let a=t[o]||"",l=s[o]||"";a!==l&&i.push({line:o+1,before:a,after:l})}return i}V();async function yo(n,e){try{await ht()}catch(u){e.json?console.log(JSON.stringify({error:u.message})):console.log(`
120
- ${h.red("\u2717")} ${u.message}
121
- `),process.exit(1);return}let t=Ut(),s=n.length?n:t.scan_paths||["."],i=t.ignore||[],{results:r,summary:o}=await Pt(s,i),a=r.flatMap(u=>u.findings.map(f=>({ruleId:f.pattern})));if(a.length>0&&co(a),e.json){console.log(JSON.stringify({results:r.filter(u=>u.findings.length>0),summary:o},null,2)),e.failOnHit&&o.red+o.yellow>0&&process.exit(1);return}console.log(`
122
- ${E()} ${h.dim("scan")}
123
- `);let l=0;for(let u of r)if(u.findings.length!==0){console.log(` ${h.bold(u.file)} ${h.dim(`(${u.lines} lines)`)}`);for(let f of u.findings)ir(f),l++;console.log("")}nr(o);let c=Mt();if(c.length>0){console.log(` ${h.yellow("\u{1F4A1} suggestions:")}`);for(let u of c.slice(0,3))console.log(` ${h.dim("\u2192")} ${u.suggestion}`);console.log("")}if(e.failOnHit&&o.red+o.yellow>0&&process.exit(1),o.red+o.yellow>0)try{(await k("/cli/profiles")).profiles?.length||console.log(` ${h.yellow("tip:")} create a voice profile for personalized results \u2014 run: ${h.cyan("hyv onboard")}
124
- `)}catch{}}var te=_(require("fs"));var eh=[{id:"ai.delve",category:"ai-slop",severity:"red",regex:/\bdelve\b/gi,suggestion:"use a specific verb: dig, explore, look at",autoFixable:!0},{id:"ai.leverage",category:"ai-slop",severity:"red",regex:/\bleverage\b/gi,suggestion:"use: use, apply, build on",autoFixable:!0},{id:"ai.tapestry",category:"ai-slop",severity:"red",regex:/\btapestry\b/gi,suggestion:"be specific about what you mean",autoFixable:!0},{id:"ai.holistic",category:"ai-slop",severity:"red",regex:/\bholistic\b/gi,suggestion:"describe the actual approach",autoFixable:!0},{id:"ai.robust",category:"ai-slop",severity:"yellow",regex:/\brobust\b/gi,suggestion:"say what actually makes it strong",autoFixable:!0},{id:"ai.pivotal",category:"ai-slop",severity:"yellow",regex:/\bpivotal\b/gi,suggestion:"say why it matters specifically",autoFixable:!0},{id:"ai.foster",category:"ai-slop",severity:"yellow",regex:/\bfoster\b/gi,suggestion:"use: build, grow, encourage, support",autoFixable:!0},{id:"ai.harness",category:"ai-slop",severity:"yellow",regex:/\bharness\b/gi,suggestion:"use: use, apply, work with",autoFixable:!0},{id:"ai.illuminate",category:"ai-slop",severity:"yellow",regex:/\billuminate\b/gi,suggestion:"use: show, explain, highlight",autoFixable:!0},{id:"ai.ever-evolving",category:"ai-slop",severity:"red",regex:/\b(?:ever[\s-]evolving|ever[\s-]changing)\b/gi,suggestion:"cut this \u2014 it says nothing",autoFixable:!0},{id:"ai.fast-paced",category:"ai-slop",severity:"red",regex:/\bfast[\s-]paced\b/gi,suggestion:"cut this \u2014 every industry says this",autoFixable:!0},{id:"ai.game-changer",category:"ai-slop",severity:"red",regex:/\bgame[\s-]changer\b/gi,suggestion:"explain what actually changed",autoFixable:!0},{id:"ai.paradigm",category:"ai-slop",severity:"red",regex:/\bparadigm\b/gi,suggestion:"describe the actual shift",autoFixable:!0},{id:"ai.synergy",category:"ai-slop",severity:"red",regex:/\bsynergy\b/gi,suggestion:"describe what works together and why",autoFixable:!0},{id:"ai.ecosystem",category:"ai-slop",severity:"yellow",regex:/\becosystem\b/gi,suggestion:"name the specific tools/partners/platforms",autoFixable:!0},{id:"ai.seamless",category:"ai-slop",severity:"yellow",regex:/\bseamless\b/gi,suggestion:"describe how it actually works",autoFixable:!0},{id:"ai.actionable",category:"ai-slop",severity:"yellow",regex:/\bactionable\b/gi,suggestion:"just give the action, don't label it",autoFixable:!0},{id:"ai.granular",category:"ai-slop",severity:"yellow",regex:/\bgranular\b/gi,suggestion:"say: specific, detailed, or name the level",autoFixable:!0},{id:"ai.impactful",category:"ai-slop",severity:"yellow",regex:/\bimpactful\b/gi,suggestion:"describe the actual impact",autoFixable:!0},{id:"ai.transform",category:"ai-slop",severity:"yellow",regex:/\btransform\b/gi,suggestion:"describe what specifically changed",autoFixable:!1},{id:"ai.empower",category:"ai-slop",severity:"yellow",regex:/\bempower\b/gi,suggestion:"describe what people can actually do",autoFixable:!0},{id:"ai.unlock",category:"ai-slop",severity:"yellow",regex:/\bunlock\b/gi,suggestion:"describe what they get access to",autoFixable:!0},{id:"ai.nuanced",category:"ai-slop",severity:"yellow",regex:/\bnuanced\b/gi,suggestion:"explain the specific complexity",autoFixable:!0},{id:"ai.multifaceted",category:"ai-slop",severity:"red",regex:/\bmultifaceted\b/gi,suggestion:"name the specific aspects",autoFixable:!0},{id:"ai.comprehensive",category:"ai-slop",severity:"yellow",regex:/\bcomprehensive\b/gi,suggestion:"say what it covers specifically",autoFixable:!1},{id:"ai.innovative",category:"ai-slop",severity:"yellow",regex:/\binnovative\b/gi,suggestion:"describe what's actually new",autoFixable:!0},{id:"ai.cut[t]?ing-edge",category:"ai-slop",severity:"red",regex:/\bcut(?:t)?ing[\s-]edge\b/gi,suggestion:"name the specific technology",autoFixable:!0},{id:"ai.state-of-the-art",category:"ai-slop",severity:"red",regex:/\bstate[\s-]of[\s-]the[\s-]art\b/gi,suggestion:"describe what makes it current",autoFixable:!0},{id:"ai.best-practices",category:"ai-slop",severity:"yellow",regex:/\bbest[\s-]practices?\b/gi,suggestion:"name the specific practice",autoFixable:!1},{id:"ai.world-class",category:"ai-slop",severity:"red",regex:/\bworld[\s-]class\b/gi,suggestion:"prove it with specifics",autoFixable:!0},{id:"ai.second-to-none",category:"ai-slop",severity:"red",regex:/\bsecond[\s-]to[\s-]none\b/gi,suggestion:"drop the superlative, show the work",autoFixable:!0}],th=[{id:"formula.firstly",category:"ai-slop",severity:"yellow",regex:/\bfirstly\b/gi,suggestion:'just start \u2014 "firstly" is filler',autoFixable:!0},{id:"formula.secondly",category:"ai-slop",severity:"yellow",regex:/\bsecondly\b/gi,suggestion:'just continue \u2014 "secondly" is filler',autoFixable:!0},{id:"formula.lastly",category:"ai-slop",severity:"yellow",regex:/\blastly\b/gi,suggestion:'just end \u2014 "lastly" is filler',autoFixable:!0},{id:"formula.moreover",category:"ai-slop",severity:"yellow",regex:/\bmoreover\b/gi,suggestion:"just add the point",autoFixable:!0},{id:"formula.furthermore",category:"ai-slop",severity:"yellow",regex:/\bfurthermore\b/gi,suggestion:"just add the point",autoFixable:!0},{id:"formula.in-conclusion",category:"ai-slop",severity:"red",regex:/\bin conclusion\b/gi,suggestion:"just end. readers know it's the end.",autoFixable:!0},{id:"formula.in-summary",category:"ai-slop",severity:"red",regex:/\bin summary\b/gi,suggestion:"just summarize. the label is redundant.",autoFixable:!0},{id:"formula.it-is-important",category:"ai-slop",severity:"yellow",regex:/\bit is important to note\b/gi,suggestion:"just note it. skip the preamble.",autoFixable:!0},{id:"formula.at-the-end",category:"ai-slop",severity:"yellow",regex:/\bat the end of the day\b/gi,suggestion:"cut this \u2014 it means nothing",autoFixable:!0},{id:"formula.needless-to-say",category:"ai-slop",severity:"yellow",regex:/\bneedless to say\b/gi,suggestion:"if it's needless, don't say it",autoFixable:!0},{id:"formula.it-goes-without",category:"ai-slop",severity:"yellow",regex:/\bit goes without saying\b/gi,suggestion:"then don't say it",autoFixable:!0},{id:"formula.in-today",category:"ai-slop",severity:"red",regex:/\bin today'?s\b/gi,suggestion:"start with your actual point instead",autoFixable:!0},{id:"formula.lets-dive",category:"ai-slop",severity:"red",regex:/\blet'?s (?:dive|jump|dig|delve)\b/gi,suggestion:"just start. no diving needed.",autoFixable:!0},{id:"formula.without-further",category:"ai-slop",severity:"red",regex:/\bwithout further ado\b/gi,suggestion:"cut this \u2014 just get to it",autoFixable:!0},{id:"formula.its-worth-noting",category:"ai-slop",severity:"yellow",regex:/\bit'?s worth noting\b/gi,suggestion:"just note it directly",autoFixable:!0}],sh=[{id:"hedge.some-might",category:"voice-drift",severity:"yellow",regex:/\bsome might say\b/gi,suggestion:"commit to the claim or drop it",autoFixable:!0},{id:"hedge.arguably",category:"voice-drift",severity:"yellow",regex:/\barguably\b/gi,suggestion:"commit. say it or don't.",autoFixable:!0},{id:"hedge.worth-noting",category:"voice-drift",severity:"yellow",regex:/\bit'?s worth noting\b/gi,suggestion:"just note it directly",autoFixable:!0},{id:"hedge.to-some-extent",category:"voice-drift",severity:"yellow",regex:/\bto some extent\b/gi,suggestion:"be specific about the extent",autoFixable:!0},{id:"hedge.perhaps",category:"voice-drift",severity:"yellow",regex:/\bperhaps\b/gi,suggestion:"commit or cut",autoFixable:!0},{id:"hedge.maybe",category:"voice-drift",severity:"yellow",regex:/\bmaybe\b/gi,suggestion:"commit or cut",autoFixable:!0},{id:"hedge.possibly",category:"voice-drift",severity:"yellow",regex:/\bpossibly\b/gi,suggestion:"commit or cut",autoFixable:!1},{id:"hedge.it-seems",category:"voice-drift",severity:"yellow",regex:/\bit seems\b/gi,suggestion:"state it directly",autoFixable:!0},{id:"hedge.i-think",category:"voice-drift",severity:"yellow",regex:/\bi think\b/gi,suggestion:'just say it. the "i think" is implied.',autoFixable:!0},{id:"hedge.in-my-opinion",category:"voice-drift",severity:"yellow",regex:/\bin my opinion\b/gi,suggestion:"just state it. it's your article.",autoFixable:!0}],ih=[{id:"struct.antithesis",category:"structure",severity:"yellow",regex:/\bnot (?:just|only) .{3,50}, but .{3,50}/gi,suggestion:"this antithesis pattern is an AI tell \u2014 restructure",autoFixable:!1},{id:"struct.not-just-but-also",category:"structure",severity:"yellow",regex:/\bnot\s+just\b.{3,80}\bbut\s+(?:also\s+)?/gi,suggestion:"say what it IS, not what it isn't",autoFixable:!1},{id:"struct.more-than-just",category:"structure",severity:"yellow",regex:/\bmore\s+than\s+just\b/gi,suggestion:"say what it IS, not what it isn't",autoFixable:!1},{id:"struct.in-order-to",category:"structure",severity:"yellow",regex:/\bin order to\b/gi,suggestion:'just use "to"',autoFixable:!0},{id:"struct.due-to-the-fact",category:"structure",severity:"yellow",regex:/\bdue to the fact that\b/gi,suggestion:'use "because"',autoFixable:!0},{id:"struct.for-the-purpose",category:"structure",severity:"yellow",regex:/\bfor the purpose of\b/gi,suggestion:'use "to"',autoFixable:!0},{id:"struct.which-is-another",category:"structure",severity:"red",regex:/\bwhich is another way of saying\b/gi,suggestion:"just say the thing directly",autoFixable:!1},{id:"struct.in-other-words",category:"structure",severity:"red",regex:/\bin other words\b/gi,suggestion:"just say it once, well",autoFixable:!1},{id:"struct.rhetorical-truth",category:"structure",severity:"yellow",regex:/\b(?:the\s+)?(?:uncomfortable|hard|harsh|brutal|ugly|unsexy|real|honest)\s+(?:truth|reality)\b/gi,suggestion:"state the fact directly, skip the framing",autoFixable:!1},{id:"struct.truth-is",category:"structure",severity:"yellow",regex:/\bthe\s+truth\s+is\b/gi,suggestion:"just say the truth. the framing is filler.",autoFixable:!1},{id:"struct.lesson-setup",category:"structure",severity:"yellow",regex:/\b(?:here'?s\s+)?what\s+.{3,80}\s+(?:taught|teaches)\s+(?:me|us|you|everyone)\b/gi,suggestion:"just share the lesson",autoFixable:!1},{id:"struct.negation-cascade",category:"structure",severity:"yellow",regex:/\b(?:no|not)\s+\w[^.!?\n]{0,80}[.!?][ \t]*\n?[ \t]*(?:no|not)\s+\w[^.!?\n]{0,80}[.!?][ \t]*\n?[ \t]*(?:no|not)\s+\w/gi,suggestion:"three negations in a row reads like AI performance",autoFixable:!1},{id:"struct.inline-triplet",category:"structure",severity:"yellow",regex:/\bit'?s\s+\w[^,.!?;\n]{0,30},\s*it'?s\s+\w[^,.!?;\n]{0,30}[,.]?\s*(?:and\s+)?it'?s\b/gi,suggestion:`the "it's X, it's Y, it's Z" pattern is an AI tell`,autoFixable:!1},{id:"struct.moment-becomes",category:"structure",severity:"red",regex:/\b(?:the\s+)?moment\b.{3,80}\bbecomes?\b/gi,suggestion:'"the moment X becomes Y" is polished founder cadence \u2014 restructure',autoFixable:!1},{id:"struct.same-better",category:"structure",severity:"red",regex:/\bsame\s+[^.!?\n]{1,35}[.!?]\s*(?:better|nicer|cleaner|calmer|safer)\s+[^.!?\n]{1,35}[.!?]?/gi,suggestion:'"same X. better Y." is screenshot-ready founder cadence',autoFixable:!1},{id:"struct.this-is-why",category:"structure",severity:"yellow",regex:/\bthis\s+is\s+(?:also\s+)?(?:why|how|where|what\b)/gi,suggestion:"signpost claims are AI tells \u2014 just make the point",autoFixable:!1},{id:"struct.heres-where",category:"structure",severity:"yellow",regex:/\b(?:here'?s|here\s+is)\s+(?:where|why|what|the\s+part|the\s+(?:harder|real|actual|main|bigger)\s+problem)\b/gi,suggestion:"just make the point without the signpost",autoFixable:!1},{id:"struct.generic-buyer",category:"structure",severity:"red",regex:/\bpeople\s+don'?t\s+just\s+buy\b|\bpeople\s+buy\s+the\s+feeling\b/gi,suggestion:"generic buyer psychology is AI filler",autoFixable:!1}],nh=[{id:"punct.em-dash",category:"ai-slop",severity:"yellow",regex:/—/g,suggestion:"em dashes are an AI tell \u2014 use a period, comma, or parentheses",autoFixable:!1}],rh=[...eh,...th,...sh,...ih,...nh],bo={delve:"dig",leverage:"use",tapestry:"web",holistic:"complete",robust:"strong",pivotal:"key",foster:"build",harness:"use",illuminate:"show","ever-evolving":"changing",everchanging:"changing","fast-paced":"fast","game-changer":"breakthrough",paradigm:"model",synergy:"fit",ecosystem:"network",seamless:"smooth",actionable:"practical",granular:"specific",impactful:"effective",empower:"enable",unlock:"open",nuanced:"complex",multifaceted:"complex",innovative:"new","cutting-edge":"modern","state-of-the-art":"modern","world-class":"excellent","second-to-none":"best",firstly:"",secondly:"",lastly:"",moreover:"",furthermore:"",perhaps:"",arguably:""};function oh(n){let t=n.split(/[.!?]+/).filter(o=>o.trim().length>0).map(o=>o.trim().split(/\s+/).length),s=t.length>0?t.reduce((o,a)=>o+a,0)/t.length:0,i=t.length>1?Math.sqrt(t.reduce((o,a)=>o+Math.pow(a-s,2),0)/t.length):0,r="low";return i>8?r="high":i>4&&(r="medium"),{avgWords:s,variance:r,sentences:t}}function ah(n){let e=[],t=n.split(`
125
- `),s=t.findIndex(r=>r.trim().length>10);if(s<0)return e;let i=t[s].trim().toLowerCase();return(i.endsWith("?")||/^(?:have you|do you|did you|what if|why do|how do|what's|how's)\b/.test(i))&&e.push({id:"voice.question-opener",line:s+1,column:1,category:"voice-drift",severity:"yellow",rule:"Opens with a question instead of a concrete observation",match:i.slice(0,80),excerpt:t[s].trim().slice(0,120),suggestion:"Open with a concrete observation, moment, mechanism, or pattern",autoFixable:!1}),/^(?:the most important thing|the key to|success is|if you want to|what i learned|here's what|the biggest mistake)\b/.test(i)&&e.push({id:"voice.lesson-opener",line:s+1,column:1,category:"voice-drift",severity:"yellow",rule:"Opens with a lesson or inspirational claim",match:i.slice(0,80),excerpt:t[s].trim().slice(0,120),suggestion:"Open with something concrete and specific, not a lesson",autoFixable:!1}),/^(?:most|many)\s+(?:brands|teams|people|founders|companies|businesses)\b/.test(i)&&e.push({id:"voice.generic-generalization",line:s+1,column:1,category:"voice-drift",severity:"yellow",rule:"Opens with a generic generalization",match:i.slice(0,80),excerpt:t[s].trim().slice(0,120),suggestion:"Start with a specific observation, not a sweeping claim",autoFixable:!1}),e}function lh(n){let e=[],t=n.split(`
126
- `),s=[];for(let i=0;i<t.length;i++){let r=t[i].trim();if(r.length<10||r.startsWith("#")||r.startsWith("```"))continue;let o=r.split(/(?<=[.!?])\s+/);for(let a of o){let l=a.trim().split(/\s+/).filter(c=>c.length>0);l.length>0&&l.length<=5?(s.push({line:i+1,text:a.trim()}),s.length>=3&&(e.push({id:"voice.staccato-triplet",line:s[0].line,column:1,category:"cadence",severity:"yellow",rule:"Three short sentences in a row reads like performance",match:s.map(c=>c.text).join(" | "),excerpt:s[0].text,suggestion:"Vary sentence length \u2014 short staccato runs feel like AI trying to sound punchy",autoFixable:!1}),s=[])):s=[]}}return e}var ch=new Set(["alignment","authenticity","awareness","clarity","confidence","consistency","differentiation","execution","framework","identity","messaging","narrative","personality","positioning","preference","presence","recall","relevance","resonance","signal","strategy","trust","utility","value"]);function hh(n,e){let t=[];return(n.toLowerCase().match(/[a-z']+/g)||[]).filter(r=>ch.has(r)).length>=3&&!/\b(?:for example|for instance|such as)\b|\d/i.test(n)&&t.push({id:"voice.abstract-cluster",line:e,column:1,category:"voice-drift",severity:"yellow",rule:"Abstract noun cluster \u2014 reads like a strategy deck",match:n.trim().slice(0,80),excerpt:n.trim().slice(0,120),suggestion:"Ground in specifics \u2014 name the thing, show the number, quote the person",autoFixable:!1}),t}function uh(n,e,t){let s=[],i=n.toLowerCase();for(let r of t){if(!r)continue;let o=r.toLowerCase().trim();i.includes(o)&&s.push({id:"voice.never-list",line:e,column:i.indexOf(o)+1,category:"voice-drift",severity:"red",rule:`Never-list violation: "${r}"`,match:o,excerpt:n.trim().slice(0,120),suggestion:`Your voice profile explicitly bans "${r}" \u2014 restructure`,autoFixable:!1})}return s}function fh(n,e,t){let s=[],i=n.toLowerCase();for(let r of t){if(!r.text)continue;let a=r.text.toLowerCase().trim().split(/\s+/);if(a.length<3)continue;let l=a.slice(0,4).join(" ");i.includes(l)&&s.push({id:`learned.${r.type}`,line:e,column:i.indexOf(l)+1,category:"learned",severity:"yellow",rule:`Learned pattern (${r.type}): "${r.text.slice(0,60)}"`,match:l,excerpt:n.trim().slice(0,120),suggestion:"Your editing history suggests this pattern should be rewritten",autoFixable:!1})}return s}function dh(n){let e=new Set;for(let t of n)t.status==="accepted"&&t.rule_id&&e.add(t.rule_id),t.status==="dismissed"&&t.accept_rate!==void 0&&t.accept_rate<.25&&e.add(t.rule_id);return e}function Ie(n,e){let t=n.split(`
127
- `),s=[],i=new Map,r=new Map,o=e?.drift_snapshot?dh(e.drift_snapshot):new Set,a=e?.never_list||[],l=e?.learned_patterns||[];for(let d=0;d<t.length;d++){let m=t[d],g=d+1;if(!m.startsWith("```")&&!m.startsWith("---")&&!m.startsWith("#")&&!(m.trim().length<10)){for(let b of rh){b.regex.lastIndex=0;let y;for(;(y=b.regex.exec(m))!==null;){let v=o.has(b.id);s.push({id:b.id,line:g,column:y.index+1,category:b.category,severity:v?"yellow":b.severity,rule:b.suggestion,match:y[0],excerpt:ph(m.trim(),y.index,y[0].length),suggestion:b.suggestion,autoFixable:b.autoFixable,driftAccepted:v})}}s.push(...hh(m,g)),s.push(...uh(m,g,a)),s.push(...fh(m,g,l))}}s.push(...ah(n)),s.push(...lh(n));for(let d of s)i.has(d.line)||i.set(d.line,[]),i.get(d.line).push(d),r.has(d.id)||r.set(d.id,[]),r.get(d.id).push(d);let c=s.filter(d=>d.severity==="red").length,u=s.filter(d=>d.severity==="yellow").length,f=s.filter(d=>d.autoFixable).length,p=s.filter(d=>d.driftAccepted).length;return{signals:s,byLine:i,byRule:r,summary:{red:c,yellow:u,autoFixable:f,driftAccepted:p,total:s.length}}}function wo(n,e){let{avgWords:t,variance:s}=oh(n);if(!e?.avg_words)return 100;let i=e.avg_words,r=Math.abs(t-i)/i,o=Math.max(0,Math.round((1-r)*100));return e.variance&&s===e.variance?o=Math.min(100,o+10):e.variance&&s!==e.variance&&(o=Math.max(0,o-10)),o}function ph(n,e,t){let s=n.slice(0,e),i=n.slice(e,e+t),r=n.slice(e+t);return`${s}\xAB${i}\xBB${r}`.slice(0,120)}function ws(n){let e=n.byLine,t=[];for(let[c,u]of e){let f=u.filter(b=>!b.driftAccepted);if(f.length===0){t.push({line:c,signals:u,strategy:"skip",priority:0,instruction:"All issues on this line are consistently dismissed by user"});continue}let p=f.map(b=>gh(b)),d=mh(p),m=bh(c,f,d),g=d==="auto_fix"?wh(c,f):void 0;t.push({line:c,signals:f,strategy:d,priority:yh(f,d),instruction:m,autoFixText:g})}let s=t.filter(c=>c.strategy==="auto_fix"),i=t.filter(c=>c.strategy==="restructure"||c.strategy==="voice_drift"),r=t.filter(c=>c.strategy==="skip"),o=Math.max(1,n.summary.total>0?new Set(n.signals.map(c=>c.line)).size:0),a=t.filter(c=>c.strategy!=="skip").length,l=Math.max(0,Math.round((o-a)/Math.max(1,o)*100));return{issues:t,autoFixes:s,llmFixes:i,skipped:r,stats:{total:t.length,autoFixable:s.length,needsLLM:i.length,skipped:r.length,score:l}}}function gh(n){return n.driftAccepted?"skip":n.autoFixable&&n.category==="ai-slop"||n.autoFixable&&n.category==="voice-drift"?"auto_fix":n.category==="voice-drift"||n.category==="cadence"||n.category==="learned"?"voice_drift":(n.category==="structure","restructure")}function mh(n){return n.includes("restructure")?"restructure":n.includes("voice_drift")?"voice_drift":n.includes("auto_fix")?"auto_fix":"skip"}function yh(n,e){let t=0,s=n.filter(r=>r.severity==="red").length,i=n.filter(r=>r.severity==="yellow").length;return t+=s*10+i*5,e==="restructure"&&(t+=20),e==="voice_drift"&&(t+=15),e==="auto_fix"&&(t+=5),t}function bh(n,e,t){let s=[...new Set(e.map(r=>r.rule))],i=e.filter(r=>r.severity==="red");if(t==="auto_fix")return`Replace AI-slop words: ${s.join("; ")}`;if(t==="restructure"){let r=e.map(o=>o.match).filter(Boolean).slice(0,3);return`Restructure line ${n}: ${s[0]||"structural issue"}. Patterns: ${r.join(", ")}`}return t==="voice_drift"?`Rewrite line ${n} to match voice profile: ${s[0]||"voice drift"}`:`Review line ${n}`}function wh(n,e){return e.filter(s=>s.autoFixable).map(s=>s.id).join(",")}function vs(n,e){let t=n.split(`
128
- `),s=[];for(let i of e){if(i.strategy!=="auto_fix")continue;let r=i.line-1;if(r<0||r>=t.length)continue;let o=t[r],a=o;for(let l of i.signals){if(!l.autoFixable)continue;let c=bo[l.match.toLowerCase()];if(c!==void 0){let u=new RegExp(vh(l.match),"gi");a=a.replace(u,f=>c===""?"":f[0]===f[0].toUpperCase()?c.charAt(0).toUpperCase()+c.slice(1):c)}}a=a.replace(/\s{2,}/g," ").trim(),a!==o&&(s.push({line:i.line,before:o,after:a,rule:i.signals.map(l=>l.id).join(", ")}),t[r]=a)}return{original:n,fixed:t.join(`
129
- `),changes:s,changed:s.length>0}}function vh(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}V();je();var oe=_(require("fs")),Mi=_(require("path")),So=_(require("os")),vo=5*60*1e3,xs=new Map;async function nt(n,e={}){let t=e.includeSamples!==!1,s=e.forceRefresh||!1;if(!s){let r=xs.get(n);if(r&&Date.now()-r.timestamp<vo)return r.data}let i=_o(n);return i&&!s?Date.now()-i.timestamp<vo?(xs.set(n,i),i.data):(xs.set(n,i),xh(n).catch(()=>{}),i.data):xo(n)}async function xo(n){try{let e=await k(`/cli/profiles/${encodeURIComponent(n)}/full`),t={id:e.profile.id,name:e.profile.name,slug:e.profile.slug,brand:e.profile.brand,keywords:e.profile.keywords,description:e.profile.description,body:e.body,drift_snapshot:e.drift_snapshot||[],learned_patterns:e.learned_patterns||[],voice_samples:e.voice_samples||[],voice_rules:e.voice_rules||[],never_list:e.never_list||[],cadence:e.cadence||{}},s={data:t,timestamp:Date.now(),version:1};return xs.set(n,s),Sh(n,s),t}catch{let t=_o(n);if(t)return t.data;let s=Sn(n);if(s)return $h(n,s);throw new Error(`Profile not found: ${n}. Run: hyv init`)}}async function xh(n){try{await xo(n)}catch{}}var Ti=Mi.join(So.homedir(),".hyv","cache","profiles");function $o(n){return Mi.join(Ti,`${n.replace(/[^a-z0-9-]/gi,"_")}.json`)}function _o(n){try{let e=$o(n);if(!oe.existsSync(e))return null;let t=oe.readFileSync(e,"utf-8"),s=JSON.parse(t);return!s.data||!s.timestamp?null:s}catch{return null}}function Sh(n,e){try{oe.existsSync(Ti)||oe.mkdirSync(Ti,{recursive:!0}),oe.writeFileSync($o(n),JSON.stringify(e),"utf-8")}catch{}}function $h(n,e){return{id:"",name:n,slug:n,body:e,drift_snapshot:[],learned_patterns:[],voice_samples:[],voice_rules:[],never_list:[],cadence:{}}}function rt(){return Ut().profile}var _h=15,Ch=2,Eh=200,kh=10;function Ss(n,e,t,s,i=1){let r=[],o=t.issues.filter(l=>l.strategy==="restructure"||l.strategy==="voice_drift").sort((l,c)=>c.priority-l.priority).slice(0,_h);return r.push(Oh(n,o.length,i)),r.push(""),o.length>0&&(r.push(Ah(e,o,n)),r.push("")),o.some(l=>l.strategy==="voice_drift")&&n.voice_samples?.length&&(r.push(jh(n.voice_samples)),r.push("")),r.push(Rh(e,o,i)),r.join(`
130
- `)}function Oh(n,e,t){let s=[];if(s.push(`Rewrite ${e} lines to match ${n.name}'s voice.`),n.description&&s.push(`Voice: ${n.description.slice(0,100)}`),n.cadence?.avg_words&&s.push(`Rhythm: ${n.cadence.avg_words} words/sentence, ${n.cadence.variance||"mixed"} variance`),n.never_list?.length){let r=n.never_list.slice(0,kh);s.push(`Never: ${r.join(", ")}`)}let i=n.drift_snapshot.filter(r=>r.status==="accepted"&&r.profile_line).map(r=>r.profile_line).slice(0,3);return i.length&&s.push(`User voice: ${i.join("; ")}`),t>1&&s.push(`RETRY ${t}: Previous rewrite had issues. Be more careful.`),s.join(`
131
- `)}function Ah(n,e,t){let s=[];s.push("FIX THESE LINES:");for(let i of e){let r=Ph(n,i.line),o=Fh(i,t);s.push(`${i.line}: "${Co(r,80)}" \u2192 ${o}`)}return s.join(`
132
- `)}function Fh(n,e){let t=n.signals.filter(r=>r.autoFixable&&r.match);if(t.length>0&&t.length===n.signals.length)return`replace: ${t.map(r=>r.match).join(", ")}`;let s=n.signals.find(r=>r.category==="structure");if(s)return s.suggestion.slice(0,60);let i=n.signals.find(r=>r.category==="voice-drift"||r.category==="learned");return i?i.suggestion.slice(0,60):n.signals.some(r=>r.category==="cadence")?`match rhythm: ${e.cadence?.avg_words||12} words/sentence`:n.instruction.slice(0,60)}function jh(n){let e=["VOICE EXAMPLES:"];for(let t=0;t<Math.min(Ch,n.length);t++){let s=n[t];e.push(`[${s.origin}] ${Co(s.text,Eh)}`)}return e.join(`
133
- `)}function Rh(n,e,t){let s=[];return s.push("OUTPUT: Return the FULL text with only the flagged lines rewritten."),s.push("- Include all lines (changed + unchanged)"),s.push("- Preserve markdown formatting"),s.push("- No commentary, no fences"),s.join(`
134
- `)}function Ph(n,e){return n.split(`
135
- `)[e-1]?.trim()||""}function Co(n,e){return n.length<=e?n:n.slice(0,e-3)+"..."}var Eo=70;var Th=25;function $s(n,e,t,s){let i=[],r=Ie(e,t),o=r.summary.red,a=r.summary.yellow;if(o>0&&i.push(`Rewrite introduced ${o} new critical issues`),s){let S=new Set(s.signals.map(x=>x.id)),$=r.signals.filter(x=>!S.has(x.id));if($.length>0){let x=[...new Set($.map(ae=>ae.id))].slice(0,5);i.push(`Rewrite introduced new patterns: ${x.join(", ")}`)}}let l=wo(e,t.cadence);l<100-Th&&i.push(`Cadence deviation: score ${l}/100 (target avg ${t.cadence?.avg_words||"?"} words)`);let c=[],u=e.toLowerCase();for(let S of t.never_list||[])S&&u.includes(S.toLowerCase())&&c.push(S);c.length>0&&i.push(`Never-list violations: ${c.join(", ")}`);let f=Mh(n,e);f<60&&i.push(`Semantic drift detected: score ${f}/100`);let p=e.length/Math.max(1,n.length);(p<.5||p>2)&&i.push(`Length changed too much: ${(p*100).toFixed(0)}% of original`);let d=Math.max(0,100-o*20-a*5),m=Math.max(0,100-c.length*25),g=Math.round(d*.35+l*.25+f*.25+m*.15),b=g<Eo&&i.length>0,y=!1,v;return b&&(v=Nh(i,r,t)),{valid:g>=Eo,score:g,issues:i,newSignals:r,cadenceScore:l,neverListHits:c,needsRetry:b,needsVerification:y,retryInstruction:v}}function Mh(n,e){let t=ko(n),s=ko(e);if(t.size===0)return 100;let i=0;for(let l of t)s.has(l)&&i++;let r=i/t.size*100,o=e.length/Math.max(1,n.length),a=o>=.7&&o<=1.5?100:Math.max(0,100-Math.abs(1-o)*100);return Math.round(r*.7+a*.3)}function ko(n){let e=n.toLowerCase().match(/[a-z]{4,}/g)||[],t=new Set(["that","this","with","from","have","been","were","they","their","would","could","should","about","which","when","what","there","than","them","then","into","over","also","just","more","some","very","your","only","will","each","make","like","well","back","much","most","other","after"]);return new Set(e.filter(s=>!t.has(s)))}function Nh(n,e,t){let s=[];s.push("The rewrite had these issues:");for(let r of n)s.push(`- ${r}`);s.push("");let i=e.byRule;if(i.size>0){s.push("Fix these specific patterns:");for(let[r,o]of i){let a=o.map(l=>l.line).join(", ");s.push(`- ${r} on lines ${a}`)}}return t.never_list?.length&&(s.push(""),s.push(`Remember: never use these words: ${t.never_list.join(", ")}`)),s.join(`
136
- `)}V();var Oo=50;async function Ao(n,e,t){try{await ht()}catch(d){t.json?console.log(JSON.stringify({error:d.message})):console.log(`
137
- ${h.red("\u2717")} ${d.message}
138
- `),process.exit(1);return}let s=rt(),i;if(n&&e?(s=n,i=e):n&&(n.endsWith(".md")||te.existsSync(n)?i=n:s=n),!s){try{let{apiGet:d}=await Promise.resolve().then(()=>(V(),zt));(await d("/cli/profiles")).profiles?.length||(console.error(`
139
- ${h.red("\u2717")} no voice profiles found`),console.error(` ${h.dim("create one:")} hyv onboard`),console.error(` ${h.dim("or visit:")} https://holdyourvoice.com/dashboard
140
- `),process.exit(1))}catch{}console.error(`
141
- ${h.red("\u2717")} no profile specified`),console.error(` ${h.dim("usage:")} hyv rewrite <profile> <file>`),console.error(` ${h.dim("or set a default:")} hyv init --profile <name>`),process.exit(1)}let r;t.text?r=t.text:i?(te.existsSync(i)||(console.error(`
142
- ${h.red("\u2717")} file not found: ${i}`),process.exit(1)),r=te.readFileSync(i,"utf-8")):(process.stdin.isTTY&&(console.error(`
143
- ${h.red("\u2717")} no text provided`),process.exit(1)),r=te.readFileSync(0,"utf-8")),r.trim()||(console.error(`
144
- ${h.red("\u2717")} empty draft`),process.exit(1)),console.log(`
145
- ${E()} ${h.dim("algorithm")} ${h.dim("v2.0")}
146
- `),console.log(` ${h.dim("1/6")} loading profile: ${h.bold(s)}`);let o;try{o=await nt(s)}catch(d){console.error(`
147
- ${h.red("\u2717")} ${d.message}`),process.exit(1)}console.log(` ${h.dim("drift rules:")} ${o.drift_snapshot.length}`),console.log(` ${h.dim("learned patterns:")} ${o.learned_patterns.length}`),console.log(` ${h.dim("voice samples:")} ${o.voice_samples.length}`),console.log(`
148
- ${h.dim("2/6")} extracting signals...`);let a=Ie(r,o);console.log(` ${h.red(a.summary.red)} critical`),console.log(` ${h.yellow(a.summary.yellow)} advisory`),console.log(` ${h.dim(a.summary.autoFixable)} auto-fixable`),console.log(` ${h.dim(a.summary.driftAccepted)} drift-accepted (skipped)`),console.log(`
149
- ${h.dim("3/6")} classifying issues...`);let l=ws(a);console.log(` ${h.green(l.autoFixes.length)} auto-fixes`),console.log(` ${h.yellow(l.llmFixes.length)} need LLM rewrite`),console.log(` ${h.dim(l.skipped.length)} skipped`);let c=r;if(l.autoFixes.length>0){console.log(`
150
- ${h.dim("4/6")} applying ${l.autoFixes.length} auto-fixes...`);let d=vs(r,l.issues);if(c=d.fixed,d.changed){console.log(` ${h.green("\u2713")} ${d.changes.length} lines fixed`);for(let m of d.changes.slice(0,5))console.log(` ${h.dim(`line ${m.line}:`)} ${m.before.slice(0,40)} \u2192 ${h.green(m.after.slice(0,40))}`)}else console.log(` ${h.dim("no auto-fixes applied")}`)}else console.log(`
151
- ${h.dim("4/6")} no auto-fixes needed`);let u=c,f=l.stats.score,p=f<Oo;if(l.llmFixes.length>0){console.log(`
152
- ${h.dim("5/6")} building prompt for your LLM...`);let d=Ss(o,c,l,a,1),m=i?`${i}.hyv-prompt.md`:"hyv-rewrite-prompt.md";te.writeFileSync(m,d,"utf-8"),console.log(` ${h.dim("prompt:")} ${m}`),t.output?(te.writeFileSync(t.output,d,"utf-8"),console.log(`
153
- ${h.green("\u2713")} prompt written to ${h.bold(t.output)}`)):(console.log(`
154
- ${"\u2500".repeat(50)}`),console.log(d),console.log(`${"\u2500".repeat(50)}
155
- `)),console.log(` ${h.yellow("\u2192")} pass this prompt to your AI agent to rewrite`),console.log(` ${h.dim(" then validate:")} hyv validate <output.md> --profile ${s}`)}else console.log(`
156
- ${h.dim("5/6")} no LLM rewrite needed \u2014 all issues auto-fixable`);console.log(`
157
- ${h.dim("6/6")} algorithm complete`),console.log(`
158
- ${"\u2500".repeat(50)}`),console.log(` ${h.bold("Score:")} ${jo(f)}/100`),console.log(` ${h.bold("Auto-fixed:")} ${l.autoFixes.length} lines`),console.log(` ${h.bold("Needs LLM:")} ${l.llmFixes.length} lines`),console.log(` ${h.bold("Skipped:")} ${l.skipped.length} lines (drift-accepted)`),p&&l.llmFixes.length>0&&console.log(`
159
- ${h.yellow("\u26A0")} Score below ${Oo} \u2014 verify the rewrite after your LLM processes it`),console.log(`${"\u2500".repeat(50)}
160
- `),lo(r,u,f,!0),t.json&&console.log(JSON.stringify({score:f,auto_fixed:l.autoFixes.length,needs_llm:l.llmFixes.length,skipped:l.skipped.length,needs_verification:p,signals:a.summary,prompt_file:l.llmFixes.length>0?i?`${i}.hyv-prompt.md`:"hyv-rewrite-prompt.md":null},null,2))}async function Fo(n,e){let t=e.profile||rt();t||(console.error(`
161
- ${h.red("\u2717")} no profile specified`),process.exit(1));let s;e.text?s=e.text:n&&te.existsSync(n)?s=te.readFileSync(n,"utf-8"):(process.stdin.isTTY&&(console.error(`
162
- ${h.red("\u2717")} no text provided`),process.exit(1)),s=te.readFileSync(0,"utf-8")),console.log(`
163
- ${E()} ${h.dim("validate")}
164
- `);let i=await nt(t),r=Ie(s,i),o=$s(s,s,i);if(console.log(` ${h.bold("Score:")} ${jo(o.score)}/100`),console.log(` ${h.bold("Signals:")} ${r.summary.red} red, ${r.summary.yellow} yellow`),console.log(` ${h.bold("Cadence:")} ${o.cadenceScore}/100`),o.neverListHits.length>0&&console.log(` ${h.red("Never-list:")} ${o.neverListHits.join(", ")}`),o.issues.length>0){console.log(`
165
- ${h.yellow("Issues:")}`);for(let a of o.issues)console.log(` - ${a}`)}o.valid?console.log(`
166
- ${h.green("\u2713")} text passes validation`):console.log(`
167
- ${h.yellow("\u26A0")} text needs improvement`),e.json&&console.log(JSON.stringify({score:o.score,valid:o.valid,cadence_score:o.cadenceScore,never_list_hits:o.neverListHits,issues:o.issues,signals:r.summary},null,2))}function jo(n){return n>=80?h.green(String(n)):n>=50?h.yellow(String(n)):h.red(String(n))}V();async function Ro(n){let e;try{e=(await k("/cli/profiles")).profiles||[]}catch(t){n.json?console.log(JSON.stringify({error:t.message})):console.log(`
168
- ${h.red("\u2717")} ${t.message}
169
- `),process.exit(1);return}if(n.json){console.log(JSON.stringify(e,null,2));return}if(console.log(`
170
- ${E()} ${h.dim("profiles")}
171
- `),e.length===0){console.log(` ${h.dim("no voice profiles yet")}`),console.log(` create one: ${h.cyan("hyv onboard")}`);return}for(let t of e){let s=h.bold(t.name||t.slug),i=t.brand?h.dim(` (${t.brand})`):"",r=t.keywords?.length?h.dim(` \u2014 ${t.keywords.slice(0,3).join(", ")}`):"";console.log(` \u25CF ${s}${i}${r}`)}console.log("")}V();je();async function Po(n){let e=xe();if(!e){n.json?console.log(JSON.stringify({error:"Not signed in. Run: hyv init"})):(console.log(`
172
- ${h.red("\u2717")} you're not signed in yet
173
- `),console.log(` run: ${h.cyan("hyv init")}
174
- `)),process.exit(2);return}try{let t=await k("/cli/heartbeat");if(n.json){console.log(JSON.stringify({email:t.email,name:t.name,plan:t.plan,status:t.status,server:e.base_url,key_prefix:e.api_key.slice(0,12)},null,2));return}console.log(`
175
- ${E()} ${h.dim("status")}
176
- `),console.log(` ${h.bold("account")}`),console.log(` email: ${t.email||"\u2014"}`),console.log(` plan: ${t.plan||"none"} (${t.status||"\u2014"})`),t.plan==="none"&&console.log(` ${h.dim("subscribe at:")} ${h.cyan("https://holdyourvoice.com/dashboard")}`),console.log(""),console.log(` ${h.bold("cli")}`),console.log(` server: ${h.dim(e.base_url)}`),console.log(` key: ${h.dim(e.api_key.slice(0,12)+"...")}`),console.log("")}catch(t){n.json?console.log(JSON.stringify({error:t.message})):console.log(` ${h.red("\u2717")} connection failed: ${t.message}`),process.exit(1)}}var Oe=_(require("fs"));V();async function To(n,e,t){if(!Oe.existsSync(n)){let r={error:`File not found: ${n}`};t.json?console.log(JSON.stringify(r)):console.log(`
177
- ${h.red("\u2717")} ${r.error}`),process.exit(1);return}if(!Oe.existsSync(e)){let r={error:`File not found: ${e}`};t.json?console.log(JSON.stringify(r)):console.log(`
178
- ${h.red("\u2717")} ${r.error}`),process.exit(1);return}let s=Oe.readFileSync(n,"utf-8"),i=Oe.readFileSync(e,"utf-8");t.json||console.log(`
179
- ${E()} ${h.dim("reinforce")}
180
- `);try{let r=await T("/cli/learning/reinforce",{original:s,edited:i});t.json?console.log(JSON.stringify({ok:!0,...r})):console.log(` ${h.green("\u2713")} learning signal sent`)}catch(r){t.json?console.log(JSON.stringify({error:r.message})):console.log(` ${h.red("\u2717")} failed: ${r.message}`),process.exit(1)}}async function Mo(n,e){if(!Oe.existsSync(n)){let s={error:`File not found: ${n}`};e.json?console.log(JSON.stringify(s)):console.log(`
181
- ${h.red("\u2717")} ${s.error}`),process.exit(1);return}let t=Oe.readFileSync(n,"utf-8");e.json||console.log(`
182
- ${E()} ${h.dim("add sample")}
183
- `);try{let s=await T("/cli/learning/add",{text:t,profile:e.profile});e.json?console.log(JSON.stringify({ok:!0,...s})):console.log(` ${h.green("\u2713")} sample added${e.profile?` to ${h.bold(e.profile)}`:""}`)}catch(s){e.json?console.log(JSON.stringify({error:s.message})):console.log(` ${h.red("\u2717")} failed: ${s.message}`),process.exit(1)}}var No=_(require("fs"));V();var Ni={claude:{name:"Claude / Claude Code",wrap:(n,e)=>`You are rewriting text to match a specific voice profile. Use this voice profile for all writing:
184
-
185
- ${e}
186
-
187
- When asked to write or rewrite "in my voice", match this profile exactly. Preserve meaning. Match rhythm, vocabulary, tone, and sentence patterns. Never use words from the never-list.`},chatgpt:{name:"ChatGPT Custom Instructions",wrap:(n,e)=>`# My Voice Profile
188
-
189
- ${e}
190
-
191
- When I ask you to "write in my voice" or "rewrite this in my voice", match this profile. Same rhythm. Same vocabulary. Same patterns. No AI-slop words.`},generic:{name:"Generic System Prompt",wrap:(n,e)=>`## Voice Profile
192
-
193
- ${e}
194
-
195
- ## Instructions
196
- Rewrite text to match this voice profile. Preserve meaning. Match rhythm, vocabulary, and tone. Remove AI-slop patterns (delve, leverage, tapestry, etc.).`},cursor:{name:"Cursor Rules",wrap:(n,e)=>`# Voice Profile
197
-
198
- ${e}
199
-
200
- ## Rewrite Rules
201
- - Match this voice profile for all writing
202
- - Preserve meaning
203
- - Remove AI-slop patterns
204
- - Use the same rhythm and vocabulary`}};async function Io(n,e){if(!Ni[n]){let r=Object.keys(Ni).join(", ");e.json?console.log(JSON.stringify({error:`Unknown format: ${n}. Valid: ${r}`})):(console.log(`
205
- ${h.red("\u2717")} unknown format: ${h.bold(n)}`),console.log(` ${h.dim("valid formats:")} ${r}`)),process.exit(1);return}let t;try{t=(await k("/cli/profiles")).profiles||[]}catch(r){e.json?console.log(JSON.stringify({error:r.message})):console.log(`
206
- ${h.red("\u2717")} failed to fetch profiles: ${r.message}`),process.exit(1);return}if(t.length===0){e.json?console.log(JSON.stringify({error:"No voice profiles found"})):(console.log(`
207
- ${h.red("\u2717")} no voice profiles found`),console.log(` ${h.dim("create one at")} ${h.cyan("https://holdyourvoice.com/dashboard")}`)),process.exit(1);return}let s=Ni[n],i=[];for(let r of t)try{let o=await k(`/cli/profiles/${encodeURIComponent(r.slug||r.name)}`),a=s.wrap(o.profile,o.body);if(e.output){let l=e.output.replace("{name}",r.slug||r.name);No.writeFileSync(l,a),i.push({profile:r.name,file:l})}else i.push({profile:r.name,prompt:a})}catch{i.push({profile:r.name,error:"Failed to fetch profile body"})}if(e.json){console.log(JSON.stringify({format:n,results:i},null,2));return}console.log(`
208
- ${E()} ${h.dim("export")}
209
- `),console.log(` ${h.bold(n.toUpperCase())} \u2014 ${s.name}
210
- `);for(let r of i){if(r.error){console.log(` ${h.red("\u2717")} ${r.profile}: ${r.error}`);continue}r.file?console.log(` ${h.green("\u2713")} ${h.bold(r.profile)} \u2192 ${h.dim(r.file)}`):(console.log(` ${h.bold("\u2500\u2500 "+r.profile+" \u2500\u2500".padEnd(60,"\u2500"))}`),console.log(r.prompt),console.log(` ${"\u2500".repeat(60)}
211
- `))}}V();je();var Ih={solo:{name:"Solo",price:"$19/mo",docs:"50 docs/mo"},team:{name:"Team",price:"$59/mo",docs:"300 docs/mo"},agency:{name:"BYOK",price:"$99 once",docs:"unlimited"}};async function Lo(n){if(!xe()){n.json?console.log(JSON.stringify({error:"Not authenticated. Run: hyv init"})):console.log(`
212
- ${h.red("\u2717")} not authenticated. run ${h.bold("hyv init")}`),process.exit(2);return}if(n.manage){try{let t=await T("/cli/subscribe/manage"),s=t.portal_url||t.url;if(s){let i=(await Promise.resolve().then(()=>_(We()))).default;await i(s),console.log(`
213
- ${h.green("\u2713")} opening billing portal...`)}else console.log(`
214
- ${h.dim("manage billing at:")} ${h.cyan("https://holdyourvoice.com/app/billing")}`)}catch{console.log(`
215
- ${h.dim("manage billing at:")} ${h.cyan("https://holdyourvoice.com/app/billing")}`)}return}if(n.upgrade){try{let s=(await T("/cli/subscribe",{plan:"team"})).checkout_url;if(s){let i=(await Promise.resolve().then(()=>_(We()))).default;await i(s),console.log(`
216
- ${h.green("\u2713")} opening checkout...`)}else console.log(`
217
- ${h.dim("upgrade at:")} ${h.cyan("https://holdyourvoice.com/app/billing")}`)}catch{console.log(`
218
- ${h.dim("upgrade at:")} ${h.cyan("https://holdyourvoice.com/app/billing")}`)}return}try{let t=await k("/cli/heartbeat");if(n.json){console.log(JSON.stringify({plan:t.plan,status:t.status,email:t.email},null,2));return}let s=(t.plan||"none").toLowerCase(),i=Ih[s];console.log(`
219
- ${E()} ${h.dim("plan")}
220
- `),console.log(` ${h.bold("account")} ${t.email||"\u2014"}`),i?(console.log(` ${h.bold("plan")} ${i.name} ${h.dim(i.price)}`),console.log(` ${h.bold("status")} ${t.status||"\u2014"}`),console.log(` ${h.bold("quota")} ${i.docs}`)):console.log(` ${h.bold("plan")} ${h.yellow(t.plan||"none")} (${t.status||"\u2014"})`),console.log(""),console.log(` ${h.dim("manage:")} hyv plan --manage`),console.log(` ${h.dim("upgrade:")} hyv plan --upgrade`),console.log(` ${h.dim("web:")} ${h.cyan("https://holdyourvoice.com/app/billing")}`),console.log("")}catch(t){n.json?console.log(JSON.stringify({error:t.message})):console.log(` ${h.red("\u2717")} failed: ${t.message}`),process.exit(1)}}var Do=_(require("readline")),we=_(require("fs")),ve=_(require("path")),Wo=_(require("os"));V();var Ii=ve.join(Wo.homedir(),".hyv"),Vo=ve.join(Ii,"voice.md");function ue(){return Do.createInterface({input:process.stdin,output:process.stdout})}function Ae(n,e){return new Promise(t=>{n.question(e,s=>t(s.trim()))})}async function Lh(n,e,t){console.log("");for(let s=0;s<t.length;s++)console.log(` ${h.dim(`${s+1}.`)} ${t[s]}`);for(console.log("");;){let s=await Ae(n,` ${h.bold(e)} `),i=parseInt(s,10);if(i>=1&&i<=t.length)return t[i-1];if(t.includes(s.toLowerCase()))return s.toLowerCase();console.log(` ${h.yellow("!")} enter a number (1-${t.length})`)}}async function Li(n,e,t=!0){let s=t?"Y/n":"y/N",i=await Ae(n,` ${h.bold(e)} ${h.dim(`(${s})`)} `);return i?i.toLowerCase().startsWith("y"):t}async function Dh(n,e){return console.log(` ${h.dim(e)}`),console.log(` ${h.dim("(paste text, then press Enter twice to finish)")}`),console.log(""),new Promise(t=>{let s=[],i=0,r=o=>{if(o.trim()===""){if(i++,i>=1&&s.length>0){n.removeListener("line",r),t(s.join(`
221
- `));return}}else i=0,s.push(o)};n.on("line",r)})}async function ot(){try{we.existsSync(Ii)||we.mkdirSync(Ii,{recursive:!0});let e=(await k("/cli/profiles")).profiles||[];if(e.length===0)return;let t=[`# Voice Profile
222
- `];for(let s of e)t.push(`## ${s.name}${s.is_default?" (default)":""}`),s.brand&&t.push(`Brand: ${s.brand}`),s.description&&t.push(s.description),s.keywords?.length&&t.push(`Keywords: ${s.keywords.join(", ")}`),t.push("");we.writeFileSync(Vo,t.join(`
223
- `))}catch{}}async function Nt(n){console.log(""),console.log(` ${h.green("\u2713")} profile ${h.bold(n)} created`),console.log(` ${h.green("\u2713")} voice profile saved: ${h.dim(Vo)}`);let e=!1;try{let t=await k("/cli/heartbeat");e=t.plan&&t.plan.toLowerCase()!=="none"&&t.status!=="none"}catch{}e?(console.log(""),console.log(` ${h.bold("you're all set! try it out:")}`),console.log(""),console.log(` ${h.cyan("hyv scan draft.md")} ${h.dim("\u2014 check a draft")}`),console.log(` ${h.cyan("hyv rewrite draft.md")} ${h.dim("\u2014 get rewrite prompt")}`),console.log(` ${h.dim('or say "rewrite in my voice" in any connected agent')}`)):(console.log(""),console.log(` ${h.bold("last step \u2014 unlock everything for just $1:")}`),console.log(""),console.log(` ${h.cyan("hyv plan --upgrade")}`),console.log(""),console.log(` ${h.dim("first month is $1, then $9/month. cancel anytime.")}`)),console.log("")}async function _s(n,e){return await Ae(n,` ${h.bold("profile name?")} ${h.dim(`(default: ${e})`)} `)||e}var Wh=[{key:"style",q:"How would you describe your writing style?",type:"text"},{key:"tone",q:"What tone do you use most?",type:"choice",options:["casual","professional","mixed","academic","conversational"]},{key:"contractions",q:"Do you use contractions? (don't, can't, it's)",type:"choice",options:["always","sometimes","never"]},{key:"sentence_length",q:"How long are your typical sentences?",type:"choice",options:["short and punchy","medium","long and flowing","mixed"]},{key:"em_dashes",q:"Do you use em dashes \u2014 like this?",type:"choice",options:["yes, often","sometimes","no"]},{key:"opening_moves",q:'How do you typically open a piece? (e.g., "with a question", "with a bold claim", "with a story")',type:"text"},{key:"never_use",q:'Words or phrases you never use? (comma-separated, or "none")',type:"text"},{key:"formality",q:"Formality level? (1 = very casual, 10 = very formal)",type:"scale"},{key:"first_person",q:"Do you write in first person? (I, me, my)",type:"choice",options:["always","sometimes","never"]},{key:"examples",q:"How do you use examples?",type:"choice",options:["lots of concrete examples","a few","rarely"]},{key:"jargon",q:"Technical jargon level?",type:"choice",options:["none \u2014 plain English","some when needed","heavy \u2014 my audience is technical"]},{key:"content_type",q:"What do you write most?",type:"choice",options:["blog posts","linkedin posts","tweets / X","newsletters","mixed"]}];async function Ho(n){let e=ue();console.log(`
224
- ${E()} ${h.dim("onboarding \u2014 questions")}
225
- `),console.log(` ${h.dim("answer 12 quick questions to build your voice profile.")}`),console.log(` ${h.dim("takes about 2 minutes.")}
226
- `);let t=await _s(e,"my-voice");console.log("");let s=[];for(let i of Wh){let r;if(i.type==="choice"&&i.options)r=await Lh(e,i.q,i.options);else if(i.type==="scale")for(;;){let o=await Ae(e,` ${h.bold(i.q)} `),a=parseInt(o,10);if(a>=1&&a<=10){r=String(a);break}console.log(` ${h.yellow("!")} enter a number 1-10`)}else r=await Ae(e,` ${h.bold(i.q)} `);s.push({question:i.q,key:i.key,answer:r})}e.close(),console.log(""),console.log(` ${h.dim("creating profile...")}`);try{let i=await T("/cli/onboarding/questions",{name:t,answers:s});n.json?console.log(JSON.stringify({ok:!0,profile:i.profile?.name||t})):(await ot(),Nt(i.profile?.name||t))}catch(i){n.json?console.log(JSON.stringify({error:i.message})):console.log(`
227
- ${h.red("\u2717")} ${i.message}`),process.exit(1)}}async function qo(n,e){if(n.length===0){console.log(`
228
- ${h.red("\u2717")} no urls provided`),console.log(` ${h.dim("usage:")} hyv onboard --url https://blog.example.com`),process.exit(1);return}console.log(`
229
- ${E()} ${h.dim("onboarding \u2014 url scrape")}
230
- `),console.log(` ${h.dim("scraping:")} ${n.map(s=>h.cyan(s)).join(`
231
- `)}
232
- `);let t="my-voice";if(!e.json){let s=ue();t=await _s(s,"my-voice"),s.close(),console.log(` ${h.dim(`using profile name: ${t}`)}
233
- `)}try{let s=await T("/cli/onboarding/scrape",{urls:n,name:t});if(e.json){console.log(JSON.stringify({ok:!0,...s}));return}let i=s.samples_found||0,r=s.words_found||0,o=s.profile?.name||t;if(i===0){console.log(` ${h.yellow("!")} couldn't extract any content from those urls`),console.log(` ${h.dim("try:")} a blog homepage, substack, or medium profile`),console.log(` ${h.dim("or:")} use ${h.dim("hyv onboard --folder ./my-writing/")} for local files`),process.exit(1);return}console.log(` ${h.green("\u2713")} found ${h.bold(String(i))} articles, ~${h.bold(String(r))} words`),await ot(),Nt(o)}catch(s){e.json?console.log(JSON.stringify({error:s.message})):console.log(`
234
- ${h.red("\u2717")} ${s.message}`),process.exit(1)}}function Vh(n){return n.split(/\s+/).filter(e=>e.length>0).length}async function Bo(n,e){if(!we.existsSync(n)){console.log(`
235
- ${h.red("\u2717")} folder not found: ${n}`),process.exit(1);return}console.log(`
236
- ${E()} ${h.dim("onboarding \u2014 local folder")}
237
- `);let t=ve.basename(n);if(!e.json){let u=ue();t=await _s(u,t),u.close(),console.log(` ${h.dim(`using profile name: ${t}`)}
238
- `)}let s=ve.resolve(n),i=["**/*.md","**/*.txt","**/*.markdown"],r=[];for(let u of i){let f=await st(u,{cwd:s,nodir:!0,absolute:!0});r.push(...f)}if(r=[...new Set(r)],r.length===0){console.log(` ${h.red("\u2717")} no .md or .txt files found in ${n}`),console.log(` ${h.dim("supported formats:")} .md, .txt, .markdown`),process.exit(1);return}let o=[],a=0;for(let u of r)try{let f=we.readFileSync(u,"utf-8"),p=Vh(f);p>=50&&(o.push({path:u,name:ve.relative(s,u),words:p,text:f}),a+=p)}catch{}if(o.length===0){console.log(` ${h.red("\u2717")} all files are too short (need 50+ words each)`),process.exit(1);return}console.log(` ${h.bold("found")} ${h.cyan(String(o.length))} files, ~${h.cyan(String(a))} words
239
- `);for(let u of o.slice(0,20))console.log(` ${h.dim(u.name)} ${h.dim(`(${u.words} words)`)}`);if(o.length>20&&console.log(` ${h.dim(`... and ${o.length-20} more`)}`),console.log(""),!e.json){let u=ue(),f=await Li(u,"upload these files?");if(u.close(),!f){console.log(` ${h.dim("cancelled")}
240
- `);return}}console.log("");let l=0,c=0;for(let u=0;u<o.length;u++){let f=o[u];try{await T("/cli/learning/add",{text:f.text.slice(0,5e3)}),l++,e.json||process.stdout.write(`\r ${h.dim("uploading:")} ${l}/${o.length}`)}catch{c++}}e.json||(process.stdout.write("\r"),console.log(` ${h.green("\u2713")} uploaded ${h.bold(String(l))} files${c>0?h.red(` (${c} failed)`):""}`),console.log(` ${h.dim("analyzing voice patterns...")}`));try{let u=await T("/cli/onboarding/analyze",{name:t}),f=u.profile?.name||t;e.json?console.log(JSON.stringify({ok:!0,uploaded:l,errors:c,profile:u.profile})):(await ot(),Nt(f))}catch(u){e.json?console.log(JSON.stringify({ok:!0,uploaded:l,errors:c,analysis_error:u.message})):(console.log(` ${h.yellow("!")} samples uploaded but analysis failed: ${u.message}`),console.log(` ${h.dim("try again:")} hyv onboard --analyze`),await ot(),console.log(""))}}var Hh=`Analyze my writing style from the samples below. Extract patterns and return your analysis in this EXACT format (use the exact labels):
241
-
242
- STYLE: [one-line description of the writing style]
243
- TONE: [casual / professional / mixed / academic / conversational]
244
- FORMALITY: [number 1-10, where 1 = very casual, 10 = very formal]
245
- SENTENCE_LENGTH: [short / medium / long / mixed]
246
- CONTRACTIONS: [always / sometimes / never]
247
- EM_DASHES: [yes / no / sometimes]
248
- FIRST_PERSON: [always / sometimes / never]
249
- OPENING_MOVES: [comma-separated list of how the writer opens pieces]
250
- NEVER_USE: [comma-separated list of words/phrases the writer avoids, or "none"]
251
- VOCABULARY: [simple / moderate / advanced]
252
- HUMOR: [often / sometimes / rarely / never]
253
- ARGUMENT_PATTERN: [one-line description of how the writer builds a point]
254
- KEYWORDS: [comma-separated list of characteristic words or phrases]
255
-
256
- DETAILED_NOTES:
257
- [2-3 paragraphs of specific observations. Quote exact phrases from the samples. Note what makes this writer distinctive.]
24
+ `)+t,o=n+1,n=r.indexOf(`
25
+ `,o)}while(n!==-1);return s+=r.substr(o),s};un.exports={stringReplaceAll:Ur,stringEncaseCRLFWithFirstIndex:Gr}});var gn=x((us,pn)=>{"use strict";var zr=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,dn=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,Yr=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Jr=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,Kr=new Map([["n",`
26
+ `],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1B"],["a","\x07"]]);function mn(r){let e=r[0]==="u",t=r[1]==="{";return e&&!t&&r.length===5||r[0]==="x"&&r.length===3?String.fromCharCode(parseInt(r.slice(1),16)):e&&t?String.fromCodePoint(parseInt(r.slice(2,-1),16)):Kr.get(r)||r}function Qr(r,e){let t=[],n=e.trim().split(/\s*,\s*/g),o;for(let s of n){let i=Number(s);if(!Number.isNaN(i))t.push(i);else if(o=s.match(Yr))t.push(o[2].replace(Jr,(a,l,u)=>l?mn(l):u));else throw new Error(`Invalid Chalk template style argument: ${s} (in style '${r}')`)}return t}function Xr(r){dn.lastIndex=0;let e=[],t;for(;(t=dn.exec(r))!==null;){let n=t[1];if(t[2]){let o=Qr(n,t[2]);e.push([n].concat(o))}else e.push([n])}return e}function fn(r,e){let t={};for(let o of e)for(let s of o.styles)t[s[0]]=o.inverse?null:s.slice(1);let n=r;for(let[o,s]of Object.entries(t))if(Array.isArray(s)){if(!(o in n))throw new Error(`Unknown Chalk style: ${o}`);n=s.length>0?n[o](...s):n[o]}return n}pn.exports=(r,e)=>{let t=[],n=[],o=[];if(e.replace(zr,(s,i,a,l,u,h)=>{if(i)o.push(mn(i));else if(l){let f=o.join("");o=[],n.push(t.length===0?f:fn(r,t)(f)),t.push({inverse:a,styles:Xr(l)})}else if(u){if(t.length===0)throw new Error("Found extraneous } in Chalk template literal");n.push(fn(r,t)(o.join(""))),o=[],t.pop()}else o.push(h)}),n.push(o.join("")),t.length>0){let s=`Chalk template literal is missing ${t.length} closing bracket${t.length===1?"":"s"} (\`}\`)`;throw new Error(s)}return n.join("")}});var N=x((hs,xn)=>{"use strict";var pe=rn(),{stdout:lt,stderr:ct}=cn(),{stringReplaceAll:Zr,stringEncaseCRLFWithFirstIndex:eo}=hn(),{isArray:ke}=Array,bn=["ansi","ansi","ansi256","ansi16m"],ie=Object.create(null),to=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=lt?lt.level:0;r.level=e.level===void 0?t:e.level},ut=class{constructor(e){return wn(e)}},wn=r=>{let e={};return to(e,r),e.template=(...t)=>vn(e.template,...t),Object.setPrototypeOf(e,Ae.prototype),Object.setPrototypeOf(e.template,e),e.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},e.template.Instance=ut,e.template};function Ae(r){return wn(r)}for(let[r,e]of Object.entries(pe))ie[r]={get(){let t=$e(this,ht(e.open,e.close,this._styler),this._isEmpty);return Object.defineProperty(this,r,{value:t}),t}};ie.visible={get(){let r=$e(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:r}),r}};var _n=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let r of _n)ie[r]={get(){let{level:e}=this;return function(...t){let n=ht(pe.color[bn[e]][r](...t),pe.color.close,this._styler);return $e(this,n,this._isEmpty)}}};for(let r of _n){let e="bg"+r[0].toUpperCase()+r.slice(1);ie[e]={get(){let{level:t}=this;return function(...n){let o=ht(pe.bgColor[bn[t]][r](...n),pe.bgColor.close,this._styler);return $e(this,o,this._isEmpty)}}}}var no=Object.defineProperties(()=>{},{...ie,level:{enumerable:!0,get(){return this._generator.level},set(r){this._generator.level=r}}}),ht=(r,e,t)=>{let n,o;return t===void 0?(n=r,o=e):(n=t.openAll+r,o=e+t.closeAll),{open:r,close:e,openAll:n,closeAll:o,parent:t}},$e=(r,e,t)=>{let n=(...o)=>ke(o[0])&&ke(o[0].raw)?yn(n,vn(n,...o)):yn(n,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(n,no),n._generator=r,n._styler=e,n._isEmpty=t,n},yn=(r,e)=>{if(r.level<=0||!e)return r._isEmpty?"":e;let t=r._styler;if(t===void 0)return e;let{openAll:n,closeAll:o}=t;if(e.indexOf("\x1B")!==-1)for(;t!==void 0;)e=Zr(e,t.close,t.open),t=t.parent;let s=e.indexOf(`
27
+ `);return s!==-1&&(e=eo(e,o,n,s)),n+e+o},at,vn=(r,...e)=>{let[t]=e;if(!ke(t)||!ke(t.raw))return e.join(" ");let n=e.slice(1),o=[t.raw[0]];for(let s=1;s<t.length;s++)o.push(String(n[s-1]).replace(/[{}\\]/g,"\\$&"),String(t.raw[s]));return at===void 0&&(at=gn()),at(r,o.join(""))};Object.defineProperties(Ae.prototype,ie);var Ee=Ae();Ee.supportsColor=lt;Ee.stderr=Ae({level:ct?ct.level:0});Ee.stderr.supportsColor=ct;xn.exports=Ee});var pt=x((fs,En)=>{"use strict";var $n=require("fs"),mt;function ro(){try{return $n.statSync("/.dockerenv"),!0}catch{return!1}}function oo(){try{return $n.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}En.exports=()=>(mt===void 0&&(mt=ro()||oo()),mt)});var Tn=x((ms,gt)=>{"use strict";var so=require("os"),io=require("fs"),Pn=pt(),Rn=()=>{if(process.platform!=="linux")return!1;if(so.release().toLowerCase().includes("microsoft"))return!Pn();try{return io.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Pn():!1}catch{return!1}};process.env.__IS_WSL_TEST__?gt.exports=Rn:gt.exports=Rn()});var Fn=x((ps,In)=>{"use strict";In.exports=(r,e,t)=>{let n=o=>Object.defineProperty(r,e,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get(){let o=t();return n(o),o},set(o){n(o)}}),r}});var vt=x((gs,Vn)=>{var ao=require("path"),lo=require("child_process"),{promises:Fe,constants:qn}=require("fs"),Ie=Tn(),co=pt(),bt=Fn(),Hn=ao.join(__dirname,"xdg-open"),{platform:ce,arch:jn}=process,uo=()=>{try{return Fe.statSync("/run/.containerenv"),!0}catch{return!1}},yt;function ho(){return yt===void 0&&(yt=uo()||co()),yt}var fo=(()=>{let r="/mnt/",e;return async function(){if(e)return e;let t="/etc/wsl.conf",n=!1;try{await Fe.access(t,qn.F_OK),n=!0}catch{}if(!n)return r;let o=await Fe.readFile(t,{encoding:"utf8"}),s=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(o);return s?(e=s.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):r}})(),Mn=async(r,e)=>{let t;for(let n of r)try{return await e(n)}catch(o){t=o}throw t},He=async r=>{if(r={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...r},Array.isArray(r.app))return Mn(r.app,a=>He({...r,app:a}));let{name:e,arguments:t=[]}=r.app||{};if(t=[...t],Array.isArray(e))return Mn(e,a=>He({...r,app:{name:a,arguments:t}}));let n,o=[],s={};if(ce==="darwin")n="open",r.wait&&o.push("--wait-apps"),r.background&&o.push("--background"),r.newInstance&&o.push("--new"),e&&o.push("-a",e);else if(ce==="win32"||Ie&&!ho()&&!e){let a=await fo();n=Ie?`${a}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:`${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`,o.push("-NoProfile","-NonInteractive","\u2013ExecutionPolicy","Bypass","-EncodedCommand"),Ie||(s.windowsVerbatimArguments=!0);let l=["Start"];r.wait&&l.push("-Wait"),e?(l.push(`"\`"${e}\`""`,"-ArgumentList"),r.target&&t.unshift(r.target)):r.target&&l.push(`"${r.target}"`),t.length>0&&(t=t.map(u=>`"\`"${u}\`""`),l.push(t.join(","))),r.target=Buffer.from(l.join(" "),"utf16le").toString("base64")}else{if(e)n=e;else{let a=!__dirname||__dirname==="/",l=!1;try{await Fe.access(Hn,qn.X_OK),l=!0}catch{}n=process.versions.electron||ce==="android"||a||!l?"xdg-open":Hn}t.length>0&&o.push(...t),r.wait||(s.stdio="ignore",s.detached=!0)}r.target&&o.push(r.target),ce==="darwin"&&t.length>0&&o.push("--args",...t);let i=lo.spawn(n,o,s);return r.wait?new Promise((a,l)=>{i.once("error",l),i.once("close",u=>{if(!r.allowNonzeroExitCode&&u>0){l(new Error(`Exited with code ${u}`));return}a(i)})}):(i.unref(),i)},wt=(r,e)=>{if(typeof r!="string")throw new TypeError("Expected a `target`");return He({...e,target:r})},mo=(r,e)=>{if(typeof r!="string")throw new TypeError("Expected a `name`");let{arguments:t=[]}=e||{};if(t!=null&&!Array.isArray(t))throw new TypeError("Expected `appArguments` as Array type");return He({...e,app:{name:r,arguments:t}})};function Nn(r){if(typeof r=="string"||Array.isArray(r))return r;let{[jn]:e}=r;if(!e)throw new Error(`${jn} is not supported`);return e}function _t({[ce]:r},{wsl:e}){if(e&&Ie)return Nn(e);if(!r)throw new Error(`${ce} is not supported`);return Nn(r)}var je={};bt(je,"chrome",()=>_t({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));bt(je,"firefox",()=>_t({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));bt(je,"edge",()=>_t({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));wt.apps=je;wt.openApp=mo;Vn.exports=wt});var Lt=y(Dt(),1),{program:Uo,createCommand:Go,createArgument:zo,createOption:Yo,CommanderError:Jo,InvalidArgumentError:Ko,InvalidOptionArgumentError:Qo,Command:Wt,Argument:Xo,Option:Zo,Help:es}=Lt.default;var I=y(N());var C=y(require("fs")),D=y(require("path")),Cn=y(require("os")),ae=D.join(Cn.homedir(),".hyv"),Pe=D.join(ae,"auth.json"),dt=D.join(ae,"config.json"),Y=D.join(ae,"profiles"),Q=D.join(ae,"cache"),On=D.join(ae,"queue"),ge=process.env.HYV_API_URL||"https://holdyourvoice.com";function T(){let r=[ae,Y,Q,On];for(let e of r)C.existsSync(e)||C.mkdirSync(e,{recursive:!0,mode:448})}function Re(){return C.existsSync(Pe)}function Te(){try{if(!C.existsSync(Pe))return null;let r=C.readFileSync(Pe,"utf-8");return JSON.parse(r)}catch{return null}}function ft(r){T(),C.writeFileSync(Pe,JSON.stringify(r,null,2),{mode:384})}function Sn(){try{if(!C.existsSync(dt))return{};let r=C.readFileSync(dt,"utf-8");return JSON.parse(r)}catch{return{}}}function kn(r){T(),C.writeFileSync(dt,JSON.stringify(r,null,2),{mode:384})}function $(){let r=Te();return!r||r.expires_at&&new Date(r.expires_at)<new Date?null:r.token}function An(){try{return C.existsSync(Y)?C.readdirSync(Y).filter(r=>r.endsWith(".md")).map(r=>r.replace(".md","")):[]}catch{return[]}}function ye(r){let e=D.join(Y,`${r}.md`);try{return C.existsSync(e)?C.readFileSync(e,"utf-8"):null}catch{return null}}function B(r,e){T();let t=D.join(Y,`${r}.md`);C.writeFileSync(t,e,{mode:384})}function le(r){T();let e=Date.now().toString(36)+Math.random().toString(36).slice(2,8),t=D.join(On,`${e}.json`);C.writeFileSync(t,JSON.stringify(r,null,2))}var xt=y(require("http")),po=y(require("https")),Dn=y(N()),Ln=y(vt());function be(r,e={}){return new Promise((t,n)=>{let o=new URL(r),s=o.protocol==="https:",i=s?po:xt,a={hostname:o.hostname,port:o.port||(s?443:80),path:o.pathname+o.search,method:e.method||"GET",headers:{"Content-Type":"application/json","User-Agent":"hyvoice-cli/0.1.0",...e.headers},timeout:e.timeout||3e4},l=i.request(a,u=>{let h="";u.on("data",f=>h+=f),u.on("end",()=>{try{t({status:u.statusCode||0,data:JSON.parse(h)})}catch{t({status:u.statusCode||0,data:h})}})});l.on("error",n),l.on("timeout",()=>{l.destroy(),n(new Error("Request timeout"))}),e.body&&l.write(JSON.stringify(e.body)),l.end()})}async function E(r,e={}){let t=$();if(!t)throw new Error("Not authenticated. Run `hyvoice init` first.");return be(r,{...e,headers:{Authorization:`Bearer ${t}`}})}async function Wn(r){let e=await be(`${ge}/cli/auth/license`,{method:"POST",body:{license_key:r,device_name:`CLI (${process.platform})`}});if(e.status!==200){let n=e.data;throw new Error(n?.error||"Authentication failed")}let t=e.data;return ft(t),t}async function Bn(){let r=xt.createServer(),e=await new Promise(i=>{r.listen(0,"127.0.0.1",()=>{i(r.address().port)})}),t=`http://127.0.0.1:${e}/callback`,n=await be(`${ge}/cli/auth/browser`,{method:"POST",body:{redirect_uri:t}});if(n.status!==200)throw r.close(),new Error("Failed to start authentication flow");let{auth_url:o}=n.data;console.log(Dn.default.cyan(`
28
+ Opening browser for authentication...`)),await(0,Ln.default)(o);let s=await new Promise((i,a)=>{let l=setTimeout(()=>{r.close(),a(new Error("Authentication timeout. Please try again."))},12e4);r.on("request",async(u,h)=>{let f=new URL(u.url||"/",`http://127.0.0.1:${e}`);if(f.pathname==="/callback"){let w=f.searchParams.get("code"),R=f.searchParams.get("state");if(!w||!R){h.writeHead(400,{"Content-Type":"text/html"}),h.end("<h1>Authentication failed</h1><p>Missing code or state.</p>"),clearTimeout(l),r.close(),a(new Error("Invalid callback parameters"));return}try{let p=await be(`${ge}/cli/auth/callback`,{method:"POST",body:{code:w,state:R}});if(p.status!==200)throw new Error("Failed to complete authentication");let P=p.data;h.writeHead(200,{"Content-Type":"text/html"}),h.end(`
29
+ <html>
30
+ <body style="font-family: -apple-system, sans-serif; text-align: center; padding: 40px;">
31
+ <h1 style="color: #22c55e;">\u2713 Authenticated</h1>
32
+ <p>You can close this window and return to the terminal.</p>
33
+ </body>
34
+ </html>
35
+ `),clearTimeout(l),r.close(),i(P)}catch(p){h.writeHead(500,{"Content-Type":"text/html"}),h.end(`<h1>Authentication failed</h1><p>${p.message}</p>`),clearTimeout(l),r.close(),a(p)}}else h.writeHead(404),h.end()})});return ft(s),s}async function Me(){let r=$();if(!r)return{valid:!1};try{let e=await be(`${ge}/cli/heartbeat`,{method:"GET",headers:{Authorization:`Bearer ${r}`}});return e.status!==200?{valid:!1}:e.data}catch{return{valid:!1}}}function Un(r){r.command("init").description("Authenticate with Hold Your Voice").argument("[license-key]","License key (skip browser flow)").option("--no-browser","Skip browser-based authentication").action(async(e,t)=>{try{if(T(),Re()){let s=Te(),i=await Me();if(i.valid){console.log(I.default.green("\u2713 Already authenticated")),console.log(I.default.dim(` Email: ${s?.user?.email||"Unknown"}`)),console.log(I.default.dim(` Plan: ${i.plan||"Unknown"}`)),console.log("\nRun `hyvoice status` for more details.");return}else console.log(I.default.yellow(`Session expired. Re-authenticating...
36
+ `))}let n;e?(console.log(I.default.cyan("Authenticating with license key...")),n=await Wn(e)):t?.browser===!1?(console.log(I.default.red("License key required when --no-browser is set.")),console.log(`
37
+ Usage: hyvoice init <license-key>`),console.log(`
38
+ Generate a license key at: https://holdyourvoice.com/app/settings`),process.exit(1)):n=await Bn();let o=Sn();kn({...o,created_at:o.created_at||new Date().toISOString()}),console.log(I.default.green(`
39
+ \u2713 Authenticated successfully!`)),console.log(I.default.dim(` Email: ${n.user?.email||"Unknown"}`)),console.log(I.default.dim(` Plan: ${n.user?.plan||"Unknown"}`)),n.license_key&&console.log(I.default.dim(` License: ${n.license_key.slice(0,12)}...`)),console.log(`
40
+ Next steps:`),console.log(I.default.dim(" 1. Create a voice profile: hyvoice new <name>")),console.log(I.default.dim(" 2. Scan a draft: hyvoice scan draft.md")),console.log(I.default.dim(" 3. Rewrite with voice: hyvoice rewrite draft.md"))}catch(n){console.error(I.default.red(`
41
+ \u2717 Authentication failed: ${n.message}`)),process.exit(1)}})}var J=y(N());function Gn(r){r.command("status").description("show account and cli status").action(async()=>{let e=$();if(!Re()){console.log(J.default.red(`
42
+ error: you're not signed in yet
43
+ `)),console.log(J.default.dim(` run: hyv init
44
+ `)),process.exit(2);return}let t=await Me();t.valid?(console.log(J.default.bold(`
45
+ account`)),console.log(` email: ${t.user?.email||"\u2014"}`),console.log(` plan: ${t.plan||"none"}`),(!t.plan||t.plan==="none")&&console.log(J.default.dim(" subscribe: ")+J.default.cyan("hyv plan --upgrade")),console.log("")):(console.log(J.default.red(`
46
+ error: your session has expired
47
+ `)),console.log(J.default.dim(` run: hyv init
48
+ `)),process.exit(1))})}var S=y(N());var Ne=y(require("fs")),qe=y(require("path"));function zn(r){r.command("sync").description("Sync profiles and rules from server").option("--force","Force re-download even if cache is fresh").action(async e=>{try{$()||(console.log(S.default.yellow("Not authenticated. Run `hyvoice init` first.")),process.exit(1)),console.log(S.default.cyan("Syncing profiles and rules..."));let n=await E("https://holdyourvoice.com/cli/sync",{method:"GET"});if(n.status!==200){let u=n.data;console.error(S.default.red(`Sync failed: ${u?.error||"Unknown error"}`)),process.exit(1)}let o=n.data;T();let s=0;for(let u of o.profiles)B(u.slug||u.name,u.content),s++;let i=qe.join(Q,"rules.md");Ne.writeFileSync(i,o.rules,{mode:384});let a=qe.join(Q,"prompt-template.md");Ne.writeFileSync(a,o.prompt_template,{mode:384});let l=qe.join(Q,"sync-meta.json");if(Ne.writeFileSync(l,JSON.stringify({synced_at:o.synced_at,profile_count:s,plan:o.plan},null,2),{mode:384}),console.log(S.default.green(`
49
+ \u2713 Synced successfully!`)),console.log(S.default.dim(` Profiles: ${s}`)),console.log(S.default.dim(" Rules: cached")),console.log(S.default.dim(" Prompt template: cached")),console.log(S.default.dim(` Plan: ${o.plan}`)),s>0){console.log(`
50
+ Profiles:`);for(let u of o.profiles)console.log(S.default.dim(` \u2022 ${u.name} (${u.slug})`))}}catch(t){console.error(S.default.red(`Sync failed: ${t.message}`)),process.exit(1)}}),r.command("profiles").description("List voice profiles").action(async()=>{try{let e=An();if(console.log(S.default.bold(`
51
+ Voice Profiles
52
+ `)),e.length===0){console.log(S.default.dim("No profiles cached.")),console.log(S.default.dim("Run `hyvoice sync` to fetch profiles."));return}for(let t of e){let n=ye(t);if(n){let o=n.match(/^#\s+(.+)$/m),s=o?o[1]:t;console.log(S.default.dim(`\u2022 ${s}`))}else console.log(S.default.dim(`\u2022 ${t}`))}console.log(S.default.dim(`
53
+ ${e.length} profile(s) cached.`))}catch(e){console.error(S.default.red(`Error: ${e.message}`)),process.exit(1)}}),r.command("pull").description("Force re-download profiles and rules").action(async()=>{await r.parseAsync(["node","hyvoice","sync","--force"])})}var F=y(N()),Z=y(require("fs")),Ct=y(require("path"));var X=y(require("fs")),Qn=y(require("path"));var go=[{id:"ai_antithesis",pattern:/\b(?:it'?s|isn'?t|is\s+not)\s+not\s+just\b.{0,80}\b(?:it'?s|but)\b/i},{id:"not_just_but",pattern:/\bnot\s+just\b.{3,80}\bbut\s+(?:also\s+)?/i},{id:"more_than_just",pattern:/\bmore\s+than\s+just\b/i},{id:"rhetorical_truth_setup",pattern:/\b(?:the\s+)?(?:uncomfortable|hard|harsh|brutal|ugly|unsexy|real|honest)\s+(?:truth|reality)\b/i},{id:"truth_is",pattern:/\bthe\s+truth\s+is\b/i},{id:"lesson_setup",pattern:/\b(?:here'?s\s+)?what\s+.{3,80}\s+(?:taught|teaches)\s+(?:me|us|you|everyone)\b/i},{id:"negation_cascade",pattern:/\b(?:no|not)\s+\w[^.!?\n]{0,80}[.!?][ \t]*\n?[ \t]*(?:no|not)\s+\w[^.!?\n]{0,80}[.!?][ \t]*\n?[ \t]*(?:no|not)\s+\w/i},{id:"formulaic_connector",pattern:/\b(?:firstly|secondly|thirdly|lastly|moreover|furthermore|in conclusion|to summarize|to sum up|in summary|it is important to note|it should be noted)\b/i},{id:"ai_words",pattern:/\b(?:delve|underscore|testament|intricate|multifaceted|cornerstone|landscape|foster|harness|leverage|tapestry|illuminate|pivotal|elevate|empower|seamlessly|revolutionize|supercharge|transformative|holistic|comprehensive|innovative|impactful|meaningful|utilize|paradigm|navigate|endeavor|realm|profound|encapsulate|synergy|robust|facilitate|bolster|streamline|differentiate|myriad|unlock|transform)\b/i},{id:"em_dash",pattern:/\u2014/},{id:"signpost_claim",pattern:/\bthis\s+is\s+(?:also\s+)?(?:why|how|where|what\b|what\s+happens\s+when)\b|\b(?:here'?s|here\s+is)\s+(?:where|why|what|the\s+part|the\s+(?:harder|real|actual|main|bigger)\s+problem)\b/i},{id:"generic_buyer_psychology",pattern:/\bpeople\s+don'?t\s+just\s+buy\b|\bpeople\s+buy\s+the\s+feeling\b/i},{id:"founder_cadence_restatement",pattern:/\bwhich\s+is\s+another\s+way\s+of\s+saying\b|\bin\s+other\s+words\b/i},{id:"founder_cadence_moment_becomes",pattern:/\b(?:the\s+)?moment\b.{3,80}\bbecomes?\b|\bbecomes?\s+(?:dangerous|useful|interesting|real|obvious)\s+the\s+moment\b/i},{id:"founder_cadence_same_better",pattern:/\bsame\s+[^.!?\n]{1,35}[.!?]\s*(?:better|nicer|cleaner|calmer|safer)\s+[^.!?\n]{1,35}[.!?]?/i}],yo=new Set(["alignment","authenticity","awareness","clarity","confidence","consistency","differentiation","execution","framework","identity","messaging","narrative","personality","positioning","preference","presence","recall","relevance","resonance","signal","strategy","trust","utility","value"]),bo=/^(?:most|many)\s+(?:brands|teams|people|founders|companies)\b/i,wo=/^(?:have you|do you|did you|what if|why do|how do)\b/i,_o=/^(?:the most important thing|the key to|success is|if you want to|what i learned)\b/i;function q(r){return(r||"").match(/[a-zA-Z][a-zA-Z0-9']*/g)||[]}function we(r){return(r||"").split(/(?<=[.!?])\s+|\n{2,}/).map(e=>e.trim()).filter(e=>q(e).length>0)}function Yn(r){return(r||"").split(/\n\s*\n/).map(e=>e.trim()).filter(e=>q(e).length>=6)}function vo(r){let e=(r||"").trim().toLowerCase();if(!e)return[];let t=[];return(e.match(/[a-z']+/g)||[]).filter(s=>yo.has(s)).length>=3&&!/\b(?:for example|for instance|such as)\b|\d/i.test(e)&&t.push({line:0,rule:"abstract_noun_cluster",phrase:r.trim().slice(0,160)}),bo.test(e)&&t.push({line:0,rule:"generic_opening_generalization",phrase:r.trim().slice(0,160)}),wo.test(e)&&t.push({line:0,rule:"voice_question_opener",phrase:"opens with a question instead of a concrete observation"}),_o.test(e)&&t.push({line:0,rule:"voice_lesson_opener",phrase:"opens with a lesson or inspirational claim"}),t}function K(r){let e=[],t=r||"";for(let s of go){let i=t.match(s.pattern);if(i)for(let a of i){let l=a.trim();if(!l)continue;let u=t.indexOf(a),h=u>=0?t.slice(0,u).split(`
54
+ `).length:1;e.push({line:h,rule:s.id,phrase:l.slice(0,160)})}}let n=t.split(`
55
+ `);for(let s=0;s<n.length;s++){let i=vo(n[s]);for(let a of i)a.line=s+1,a.text=n[s].trim().slice(0,240),e.push(a)}let o=[];for(let s=0;s<n.length;s++){let i=n[s].split(/(?<=[.!?])\s+/);for(let a of i){let l=q(a).length;l>0&&o.push({line:s+1,text:a.trim(),wordCount:l})}}for(let s=0;s<o.length-2;s++){let i=o.slice(s,s+3);if(i.every(a=>a.wordCount<=5)){e.push({line:i[0].line,rule:"voice_staccato_triplet",phrase:"three short sentences in a row reads like performance",text:i[0].text});break}}return e.sort((s,i)=>s.line!==i.line?s.line-i.line:s.rule.localeCompare(i.rule))}function Jn(r,e){if(!e.length)return`${r}: no deterministic AI-pattern issues found`;let t=[`${r}: ${e.length} issue(s)`];for(let n of e)t.push(`- line ${n.line}: ${n.rule} - ${n.phrase}`);return t.join(`
56
+ `)}function Kn(r,e){return{path:r,issue_count:e.length,issues:e}}function xo(){let r=Qn.join(Q,"prompt-template.md");try{if(X.existsSync(r))return X.readFileSync(r,"utf-8")}catch{}return`Rewrite only the flagged lines. Do not rewrite the whole piece.
57
+
58
+ Return only valid JSON in this exact shape:
59
+ {{"replacements":[{{"line":1,"text":"replacement line"}}]}}
60
+
61
+ Rules:
62
+ - Include only flagged line numbers.
63
+ - Preserve unflagged lines exactly by not returning them.
64
+ - Preserve the original argument and local meaning.
65
+ - Use the voice profile as the benchmark when present.
66
+ - Remove AI cadence, polished founder cadence, abstract strategy-deck language, and generic lesson shapes.
67
+ - Do not add new sections, hooks, CTAs, markdown, bullets, or commentary.
68
+
69
+ Voice profile:
70
+ {profile_block}
71
+
72
+ Extra constraints:
73
+ {constraints_block}
74
+
75
+ Flagged lines:
76
+ {issue_lines}
77
+
78
+ Draft with line numbers ({draft_name}):
79
+ {numbered_draft}
80
+ `}function Co(r){if(r){let e=ye(r);if(e)return{content:e,name:r}}try{if(!X.existsSync(Y))return null;let e=X.readdirSync(Y).filter(t=>t.endsWith(".md"));if(e.length>0){let t=e[0].replace(".md",""),n=ye(t);if(n)return{content:n,name:t}}}catch{}return null}function Xn(r){let{draftPath:e,draftContent:t,profileName:n,constraints:o="",skipScan:s=!1}=r,i=s?[]:K(t),a=i.length>0?i.map(p=>`- line ${p.line} [${p.rule}]: ${p.phrase}`).join(`
81
+ `):"- none found by deterministic scan",l=Co(n),u=l?l.content:"(no voice profile supplied \u2014 use generic voice rules)",f=t.split(`
82
+ `).map((p,P)=>`${P+1}: ${p}`).join(`
83
+ `);return{prompt:xo().replace("{profile_block}",u).replace("{constraints_block}",o||"(none)").replace("{issue_lines}",a).replace("{draft_name}",e).replace("{numbered_draft}",f),profileUsed:l?.name||null,issuesFound:i.length}}function Zn(r){r.command("rewrite").description("Generate rewrite prompt for LLM").argument("<file>","File to rewrite (or - for stdin)").option("--profile <name>","Voice profile to use").option("--format <type>","Content format (linkedin, blog, email)").option("--constraints <text>","Additional constraints").option("--no-scan","Skip local scan").option("--output <file>","Write prompt to file instead of stdout").action(async(e,t)=>{try{let n,o;e==="-"?(o="stdin",n=Z.readFileSync(0,"utf-8")):(o=Ct.resolve(e),Z.existsSync(o)||(console.error(F.default.red(`File not found: ${o}`)),process.exit(1)),n=Z.readFileSync(o,"utf-8"));let s=Xn({draftPath:o,draftContent:n,profileName:t.profile,format:t.format,constraints:t.constraints,skipScan:t.scan===!1});if(console.log(F.default.dim(`
84
+ Draft: ${o}`)),console.log(F.default.dim(`Profile: ${s.profileUsed||"none (using generic rules)"}`)),console.log(F.default.dim(`Issues found: ${s.issuesFound}`)),s.issuesFound===0){console.log(F.default.green(`
85
+ \u2713 No issues found. Draft looks clean!`));return}console.log(F.default.bold(`
86
+ Issues:`));let i=K(n);for(let a of i.slice(0,10))console.log(F.default.yellow(` Line ${a.line}: [${a.rule}] ${a.phrase}`));if(i.length>10&&console.log(F.default.dim(` ... and ${i.length-10} more`)),t.output){let a=Ct.resolve(t.output);Z.writeFileSync(a,s.prompt),console.log(F.default.green(`
87
+ \u2713 Prompt written to ${a}`))}else console.log(F.default.bold(`
88
+ --- Rewrite Prompt ---
89
+ `)),console.log(s.prompt),console.log(F.default.dim(`
90
+ --- End Prompt ---
91
+ `)),console.log(F.default.dim("Copy this prompt and paste it into your LLM.")),console.log(F.default.dim("Or pipe directly: hyvoice rewrite draft.md | pbcopy"))}catch(n){console.error(F.default.red(`Error: ${n.message}`)),process.exit(1)}})}var k=y(N()),ue=y(require("fs")),Ot=y(require("path"));function Oo(r,e){return r.trim()!==e.trim()}function er(r,e,t,n){let o=t.split(`
92
+ `),s=n.split(`
93
+ `),i=K(t),a=new Set(i.map(g=>g.line)),l={};for(let g of i)l[g.line]||(l[g.line]=[]),l[g.line].push(g.rule);let u={},h={},f={},w=Math.min(o.length,s.length),R=0;for(let g=0;g<w;g++){let U=g+1,_e=Oo(o[g],s[g]),ve=l[U]||[];if(_e){if(R++,ve.length>0)for(let G of ve)u[G]=(u[G]||0)+1;else if(!a.has(U)){let G=o[g].trim();G.length>40&&(f[U]=G.slice(0,240))}}else if(ve.length>0)for(let G of ve)h[G]=(h[G]||0)+1}let p=R>Math.max(1,w*.8),P=q(n),ne=we(n).map(g=>q(g).length).filter(g=>g>0),Ve=ne.length>0?Math.round(ne.reduce((g,U)=>g+U,0)/ne.length*10)/10:0,L=[],v=new Set;for(let g of Object.keys(f).map(Number).sort()){let U=f[g],_e=U.toLowerCase().trim().slice(0,60);if(!v.has(_e)&&(v.add(_e),L.push({line:g,original_text:U}),L.length>=10))break}return{signal_version:"hold-your-voice-signal-v1",session:{original_path:r,accepted_path:e,full_rewrite:p},patterns_accepted:u,patterns_overridden:h,new_removals:L,session_stats:{original_words:q(t).length,accepted_words:P.length,accepted_avg_sentence:Ve,accepted_sentence_count:ne.length}}}function tr(r){let e=[],t=Object.values(r.patterns_accepted).reduce((o,s)=>o+s,0),n=Object.values(r.patterns_overridden).reduce((o,s)=>o+s,0);if(t>0&&e.push(`${t} pattern(s) accepted (fixes applied)`),n>0&&e.push(`${n} pattern(s) overridden (user kept original)`),r.new_removals.length>0&&e.push(`${r.new_removals.length} potential new pattern(s) detected`),t===0&&n===0&&r.new_removals.length===0&&e.push("No significant changes detected"),Object.keys(r.patterns_accepted).length>0){e.push(""),e.push("Accepted patterns:");for(let[o,s]of Object.entries(r.patterns_accepted))e.push(` \u2022 ${o}: ${s} fix(es)`)}if(Object.keys(r.patterns_overridden).length>0){e.push(""),e.push("Overridden patterns (user kept original):");for(let[o,s]of Object.entries(r.patterns_overridden))e.push(` \u2022 ${o}: ${s} time(s)`)}return e.join(`
94
+ `)}function nr(r){r.command("reinforce").description("Send learning signals from edited draft").argument("<original>","Original file").argument("<edited>","Edited file").option("--profile <name>","Voice profile").option("--no-send","Queue signal without sending to server").action(async(e,t,n)=>{try{let o=Ot.resolve(e),s=Ot.resolve(t);ue.existsSync(o)||(console.error(k.default.red(`Original file not found: ${o}`)),process.exit(1)),ue.existsSync(s)||(console.error(k.default.red(`Edited file not found: ${s}`)),process.exit(1));let i=ue.readFileSync(o,"utf-8"),a=ue.readFileSync(s,"utf-8"),l=er(o,s,i,a);if(console.log(k.default.bold(`
95
+ Learning Signal Report
96
+ `)),console.log(tr(l)),n.send===!1)le({type:"reinforce",profile:n.profile,report:l,timestamp:new Date().toISOString()}),console.log(k.default.yellow(`
97
+ Signal queued for later sync.`));else{if(!$()){console.log(k.default.yellow(`
98
+ Not authenticated. Queuing signal for later sync.`)),le({type:"reinforce",profile:n.profile,report:l,timestamp:new Date().toISOString()});return}console.log(k.default.cyan(`
99
+ Sending to server...`)),(await E("https://holdyourvoice.com/cli/learning/reinforce",{method:"POST",body:{profile_id:n.profile,original_text:i,accepted_text:a,signal_report:l}})).status===200?console.log(k.default.green("\u2713 Signal sent successfully")):(console.log(k.default.yellow("Failed to send. Queuing for later sync.")),le({type:"reinforce",profile:n.profile,report:l,timestamp:new Date().toISOString()}))}}catch(o){console.error(k.default.red(`Error: ${o.message}`)),process.exit(1)}}),r.command("add").description("Add a voice instruction").argument("<instruction>","Natural language instruction").option("--profile <name>","Voice profile").action(async(e,t)=>{try{if(!$()){console.log(k.default.yellow("Not authenticated. Queuing instruction for later sync.")),le({type:"add_instruction",profile:t.profile,instruction:e,timestamp:new Date().toISOString()}),console.log(k.default.dim(`Instruction: "${e}"`));return}console.log(k.default.cyan("Adding instruction..."));let o=await E("https://holdyourvoice.com/cli/learning/add",{method:"POST",body:{profile_id:t.profile,instruction:e}});if(o.status===200){let s=o.data;console.log(k.default.green(`
100
+ \u2713 Instruction added`)),console.log(k.default.dim(` "${e}"`)),console.log(k.default.dim(` Confidence: ${s.confidence||.7}`))}else console.log(k.default.yellow("Failed to add. Queuing for later sync.")),le({type:"add_instruction",profile:t.profile,instruction:e,timestamp:new Date().toISOString()})}catch(n){console.error(k.default.red(`Error: ${n.message}`)),process.exit(1)}})}var m=y(N()),he=y(require("fs")),de=y(require("path"));var So=[{key:"tone",question:"How would you describe your tone? (e.g., casual, professional, witty, direct)"},{key:"audience",question:"Who is your audience? (e.g., founders, developers, marketers)"},{key:"personality",question:"If your brand was a person, how would they talk?"},{key:"avoid",question:"What words or phrases do you never use?"},{key:"inspiration",question:"Who writes like you? Any writers you admire?"},{key:"goal",question:"What should reading your content feel like?"},{key:"format",question:"What formats do you write in? (e.g., LinkedIn posts, emails, blog posts)"}],ko={tech:[{key:"technical_depth",question:"How technical do you get? (high-level concepts vs deep code)"},{key:"jargon",question:"Do you use technical jargon or explain everything?"},{key:"opinionated",question:"Do you take strong positions on tools/frameworks?"}],marketing:[{key:"pitch_style",question:"How do you pitch? (soft sell, hard sell, story-based)"},{key:"data_driven",question:"Do you lean on data or emotion?"},{key:"cta_style",question:"How do you end posts? (CTA style)"}],default:[{key:"formality",question:"How formal is your writing?"},{key:"storytelling",question:"Do you use stories/examples often?"},{key:"length",question:"Do you prefer short punchy content or longer pieces?"}]};function Ao(r){let e=r.map(v=>v.text).join(`
101
+
102
+ `),t=q(e),n=we(e),o=Yn(e),s=n.map(v=>q(v).length),i=s.length>0?Math.round(s.reduce((v,g)=>v+g,0)/s.length):0,a=o.map(v=>we(v).length),l=a.length>0?Math.round(a.reduce((v,g)=>v+g,0)/a.length):0,u=i,h=s.length>2?Math.sqrt(s.reduce((v,g)=>v+Math.pow(g-u,2),0)/s.length)/u:0,f=h<.35?"low":h>.85?"high":"medium",w=n.map(v=>{let g=v.trim().match(/[A-Za-z]/);return g?g[0]:""}).filter(Boolean),p=w.filter(v=>v===v.toLowerCase()).length/w.length>.85?"mostly lowercase":"standard",P=n.filter(v=>v.trim().endsWith("?")).length/n.length,te=(e.match(/\b(?:i|we|my|our|me|us)\b/gi)||[]).length,ne=(e.match(/\b(?:but|actually|instead|not|wrong|real|because)\b/gi)||[]).length,Ve=(e.match(/\b\d+(?:\.\d+)?%?\b/g)||[]).length,L="mixed";return P>.18?L="question-led":Ve>=Math.max(4,n.length/10)?L="data-led":te>=Math.max(6,n.length/4)?L="narrative":ne>=Math.max(8,n.length/3)&&(L="contrarian"),{word_count:t.length,sentence_count:n.length,paragraph_count:o.length,avg_sentence_length:i,avg_paragraph_length:l,sentence_variance:f,case_style:p,argument_pattern:L,sample_count:r.length}}function or(r){r.command("new").description("Create a new voice profile").argument("<name>","Profile name").option("--from-samples <dir>","Create from writing samples").option("--from-url <urls>","Scrape blog/URL for writing samples (comma-separated)").option("--from-llm","Generate extraction prompt for LLM").action(async(e,t)=>{try{let n=$();t.fromSamples?await Eo(e,t.fromSamples,n):t.fromUrl?await Po(e,t.fromUrl,n):t.fromLlm?await Ro(e):await $o(e,n)}catch(n){console.error(m.default.red(`
103
+ error: ${n.message}`)),process.exit(1)}})}async function $o(r,e){console.log(m.default.bold(`
104
+ Creating voice profile: ${r}
105
+ `)),console.log(m.default.dim(`Answer these questions to define your voice.
106
+ `));let t={};for(let o of So){let s=await rr(o.question);t[o.key]=s}let n=t.format?.toLowerCase().includes("code")||t.audience?.toLowerCase().includes("developer")?"tech":t.format?.toLowerCase().includes("market")||t.audience?.toLowerCase().includes("market")?"marketing":"default";console.log(m.default.dim(`
107
+ Industry: ${n}
108
+ `));for(let o of ko[n]){let s=await rr(o.question);t[o.key]=s}if(e){console.log(m.default.cyan(`
109
+ Generating profile on server...`));let o=await E("https://holdyourvoice.com/cli/profiles/new",{method:"POST",body:{name:r,answers:t,industry:n}});if(o.status===200){let i=o.data.content||St(r,t);T(),B(r,i),console.log(m.default.green(`
110
+ \u2713 Profile created: ${r}`)),console.log(m.default.dim("Run `hyvoice profiles` to see your profiles."))}else{console.log(m.default.yellow(`
111
+ Server unavailable. Creating local profile...`));let s=St(r,t);T(),B(r,s),console.log(m.default.green(`
112
+ \u2713 Local profile created: ${r}`))}}else{console.log(m.default.yellow(`
113
+ Not authenticated. Creating local profile...`));let o=St(r,t);T(),B(r,o),console.log(m.default.green(`
114
+ \u2713 Local profile created: ${r}`))}}async function Eo(r,e,t){let n=de.resolve(e);if(!he.existsSync(n))throw new Error(`Directory not found: ${n}`);console.log(m.default.bold(`
115
+ Creating voice profile: ${r}`)),console.log(m.default.dim(`Reading samples from: ${n}
116
+ `));let o=he.readdirSync(n).filter(a=>a.endsWith(".md")||a.endsWith(".txt")).map(a=>de.join(n,a));if(o.length===0)throw new Error("No .md or .txt files found in directory");let s=[];for(let a of o){let l=he.readFileSync(a,"utf-8");l.trim().length>0&&(s.push({path:a,text:l}),console.log(m.default.dim(` \u2022 ${de.basename(a)} (${q(l).length} words)`)))}if(s.length===0)throw new Error("No readable text found in files");let i=Ao(s);if(console.log(m.default.dim(`
117
+ Stats extracted:`)),console.log(m.default.dim(` Words: ${i.word_count}`)),console.log(m.default.dim(` Sentences: ${i.sentence_count}`)),console.log(m.default.dim(` Avg sentence: ${i.avg_sentence_length} words`)),console.log(m.default.dim(` Case style: ${i.case_style}`)),console.log(m.default.dim(` Argument pattern: ${i.argument_pattern}`)),t){console.log(m.default.cyan(`
118
+ Generating profile on server...`));let a=await E("https://holdyourvoice.com/cli/profiles/new",{method:"POST",body:{name:r,samples:s.map(l=>({path:l.path,text:l.text.slice(0,4e3)})),stats:i}});if(a.status===200){let l=a.data;T(),B(r,l.content||kt(r,i)),console.log(m.default.green(`
119
+ \u2713 Profile created: ${r}`))}else console.log(m.default.yellow(`
120
+ Server unavailable. Creating local profile...`)),T(),B(r,kt(r,i)),console.log(m.default.green(`
121
+ \u2713 Local profile created: ${r}`))}else console.log(m.default.yellow(`
122
+ Not authenticated. Creating local profile...`)),T(),B(r,kt(r,i)),console.log(m.default.green(`
123
+ \u2713 local profile created: ${r}`));await sr(t)}async function Po(r,e,t){let n=e.split(",").map(o=>o.trim()).filter(Boolean);if(console.log(m.default.bold(`
124
+ creating voice profile: ${r}`)),console.log(m.default.dim(`scraping: ${n.join(", ")}
125
+ `)),t){console.log(m.default.cyan("scraping urls on server..."));let o=await E("https://holdyourvoice.com/cli/onboarding/scrape",{method:"POST",body:{name:r,urls:n}});if(o.status===200){let s=o.data,i=s.samples_found||0,a=s.words_found||0;if(i===0){console.log(m.default.yellow(`
126
+ couldn't extract any content from those urls`)),console.log(m.default.dim("try: a blog homepage, substack, or medium profile")),console.log(m.default.dim("or: hyv new <name> --from-samples ./my-writing/"));return}console.log(m.default.green(`
127
+ \u2713 found ${i} articles, ~${a} words`)),console.log(m.default.green(`\u2713 profile created: ${r}`))}else console.log(m.default.red(`
128
+ error: server returned ${o.status}`))}else console.log(m.default.yellow(`
129
+ not authenticated. url scraping requires a server connection.`)),console.log(m.default.dim("run: hyv init"));await sr(t)}async function sr(r){if(r){try{let e=await E("https://holdyourvoice.com/cli/heartbeat",{method:"GET"});if(e.status===200){let t=e.data,n=(t.plan||"none").toLowerCase(),o=t.status||"none";n==="none"||o==="none"?(console.log(""),console.log(m.default.bold("last step \u2014 unlock everything for just $1:")),console.log(""),console.log(m.default.cyan(" hyv plan --upgrade")),console.log(""),console.log(m.default.dim("first month is $1, then $9/month. cancel anytime."))):(console.log(""),console.log(m.default.bold("you're all set! try it out:")),console.log(""),console.log(m.default.cyan(" hyv scan draft.md")+m.default.dim(" \u2014 check a draft")),console.log(m.default.cyan(" hyv rewrite draft.md")+m.default.dim(" \u2014 get rewrite prompt")),console.log(m.default.dim(' or say "rewrite in my voice" in any connected agent')))}}catch{}console.log("")}}async function Ro(r){console.log(m.default.bold(`
130
+ Generating extraction prompt for: ${r}
131
+ `));let e=`I need you to analyze writing samples and create a voice profile.
132
+
133
+ Please provide:
134
+ 1. 8-10 voice keywords with descriptions
135
+ 2. Writing signature (sentence length, rhythm, opening moves)
136
+ 3. 3 anchor passages that capture the voice
137
+ 4. Never list (phrases to avoid)
138
+ 5. Voice rules
139
+
140
+ Save the output as a markdown file, then run:
141
+ hyvoice import ${r} <file.md>
142
+
143
+ Or paste the profile content and I'll save it.`;console.log(e)}function rr(r){return new Promise(e=>{let n=require("readline").createInterface({input:process.stdin,output:process.stdout});n.question(m.default.cyan(` ${r}
144
+ > `),o=>{n.close(),e(o.trim())})})}function St(r,e){return`# Voice Profile: ${r}
145
+
146
+ ## Tone & Style
147
+ - **Tone:** ${e.tone||"Not specified"}
148
+ - **Audience:** ${e.audience||"General"}
149
+ - **Personality:** ${e.personality||"Direct and clear"}
150
+
151
+ ## Keywords
152
+ - ${e.tone||"direct"}
153
+ - ${e.audience?`for ${e.audience}`:"clear"}
154
+ - ${e.goal||"engaging"}
155
+
156
+ ## Never List
157
+ ${e.avoid?e.avoid.split(",").map(t=>`- ${t.trim()}`).join(`
158
+ `):`- here's the thing
159
+ - let's be honest
160
+ - at the end of the day`}
161
+
162
+ ## Format Preferences
163
+ - **Formats:** ${e.format||"General"}
164
+ - **Inspiration:** ${e.inspiration||"None specified"}
165
+
166
+ ## Voice Rules
167
+ 1. Open from concrete observations
168
+ 2. Keep natural rhythm
169
+ 3. Avoid AI-pattern language
170
+ 4. Be specific, not abstract
258
171
 
259
172
  ---
260
- MY WRITING SAMPLES:
261
-
262
- [paste your writing samples here \u2014 blog posts, tweets, emails, essays, any prose that represents your voice]`;async function Uo(n){console.log(`
263
- ${E()} ${h.dim("onboarding \u2014 llm extract")}
264
- `);let e="my-voice";if(!n.json){let r=ue();e=await _s(r,"my-voice"),r.close(),console.log(` ${h.dim(`using profile name: ${e}`)}
265
- `)}console.log(` ${h.dim("this generates a prompt you paste into any LLM.")}`),console.log(` ${h.dim("then paste the LLM's response back here.")}
266
- `),console.log(` ${h.bold("\u2500\u2500 copy this prompt \u2500\u2500".padEnd(60,"\u2500"))}`),console.log(""),console.log(Hh),console.log(""),console.log(` ${"\u2500".repeat(60)}`),console.log("");let t=ue();if(!await Li(t,"ready to paste the llm response?")){t.close(),console.log(` ${h.dim("cancelled")}
267
- `);return}console.log("");let i=await Dh(t,"paste the llm's response below:");if(t.close(),!i.trim()){console.log(`
268
- ${h.red("\u2717")} empty response`),process.exit(1);return}console.log(""),console.log(` ${h.dim("creating profile from llm response...")}`);try{let r=await T("/cli/onboarding/extract",{llm_response:i,name:e}),o=r.profile?.name||e;n.json?console.log(JSON.stringify({ok:!0,profile:r.profile})):(await ot(),Nt(o))}catch(r){n.json?console.log(JSON.stringify({error:r.message})):console.log(`
269
- ${h.red("\u2717")} ${r.message}`),process.exit(1)}}async function qh(n){let e=ue();console.log(`
270
- ${E()} ${h.dim("onboarding")}
271
- `),console.log(` ${h.bold("how do you want to create your voice profile?")}
272
- `),console.log(` ${h.dim("1.")} answer questions ${h.dim("(quick start, ~2 min)")}`),console.log(` ${h.dim("2.")} point to a blog or url ${h.dim("(we scrape your writing)")}`),console.log(` ${h.dim("3.")} upload from a local folder ${h.dim("(.md and .txt files)")}`),console.log(` ${h.dim("4.")} extract from any llm ${h.dim("(paste a prompt + samples)")}`),console.log("");let t=await Ae(e,` ${h.bold("pick one:")} ${h.dim("(1-4)")} `);switch(e.close(),t){case"1":await Ho(n);break;case"2":{let s=ue(),i=await Ae(s,`
273
- ${h.bold("enter url(s), comma-separated:")} `);s.close();let r=i.split(",").map(o=>o.trim()).filter(Boolean);await qo(r,n);break}case"3":{let s=ue(),i=await Ae(s,`
274
- ${h.bold("path to folder:")} `);s.close(),await Bo(i,n);break}case"4":await Uo(n);break;default:console.log(`
275
- ${h.red("\u2717")} invalid choice. run ${h.dim("hyv onboard --help")} for options.
276
- `),process.exit(1)}}async function zo(n){try{await k("/cli/heartbeat")}catch{n.json?console.log(JSON.stringify({error:"Not signed in. Run: hyv init"})):(console.log(`
277
- ${h.red("\u2717")} you need to sign in first
278
- `),console.log(` run: ${h.cyan("hyv init")}
279
- `)),process.exit(1);return}try{let e=await k("/cli/profiles");if(e.profiles?.length>0&&!n.analyze){let t=ue(),s=await Li(t,`you already have ${e.profiles.length} profile(s). create another?`,!1);if(t.close(),!s){console.log(` ${h.dim("cancelled")}
280
- `);return}}}catch{}if(n.questions)await Ho(n);else if(n.url){let e=n.url.split(",").map(t=>t.trim()).filter(Boolean);await qo(e,n)}else if(n.folder)await Bo(n.folder,n);else if(n.extract)await Uo(n);else if(n.analyze){console.log(`
281
- ${E()} ${h.dim("analyzing voice patterns...")}
282
- `);try{let e=await T("/cli/onboarding/analyze",{}),t=e.profile?.name||"my-voice";n.json?console.log(JSON.stringify({ok:!0,profile:e.profile})):(await ot(),Nt(t))}catch(e){console.log(` ${h.red("\u2717")} ${e.message}`),process.exit(1)}}else await qh(n)}var at=_(require("fs")),Wi=_(require("path")),Go=_(require("os"));V();var Di=Wi.join(Go.homedir(),".hyv"),Bh=Wi.join(Di,"voice.md");async function Uh(){try{at.existsSync(Di)||at.mkdirSync(Di,{recursive:!0});let e=(await k("/cli/profiles")).profiles||[];if(e.length===0)return;let t=[`# Voice Profile
283
- `];for(let s of e)t.push(`## ${s.name}${s.is_default?" (default)":""}`),s.brand&&t.push(`Brand: ${s.brand}`),s.description&&t.push(s.description),s.keywords?.length&&t.push(`Keywords: ${s.keywords.join(", ")}`),t.push("");at.writeFileSync(Bh,t.join(`
284
- `))}catch{}}async function Vi(n,e){if(!n||n.trim()===""){e.json?console.log(JSON.stringify({error:"No name provided"})):(console.log(`
285
- ${h.red("\u2717")} what do you want to name your profile?
286
- `),console.log(` ${h.dim("example:")} hyv rename "my brand voice"
287
- `)),process.exit(1);return}let t=n.trim();if(t.length>100){e.json?console.log(JSON.stringify({error:"Name too long (max 100 characters)"})):console.log(`
288
- ${h.red("\u2717")} name is too long \u2014 keep it under 100 characters
289
- `),process.exit(1);return}let s;try{s=(await k("/cli/profiles")).profiles||[]}catch(r){e.json?console.log(JSON.stringify({error:r.message})):console.log(`
290
- ${h.red("\u2717")} ${r.message}
291
- `),process.exit(1);return}if(s.length===0){e.json?console.log(JSON.stringify({error:"No voice profiles found"})):(console.log(`
292
- ${h.red("\u2717")} you don't have a voice profile yet
293
- `),console.log(` create one: ${h.cyan("hyv onboard")}
294
- `)),process.exit(1);return}let i;if(e.profile)i=e.profile;else if(s.length===1)i=s[0].slug||s[0].id;else{let r=s.find(o=>o.is_default);if(r)i=r.slug||r.id;else{e.json?console.log(JSON.stringify({error:"Multiple profiles found. Specify which one with: hyv rename <name> --profile <profile-slug>"})):(console.log(`
295
- ${h.red("\u2717")} you have multiple profiles \u2014 which one do you want to rename?
296
- `),console.log(` ${h.dim("example:")} hyv rename "${t}" --profile <profile-slug>`),console.log(` ${h.dim("your profiles:")} ${s.map(o=>o.slug||o.name).join(", ")}
297
- `)),process.exit(1);return}}try{let r=await T("/cli/profiles/rename",{slug_or_id:i,new_name:t});e.json?console.log(JSON.stringify({ok:!0,profile:r.profile})):(await Uh(),console.log(`
298
- ${E()} ${h.dim("rename")}
299
- `),console.log(` ${h.green("\u2713")} profile renamed to ${h.bold(r.profile?.name||t)}`),console.log(` ${h.green("\u2713")} voice.md updated
300
- `))}catch(r){e.json?console.log(JSON.stringify({error:r.message})):console.log(`
301
- ${h.red("\u2717")} ${r.message}
302
- `),process.exit(1)}}function zh(n){let e=n.toLowerCase().trim(),t=n.trim(),s=[/rename\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:to|as)\s+(.+)/i,/update\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i,/change\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i,/call\s+(?:my\s+)?(?:voice\s+)?profile\s+(.+)/i,/set\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i,/name\s+(?:my\s+)?(?:voice\s+)?profile\s+(.+)/i,/(?:voice\s+)?profile\s+(?:rename|name)\s+(?:to|as)\s+(.+)/i,/rename\s+(?:to|as)\s+(.+)/i,/update\s+(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i];for(let i of s){let r=t.match(i);if(r&&r[1]){let o=r[1].trim();if((o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),o=o.replace(/[.!?]+$/,"").trim(),o.length>0&&o.length<=100)return{action:"rename",name:o,raw:t}}}return{action:"unknown",raw:t}}async function Jo(n,e){if(!n||n.trim()===""){e.json?console.log(JSON.stringify({error:"No input provided"})):(console.log(`
303
- ${h.red("\u2717")} no input provided`),console.log(` ${h.dim("usage:")} hyv say "rename my profile to cristiano ronaldo"`),console.log(` ${h.dim(' hyv say "update my voice profile name to brand voice"')}
304
- `)),process.exit(1);return}let t=zh(n);if(e.json){console.log(JSON.stringify({intent:t})),t.action==="unknown"&&process.exit(1);return}switch(t.action){case"rename":t.name&&await Vi(t.name,{json:e.json});break;case"unknown":default:console.log(`
305
- ${h.yellow("!")} I didn't catch that
306
- `),console.log(` ${h.dim("try:")} hyv say "rename my profile to <name>"`),console.log(` ${h.dim("or:")} hyv rename <new-name>
307
- `),process.exit(1);break}}var lt=_(require("fs")),qi=_(require("path")),Es=_(require("os"));var Yo=qi.join(Es.homedir(),".hyv","voice.md");function Hi(n,e){return JSON.stringify({jsonrpc:"2.0",id:n,result:e})}function Gh(n,e,t){return JSON.stringify({jsonrpc:"2.0",id:n,error:{code:e,message:t}})}function Cs(n){process.stdout.write(n+`
308
- `)}async function Jh(n){let e=n.text||"",t=n.profile||rt()||"default";if(!e.trim())return"Error: no text provided";try{let s=await nt(t),i=Ie(e,s),r=ws(i),o=e;if(r.autoFixes.length>0&&(o=vs(e,r.issues).fixed),r.llmFixes.length>0){let a=Ss(s,o,r,i,1);return`Auto-fixed ${r.autoFixes.length} issues. ${r.llmFixes.length} issues need LLM rewrite.
173
+ *Created via hyvoice onboarding*
174
+ `}function kt(r,e){return`# Voice Profile: ${r}
175
+
176
+ ## Voice Stats
177
+ - **Word count analyzed:** ${e.word_count}
178
+ - **Sentence count:** ${e.sentence_count}
179
+ - **Average sentence length:** ${e.avg_sentence_length} words
180
+ - **Sentence variance:** ${e.sentence_variance}
181
+ - **Case style:** ${e.case_style}
182
+ - **Argument pattern:** ${e.argument_pattern}
183
+
184
+ ## Signature
185
+ - Sentences average ${e.avg_sentence_length} words
186
+ - ${e.sentence_variance} variance in sentence length
187
+ - ${e.avg_paragraph_length} sentences per paragraph
188
+ - ${e.case_style} casing
189
+ - ${e.argument_pattern} argument structure
190
+
191
+ ## Voice Rules
192
+ 1. Match the sentence rhythm (${e.avg_sentence_length} words avg)
193
+ 2. Maintain ${e.sentence_variance} variance
194
+ 3. Use ${e.argument_pattern} argument pattern
195
+ 4. ${e.case_style==="mostly lowercase"?"Use lowercase for casual tone":"Use standard sentence case"}
309
196
 
310
- ${a}`}return o}catch(s){return`Error: ${s.message}`}}async function Yh(n){let e=n.text||"",t=n.file||"";if(!e.trim()&&!t.trim())return"Error: no text or file provided";try{if(t){let{results:i,summary:r}=await Pt([t]),o=i.flatMap(a=>a.findings.map(l=>`line ${l.line}: [${l.severity}] ${l.pattern} \u2014 ${l.excerpt}`));return o.length===0?`No issues found in ${t}`:`Found ${o.length} issues:
311
- ${o.join(`
312
- `)}`}let s=qi.join(Es.tmpdir(),`hyv-scan-${Date.now()}.md`);lt.writeFileSync(s,e);try{let{results:i,summary:r}=await Pt([s]),o=i.flatMap(a=>a.findings.map(l=>`line ${l.line}: [${l.severity}] ${l.pattern} \u2014 ${l.excerpt}`));return o.length===0?"No AI patterns found":`Found ${o.length} issues:
313
- ${o.join(`
314
- `)}`}finally{try{lt.unlinkSync(s)}catch{}}}catch(s){return`Error: ${s.message}`}}async function Kh(n){try{let{apiGet:e}=await Promise.resolve().then(()=>(V(),zt)),s=(await e("/cli/profiles")).profiles||[];return s.length===0?"No voice profiles found. Create one at holdyourvoice.com or run: hyv new <name>":s.map(i=>`${i.name}${i.is_default?" (default)":""}${i.keywords?.length?" \u2014 "+i.keywords.slice(0,3).join(", "):""}`).join(`
315
- `)}catch(e){return`Error: ${e.message}`}}async function Xh(n){let e=n.text||"",t=n.profile||rt()||"default";if(!e.trim())return"Error: no text provided";try{let s=await nt(t),i=$s(e,e,s),r=[`Score: ${i.score}/100`];return i.cadenceScore&&r.push(`Cadence: ${i.cadenceScore}/100`),i.neverListHits.length&&r.push(`Never-list hits: ${i.neverListHits.join(", ")}`),i.valid?r.push("PASS"):r.push("NEEDS IMPROVEMENT"),i.issues.length&&r.push(`Issues:
316
- ${i.issues.map(o=>` - ${o}`).join(`
317
- `)}`),r.join(`
318
- `)}catch(s){return`Error: ${s.message}`}}var Zh=[{name:"hyv_rewrite",description:`Rewrite text to match the user's voice profile. Auto-fixes AI patterns and generates a prompt for remaining issues. Use when the user says "rewrite in my voice" or wants text rewritten.`,inputSchema:{type:"object",properties:{text:{type:"string",description:"The text to rewrite"},profile:{type:"string",description:"Voice profile name (optional, uses default if omitted)"}},required:["text"]}},{name:"hyv_scan",description:"Scan text or a file for AI writing patterns and voice drift. Returns a list of issues found.",inputSchema:{type:"object",properties:{text:{type:"string",description:"Inline text to scan"},file:{type:"string",description:"Path to a .md file to scan"}}}},{name:"hyv_profiles",description:"List the user's voice profiles. Use before rewriting to pick the right profile.",inputSchema:{type:"object",properties:{}}},{name:"hyv_validate",description:"Validate text against a voice profile. Returns a score and list of remaining issues.",inputSchema:{type:"object",properties:{text:{type:"string",description:"Text to validate"},profile:{type:"string",description:"Voice profile name (optional)"}},required:["text"]}}];async function Qh(n){let e;try{e=JSON.parse(n)}catch{return}let{id:t,method:s,params:i}=e;switch(s){case"initialize":Cs(Hi(t,{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"hyv",version:"0.6.0"}}));break;case"notifications/initialized":break;case"tools/list":Cs(Hi(t,{tools:Zh}));break;case"tools/call":{let r=i?.name,o=i?.arguments||{},a;try{switch(r){case"hyv_rewrite":a=await Jh(o);break;case"hyv_scan":a=await Yh(o);break;case"hyv_profiles":a=await Kh(o);break;case"hyv_validate":a=await Xh(o);break;default:a=`Unknown tool: ${r}`;break}}catch(l){a=`Error: ${l.message}`}Cs(Hi(t,{content:[{type:"text",text:a}]}));break}default:t!==void 0&&Cs(Gh(t,-32601,`Method not found: ${s}`));break}}function Ko(){lt.existsSync(Yo)?process.stderr.write(`[hyv-mcp] voice profile: ${Yo}
319
- `):process.stderr.write(`[hyv-mcp] no voice.md found \u2014 run hyv init first
320
- `);let n="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",e=>{n+=e;let t=n.split(`
321
- `);n=t.pop()||"";for(let s of t)s.trim()&&Qh(s.trim()).catch(i=>{process.stderr.write(`[hyv-mcp] error: ${i.message}
322
- `)})}),process.stdin.on("end",()=>{process.exit(0)}),process.stderr.write(`[hyv-mcp] server started
323
- `)}var Bi="0.7.2",Xo="@holdyourvoice/hyv";(async()=>{try{let n=Number(process.env._HYV_UPDATE_CHECK||"0"),e=Date.now();if(e-n<864e5)return;process.env._HYV_UPDATE_CHECK=String(e);let t=await fetch(`https://registry.npmjs.org/${Xo}/latest`,{signal:AbortSignal.timeout(3e3)});if(!t.ok)return;let s=await t.json();s.version&&s.version!==Bi&&(console.log(`
324
- ${h.yellow("\u2B06")} update available: ${h.dim(Bi)} \u2192 ${h.green(s.version)}`),console.log(` ${h.dim("run:")} npm i -g ${Xo}
325
- `))}catch{}})();var W=new on;W.name("hyv").description("hold your voice \u2014 voice gate layer for ai workflows").version(Bi);W.command("init").description("authenticate and set up your project").option("-p, --profile <name>","set default voice profile").option("-k, --key <key>","use a license key directly").option("-q, --quiet","minimal output (for CI)").action(n=>cr(n.profile,{key:n.key,quiet:n.quiet}));W.command("scan").description("scan local .md files for ai patterns and voice drift").argument("[paths...]","files or directories to scan").option("--json","output as json").option("--fail-on-hit","exit with code 1 if issues found").action((n,e)=>yo(n,e));W.command("rewrite").description("generate a rewrite prompt for your ai agent").argument("[profile-or-file]","voice profile name or .md file").argument("[file]",".md file to rewrite").option("-o, --output <file>","write prompt to file instead of stdout").option("-t, --text <text>","inline text to rewrite (instead of file/stdin)").option("--json","output as json").action((n,e,t)=>Ao(n,e,t));W.command("profiles").description("list your voice profiles").option("--json","output as json").action(n=>Ro(n));W.command("status").description("show account and cli status").option("--json","output as json").option("-q, --quiet","minimal output (for CI)").action(n=>Po(n));W.command("reinforce").description("send learning signals from an edited draft").argument("<original>","original .md file").argument("<edited>","edited .md file").option("--json","output as json").action((n,e,t)=>To(n,e,t));W.command("add").description("add a writing sample to your voice profile").argument("<file>",".md file to add as sample").option("-p, --profile <name>","target profile").option("--json","output as json").action((n,e)=>Mo(n,e));W.command("validate").description("validate text against your voice profile").argument("[file]",".md file to validate").option("-p, --profile <name>","voice profile to validate against").option("-t, --text <text>","inline text to validate").option("--json","output as json").action((n,e)=>Fo(n,e));W.command("export").description("export voice profile as system prompt for AI apps").argument("<format>","target format: claude, chatgpt, generic, cursor").option("-o, --output <file>","write to file (use {name} for profile name)").option("--json","output as json").action((n,e)=>Io(n,e));W.command("plan").description("show or manage your subscription").option("--upgrade","open checkout to upgrade").option("--manage","open billing portal").option("--json","output as json").action(n=>Lo(n));W.command("onboard").description("create your voice profile (questions, url scrape, folder, or llm extract)").option("--questions","answer questions to build profile").option("--url <urls>","comma-separated urls to scrape for writing samples").option("--folder <path>","path to a folder of .md/.txt files to upload").option("--extract","generate a prompt to extract voice from any llm").option("--analyze","re-analyze uploaded samples to build/update profile").option("--json","output as json").action(n=>zo(n));W.command("rename").description("rename a voice profile").argument("<new-name>","new name for the profile").option("-p, --profile <slug>","specific profile to rename (uses default if only one exists)").option("--json","output as json").action((n,e)=>Vi(n,e));W.command("say").description('natural language commands (e.g., "rename my profile to X")').argument("<input>","natural language command").option("--json","output as json").action((n,e)=>Jo(n,e));W.command("mcp").description("start MCP server (for Claude Desktop and other MCP hosts)").option("--setup-chatgpt","open ChatGPT connector settings to add HYV").action(async n=>{if(n.setupChatgpt){let e=(await Promise.resolve().then(()=>_(We()))).default;console.log(`
326
- ${E()} ${h.dim("chatgpt setup")}
327
- `),console.log(" opening chatgpt connector settings..."),console.log(` ${h.dim("add this server url:")} ${h.cyan("https://holdyourvoice.com/mcp")}`),console.log(` ${h.dim('authentication: select "OAuth" or "API Key"')}`),console.log(` ${h.dim("your CLI key will be used for auth")}
328
- `),await e("https://chatgpt.com/#settings/Connectors");return}Ko()});W.command("learn").description("manage learning signals").option("--sync","sync pending learning events to server").option("--consolidate","consolidate old learnings into summary").option("--stats","show learning statistics").option("--show","show consolidated learnings").option("--suggestions","show proactive suggestions").option("--dismiss <ruleId>","dismiss a suggestion").option("--json","output as json").action(async n=>{if(n.sync){console.log(`
329
- ${E()} ${h.dim("learn sync")}
330
- `);let s=await go();console.log(` ${h.green("\u2713")} synced ${s.synced} events`),s.errors>0&&console.log(` ${h.yellow("\u26A0")} ${s.errors} errors`);return}if(n.consolidate){console.log(`
331
- ${E()} ${h.dim("learn consolidate")}
332
- `),console.log(` ${h.dim("consolidating old learnings...")}`);let s=await fo();console.log(` ${h.green("\u2713")} consolidated ${s.consolidated} events`);return}if(n.show){let s=po();s?(console.log(`
333
- ${E()} ${h.dim("consolidated learnings")}
334
- `),console.log(s)):(console.log(`
335
- ${h.dim("no consolidated learnings yet")}`),console.log(` ${h.dim("run:")} hyv learn --consolidate`));return}if(n.dismiss){ho(n.dismiss),console.log(` ${h.green("\u2713")} dismissed suggestion for ${h.bold(n.dismiss)}`);return}if(n.suggestions){let s=Mt();if(s.length===0){console.log(`
336
- ${h.dim("no suggestions yet \u2014 keep scanning!")}
337
- `);return}console.log(`
338
- ${E()} ${h.dim("suggestions")}
339
- `);for(let i of s)console.log(` ${h.yellow("\u2192")} ${i.suggestion}`),console.log(` ${h.dim("dismiss:")} hyv learn --dismiss ${i.ruleId}`);console.log("");return}let e=mo();if(n.json){console.log(JSON.stringify(e,null,2));return}console.log(`
340
- ${E()} ${h.dim("learn stats")}
341
- `),console.log(` ${h.bold("Pending:")} ${e.total} events`);for(let[s,i]of Object.entries(e.byType))console.log(` ${s}: ${i}`);e.lastSync&&console.log(` ${h.dim("Last sync:")} ${e.lastSync}`);let t=Mt();t.length>0&&console.log(`
342
- ${h.yellow("\u{1F4A1}")} ${t.length} suggestions \u2014 run ${h.dim("hyv learn --suggestions")}`)});W.parse();
197
+ ---
198
+ *Created from ${e.sample_count} sample(s) via hyvoice*
199
+ `}var b=y(N());var At=y(vt());function ir(r){r.command("plan").description("Manage subscription").option("--upgrade","Upgrade plan").option("--manage","Open billing portal").option("--downgrade","Downgrade plan").action(async e=>{try{$()||(console.log(b.default.yellow("Not authenticated. Run `hyvoice init` first.")),process.exit(1)),e.upgrade?await Io():e.manage?await Fo():e.downgrade?await Ho():await To()}catch(t){console.error(b.default.red(`
200
+ Error: ${t.message}`)),process.exit(1)}})}async function To(){console.log(b.default.bold(`
201
+ Subscription Plan
202
+ `));let r=await E("https://holdyourvoice.com/cli/heartbeat",{method:"GET"});if(r.status!==200){console.log(b.default.yellow("Could not fetch plan info."));return}let e=r.data,t=e.plan||"none",n=e.license,o={none:"No Plan",individual:"Individual",team:"Team",agency:"Agency"},s={none:"-",individual:"$9/mo",team:"$29/mo",agency:"Custom"};console.log(b.default.dim("Plan:"),b.default.bold(o[t]||t)),console.log(b.default.dim("Price:"),s[t]||"-"),console.log(b.default.dim("Status:"),e.subscription_status||"none"),n&&console.log(b.default.dim("License:"),n.key_hint),t==="none"?(console.log(`
203
+ You don't have an active subscription.`),console.log(b.default.dim("Run `hyvoice plan --upgrade` to subscribe."))):(console.log(`
204
+ Manage your subscription:`),console.log(b.default.dim(" hyvoice plan --manage")))}async function Io(){console.log(b.default.cyan(`
205
+ Opening checkout...
206
+ `));let r=await E("https://holdyourvoice.com/cli/subscribe",{method:"POST",body:{plan:"individual"}});if(r.status===200){let t=r.data.checkout_url;t?(console.log(b.default.dim("Opening browser...")),await(0,At.default)(t),console.log(b.default.green(`
207
+ \u2713 Checkout opened in browser`)),console.log(b.default.dim("Complete the checkout to activate your plan."))):console.log(b.default.yellow("No checkout URL received."))}else console.log(b.default.yellow("Could not create checkout session.")),console.log(b.default.dim("Visit https://holdyourvoice.com/pricing to subscribe."))}async function Fo(){console.log(b.default.cyan(`
208
+ Opening billing portal...
209
+ `));let r=await E("https://holdyourvoice.com/cli/subscribe/manage",{method:"POST"});if(r.status===200){let t=r.data.portal_url;t?(console.log(b.default.dim("Opening browser...")),await(0,At.default)(t),console.log(b.default.green(`
210
+ \u2713 Billing portal opened`))):console.log(b.default.yellow("No portal URL received."))}else console.log(b.default.yellow("Could not open billing portal.")),console.log(b.default.dim("Visit https://holdyourvoice.com/app/settings to manage billing."))}async function Ho(){console.log(b.default.yellow(`
211
+ Downgrade Plan
212
+ `)),console.log("To downgrade your plan, please visit:"),console.log(b.default.dim(" https://holdyourvoice.com/app/settings")),console.log(`
213
+ Or contact support at shashank@holdyourvoice.com`)}var V=y(N()),ee=y(require("fs")),ar=y(require("path"));function lr(r){r.command("scan").description("Scan text for voice issues").argument("<file>","File to scan (or - for stdin)").option("--format <type>","Output format (text or json)","text").option("--fail-on-hit","Exit with code 2 if issues found").option("--ignore <rules>","Comma-separated rules to ignore").action(async(e,t)=>{try{let n,o;if(e==="-")o="stdin",process.stdin.isTTY&&(console.error(V.default.red("No input provided. Pipe content or specify a file.")),console.log(V.default.dim('Example: echo "text" | hyvoice scan -')),console.log(V.default.dim("Example: hyvoice scan draft.md")),process.exit(1)),n=ee.readFileSync(0,"utf-8");else{o=ar.resolve(e),ee.existsSync(o)||(console.error(V.default.red(`File not found: ${o}`)),console.log(V.default.dim("Check the file path and try again.")),process.exit(1));let a=ee.statSync(o);a.isDirectory()&&(console.error(V.default.red(`${o} is a directory, not a file.`)),console.log(V.default.dim("Specify a file: hyvoice scan draft.md")),process.exit(1)),a.size>5e5&&console.warn(V.default.yellow(`Warning: Large file (${Math.round(a.size/1024)}KB). Scanning may be slow.`)),n=ee.readFileSync(o,"utf-8")}n.trim()||(console.warn(V.default.yellow("File is empty or contains only whitespace.")),process.exit(0));let s=t.ignore?new Set(t.ignore.split(",").map(a=>a.trim())):new Set,i=K(n);s.size>0&&(i=i.filter(a=>!s.has(a.rule))),t.format==="json"?console.log(JSON.stringify(Kn(o,i),null,2)):console.log(Jn(o,i)),t.failOnHit&&i.length>0&&process.exit(2)}catch(n){console.error(V.default.red(`Error: ${n.message}`)),process.exit(1)}})}var A=y(N());function cr(r){r.command("rename").description("rename a voice profile").argument("<new-name>","new name for the profile").option("-p, --profile <slug>","specific profile to rename").action(async(e,t)=>{try{let n=e.trim();if(!n){console.log(A.default.red(`
214
+ error: what do you want to name your profile?
215
+ `)),console.log(A.default.dim(` example: hyv rename "my brand voice"
216
+ `)),process.exit(1);return}if(n.length>100){console.log(A.default.red(`
217
+ error: name is too long \u2014 keep it under 100 characters
218
+ `)),process.exit(1);return}if(!$()){console.log(A.default.red(`
219
+ error: you're not signed in yet
220
+ `)),console.log(A.default.dim(` run: hyv init
221
+ `)),process.exit(1);return}let s=await E("https://holdyourvoice.com/cli/profiles/rename",{method:"POST",body:{slug_or_id:t.profile||"default",new_name:n}});if(s.status===200){let i=s.data;console.log(A.default.green(`
222
+ \u2713 profile renamed to ${i.profile?.name||n}
223
+ `))}else console.log(A.default.red(`
224
+ error: server returned ${s.status}
225
+ `))}catch(n){console.error(A.default.red(`
226
+ error: ${n.message}
227
+ `)),process.exit(1)}})}function ur(r){r.command("say").description('natural language commands (e.g., "rename my profile to X")').argument("<input>","natural language command").action(async e=>{let t=e.trim();if(!t){console.log(A.default.red(`
228
+ error: no input provided
229
+ `)),console.log(A.default.dim(` try: hyv say "rename my profile to <name>"
230
+ `)),process.exit(1);return}let n=jo(t);switch(n.action){case"rename":if(n.name){if(!$()){console.log(A.default.red(`
231
+ error: you're not signed in yet
232
+ `)),console.log(A.default.dim(` run: hyv init
233
+ `)),process.exit(1);return}let s=await E("https://holdyourvoice.com/cli/profiles/rename",{method:"POST",body:{slug_or_id:"default",new_name:n.name}});if(s.status===200){let i=s.data;console.log(A.default.green(`
234
+ \u2713 profile renamed to ${i.profile?.name||n.name}
235
+ `))}else console.log(A.default.red(`
236
+ error: server returned ${s.status}
237
+ `))}break;case"unknown":default:console.log(A.default.yellow(`
238
+ ! i didn't catch that
239
+ `)),console.log(A.default.dim(' try: hyv say "rename my profile to <name>"')),console.log(A.default.dim(` or: hyv rename <new-name>
240
+ `)),process.exit(1);break}})}function jo(r){let e=r.trim(),t=[/rename\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:to|as)\s+(.+)/i,/update\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i,/change\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i,/call\s+(?:my\s+)?(?:voice\s+)?profile\s+(.+)/i,/set\s+(?:my\s+)?(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i,/name\s+(?:my\s+)?(?:voice\s+)?profile\s+(.+)/i,/(?:voice\s+)?profile\s+(?:rename|name)\s+(?:to|as)\s+(.+)/i,/rename\s+(?:to|as)\s+(.+)/i,/update\s+(?:voice\s+)?profile\s+(?:name\s+)?(?:to|as)\s+(.+)/i];for(let n of t){let o=e.match(n);if(o&&o[1]){let s=o[1].trim();if((s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1)),s=s.replace(/[.!?]+$/,"").trim(),s.length>0&&s.length<=100)return{action:"rename",name:s,raw:e}}}return{action:"unknown",raw:e}}var $t="0.7.3",hr="@holdyourvoice/hyv";(async()=>{try{let r=Number(process.env._HYV_UPDATE_CHECK||"0"),e=Date.now();if(e-r<864e5)return;process.env._HYV_UPDATE_CHECK=String(e);let t=await fetch(`https://registry.npmjs.org/${hr}/latest`,{signal:AbortSignal.timeout(3e3)});if(!t.ok)return;let n=await t.json();n.version&&n.version!==$t&&(console.log(`
241
+ ${c.yellow("\u2B06")} update available: ${c.dim($t)} \u2192 ${c.green(n.version)}`),console.log(` ${c.dim("run:")} npm i -g ${hr}
242
+ `))}catch{}})();var H=new Wt;H.name("hyv").description("hold your voice \u2014 voice gate layer for ai workflows").version($t);Un(H);Gn(H);zn(H);Zn(H);nr(H);or(H);ir(H);lr(H);cr(H);ur(H);H.parse();process.argv.slice(2).length||H.outputHelp();