@cmflow/agents 3.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -0
- package/bin/cm-agents.ts +0 -0
- package/dist/bin/cm-agents.d.mts +2 -0
- package/dist/bin/cm-agents.mjs +372 -0
- package/dist/bin/cm-agents.mjs.map +1 -0
- package/package.json +37 -0
- package/scripts/clubmed-models.json +33 -0
- package/scripts/setup.ps1 +63 -0
- package/scripts/setup.sh +29 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath as __atlasFileURLToPath } from "node:url";
|
|
3
|
+
const __filename = __atlasFileURLToPath(import.meta.url);
|
|
4
|
+
import{createRequire as e}from"node:module";import{EventEmitter as t,addAbortListener as n,on as r,once as i,setMaxListeners as a}from"node:events";import o,{ChildProcess as s,execFile as c,spawn as l,spawnSync as u}from"node:child_process";import d,{dirname as f,join as p}from"node:path";import m,{appendFileSync as h,closeSync as g,createReadStream as _,createWriteStream as v,openSync as y,readFileSync as b,readSync as x,statSync as S,writeFileSync as C}from"node:fs";import w,{execArgv as ee,execPath as te,hrtime as ne,platform as re,stdin as ie,stdout as ae}from"node:process";import{aborted as oe,callbackify as se,debuglog as ce,inspect as le,promisify as ue,stripVTControlCharacters as de,styleText as T}from"node:util";import*as fe from"node:readline";import pe from"node:readline";import me,{ReadStream as he}from"node:tty";import ge,{constants as _e,homedir as ve}from"node:os";import{fileURLToPath as ye}from"node:url";import{StringDecoder as be}from"node:string_decoder";import{scheduler as xe,setImmediate as Se,setTimeout as Ce}from"node:timers/promises";import{serialize as we}from"node:v8";import{Buffer as Te}from"node:buffer";import{finished as Ee}from"node:stream/promises";import{Duplex as De,PassThrough as Oe,Readable as ke,Transform as Ae,Writable as je,getDefaultHighWaterMark as Me}from"node:stream";import Ne from"node:path/win32";var Pe=Object.create,Fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Le=Object.getOwnPropertyNames,Re=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty,E=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Be=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Le(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ze.call(e,s)&&s!==n&&Fe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ie(t,s))||r.enumerable});return e},Ve=(e,t,n)=>(n=e==null?{}:Pe(Re(e)),Be(t||!e||!e.__esModule||!ze.call(e,`default`)?Fe(n,`default`,{value:e,enumerable:!0}):n,e)),D=e(import.meta.url),He=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}},Ue=class extends He{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},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}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}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=(e,t)=>{if(!this.argChoices.includes(e))throw new Ue(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ge(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var Ke=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&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 e=n.options.filter(e=>!e.hidden);t.push(...e)}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(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>Ge(e)).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((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).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){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).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}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
5
|
+
`)}displayWidth(e){return de(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
6
|
+
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
7
|
+
`)}},qe=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=Xe(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,this.helpGroupHeading=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}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new Ue(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?Ye(this.name().replace(/^no-/,``)):Ye(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Je=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function Ye(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Xe(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
8
|
+
- a short flag is a single dash and a single character
|
|
9
|
+
- either use a single dash and a single character (for a short flag)
|
|
10
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(t)?Error(`${n}
|
|
11
|
+
- too many short flags`):i.test(t)?Error(`${n}
|
|
12
|
+
- too many long flags`):Error(`${n}
|
|
13
|
+
- unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}function Ze(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function Qe(e,t){if(!t||t.length===0)return``;t=Array.from(new Set(t));let n=e.startsWith(`--`);n&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let r=[],i=3;return t.forEach(t=>{if(t.length<=1)return;let n=Ze(e,t),a=Math.max(e.length,t.length);(a-n)/a>.4&&(n<i?(i=n,r=[t]):n===i&&r.push(t))}),r.sort((e,t)=>e.localeCompare(t)),n&&(r=r.map(e=>`--${e}`)),r.length>1?`\n(Did you mean one of ${r.join(`, `)}?)`:r.length===1?`\n(Did you mean ${r[0]}?)`:``}var $e=class e extends t{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,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._savedState=null,this._outputConfiguration={writeOut:e=>w.stdout.write(e),writeErr:e=>w.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>w.stdout.isTTY?w.stdout.columns:void 0,getErrHelpWidth:()=>w.stderr.isTTY?w.stderr.columns:void 0,getOutHasColors:()=>tt()??(w.stdout.isTTY&&w.stdout.hasColors?.()),getErrHasColors:()=>tt()??(w.stderr.isTTY&&w.stderr.hasColors?.()),stripColor:e=>de(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}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 r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Ke,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...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 Error(`Command passed to .addCommand() must have a name
|
|
14
|
+
- specify the name in Command constructor or using .name()`);return 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 We(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n==`function`?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw 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,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,n,r]=(e??`help [command]`).match(/([^ ]+) *(.*)/),i=t??`display help for command`,a=this.createCommand(n);return a.helpOption(!1),r&&a.arguments(r),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e==`object`?(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this):(this.helpCommand(e,t),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 Error(`Unexpected value for event passed to hook : '${e}'.
|
|
15
|
+
Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e}),this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new He(e,t,n)),w.exit(e)}action(e){let t=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return r[n]=this._storeOptionsAsProperties?this:this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new qe(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if(e.code===`commander.invalidArgument`){let t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_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 Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
16
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){let r=t(this._findCommand(n)).join(`|`),i=t(e).join(`|`);throw Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,`default`);let r=(t,r,i)=>{t==null&&e.presetArg!==void 0&&(t=e.presetArg);let a=this.getOptionValue(n);t!==null&&e.parseArg?t=this._callParseArg(e,t,a,r):t!==null&&e.variadic&&(t=e._collectValue(t,a)),t??=e.negate?!1:e.isBoolean()||e.optional?!0:``,this.setOptionValueWithSource(n,t,i)};return this.on(`option:`+t,t=>{let n=`error: option '${e.flags}' argument '${t}' is invalid.`;r(t,n,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{let n=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;r(t,n,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof qe)throw Error(`To add an Option object use addOption() instead of option() or requiredOption()`);let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r==`function`)a.default(i).argParser(r);else if(r instanceof RegExp){let e=r;r=(t,n)=>{let r=e.exec(t);return r?r[0]:n},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}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 Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error(`call .storeOptionsAsProperties() before adding options`);if(Object.keys(this._optionValues).length)throw Error(`call .storeOptionsAsProperties() before setting option values`);return this._storeOptionsAsProperties=!!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 Error(`first parameter to parse must be array or undefined`);if(t||={},e===void 0&&t.from===void 0){w.versions?.electron&&(t.from=`electron`);let e=w.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=w.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`:w.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 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){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,`default`)}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
17
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(m.existsSync(e))return;let r=`'${e}' does not exist
|
|
18
|
+
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
19
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
20
|
+
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function r(e,t){let r=d.resolve(e,t);if(m.existsSync(r))return r;if(n.includes(d.extname(t)))return;let i=n.find(e=>m.existsSync(`${r}${e}`));if(i)return`${r}${i}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||``;if(this._scriptPath){let e;try{e=m.realpathSync(this._scriptPath)}catch{e=this._scriptPath}a=d.resolve(d.dirname(e),a)}if(a){let t=r(a,i);if(!t&&!e._executableFile&&this._scriptPath){let n=d.basename(this._scriptPath,d.extname(this._scriptPath));n!==this._name&&(t=r(a,`${n}-${e._name}`))}i=t||i}let s=n.includes(d.extname(i)),c;w.platform===`win32`?(this._checkForMissingExecutable(i,a,e._name),t.unshift(i),t=et(w.execArgv).concat(t),c=o.spawn(w.execPath,t,{stdio:`inherit`})):s?(t.unshift(i),t=et(w.execArgv).concat(t),c=o.spawn(w.argv[0],t,{stdio:`inherit`})):c=o.spawn(i,t,{stdio:`inherit`}),c.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{w.on(e,()=>{c.killed===!1&&c.exitCode===null&&c.kill(e)})});let l=this._exitCallback;c.on(`close`,e=>{e??=1,l?l(new He(e,`commander.executeSubCommandAsync`,`(close)`)):w.exit(e)}),c.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(i,a,e._name);else if(t.code===`EACCES`)throw Error(`'${i}' not executable`);if(!l)w.exit(1);else{let e=new He(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,l(e)}}),this.runningCommand=c}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_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=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_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 r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,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():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),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(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.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 t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
21
|
+
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in w.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()}`,w.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Je(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`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=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=Qe(e,n)}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`,r=e.length,i=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${r}: ${e.join(`, `)}.`;this.error(i,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=Qe(e,n)}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||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),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 Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>Ge(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=d.basename(e,d.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(w.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 Error(`Unexpected value for position to addHelpText.
|
|
22
|
+
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function et(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function tt(){if(w.env.NO_COLOR||w.env.FORCE_COLOR===`0`||w.env.FORCE_COLOR===`false`)return!1;if(w.env.FORCE_COLOR||w.env.CLICOLOR_FORCE!==void 0)return!0}new $e;const nt=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),rt=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,it=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,at=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ot=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,st=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ct=/\t{1,1000}/y,lt=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,ut=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,dt=/\p{M}+/gu,ft={limit:1/0,ellipsis:``},pt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?pt(i,ft,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[ut,l],[at,0],[ot,o],[ct,s],[lt,c],[st,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(dt,``)){let t=e.codePointAt(0)||0;if(S=rt(t)?2:it(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===st?nt(e.slice(p,n.lastIndex)):n===lt?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},mt={limit:1/0,ellipsis:``,ellipsisWidth:0},O=(e,t={})=>pt(e,mt,t).width,ht=`]8;;`,gt=RegExp(`(?:\\[(?<code>\\d+)m|\\${ht}(?<uri>.*))`,`y`),_t=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},vt=e=>`[${e}m`,yt=e=>`${ht}${e}`,bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:O(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=O(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(ht,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},xt=e=>{let t=e.split(` `),n=t.length;for(;n&&!O(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},St=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=O(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=O(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),bt(s,r,t),c=O(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){bt(s,r,t),c=O(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){bt(s,r,t),c=O(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>xt(e)));let l=s.join(`
|
|
23
|
+
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){gt.lastIndex=e+1;let t=gt.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
|
|
24
|
+
`){a&&(r+=yt(``));let e=i?_t(i):void 0;i&&e&&(r+=vt(e))}else t===`
|
|
25
|
+
`&&(i&&_t(i)&&(r+=vt(i)),a&&(r+=yt(a)))}return r},Ct=/\r?\n/;function wt(e,t,n){return String(e).normalize().split(Ct).map(e=>St(e,t,n)).join(`
|
|
26
|
+
`)}var k=E(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}}))();const A={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!0,date:{monthNames:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],messages:{required:`Please enter a valid date`,invalidMonth:`There are only 12 months in a year`,invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Tt(e,t){if(typeof e==`string`)return A.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Tt(n,t))return!0;return!1}function Et(e,t){if(e===t)return;let n=e.split(`
|
|
27
|
+
`),r=t.split(`
|
|
28
|
+
`),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const Dt=globalThis.process.platform.startsWith(`win`),Ot=Symbol(`clack:cancel`);function kt(e){return e===Ot}function At(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function jt({input:e=ie,output:t=ae,overwrite:n=!0,hideCursor:r=!0}={}){let i=fe.createInterface({input:e,output:t,prompt:``,tabSize:1});fe.emitKeypressEvents(e,i),e instanceof he&&e.isTTY&&e.setRawMode(!0);let a=(i,{name:o,sequence:s})=>{if(Tt([String(i),o,s],`cancel`)){r&&t.write(k.cursor.show),process.exit(0);return}if(!n)return;let c=o===`return`?0:-1,l=o===`return`?-1:0;fe.moveCursor(t,c,l,()=>{fe.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(k.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(k.cursor.show),e instanceof he&&e.isTTY&&!Dt&&e.setRawMode(!1),i.terminal=!1,i.close()}}const Mt=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,Nt=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function Pt(e,t,n,r=n,i=n,a){return wt(t,Mt(e??ae)-n.length,{hard:!0,trim:!1}).split(`
|
|
29
|
+
`).map((e,t,o)=>{let s=a?a(e,t):e;return t===0?`${r}${s}`:t===o.length-1?`${i}${s}`:`${n}${s}`}).join(`
|
|
30
|
+
`)}function Ft(e,t){if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return n.issues?.at(0)?.message}return e(t)}var It=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;constructor(e,t=!0){let{input:n=ie,output:r=ae,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(Ot);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=pe.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),At(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(k.cursor.show),this.output.off(`resize`,this.render),At(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(k.cursor.show),this.output.off(`resize`,this.render),At(this.input,!1),e(Ot)})})}_isActionKey(e,t){return e===` `}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:`u`}),this._setUserInput(``)}onKeypress(e,t){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&A.aliases.has(t.name)&&this.emit(`cursor`,A.aliases.get(t.name)),A.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e,t),t?.name===`return`&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=Ft(this.opts.validate,this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Tt([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
|
|
31
|
+
`),At(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=wt(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
32
|
+
`).length-1;this.output.write(k.cursor.move(-999,e*-1))}render(){let e=wt(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(k.cursor.hide);else{let t=Et(this._prevFrame,e),n=Nt(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(k.cursor.move(0,a-i)),this.output.write(k.erase.lines(1));let t=e.split(`
|
|
33
|
+
`);this.output.write(t[a]),this._prevFrame=e,this.output.write(k.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(k.cursor.move(0,e))}this.output.write(k.erase.down());let t=e.split(`
|
|
34
|
+
`).slice(a);this.output.write(t.join(`
|
|
35
|
+
`)),this._prevFrame=e;return}}this.output.write(k.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},Lt=class extends It{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(k.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}};let Rt=class extends It{_mask=`•`;get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state===`submit`||this.state===`cancel`)return this.masked;let e=this.userInput;if(this.cursor>=e.length)return`${this.masked}${T([`inverse`,`hidden`],`_`)}`;let t=this.masked,n=t.slice(0,this.cursor),r=t.slice(this.cursor,this.cursor+1),i=t.slice(this.cursor+1);return`${n}${T(`inverse`,r)}${i}`}clear(){this._clearUserInput()}constructor({mask:e,...t}){super(t),this._mask=e??`•`,this.on(`userInput`,e=>{this._setValue(e)}),this.on(`finalize`,()=>{this.value===void 0&&(this.value=``)})}};var zt=class extends It{get userInputWithCursor(){if(this.state===`submit`)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),n=e.slice(this.cursor,this.cursor+1),r=e.slice(this.cursor+1);return`${t}${T(`inverse`,n)}${r}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on(`userInput`,e=>{this._setValue(e)}),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.value===void 0&&(this.value=``)})}};function Bt(){return w.platform===`win32`?!!w.env.CI||!!w.env.WT_SESSION||!!w.env.TERMINUS_SUBLIME||w.env.ConEmuTask===`{cmd::Cmder}`||w.env.TERM_PROGRAM===`Terminus-Sublime`||w.env.TERM_PROGRAM===`vscode`||w.env.TERM===`xterm-256color`||w.env.TERM===`alacritty`||w.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:w.env.TERM!==`linux`}const Vt=Bt(),Ht=()=>process.env.CI===`true`,j=(e,t)=>Vt?e:t,Ut=j(`◆`,`*`),Wt=j(`■`,`x`),Gt=j(`▲`,`x`),Kt=j(`◇`,`o`),qt=j(`┌`,`T`),M=j(`│`,`|`),Jt=j(`└`,`—`),Yt=j(`●`,`>`),Xt=j(`○`,` `),Zt=j(`▪`,`•`),Qt=j(`─`,`-`),$t=j(`╮`,`+`),en=j(`├`,`+`),tn=j(`╯`,`+`),nn=j(`╰`,`+`),rn=j(`●`,`•`),an=j(`◆`,`*`),on=j(`▲`,`!`),sn=j(`■`,`x`),cn=e=>{switch(e){case`initial`:case`active`:return T(`cyan`,Ut);case`cancel`:return T(`red`,Wt);case`error`:return T(`yellow`,Gt);case`submit`:return T(`green`,Kt)}},ln=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new Lt({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let r=e.withGuide??A.withGuide,i=`${cn(this.state)} `,a=r?`${T(`gray`,M)} `:``,o=Pt(e.output,e.message,a,i),s=`${r?`${T(`gray`,M)}
|
|
36
|
+
`:``}${o}
|
|
37
|
+
`,c=this.value?t:n;switch(this.state){case`submit`:return`${s}${r?`${T(`gray`,M)} `:``}${T(`dim`,c)}`;case`cancel`:return`${s}${r?`${T(`gray`,M)} `:``}${T([`strikethrough`,`dim`],c)}${r?`
|
|
38
|
+
${T(`gray`,M)}`:``}`;default:{let i=r?`${T(`cyan`,M)} `:``,a=r?T(`cyan`,Jt):``;return`${s}${i}${this.value?`${T(`green`,Yt)} ${t}`:`${T(`dim`,Xt)} ${T(`dim`,t)}`}${e.vertical?r?`
|
|
39
|
+
${T(`cyan`,M)} `:`
|
|
40
|
+
`:` ${T(`dim`,`/`)} `}${this.value?`${T(`dim`,Xt)} ${T(`dim`,n)}`:`${T(`green`,Yt)} ${n}`}
|
|
41
|
+
${a}
|
|
42
|
+
`}}}}).prompt()},un=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&kt(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n};`${T(`dim`,`↑/↓`)}`,`${T(`dim`,`Space:`)}`,`${T(`dim`,`Enter:`)}`;const N={message:(e=[],{symbol:t=T(`gray`,M),secondarySymbol:n=T(`gray`,M),output:r=process.stdout,spacing:i=1,withGuide:a}={})=>{let o=[],s=a??A.withGuide,c=s?n:``,l=s?`${t} `:``,u=s?`${n} `:``;for(let e=0;e<i;e++)o.push(c);let d=Array.isArray(e)?e:e.split(`
|
|
43
|
+
`);if(d.length>0){let[e,...r]=d;e.length>0?o.push(`${l}${e}`):o.push(s?t:``);for(let e of r)e.length>0?o.push(`${u}${e}`):o.push(s?n:``)}r.write(`${o.join(`
|
|
44
|
+
`)}
|
|
45
|
+
`)},info:(e,t)=>{N.message(e,{...t,symbol:T(`blue`,rn)})},success:(e,t)=>{N.message(e,{...t,symbol:T(`green`,an)})},step:(e,t)=>{N.message(e,{...t,symbol:T(`green`,Kt)})},warn:(e,t)=>{N.message(e,{...t,symbol:T(`yellow`,on)})},warning:(e,t)=>{N.warn(e,t)},error:(e,t)=>{N.message(e,{...t,symbol:T(`red`,sn)})}},dn=(e=``,t)=>{let n=t?.output??process.stdout,r=t?.withGuide??A.withGuide?`${T(`gray`,Jt)} `:``;n.write(`${r}${T(`red`,e)}
|
|
46
|
+
|
|
47
|
+
`)},fn=(e=``,t)=>{let n=t?.output??process.stdout,r=t?.withGuide??A.withGuide?`${T(`gray`,qt)} `:``;n.write(`${r}${e}
|
|
48
|
+
`)},pn=(e=``,t)=>{let n=t?.output??process.stdout,r=t?.withGuide??A.withGuide?`${T(`gray`,M)}
|
|
49
|
+
${T(`gray`,Jt)} `:``;n.write(`${r}${e}
|
|
50
|
+
|
|
51
|
+
`)},mn=e=>e,hn=(e,t,n)=>{let r={hard:!0,trim:!1},i=wt(e,t,r).split(`
|
|
52
|
+
`),a=i.reduce((e,t)=>Math.max(O(t),e),0);return wt(e,t-(i.map(n).reduce((e,t)=>Math.max(O(t),e),0)-a),r)},gn=(e=``,t=``,n)=>{let r=n?.output??w.stdout,i=n?.withGuide??A.withGuide,a=n?.format??mn,o=[``,...hn(e,Mt(r)-6,a).split(`
|
|
53
|
+
`).map(a),``],s=O(t),c=Math.max(o.reduce((e,t)=>{let n=O(t);return n>e?n:e},0),s)+2,l=o.map(e=>`${T(`gray`,M)} ${e}${` `.repeat(c-O(e))}${T(`gray`,M)}`).join(`
|
|
54
|
+
`),u=i?`${T(`gray`,M)}
|
|
55
|
+
`:``,d=i?en:nn;r.write(`${u}${T(`green`,Kt)} ${T(`reset`,t)} ${T(`gray`,Qt.repeat(Math.max(c-s-1,1))+$t)}
|
|
56
|
+
${l}
|
|
57
|
+
${T(`gray`,d+Qt.repeat(c+2)+tn)}
|
|
58
|
+
`)},_n=e=>new Rt({validate:e.validate,mask:e.mask??Zt,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??A.withGuide,n=`${t?`${T(`gray`,M)}
|
|
59
|
+
`:``}${cn(this.state)} ${e.message}
|
|
60
|
+
`,r=this.userInputWithCursor,i=this.masked;switch(this.state){case`error`:{let r=t?`${T(`yellow`,M)} `:``,a=t?`${T(`yellow`,Jt)} `:``,o=i??``;return e.clearOnError&&this.clear(),`${n.trim()}
|
|
61
|
+
${r}${o}
|
|
62
|
+
${a}${T(`yellow`,this.error)}
|
|
63
|
+
`}case`submit`:return`${n}${t?`${T(`gray`,M)} `:``}${i?T(`dim`,i):``}`;case`cancel`:return`${n}${t?`${T(`gray`,M)} `:``}${i?T([`strikethrough`,`dim`],i):``}${i&&t?`
|
|
64
|
+
${T(`gray`,M)}`:``}`;default:return`${n}${t?`${T(`cyan`,M)} `:``}${r}
|
|
65
|
+
${t?T(`cyan`,Jt):``}
|
|
66
|
+
`}}}).prompt(),vn=e=>T(`magenta`,e),yn=({indicator:e=`dots`,onCancel:t,output:n=process.stdout,cancelMessage:r,errorMessage:i,frames:a=Vt?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],delay:o=Vt?80:120,signal:s,...c}={})=>{let l=Ht(),u,d,f=!1,p=!1,m=``,h,g=performance.now(),_=Mt(n),v=c?.styleFrame??vn,y=e=>{let n=e>1?i??A.messages.error:r??A.messages.cancel;p=e===1,f&&(ie(n,e),p&&typeof t==`function`&&t())},b=()=>y(2),x=()=>y(1),S=()=>{process.on(`uncaughtExceptionMonitor`,b),process.on(`unhandledRejection`,b),process.on(`SIGINT`,x),process.on(`SIGTERM`,x),process.on(`exit`,y),s&&s.addEventListener(`abort`,x)},C=()=>{process.removeListener(`uncaughtExceptionMonitor`,b),process.removeListener(`unhandledRejection`,b),process.removeListener(`SIGINT`,x),process.removeListener(`SIGTERM`,x),process.removeListener(`exit`,y),s&&s.removeEventListener(`abort`,x)},w=()=>{if(h===void 0)return;l&&n.write(`
|
|
67
|
+
`);let e=wt(h,_,{hard:!0,trim:!1}).split(`
|
|
68
|
+
`);e.length>1&&n.write(k.cursor.up(e.length-1)),n.write(k.cursor.to(0)),n.write(k.erase.down())},ee=e=>e.replace(/\.+$/,``),te=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},ne=c.withGuide??A.withGuide,re=(t=``)=>{f=!0,u=jt({output:n}),m=ee(t),g=performance.now(),ne&&n.write(`${T(`gray`,M)}
|
|
69
|
+
`);let r=0,i=0;S(),d=setInterval(()=>{if(l&&m===h)return;w(),h=m;let t=v(a[r]),o;if(l)o=`${t} ${m}...`;else if(e===`timer`)o=`${t} ${m} ${te(g)}`;else{let e=`.`.repeat(Math.floor(i)).slice(0,3);o=`${t} ${m}${e}`}let s=wt(o,_,{hard:!0,trim:!1});n.write(s),r=r+1<a.length?r+1:0,i=i<4?i+.125:0},o)},ie=(t=``,r=0,i=!1)=>{if(!f)return;f=!1,clearInterval(d),w();let a=r===0?T(`green`,Kt):r===1?T(`red`,Wt):T(`red`,Gt);m=t??m,i||(e===`timer`?n.write(`${a} ${m} ${te(g)}
|
|
70
|
+
`):n.write(`${a} ${m}
|
|
71
|
+
`)),C(),u()};return{start:re,stop:(e=``)=>ie(e,0),message:(e=``)=>{m=ee(e??m)},cancel:(e=``)=>ie(e,1),error:(e=``)=>ie(e,2),clear:()=>ie(``,0,!0),get isCancelled(){return p}}};`${T(`dim`,`↑/↓`)}`,`${T(`dim`,`Enter:`)}`,`${T(`gray`,M)}`;const bn=e=>new zt({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??A.withGuide,n=`${`${t?`${T(`gray`,M)}
|
|
72
|
+
`:``}${cn(this.state)} `}${e.message}
|
|
73
|
+
`,r=e.placeholder&&e.placeholder.length>0?T(`inverse`,e.placeholder[0])+T(`dim`,e.placeholder.slice(1)):T([`inverse`,`hidden`],`_`),i=this.userInput?this.userInputWithCursor:r,a=this.value??``;switch(this.state){case`error`:{let e=this.error?` ${T(`yellow`,this.error)}`:``,r=t?`${T(`yellow`,M)} `:``,a=t?T(`yellow`,Jt):``;return`${n.trim()}
|
|
74
|
+
${r}${i}
|
|
75
|
+
${a}${e}
|
|
76
|
+
`}case`submit`:{let e=a?` ${T(`dim`,a)}`:``;return`${n}${t?T(`gray`,M):``}${e}`}case`cancel`:{let e=a?` ${T([`strikethrough`,`dim`],a)}`:``,r=t?T(`gray`,M):``;return`${n}${r}${e}${a.trim()?`
|
|
77
|
+
${r}`:``}`}default:return`${n}${t?`${T(`cyan`,M)} `:``}${i}
|
|
78
|
+
${t?T(`cyan`,Jt):``}
|
|
79
|
+
`}}}).prompt();var P=E((e=>{e.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]==`function`)e.apply(this,t);else return new Promise((n,r)=>{t.push((e,t)=>e==null?n(t):r(e)),e.apply(this,t)})},"name",{value:e.name})},e.fromPromise=function(e){return Object.defineProperty(function(...t){let n=t[t.length-1];if(typeof n!=`function`)return e.apply(this,t);t.pop(),e.apply(this,t).then(e=>n(null,e),n)},"name",{value:e.name})}})),xn=E(((e,t)=>{var n=D(`constants`),r=process.cwd,i=null,a=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return i||=r.call(process),i};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var o=process.chdir;process.chdir=function(e){i=null,o.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,o)}t.exports=s;function s(e){n.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=o(e.chmodSync),e.fchmodSync=o(e.fchmodSync),e.lchmodSync=o(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),a===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,r,i){e.open(t,n.O_WRONLY|n.O_SYMLINK,r,function(t,n){if(t){i&&i(t);return}e.fchmod(n,r,function(t){e.close(n,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,r){var i=e.openSync(t,n.O_WRONLY|n.O_SYMLINK,r),a=!0,o;try{o=e.fchmodSync(i,r),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function r(e){n.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,r,i,a){e.open(t,n.O_SYMLINK,function(t,n){if(t){a&&a(t);return}e.futimes(n,r,i,function(t){e.close(n,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,r,i){var a=e.openSync(t,n.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,r,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function o(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),Sn=E(((e,t)=>{var n=D(`stream`).Stream;t.exports=r;function r(e){return{ReadStream:t,WriteStream:r};function t(r,i){if(!(this instanceof t))return new t(r,i);n.call(this);var a=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function r(t,i){if(!(this instanceof r))return new r(t,i);n.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),Cn=E(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),wn=E(((e,t)=>{var n=D(`fs`),r=xn(),i=Sn(),a=Cn(),o=D(`util`),s,c;typeof Symbol==`function`&&typeof Symbol.for==`function`?(s=Symbol.for(`graceful-fs.queue`),c=Symbol.for(`graceful-fs.previous`)):(s=`___graceful-fs.queue`,c=`___graceful-fs.previous`);function l(){}function u(e,t){Object.defineProperty(e,s,{get:function(){return t}})}var d=l;o.debuglog?d=o.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(d=function(){var e=o.format.apply(o,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
80
|
+
GFS4: `),console.error(e)}),n[s]||(u(n,global[s]||[]),n.close=(function(e){function t(t,r){return e.call(n,t,function(e){e||h(),typeof r==`function`&&r.apply(this,arguments)})}return Object.defineProperty(t,c,{value:e}),t})(n.close),n.closeSync=(function(e){function t(t){e.apply(n,arguments),h()}return Object.defineProperty(t,c,{value:e}),t})(n.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){d(n[s]),D(`assert`).equal(n[s].length,0)})),global[s]||u(global,n[s]),t.exports=f(a(n)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!n.__patched&&(t.exports=f(n),n.__patched=!0);function f(e){r(e),e.gracefulify=f,e.createReadStream=ee,e.createWriteStream=te;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?p([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var a=e.writeFile;e.writeFile=o;function o(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,o){return a(e,t,n,function(a){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?p([i,[e,t,n,r],a,o||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var m=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=m.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?p([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=i(e);x=g.ReadStream,C=g.WriteStream}var _=e.ReadStream;_&&(x.prototype=Object.create(_.prototype),x.prototype.open=S);var v=e.WriteStream;v&&(C.prototype=Object.create(v.prototype),C.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return C},set:function(e){C=e},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var b=C;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0});function x(e,t){return this instanceof x?(_.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function S(){var e=this;re(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function C(e,t){return this instanceof C?(v.apply(this,arguments),this):C.apply(Object.create(C.prototype),arguments)}function w(){var e=this;re(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function ee(t,n){return new e.ReadStream(t,n)}function te(t,n){return new e.WriteStream(t,n)}var ne=e.open;e.open=re;function re(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return ne(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function p(e){d(`ENQUEUE`,e[0].name,e[1]),n[s].push(e),g()}var m;function h(){for(var e=Date.now(),t=0;t<n[s].length;++t)n[s][t].length>2&&(n[s][t][3]=e,n[s][t][4]=e);g()}function g(){if(clearTimeout(m),m=void 0,n[s].length!==0){var e=n[s].shift(),t=e[0],r=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)d(`RETRY`,t.name,r),t.apply(null,r);else if(Date.now()-a>=6e4){d(`TIMEOUT`,t.name,r);var c=r.pop();typeof c==`function`&&c.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(d(`RETRY`,t.name,r),t.apply(null,r.concat([a]))):n[s].push(e)}m===void 0&&(m=setTimeout(g,0))}}})),F=E((e=>{let t=P().fromCallback,n=wn(),r=`access.appendFile.chmod.chown.close.copyFile.cp.fchmod.fchown.fdatasync.fstat.fsync.ftruncate.futimes.glob.lchmod.lchown.lutimes.link.lstat.mkdir.mkdtemp.open.opendir.readdir.readFile.readlink.realpath.rename.rm.rmdir.stat.statfs.symlink.truncate.unlink.utimes.writeFile`.split(`.`).filter(e=>typeof n[e]==`function`);Object.assign(e,n),r.forEach(r=>{e[r]=t(n[r])}),e.exists=function(e,t){return typeof t==`function`?n.exists(e,t):new Promise(t=>n.exists(e,t))},e.read=function(e,t,r,i,a,o){return typeof o==`function`?n.read(e,t,r,i,a,o):new Promise((o,s)=>{n.read(e,t,r,i,a,(e,t,n)=>{if(e)return s(e);o({bytesRead:t,buffer:n})})})},e.write=function(e,t,...r){return typeof r[r.length-1]==`function`?n.write(e,t,...r):new Promise((i,a)=>{n.write(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesWritten:t,buffer:n})})})},e.readv=function(e,t,...r){return typeof r[r.length-1]==`function`?n.readv(e,t,...r):new Promise((i,a)=>{n.readv(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesRead:t,buffers:n})})})},e.writev=function(e,t,...r){return typeof r[r.length-1]==`function`?n.writev(e,t,...r):new Promise((i,a)=>{n.writev(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesWritten:t,buffers:n})})})},typeof n.realpath.native==`function`?e.realpath.native=t(n.realpath.native):process.emitWarning(`fs.realpath.native is not a function. Is fs being monkey-patched?`,`Warning`,`fs-extra-WARN0003`)})),Tn=E(((e,t)=>{let n=D(`path`);t.exports.checkPath=function(e){if(process.platform===`win32`&&/[<>:"|?*]/.test(e.replace(n.parse(e).root,``))){let t=Error(`Path contains invalid characters: ${e}`);throw t.code=`EINVAL`,t}}})),En=E(((e,t)=>{let n=F(),{checkPath:r}=Tn(),i=e=>typeof e==`number`?e:{mode:511,...e}.mode;t.exports.makeDir=async(e,t)=>(r(e),n.mkdir(e,{mode:i(t),recursive:!0})),t.exports.makeDirSync=(e,t)=>(r(e),n.mkdirSync(e,{mode:i(t),recursive:!0}))})),I=E(((e,t)=>{let n=P().fromPromise,{makeDir:r,makeDirSync:i}=En(),a=n(r);t.exports={mkdirs:a,mkdirsSync:i,mkdirp:a,mkdirpSync:i,ensureDir:a,ensureDirSync:i}})),Dn=E(((e,t)=>{let n=P().fromPromise,r=F();function i(e){return r.access(e).then(()=>!0).catch(()=>!1)}t.exports={pathExists:n(i),pathExistsSync:r.existsSync}})),On=E(((e,t)=>{let n=F(),r=P().fromPromise;async function i(e,t,r){let i=await n.open(e,`r+`),a=null;try{await n.futimes(i,t,r)}catch(e){a=e}finally{try{await n.close(i)}catch(e){a||=e}}if(a)throw a}function a(e,t,r){let i=n.openSync(e,`r+`),a=null;try{n.futimesSync(i,t,r)}catch(e){a=e}finally{try{n.closeSync(i)}catch(e){a||=e}}if(a)throw a}t.exports={utimesMillis:r(i),utimesMillisSync:a}})),kn=E(((e,t)=>{let n=F(),r=D(`path`),i=P().fromPromise;function a(e,t,r){let i=r.dereference?e=>n.stat(e,{bigint:!0}):e=>n.lstat(e,{bigint:!0});return Promise.all([i(e),i(t).catch(e=>{if(e.code===`ENOENT`)return null;throw e})]).then(([e,t])=>({srcStat:e,destStat:t}))}function o(e,t,r){let i,a=r.dereference?e=>n.statSync(e,{bigint:!0}):e=>n.lstatSync(e,{bigint:!0}),o=a(e);try{i=a(t)}catch(e){if(e.code===`ENOENT`)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:i}}async function s(e,t,n,i){let{srcStat:o,destStat:s}=await a(e,t,i);if(s){if(d(o,s)){let i=r.basename(e),a=r.basename(t);if(n===`move`&&i!==a&&i.toLowerCase()===a.toLowerCase())return{srcStat:o,destStat:s,isChangingCase:!0};throw Error(`Source and destination must not be the same.`)}if(o.isDirectory()&&!s.isDirectory())throw Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!o.isDirectory()&&s.isDirectory())throw Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(o.isDirectory()&&f(e,t))throw Error(p(e,t,n));return{srcStat:o,destStat:s}}function c(e,t,n,i){let{srcStat:a,destStat:s}=o(e,t,i);if(s){if(d(a,s)){let i=r.basename(e),o=r.basename(t);if(n===`move`&&i!==o&&i.toLowerCase()===o.toLowerCase())return{srcStat:a,destStat:s,isChangingCase:!0};throw Error(`Source and destination must not be the same.`)}if(a.isDirectory()&&!s.isDirectory())throw Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!a.isDirectory()&&s.isDirectory())throw Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(a.isDirectory()&&f(e,t))throw Error(p(e,t,n));return{srcStat:a,destStat:s}}async function l(e,t,i,a){let o=r.resolve(r.dirname(e)),s=r.resolve(r.dirname(i));if(s===o||s===r.parse(s).root)return;let c;try{c=await n.stat(s,{bigint:!0})}catch(n){if(n.code===`ENOENT`)return l(e,t,s,a);throw n}if(d(t,c))throw Error(p(e,i,a));return l(e,t,s,a)}function u(e,t,i,a){let o=r.resolve(r.dirname(e)),s=r.resolve(r.dirname(i));if(s===o||s===r.parse(s).root)return;let c;try{c=n.statSync(s,{bigint:!0})}catch(n){if(n.code===`ENOENT`)return u(e,t,s,a);throw n}if(d(t,c))throw Error(p(e,i,a));return u(e,t,s,a)}function d(e,t){return t.ino!==void 0&&t.dev!==void 0&&t.ino===e.ino&&t.dev===e.dev}function f(e,t){let n=r.resolve(e).split(r.sep).filter(e=>e),i=r.resolve(t).split(r.sep).filter(e=>e);return n.every((e,t)=>i[t]===e)}function p(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}t.exports={checkPaths:i(s),checkPathsSync:c,checkParentPaths:i(l),checkParentPathsSync:u,isSrcSubdir:f,areIdentical:d}})),An=E(((e,t)=>{async function n(e,t){let n=[];for await(let r of e)n.push(t(r).then(()=>null,e=>e??Error(`unknown error`)));await Promise.all(n.map(e=>e.then(e=>{if(e!==null)throw e})))}t.exports={asyncIteratorConcurrentProcess:n}})),jn=E(((e,t)=>{let n=F(),r=D(`path`),{mkdirs:i}=I(),{pathExists:a}=Dn(),{utimesMillis:o}=On(),s=kn(),{asyncIteratorConcurrentProcess:c}=An();async function l(e,t,n={}){typeof n==`function`&&(n={filter:n}),n.clobber=`clobber`in n?!!n.clobber:!0,n.overwrite=`overwrite`in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&process.arch===`ia32`&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
81
|
+
|
|
82
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,`Warning`,`fs-extra-WARN0001`);let{srcStat:o,destStat:c}=await s.checkPaths(e,t,`copy`,n);if(await s.checkParentPaths(e,o,t,`copy`),!await u(e,t,n))return;let l=r.dirname(t);await a(l)||await i(l),await d(c,e,t,n)}async function u(e,t,n){return!n.filter||n.filter(e,t)}async function d(e,t,r,i){let a=await(i.dereference?n.stat:n.lstat)(t);if(a.isDirectory())return g(a,e,t,r,i);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return f(a,e,t,r,i);if(a.isSymbolicLink())return _(e,t,r,i);throw a.isSocket()?Error(`Cannot copy a socket file: ${t}`):a.isFIFO()?Error(`Cannot copy a FIFO pipe: ${t}`):Error(`Unknown file: ${t}`)}async function f(e,t,r,i,a){if(!t)return p(e,r,i,a);if(a.overwrite)return await n.unlink(i),p(e,r,i,a);if(a.errorOnExist)throw Error(`'${i}' already exists`)}async function p(e,t,r,i){if(await n.copyFile(t,r),i.preserveTimestamps){m(e.mode)&&await h(r,e.mode);let i=await n.stat(t);await o(r,i.atime,i.mtime)}return n.chmod(r,e.mode)}function m(e){return!(e&128)}function h(e,t){return n.chmod(e,t|128)}async function g(e,t,i,a,o){t||await n.mkdir(a),await c(await n.opendir(i),async e=>{let t=r.join(i,e.name),n=r.join(a,e.name);if(await u(t,n,o)){let{destStat:e}=await s.checkPaths(t,n,`copy`,o);await d(e,t,n,o)}}),t||await n.chmod(a,e.mode)}async function _(e,t,i,a){let o=await n.readlink(t);if(a.dereference&&(o=r.resolve(process.cwd(),o)),!e)return n.symlink(o,i);let c=null;try{c=await n.readlink(i)}catch(e){if(e.code===`EINVAL`||e.code===`UNKNOWN`)return n.symlink(o,i);throw e}if(a.dereference&&(c=r.resolve(process.cwd(),c)),o!==c){if(s.isSrcSubdir(o,c))throw Error(`Cannot copy '${o}' to a subdirectory of itself, '${c}'.`);if(s.isSrcSubdir(c,o))throw Error(`Cannot overwrite '${c}' with '${o}'.`)}return await n.unlink(i),n.symlink(o,i)}t.exports=l})),Mn=E(((e,t)=>{let n=wn(),r=D(`path`),i=I().mkdirsSync,a=On().utimesMillisSync,o=kn();function s(e,t,a){typeof a==`function`&&(a={filter:a}),a||={},a.clobber=`clobber`in a?!!a.clobber:!0,a.overwrite=`overwrite`in a?!!a.overwrite:a.clobber,a.preserveTimestamps&&process.arch===`ia32`&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
83
|
+
|
|
84
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,`Warning`,`fs-extra-WARN0002`);let{srcStat:s,destStat:l}=o.checkPathsSync(e,t,`copy`,a);if(o.checkParentPathsSync(e,s,t,`copy`),a.filter&&!a.filter(e,t))return;let u=r.dirname(t);return n.existsSync(u)||i(u),c(l,e,t,a)}function c(e,t,r,i){let a=(i.dereference?n.statSync:n.lstatSync)(t);if(a.isDirectory())return _(a,e,t,r,i);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return l(a,e,t,r,i);if(a.isSymbolicLink())return x(e,t,r,i);throw a.isSocket()?Error(`Cannot copy a socket file: ${t}`):a.isFIFO()?Error(`Cannot copy a FIFO pipe: ${t}`):Error(`Unknown file: ${t}`)}function l(e,t,n,r,i){return t?u(e,n,r,i):d(e,n,r,i)}function u(e,t,r,i){if(i.overwrite)return n.unlinkSync(r),d(e,t,r,i);if(i.errorOnExist)throw Error(`'${r}' already exists`)}function d(e,t,r,i){return n.copyFileSync(t,r),i.preserveTimestamps&&f(e.mode,t,r),h(r,e.mode)}function f(e,t,n){return p(e)&&m(n,e),g(t,n)}function p(e){return!(e&128)}function m(e,t){return h(e,t|128)}function h(e,t){return n.chmodSync(e,t)}function g(e,t){let r=n.statSync(e);return a(t,r.atime,r.mtime)}function _(e,t,n,r,i){return t?y(n,r,i):v(e.mode,n,r,i)}function v(e,t,r,i){return n.mkdirSync(r),y(t,r,i),h(r,e)}function y(e,t,r){let i=n.opendirSync(e);try{let n;for(;(n=i.readSync())!==null;)b(n.name,e,t,r)}finally{i.closeSync()}}function b(e,t,n,i){let a=r.join(t,e),s=r.join(n,e);if(i.filter&&!i.filter(a,s))return;let{destStat:l}=o.checkPathsSync(a,s,`copy`,i);return c(l,a,s,i)}function x(e,t,i,a){let s=n.readlinkSync(t);if(a.dereference&&(s=r.resolve(process.cwd(),s)),e){let e;try{e=n.readlinkSync(i)}catch(e){if(e.code===`EINVAL`||e.code===`UNKNOWN`)return n.symlinkSync(s,i);throw e}if(a.dereference&&(e=r.resolve(process.cwd(),e)),s!==e){if(o.isSrcSubdir(s,e))throw Error(`Cannot copy '${s}' to a subdirectory of itself, '${e}'.`);if(o.isSrcSubdir(e,s))throw Error(`Cannot overwrite '${e}' with '${s}'.`)}return S(s,i)}return n.symlinkSync(s,i)}function S(e,t){return n.unlinkSync(t),n.symlinkSync(e,t)}t.exports=s})),Nn=E(((e,t)=>{let n=P().fromPromise;t.exports={copy:n(jn()),copySync:Mn()}})),Pn=E(((e,t)=>{let n=wn(),r=P().fromCallback;function i(e,t){n.rm(e,{recursive:!0,force:!0},t)}function a(e){n.rmSync(e,{recursive:!0,force:!0})}t.exports={remove:r(i),removeSync:a}})),Fn=E(((e,t)=>{let n=P().fromPromise,r=F(),i=D(`path`),a=I(),o=Pn(),s=n(async function(e){let t;try{t=await r.readdir(e)}catch{return a.mkdirs(e)}return Promise.all(t.map(t=>o.remove(i.join(e,t))))});function c(e){let t;try{t=r.readdirSync(e)}catch{return a.mkdirsSync(e)}t.forEach(t=>{t=i.join(e,t),o.removeSync(t)})}t.exports={emptyDirSync:c,emptydirSync:c,emptyDir:s,emptydir:s}})),In=E(((e,t)=>{let n=P().fromPromise,r=D(`path`),i=F(),a=I();async function o(e){let t;try{t=await i.stat(e)}catch{}if(t&&t.isFile())return;let n=r.dirname(e),o=null;try{o=await i.stat(n)}catch(t){if(t.code===`ENOENT`){await a.mkdirs(n),await i.writeFile(e,``);return}throw t}o.isDirectory()?await i.writeFile(e,``):await i.readdir(n)}function s(e){let t;try{t=i.statSync(e)}catch{}if(t&&t.isFile())return;let n=r.dirname(e);try{i.statSync(n).isDirectory()||i.readdirSync(n)}catch(e){if(e&&e.code===`ENOENT`)a.mkdirsSync(n);else throw e}i.writeFileSync(e,``)}t.exports={createFile:n(o),createFileSync:s}})),Ln=E(((e,t)=>{let n=P().fromPromise,r=D(`path`),i=F(),a=I(),{pathExists:o}=Dn(),{areIdentical:s}=kn();async function c(e,t){let n;try{n=await i.lstat(t,{bigint:!0})}catch{}let c;try{c=await i.lstat(e,{bigint:!0})}catch(e){throw e.message=e.message.replace(`lstat`,`ensureLink`),e}if(n&&s(c,n))return;let l=r.dirname(t);await o(l)||await a.mkdirs(l),await i.link(e,t)}function l(e,t){let n;try{n=i.lstatSync(t,{bigint:!0})}catch{}try{let t=i.lstatSync(e,{bigint:!0});if(n&&s(t,n))return}catch(e){throw e.message=e.message.replace(`lstat`,`ensureLink`),e}let o=r.dirname(t);return i.existsSync(o)||a.mkdirsSync(o),i.linkSync(e,t)}t.exports={createLink:n(c),createLinkSync:l}})),Rn=E(((e,t)=>{let n=D(`path`),r=F(),{pathExists:i}=Dn(),a=P().fromPromise;async function o(e,t){if(n.isAbsolute(e)){try{await r.lstat(e)}catch(e){throw e.message=e.message.replace(`lstat`,`ensureSymlink`),e}return{toCwd:e,toDst:e}}let a=n.dirname(t),o=n.join(a,e);if(await i(o))return{toCwd:o,toDst:e};try{await r.lstat(e)}catch(e){throw e.message=e.message.replace(`lstat`,`ensureSymlink`),e}return{toCwd:e,toDst:n.relative(a,e)}}function s(e,t){if(n.isAbsolute(e)){if(!r.existsSync(e))throw Error(`absolute srcpath does not exist`);return{toCwd:e,toDst:e}}let i=n.dirname(t),a=n.join(i,e);if(r.existsSync(a))return{toCwd:a,toDst:e};if(!r.existsSync(e))throw Error(`relative srcpath does not exist`);return{toCwd:e,toDst:n.relative(i,e)}}t.exports={symlinkPaths:a(o),symlinkPathsSync:s}})),zn=E(((e,t)=>{let n=F(),r=P().fromPromise;async function i(e,t){if(t)return t;let r;try{r=await n.lstat(e)}catch{return`file`}return r&&r.isDirectory()?`dir`:`file`}function a(e,t){if(t)return t;let r;try{r=n.lstatSync(e)}catch{return`file`}return r&&r.isDirectory()?`dir`:`file`}t.exports={symlinkType:r(i),symlinkTypeSync:a}})),Bn=E(((e,t)=>{let n=P().fromPromise,r=D(`path`),i=F(),{mkdirs:a,mkdirsSync:o}=I(),{symlinkPaths:s,symlinkPathsSync:c}=Rn(),{symlinkType:l,symlinkTypeSync:u}=zn(),{pathExists:d}=Dn(),{areIdentical:f}=kn();async function p(e,t,n){let o;try{o=await i.lstat(t)}catch{}if(o&&o.isSymbolicLink()){let n;if(r.isAbsolute(e))n=await i.stat(e,{bigint:!0});else{let a=r.dirname(t),o=r.join(a,e);try{n=await i.stat(o,{bigint:!0})}catch{n=await i.stat(e,{bigint:!0})}}let a;try{a=await i.stat(t,{bigint:!0})}catch(e){if(e.code!==`ENOENT`)throw e}if(a&&f(n,a))return}let c=await s(e,t);e=c.toDst;let u=await l(c.toCwd,n),p=r.dirname(t);return await d(p)||await a(p),i.symlink(e,t,u)}function m(e,t,n){let a;try{a=i.lstatSync(t)}catch{}if(a&&a.isSymbolicLink()){let n;if(r.isAbsolute(e))n=i.statSync(e,{bigint:!0});else{let a=r.dirname(t),o=r.join(a,e);try{n=i.statSync(o,{bigint:!0})}catch{n=i.statSync(e,{bigint:!0})}}let a;try{a=i.statSync(t,{bigint:!0})}catch(e){if(e.code!==`ENOENT`)throw e}if(a&&f(n,a))return}let s=c(e,t);e=s.toDst,n=u(s.toCwd,n);let l=r.dirname(t);return i.existsSync(l)||o(l),i.symlinkSync(e,t,n)}t.exports={createSymlink:n(p),createSymlinkSync:m}})),Vn=E(((e,t)=>{let{createFile:n,createFileSync:r}=In(),{createLink:i,createLinkSync:a}=Ln(),{createSymlink:o,createSymlinkSync:s}=Bn();t.exports={createFile:n,createFileSync:r,ensureFile:n,ensureFileSync:r,createLink:i,createLinkSync:a,ensureLink:i,ensureLinkSync:a,createSymlink:o,createSymlinkSync:s,ensureSymlink:o,ensureSymlinkSync:s}})),Hn=E(((e,t)=>{function n(e,{EOL:t=`
|
|
85
|
+
`,finalEOL:n=!0,replacer:r=null,spaces:i}={}){let a=n?t:``,o=JSON.stringify(e,r,i);if(o===void 0)throw TypeError(`Converting ${typeof e} value to JSON is not supported`);return o.replace(/\n/g,t)+a}function r(e){return Buffer.isBuffer(e)&&(e=e.toString(`utf8`)),e.replace(/^\uFEFF/,``)}t.exports={stringify:n,stripBom:r}})),Un=E(((e,t)=>{let n;try{n=wn()}catch{n=D(`fs`)}let r=P(),{stringify:i,stripBom:a}=Hn();async function o(e,t={}){typeof t==`string`&&(t={encoding:t});let i=t.fs||n,o=`throws`in t?t.throws:!0,s=await r.fromCallback(i.readFile)(e,t);s=a(s);let c;try{c=JSON.parse(s,t?t.reviver:null)}catch(t){if(o)throw t.message=`${e}: ${t.message}`,t;return null}return c}let s=r.fromPromise(o);function c(e,t={}){typeof t==`string`&&(t={encoding:t});let r=t.fs||n,i=`throws`in t?t.throws:!0;try{let n=r.readFileSync(e,t);return n=a(n),JSON.parse(n,t.reviver)}catch(t){if(i)throw t.message=`${e}: ${t.message}`,t;return null}}async function l(e,t,a={}){let o=a.fs||n,s=i(t,a);await r.fromCallback(o.writeFile)(e,s,a)}let u=r.fromPromise(l);function d(e,t,r={}){let a=r.fs||n,o=i(t,r);return a.writeFileSync(e,o,r)}t.exports={readFile:s,readFileSync:c,writeFile:u,writeFileSync:d}})),Wn=E(((e,t)=>{let n=Un();t.exports={readJson:n.readFile,readJsonSync:n.readFileSync,writeJson:n.writeFile,writeJsonSync:n.writeFileSync}})),Gn=E(((e,t)=>{let n=P().fromPromise,r=F(),i=D(`path`),a=I(),o=Dn().pathExists;async function s(e,t,n=`utf-8`){let s=i.dirname(e);return await o(s)||await a.mkdirs(s),r.writeFile(e,t,n)}function c(e,...t){let n=i.dirname(e);r.existsSync(n)||a.mkdirsSync(n),r.writeFileSync(e,...t)}t.exports={outputFile:n(s),outputFileSync:c}})),Kn=E(((e,t)=>{let{stringify:n}=Hn(),{outputFile:r}=Gn();async function i(e,t,i={}){let a=n(t,i);await r(e,a,i)}t.exports=i})),qn=E(((e,t)=>{let{stringify:n}=Hn(),{outputFileSync:r}=Gn();function i(e,t,i){let a=n(t,i);r(e,a,i)}t.exports=i})),Jn=E(((e,t)=>{let n=P().fromPromise,r=Wn();r.outputJson=n(Kn()),r.outputJsonSync=qn(),r.outputJSON=r.outputJson,r.outputJSONSync=r.outputJsonSync,r.writeJSON=r.writeJson,r.writeJSONSync=r.writeJsonSync,r.readJSON=r.readJson,r.readJSONSync=r.readJsonSync,t.exports=r})),Yn=E(((e,t)=>{let n=F(),r=D(`path`),{copy:i}=Nn(),{remove:a}=Pn(),{mkdirp:o}=I(),{pathExists:s}=Dn(),c=kn();async function l(e,t,n={}){let i=n.overwrite||n.clobber||!1,{srcStat:a,isChangingCase:s=!1}=await c.checkPaths(e,t,`move`,n);await c.checkParentPaths(e,a,t,`move`);let l=r.dirname(t);return r.parse(l).root!==l&&await o(l),u(e,t,i,s)}async function u(e,t,r,i){if(!i){if(r)await a(t);else if(await s(t))throw Error(`dest already exists.`)}try{await n.rename(e,t)}catch(n){if(n.code!==`EXDEV`)throw n;await d(e,t,r)}}async function d(e,t,n){return await i(e,t,{overwrite:n,errorOnExist:!0,preserveTimestamps:!0}),a(e)}t.exports=l})),Xn=E(((e,t)=>{let n=wn(),r=D(`path`),i=Nn().copySync,a=Pn().removeSync,o=I().mkdirpSync,s=kn();function c(e,t,n){n||={};let i=n.overwrite||n.clobber||!1,{srcStat:a,isChangingCase:c=!1}=s.checkPathsSync(e,t,`move`,n);return s.checkParentPathsSync(e,a,t,`move`),l(t)||o(r.dirname(t)),u(e,t,i,c)}function l(e){let t=r.dirname(e);return r.parse(t).root===t}function u(e,t,r,i){if(i)return d(e,t,r);if(r)return a(t),d(e,t,r);if(n.existsSync(t))throw Error(`dest already exists.`);return d(e,t,r)}function d(e,t,r){try{n.renameSync(e,t)}catch(n){if(n.code!==`EXDEV`)throw n;return f(e,t,r)}}function f(e,t,n){return i(e,t,{overwrite:n,errorOnExist:!0,preserveTimestamps:!0}),a(e)}t.exports=c})),Zn=E(((e,t)=>{let n=P().fromPromise;t.exports={move:n(Yn()),moveSync:Xn()}})),L=Ve(E(((e,t)=>{t.exports={...F(),...Nn(),...Fn(),...Vn(),...Jn(),...I(),...Zn(),...Gn(),...Dn(),...Pn()}}))(),1);const Qn=process.platform===`win32`,$n=ve(),er=p($n,`workspaces`,`digital-api-team-skills`),tr=`https://apim-prdaiplatform-frc.azure-api.net/litellm-api/v1`;process.env.LITELLM_API_KEY;const nr=p($n,`.codex`),R=p(nr,`config.toml`),rr=p(nr,`clubmed-models.json`),ir={fable:`gmdt-swc-claude-fable-5`,opus:`gmdt-swc-claude-opus-4-8`,sonnet:`gmdt-swc-claude-sonnet-5`,haiku:`gmdt-swc-claude-haiku-4-5`,codex:`gmdt-swc-gpt-5.3-codex`},ar=`201801041426.test.clubmed.com`,or={clubmed_api:JSON.stringify({type:`http`,url:`https://portal.api.clubmed/mcp`,headers:{"x-api-key":"${CLUBMED_API_MCP_KEY}"}}),cms_api:JSON.stringify({type:`http`,url:`https://cms.api.clubmed/mcp`,headers:{Authorization:"Bearer ${CMS_API_MCP_TOKEN}"}}),atlassian:JSON.stringify({type:`http`,url:`https://mcp.atlassian.com/v1/mcp/authv2`,auth:{type:`oauth`}})},sr={clubmed_api:JSON.stringify({type:`http`,url:`https://portal.api.clubmed/mcp`,headers:{"x-api-key":"${CLUBMED_API_MCP_KEY}"}}),cms_api:JSON.stringify({type:`http`,url:`https://cms.api.clubmed/mcp`,headers:{Authorization:"Bearer ${CMS_API_MCP_TOKEN}"}})},cr=[`atlassian@claude-plugins-official`],lr=[`LITELLM_API_KEY`,`ANTHROPIC_API_KEY`,`ANTHROPIC_BASE_URL`,`CLUBMED_API_MCP_KEY`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`],ur=[`CMS_API_MCP_TOKEN`];function z(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}const dr=(e,t)=>{let n=mr(fr(e));if(typeof n!=`string`)throw TypeError(`${t} must be a string or a file URL: ${n}.`);return n},fr=e=>pr(e)?e.toString():e,pr=e=>typeof e!=`string`&&e&&Object.getPrototypeOf(e)===String.prototype,mr=e=>e instanceof URL?ye(e):e,hr=(e,t=[],n={})=>{let r=dr(e,`First argument`),[i,a]=z(t)?[[],t]:[t,n];if(!Array.isArray(i))throw TypeError(`Second argument must be either an array of arguments or an options object: ${i}`);if(i.some(e=>typeof e==`object`&&!!e))throw TypeError(`Second argument must be an array of strings: ${i}`);let o=i.map(String),s=o.find(e=>e.includes(`\0`));if(s!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${s}`);if(!z(a))throw TypeError(`Last argument must be an options object: ${a}`);return[r,o,{__proto__:null,...a}]},{toString:gr}=Object.prototype,_r=e=>gr.call(e)===`[object ArrayBuffer]`,B=e=>gr.call(e)===`[object Uint8Array]`,vr=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),yr=new TextEncoder,br=e=>yr.encode(e),xr=new TextDecoder,Sr=e=>xr.decode(e),Cr=(e,t)=>wr(e,t).join(``),wr=(e,t)=>{if(t===`utf8`&&e.every(e=>typeof e==`string`))return e;let n=new be(t),r=e.map(e=>typeof e==`string`?br(e):e).map(e=>n.write(e)),i=n.end();return i===``?r:[...r,i]},Tr=e=>e.length===1&&B(e[0])?e[0]:Dr(Er(e)),Er=e=>e.map(e=>typeof e==`string`?br(e):e),Dr=e=>{let t=new Uint8Array(Or(e)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t},Or=e=>{let t=0;for(let n of e)t+=n.length;return t},kr=e=>Array.isArray(e)&&Array.isArray(e.raw),Ar=(e,t)=>{let n=[];for(let[r,i]of e.entries())n=jr({templates:e,expressions:t,tokens:n,index:r,template:i});if(n.length===0)throw TypeError(`Template script must not be empty`);let[r,...i]=n;return[r,i,{}]},jr=({templates:e,expressions:t,tokens:n,index:r,template:i})=>{if(i===void 0)throw TypeError(`Invalid backslash sequence: ${e.raw[r]}`);let{nextTokens:a,leadingWhitespaces:o,trailingWhitespaces:s}=Mr(i,e.raw[r]),c=Fr(n,a,o);if(r===t.length)return c;let l=t[r],u=Array.isArray(l)?l.map(e=>Ir(e)):[Ir(l)];return Fr(c,u,s)},Mr=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let n=[],r=0,i=Nr.has(t[0]);for(let i=0,a=0;i<e.length;i+=1,a+=1){let o=t[a];if(Nr.has(o))r!==i&&n.push(e.slice(r,i)),r=i+1;else if(o===`\\`){let e=t[a+1];e===`
|
|
86
|
+
`?(--i,a+=1):e===`u`&&t[a+2]===`{`?a=t.indexOf(`}`,a+3):a+=Pr[e]??1}}let a=r===e.length;return a||n.push(e.slice(r)),{nextTokens:n,leadingWhitespaces:i,trailingWhitespaces:a}},Nr=new Set([` `,` `,`\r`,`
|
|
87
|
+
`]),Pr={x:3,u:5},Fr=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],Ir=e=>{let t=typeof e;if(t===`string`)return e;if(t===`number`)return String(e);if(z(e)&&(`stdout`in e||`isMaxBuffer`in e))return Lr(e);throw e instanceof s||Object.prototype.toString.call(e)===`[object Promise]`?TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):TypeError(`Unexpected "${t}" in template expression`)},Lr=({stdout:e})=>{if(typeof e==`string`)return e;if(B(e))return Sr(e);throw TypeError(e===void 0?`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`:`Unexpected "${typeof e}" stdout in template expression`)},Rr=e=>zr.includes(e),zr=[w.stdin,w.stdout,w.stderr],V=[`stdin`,`stdout`,`stderr`],Br=e=>V[e]??`stdio[${e}]`,Vr=e=>{let t={...e};for(let n of $r)t[n]=Hr(e,n);return t},Hr=(e,t)=>{let n=Ur(e),r=Array.from({length:n+1}),i=Wr(e[t],r,t,n);return Zr(i,t)},Ur=({stdio:e})=>Array.isArray(e)?Math.max(e.length,V.length):V.length,Wr=(e,t,n,r)=>z(e)?Gr(e,t,n,r):t.fill(e),Gr=(e,t,n,r)=>{for(let i of Object.keys(e).sort(Kr))for(let a of Jr(i,n,r))t[a]=e[i];return t},Kr=(e,t)=>qr(e)<qr(t)?1:-1,qr=e=>e===`stdout`||e===`stderr`?0:e===`all`?2:1,Jr=(e,t,n)=>{if(e===`ipc`)return[n];let r=Yr(e);if(r===void 0||r===0)throw TypeError(`"${t}.${e}" is invalid.
|
|
88
|
+
It must be "${t}.stdout", "${t}.stderr", "${t}.all", "${t}.ipc", or "${t}.fd3", "${t}.fd4" (and so on).`);if(r!==`all`&&r>=n)throw TypeError(`"${t}.${e}" is invalid: that file descriptor does not exist.
|
|
89
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);return r===`all`?[1,2]:[r]},Yr=e=>{if(e===`all`)return e;if(V.includes(e))return V.indexOf(e);let t=Xr.exec(e);if(t!==null)return Number(t.groups.fdNumber)},Xr=/^fd(?<fdNumber>\d+)$/,Zr=(e,t)=>e.map(e=>e===void 0?Qr[t]:e),Qr={lines:!1,buffer:!0,maxBuffer:1e8,verbose:ce(`execa`).enabled?`full`:`none`,stripFinalNewline:!0},$r=[`lines`,`buffer`,`maxBuffer`,`verbose`,`stripFinalNewline`],ei=(e,t)=>t===`ipc`?e.at(-1):e[t],ti=({verbose:e},t)=>ii(e,t)!==`none`,ni=({verbose:e},t)=>![`none`,`short`].includes(ii(e,t)),ri=({verbose:e},t)=>{let n=ii(e,t);return oi(n)?n:void 0},ii=(e,t)=>t===void 0?ai(e):ei(e,t),ai=e=>e.find(e=>oi(e))??si.findLast(t=>e.includes(t)),oi=e=>typeof e==`function`,si=[`none`,`short`,`full`],ci=(e,t)=>{let n=[e,...t];return{command:n.join(` `),escapedCommand:n.map(e=>hi(ui(e))).join(` `)}},li=e=>de(e).split(`
|
|
90
|
+
`).map(e=>ui(e)).join(`
|
|
91
|
+
`),ui=e=>e.replaceAll(fi,e=>di(e)),di=e=>{let t=pi[e];if(t!==void 0)return t;let n=e.codePointAt(0),r=n.toString(16);return n<=mi?`\\u${r.padStart(4,`0`)}`:`\\U${r}`},fi=(()=>{try{return RegExp(`\\p{Separator}|\\p{Other}`,`gu`)}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}})(),pi={" ":` `,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`},mi=65535,hi=e=>gi.test(e)?e:re===`win32`?`"${e.replaceAll(`"`,`""`)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`,gi=/^[\w\-./]+$/;function _i(){let{env:e}=w,{TERM:t,TERM_PROGRAM:n}=e;return w.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const vi={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},yi={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},bi={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},xi={...vi,...yi},Si={...vi,...bi},H=_i()?xi:Si;Object.entries(yi);const Ci=me?.WriteStream?.prototype?.hasColors?.()??!1,U=(e,t)=>{if(!Ci)return e=>e;let n=`\u001B[${e}m`,r=`\u001B[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}};U(0,0);const wi=U(1,22);U(2,22),U(3,23),U(4,24),U(`4:2`,24),U(`4:3`,24),U(`4:4`,24),U(`4:5`,24),U(53,55),U(7,27),U(8,28),U(9,29),U(30,39),U(31,39),U(32,39),U(33,39),U(34,39),U(35,39),U(36,39),U(37,39);const Ti=U(90,39);U(40,49),U(41,49),U(42,49),U(43,49),U(44,49),U(45,49),U(46,49),U(47,49),U(100,49);const Ei=U(91,39);U(92,39);const Di=U(93,39);U(94,39),U(95,39),U(96,39),U(97,39),U(101,49),U(102,49),U(103,49),U(104,49),U(105,49),U(106,49),U(107,49),U(`58;5;0`,59),U(`58;5;1`,59),U(`58;5;2`,59),U(`58;5;3`,59),U(`58;5;4`,59),U(`58;5;5`,59),U(`58;5;6`,59),U(`58;5;7`,59),U(`58;5;8`,59),U(`58;5;9`,59),U(`58;5;10`,59),U(`58;5;11`,59),U(`58;5;12`,59),U(`58;5;13`,59),U(`58;5;14`,59),U(`58;5;15`,59);const Oi=({type:e,message:t,timestamp:n,piped:r,commandId:i,result:{failed:a=!1}={},options:{reject:o=!0}})=>{let s=ki(n),c=Mi[e]({failed:a,reject:o,piped:r}),l=Pi[e]({reject:o});return`${Ti(`[${s}]`)} ${Ti(`[${i}]`)} ${l(c)} ${l(t)}`},ki=e=>`${Ai(e.getHours(),2)}:${Ai(e.getMinutes(),2)}:${Ai(e.getSeconds(),2)}.${Ai(e.getMilliseconds(),3)}`,Ai=(e,t)=>String(e).padStart(t,`0`),ji=({failed:e,reject:t})=>e?t?H.cross:H.warning:H.tick,Mi={command:({piped:e})=>e?`|`:`$`,output:()=>` `,ipc:()=>`*`,error:ji,duration:ji},Ni=e=>e,Pi={command:()=>wi,output:()=>Ni,ipc:()=>Ni,error:({reject:e})=>e?Ei:Di,duration:()=>Ti},Fi=(e,t,n)=>{let r=ri(t,n);return e.map(({verboseLine:e,verboseObject:t})=>Ii(e,t,r)).filter(e=>e!==void 0).map(e=>Li(e)).join(``)},Ii=(e,t,n)=>{if(n===void 0)return e;let r=n(e,t);if(typeof r==`string`)return r},Li=e=>e.endsWith(`
|
|
92
|
+
`)?e:`${e}\n`,Ri=({type:e,verboseMessage:t,fdNumber:n,verboseInfo:r,result:i})=>{let a=zi({type:e,result:i,verboseInfo:r}),o=Bi(t,a),s=Fi(o,r,n);s!==``&&console.warn(s.slice(0,-1))},zi=({type:e,result:t,verboseInfo:n})=>{let{escapedCommand:r,commandId:i,rawOptions:a}=n,{piped:o=!1,...s}=a;return{type:e,escapedCommand:r,commandId:`${i}`,timestamp:new Date,piped:o,result:t,options:s}},Bi=(e,t)=>e.split(`
|
|
93
|
+
`).map(e=>Vi({...t,message:e})),Vi=e=>({verboseLine:Oi(e),verboseObject:e}),Hi=e=>{let t=typeof e==`string`?e:le(e);return li(t).replaceAll(` `,()=>` `.repeat(Ui))},Ui=2,Wi=(e,t)=>{ti(t)&&Ri({type:`command`,verboseMessage:e,verboseInfo:t})},Gi=(e,t,n)=>(Ji(e),{verbose:e,escapedCommand:t,commandId:Ki(e),rawOptions:n}),Ki=e=>ti({verbose:e})?qi++:void 0;let qi=0n;const Ji=e=>{for(let t of e){if(t===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(t===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!si.includes(t)&&!oi(t)){let e=si.map(e=>`'${e}'`).join(`, `);throw TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${e} or a function.`)}}},Yi=()=>ne.bigint(),Xi=e=>Number(ne.bigint()-e)/1e6,Zi=(e,t,n)=>{let r=Yi(),{command:i,escapedCommand:a}=ci(e,t),o=Hr(n,`verbose`),s=Gi(o,a,{...n});return Wi(a,s),{command:i,escapedCommand:a,startTime:r,verboseInfo:s}};function Qi(e={}){let{env:t=process.env,platform:n=process.platform}=e;return n===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`}ue(c);function $i(e){return e instanceof URL?ye(e):e}function ea(e){return{*[Symbol.iterator](){let t=d.resolve($i(e)),n;for(;n!==t;)yield t,n=t,t=d.resolve(t,`..`)}}}const ta=({cwd:e=w.cwd(),path:t=w.env[Qi()],preferLocal:n=!0,execPath:r=w.execPath,addExecPath:i=!0}={})=>{let a=d.resolve($i(e)),o=[],s=t.split(d.delimiter);return n&&na(o,s,a),i&&ra(o,s,r,a),t===``||t===d.delimiter?`${o.join(d.delimiter)}${t}`:[...o,t].join(d.delimiter)},na=(e,t,n)=>{for(let r of ea(n)){let n=d.join(r,`node_modules/.bin`);t.includes(n)||e.push(n)}},ra=(e,t,n,r)=>{let i=d.resolve(r,$i(n),`..`);t.includes(i)||e.push(i)},ia=({env:e=w.env,...t}={})=>{e={...e};let n=Qi({env:e});return t.path=e[n],e[n]=ta(t),e},aa=(e,t,n)=>new(n?fa:da)(t,e instanceof oa?{}:{cause:e});var oa=class extends Error{};const sa=(e,t)=>{Object.defineProperties(e.prototype,{name:{value:t,writable:!0,enumerable:!1,configurable:!0},[la]:{value:!0,writable:!1,enumerable:!1,configurable:!1}})},ca=e=>ua(e)&&la in e,la=Symbol(`isExecaError`),ua=e=>Object.prototype.toString.call(e)===`[object Error]`;var da=class extends Error{};sa(da,da.name);var fa=class extends Error{};sa(fa,fa.name);const pa=()=>{let e=64-ha+1;return Array.from({length:e},ma)},ma=(e,t)=>({name:`SIGRT${t+1}`,number:ha+t,action:`terminate`,description:`Application-specific signal (realtime)`,standard:`posix`}),ha=34,ga=[{name:`SIGHUP`,number:1,action:`terminate`,description:`Terminal closed`,standard:`posix`},{name:`SIGINT`,number:2,action:`terminate`,description:`User interruption with CTRL-C`,standard:`ansi`},{name:`SIGQUIT`,number:3,action:`core`,description:`User interruption with CTRL-\\`,standard:`posix`},{name:`SIGILL`,number:4,action:`core`,description:`Invalid machine instruction`,standard:`ansi`},{name:`SIGTRAP`,number:5,action:`core`,description:`Debugger breakpoint`,standard:`posix`},{name:`SIGABRT`,number:6,action:`core`,description:`Aborted`,standard:`ansi`},{name:`SIGIOT`,number:6,action:`core`,description:`Aborted`,standard:`bsd`},{name:`SIGBUS`,number:7,action:`core`,description:`Bus error due to misaligned, non-existing address or paging error`,standard:`bsd`},{name:`SIGEMT`,number:7,action:`terminate`,description:`Command should be emulated but is not implemented`,standard:`other`},{name:`SIGFPE`,number:8,action:`core`,description:`Floating point arithmetic error`,standard:`ansi`},{name:`SIGKILL`,number:9,action:`terminate`,description:`Forced termination`,standard:`posix`,forced:!0},{name:`SIGUSR1`,number:10,action:`terminate`,description:`Application-specific signal`,standard:`posix`},{name:`SIGSEGV`,number:11,action:`core`,description:`Segmentation fault`,standard:`ansi`},{name:`SIGUSR2`,number:12,action:`terminate`,description:`Application-specific signal`,standard:`posix`},{name:`SIGPIPE`,number:13,action:`terminate`,description:`Broken pipe or socket`,standard:`posix`},{name:`SIGALRM`,number:14,action:`terminate`,description:`Timeout or timer`,standard:`posix`},{name:`SIGTERM`,number:15,action:`terminate`,description:`Termination`,standard:`ansi`},{name:`SIGSTKFLT`,number:16,action:`terminate`,description:`Stack is empty or overflowed`,standard:`other`},{name:`SIGCHLD`,number:17,action:`ignore`,description:`Child process terminated, paused or unpaused`,standard:`posix`},{name:`SIGCLD`,number:17,action:`ignore`,description:`Child process terminated, paused or unpaused`,standard:`other`},{name:`SIGCONT`,number:18,action:`unpause`,description:`Unpaused`,standard:`posix`,forced:!0},{name:`SIGSTOP`,number:19,action:`pause`,description:`Paused`,standard:`posix`,forced:!0},{name:`SIGTSTP`,number:20,action:`pause`,description:`Paused using CTRL-Z or "suspend"`,standard:`posix`},{name:`SIGTTIN`,number:21,action:`pause`,description:`Background process cannot read terminal input`,standard:`posix`},{name:`SIGBREAK`,number:21,action:`terminate`,description:`User interruption with CTRL-BREAK`,standard:`other`},{name:`SIGTTOU`,number:22,action:`pause`,description:`Background process cannot write to terminal output`,standard:`posix`},{name:`SIGURG`,number:23,action:`ignore`,description:`Socket received out-of-band data`,standard:`bsd`},{name:`SIGXCPU`,number:24,action:`core`,description:`Process timed out`,standard:`bsd`},{name:`SIGXFSZ`,number:25,action:`core`,description:`File too big`,standard:`bsd`},{name:`SIGVTALRM`,number:26,action:`terminate`,description:`Timeout or timer`,standard:`bsd`},{name:`SIGPROF`,number:27,action:`terminate`,description:`Timeout or timer`,standard:`bsd`},{name:`SIGWINCH`,number:28,action:`ignore`,description:`Terminal window size changed`,standard:`bsd`},{name:`SIGIO`,number:29,action:`terminate`,description:`I/O is available`,standard:`other`},{name:`SIGPOLL`,number:29,action:`terminate`,description:`Watched event`,standard:`other`},{name:`SIGINFO`,number:29,action:`ignore`,description:`Request for process information`,standard:`other`},{name:`SIGPWR`,number:30,action:`terminate`,description:`Device running out of power`,standard:`systemv`},{name:`SIGSYS`,number:31,action:`core`,description:`Invalid system call`,standard:`other`},{name:`SIGUNUSED`,number:31,action:`terminate`,description:`Invalid system call`,standard:`other`}],_a=()=>{let e=pa();return[...ga,...e].map(va)},va=({name:e,number:t,description:n,action:r,forced:i=!1,standard:a})=>{let{signals:{[e]:o}}=_e,s=o!==void 0;return{name:e,number:s?o:t,description:n,supported:s,action:r,forced:i,standard:a}},ya=()=>{let e=_a();return Object.fromEntries(e.map(ba))},ba=({name:e,number:t,description:n,supported:r,action:i,forced:a,standard:o})=>[e,{name:e,number:t,description:n,supported:r,action:i,forced:a,standard:o}],xa=ya(),Sa=()=>{let e=_a(),t=Array.from({length:65},(t,n)=>Ca(n,e));return Object.assign({},...t)},Ca=(e,t)=>{let n=wa(e,t);if(n===void 0)return{};let{name:r,description:i,supported:a,action:o,forced:s,standard:c}=n;return{[e]:{name:r,number:e,description:i,supported:a,action:o,forced:s,standard:c}}},wa=(e,t)=>{let n=t.find(({name:t})=>_e.signals[t]===e);return n===void 0?t.find(t=>t.number===e):n};Sa();const Ta=e=>{let t="option `killSignal`";if(e===0)throw TypeError(`Invalid ${t}: 0 cannot be used.`);return Da(e,t)},Ea=e=>e===0?e:Da(e,"`subprocess.kill()`'s argument"),Da=(e,t)=>{if(Number.isInteger(e))return Oa(e,t);if(typeof e==`string`)return Aa(e,t);throw TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.\n${ja()}`)},Oa=(e,t)=>{if(ka.has(e))return ka.get(e);throw TypeError(`Invalid ${t} ${e}: this signal integer does not exist.\n${ja()}`)},ka=new Map(Object.entries(_e.signals).reverse().map(([e,t])=>[t,e])),Aa=(e,t)=>{if(e in _e.signals)return e;throw e.toUpperCase()in _e.signals?TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`):TypeError(`Invalid ${t} '${e}': this signal name does not exist.\n${ja()}`)},ja=()=>`Available signal names: ${Ma()}.
|
|
94
|
+
Available signal numbers: ${Na()}.`,Ma=()=>Object.keys(_e.signals).sort().map(e=>`'${e}'`).join(`, `),Na=()=>[...new Set(Object.values(_e.signals).sort((e,t)=>e-t))].join(`, `),Pa=e=>xa[e].description,Fa=e=>{if(e===!1)return e;if(e===!0)return Ia;if(!Number.isFinite(e)||e<0)throw TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Ia=5e3,La=({kill:e,options:{forceKillAfterDelay:t,killSignal:n},onInternalError:r,context:i,controller:a},o,s)=>{let{signal:c,error:l}=Ra(o,s,n);za(l,r);let u=e(c);return Ba({kill:e,signal:c,forceKillAfterDelay:t,killSignal:n,killResult:u,context:i,controller:a}),u},Ra=(e,t,n)=>{let[r=n,i]=ua(e)?[void 0,e]:[e,t];if(typeof r!=`string`&&!Number.isInteger(r))throw TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(r)}`);if(i!==void 0&&!ua(i))throw TypeError(`The second argument is optional. If specified, it must be an error instance: ${i}`);return{signal:Ea(r),error:i}},za=(e,t)=>{e!==void 0&&t.reject(e)},Ba=async({kill:e,signal:t,forceKillAfterDelay:n,killSignal:r,killResult:i,context:a,controller:o})=>{t===r&&i&&Va({kill:e,forceKillAfterDelay:n,context:a,controllerSignal:o.signal})},Va=async({kill:e,forceKillAfterDelay:t,context:n,controllerSignal:r})=>{if(t!==!1)try{await Ce(t,void 0,{signal:r}),e(`SIGKILL`)&&(n.isForcefullyTerminated??=!0)}catch{}},Ha=async(e,t)=>{e.aborted||await i(e,`abort`,{signal:t})},Ua=({cancelSignal:e})=>{if(e!==void 0&&Object.prototype.toString.call(e)!==`[object AbortSignal]`)throw Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(e)}`)},Wa=({kill:e,cancelSignal:t,gracefulCancel:n,context:r,controller:i})=>t===void 0||n?[]:[Ga(e,t,r,i)],Ga=async(e,t,n,{signal:r})=>{throw await Ha(t,r),n.terminationReason??=`cancel`,e(),t.reason},Ka=({methodName:e,isSubprocess:t,ipc:n,isConnected:r})=>{qa(e,t,n),Ja(e,t,r)},qa=(e,t,n)=>{if(!n)throw Error(`${W(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},Ja=(e,t,n)=>{if(!n)throw Error(`${W(e,t)} cannot be used: the ${co(t)} has already exited or disconnected.`)},Ya=e=>{throw Error(`${W(`getOneMessage`,e)} could not complete: the ${co(e)} exited or disconnected.`)},Xa=e=>{throw Error(`${W(`sendMessage`,e)} failed: the ${co(e)} is sending a message too, instead of listening to incoming messages.
|
|
95
|
+
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
96
|
+
|
|
97
|
+
const [receivedMessage] = await Promise.all([
|
|
98
|
+
${W(`getOneMessage`,e)},
|
|
99
|
+
${W(`sendMessage`,e,`message, {strict: true}`)},
|
|
100
|
+
]);`)},Za=(e,t)=>Error(`${W(`sendMessage`,t)} failed when sending an acknowledgment response to the ${co(t)}.`,{cause:e}),Qa=e=>{throw Error(`${W(`sendMessage`,e)} failed: the ${co(e)} is not listening to incoming messages.`)},$a=e=>{throw Error(`${W(`sendMessage`,e)} failed: the ${co(e)} exited without listening to incoming messages.`)},eo=()=>Error(`\`cancelSignal\` aborted: the ${co(!0)} disconnected.`),to=()=>{throw Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},no=({error:e,methodName:t,isSubprocess:n})=>{if(e.code===`EPIPE`)throw Error(`${W(t,n)} cannot be used: the ${co(n)} is disconnecting.`,{cause:e})},ro=({error:e,methodName:t,isSubprocess:n,message:r})=>{if(io(e))throw Error(`${W(t,n)}'s argument type is invalid: the message cannot be serialized: ${String(r)}.`,{cause:e})},io=({code:e,message:t})=>ao.has(e)||oo.some(e=>t.includes(e)),ao=new Set([`ERR_MISSING_ARGS`,`ERR_INVALID_ARG_TYPE`]),oo=[`could not be cloned`,`circular structure`,`call stack size exceeded`],W=(e,t,n=``)=>e===`cancelSignal`?"`cancelSignal`'s `controller.abort()`":`${so(t)}${e}(${n})`,so=e=>e?``:`subprocess.`,co=e=>e?`parent process`:`subprocess`,lo=e=>{e.connected&&e.disconnect()},uo=()=>{let e={},t=new Promise((t,n)=>{Object.assign(e,{resolve:t,reject:n})});return Object.assign(t,e)},fo=(e,t,r)=>{let i=e.getMaxListeners();i!==0&&i!==1/0&&(e.setMaxListeners(i+t),n(r,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))},po=(e,t)=>{t&&mo(e)},mo=e=>{e.refCounted()},ho=(e,t)=>{t&&go(e)},go=e=>{e.unrefCounted()},_o=(e,t)=>{t&&(go(e),go(e))},vo=(e,t)=>{t&&(mo(e),mo(e))},yo=async({anyProcess:e,channel:t,isSubprocess:n,ipcEmitter:r},i)=>{if(Ao(i)||es(i))return;xo.has(e)||xo.set(e,[]);let a=xo.get(e);if(a.push(i),!(a.length>1))for(;a.length>0;){await Ro(e,r,i),await xe.yield();let o=await ko({wrappedMessage:a[0],anyProcess:e,channel:t,isSubprocess:n,ipcEmitter:r});a.shift(),r.emit(`message`,o),r.emit(`message:done`)}},bo=async({anyProcess:e,channel:t,isSubprocess:n,ipcEmitter:r,boundOnMessage:a})=>{ns();let o=xo.get(e);for(;o?.length>0;)await i(r,`message:done`);e.removeListener(`message`,a),vo(t,n),r.connected=!1,r.emit(`disconnect`)},xo=new WeakMap,So=(e,n,r)=>{if(Co.has(e))return Co.get(e);let i=new t;return i.connected=!0,Co.set(e,i),wo({ipcEmitter:i,anyProcess:e,channel:n,isSubprocess:r}),i},Co=new WeakMap,wo=({ipcEmitter:e,anyProcess:t,channel:n,isSubprocess:r})=>{let i=yo.bind(void 0,{anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:e});t.on(`message`,i),t.once(`disconnect`,bo.bind(void 0,{anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:e,boundOnMessage:i})),_o(n,r)},To=e=>{let t=Co.get(e);return t===void 0?e.channel!==void 0&&e.channel!==null:t.connected},Eo=({anyProcess:e,channel:t,isSubprocess:n,message:r,strict:i})=>{if(!i)return r;let a=So(e,t,n),o=Ho(e,a);return{id:Do++,type:Po,message:r,hasListeners:o}};let Do=0n;const Oo=(e,t)=>{if(!(t?.type!==Po||t.hasListeners))for(let{id:t}of e)t!==void 0&&Mo[t].resolve({isDeadlock:!0,hasListeners:!1})},ko=async({wrappedMessage:e,anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:i})=>{if(e?.type!==Po||!t.connected)return e;let{id:a,message:o}=e,s={id:a,type:Fo,message:Ho(t,i)};try{await Go({anyProcess:t,channel:n,isSubprocess:r,ipc:!0},s)}catch(e){i.emit(`strict:error`,e)}return o},Ao=e=>{if(e?.type!==Fo)return!1;let{id:t,message:n}=e;return Mo[t]?.resolve({isDeadlock:!1,hasListeners:n}),!0},jo=async(e,t,n)=>{if(e?.type!==Po)return;let r=uo();Mo[e.id]=r;let i=new AbortController;try{let{isDeadlock:e,hasListeners:a}=await Promise.race([r,No(t,n,i)]);e&&Xa(n),a||Qa(n)}finally{i.abort(),delete Mo[e.id]}},Mo={},No=async(e,t,{signal:n})=>{fo(e,1,n),await i(e,`disconnect`,{signal:n}),$a(t)},Po=`execa:ipc:request`,Fo=`execa:ipc:response`,Io=(e,t,n)=>{zo.has(e)||zo.set(e,new Set);let r=zo.get(e),i={onMessageSent:uo(),id:n?t.id:void 0};return r.add(i),{outgoingMessages:r,outgoingMessage:i}},Lo=({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()},Ro=async(e,t,n)=>{for(;!Ho(e,t)&&zo.get(e)?.size>0;){let t=[...zo.get(e)];Oo(t,n),await Promise.all(t.map(({onMessageSent:e})=>e))}},zo=new WeakMap,Bo=new WeakMap,Vo=(e,t)=>{Bo.set(e,t)},Ho=(e,t)=>t.listenerCount(`message`)>Uo(e),Uo=e=>+(Wo(e)!==void 0&&!ei(Wo(e).buffer,`ipc`)),Wo=e=>Bo.get(e),Go=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},i,{strict:a=!1}={})=>{let o=`sendMessage`;return Ka({methodName:o,isSubprocess:n,ipc:r,isConnected:e.connected}),Ko({anyProcess:e,channel:t,methodName:o,isSubprocess:n,message:i,strict:a})},Ko=async({anyProcess:e,channel:t,methodName:n,isSubprocess:r,message:i,strict:a})=>{let o=Eo({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:a}),s=Io(e,o,a);try{await qo({anyProcess:e,methodName:n,isSubprocess:r,wrappedMessage:o,message:i})}catch(t){throw lo(e),t}finally{Lo(s)}},qo=async({anyProcess:e,methodName:t,isSubprocess:n,wrappedMessage:r,message:i})=>{let a=Jo(e);try{await Promise.all([jo(r,e,n),a(r)])}catch(e){throw no({error:e,methodName:t,isSubprocess:n}),ro({error:e,methodName:t,isSubprocess:n,message:i}),e}},Jo=e=>{if(Yo.has(e))return Yo.get(e);let t=ue(e.send.bind(e));return Yo.set(e,t),t},Yo=new WeakMap,Xo=(e,t)=>{let n=`cancelSignal`;return Ja(n,!1,e.connected),qo({anyProcess:e,methodName:n,isSubprocess:!1,wrappedMessage:{type:ts,message:t},message:t})},Zo=async({anyProcess:e,channel:t,isSubprocess:n,ipc:r})=>(await Qo({anyProcess:e,channel:t,isSubprocess:n,ipc:r}),rs.signal),Qo=async({anyProcess:e,channel:t,isSubprocess:n,ipc:r})=>{if(!$o){if($o=!0,!r){to();return}if(t===null){ns();return}So(e,t,n),await xe.yield()}};let $o=!1;const es=e=>e?.type===ts&&(rs.abort(e.message),!0),ts=`execa:ipc:cancel`,ns=()=>{rs.abort(eo())},rs=new AbortController,is=({gracefulCancel:e,cancelSignal:t,ipc:n,serialization:r})=>{if(e){if(t===void 0)throw Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!n)throw Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(r===`json`)throw Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")}},as=({subprocess:e,kill:t,cancelSignal:n,gracefulCancel:r,forceKillAfterDelay:i,context:a,controller:o})=>r?[os({subprocess:e,kill:t,cancelSignal:n,forceKillAfterDelay:i,context:a,controller:o})]:[],os=async({subprocess:e,kill:t,cancelSignal:n,forceKillAfterDelay:r,context:i,controller:{signal:a}})=>{await Ha(n,a);let o=ss(n);throw await Xo(e,o),Va({kill:t,forceKillAfterDelay:r,context:i,controllerSignal:a}),i.terminationReason??=`gracefulCancel`,n.reason},ss=({reason:e})=>{if(!(e instanceof DOMException))return e;let t=Error(e.message);return Object.defineProperty(t,"stack",{value:e.stack,enumerable:!1,configurable:!0,writable:!0}),t},cs=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},ls=(e,t,n,r)=>t===0||t===void 0?[]:[us(e,t,n,r)],us=async(e,t,n,{signal:r})=>{throw await Ce(t,void 0,{signal:r}),n.terminationReason??=`timeout`,e(),new oa},ds=({options:e})=>{if(e.node===!1)throw TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}},fs=(e,t,{node:n=!1,nodePath:r=te,nodeOptions:i=ee.filter(e=>!e.startsWith(`--inspect`)),cwd:a,execPath:o,...s})=>{if(o!==void 0)throw TypeError(`The "execPath" option has been removed. Please use the "nodePath" option instead.`);let c=dr(r,`The "nodePath" option`),l=d.resolve(a,c),u={__proto__:null,shell:!1,...s,nodePath:l,node:n,cwd:a};if(!n)return[e,t,u];if(d.basename(e,`.exe`)===`node`)throw TypeError(`When the "node" option is true, the first argument does not need to be "node".`);return[l,[...i,e,...t],{__proto__:null,ipc:!0,...u,shell:!1}]},ps=({ipcInput:e,ipc:t,serialization:n})=>{if(e!==void 0){if(!t)throw Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");ms[n](e)}},ms={advanced:e=>{try{we(e)}catch(e){throw Error("The `ipcInput` option is not serializable with a structured clone.",{cause:e})}},json:e=>{try{JSON.stringify(e)}catch(e){throw Error("The `ipcInput` option is not serializable with JSON.",{cause:e})}}},hs=async(e,t,n)=>{t!==void 0&&await Go({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:n},t)},gs=({encoding:e})=>{if(ys.has(e))return;let t=bs(e);if(t!==void 0)throw TypeError(`Invalid option \`encoding: ${Ss(e)}\`.
|
|
101
|
+
Please rename it to ${Ss(t)}.`);let n=[...ys].map(e=>Ss(e)).join(`, `);throw TypeError(`Invalid option \`encoding: ${Ss(e)}\`.
|
|
102
|
+
Please rename it to one of: ${n}.`)},_s=new Set([`utf8`,`utf16le`]),vs=new Set([`buffer`,`hex`,`base64`,`base64url`,`latin1`,`ascii`]),ys=_s.union(vs),bs=e=>{if(e===null)return`buffer`;if(typeof e!=`string`)return;let t=e.toLowerCase();if(t in xs)return xs[t];if(ys.has(t))return t},xs={"utf-8":`utf8`,"utf-16le":`utf16le`,"ucs-2":`utf16le`,ucs2:`utf16le`,binary:`latin1`},Ss=e=>typeof e==`string`?`"${e}"`:String(e),Cs=w.platform===`win32`,ws=Cs?/[\/\\]/v:/\//v;function Ts(e,t){if(typeof e!=`string`||e.length===0)throw TypeError(`Expected a non-empty string.`);let{cwd:n=w.cwd(),path:r=w.env.PATH??(Cs?w.env.Path:void 0)??``,pathExt:i=w.env.PATHEXT||`.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC`}=t;return{cwd:n,searchPath:r,pathExt:i}}function Es(e,t){let n=t.split(d.delimiter).filter(Boolean),r=d.extname(e).toLowerCase();return r!==``&&n.some(e=>e.toLowerCase()===r)?[``,...n]:n}function*Ds(e,{cwd:t,searchPath:n,pathExt:r}){let i=Cs?Es(e,r):[``];if(ws.test(e)){let n=d.resolve(t,e);for(let e of i)yield n+e;return}let a=[...Cs?[t]:[],...n.split(d.delimiter)];for(let n of a){let r=Cs&&n.length>1&&n.startsWith(`"`)&&n.endsWith(`"`)?n.slice(1,-1):n;if(r===``)continue;let a=d.resolve(t,r,e);for(let e of i)yield a+e}}function Os(e){let t;try{t=m.statSync(e)}catch(e){return Cs&&e.code===`EACCES`}if(!t.isFile())return!1;if(Cs)return!0;try{return m.accessSync(e,m.constants.X_OK),!0}catch{return!1}}function ks(e,t={}){let n=Ts(e,t);for(let t of Ds(e,n))if(Os(t))return t}const As=(e,t,n)=>{let r={file:e,commandArguments:[...t],options:n};return n.shell||w.platform!==`win32`?r:Ns(r)},js=/\.(?:com|exe)$/i,Ms=/\.(?:bat|cmd)$/i,Ns=e=>{let t=Ps(e);if(t!==void 0&&js.test(t))return e.options.argv0===void 0&&(e.options.argv0=e.file),e.file=t,e;for(let t of[e.file,...e.commandArguments])Ws(t);let n=t!==void 0&&Ms.test(t),r=`"${[Ks(d.normalize(t??e.file)),...e.commandArguments.map(e=>Js(e,n))].join(` `)}"`;return e.options.windowsVerbatimArguments=!0,{file:w.env.comspec||`cmd.exe`,commandArguments:[`/d`,`/s`,`/c`,r],options:e.options}},Ps=e=>{let t=Fs(e),n=t!==void 0&&Bs(t);return n?(e.commandArguments.unshift(t),e.file=n,Fs(e)):t},Fs=e=>{let t=e.options.env||w.env,n=e.options.cwd??w.cwd(),r=zs(t,`PATHEXT`),i=d.extname(e.file),a=i===``?r:`${i}${d.delimiter}${r??``}`;if(Is(e.file))return ks(d.resolve(n,e.file),{cwd:n,pathExt:a});let o={cwd:n,path:zs(t,`PATH`)??zs(w.env,`PATH`)??``,pathExt:a};return Ls(t)?ks(e.file,o):Rs(e.file,o)},Is=e=>e.includes(`/`)||e.includes(`\\`)||e.includes(`:`),Ls=e=>zs(w.env,`NODEFAULTCURRENTDIRECTORYINEXEPATH`)===void 0&&zs(e,`NODEFAULTCURRENTDIRECTORYINEXEPATH`)===void 0,Rs=(e,{cwd:t,path:n,pathExt:r})=>{for(let i of n.split(d.delimiter)){let n=i.length>1&&i.startsWith(`"`)&&i.endsWith(`"`)?i.slice(1,-1):i;if(n===``)continue;let a=ks(d.resolve(t,n,e),{cwd:t,pathExt:r});if(a!==void 0)return a}},zs=(e,t)=>{let n=Object.keys(e).sort().find(e=>e.toUpperCase()===t);return n===void 0?void 0:e[n]},Bs=e=>{let t=Te.alloc(150);try{let n=y(e,`r`);try{x(n,t,0,150,0)}finally{g(n)}}catch{return}return Hs(t.toString())},Vs=/^#!(?<line>.*)/,Hs=e=>{let t=e.match(Vs)?.groups.line.trim();if(!t)return;let[n,r]=t.split(` `),i=n.split(`/`).at(-1);return i===`env`?r:r?`${i} ${r}`:i},Us=/[\n\r]/,Ws=e=>{if(Us.test(e))throw TypeError(`The command and its arguments cannot contain a line break on Windows without a shell.\nThis would allow a command injection with \`cmd.exe\`.\nInvalid value: ${JSON.stringify(`${e}`)}`)},Gs=/[()\][%!^"`<>&|;, *?]/g,Ks=e=>e.replaceAll(Gs,`^$&`),qs=/\\+/g,Js=(e,t)=>{let n=`${e}`.replaceAll(qs,(e,t,n)=>{let r=n[t+e.length];return r===`"`||r===void 0?e.repeat(2):e}).replaceAll(`"`,`\\"`),r=Ks(`"${n}"`);return t?Ks(r):r},Ys=(e=Xs())=>{let t=dr(e,`The "cwd" option`);return d.resolve(t)},Xs=()=>{try{return w.cwd()}catch(e){throw e.message=`The current directory does not exist.\n${e.message}`,e}},Zs=(e,t)=>{if(t===Xs())return e;let n;try{n=S(t)}catch(n){return`The "cwd" option is invalid: ${t}.\n${n.message}\n${e}`}return n.isDirectory()?e:`The "cwd" option is not a directory: ${t}.\n${e}`},Qs=/^cmd(?:\.exe)?$/i,$s=(e,t,n)=>{let r={__proto__:null,...n};r.cwd=Ys(r.cwd);let[i,a,o]=fs(e,t,r),s=Vr(o),c=ec(s);c.env=tc(c);let{file:l,commandArguments:u}=As(i,a,c);return cs(c),gs(c),ps(c),Ua(c),is(c),c.shell=mr(c.shell),c.killSignal=Ta(c.killSignal),c.forceKillAfterDelay=Fa(c.forceKillAfterDelay),c.lines=c.lines.map((e,t)=>e&&!vs.has(c.encoding)&&c.buffer[t]),w.platform===`win32`&&Qs.test(d.basename(l))&&u.unshift(`/q`),{file:l,commandArguments:u,options:c}},ec=({extendEnv:e=!0,preferLocal:t=!1,cwd:n,localDir:r=n,encoding:i=`utf8`,reject:a=!0,cleanup:o=!0,killDescendants:s=!1,all:c=!1,windowsHide:l=!0,killSignal:u=`SIGTERM`,forceKillAfterDelay:d=!0,gracefulCancel:f=!1,ipcInput:p,ipc:m=p!==void 0||f,serialization:h=`advanced`,...g})=>({__proto__:null,...g,extendEnv:e,preferLocal:t,cwd:n,localDirectory:r,encoding:i,reject:a,cleanup:o,killDescendants:s,all:c,windowsHide:l,killSignal:u,forceKillAfterDelay:d,gracefulCancel:f,ipcInput:p,ipc:m,serialization:h}),tc=({env:e,extendEnv:t,preferLocal:n,node:r,localDirectory:i,nodePath:a})=>{let o=t?{...w.env,...e}:e;return n||r?ia({env:o,cwd:i,execPath:a,preferLocal:n,addExecPath:r}):o},nc=(e,t,n)=>n.shell&&t.length>0?[[e,...t].join(` `),[],n]:[e,t,n];function rc(e){if(typeof e==`string`)return ic(e);if(!(ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1))throw Error(`Input must be a string or a Uint8Array`);return ac(e)}const ic=e=>e.at(-1)===oc?e.slice(0,e.at(-2)===cc?-2:-1):e,ac=e=>e.at(-1)===sc?e.subarray(0,e.at(-2)===lc?-2:-1):e,oc=`
|
|
103
|
+
`,sc=`
|
|
104
|
+
`.codePointAt(0),cc=`\r`,lc=`\r`.codePointAt(0);function uc(e,{checkOpen:t=!0}={}){return typeof e==`object`&&!!e&&(e.writable||e.readable||!t||e.writable===void 0&&e.readable===void 0)&&typeof e.pipe==`function`}function dc(e,{checkOpen:t=!0}={}){return uc(e,{checkOpen:t})&&(e.writable||!t)&&typeof e.write==`function`&&typeof e.end==`function`&&typeof e.writable==`boolean`&&typeof e.writableObjectMode==`boolean`&&typeof e.destroy==`function`&&typeof e.destroyed==`boolean`}function fc(e,{checkOpen:t=!0}={}){return uc(e,{checkOpen:t})&&(e.readable||!t)&&typeof e.read==`function`&&typeof e.readable==`boolean`&&typeof e.readableObjectMode==`boolean`&&typeof e.destroy==`function`&&typeof e.destroyed==`boolean`}function pc(e,t){return dc(e,t)&&fc(e,t)}const mc=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);var hc=class{#e;#t;#n=!1;#r=void 0;constructor(e,t){this.#e=e,this.#t=t}next(){let e=()=>this.#i();return this.#r=this.#r?this.#r.then(e,e):e(),this.#r}return(e){let t=()=>this.#a(e);return this.#r?this.#r.then(t,t):t()}async#i(){if(this.#n)return{done:!0,value:void 0};let e;try{e=await this.#e.read()}catch(e){throw this.#r=void 0,this.#n=!0,this.#e.releaseLock(),e}return e.done&&(this.#r=void 0,this.#n=!0,this.#e.releaseLock()),e}async#a(e){if(this.#n)return{done:!0,value:e};if(this.#n=!0,!this.#t){let t=this.#e.cancel(e);return this.#e.releaseLock(),await t,{done:!0,value:e}}return this.#e.releaseLock(),{done:!0,value:e}}};const gc=Symbol();function _c(){return this[gc].next()}Object.defineProperty(_c,"name",{value:`next`});function vc(e){return this[gc].return(e)}Object.defineProperty(vc,"name",{value:`return`});const yc=Object.create(mc,{next:{enumerable:!0,configurable:!0,writable:!0,value:_c},return:{enumerable:!0,configurable:!0,writable:!0,value:vc}});function bc({preventCancel:e=!1}={}){let t=new hc(this.getReader(),e),n=Object.create(yc);return n[gc]=t,n}const xc=e=>{if(fc(e,{checkOpen:!1})&&Tc.on!==void 0)return Cc(e);if(typeof e?.[Symbol.asyncIterator]==`function`)return e;if(Sc.call(e)===`[object ReadableStream]`)return bc.call(e);throw TypeError(`The first argument must be a Readable, a ReadableStream, or an async iterable.`)},{toString:Sc}=Object.prototype,Cc=async function*(e){let t=new AbortController,n={};wc(e,t,n);try{for await(let[n]of Tc.on(e,`data`,{signal:t.signal}))yield n}catch(e){if(n.error!==void 0)throw n.error;if(!t.signal.aborted)throw e}finally{e.destroy()}},wc=async(e,t,n)=>{try{await Tc.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(e){n.error=e}finally{t.abort()}},Tc={},Ec=async(e,{init:t,convertChunk:n,getSize:r,truncateChunk:i,addChunk:a,getFinalChunk:o,finalize:s},{maxBuffer:c=1/0}={})=>{let l=xc(e),u=t();u.length=0;try{for await(let e of l){let t=n[Ac(e)](e,u);Oc({convertedChunk:t,state:u,getSize:r,truncateChunk:i,addChunk:a,maxBuffer:c})}return Dc({state:u,convertChunk:n,getSize:r,truncateChunk:i,addChunk:a,getFinalChunk:o,maxBuffer:c}),s(u)}catch(e){let t=typeof e==`object`&&e?e:Error(e);throw t.bufferedData=s(u),t}},Dc=({state:e,getSize:t,truncateChunk:n,addChunk:r,getFinalChunk:i,maxBuffer:a})=>{let o=i(e);o!==void 0&&Oc({convertedChunk:o,state:e,getSize:t,truncateChunk:n,addChunk:r,maxBuffer:a})},Oc=({convertedChunk:e,state:t,getSize:n,truncateChunk:r,addChunk:i,maxBuffer:a})=>{let o=n(e),s=t.length+o;if(s<=a){kc(e,t,i,s);return}let c=r(e,a-t.length);throw c!==void 0&&kc(c,t,i,a),new Mc},kc=(e,t,n,r)=>{t.contents=n(e,t,r),t.length=r},Ac=e=>{let t=typeof e;if(t===`string`)return`string`;if(t!==`object`||e===null)return`others`;if(globalThis.Buffer?.isBuffer(e))return`buffer`;let n=jc.call(e);return n===`[object ArrayBuffer]`?`arrayBuffer`:n===`[object DataView]`?`dataView`:Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&jc.call(e.buffer)===`[object ArrayBuffer]`?`typedArray`:`others`},{toString:jc}=Object.prototype;var Mc=class extends Error{name=`MaxBufferError`;constructor(){super(`maxBuffer exceeded`)}};const Nc=e=>e,Pc=()=>void 0,Fc=({contents:e})=>e,Ic=e=>{throw Error(`Streams in object mode are not supported: ${String(e)}`)},Lc=e=>e.length;async function Rc(e,t){return Ec(e,zc,t)}const zc={init:()=>({contents:[]}),convertChunk:{string:Nc,buffer:Nc,arrayBuffer:Nc,dataView:Nc,typedArray:Nc,others:Nc},getSize:()=>1,truncateChunk:Pc,addChunk:(e,{contents:t})=>(t.push(e),t),getFinalChunk:Pc,finalize:Fc};async function Bc(e,t){return Ec(e,el,t)}const Vc=()=>({contents:new ArrayBuffer(0)}),Hc=e=>Uc.encode(e),Uc=new TextEncoder,Wc=e=>new Uint8Array(e),Gc=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Kc=(e,t)=>e.slice(0,t),qc=(e,{contents:t,length:n},r)=>{let i=$c()?Yc(t,r):Jc(t,r);return new Uint8Array(i).set(e,n),i},Jc=(e,t)=>{if(t<=e.byteLength)return e;let n=new ArrayBuffer(Xc(t));return new Uint8Array(n).set(new Uint8Array(e),0),n},Yc=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let n=new ArrayBuffer(t,{maxByteLength:Xc(t)});return new Uint8Array(n).set(new Uint8Array(e),0),n},Xc=e=>Zc**Math.ceil(Math.log(e)/Math.log(Zc)),Zc=2,Qc=({contents:e,length:t})=>$c()?e:e.slice(0,t),$c=()=>`resize`in ArrayBuffer.prototype,el={init:Vc,convertChunk:{string:Hc,buffer:Wc,arrayBuffer:Wc,dataView:Gc,typedArray:Gc,others:Ic},getSize:Lc,truncateChunk:Kc,addChunk:qc,getFinalChunk:Pc,finalize:Qc};async function tl(e,t){return Ec(e,il,t)}const nl=()=>({contents:``,textDecoder:new TextDecoder}),rl=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),il={init:nl,convertChunk:{string:Nc,buffer:rl,arrayBuffer:rl,dataView:rl,typedArray:rl,others:Ic},getSize:Lc,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t})=>t+e,getFinalChunk:({textDecoder:e})=>{let t=e.decode();return t===``?void 0:t},finalize:Fc},al=({error:e,stream:t,readableObjectMode:n,lines:r,encoding:i,fdNumber:a})=>{if(!(e instanceof Mc))throw e;if(a===`all`)return e;throw e.maxBufferInfo={fdNumber:a,unit:ol(n,r,i)},t.destroy(),e},ol=(e,t,n)=>e?`objects`:t?`lines`:n===`buffer`?`bytes`:`characters`,sl=(e,t,n)=>{if(t.length!==n)return;let r=new Mc;throw r.maxBufferInfo={fdNumber:`ipc`},r},cl=(e,t)=>{let{streamName:n,threshold:r,unit:i}=ll(e,t);return`Command's ${n} was larger than ${r} ${i}`},ll=(e,t)=>{if(e?.maxBufferInfo===void 0)return{streamName:`output`,threshold:t[1],unit:`bytes`};let{maxBufferInfo:{fdNumber:n,unit:r}}=e;delete e.maxBufferInfo;let i=ei(t,n);return n===`ipc`?{streamName:`IPC output`,threshold:i,unit:`messages`}:{streamName:Br(n),threshold:i,unit:r}},ul=(e,t,n)=>e?.code===`ENOBUFS`&&t!==null&&t.some(e=>e!==null&&e.length>fl(n)),dl=(e,t,n)=>{if(!t)return e;let r=fl(n);return e.length>r?e.slice(0,r):e},fl=([,e])=>e,pl=({stdio:e,all:t,ipcOutput:n,originalError:r,signal:i,signalDescription:a,exitCode:o,escapedCommand:s,timedOut:c,isCanceled:l,isGracefullyCanceled:u,isMaxBuffer:d,isForcefullyTerminated:f,forceKillAfterDelay:p,killSignal:m,maxBuffer:h,timeout:g,cwd:_})=>{let v=r?.code,y=ml({originalError:r,timedOut:c,timeout:g,isMaxBuffer:d,maxBuffer:h,errorCode:v,signal:i,signalDescription:a,exitCode:o,isCanceled:l,isGracefullyCanceled:u,isForcefullyTerminated:f,forceKillAfterDelay:p,killSignal:m}),b=gl(r,_),x=`${y}: ${s}${b===void 0?``:`\n${b}`}`;return{originalMessage:b,shortMessage:x,message:[x,...t===void 0?[e[2],e[1]]:[t],...e.slice(3),n.map(e=>_l(e)).join(`
|
|
105
|
+
`)].map(e=>li(rc(vl(e)))).filter(Boolean).join(`
|
|
106
|
+
|
|
107
|
+
`)}},ml=({originalError:e,timedOut:t,timeout:n,isMaxBuffer:r,maxBuffer:i,errorCode:a,signal:o,signalDescription:s,exitCode:c,isCanceled:l,isGracefullyCanceled:u,isForcefullyTerminated:d,forceKillAfterDelay:f,killSignal:p})=>{let m=hl(d,f);return t?`Command timed out after ${n} milliseconds${m}`:u?o===void 0?`Command was gracefully canceled with exit code ${c}`:d?`Command was gracefully canceled${m}`:`Command was gracefully canceled with ${o} (${s})`:l?`Command was canceled${m}`:r?`${cl(e,i)}${m}`:a===void 0?d?`Command was killed with ${p} (${Pa(p)})${m}`:o===void 0?c===void 0?`Command failed`:`Command failed with exit code ${c}`:`Command was killed with ${o} (${s})`:`Command failed with ${a}${m}`},hl=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:``,gl=(e,t)=>{if(e instanceof oa)return;let n=ca(e)?e.originalMessage:String(e?.message??e),r=li(Zs(n,t));return r===``?void 0:r},_l=e=>typeof e==`string`?e:le(e),vl=e=>Array.isArray(e)?e.map(e=>rc(yl(e))).filter(Boolean).join(`
|
|
108
|
+
`):yl(e),yl=e=>typeof e==`string`?e:B(e)?Sr(e):``,bl=({command:e,escapedCommand:t,stdio:n,all:r,ipcOutput:i,options:{cwd:a},startTime:o})=>wl({command:e,escapedCommand:t,cwd:a,durationMs:Xi(o),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:n[1],stderr:n[2],all:r,stdio:n,ipcOutput:i,pipedFrom:[]}),xl=({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:a,isSync:o})=>Sl({error:e,command:t,escapedCommand:n,startTime:a,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:r.length}),ipcOutput:[],options:i,isSync:o}),Sl=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:l,signal:u,stdio:d,all:f,ipcOutput:p,options:{timeoutDuration:m,timeout:h=m,forceKillAfterDelay:g,killSignal:_,cwd:v,maxBuffer:y},isSync:b})=>{let{exitCode:x,signal:S,signalDescription:C}=Tl(l,u),{originalMessage:w,shortMessage:ee,message:te}=pl({stdio:d,all:f,ipcOutput:p,originalError:e,signal:S,signalDescription:C,exitCode:x,escapedCommand:n,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,forceKillAfterDelay:g,killSignal:_,maxBuffer:y,timeout:h,cwd:v}),ne=aa(e,te,b);return Object.assign(ne,Cl({error:ne,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:x,signal:S,signalDescription:C,stdio:d,all:f,ipcOutput:p,cwd:v,originalMessage:w,shortMessage:ee})),ne},Cl=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:l,signal:u,signalDescription:d,stdio:f,all:p,ipcOutput:m,cwd:h,originalMessage:g,shortMessage:_})=>wl({shortMessage:_,originalMessage:g,command:t,escapedCommand:n,cwd:h,durationMs:Xi(r),failed:!0,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isTerminated:u!==void 0,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:l,signal:u,signalDescription:d,code:e.cause?.code,stdout:f[1],stderr:f[2],all:p,stdio:f,ipcOutput:m,pipedFrom:[]}),wl=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)),Tl=(e,t)=>{let n=e===null?void 0:e,r=t===null?void 0:t;return{exitCode:n,signal:r,signalDescription:r===void 0?void 0:Pa(t)}},El=e=>Number.isFinite(e)?e:0;function Dl(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(El(e*1e3)%1e3),nanoseconds:Math.trunc(El(e*1e6)%1e3)}}function Ol(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function kl(e){switch(typeof e){case`number`:if(Number.isFinite(e))return Dl(e);break;case`bigint`:return Ol(e)}throw TypeError(`Expected a finite number or bigint`)}const Al=e=>e===0||e===0n,jl=(e,t)=>t===1||t===1n?e:`${e}s`,Ml=24n*60n*60n*1000n;function Nl(e,t){let n=typeof e==`bigint`;if(!n&&!Number.isFinite(e))throw TypeError(`Expected a finite number or bigint`);t={...t};let r=e<0?`-`:``;e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[],a=(e,t)=>{let n=Math.floor(e*10**t+1e-7);return(Math.round(n)/10**t).toFixed(t)},o=(e,n,r,a)=>{if(!((i.length===0||!t.colonNotation)&&Al(e)&&!(t.colonNotation&&r===`m`))){if(a??=String(e),t.colonNotation){let e=a.includes(`.`)?a.split(`.`)[0].length:a.length,t=i.length>0?2:1;a=`0`.repeat(Math.max(0,t-e))+a}else a+=t.verbose?` `+jl(n,e):r;i.push(a)}},s=kl(e),c=BigInt(s.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(s.hours),`hour`,`h`):(t.hideYear?o(c,`day`,`d`):(o(c/365n,`year`,`y`),o(c%365n,`day`,`d`)),o(Number(s.hours),`hour`,`h`)),o(Number(s.minutes),`minute`,`m`),!t.hideSeconds){if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let e=Number(s.seconds),n=Number(s.milliseconds),r=Number(s.microseconds),i=Number(s.nanoseconds);if(o(e,`second`,`s`),t.formatSubMilliseconds)o(n,`millisecond`,`ms`),o(r,`microsecond`,`µs`),o(i,`nanosecond`,`ns`);else{let e=n+r/1e3+i/1e6,a=typeof t.millisecondsDecimalDigits==`number`?t.millisecondsDecimalDigits:0,s=a?e.toFixed(a):e>=1?Math.round(e):Math.ceil(e);o(Number.parseFloat(s),`millisecond`,`ms`,s)}}else{let r=a((n?Number(e%Ml):e)/1e3%60,typeof t.secondsDecimalDigits==`number`?t.secondsDecimalDigits:1),i=t.keepDecimalsOnWholeSeconds?r:r.replace(/\.0+$/,``);o(Number.parseFloat(i),`second`,`s`,i)}}if(i.length===0)return r+`0`+(t.verbose?` milliseconds`:`ms`);let l=t.colonNotation?`:`:` `;return typeof t.unitCount==`number`&&(i=i.slice(0,Math.max(t.unitCount,1))),r+i.join(l)}const Pl=(e,t)=>{e.failed&&Ri({type:`error`,verboseMessage:e.shortMessage,verboseInfo:t,result:e})},Fl=(e,t)=>{ti(t)&&(Pl(e,t),Il(e,t))},Il=(e,t)=>{let n=`(done in ${Nl(e.durationMs)})`;Ri({type:`duration`,verboseMessage:n,verboseInfo:t,result:e})},Ll=(e,t,{reject:n})=>{if(Fl(e,t),e.failed&&n)throw e;return e},Rl=(e,t)=>ql(e)?`asyncGenerator`:Jl(e)?`generator`:Xl(e)?`fileUrl`:Ql(e)?`filePath`:su(e)?`webStream`:uc(e,{checkOpen:!1})?`native`:B(e)?`uint8Array`:lu(e)?`asyncIterable`:uu(e)?`iterable`:cu(e)?Vl({transform:e},t):Yl(e)?zl(e,t):`native`,zl=(e,t)=>pc(e.transform,{checkOpen:!1})?Bl(e,t):cu(e.transform)?Vl(e,t):Wl(e,t),Bl=(e,t)=>(Hl(e,t,`Duplex stream`),`duplex`),Vl=(e,t)=>(Hl(e,t,`web TransformStream`),`webTransform`),Hl=({final:e,binary:t,objectMode:n},r,i)=>{Ul(e,`${r}.final`,i),Ul(t,`${r}.binary`,i),Gl(n,`${r}.objectMode`)},Ul=(e,t,n)=>{if(e!==void 0)throw TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${n}.`)},Wl=({transform:e,final:t,binary:n,objectMode:r},i)=>{if(e!==void 0&&!Kl(e))throw TypeError(`The \`${i}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(pc(t,{checkOpen:!1}))throw TypeError(`The \`${i}.final\` option must not be a Duplex stream.`);if(cu(t))throw TypeError(`The \`${i}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!Kl(t))throw TypeError(`The \`${i}.final\` option must be a generator.`);return Gl(n,`${i}.binary`),Gl(r,`${i}.objectMode`),ql(e)||ql(t)?`asyncGenerator`:`generator`},Gl=(e,t)=>{if(e!==void 0&&typeof e!=`boolean`)throw TypeError(`The \`${t}\` option must use a boolean.`)},Kl=e=>ql(e)||Jl(e),ql=e=>Object.prototype.toString.call(e)===`[object AsyncGeneratorFunction]`,Jl=e=>Object.prototype.toString.call(e)===`[object GeneratorFunction]`,Yl=e=>z(e)&&(e.transform!==void 0||e.final!==void 0),Xl=e=>Object.prototype.toString.call(e)===`[object URL]`,Zl=e=>Xl(e)&&e.protocol!==`file:`,Ql=e=>z(e)&&Object.keys(e).length>0&&Object.keys(e).every(e=>$l.has(e))&&eu(e.file),$l=new Set([`file`,`append`]),eu=e=>typeof e==`string`,tu=e=>z(e)&&Object.keys(e).length>0&&Object.keys(e).every(e=>nu.has(e))&&`value`in e,nu=new Set([`value`,`input`]),ru=(e,t)=>e===`native`&&typeof t==`string`&&!iu.has(t),iu=new Set([`ipc`,`ignore`,`inherit`,`overlapped`,`pipe`]),au=e=>Object.prototype.toString.call(e)===`[object ReadableStream]`,ou=e=>Object.prototype.toString.call(e)===`[object WritableStream]`,su=e=>au(e)||ou(e),cu=e=>au(e?.readable)&&ou(e?.writable),lu=e=>du(e)&&typeof e[Symbol.asyncIterator]==`function`,uu=e=>du(e)&&typeof e[Symbol.iterator]==`function`,du=e=>typeof e==`object`&&!!e,fu=new Set([`generator`,`asyncGenerator`,`duplex`,`webTransform`]),pu=new Set([`fileUrl`,`filePath`,`fileNumber`]),mu=new Set([`fileUrl`,`filePath`]),hu=new Set([...mu,`webStream`,`nodeStream`]),gu=new Set([`webTransform`,`duplex`]),_u={generator:`a generator`,asyncGenerator:`an async generator`,fileUrl:`a file URL`,filePath:`a file path string`,fileNumber:`a file descriptor number`,webStream:`a web stream`,nodeStream:`a Node.js stream`,webTransform:`a web TransformStream`,duplex:`a Duplex stream`,native:`any value`,iterable:`an iterable`,asyncIterable:`an async iterable`,string:`a string`,uint8Array:`a Uint8Array`},vu=(e,t,n,r)=>r===`output`?yu(e,t,n):bu(e,t,n),yu=(e,t,n)=>{let r=t!==0&&n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:e??r}},bu=(e,t,n)=>{let r=t===0?e===!0:n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:t!==n.length-1&&(e??r)}},xu=(e,t)=>{let n=e.findLast(({type:e})=>fu.has(e));return n===void 0?!1:t===`input`?n.value.writableObjectMode:n.value.readableObjectMode},Su=(e,t,n,r)=>[...e.filter(({type:e})=>!fu.has(e)),...Cu(e,t,n,r)],Cu=(e,t,n,{encoding:r})=>{let i=e.filter(({type:e})=>fu.has(e)),a=Array.from({length:i.length});for(let[e,o]of Object.entries(i))a[e]=wu({stdioItem:o,index:Number(e),newTransforms:a,optionName:t,direction:n,encoding:r});return Ou(a,n)},wu=({stdioItem:e,stdioItem:{type:t},index:n,newTransforms:r,optionName:i,direction:a,encoding:o})=>t===`duplex`?Tu({stdioItem:e,optionName:i}):t===`webTransform`?Eu({stdioItem:e,index:n,newTransforms:r,direction:a}):Du({stdioItem:e,index:n,newTransforms:r,direction:a,encoding:o}),Tu=({stdioItem:e,optionName:t})=>{let{value:n}=e,{transform:r}=n,{writableObjectMode:i,readableObjectMode:a}=r,{objectMode:o=a}=n;if(o&&!a)throw TypeError(`The \`${t}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!o&&a)throw TypeError(`The \`${t}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:r,writableObjectMode:i,readableObjectMode:a}}},Eu=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i})=>{let{transform:a,objectMode:o}=z(t)?t:{transform:t},{writableObjectMode:s,readableObjectMode:c}=vu(o,n,r,i);return{...e,value:{transform:a,writableObjectMode:s,readableObjectMode:c}}},Du=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i,encoding:a})=>{let{transform:o,final:s,binary:c=!1,preserveNewlines:l=!1,objectMode:u}=z(t)?t:{transform:t},d=c||vs.has(a),{writableObjectMode:f,readableObjectMode:p}=vu(u,n,r,i);return{...e,value:{transform:o,final:s,binary:d,preserveNewlines:l,writableObjectMode:f,readableObjectMode:p}}},Ou=(e,t)=>t===`input`?e.reverse():e,ku=(e,t,n)=>{let r=e.map(e=>Au(e,t));if(r.includes(`input`)&&r.includes(`output`))throw TypeError(`The \`${n}\` option must not be an array of both readable and writable values.`);return r.find(Boolean)??Lu},Au=(e,t)=>Mu[t]??ju(e),ju=({type:e,value:t,direction:n,optionName:r})=>{let i=Fu[e](t);if(n===`input`&&i===`output`)throw TypeError(`The \`${r}\` option is invalid: \`input: true\` cannot be used with a writable value, which is always an output.`);return n??i},Mu=[`input`,`output`,`output`],Nu=()=>void 0,Pu=()=>`input`,Fu={generator:Nu,asyncGenerator:Nu,fileUrl:Nu,filePath:Nu,iterable:Pu,asyncIterable:Pu,uint8Array:Pu,webStream:e=>ou(e)?`output`:`input`,nodeStream(e){return fc(e,{checkOpen:!1})?dc(e,{checkOpen:!1})?void 0:`input`:`output`},webTransform:Nu,duplex:Nu,native(e){let t=Iu(e);if(t!==void 0)return t;if(uc(e,{checkOpen:!1}))return Fu.nodeStream(e)}},Iu=e=>{if([0,w.stdin].includes(e))return`input`;if([1,2,w.stdout,w.stderr].includes(e))return`output`},Lu=`output`,Ru=(e,t)=>t?[...e,`ipc`]:e,zu=({stdio:e,ipc:t,buffer:n,...r},i,a)=>{let o=Uu(e,r).map((e,t)=>Gu(e,t));return Bu(o),a?Ku(o,n,i):Ru(o,t)},Bu=e=>{if(e.some(e=>Vu(e)))throw Error("The `ipc: true` option must be used instead of `stdio: 'ipc'`.")},Vu=e=>Array.isArray(e)?e.some(e=>Hu(e)):Hu(e),Hu=e=>tu(e)?e.value===`ipc`:e===`ipc`,Uu=(e,t)=>{if(e===void 0)return V.map(e=>t[e]);if(Wu(t))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${V.map(e=>`\`${e}\``).join(`, `)}`);if(typeof e==`string`)return[e,e,e];if(!Array.isArray(e))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let n=Math.max(e.length,V.length);return Array.from({length:n},(t,n)=>e[n])},Wu=e=>V.some(t=>e[t]!==void 0),Gu=(e,t)=>Array.isArray(e)?e.map(e=>Gu(e,t)):e??(t>=V.length?`ignore`:`pipe`),Ku=(e,t,n)=>e.map((e,r)=>!t[r]&&r!==0&&!ni(n,r)&&qu(e,r)?`ignore`:e),qu=(e,t)=>Ju(e,t)||Array.isArray(e)&&e.every(e=>Ju(e,t)),Ju=(e,t)=>e===`pipe`||Yu(e,t),Yu=(e,t)=>tu(e)&&e.value===`pipe`&&(e.input===void 0||e.input===!1||Xu(t,e.input)),Xu=(e,t)=>t===!0&&(e===1||e===2),Zu=(e,t=`stdin`)=>{let{options:n,fileDescriptors:r}=$u.get(e),i=ed(r,t,!0),a=e.stdio[i];if(a===null)throw TypeError(rd(i,t,n,!0));return a},Qu=(e,t=`stdout`)=>{let{options:n,fileDescriptors:r}=$u.get(e),i=ed(r,t,!1),a=i===`all`?e.all:e.stdio[i];if(a==null)throw TypeError(rd(i,t,n,!1));return a},$u=new WeakMap,ed=(e,t,n)=>{let r=td(t,n);return nd(r,t,n,e),r},td=(e,t)=>{let n=Yr(e);if(n!==void 0)return n;let{validOptions:r,defaultValue:i}=t?{validOptions:`"stdin"`,defaultValue:`stdin`}:{validOptions:`"stdout", "stderr", "all"`,defaultValue:`stdout`};throw TypeError(`"${od(t)}" must not be "${e}".
|
|
109
|
+
It must be ${r} or "fd3", "fd4" (and so on).
|
|
110
|
+
It is optional and defaults to "${i}".`)},nd=(e,t,n,r)=>{let i=r[ad(e)];if(i===void 0)throw TypeError(`"${od(n)}" must not be ${t}. That file descriptor does not exist.
|
|
111
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);if(i.direction===`input`&&!n)throw TypeError(`"${od(n)}" must not be ${t}. It must be a readable stream, not writable.`);if(i.direction!==`input`&&n)throw TypeError(`"${od(n)}" must not be ${t}. It must be a writable stream, not readable.
|
|
112
|
+
If you meant to use it as input, please set its "stdio" option to \`{value: 'pipe', input: true}\`.`)},rd=(e,t,n,r)=>{if(e===`all`&&!n.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:i,optionValue:a}=id(e,n);return`The "${i}: ${sd(a)}" option is incompatible with using "${od(r)}: ${sd(t)}".
|
|
113
|
+
Please set this option with "pipe" instead.`},id=(e,{stdin:t,stdout:n,stderr:r,stdio:i})=>{let a=ad(e);return a===0&&t!==void 0?{optionName:`stdin`,optionValue:t}:a===1&&n!==void 0?{optionName:`stdout`,optionValue:n}:a===2&&r!==void 0?{optionName:`stderr`,optionValue:r}:{optionName:`stdio[${a}]`,optionValue:i[a]}},ad=e=>e===`all`?1:e,od=e=>e?`to`:`from`,sd=e=>typeof e==`string`?`'${e}'`:typeof e==`number`?`${e}`:`Stream`,cd=({stdioItem:e,stdioItem:{type:t},isStdioArray:n,fdNumber:r,direction:i,isSync:a})=>!n||t!==`native`?e:a?ld({stdioItem:e,fdNumber:r,direction:i}):fd({stdioItem:e,fdNumber:r}),ld=({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r,direction:i})=>{let a=ud({value:t,optionName:n,fdNumber:r,direction:i});if(a!==void 0)return a;if(uc(t,{checkOpen:!1}))throw TypeError(`The \`${n}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},ud=({value:e,optionName:t,fdNumber:n,direction:r})=>{let i=dd(e,n);if(i!==void 0){if(r===`output`)return{type:`fileNumber`,value:i,optionName:t};if(me.isatty(i))throw TypeError(`The \`${t}: ${sd(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:`uint8Array`,value:vr(b(i)),optionName:t}}},dd=(e,t)=>{if(e===`inherit`)return t;if(typeof e==`number`)return e;let n=zr.indexOf(e);if(n!==-1)return n},fd=({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r})=>t===`inherit`?{type:`nodeStream`,value:pd(r,t,n),optionName:n}:typeof t==`number`?{type:`nodeStream`,value:pd(t,t,n),optionName:n}:uc(t,{checkOpen:!1})?{type:`nodeStream`,value:t,optionName:n}:e,pd=(e,t,n)=>{let r=zr[e];if(r===void 0)throw TypeError(`The \`${n}: ${t}\` option is invalid: no such standard stream.`);return r},md=({input:e,inputFile:t},n)=>n===0?[...hd(e),..._d(t)]:[],hd=e=>e===void 0?[]:[{type:gd(e),value:e,optionName:`input`}],gd=e=>{if(fc(e,{checkOpen:!1}))return`nodeStream`;if(typeof e==`string`)return`string`;if(B(e))return`uint8Array`;throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},_d=e=>e===void 0?[]:[{...vd(e),optionName:`inputFile`}],vd=e=>{if(Xl(e))return{type:`fileUrl`,value:e};if(eu(e))return{type:`filePath`,value:{file:e}};throw Error("The `inputFile` option must be a file path string or a file URL.")},yd=e=>e.filter((t,n)=>e.every((e,r)=>!bd(t,e)||n>=r||t.type===`generator`||t.type===`asyncGenerator`)),bd=(e,t)=>e.value===t.value&&e.direction===t.direction,xd=({stdioItem:{type:e,value:t,optionName:n},direction:r,fileDescriptors:i,isSync:a})=>{let o=Sd(i,e);if(o.length!==0){if(a){Cd({otherStdioItems:o,type:e,value:t,optionName:n,direction:r});return}if(hu.has(e))return wd({otherStdioItems:o,type:e,value:t,optionName:n,direction:r});gu.has(e)&&Ed({otherStdioItems:o,type:e,value:t,optionName:n})}},Sd=(e,t)=>e.flatMap(({direction:e,stdioItems:n})=>n.filter(e=>e.type===t).map((t=>({...t,direction:e})))),Cd=({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{mu.has(t)&&wd({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})},wd=({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{let a=e.filter(e=>Td(e,n));if(a.length===0)return;let o=a.find(e=>e.direction!==i);return Dd(o,r,t),i===`output`?a[0].stream:void 0},Td=({type:e,value:t},n)=>e===`filePath`?t.file===n.file:e===`fileUrl`?t.href===n.href:t===n,Ed=({otherStdioItems:e,type:t,value:n,optionName:r})=>{let i=e.find(({value:{transform:e}})=>e===n.transform);Dd(i,r,t)},Dd=(e,t,n)=>{if(e!==void 0)throw TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${_u[n]} that is the same.`)},Od=(e,t,n,r)=>{let i=zu(t,n,r).map((e,n)=>kd({stdioOption:e,fdNumber:n,options:t,isSync:r})),a=Bd({initialFileDescriptors:i,addProperties:e,options:t,isSync:r});return t.stdio=a.map(({stdioItems:e})=>Wd(e)),a},kd=({stdioOption:e,fdNumber:t,options:n,isSync:r})=>{let i=Br(t),{stdioItems:a,isStdioArray:o}=Ad({stdioOption:e,fdNumber:t,options:n,optionName:i}),s=ku(a,t,i),c=a.map(e=>cd({stdioItem:e,isStdioArray:o,fdNumber:t,direction:s,isSync:r})),l=Su(c,i,s,n),u=xu(l,s);return zd(l,u),{direction:s,objectMode:u,stdioItems:l}},Ad=({stdioOption:e,fdNumber:t,options:n,optionName:r})=>{let i=Array.isArray(e)?e:[e],a=md(n,t),o=[...jd(i.map(e=>Nd(e,r)),a),...a],s=yd(o),c=s.length>1;return Fd(s,c,r),Ld(s),{stdioItems:s,isStdioArray:c}},jd=(e,t)=>t.length>0&&Md(e)?[]:e,Md=e=>e.length===1&&e[0].type===`native`&&e[0].value===`inherit`,Nd=(e,t)=>tu(e)?Pd(e,t):{type:Rl(e,t),value:e,optionName:t},Pd=({value:e,input:t},n)=>(Gl(t,`${n}.input`),{type:Rl(e,n),value:e,direction:t?`input`:void 0,optionName:n}),Fd=(e,t,n)=>{if(e.length===0)throw TypeError(`The \`${n}\` option must not be an empty array.`);if(t){for(let{value:t,optionName:n}of e)if(Id.has(t))throw Error(`The \`${n}\` option must not include \`${t}\`.`)}},Id=new Set([`ignore`]),Ld=e=>{for(let t of e)Rd(t)},Rd=({type:e,value:t,optionName:n})=>{if(Zl(t))throw TypeError(`The \`${n}: URL\` option must use the \`file:\` scheme.
|
|
114
|
+
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(ru(e,t))throw TypeError(`The \`${n}: { file: '...' }\` option must be used instead of \`${n}: '...'\`.`)},zd=(e,t)=>{if(!t)return;let n=e.find(({type:e})=>pu.has(e));if(n!==void 0)throw TypeError(`The \`${n.optionName}\` option cannot use both files and transforms in objectMode.`)},Bd=({initialFileDescriptors:e,addProperties:t,options:n,isSync:r})=>{let i=[];try{for(let a of e)i.push(Vd({fileDescriptor:a,fileDescriptors:i,addProperties:t,options:n,isSync:r}));return i}catch(e){throw Ud(i),e}},Vd=({fileDescriptor:{direction:e,objectMode:t,stdioItems:n},fileDescriptors:r,addProperties:i,options:a,isSync:o})=>({direction:e,objectMode:t,stdioItems:n.map(t=>Hd({stdioItem:t,addProperties:i,direction:e,options:a,fileDescriptors:r,isSync:o}))}),Hd=({stdioItem:e,addProperties:t,direction:n,options:r,fileDescriptors:i,isSync:a})=>{let o=xd({stdioItem:e,direction:n,fileDescriptors:i,isSync:a});return o===void 0?{...e,...t[n][e.type](e,r)}:{...e,stream:o}},Ud=e=>{for(let{stdioItems:t}of e)for(let{stream:e}of t)e!==void 0&&!Rr(e)&&e.destroy()},Wd=e=>{if(e.length>1)return e.some(({value:e})=>e===`overlapped`)?`overlapped`:`pipe`;let[{type:t,value:n}]=e;return t===`native`?n:`pipe`},Gd=(e,t)=>Od(Xd,e,t,!0),G=({type:e,optionName:t})=>{Jd(t,_u[e])},Kd=({optionName:e,value:t})=>(t===`overlapped`&&Jd(e,`"${t}"`),{}),qd=e=>{let{optionName:t,value:n}=e;if(n===`pipe`&&t!==`stdin`)throw TypeError(`Only the \`stdin\` option, not \`${t}\`, can be an input pipe with synchronous methods.`);return Kd(e)},Jd=(e,t)=>{throw TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},Yd={generator(){},asyncGenerator:G,webStream:G,nodeStream:G,webTransform:G,duplex:G,asyncIterable:G,native:Kd},Xd={input:{...Yd,native:qd,fileUrl:({value:e})=>({contents:[vr(b(e))]}),filePath:({value:{file:e}})=>({contents:[vr(b(e))]}),fileNumber:G,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...Yd,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:G,string:G,uint8Array:G}},Zd=(e,{stripFinalNewline:t},n)=>Qd(t,n)&&e!==void 0&&!Array.isArray(e)?rc(e):e,Qd=(e,t)=>t===`all`?e[1]||e[2]:e[t],$d=(e,t,n,r)=>e||n?void 0:nf(t,r),ef=(e,t,n)=>n?e.flatMap(e=>tf(e,t)):tf(e,t),tf=(e,t)=>{let{transform:n,final:r}=nf(t,{});return[...n(e),...r()]},nf=(e,t)=>(t.previousChunks=``,{transform:rf.bind(void 0,t,e),final:of.bind(void 0,t)}),rf=function*(e,t,n){if(typeof n!=`string`){yield n;return}let{previousChunks:r}=e,i=-1;for(let a=0;a<n.length;a+=1){if(n[a]!==`
|
|
115
|
+
`)continue;let o=af(n,a,t,e),s=n.slice(i+1,a+1-o);r.length>0&&(s=lf(r,s),r=``),yield s,i=a}i!==n.length-1&&(r=lf(r,n.slice(i+1))),e.previousChunks=r},af=(e,t,n,r)=>n?0:(r.isWindowsNewline=t!==0&&e[t-1]===`\r`,r.isWindowsNewline?2:1),of=function*({previousChunks:e}){e.length>0&&(yield e)},sf=({binary:e,preserveNewlines:t,readableObjectMode:n,state:r})=>e||t||n?void 0:{transform:cf.bind(void 0,r)},cf=function*({isWindowsNewline:e=!1},t){let{unixNewline:n,windowsNewline:r,LF:i,concatBytes:a}=typeof t==`string`?uf:df;if(t.at(-1)===i){yield t;return}yield a(t,e?r:n)},lf=(e,t)=>`${e}${t}`,uf={windowsNewline:`\r
|
|
116
|
+
`,unixNewline:`
|
|
117
|
+
`,LF:`
|
|
118
|
+
`,concatBytes:lf},df={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:(e,t)=>{let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}},ff=(e,t)=>e?void 0:pf.bind(void 0,t),pf=function*(e,t){if(typeof t!=`string`&&!B(t)&&!Te.isBuffer(t))throw TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},mf=(e,t)=>e?hf.bind(void 0,t):gf.bind(void 0,t),hf=function*(e,t){_f(e,t),yield t},gf=function*(e,t){if(_f(e,t),typeof t!=`string`&&!B(t))throw TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},_f=(e,t)=>{if(t==null)throw TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.
|
|
119
|
+
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
120
|
+
if (condition) { yield value; }`)},vf=(e,t,n)=>{if(n)return;if(e)return{transform:yf.bind(void 0,new TextEncoder)};let r=new be(t);return{transform:bf.bind(void 0,r),final:xf.bind(void 0,r)}},yf=function*(e,t){Te.isBuffer(t)?yield vr(t):typeof t==`string`?yield e.encode(t):yield t},bf=function*(e,t){yield B(t)?e.write(t):t},xf=function*(e){let t=e.end();t!==``&&(yield t)},Sf=se(async(e,t,n,r)=>{t.currentIterable=e(...n);try{for await(let e of t.currentIterable)r.push(e)}finally{delete t.currentIterable}}),Cf=async function*(e,t,n){if(n===t.length){yield e;return}let{transform:r=Df}=t[n];for await(let i of r(e))yield*Cf(i,t,n+1)},wf=async function*(e){for(let[t,{final:n}]of Object.entries(e))yield*Tf(n,Number(t),e)},Tf=async function*(e,t,n){if(e!==void 0)for await(let r of e())yield*Cf(r,n,t+1)},Ef=se(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),Df=function*(e){yield e},Of=(e,t,n,r)=>{try{for(let r of e(...t))n.push(r);r()}catch(e){r(e)}},kf=(e,t)=>[...t.flatMap(t=>[...Af(t,e,0)]),...jf(e)],Af=function*(e,t,n){if(n===t.length){yield e;return}let{transform:r=Nf}=t[n];for(let i of r(e))yield*Af(i,t,n+1)},jf=function*(e){for(let[t,{final:n}]of Object.entries(e))yield*Mf(n,Number(t),e)},Mf=function*(e,t,n){if(e!==void 0)for(let r of e())yield*Af(r,n,t+1)},Nf=function*(e){yield e},Pf=({value:e,value:{transform:t,final:n,writableObjectMode:r,readableObjectMode:i},optionName:a},{encoding:o})=>{let s={},c=If(e,o,a),l=ql(t),u=ql(n),d=l?Sf.bind(void 0,Cf,s):Of.bind(void 0,Af),f=l||u?Sf.bind(void 0,wf,s):Of.bind(void 0,jf),p=l||u?Ef.bind(void 0,s):void 0;return{stream:new Ae({writableObjectMode:r,writableHighWaterMark:Me(r),readableObjectMode:i,readableHighWaterMark:Me(i),transform(e,t,n){d([e,c,0],this,n)},flush(e){f([c],this,e)},destroy:p})}},Ff=(e,t,n,r)=>{let i=t.filter(({type:e})=>e===`generator`),a=r?i.reverse():i;for(let{value:t,optionName:r}of a){let i=If(t,n,r);e=kf(i,e)}return e},If=({transform:e,final:t,binary:n,writableObjectMode:r,readableObjectMode:i,preserveNewlines:a},o,s)=>{let c={};return[{transform:ff(r,s)},vf(n,o,r),$d(n,a,r,c),{transform:e,final:t},{transform:mf(i,s)},sf({binary:n,preserveNewlines:a,readableObjectMode:i,state:c})].filter(Boolean)},Lf=(e,t)=>{for(let n of Rf(e))zf(e,n,t)},Rf=e=>new Set(Object.entries(e).filter(([,{direction:e}])=>e===`input`).map(([e])=>Number(e))),zf=(e,t,n)=>{let{stdioItems:r}=e[t],i=r.filter(({contents:e})=>e!==void 0);if(i.length===0)return;if(t!==0){let[{type:e,optionName:t}]=i;throw TypeError(`Only the \`stdin\` option, not \`${t}\`, can be ${_u[e]} with synchronous methods.`)}let a=i.map(({contents:e})=>e).map(e=>Bf(e,r));n.input=Tr(a)},Bf=(e,t)=>{let n=Ff(e,t,`utf8`,!0);return Vf(n),Tr(n)},Vf=e=>{let t=e.find(e=>typeof e!=`string`&&!B(e));if(t!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)},Hf=({stdioItems:e,encoding:t,verboseInfo:n,fdNumber:r})=>r!==`all`&&ni(n,r)&&!vs.has(t)&&Uf(r)&&(e.some(({type:e,value:t})=>e===`native`&&Wf.has(t))||e.every(({type:e})=>fu.has(e))),Uf=e=>e===1||e===2,Wf=new Set([`pipe`,`overlapped`]),Gf=async(e,t,n,r)=>{for await(let i of e)qf(t)||Jf(i,n,r)},Kf=(e,t,n)=>{for(let r of e)Jf(r,t,n)},qf=e=>e._readableState.pipes.length>0,Jf=(e,t,n)=>{let r=Hi(e);Ri({type:`output`,verboseMessage:r,fdNumber:t,verboseInfo:n})},Yf=({fileDescriptors:e,syncResult:{output:t},options:n,isMaxBuffer:r,verboseInfo:i})=>{if(t===null)return{output:Array.from({length:3})};let a={},o=new Set;return{output:t.map((t,s)=>Xf({result:t,fileDescriptors:e,fdNumber:s,state:a,outputFiles:o,isMaxBuffer:r,verboseInfo:i},n)),...a}},Xf=({result:e,fileDescriptors:t,fdNumber:n,state:r,outputFiles:i,isMaxBuffer:a,verboseInfo:o},{buffer:s,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(e===null)return;let f=dl(e,a,d),p=vr(f),{stdioItems:m,objectMode:h}=t[n],g=Zf([p],m,c,r),{serializedResult:_,finalResult:v=_}=Qf({chunks:g,objectMode:h,encoding:c,lines:l,stripFinalNewline:u,fdNumber:n});$f({serializedResult:_,fdNumber:n,state:r,verboseInfo:o,encoding:c,stdioItems:m,objectMode:h});let y=s[n]?v:void 0;try{return r.error===void 0&&ep(_,m,i),y}catch(e){return r.error=e,y}},Zf=(e,t,n,r)=>{try{return Ff(e,t,n,!1)}catch(t){return r.error=t,e}},Qf=({chunks:e,objectMode:t,encoding:n,lines:r,stripFinalNewline:i,fdNumber:a})=>{if(t)return{serializedResult:e};if(n===`buffer`)return{serializedResult:Tr(e)};let o=Cr(e,n);return r[a]?{serializedResult:o,finalResult:ef(o,!i[a],t)}:{serializedResult:o}},$f=({serializedResult:e,fdNumber:t,state:n,verboseInfo:r,encoding:i,stdioItems:a,objectMode:o})=>{if(!Hf({stdioItems:a,encoding:i,verboseInfo:r,fdNumber:t}))return;let s=ef(e,!1,o);try{Kf(s,t,r)}catch(e){n.error??=e}},ep=(e,t,n)=>{let r=t.filter(({type:e})=>pu.has(e));for(let{path:t,append:i}of r){let r=typeof t==`string`?t:t.toString();i||n.has(r)?h(t,e):(n.add(r),C(t,e))}},tp=([,e,t],n)=>{if(n.all)return e===void 0?t:t===void 0?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,Zd(t,n,`all`)]:Array.isArray(t)?[Zd(e,n,`all`),...t]:B(e)&&B(t)?Dr([e,t]):`${e}${t}`},np=async(e,t)=>{let[n,r]=await rp(e);return t.isForcefullyTerminated??=!1,[n,r]},rp=async e=>{let[t,n]=await Promise.allSettled([i(e,`spawn`),i(e,`exit`)]);return t.status===`rejected`?[]:n.status===`rejected`?ip(e):n.value},ip=async e=>{try{return await i(e,`exit`)}catch{return ip(e)}},ap=async e=>{let[t,n]=await e;if(!op(t,n)&&sp(t,n))throw new oa;return[t,n]},op=(e,t)=>e===void 0&&t===void 0,sp=(e,t)=>e!==0||t!==null,cp=({error:e,status:t,signal:n,output:r},{maxBuffer:i})=>{let a=lp(e,t,n);return{resultError:a,exitCode:t,signal:n,timedOut:a?.code===`ETIMEDOUT`,isMaxBuffer:ul(a,r,i)}},lp=(e,t,n)=>e===void 0?sp(t,n)?new oa:void 0:e,up=(e,t,n)=>{let{file:r,commandArguments:i,command:a,escapedCommand:o,startTime:s,verboseInfo:c,options:l,fileDescriptors:u}=dp(e,t,n),d=hp({file:r,commandArguments:i,options:l,command:a,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:s});return Ll(d,c,l)},dp=(e,t,n)=>{let{command:r,escapedCommand:i,startTime:a,verboseInfo:o}=Zi(e,t,n),s=fp(n),{file:c,commandArguments:l,options:u}=$s(e,t,s);return pp(u),{file:c,commandArguments:l,command:r,escapedCommand:i,startTime:a,verboseInfo:o,options:u,fileDescriptors:Gd(u,o)}},fp=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,pp=({ipc:e,ipcInput:t,detached:n,cancelSignal:r,killDescendants:i})=>{t&&mp(`ipcInput`),e&&mp(`ipc: true`),n&&mp(`detached: true`),i&&mp(`killDescendants: true`),r&&mp(`cancelSignal`)},mp=e=>{throw TypeError(`The "${e}" option cannot be used with synchronous methods.`)},hp=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,verboseInfo:a,fileDescriptors:o,startTime:s})=>{let c=gp({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:o,startTime:s});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=cp(c,n),{output:m,error:h=l}=Yf({fileDescriptors:o,syncResult:c,options:n,isMaxBuffer:p,verboseInfo:a}),g=m.map((e,t)=>Zd(e,n,t)),_=Zd(tp(m,n),n,`all`);return vp({error:h,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:n,command:r,escapedCommand:i,startTime:s})},gp=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:a,startTime:o})=>{try{Lf(a,n);let r=_p(n);return u(...nc(e,t,r))}catch(e){return xl({error:e,command:r,escapedCommand:i,fileDescriptors:a,options:n,startTime:o,isSync:!0})}},_p=({encoding:e,maxBuffer:t,...n})=>({...n,encoding:`buffer`,maxBuffer:fl(t)}),vp=({error:e,exitCode:t,signal:n,timedOut:r,isMaxBuffer:i,stdio:a,all:o,options:s,command:c,escapedCommand:l,startTime:u})=>e===void 0?bl({command:c,escapedCommand:l,stdio:a,all:o,ipcOutput:[],options:s,startTime:u}):Sl({error:e,command:c,escapedCommand:l,timedOut:r,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:t,signal:n,stdio:a,all:o,ipcOutput:[],options:s,startTime:u,isSync:!0}),yp=Symbol(`internalGetOneMessageOptions`),bp=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},i={})=>{let{reference:a=!0,filter:o}=i,{signal:s}=i[yp]??{};return Ka({methodName:`getOneMessage`,isSubprocess:n,ipc:r,isConnected:To(e)}),xp({anyProcess:e,channel:t,isSubprocess:n,filter:o,reference:a,signal:s})},xp=async({anyProcess:e,channel:t,isSubprocess:n,filter:r,reference:i,signal:a})=>{po(t,i);let o=So(e,t,n),s=new AbortController;Sp(a,s);try{return await Promise.race([Cp(o,r,s),wp(o,n,s),Tp(o,n,s)])}catch(t){throw lo(e),t}finally{s.abort(),ho(t,i)}},Sp=(e,t)=>{if(e!==void 0){if(e.aborted){t.abort();return}e.addEventListener(`abort`,()=>{t.abort()},{once:!0,signal:t.signal})}},Cp=async(e,t,{signal:n})=>{if(t===void 0){let[t]=await i(e,`message`,{signal:n});return t}for await(let[i]of r(e,`message`,{signal:n}))if(t(i))return i},wp=async(e,t,{signal:n})=>{await i(e,`disconnect`,{signal:n}),Ya(t)},Tp=async(e,t,{signal:n})=>{let[r]=await i(e,`strict:error`,{signal:n});throw Za(r,t)},Ep=Symbol(`internalGetEachMessageOptions`),Dp=(e,t={})=>{let{reference:n=!0}=t,{signal:r,shouldAwait:i=!e.isSubprocess}=t[Ep]??{};return Op({...e,shouldAwait:i,reference:n,signal:r})},Op=({anyProcess:e,waitProcess:t=e,channel:n,isSubprocess:r,ipc:i,shouldAwait:a,reference:o,signal:s})=>{Ka({methodName:`getEachMessage`,isSubprocess:r,ipc:i,isConnected:To(e)}),po(n,o);let c=So(e,n,r),l=new AbortController,u={};return kp(s,l),Ap(e,c,l),jp({ipcEmitter:c,isSubprocess:r,controller:l,state:u}),Mp({anyProcess:e,waitProcess:t,channel:n,ipcEmitter:c,isSubprocess:r,shouldAwait:a,controller:l,state:u,reference:o})},kp=(e,t)=>{if(e!==void 0){if(e.aborted){t.abort();return}e.addEventListener(`abort`,()=>{t.abort()},{once:!0,signal:t.signal})}},Ap=async(e,t,n)=>{try{await i(t,`disconnect`,{signal:n.signal}),n.abort()}catch{}},jp=async({ipcEmitter:e,isSubprocess:t,controller:n,state:r})=>{try{let[a]=await i(e,`strict:error`,{signal:n.signal});r.error=Za(a,t),n.abort()}catch{}},Mp=async function*({anyProcess:e,waitProcess:t,channel:n,ipcEmitter:i,isSubprocess:a,shouldAwait:o,controller:s,state:c,reference:l}){try{for await(let[e]of r(i,`message`,{signal:s.signal}))Np(c),yield e}catch{Np(c)}finally{s.abort(),ho(n,l),a||lo(e),o&&await t}},Np=({error:e})=>{if(e)throw e},Pp=(e,t,{ipc:n})=>{Object.assign(e,Ip(t,!1,n,e))},Fp=()=>{let e=w,t=w.channel!==void 0;return{...Ip(e,!0,t),getCancelSignal:Zo.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:!0,ipc:t})}},Ip=(e,t,n,r=e)=>({sendMessage:Go.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getOneMessage:bp.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getEachMessage:Dp.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n,waitProcess:r})}),Lp=({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:a,verboseInfo:o})=>{Ud(r);let c=new s,l=Rp(c,r),u=xl({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:a,isSync:!1});return{subprocess:c,promise:qp(u,o,i),all:i.all?l:void 0,convertedStreams:{readable:Bp,writable:Vp,duplex:Hp,readableStream:Up,writableStream:Wp,transformStream:Gp,iterable:Kp,[Symbol.asyncIterator]:Kp}}},Rp=(e,t)=>{let n=zp(),r=zp(),i=zp(),a=Array.from({length:t.length-3},zp),o=zp(),s=[n,r,i,...a];return Object.assign(e,{stdin:n,stdout:r,stderr:i,stdio:s}),o},zp=()=>{let e=new Oe;return e.end(),e},Bp=()=>new ke({read(){}}),Vp=()=>new je({write(){}}),Hp=()=>new De({read(){},write(){}}),Up=()=>ke.toWeb(Bp()),Wp=()=>je.toWeb(Vp()),Gp=()=>De.toWeb(Hp()),Kp=async function*(){},qp=async(e,t,n)=>Ll(e,t,n),Jp=(e,t)=>Od(Zp,e,t,!1),Yp=({type:e,optionName:t})=>{throw TypeError(`The \`${t}\` option cannot be ${_u[e]}.`)},Xp={fileNumber:Yp,generator:Pf,asyncGenerator:Pf,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:n}}){let r=t||n;return{stream:De.fromWeb(e,{objectMode:r})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},Zp={input:{...Xp,fileUrl:({value:e})=>({stream:_(e)}),filePath:({value:{file:e}})=>({stream:_(e)}),webStream:({value:e})=>({stream:ke.fromWeb(e)}),iterable:({value:e})=>({stream:ke.from(e)}),asyncIterable:({value:e})=>({stream:ke.from(e)}),string:({value:e})=>({stream:ke.from(e)}),uint8Array:({value:e})=>({stream:ke.from(Te.from(e))})},output:{...Xp,fileUrl:({value:e})=>({stream:v(e)}),filePath:({value:{file:e,append:t}})=>({stream:v(e,t?{flags:`a`}:{})}),webStream:({value:e})=>({stream:je.fromWeb(e)}),iterable:Yp,asyncIterable:Yp,string:Yp,uint8Array:Yp}};function Qp(e){if(!Array.isArray(e))throw TypeError(`Expected an array, got \`${typeof e}\`.`);for(let t of e)im(t);let t=e.some(({readableObjectMode:e})=>e),n=$p(e,t),r=new em({objectMode:t,writableHighWaterMark:n,readableHighWaterMark:n});for(let t of e)r.add(t);return r}const $p=(e,t)=>{if(e.length===0)return Me(t);let n=e.filter(({readableObjectMode:e})=>e===t).map(({readableHighWaterMark:e})=>e);return Math.max(...n)};var em=class extends Oe{#e=new Set([]);#t=new Set([]);#n=new Set([]);#r;#i=Symbol(`unpipe`);#a=new WeakMap;add(e){if(im(e),this.#e.has(e))return;this.#e.add(e),this.#r??=tm(this,this.#e,this.#i);let t=am({passThroughStream:this,stream:e,streams:this.#e,ended:this.#t,aborted:this.#n,onFinished:this.#r,unpipeEvent:this.#i});this.#a.set(e,t),e.pipe(this,{end:!1})}async remove(e){if(im(e),!this.#e.has(e))return!1;let t=this.#a.get(e);return t!==void 0&&(this.#a.delete(e),e.unpipe(this),await t,!0)}};const tm=async(e,t,n)=>{hm(e,gm);let r=new AbortController;try{await Promise.race([nm(e,r),rm(e,t,n,r)])}finally{r.abort(),hm(e,-gm)}},nm=async(e,{signal:t})=>{try{await Ee(e,{signal:t,cleanup:!0})}catch(t){throw um(e,t),t}},rm=async(e,t,n,{signal:i})=>{for await(let[a]of r(e,`unpipe`,{signal:i}))t.has(a)&&a.emit(n)},im=e=>{if(typeof e?.pipe!=`function`)throw TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},am=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,onFinished:a,unpipeEvent:o})=>{hm(e,_m);let s=new AbortController;try{await Promise.race([om(a,t,s),sm({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:s}),cm({stream:t,streams:n,ended:r,aborted:i,unpipeEvent:o,controller:s})])}finally{s.abort(),hm(e,-_m)}n.size>0&&n.size===r.size+i.size&&(r.size===0&&i.size>0?fm(e):lm(e))},om=async(e,t,{signal:n})=>{try{await e,n.aborted||fm(t)}catch(e){n.aborted||um(t,e)}},sm=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:{signal:a}})=>{try{await Ee(t,{signal:a,cleanup:!0,readable:!0,writable:!1}),n.has(t)&&r.add(t)}catch(r){if(a.aborted||!n.has(t))return;dm(r)?i.add(t):pm(e,r)}},cm=async({stream:e,streams:t,ended:n,aborted:r,unpipeEvent:a,controller:{signal:o}})=>{if(await i(e,a,{signal:o}),!e.readable)return i(o,`abort`,{signal:o});t.delete(e),n.delete(e),r.delete(e)},lm=e=>{e.writable&&e.end()},um=(e,t)=>{dm(t)?fm(e):pm(e,t)},dm=e=>e?.code===`ERR_STREAM_PREMATURE_CLOSE`,fm=e=>{(e.readable||e.writable)&&e.destroy()},pm=(e,t)=>{e.destroyed||(e.once(`error`,mm),e.destroy(t))},mm=()=>{},hm=(e,t)=>{let n=e.getMaxListeners();n!==0&&n!==1/0&&e.setMaxListeners(n+t)},gm=2,_m=1,vm=(e,t)=>{e.pipe(t),ym(e,t),xm(e,t)},ym=async(e,t)=>{if(!(Rr(e)||Rr(t))){try{await Ee(e,{cleanup:!0,readable:!0,writable:!1})}catch{}bm(t)}},bm=e=>{e.writable&&e.end()},xm=async(e,t)=>{if(!(Rr(e)||Rr(t))){try{await Ee(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Sm(e)}},Sm=e=>{e.readable&&e.destroy()},Cm=(e,t,n)=>{let r=new Map;for(let[i,{stdioItems:a,direction:o}]of Object.entries(t)){let t=a.filter(({type:e})=>fu.has(e));for(let{stream:n}of t)wm(e,n,o,i);let s=a.filter(({type:e})=>!fu.has(e));for(let{stream:t}of s)Em({subprocess:e,stream:t,direction:o,fdNumber:i,pipeGroups:r,controller:n})}for(let[e,t]of r){let n=t.length===1?t[0]:Qp(t);vm(n,e)}},wm=(e,t,n,r)=>{n===`output`?vm(e.stdio[r],t):vm(t,e.stdio[r]);let i=Tm[r];i!==void 0&&(e[i]=t),e.stdio[r]=t},Tm=[`stdin`,`stdout`,`stderr`],Em=({subprocess:e,stream:t,direction:n,fdNumber:r,pipeGroups:i,controller:a})=>{if(t===void 0)return;Dm(t,a);let[o,s]=n===`output`?[t,e.stdio[r]]:[e.stdio[r],t],c=i.get(o)??[];i.set(o,[...c,s])},Dm=(e,{signal:t})=>{Rr(e)&&fo(e,Om,t)},Om=2,km=w.platform===`win32`,Am=e=>e.killDescendants&&!km?{...e,detached:!0}:e,jm=(e,{killDescendants:t})=>t?(km?Nm:Mm).bind(void 0,e):e.kill.bind(e),Mm=(e,t)=>{if(e.pid===void 0)return!1;try{return w.kill(-e.pid,t)}catch{return e.kill(t)}},Nm=(e,t)=>{if(e.pid===void 0)return!1;let n=Pm();return n===void 0?e.kill(t):(c(n,[`/pid`,`${e.pid}`,`/T`,`/F`],n=>{n&&e.kill(t)}),!0)},Pm=()=>{let e=[w.env.SystemRoot,w.env.windir].find(e=>e&&Fm(e));return e===void 0?void 0:Ne.join(e,`System32`,`taskkill.exe`)},Fm=e=>{let{root:t}=Ne.parse(e);return/^[a-z]:[/\\]/i.test(t)},Im=[];Im.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&Im.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&Im.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const Lm=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,Rm=Symbol.for(`signal-exit emitter`),zm=globalThis,Bm=Object.defineProperty.bind(Object);var Vm=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(zm[Rm])return zm[Rm];Bm(zm,Rm,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},Hm=class{};const Um=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var Wm=class extends Hm{onExit(){return()=>{}}load(){}unload(){}},Gm=class extends Hm{#e=Km.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Vm;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of Im)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!Lm(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of Im)try{let t=this.#a[e];t&&this.#n.on(e,t)}catch{}this.#n.emit=(e,...t)=>this.#c(e,...t),this.#n.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,Im.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return Lm(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&Lm(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}return n.call(this.#n,e,...t)}};const Km=globalThis.process,{onExit:qm,load:Jm,unload:Ym}=Um(Lm(Km)?new Gm(Km):new Wm),Xm=(e,{cleanup:t,detached:r},{signal:i})=>{if(!t||r)return;let a=qm(()=>{e()});n(i,()=>{a()})},Zm=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Qm=(e,t,n)=>{let r=e[n];r.has(t)||r.set(t,[]);let i=r.get(t),a=uo();return i.push(a),{resolve:a.resolve.bind(a),promises:i}},$m=async({resolve:e,promises:t},n)=>{e();let[r]=await Promise.race([Promise.allSettled([!0,n]),Promise.all([!1,...t])]);return!r},eh=({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:r,encoding:i,preserveNewlines:a})=>{let o=new AbortController;return th(t,o),ih({stream:e,controller:o,binary:n,shouldEncode:!e.readableObjectMode&&r,encoding:i,shouldSplit:!e.readableObjectMode,preserveNewlines:a})},th=async(e,t)=>{try{await e}catch{}finally{t.abort()}},nh=({stream:e,onStreamEnd:t,lines:n,encoding:r,stripFinalNewline:i,allMixed:a})=>{let o=new AbortController;rh(t,o,e);let s=e.readableObjectMode&&!a;return ih({stream:e,controller:o,binary:r===`buffer`,shouldEncode:!s,encoding:r,shouldSplit:!s&&n,preserveNewlines:!i})},rh=async(e,t,n)=>{try{await e}catch{n.destroy()}finally{t.abort()}},ih=({stream:e,controller:t,binary:n,shouldEncode:i,encoding:a,shouldSplit:o,preserveNewlines:s})=>{let c=r(e,`data`,{signal:t.signal,highWaterMark:oh,highWatermark:oh});return sh({onStdoutChunk:c,controller:t,binary:n,shouldEncode:i,encoding:a,shouldSplit:o,preserveNewlines:s})},ah=Me(!0),oh=ah,sh=async function*({onStdoutChunk:e,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:a,preserveNewlines:o}){let s=ch({binary:n,shouldEncode:r,encoding:i,shouldSplit:a,preserveNewlines:o});try{for await(let[t]of e)yield*Af(t,s,0)}catch(e){if(!t.signal.aborted)throw e}finally{yield*jf(s)}},ch=({binary:e,shouldEncode:t,encoding:n,shouldSplit:r,preserveNewlines:i})=>[vf(e,n,!t),$d(e,i,!r,{})].filter(Boolean),lh=(e,t,{from:n,binary:r=!1,preserveNewlines:i=!1}={})=>{let a=r||vs.has(t),o=Qu(e,n),s=eh({subprocessStdout:o,subprocess:e,binary:a,shouldEncode:!0,encoding:t,preserveNewlines:i});return uh(s,o,e)},uh=async function*(e,t,n){try{yield*e}finally{t.readable&&t.destroy(),await n}},dh=async(e,t,n,{isSameDirection:r,stopOnExit:i=!1}={})=>{let a=fh(e,n),o=new AbortController;try{await Promise.race([...i?[n.exitPromise]:[],Ee(e,{cleanup:!0,signal:o.signal})])}catch(e){a.stdinCleanedUp||hh(e,t,n,r)}finally{o.abort()}},fh=(e,{originalStreams:t,subprocess:n})=>{let[r]=t,i={stdinCleanedUp:!1};return e===r&&ph(e,n,i),i},ph=(e,t,n)=>{let{_destroy:r}=e;e._destroy=(...i)=>{mh(t,n),r.call(e,...i)}},mh=({exitCode:e,signalCode:t},n)=>{(e!==null||t!==null)&&(n.stdinCleanedUp=!0)},hh=(e,t,n,r)=>{if(!gh(e,t,n,r))throw e},gh=(e,t,n,r=!0)=>n.propagating?yh(e)||vh(e):(n.propagating=!0,_h(n,t)===r?yh(e):vh(e)),_h=({fileDescriptors:e},t)=>t!==`all`&&e[t].direction===`input`,vh=e=>e?.code===`ERR_STREAM_PREMATURE_CLOSE`,yh=e=>e?.code===`EPIPE`,bh=async e=>{if(e!==void 0)try{await Sh(e)}catch{}},xh=async e=>{if(e!==void 0)try{await Ch(e)}catch{}},Sh=async e=>{await Ee(e,{cleanup:!0,readable:!1,writable:!0})},Ch=async e=>{await Ee(e,{cleanup:!0,readable:!0,writable:!1})},wh=async(e,t)=>{if(await e,t)throw t},Th=(e,t,n)=>{n&&!vh(n)?e.destroy(n):t&&e.destroy()},Eh=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,binary:i=!0,preserveNewlines:a=!0}={})=>{let o=i||vs.has(n),{subprocessStdout:s,waitReadableDestroy:c}=Dh(e,r,t),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Oh(s,o),{read:f,onStdoutDataDone:p}=kh({subprocessStdout:s,subprocess:e,binary:o,encoding:n,preserveNewlines:a}),m=new ke({read:f,destroy:se(Nh.bind(void 0,{subprocessStdout:s,subprocess:e,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return jh({subprocessStdout:s,onStdoutDataDone:p,readable:m,subprocess:e}),m},Dh=(e,t,n)=>{let r=Qu(e,t);return{subprocessStdout:r,waitReadableDestroy:Qm(n,r,`readableDestroy`)}},Oh=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n},r)=>r?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:ah},kh=({subprocessStdout:e,subprocess:t,binary:n,encoding:r,preserveNewlines:i})=>{let a=uo(),o=eh({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:!n,encoding:r,preserveNewlines:i});return{read(){Ah(this,o,a)},onStdoutDataDone:a}},Ah=async(e,t,n)=>{try{let{value:r,done:i}=await t.next();i?n.resolve():e.push(r)}catch{}},jh=async({subprocessStdout:e,onStdoutDataDone:t,readable:n,subprocess:r,subprocessStdin:i})=>{try{await Ch(e),await r,await bh(i),await t,n.readable&&n.push(null)}catch(e){await bh(i),Ph(n,await Mh(r,e))}},Mh=async(e,t)=>{if(t.code!==`ERR_STREAM_PREMATURE_CLOSE`)return t;try{await e}catch(e){return e}return t},Nh=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:n},r)=>{await $m(n,t)&&(Ph(e,r),await wh(t,r))},Ph=(e,t)=>{Th(e,e.readable,t)},Fh=(e,t)=>ke.toWeb(e.readable(t)),Ih=(e,t)=>je.toWeb(e.writable(t)),Lh=(e,t)=>De.toWeb(e.duplex(t)),Rh=({source:e,sourcePromise:t,boundOptions:n,createNested:r},...i)=>{let a=Yi(),{destination:o,destinationStream:s,destinationError:c,from:l,unpipeSignal:u}=zh(n,r,i),{sourceStream:d,sourceError:f}=Hh(e,l),{options:p,fileDescriptors:m}=$u.get(e);return{sourcePromise:t,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:s,destinationError:c,unpipeSignal:u,fileDescriptors:m,startTime:a}},zh=(e,t,n)=>{try{let{destination:r,pipeOptions:{from:i,to:a,unpipeSignal:o}={}}=Bh(e,t,...n);return{destination:r,destinationStream:Zu(r,a),from:i,unpipeSignal:o}}catch(e){return{destinationError:e}}},Bh=(e,t,n,...r)=>{if(Array.isArray(n))return{destination:t(Vh,e)(n,...r),pipeOptions:e};if(typeof n==`string`||n instanceof URL||pr(n)){if(Object.keys(e).length>0)throw TypeError(`Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).`);let[i,a,o]=hr(n,...r);return{destination:t(Vh)(i,a,o),pipeOptions:o}}if($u.has(n)){if(Object.keys(e).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:n,pipeOptions:r[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${n}`)},Vh=({options:e})=>({options:{...e,stdin:`pipe`,piped:!0}}),Hh=(e,t)=>{try{return{sourceStream:Qu(e,t)}}catch(e){return{sourceError:e}}},Uh=({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r,fileDescriptors:i,sourceOptions:a,startTime:o})=>{let s=Wh({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r});if(s!==void 0)throw Gh({error:s,fileDescriptors:i,sourceOptions:a,startTime:o})},Wh=({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r})=>{if(t!==void 0&&r!==void 0)return r;if(r!==void 0)return Sm(e),r;if(t!==void 0)return bm(n),t},Gh=({error:e,fileDescriptors:t,sourceOptions:n,startTime:r})=>xl({error:e,command:Kh,escapedCommand:Kh,fileDescriptors:t,options:n,startTime:r,isSync:!1}),Kh=`source.pipe(destination)`,qh=async e=>{let[{status:t,reason:n,value:r=n},{status:i,reason:a,value:o=a}]=await e;if(o.pipedFrom.includes(r)||o.pipedFrom.push(r),i===`rejected`)throw o;if(t===`rejected`)throw r;return o},Jh=(e,t,n)=>{let r=Qh.has(t)?Xh(e,t):Yh(e,t);return fo(e,$h,n.signal),fo(t,eg,n.signal),Zh(t),r},Yh=(e,t)=>{let n=Qp([e]);return vm(n,t),Qh.set(t,n),n},Xh=(e,t)=>{let n=Qh.get(t);return n.add(e),n},Zh=async e=>{try{await Ee(e,{cleanup:!0,readable:!1,writable:!0})}catch{}Qh.delete(e)},Qh=new WeakMap,$h=2,eg=1,tg=(e,t)=>e===void 0?[]:[ng(e,t)],ng=async(e,{sourceStream:t,mergedStream:n,fileDescriptors:r,sourceOptions:i,startTime:a})=>{throw await oe(e,t),await n.remove(t),Gh({error:Error("Pipe canceled by `unpipeSignal` option."),fileDescriptors:r,sourceOptions:i,startTime:a})},rg=(e,...t)=>{if(z(t[0]))return rg.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:n,...r}=Rh(e,...t),i=new AbortController,a=vg({...r,destination:n,pipeFailureController:i});return a.pipe=rg.bind(void 0,{...e,source:n,sourcePromise:a,boundOptions:{}}),ig(a,n,i.signal),a},ig=(e,t,n)=>{t!==void 0&&(ag(e,t),ug(e,t,n))},ag=(e,t)=>{let n=$u.get(t);$u.set(e,n),e.stdio=t.stdio,e.all=t.all;let{options:{encoding:r}}=n,i=Zm();e[Symbol.asyncIterator]=lh.bind(void 0,e,r,{}),e.iterable=lh.bind(void 0,e,r),e.readable=cg.bind(void 0,e,{subprocess:e,concurrentStreams:i,encoding:r}),e.readableStream=Fh.bind(void 0,e),og(e,t)},og=(e,t)=>{if(t.all===void 0){e.all=void 0;return}Object.defineProperty(e,"all",{get(){sg(e,t.all);let n=e.readable({from:`all`});return sg(e,n),n},enumerable:!0,configurable:!0})},sg=(e,t)=>{Object.defineProperty(e,"all",{value:t,writable:!0,enumerable:!0,configurable:!0})},cg=(e,t,...n)=>{let r=Eh(t,...n);return lg(e,r),r},lg=async(e,t)=>{try{await e}catch(e){t.destroy(e)}},ug=(e,t,n)=>{e.sendMessage=t.sendMessage,e.getOneMessage=dg.bind(void 0,t,n),e.getEachMessage=mg.bind(void 0,e,t,n)},dg=(e,t,...n)=>{let r=new AbortController,i=e.getOneMessage(...gg(n,r.signal,yp));return fg(t,i,r)},fg=async(e,t,n)=>{try{return await Promise.race([t,pg(e,n.signal)])}finally{n.abort()}},pg=(e,t)=>new Promise((n,r)=>{if(e.aborted){r(e.reason);return}e.addEventListener(`abort`,()=>{r(e.reason)},{once:!0,signal:t})}),mg=(e,t,n,...r)=>{let i=new AbortController,a=t.getEachMessage(...gg(r,i.signal,Ep));return _g(n,i),hg(e,a,i)},hg=async function*(e,t,n){try{yield*t}finally{n.abort(),await e}},gg=(e,t,n)=>{if(e[0]===null)return e;let[r]=e;return[{...r,[n]:{signal:t,shouldAwait:!1}}]},_g=(e,t)=>{if(e.aborted){t.abort();return}e.addEventListener(`abort`,()=>{t.abort()},{once:!0,signal:t.signal})},vg=async({sourcePromise:e,sourceStream:t,sourceOptions:n,sourceError:r,destination:i,destinationStream:a,destinationError:o,unpipeSignal:s,fileDescriptors:c,startTime:l,pipeFailureController:u})=>{let d=new AbortController;try{let u=yg(e,i);Uh({sourceStream:t,sourceError:r,destinationStream:a,destinationError:o,fileDescriptors:c,sourceOptions:n,startTime:l});let f=Jh(t,a,d);return await Promise.race([qh(u),...tg(s,{sourceStream:t,mergedStream:f,sourceOptions:n,fileDescriptors:c,startTime:l})])}catch(e){throw u.abort(e),e}finally{d.abort()}},yg=(e,t)=>Promise.allSettled([e,t]),bg=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,buffer:i,maxBuffer:a,lines:o,allMixed:s,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=xg({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:s,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Sg(e),d]);return}let f=Qd(c,n),p=nh({stream:e,onStreamEnd:t,lines:o,encoding:r,stripFinalNewline:f,allMixed:s}),[m]=await Promise.all([Cg({stream:e,iterable:p,fdNumber:n,encoding:r,maxBuffer:a,lines:o}),d]);return m},xg=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:i,verboseInfo:a,streamInfo:{fileDescriptors:o}})=>{if(!Hf({stdioItems:o[n]?.stdioItems,encoding:r,verboseInfo:a,fdNumber:n}))return;let s=nh({stream:e,onStreamEnd:t,lines:!0,encoding:r,stripFinalNewline:!0,allMixed:i});await Gf(s,e,n,a)},Sg=async e=>{await Se(),e.readableFlowing===null&&e.resume()},Cg=async({stream:e,stream:{readableObjectMode:t},iterable:n,fdNumber:r,encoding:i,maxBuffer:a,lines:o})=>{try{return t||o?await Rc(n,{maxBuffer:a}):i===`buffer`?new Uint8Array(await Bc(n,{maxBuffer:a})):await tl(n,{maxBuffer:a})}catch(n){return Tg(al({error:n,stream:e,readableObjectMode:t,lines:o,encoding:i,fdNumber:r}))}},wg=async e=>{try{return await e}catch(e){return Tg(e)}},Tg=({bufferedData:e})=>_r(e)?new Uint8Array(e):e,Eg=({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:a,verboseInfo:o,streamInfo:s})=>e.stdio.map((e,c)=>Dg({stream:e,fdNumber:c,encoding:t,buffer:n[c],maxBuffer:r[c],lines:i[c],allMixed:!1,stripFinalNewline:a,verboseInfo:o,streamInfo:s})),Dg=async({stream:e,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:a,allMixed:o,stripFinalNewline:s,verboseInfo:c,streamInfo:l})=>{if(!e)return;let u=dh(e,t,l);if(_h(l,t)){await u;return}let[d]=await Promise.all([bg({stream:e,onStreamEnd:u,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:a,allMixed:o,stripFinalNewline:s,verboseInfo:c,streamInfo:l}),u]);return d},Og=({stdout:e,stderr:t},{all:n})=>n&&(e||t)?Qp([e,t].filter(Boolean)):void 0,kg=({subprocess:e,all:t,encoding:n,buffer:r,maxBuffer:i,lines:a,stripFinalNewline:o,verboseInfo:s,streamInfo:c})=>Dg({...Ag(e,t,r),fdNumber:`all`,encoding:n,maxBuffer:i[1]+i[2],lines:a[1]||a[2],allMixed:jg(e,t),stripFinalNewline:o,verboseInfo:s,streamInfo:c}),Ag=({stdout:e,stderr:t},n,[,r,i])=>{let a=r||i;return a?r?i?{stream:n,buffer:a}:{stream:e,buffer:a}:{stream:t,buffer:a}:{stream:n,buffer:a}},jg=({stdout:e,stderr:t},n)=>n&&e&&t&&e.readableObjectMode!==t.readableObjectMode,Mg=e=>ni(e,`ipc`),Ng=(e,t)=>{let n=Hi(e);Ri({type:`ipc`,verboseMessage:n,fdNumber:`ipc`,verboseInfo:t})},Pg=async({subprocess:e,buffer:t,maxBuffer:n,ipc:r,ipcOutput:i,verboseInfo:a})=>{if(!r)return i;let o=Mg(a),s=ei(t,`ipc`),c=ei(n,`ipc`);for await(let t of Op({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:r,shouldAwait:!1,reference:!0}))s&&(sl(e,i,c),i.push(t)),o&&Ng(t,a);return i},Fg=async(e,t)=>(await Promise.allSettled([e]),t),Ig=async({subprocess:e,kill:t,all:n,options:{encoding:r,buffer:i,maxBuffer:a,lines:o,timeoutDuration:s,cancelSignal:c,gracefulCancel:l,forceKillAfterDelay:u,stripFinalNewline:d,ipc:f,ipcInput:p},context:m,verboseInfo:h,fileDescriptors:g,originalStreams:_,onInternalError:v,controller:y})=>{let b=np(e,m),x={originalStreams:_,fileDescriptors:g,subprocess:e,exitPromise:b,propagating:!1},S=Eg({subprocess:e,encoding:r,buffer:i,maxBuffer:a,lines:o,stripFinalNewline:d,verboseInfo:h,streamInfo:x}),C=kg({subprocess:e,all:n,encoding:r,buffer:i,maxBuffer:a,lines:o,stripFinalNewline:d,verboseInfo:h,streamInfo:x}),w=[],ee=Pg({subprocess:e,buffer:i,maxBuffer:a,ipc:f,ipcOutput:w,verboseInfo:h}),te=Lg(_,e,x),ne=Rg(g,x);try{return await Promise.race([Promise.all([{},ap(b),Promise.all(S),C,ee,hs(e,p,f),...te,...ne]),v,zg(e,y),...ls(t,s,m,y),...Wa({kill:t,cancelSignal:c,gracefulCancel:l,context:m,controller:y}),...as({subprocess:e,kill:t,cancelSignal:c,gracefulCancel:l,forceKillAfterDelay:u,context:m,controller:y})])}catch(e){return m.terminationReason??=`other`,Promise.all([{error:e},b,Promise.all(S.map(e=>wg(e))),wg(C),Fg(ee,w),Promise.allSettled(te),Promise.allSettled(ne)])}},Lg=(e,t,n)=>e.map((e,r)=>e===t.stdio[r]?void 0:dh(e,r,n)),Rg=(e,t)=>e.flatMap(({stdioItems:e},n)=>e.filter(({value:e,stream:t=e})=>uc(t,{checkOpen:!1})&&!Rr(t)).map(({type:e,value:r,stream:i=r})=>dh(i,n,t,{isSameDirection:fu.has(e),stopOnExit:e===`native`}))),zg=async(e,{signal:t})=>{let[n]=await i(e,`error`,{signal:t});throw n},Bg=({subprocess:e,concurrentStreams:t},{to:n}={})=>{let{subprocessStdin:r,waitWritableFinal:i,waitWritableDestroy:a}=Vg(e,n,t),o=new je({...Hg(r,e,i),destroy:se(Jg.bind(void 0,{subprocessStdin:r,subprocess:e,waitWritableFinal:i,waitWritableDestroy:a})),highWaterMark:r.writableHighWaterMark,objectMode:r.writableObjectMode});return Gg(r,o,void 0,e),o},Vg=(e,t,n)=>{let r=Zu(e,t);return{subprocessStdin:r,waitWritableFinal:Qm(n,r,`writableFinal`),waitWritableDestroy:Qm(n,r,`writableDestroy`)}},Hg=(e,t,n)=>({write:Ug.bind(void 0,e),final:se(Wg.bind(void 0,e,t,n))}),Ug=(e,t,n,r)=>{e.write(t,n)?r():e.once(`drain`,r)},Wg=async(e,t,n)=>{await $m(n,t)&&(e.writable&&e.end(),await t)},Gg=async(e,t,n,r)=>{try{await Sh(e),await r,t.writable&&t.end()}catch(e){await xh(n),Yg(t,await Kg(r,e))}},Kg=async(e,t)=>{if(!qg(t))return t;try{await e}catch(e){return e}return t},qg=e=>e===void 0||vh(e),Jg=async({subprocessStdin:e,subprocess:t,waitWritableFinal:n,waitWritableDestroy:r},i)=>{await $m(n,t),await $m(r,t)&&(Yg(e,i),await wh(t,i))},Yg=(e,t)=>{Th(e,e.writable,t)},Xg=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,to:i,binary:a=!0,preserveNewlines:o=!0}={})=>{let s=a||vs.has(n),{subprocessStdout:c,waitReadableDestroy:l}=Dh(e,r,t),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Vg(e,i,t),{readableEncoding:p,readableObjectMode:m,readableHighWaterMark:h}=Oh(c,s),{read:g,onStdoutDataDone:_}=kh({subprocessStdout:c,subprocess:e,binary:s,encoding:n,preserveNewlines:o}),v=new De({read:g,...Hg(u,e,d),destroy:se(Zg.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:e,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:h,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:m,writableObjectMode:u.writableObjectMode,encoding:p});return jh({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:e,subprocessStdin:u}),Gg(u,v,c,e),v},Zg=async({subprocessStdout:e,subprocessStdin:t,subprocess:n,waitReadableDestroy:r,waitWritableFinal:i,waitWritableDestroy:a},o)=>{await Promise.all([Nh({subprocessStdout:e,subprocess:n,waitReadableDestroy:r},o),Jg({subprocessStdin:t,subprocess:n,waitWritableFinal:i,waitWritableDestroy:a},o)])},Qg=(e,{encoding:t})=>{let n=Zm();e.readable=Eh.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.writable=Bg.bind(void 0,{subprocess:e,concurrentStreams:n}),e.duplex=Xg.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.readableStream=Fh.bind(void 0,e),e.writableStream=Ih.bind(void 0,e),e.transformStream=Lh.bind(void 0,e),e.iterable=lh.bind(void 0,e,t),e[Symbol.asyncIterator]=lh.bind(void 0,e,t,{})},$g=(e,t)=>Object.assign(e,t),e_=(e,t,n,r)=>{let{file:i,commandArguments:a,command:o,escapedCommand:s,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=t_(e,t,n),{subprocess:f,promise:p,kill:m,all:h,convertedStreams:g}=r_({file:i,commandArguments:a,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:s,fileDescriptors:d}),_=i_({promise:p,nodeChildProcess:f,kill:m,all:h,convertedStreams:g,options:u});return _.pipe=rg.bind(void 0,{source:_,sourcePromise:p,boundOptions:{},createNested:r}),$u.set(_,{options:u,fileDescriptors:d}),_},t_=(e,t,n)=>{let{command:r,escapedCommand:i,startTime:a,verboseInfo:o}=Zi(e,t,n),{file:s,commandArguments:c,options:l}=$s(e,t,n),u=n_(l);return{file:s,commandArguments:c,command:r,escapedCommand:i,startTime:a,verboseInfo:o,options:u,fileDescriptors:Jp(u,o)}},n_=({timeout:e,signal:t,...n})=>{if(t!==void 0)throw TypeError(`The "signal" option has been renamed to "cancelSignal" instead.`);return{...n,timeoutDuration:e}},r_=({file:e,commandArguments:t,options:n,startTime:r,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:c})=>{let u;try{u=l(...nc(e,t,Am(n)))}catch(e){return Lp({error:e,command:o,escapedCommand:s,fileDescriptors:c,options:n,startTime:r,verboseInfo:i})}let d=new AbortController;a(1/0,d.signal);let f=[...u.stdio];Cm(u,c,d),Vo(u,n);let p={},m=uo(),h=La.bind(void 0,{kill:jm(u,n),options:n,onInternalError:m,context:p,controller:d});Xm(h,n,d);let g=Og(u,n),_=o_({subprocess:u,kill:h,all:g,options:n,startTime:r,verboseInfo:i,fileDescriptors:c,originalStreams:f,command:o,escapedCommand:s,context:p,onInternalError:m,controller:d});return{subprocess:u,promise:_,kill:h,all:g}},i_=({promise:e,nodeChildProcess:t,kill:n,all:r,convertedStreams:i,options:a})=>{let o=$g(e,a_(t,r));return o.kill=n??o.kill,i===void 0?Qg(o,a):Object.assign(o,i),Pp(o,t,a),o},a_=(e,t)=>({nodeChildProcess:e,pid:e.pid,stdin:e.stdin,stdout:e.stdout,stderr:e.stderr,stdio:e.stdio,all:t,kill:e.kill.bind(e)}),o_=async({subprocess:e,kill:t,all:n,options:r,startTime:i,verboseInfo:a,fileDescriptors:o,originalStreams:s,command:c,escapedCommand:l,context:u,onInternalError:d,controller:f})=>{let[p,[m,h],g,_,v]=await Ig({subprocess:e,kill:t,all:n,options:r,context:u,verboseInfo:a,fileDescriptors:o,originalStreams:s,onInternalError:d,controller:f});f.abort(),d.resolve();let y=g.map((e,t)=>Zd(e,r,t)),b=Zd(_,r,`all`),x=s_({errorInfo:p,exitCode:m,signal:h,stdio:y,all:b,ipcOutput:v,context:u,options:r,command:c,escapedCommand:l,startTime:i});return Ll(x,a,r)},s_=({errorInfo:e,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:a,context:o,options:s,command:c,escapedCommand:l,startTime:u})=>`error`in e?Sl({error:e.error,command:c,escapedCommand:l,timedOut:o.terminationReason===`timeout`,isCanceled:o.terminationReason===`cancel`||o.terminationReason===`gracefulCancel`,isGracefullyCanceled:o.terminationReason===`gracefulCancel`,isMaxBuffer:e.error instanceof Mc,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:a,options:s,startTime:u,isSync:!1}):bl({command:c,escapedCommand:l,stdio:r,all:i,ipcOutput:a,options:s,startTime:u}),c_=(e,t)=>{let n={__proto__:null,...e},r=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,l_(e,n[e],t)]));return{...n,...r}},l_=(e,t,n)=>u_.has(e)&&z(t)&&z(n)?{...t,...n}:n,u_=new Set([`env`,...$r]),d_=(e,t,n,r)=>{let i=(e,t,r)=>d_(e,t,n,r),a=(...a)=>f_({mapArguments:e,deepOptions:n,boundOptions:t,setBoundExeca:r,createNested:i},...a);return r!==void 0&&r(a,i,t),a},f_=({mapArguments:e,deepOptions:t={},boundOptions:n={},setBoundExeca:r,createNested:i},a,...o)=>{if(z(a))return i(e,c_(n,a),r);let{file:s,commandArguments:c,options:l,isSync:u}=p_({mapArguments:e,firstArgument:a,nextArguments:o,deepOptions:t,boundOptions:n});return u?up(s,c,l):e_(s,c,l,i)},p_=({mapArguments:e,firstArgument:t,nextArguments:n,deepOptions:r,boundOptions:i})=>{let a=kr(t)?Ar(t,n):[t,...n],[o,s,c]=hr(...a),l=c_(c_(r,i),c),{options:u=l,isSync:d=!1}=e({options:l});return{file:o,commandArguments:s,options:u,isSync:d}},m_=(e,t,n)=>{e.sync=t(g_,n),e.s=e.sync},h_=({options:e})=>__(e),g_=({options:e})=>({...__(e),isSync:!0}),__=e=>({options:{...v_(e),...e}}),v_=({input:e,inputFile:t,stdio:n})=>e===void 0&&t===void 0&&n===void 0?{stdin:`inherit`}:{},y_={preferLocal:!0},b_=d_(()=>({})),x_=d_(()=>({isSync:!0}));d_(ds),d_(h_,{},y_,m_);const{sendMessage:S_,getOneMessage:C_,getEachMessage:w_,getCancelSignal:T_}=Fp();var K=class e{constructor(e){this.cmd=e}sync(...t){return e.run(this.cmd,t).sync()}run(...t){return e.run(this.cmd,t)}get(...e){return x_(this.cmd,e,{reject:!0}).stdout.trim()}tryGet(...e){try{return this.get(...e)}catch{return null}}available(){let e=Qn?`where`:`which`;try{return x_(e,[this.cmd],{reject:!0}),!0}catch{return!1}}static run(t,n=[],r={}){let i=(e={})=>({cwd:process.cwd(),...e,...r}),a=!0,o=new Promise((e,r)=>{setTimeout(async()=>{if(a)try{await b_(t,n,i({stdio:`inherit`})),e()}catch(e){r(e)}else e()},10)});return o.toStream=e=>(a=!1,b_(t,n,i(e))),o.cwd=e=>(r={...r,cwd:e},o),o.sync=e=>(a=!1,x_(t,n,{cwd:process.cwd(),stdio:`inherit`,...r,...e})),o.getRaw=i=>(a=!1,e.getRaw(t,n,{cwd:process.cwd(),...r,...i})),o.get=o.getRaw,o}static getRaw(e,t,n){return x_(e,t,{encoding:`utf8`,...n}).stdout.trim()}};const E_=new class extends K{constructor(){super(`claude`)}version(){return this.tryGet(`--version`)}listMcp(){return this.tryGet(`mcp`,`list`)??``}hasMcp(e){let t=this.listMcp();return t.includes(e)||t.includes(`plugin:${e}`)}addMcp(e,t,n=`user`,r=!1){return!r&&this.hasMcp(e)?!1:(r&&this.hasMcp(e)&&this.removeMcp(e),this.tryGet(`mcp`,`add-json`,`--scope`,n,e,t),!0)}removeMcp(e){return this.hasMcp(e)?(this.tryGet(`mcp`,`remove`,e),!0):!1}setDefaultModel(e){this.tryGet(`config`,`set`,`--global`,`model`,e)}async addMarketplace(e){await this.run(`plugin`,`install`,e),await this.run(`mcp`,`login`,`plugin:${e.split(`@`)[0]}:${e.split(`@`)[0]}`)}};
|
|
121
|
+
/*!
|
|
122
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
123
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
124
|
+
*
|
|
125
|
+
* Redistribution and use in source and binary forms, with or without
|
|
126
|
+
* modification, are permitted provided that the following conditions are met:
|
|
127
|
+
*
|
|
128
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
129
|
+
* list of conditions and the following disclaimer.
|
|
130
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
131
|
+
* this list of conditions and the following disclaimer in the
|
|
132
|
+
* documentation and/or other materials provided with the distribution.
|
|
133
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
134
|
+
* may be used to endorse or promote products derived from this software without
|
|
135
|
+
* specific prior written permission.
|
|
136
|
+
*
|
|
137
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
138
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
139
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
140
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
141
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
142
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
143
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
144
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
145
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
146
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
147
|
+
*/
|
|
148
|
+
let D_=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var O_=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(D_);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
|
|
149
|
+
/*!
|
|
150
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
151
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
152
|
+
*
|
|
153
|
+
* Redistribution and use in source and binary forms, with or without
|
|
154
|
+
* modification, are permitted provided that the following conditions are met:
|
|
155
|
+
*
|
|
156
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
157
|
+
* list of conditions and the following disclaimer.
|
|
158
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
159
|
+
* this list of conditions and the following disclaimer in the
|
|
160
|
+
* documentation and/or other materials provided with the distribution.
|
|
161
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
162
|
+
* may be used to endorse or promote products derived from this software without
|
|
163
|
+
* specific prior written permission.
|
|
164
|
+
*
|
|
165
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
166
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
167
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
168
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
169
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
170
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
171
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
172
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
173
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
174
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
175
|
+
*/
|
|
176
|
+
function k_(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function A_(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
|
|
177
|
+
`,e===t&&(i+=` `.repeat(a+n+2),i+=`^
|
|
178
|
+
`))}return i}var q=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=k_(t.toml,t.ptr),i=A_(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
|
|
179
|
+
/*!
|
|
180
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
181
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
182
|
+
*
|
|
183
|
+
* Redistribution and use in source and binary forms, with or without
|
|
184
|
+
* modification, are permitted provided that the following conditions are met:
|
|
185
|
+
*
|
|
186
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
187
|
+
* list of conditions and the following disclaimer.
|
|
188
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
189
|
+
* this list of conditions and the following disclaimer in the
|
|
190
|
+
* documentation and/or other materials provided with the distribution.
|
|
191
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
192
|
+
* may be used to endorse or promote products derived from this software without
|
|
193
|
+
* specific prior written permission.
|
|
194
|
+
*
|
|
195
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
196
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
197
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
198
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
199
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
200
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
201
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
202
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
203
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
204
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
205
|
+
*/
|
|
206
|
+
function j_(e,t=0){let n=e.indexOf(`
|
|
207
|
+
`,t);return e.charCodeAt(n-1)===13&&n--,n}function M_(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)break;if(t===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}if(t<32&&t!==9||t===127)throw new q(`control characters are not allowed in comments`,{toml:e.s,ptr:e.p})}}function N_(e,t,n){let r;for(;;){for(;(r=e.s.charCodeAt(e.p))===32||r===9||!t&&(r===10||r===13&&e.s.charCodeAt(e.p+1)===10);)e.p++;if(n||r!==35)break;M_(e)}}function P_(e,t,n){let r=e.p;if(!n){r=j_(e.s,r),e.p=r<0?e.s.length:r;return}for(;e.p<e.s.length;e.p++){let r=e.s.charCodeAt(e.p);if(r===35)M_(e);else if(r===n||r===t)return}throw new q(`cannot find end of structure`,{toml:e.s,ptr:r})}
|
|
208
|
+
/*!
|
|
209
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
210
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
211
|
+
*
|
|
212
|
+
* Redistribution and use in source and binary forms, with or without
|
|
213
|
+
* modification, are permitted provided that the following conditions are met:
|
|
214
|
+
*
|
|
215
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
216
|
+
* list of conditions and the following disclaimer.
|
|
217
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
218
|
+
* this list of conditions and the following disclaimer in the
|
|
219
|
+
* documentation and/or other materials provided with the distribution.
|
|
220
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
221
|
+
* may be used to endorse or promote products derived from this software without
|
|
222
|
+
* specific prior written permission.
|
|
223
|
+
*
|
|
224
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
225
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
226
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
227
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
228
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
229
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
230
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
231
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
232
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
233
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
234
|
+
*/
|
|
235
|
+
let F_=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,I_=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,L_=/^[+-]?0[0-9_]/;function R_(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);a&&((n=e.s.charCodeAt(e.p+=2))===10?e.p++:n===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let o=``,s=e.p,c=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),a&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))c&&=3;else if(n<32&&n!==9||n===127)throw new q(`control characters are not allowed in strings`,{toml:e.s,ptr:e.p});else if((!c||c===3)&&n===r&&(!a||e.s.charCodeAt(e.p+1)===r&&e.s.charCodeAt(e.p+2)===r))return a&&(e.s.charCodeAt(e.p+3)===r&&e.p++,e.s.charCodeAt(e.p+3)===r&&e.p++),c||(o+=e.s.slice(s,e.p)),e.p+=a?3:1,o;else if(!c)!i&&n===92&&(o+=e.s.slice(s,s=e.p),c=1);else if(c===1){if(n===120||n===117||n===85){let t=0,r=n===120?2:n===117?4:8;for(let n=0;n<r;n++,e.p++){let n=e.s.charCodeAt(e.p+1),r=n>=48&&n<=57?n-48:n>=65&&n<=70?n-65+10:n>=97&&n<=102?n-97+10:-1;if(r<0)throw new q(`invalid non-hex character in unicode escape`,{toml:e.s,ptr:e.p+1});t=t<<4|r}if(t<0||t>1114111||t>=55296&&t<=57343)throw new q(`invalid unicode escape`,{toml:e.s,ptr:e.p});o+=String.fromCodePoint(t),s=e.p+1,c=0}else if(n===32||n===9)c=2;else{if(n===98)o+=`\b`;else if(n===116)o+=` `;else if(n===110)o+=`
|
|
236
|
+
`;else if(n===102)o+=`\f`;else if(n===114)o+=`\r`;else if(n===101)o+=`\x1B`;else if(n===34)o+=`"`;else if(n===92)o+=`\\`;else throw new q(`unrecognized escape sequence`,{toml:e.s,ptr:e.p});s=e.p+1,c=0}}else if(n!==32&&n!==9){if(c===2)throw new q(`invalid escape: only line-ending whitespace may be escaped`,{toml:e.s,ptr:s});c=+(!i&&n===92),s=e.p}throw new q(`unfinished string`,{toml:e.s,ptr:t})}function z_(e,t,n){let r=e.s.slice(t,n),i=r.indexOf(`#`);return i>0&&(M_({s:r,p:i,d:0}),r=r.slice(0,i)),r.trimEnd()}function B_(e,t,n){let r=e.p,i={toml:e.s,ptr:r};P_(e,44,n);let a=z_(e,r,e.p);if(!a)throw new q(`incomplete declaration: value expected`,i);if(a===`-inf`)return-1/0;if(a===`inf`||a===`+inf`)return 1/0;if(a===`nan`||a===`+nan`||a===`-nan`)return NaN;if(a===`-0`)return t?0n:0;let o=F_.test(a);if(o||I_.test(a)){if(L_.test(a))throw new q(`leading zeroes are not allowed`,i);a=a.replace(/_/g,``);let e=+a;if(isNaN(e))throw new q(`invalid number`,i);if(o){if((o=!Number.isSafeInteger(e))&&!t)throw new q(`integer value cannot be represented losslessly`,i);(o||t===!0)&&(e=BigInt(a))}return e}let s=new O_(a);if(!s.isValid())throw new q(`invalid value`,i);return s}
|
|
237
|
+
/*!
|
|
238
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
239
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
240
|
+
*
|
|
241
|
+
* Redistribution and use in source and binary forms, with or without
|
|
242
|
+
* modification, are permitted provided that the following conditions are met:
|
|
243
|
+
*
|
|
244
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
245
|
+
* list of conditions and the following disclaimer.
|
|
246
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
247
|
+
* this list of conditions and the following disclaimer in the
|
|
248
|
+
* documentation and/or other materials provided with the distribution.
|
|
249
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
250
|
+
* may be used to endorse or promote products derived from this software without
|
|
251
|
+
* specific prior written permission.
|
|
252
|
+
*
|
|
253
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
254
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
255
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
256
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
257
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
258
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
259
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
260
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
261
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
262
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
263
|
+
*/
|
|
264
|
+
function V_(e,t,n){let r=e.p,i=e.s.charCodeAt(r);if(i===91||i===123){if(!e.d--)throw new q(`document contains excessively nested structures. aborting.`,{toml:e.s,ptr:r});let t=i===91?G_(e,n):W_(e,n);return e.d++,t}if(i===34||i===39)return R_(e);if(i===116){if(e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)throw new q(`invalid value`,{toml:e.s,ptr:r});return e.p++,!0}if(i===102){if(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)throw new q(`invalid value`,{toml:e.s,ptr:r});return e.p++,!1}return B_(e,n,t)}
|
|
265
|
+
/*!
|
|
266
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
267
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
268
|
+
*
|
|
269
|
+
* Redistribution and use in source and binary forms, with or without
|
|
270
|
+
* modification, are permitted provided that the following conditions are met:
|
|
271
|
+
*
|
|
272
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
273
|
+
* list of conditions and the following disclaimer.
|
|
274
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
275
|
+
* this list of conditions and the following disclaimer in the
|
|
276
|
+
* documentation and/or other materials provided with the distribution.
|
|
277
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
278
|
+
* may be used to endorse or promote products derived from this software without
|
|
279
|
+
* specific prior written permission.
|
|
280
|
+
*
|
|
281
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
282
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
283
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
284
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
285
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
286
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
287
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
288
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
289
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
290
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
291
|
+
*/
|
|
292
|
+
let H_=/^[a-zA-Z0-9-_]+[ \t]*$/;function U_(e,t=`=`){let n=e.p,r=n-1,i=[],a=e.s.indexOf(t,n);if(a<0)throw new q(`incomplete key-value: cannot find end of key`,{toml:e.s,ptr:n});do{let o=e.s.charCodeAt(e.p=++r);if(o!==32&&o!==9){if(o===34||o===39){if(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2))throw new q(`multiline strings are not allowed in keys`,{toml:e.s,ptr:e.p});let s=R_(e);r=e.s.indexOf(`.`,e.p);let c=e.s.slice(e.p,r<0||r>a?a:r),l=j_(c);if(l>-1)throw new q(`newlines are not allowed in keys`,{toml:e.s,ptr:l});if(c.trimStart())throw new q(`found extra tokens after the string part`,{toml:e.s,ptr:e.p});if(a<e.p&&(a=e.s.indexOf(t,e.p),a<0))throw new q(`incomplete key-value: cannot find end of key`,{toml:e.s,ptr:n});i.push(s)}else{r=e.s.indexOf(`.`,e.p);let t=e.s.slice(e.p,r<0||r>a?a:r);if(!H_.test(t))throw new q(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e.s,ptr:e.p});i.push(t.trimEnd())}}}while(r+1&&r<a);return e.p=a+1,N_(e,!0,!0),i}function W_(e,t){let n={},r=new Set,i;for(e.p++;e.p<e.s.length;){if(N_(e),(i=e.s.charCodeAt(e.p))===125)return e.p++,n;let a,o=n,s=!1,c=e.p,l=U_(e);for(let t=0;t<l.length;t++){if(t&&(o=s?o[a]:o[a]={}),a=l[t],(s=Object.hasOwn(o,a))&&(typeof o[a]!=`object`||r.has(o[a])))throw new q(`trying to redefine an already defined value`,{toml:e.s,ptr:c});!s&&a===`__proto__`&&Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0})}if(s)throw new q(`trying to redefine an already defined value`,{toml:e.s,ptr:e.p});let u=V_(e,125,t);if(r.add(o[a]=u),N_(e),(i=e.s.charCodeAt(e.p++))===125)return n;if(i!==44)throw new q(`expected comma or end of structure`,{toml:e.s,ptr:e.p-1})}throw new q(`unfinished table encountered`,{toml:e.s,ptr:e.p})}function G_(e,t){let n=[],r;for(e.p++;e.p<e.s.length;){if(N_(e),(r=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(V_(e,93,t)),N_(e),(r=e.s.charCodeAt(e.p++))===93)return n;if(r!==44)throw new q(`expected comma or end of structure`,{toml:e.s,ptr:e.p-1})}throw new q(`unfinished array encountered`,{toml:e.s,ptr:e.p})}
|
|
293
|
+
/*!
|
|
294
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
295
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
296
|
+
*
|
|
297
|
+
* Redistribution and use in source and binary forms, with or without
|
|
298
|
+
* modification, are permitted provided that the following conditions are met:
|
|
299
|
+
*
|
|
300
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
301
|
+
* list of conditions and the following disclaimer.
|
|
302
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
303
|
+
* this list of conditions and the following disclaimer in the
|
|
304
|
+
* documentation and/or other materials provided with the distribution.
|
|
305
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
306
|
+
* may be used to endorse or promote products derived from this software without
|
|
307
|
+
* specific prior written permission.
|
|
308
|
+
*
|
|
309
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
310
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
311
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
312
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
313
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
314
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
315
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
316
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
317
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
318
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
319
|
+
*/
|
|
320
|
+
function K_(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&(r!==1||c.t!==3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function q_(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={s:e,p:0,d:t},i={},a={},o,s=i,c=a;for(N_(r);r.p<e.length;){if(e.charCodeAt(r.p)===91){let t=e.charCodeAt(++r.p)===91;o=r.p+=+t;let n=U_(r,`]`);if(t){if(e.charCodeAt(r.p-1)!==93)throw new q(`expected end of table declaration`,{toml:e,ptr:r.p-1});r.p++}let l=K_(n,i,a,t?2:1);if(!l)throw new q(`trying to redefine an already defined table or value`,{toml:e,ptr:o});c=l[2],s=l[1]}else{o=r.p;let t=K_(U_(r),s,c,0);if(!t)throw new q(`trying to redefine an already defined table or value`,{toml:e,ptr:o});t[1][t[0]]=V_(r,void 0,n)}if(N_(r,!0),r.p<e.length&&(o=e.charCodeAt(r.p))!==10&&o!==13)throw new q(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:r.p});N_(r)}return i}
|
|
321
|
+
/*!
|
|
322
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
323
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
324
|
+
*
|
|
325
|
+
* Redistribution and use in source and binary forms, with or without
|
|
326
|
+
* modification, are permitted provided that the following conditions are met:
|
|
327
|
+
*
|
|
328
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
329
|
+
* list of conditions and the following disclaimer.
|
|
330
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
331
|
+
* this list of conditions and the following disclaimer in the
|
|
332
|
+
* documentation and/or other materials provided with the distribution.
|
|
333
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
334
|
+
* may be used to endorse or promote products derived from this software without
|
|
335
|
+
* specific prior written permission.
|
|
336
|
+
*
|
|
337
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
338
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
339
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
340
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
341
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
342
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
343
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
344
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
345
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
346
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
347
|
+
*/
|
|
348
|
+
let J_=/^[a-z0-9-_]+$/i;function Y_(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(typeof e?.getUTCDate==`function`&&e instanceof Date)return`date`;if(globalThis.Temporal&&typeof e?.since==`function`&&(e instanceof Temporal.Instant||e instanceof Temporal.PlainDate||e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainTime||e instanceof Temporal.ZonedDateTime))return`temporal`}return t}function X_(e){for(let t=0;t<e.length;t++)if(Y_(e[t])!==`object`)return!1;return e.length!=0}function Z_(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function Q_(e){return e.toString({calendarName:`never`,timeZoneName:`never`})}function $_(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);switch(t){case`number`:if(isNaN(e))return`nan`;if(e===1/0)return`inf`;if(e===-1/0)return`-inf`;if(Number.isInteger(e)&&(r||!Number.isSafeInteger(e)))return e.toFixed(1);case`bigint`:case`boolean`:return e.toString();case`string`:return Z_(e);case`date`:if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString();case`object`:return ev(e,n,r);case`array`:return tv(e,n,r);case`temporal`:return Q_(e)}}function ev(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=J_.test(o)?o:Z_(o),i+=` = `,i+=$_(e[o],Y_(e[o]),t-1,n)}return i+` }`}function tv(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=$_(e[i],Y_(e[i]),t-1,n)}return r+` ]`}function nv(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
|
|
349
|
+
`}[[${t}]]\n`,i+=rv(0,e[a],t,n,r);return i}function rv(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=Y_(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=J_.test(c)?c:Z_(c);if(e===`array`&&X_(t[c]))o+=(o&&`
|
|
350
|
+
`)+nv(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
351
|
+
`)+rv(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=$_(t[c],e,r,i),a+=`
|
|
352
|
+
`}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function iv(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Y_(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=rv(0,e,``,t,n);return r[r.length-1]===`
|
|
353
|
+
`?r:r+`
|
|
354
|
+
`}const av=new class extends K{constructor(){super(`codex`)}version(){return this.tryGet(`--version`)}getConfig(){if(!L.default.pathExistsSync(R))return null;try{return q_(L.default.readFileSync(R,`utf8`))}catch{return null}}updateConfig(e){L.default.ensureDirSync(f(R)),L.default.writeFileSync(R,iv(e),`utf8`)}writeBaseConfig(e,t){let n=L.default.pathExistsSync(R)&&t;return n&&L.default.copyFileSync(R,`${R}.bak`),this.updateConfig(e),n}listMcp(){return this.tryGet(`mcp`,`list`)??``}hasMcp(e){return this.listMcp().includes(e)}addMcp(e,t,n=!1){return!n&&this.hasMcp(e)?!1:(n&&this.hasMcp(e)&&this.tryGet(`mcp`,`remove`,e),this.tryGet(`mcp`,`add-json`,e,t),!0)}removeMcp(e){return this.hasMcp(e)?(this.tryGet(`mcp`,`remove`,e),!0):!1}addExtraMcpSettings(e,t){let n=this.getConfig();n?.mcp_servers?.[e]&&(n.mcp_servers[e]={...n.mcp_servers[e],...t},this.updateConfig(n))}},ov=new K(`git`),sv=new K(`mise`),cv=new K(`node`),lv=new K(Qn?`python`:`python3`);var uv=class extends Error{constructor(e,t){super(`${e}: ${t.join(`, `)}`),this.name=`CheckError`}};function J(e,t=``){N.success(t?`${e} — ${t}`:e)}function dv(e,t=``){N.warn(t?`${e} — ${t}`:e)}function Y(e,t){N.error(`${e} — ${t}`)}function fv(e){return Qn?new K(`powershell`).tryGet(`-Command`,`[System.Environment]::GetEnvironmentVariable('${e}', 'User')`)??void 0:process.env[e]}function pv(){N.step(`Tools`);let e=[],t=ov.tryGet(`--version`);t?J(`git`,t.replace(`git version `,``)):(Y(`git`,`not found`),e.push(`git`));let n=sv.tryGet(`--version`);n?J(`mise`,n):(Y(`mise`,`not found`),e.push(`mise`));let r=cv.tryGet(`-v`);r?J(`node`,r):(Y(`node`,`not found`),e.push(`node`)),av.available()?J(`codex`):(Y(`codex`,`not found`),e.push(`codex`)),E_.available()?J(`claude`):(Y(`claude`,`not found`),e.push(`claude`));let i=lv.tryGet(`--version`);if(i?J(`python`,i):dv(`python`,`not installed (optional)`),e.length)throw new uv(`Tools`,e)}function mv(){N.step(`Environment Variables`);let e=[];for(let t of lr)fv(t)?J(t):(Y(t,`not set`),e.push(t));for(let e of ur)fv(e)?J(e):dv(e,`not set (optional)`);if(e.length)throw new uv(`Environment Variables`,e)}function hv(){if(N.step(`Codex — config.toml`),!av.getConfig())throw Y(`config.toml`,`not found (~/.codex/config.toml)`),new uv(`Codex`,[`config.toml missing`]);J(`config.toml`,R);let e=[];for(let t of Object.keys(or))av.hasMcp(t)?J(`MCP ${t}`):(Y(`MCP ${t}`,`not configured`),e.push(t));if(e.length)throw new uv(`Codex MCPs`,e)}function gv(){if(N.step(`Claude — MCPs`),!E_.available())throw Y(`Claude MCPs`,`claude CLI not found`),new uv(`Claude MCPs`,[`claude CLI not found`]);let e=E_.listMcp(),t=[],n=[[`clubmed_api`,e.includes(`clubmed_api`)],[`cms_api`,e.includes(`cms_api`)],[`atlassian`,e.includes(`atlassian`)||e.includes(`plugin:atlassian`)]];for(let[e,r]of n)r?J(`MCP ${e}`):(Y(`MCP ${e}`,`not configured`),t.push(e));if(t.length)throw new uv(`Claude MCPs`,t)}function _v(){N.step(`Repository`);let e=process.env.CLUBMED_REPO_DIR??er;if(L.default.pathExistsSync(p(e,`.git`)))J(`Repository`,e);else throw Y(`Repository`,e),new uv(`Repository`,[`not cloned`])}var vv=e=>void e.command(`check`).description(`Check the installation state of the workstation`).action(()=>{fn(`Club Med — AI Tools Check (${Qn?`Windows`:`macOS/Linux`})`);let e=[];for(let t of[pv,mv,hv,gv,_v])try{t()}catch(t){if(t instanceof uv)e.push(t);else throw t}e.length?(pn(`Some checks failed — run cm-agents install to fix.`),process.exit(1)):pn(`Everything is correctly configured.`)});function yv(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function bv(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
355
|
+
`:`
|
|
356
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
357
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const xv=(e=0)=>t=>`\u{1B}[${t+e}m`,Sv=(e=0)=>t=>`\u{1B}[${38+e};5;${t}m`,Cv=(e=0)=>(t,n,r)=>`\u{1B}[${38+e};2;${t};${n};${r}m`,wv=e=>`\u{1B}[58;5;${e<90?e-30:e-90+8}m`,X={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:[`4:2`,24],underlineCurly:[`4:3`,24],underlineDotted:[`4:4`,24],underlineDashed:[`4:5`,24],overline:[53,55],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],gray:[90,39],grey:[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],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:[`58;5;0`,59],underlineRed:[`58;5;1`,59],underlineGreen:[`58;5;2`,59],underlineYellow:[`58;5;3`,59],underlineBlue:[`58;5;4`,59],underlineMagenta:[`58;5;5`,59],underlineCyan:[`58;5;6`,59],underlineWhite:[`58;5;7`,59],underlineBlackBright:[`58;5;8`,59],underlineGray:[`58;5;8`,59],underlineGrey:[`58;5;8`,59],underlineRedBright:[`58;5;9`,59],underlineGreenBright:[`58;5;10`,59],underlineYellowBright:[`58;5;11`,59],underlineBlueBright:[`58;5;12`,59],underlineMagentaBright:[`58;5;13`,59],underlineCyanBright:[`58;5;14`,59],underlineWhiteBright:[`58;5;15`,59]}};Object.keys(X.modifier);const Tv=Object.keys(X.color),Ev=Object.keys(X.bgColor);Object.keys(X.underlineColor),[...Tv,...Ev];function Dv(){let e=new Map;for(let[t,n]of Object.entries(X)){for(let[t,r]of Object.entries(n))X[t]={open:`\u{1B}[${r[0]}m`,close:`\u{1B}[${r[1]}m`},n[t]=X[t],e.set(Number.parseInt(r[0],10),r[1]);Object.defineProperty(X,t,{value:n,enumerable:!1})}return Object.defineProperty(X,"codes",{value:e,enumerable:!1}),X.color.close=`\x1B[39m`,X.bgColor.close=`\x1B[49m`,X.underlineColor.close=`\x1B[59m`,X.color.ansi=xv(),X.color.ansi256=Sv(),X.color.ansi16m=Cv(),X.bgColor.ansi=xv(10),X.bgColor.ansi256=Sv(10),X.bgColor.ansi16m=Cv(10),X.underlineColor.ansi=wv,X.underlineColor.ansi256=Sv(20),X.underlineColor.ansi16m=Cv(20),Object.defineProperties(X,{rgbToAnsi256:{value(e,t,n){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)},enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>X.rgbToAnsi256(...X.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>X.ansi256ToAnsi(X.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>X.ansi256ToAnsi(X.hexToAnsi256(e)),enumerable:!1}}),X}const Ov=Dv();function Z(e,t=globalThis.Deno?globalThis.Deno.args:w.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:Q}=w;let kv;Z(`no-color`)||Z(`no-colors`)||Z(`color=false`)||Z(`color=never`)?kv=0:(Z(`color`)||Z(`colors`)||Z(`color=true`)||Z(`color=always`))&&(kv=1);function Av(){return/^\d+$/.test(Q.FORCE_COLOR)}function jv(){if(`FORCE_COLOR`in Q){if(Q.FORCE_COLOR===`false`)return 0;if(Q.FORCE_COLOR===`true`||Q.FORCE_COLOR.length===0)return 1;if(Av())return Math.min(Number.parseInt(Q.FORCE_COLOR,10),3)}}function Mv(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Nv(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=jv();r!==void 0&&(kv=r);let i=n?kv:r;if(i===0)return 0;if(n){if(Z(`color=16m`)||Z(`color=full`)||Z(`color=truecolor`))return 3;if(Z(`color=256`))return 2}if(i!==void 0&&Av())return i;if(`TF_BUILD`in Q&&`AGENT_NAME`in Q)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(Q.TERM===`dumb`)return a;if(w.platform===`win32`){let e=ge.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in Q)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in Q)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in Q)||Q.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in Q)return+!!/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(Q.TEAMCITY_VERSION);if(Q.COLORTERM===`truecolor`||Q.TERM===`xterm-kitty`||Q.TERM===`xterm-ghostty`||Q.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in Q){let e=Number.parseInt((Q.TERM_PROGRAM_VERSION||``).split(`.`,1)[0],10);switch(Q.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(?:color)?$/i.test(Q.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Q.TERM)||`COLORTERM`in Q?1:a}function Pv(e,t={}){return Mv(Nv(e,{streamIsTTY:e&&e.isTTY,...t}))}const{stdout:Fv,stderr:Iv}={stdout:Pv({isTTY:me.isatty(1)}),stderr:Pv({isTTY:me.isatty(2)})},Lv=Symbol(`GENERATOR`),Rv=Symbol(`STYLER`),zv=Symbol(`IS_EMPTY`),Bv=Symbol(`LEVEL`),Vv=Object.create(null),Hv=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")},Uv={enumerable:!0,get(){return this[Bv]},set(e){Hv(e),this[Bv]=e}},Wv=(e,t={})=>{t.level!==void 0&&Hv(t.level);let n=Fv?Fv.level:0;e[Bv]=t.level===void 0?n:t.level},Gv=e=>{let t=(...e)=>e.join(` `);return Wv(t,e),Object.setPrototypeOf(t,Kv.prototype),t};function Kv(e){return Gv(e)}Object.setPrototypeOf(Kv.prototype,Function.prototype);for(let[e,t]of Object.entries(Ov))Vv[e]={get(){let n=Xv(this,Yv(t.open,t.close,this[Rv]),this[zv]);return Object.defineProperty(this,e,{value:n}),n}};Vv.visible={get(){let e=Xv(this,this[Rv],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const qv=(e,t)=>{let n=Ov[t];if(e===`rgb`){let e=(e,t,r)=>n.ansi(Ov.rgbToAnsi(e,t,r));return[e,e,(e,t,r)=>n.ansi256(Ov.rgbToAnsi256(e,t,r)),n.ansi16m]}if(e===`hex`){let e=e=>n.ansi(Ov.hexToAnsi(e));return[e,e,e=>n.ansi256(Ov.hexToAnsi256(e)),e=>n.ansi16m(...Ov.hexToRgb(e))]}let r=e=>n.ansi(Ov.ansi256ToAnsi(e));return[r,r,n.ansi256,n.ansi256]};for(let e of[`rgb`,`hex`,`ansi256`]){let t=e[0].toUpperCase()+e.slice(1);for(let[n,r]of[[e,`color`],[`bg`+t,`bgColor`],[`underline`+t,`underlineColor`]]){let{close:t}=Ov[r],i=qv(e,r);Vv[n]={get(){let e=function(e,n,r){let a=i[this.level](e,n,r);return Xv(this,Yv(a,t,this[Rv]),this[zv])};return Object.defineProperty(this,n,{value:e}),e}}}}const Jv=Object.defineProperties(()=>{},{...Vv,level:{enumerable:!0,get(){return this[Lv].level},set(e){this[Lv].level=e}}}),Yv=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},Xv=(e,t,n)=>{let r=(...e)=>e.length===1?Zv(r,``+e[0]):e.length===2?Zv(r,e[0]+` `+e[1]):Zv(r,e.join(` `));return Object.setPrototypeOf(r,Jv),r[Lv]=e[Lv]??e,r[Rv]=t,r[zv]=n,r},Zv=(e,t)=>{if(e[Lv][Bv]<=0||!t)return e[zv]?``:t;let n=e[Rv];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=yv(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
358
|
+
`);return a!==-1&&(t=bv(t,i,r,a)),r+t+i};Object.defineProperties(Kv.prototype,{...Vv,level:Uv});const $=Kv();Kv({level:Iv?Iv.level:0});var Qv=E(((e,t)=>{let n=[],r=0,i=(e,t)=>{r>=t&&n.push(e)};i.WARN=1,i.INFO=2,i.DEBUG=3,i.reset=()=>{n=[]},i.setDebugLevel=e=>{r=e},i.warn=e=>i(e,i.WARN),i.info=e=>i(e,i.INFO),i.debug=e=>i(e,i.DEBUG),i.debugMessages=()=>n,t.exports=i})),$v=E(((e,t)=>{t.exports=({onlyFirst:e=!1}={})=>{let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}})),ey=E(((e,t)=>{let n=$v();t.exports=e=>typeof e==`string`?e.replace(n(),``):e})),ty=E(((e,t)=>{let n=e=>!Number.isNaN(e)&&e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141);t.exports=n,t.exports.default=n})),ny=E(((e,t)=>{t.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}})),ry=E(((e,t)=>{let n=ey(),r=ty(),i=ny(),a=e=>{if(typeof e!=`string`||e.length===0||(e=n(e),e.length===0))return 0;e=e.replace(i(),` `);let t=0;for(let n=0;n<e.length;n++){let i=e.codePointAt(n);i<=31||i>=127&&i<=159||i>=768&&i<=879||(i>65535&&n++,t+=r(i)?2:1)}return t};t.exports=a,t.exports.default=a})),iy=E(((e,t)=>{let n=ry();function r(e){return e?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function i(e){let t=r();return(``+e).replace(t,``).split(`
|
|
359
|
+
`).reduce(function(e,t){return n(t)>e?n(t):e},0)}function a(e,t){return Array(t+1).join(e)}function o(e,t,n,r){let o=i(e);if(t+1>=o){let i=t-o;switch(r){case`right`:e=a(n,i)+e;break;case`center`:{let t=Math.ceil(i/2);e=a(n,i-t)+e+a(n,t);break}default:e+=a(n,i)}}return e}let s={};function c(e,t,n){t=`\x1B[`+t+`m`,n=`\x1B[`+n+`m`,s[t]={set:e,to:!0},s[n]={set:e,to:!1},s[e]={on:t,off:n}}c(`bold`,1,22),c(`italics`,3,23),c(`underline`,4,24),c(`inverse`,7,27),c(`strikethrough`,9,29);function l(e,t){let n=t[1]?parseInt(t[1].split(`;`)[0]):0;if(n>=30&&n<=39||n>=90&&n<=97){e.lastForegroundAdded=t[0];return}if(n>=40&&n<=49||n>=100&&n<=107){e.lastBackgroundAdded=t[0];return}if(n===0){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return}let r=s[t[0]];r&&(e[r.set]=r.to)}function u(e){let t=r(!0),n=t.exec(e),i={};for(;n!==null;)l(i,n),n=t.exec(e);return i}function d(e,t){let n=e.lastBackgroundAdded,r=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(n){e[n]&&(t+=s[n].off)}),n&&n!=`\x1B[49m`&&(t+=`\x1B[49m`),r&&r!=`\x1B[39m`&&(t+=`\x1B[39m`),t}function f(e,t){let n=e.lastBackgroundAdded,r=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(n){e[n]&&(t=s[n].on+t)}),n&&n!=`\x1B[49m`&&(t=n+t),r&&r!=`\x1B[39m`&&(t=r+t),t}function p(e,t){if(e.length===i(e))return e.substr(0,t);for(;i(e)>t;)e=e.slice(0,-1);return e}function m(e,t){let n=r(!0),a=e.split(r()),o=0,s=0,c=``,u,f={};for(;s<t;){u=n.exec(e);let r=a[o];if(o++,s+i(r)>t&&(r=p(r,t-s)),c+=r,s+=i(r),s<t){if(!u)break;c+=u[0],l(f,u)}}return d(f,c)}function h(e,t,n){if(n||=`…`,i(e)<=t)return e;t-=i(n);let r=m(e,t);r+=n;let a=`\x1B]8;;\x07`;return e.includes(a)&&!r.includes(a)&&(r+=a),r}function g(){return{chars:{top:`─`,"top-mid":`┬`,"top-left":`┌`,"top-right":`┐`,bottom:`─`,"bottom-mid":`┴`,"bottom-left":`└`,"bottom-right":`┘`,left:`│`,"left-mid":`├`,mid:`─`,"mid-mid":`┼`,right:`│`,"right-mid":`┤`,middle:`│`},truncate:`…`,colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:[`red`],border:[`grey`],compact:!1},head:[]}}function _(e,t){e||={},t||=g();let n=Object.assign({},t,e);return n.chars=Object.assign({},t.chars,e.chars),n.style=Object.assign({},t.style,e.style),n}function v(e,t){let n=[],r=t.split(/(\s+)/g),a=[],o=0,s;for(let t=0;t<r.length;t+=2){let c=r[t],l=o+i(c);o>0&&s&&(l+=s.length),l>e?(o!==0&&n.push(a.join(``)),a=[c],o=i(c)):(a.push(s||``,c),o=l),s=r[t+1]}return o&&n.push(a.join(``)),n}function y(e,t){let n=[],r=``;function i(t,i){for(r.length&&i&&(r+=i),r+=t;r.length>e;)n.push(r.slice(0,e)),r=r.slice(e)}let a=t.split(/(\s+)/g);for(let e=0;e<a.length;e+=2)i(a[e],e&&a[e-1]);return r.length&&n.push(r),n}function b(e,t,n=!0){let r=[];t=t.split(`
|
|
360
|
+
`);let i=n?v:y;for(let n=0;n<t.length;n++)r.push.apply(r,i(e,t[n]));return r}function x(e){let t={},n=[];for(let r=0;r<e.length;r++){let i=f(t,e[r]);t=u(i);let a=Object.assign({},t);n.push(d(a,i))}return n}function S(e,t){return[`\x1B]`,`8`,`;`,`;`,e||t,`\x07`,t,`\x1B]`,`8`,`;`,`;`,`\x07`].join(``)}t.exports={strlen:i,repeat:a,pad:o,truncate:h,mergeOptions:_,wordWrap:b,colorizeLines:x,hyperlink:S}})),ay=E(((e,t)=>{var n={};t.exports=n;var r={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(r).forEach(function(e){var t=r[e],i=n[e]=[];i.open=`\x1B[`+t[0]+`m`,i.close=`\x1B[`+t[1]+`m`})})),oy=E(((e,t)=>{t.exports=function(e,t){t||=process.argv;var n=t.indexOf(`--`),r=/^-{1,2}/.test(e)?``:`--`,i=t.indexOf(r+e);return i!==-1&&(n===-1||i<n)}})),sy=E(((e,t)=>{var n=D(`os`),r=oy(),i=process.env,a=void 0;r(`no-color`)||r(`no-colors`)||r(`color=false`)?a=!1:(r(`color`)||r(`colors`)||r(`color=true`)||r(`color=always`))&&(a=!0),`FORCE_COLOR`in i&&(a=i.FORCE_COLOR.length===0||parseInt(i.FORCE_COLOR,10)!==0);function o(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function s(e){if(a===!1)return 0;if(r(`color=16m`)||r(`color=full`)||r(`color=truecolor`))return 3;if(r(`color=256`))return 2;if(e&&!e.isTTY&&a!==!0)return 0;var t=+!!a;if(process.platform===`win32`){var o=n.release().split(`.`);return Number(process.versions.node.split(`.`)[0])>=8&&Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if(`CI`in i)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`].some(function(e){return e in i})||i.CI_NAME===`codeship`?1:t;if(`TEAMCITY_VERSION`in i)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION);if(`TERM_PROGRAM`in i){var s=parseInt((i.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(i.TERM_PROGRAM){case`iTerm.app`:return s>=3?3:2;case`Hyper`:return 3;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(i.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)||`COLORTERM`in i?1:(i.TERM,t)}function c(e){return o(s(e))}t.exports={supportsColor:c,stdout:c(process.stdout),stderr:c(process.stderr)}})),cy=E(((e,t)=>{t.exports=function(e,t){var n=``;e||=`Run the trap, drop the bass`,e=e.split(``);var r={a:[`@`,`Ą`,`Ⱥ`,`Ʌ`,`Δ`,`Λ`,`Д`],b:[`ß`,`Ɓ`,`Ƀ`,`ɮ`,`β`,`฿`],c:[`©`,`Ȼ`,`Ͼ`],d:[`Ð`,`Ɗ`,`Ԁ`,`ԁ`,`Ԃ`,`ԃ`],e:[`Ë`,`ĕ`,`Ǝ`,`ɘ`,`Σ`,`ξ`,`Ҽ`,`੬`],f:[`Ӻ`],g:[`ɢ`],h:[`Ħ`,`ƕ`,`Ң`,`Һ`,`Ӈ`,`Ԋ`],i:[`༏`],j:[`Ĵ`],k:[`ĸ`,`Ҡ`,`Ӄ`,`Ԟ`],l:[`Ĺ`],m:[`ʍ`,`Ӎ`,`ӎ`,`Ԡ`,`ԡ`,`൩`],n:[`Ñ`,`ŋ`,`Ɲ`,`Ͷ`,`Π`,`Ҋ`],o:[`Ø`,`õ`,`ø`,`Ǿ`,`ʘ`,`Ѻ`,`ם`,``,`๏`],p:[`Ƿ`,`Ҏ`],q:[`্`],r:[`®`,`Ʀ`,`Ȑ`,`Ɍ`,`ʀ`,`Я`],s:[`§`,`Ϟ`,`ϟ`,`Ϩ`],t:[`Ł`,`Ŧ`,`ͳ`],u:[`Ʊ`,`Ս`],v:[`ט`],w:[`Ш`,`Ѡ`,`Ѽ`,`൰`],x:[`Ҳ`,`Ӿ`,`Ӽ`,`ӽ`],y:[`¥`,`Ұ`,`Ӌ`],z:[`Ƶ`,`ɀ`]};return e.forEach(function(e){e=e.toLowerCase();var t=r[e]||[` `],i=Math.floor(Math.random()*t.length);r[e]===void 0?n+=e:n+=r[e][i]}),n}})),ly=E(((e,t)=>{t.exports=function(e,t){e||=` he is here `;var n={up:`̍.̎.̄.̅.̿.̑.̆.̐.͒.͗.͑.̇.̈.̊.͂.̓.̈.͊.͋.͌.̃.̂.̌.͐.̀.́.̋.̏.̒.̓.̔.̽.̉.ͣ.ͤ.ͥ.ͦ.ͧ.ͨ.ͩ.ͪ.ͫ.ͬ.ͭ.ͮ.ͯ.̾.͛.͆.̚`.split(`.`),down:`̖.̗.̘.̙.̜.̝.̞.̟.̠.̤.̥.̦.̩.̪.̫.̬.̭.̮.̯.̰.̱.̲.̳.̹.̺.̻.̼.ͅ.͇.͈.͉.͍.͎.͓.͔.͕.͖.͙.͚.̣`.split(`.`),mid:[`̕`,`̛`,`̀`,`́`,`͘`,`̡`,`̢`,`̧`,`̨`,`̴`,`̵`,`̶`,`͜`,`͝`,`͞`,`͟`,`͠`,`͢`,`̸`,`̷`,`͡`,` ҉`]},r=[].concat(n.up,n.down,n.mid);function i(e){return Math.floor(Math.random()*e)}function a(e){var t=!1;return r.filter(function(n){t=n===e}),t}function o(e,t){var r=``,o,s;for(s in t||={},t.up=t.up===void 0||t.up,t.mid=t.mid===void 0||t.mid,t.down=t.down===void 0||t.down,t.size=t.size===void 0?`maxi`:t.size,e=e.split(``),e)if(!a(s)){switch(r+=e[s],o={up:0,down:0,mid:0},t.size){case`mini`:o.up=i(8),o.mid=i(2),o.down=i(8);break;case`maxi`:o.up=i(16)+3,o.mid=i(4)+1,o.down=i(64)+3;break;default:o.up=i(8)+1,o.mid=i(6)/2,o.down=i(8)+1}var c=[`up`,`mid`,`down`];for(var l in c)for(var u=c[l],d=0;d<=o[u];d++)t[u]&&(r+=n[u][i(n[u].length)])}return r}return o(e,t)}})),uy=E(((e,t)=>{t.exports=function(e){return function(t,n,r){if(t===` `)return t;switch(n%3){case 0:return e.red(t);case 1:return e.white(t);case 2:return e.blue(t)}}}})),dy=E(((e,t)=>{t.exports=function(e){return function(t,n,r){return n%2==0?t:e.inverse(t)}}})),fy=E(((e,t)=>{t.exports=function(e){var t=[`red`,`yellow`,`green`,`blue`,`magenta`];return function(n,r,i){return n===` `?n:e[t[r++%t.length]](n)}}})),py=E(((e,t)=>{t.exports=function(e){var t=[`underline`,`inverse`,`grey`,`yellow`,`red`,`green`,`blue`,`white`,`cyan`,`magenta`,`brightYellow`,`brightRed`,`brightGreen`,`brightBlue`,`brightWhite`,`brightCyan`,`brightMagenta`];return function(n,r,i){return n===` `?n:e[t[Math.round(Math.random()*(t.length-2))]](n)}}})),my=E(((e,t)=>{var n={};t.exports=n,n.themes={};var r=D(`util`),i=n.styles=ay(),a=Object.defineProperties,o=new RegExp(/[\r\n]+/g);n.supportsColor=sy().supportsColor,n.enabled===void 0&&(n.enabled=n.supportsColor()!==!1),n.enable=function(){n.enabled=!0},n.disable=function(){n.enabled=!1},n.stripColors=n.strip=function(e){return(``+e).replace(/\x1B\[\d+m/g,``)},n.stylize=function(e,t){if(!n.enabled)return e+``;var r=i[t];return!r&&t in n?n[t](e):r.open+e+r.close};var s=/[|\\{}()[\]^$+*?.]/g,c=function(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(s,`\\$&`)};function l(e){var t=function e(){return f.apply(e,arguments)};return t._styles=e,t.__proto__=d,t}var u=(function(){var e={};return i.grey=i.gray,Object.keys(i).forEach(function(t){i[t].closeRe=new RegExp(c(i[t].close),`g`),e[t]={get:function(){return l(this._styles.concat(t))}}}),e})(),d=a(function(){},u);function f(){var e=Array.prototype.slice.call(arguments).map(function(e){return e!=null&&e.constructor===String?e:r.inspect(e)}).join(` `);if(!n.enabled||!e)return e;for(var t=e.indexOf(`
|
|
361
|
+
`)!=-1,a=this._styles,s=a.length;s--;){var c=i[a[s]];e=c.open+e.replace(c.closeRe,c.open)+c.close,t&&(e=e.replace(o,function(e){return c.close+e+c.open}))}return e}n.setTheme=function(e){if(typeof e==`string`){console.log(`colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));`);return}for(var t in e)(function(t){n[t]=function(r){if(typeof e[t]==`object`){var i=r;for(var a in e[t])i=n[e[t][a]](i);return i}return n[e[t]](r)}})(t)};function p(){var e={};return Object.keys(u).forEach(function(t){e[t]={get:function(){return l([t])}}}),e}var m=function(e,t){var n=t.split(``);return n=n.map(e),n.join(``)};for(var h in n.trap=cy(),n.zalgo=ly(),n.maps={},n.maps.america=uy()(n),n.maps.zebra=dy()(n),n.maps.rainbow=fy()(n),n.maps.random=py()(n),n.maps)(function(e){n[e]=function(t){return m(n.maps[e],t)}})(h);a(n,p())})),hy=E(((e,t)=>{t.exports=my()})),gy=E(((e,t)=>{let{info:n,debug:r}=Qv(),i=iy();var a=class e{constructor(e){this.setOptions(e),this.x=null,this.y=null}setOptions(e){[`boolean`,`number`,`bigint`,`string`].indexOf(typeof e)!==-1&&(e={content:``+e}),e||={},this.options=e;let t=e.content;if([`boolean`,`number`,`bigint`,`string`].indexOf(typeof t)!==-1)this.content=String(t);else if(!t)this.content=this.options.href||``;else throw Error(`Content needs to be a primitive, got: `+typeof t);this.colSpan=e.colSpan||1,this.rowSpan=e.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(e,t){this.cells=t;let n=this.options.chars||{},r=e.chars,a=this.chars={};f.forEach(function(e){l(n,r,e,a)}),this.truncate=this.options.truncate||e.truncate;let o=this.options.style=this.options.style||{},s=e.style;l(o,s,`padding-left`,this),l(o,s,`padding-right`,this),this.head=o.head||s.head,this.border=o.border||s.border,this.fixedWidth=e.colWidths[this.x],this.lines=this.computeLines(e),this.desiredWidth=i.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(e){let t=e.wordWrap||e.textWrap,{wordWrap:n=t}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let t=1;for(;t<this.colSpan;)this.fixedWidth+=e.colWidths[this.x+t],t++}let{wrapOnWordBoundary:t=!0}=e,{wrapOnWordBoundary:n=t}=this.options;return this.wrapLines(i.wordWrap(this.fixedWidth,this.content,n))}return this.wrapLines(this.content.split(`
|
|
362
|
+
`))}wrapLines(e){let t=i.colorizeLines(e);return this.href?t.map(e=>i.hyperlink(this.href,e)):t}init(e){let t=this.x,n=this.y;this.widths=e.colWidths.slice(t,t+this.colSpan),this.heights=e.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(d,-1),this.height=this.heights.reduce(d,-1),this.hAlign=this.options.hAlign||e.colAligns[t],this.vAlign=this.options.vAlign||e.rowAligns[n],this.drawRight=t+this.colSpan==e.colWidths.length}draw(e,t){if(e==`top`)return this.drawTop(this.drawRight);if(e==`bottom`)return this.drawBottom(this.drawRight);let r=i.truncate(this.content,10,this.truncate);e||n(`${this.y}-${this.x}: ${this.rowSpan-e}x${this.colSpan} Cell ${r}`);let a=Math.max(this.height-this.lines.length,0),o;switch(this.vAlign){case`center`:o=Math.ceil(a/2);break;case`bottom`:o=a;break;default:o=0}if(e<o||e>=o+this.lines.length)return this.drawEmpty(this.drawRight,t);let s=this.lines.length>this.height&&e+1>=this.height;return this.drawLine(e-o,this.drawRight,s,t)}drawTop(e){let t=[];return this.cells?this.widths.forEach(function(e,n){t.push(this._topLeftChar(n)),t.push(i.repeat(this.chars[this.y==0?`top`:`mid`],e))},this):(t.push(this._topLeftChar(0)),t.push(i.repeat(this.chars[this.y==0?`top`:`mid`],this.width))),e&&t.push(this.chars[this.y==0?`topRight`:`rightMid`]),this.wrapWithStyleColors(`border`,t.join(``))}_topLeftChar(t){let n=this.x+t,r;if(this.y==0)r=n==0?`topLeft`:t==0?`topMid`:`top`;else if(n==0)r=`leftMid`;else if(r=t==0?`midMid`:`bottomMid`,this.cells&&(this.cells[this.y-1][n]instanceof e.ColSpanCell&&(r=t==0?`topMid`:`mid`),t==0)){let t=1;for(;this.cells[this.y][n-t]instanceof e.ColSpanCell;)t++;this.cells[this.y][n-t]instanceof e.RowSpanCell&&(r=`leftMid`)}return this.chars[r]}wrapWithStyleColors(e,t){if(this[e]&&this[e].length)try{let n=hy();for(let t=this[e].length-1;t>=0;t--)n=n[this[e][t]];return n(t)}catch{return t}return t}drawLine(e,t,n,r){let a=this.chars[this.x==0?`left`:`middle`];if(this.x&&r&&this.cells){let e=this.cells[this.y+r][this.x-1];for(;e instanceof o;)e=this.cells[e.y][e.x-1];e instanceof s||(a=this.chars.rightMid)}let c=i.repeat(` `,this.paddingLeft),l=t?this.chars.right:``,u=i.repeat(` `,this.paddingRight),d=this.lines[e],f=this.width-(this.paddingLeft+this.paddingRight);n&&(d+=this.truncate||`…`);let p=i.truncate(d,f,this.truncate);return p=i.pad(p,f,` `,this.hAlign),p=c+p+u,this.stylizeLine(a,p,l)}stylizeLine(e,t,n){return e=this.wrapWithStyleColors(`border`,e),n=this.wrapWithStyleColors(`border`,n),this.y===0&&(t=this.wrapWithStyleColors(`head`,t)),e+t+n}drawBottom(e){let t=this.chars[this.x==0?`bottomLeft`:`bottomMid`],n=i.repeat(this.chars.bottom,this.width),r=e?this.chars.bottomRight:``;return this.wrapWithStyleColors(`border`,t+n+r)}drawEmpty(e,t){let n=this.chars[this.x==0?`left`:`middle`];if(this.x&&t&&this.cells){let e=this.cells[this.y+t][this.x-1];for(;e instanceof o;)e=this.cells[e.y][e.x-1];e instanceof s||(n=this.chars.rightMid)}let r=e?this.chars.right:``,a=i.repeat(` `,this.width);return this.stylizeLine(n,a,r)}},o=class{constructor(){}draw(e){return typeof e==`number`&&r(`${this.y}-${this.x}: 1x1 ColSpanCell`),``}init(){}mergeTableOptions(){}},s=class{constructor(e){this.originalCell=e}init(e){let t=this.y,n=this.originalCell.y;this.cellOffset=t-n,this.offset=u(e.rowHeights,n,this.cellOffset)}draw(e){return e==`top`?this.originalCell.draw(this.offset,this.cellOffset):e==`bottom`?this.originalCell.draw(`bottom`):(r(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+e))}mergeTableOptions(){}};function c(...e){return e.filter(e=>e!=null).shift()}function l(e,t,n,r){let i=n.split(`-`);i.length>1?(i[1]=i[1].charAt(0).toUpperCase()+i[1].substr(1),i=i.join(``),r[i]=c(e[i],e[n],t[i],t[n])):r[n]=c(e[n],t[n])}function u(e,t,n){let r=e[t];for(let i=1;i<n;i++)r+=1+e[t+i];return r}function d(e,t){return e+t+1}let f=[`top`,`top-mid`,`top-left`,`top-right`,`bottom`,`bottom-mid`,`bottom-left`,`bottom-right`,`left`,`left-mid`,`mid`,`mid-mid`,`right`,`right-mid`,`middle`];t.exports=a,t.exports.ColSpanCell=o,t.exports.RowSpanCell=s})),_y=E(((e,t)=>{let{warn:n,debug:r}=Qv(),i=gy(),{ColSpanCell:a,RowSpanCell:o}=i;(function(){function e(t,n){return t[n]>0?e(t,n+1):n}function c(t){let n={};t.forEach(function(t,r){let i=0;t.forEach(function(t){t.y=r,t.x=r?e(n,i):i;let a=t.rowSpan||1,o=t.colSpan||1;if(a>1)for(let e=0;e<o;e++)n[t.x+e]=a;i=t.x+o}),Object.keys(n).forEach(e=>{n[e]--,n[e]<1&&delete n[e]})})}function l(e){let t=0;return e.forEach(function(e){e.forEach(function(e){t=Math.max(t,e.x+(e.colSpan||1))})}),t}function u(e){return e.length}function d(e,t){let n=e.y,r=e.y-1+(e.rowSpan||1),i=t.y,a=!(n>t.y-1+(t.rowSpan||1)||i>r),o=e.x,s=e.x-1+(e.colSpan||1),c=t.x,l=!(o>t.x-1+(t.colSpan||1)||c>s);return a&&l}function f(e,t,n){let r=Math.min(e.length-1,n),i={x:t,y:n};for(let t=0;t<=r;t++){let n=e[t];for(let e=0;e<n.length;e++)if(d(i,n[e]))return!0}return!1}function p(e,t,n,r){for(let i=n;i<r;i++)if(f(e,i,t))return!1;return!0}function m(e){e.forEach(function(t,n){t.forEach(function(t){for(let r=1;r<t.rowSpan;r++){let i=new o(t);i.x=t.x,i.y=t.y+r,i.colSpan=t.colSpan,g(i,e[n+r])}})})}function h(e){for(let t=e.length-1;t>=0;t--){let n=e[t];for(let e=0;e<n.length;e++){let t=n[e];for(let r=1;r<t.colSpan;r++){let i=new a;i.x=t.x+r,i.y=t.y,n.splice(e+1,0,i)}}}}function g(e,t){let n=0;for(;n<t.length&&t[n].x<e.x;)n++;t.splice(n,0,e)}function _(e){let t=u(e),a=l(e);r(`Max rows: ${t}; Max cols: ${a}`);for(let r=0;r<t;r++)for(let o=0;o<a;o++)if(!f(e,o,r)){let s={x:o,y:r,colSpan:1,rowSpan:1};for(o++;o<a&&!f(e,o,r);)s.colSpan++,o++;let c=r+1;for(;c<t&&p(e,c,s.x,s.x+s.colSpan);)s.rowSpan++,c++;let l=new i(s);l.x=s.x,l.y=s.y,n(`Missing cell at ${l.y}-${l.x}.`),g(l,e[r])}}function v(e){return e.map(function(e){if(!Array.isArray(e)){let t=Object.keys(e)[0];e=e[t],Array.isArray(e)?(e=e.slice(),e.unshift(t)):e=[t,e]}return e.map(function(e){return new i(e)})})}function y(e){let t=v(e);return c(t),_(t),m(t),h(t),t}t.exports={makeTableLayout:y,layoutTable:c,addRowSpanCells:m,maxWidth:l,fillInTable:_,computeWidths:s(`colSpan`,`desiredWidth`,`x`,1),computeHeights:s(`rowSpan`,`desiredHeight`,`y`,1)}})();function s(e,t,n,r){return function(i,a){let o=[],s=[],c={};a.forEach(function(i){i.forEach(function(i){(i[e]||1)>1?s.push(i):o[i[n]]=Math.max(o[i[n]]||0,i[t]||0,r)})}),i.forEach(function(e,t){typeof e==`number`&&(o[t]=e)});for(let r=s.length-1;r>=0;r--){let a=s[r],l=a[e],u=a[n],d=o[u],f=typeof i[u]==`number`?0:1;if(typeof d==`number`)for(let e=1;e<l;e++)d+=1+o[u+e],typeof i[u+e]!=`number`&&f++;else d=t===`desiredWidth`?a.desiredWidth-1:1,(!c[u]||c[u]<d)&&(c[u]=d);if(a[t]>d){let e=0;for(;f>0&&a[t]>d;){if(typeof i[u+e]!=`number`){let n=Math.round((a[t]-d)/f);d+=n,o[u+e]+=n,f--}e++}}}Object.assign(i,o,c);for(let e=0;e<i.length;e++)i[e]=Math.max(r,i[e]||0)}}})),vy=E(((e,t)=>{let n=Qv(),r=iy(),i=_y();var a=class extends Array{constructor(e){super();let t=r.mergeOptions(e);if(Object.defineProperty(this,"options",{value:t,enumerable:t.debug}),t.debug){switch(typeof t.debug){case`boolean`:n.setDebugLevel(n.WARN);break;case`number`:n.setDebugLevel(t.debug);break;case`string`:n.setDebugLevel(parseInt(t.debug,10));break;default:n.setDebugLevel(n.WARN),n.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof t.debug}`)}Object.defineProperty(this,"messages",{get(){return n.debugMessages()}})}}toString(){let e=this,t=this.options.head&&this.options.head.length;t?(e=[this.options.head],this.length&&e.push.apply(e,this)):this.options.style.head=[];let n=i.makeTableLayout(e);n.forEach(function(e){e.forEach(function(e){e.mergeTableOptions(this.options,n)},this)},this),i.computeWidths(this.options.colWidths,n),i.computeHeights(this.options.rowHeights,n),n.forEach(function(e){e.forEach(function(e){e.init(this.options)},this)},this);let r=[];for(let e=0;e<n.length;e++){let i=n[e],a=this.options.rowHeights[e];(e===0||!this.options.style.compact||e==1&&t)&&o(i,`top`,r);for(let e=0;e<a;e++)o(i,e,r);e+1==n.length&&o(i,`bottom`,r)}return r.join(`
|
|
363
|
+
`)}get width(){return this.toString().split(`
|
|
364
|
+
`)[0].length}};a.reset=()=>n.reset();function o(e,t,n){let r=[];e.forEach(function(e){r.push(e.draw(t))});let i=r.join(``);i.length&&n.push(i)}t.exports=a})),yy=Ve(E(((e,t)=>{t.exports=vy()}))(),1);const by=new class{step(e){console.log(`\n${$.bold.cyan(`${H.pointer} ${e}`)}`)}ok(e){console.log(` ${$.green(H.tick)} ${e}`)}warn(e){console.log(` ${$.yellow(H.warning)} ${e}`)}info(e){console.log(` ${e}`)}err(e){console.error(` ${$.red(H.cross)} ${e}`)}header(e){let t=`═`.repeat(47);console.log(`\n${$.bold(t)}`),console.log(`${$.bold(` ${e}`)}`),console.log(`${$.bold(t)}\n`)}table(e,t){let n=new yy.default({chars:{mid:``,"left-mid":``,"mid-mid":``,"right-mid":``},style:{border:[`grey`],head:[]},colWidths:t?.colWidths??[4,40,30]});for(let[t,r,i=``]of e){let e=r===`ok`?$.green(H.tick):r===`warn`?$.yellow(H.warning):$.red(H.cross),a=r===`ok`?$.grey(i):r===`warn`?$.yellow(i):$.red(i);n.push([e,t,a])}console.log(n.toString())}section(e,t){console.log(`\n${$.bold(e)}`),this.table(t)}print(e){console.log(e)}break(){console.log()}};function xy(e,t){return Qn?new K(`powershell`).tryGet(`-Command`,`[System.Environment]::GetEnvironmentVariable('${e}', 'User')`)??t:process.env[e]??t}const Sy=new class{async fetch(e,t){let n={accept:`application/json`,...t?.headers},r=await fetch(e,{...t,headers:n});if(!r.ok)throw Error(`Unable to fetch ${e}: ${r.status} ${r.statusText}`);if(t?.onProgress){let e=r.body?.getReader();if(!e)return r.json();let n=new TextDecoder,i=``;for(;;){let{done:r,value:a}=await e.read();if(r)break;i+=n.decode(a,{stream:!0}),t.onProgress(i)}return i+n.decode()}return r}async get(e,t){return(await this.fetch(e,t)).json()}},Cy=new class{constructor(e=xy(`LITELLM_BASE_URL`,``),t=xy(`LITELLM_API_KEY`,``)){this.baseUrl=e,this.apiKey=t}getModels(e){let t=e?.apiKey??this.apiKey;return Sy.get(`${this.baseUrl}/models`,{headers:{Accept:`application/json`,...t?{Authorization:`Bearer ${t}`}:{}}})}};function wy(e){return(e.startsWith(`gmdt-`)||e.startsWith(`eus2-`))&&!e.includes(`text-embedding`)}function Ty(){if(!L.default.pathExistsSync(R)){by.warn(`config.toml not found (~/.codex/config.toml). Run "cm-agents install" first.`);return}let e=L.default.readFileSync(R,`utf8`),t=e.match(/^model\s*=\s*"([^"]+)"/m),n=e.match(/^model_catalog_json\s*=\s*"([^"]+)"/m);by.header(`Codex — current configuration`);let r=new yy.default({style:{border:[`grey`],head:[]}});if(r.push([$.dim(`Model`),t?.[1]??$.red(`not set`)],[$.dim(`Catalog`),n?.[1]??$.red(`not set`)]),by.print(r.toString()),!L.default.pathExistsSync(rr))return;let i=JSON.parse(L.default.readFileSync(rr,`utf8`));by.step(`Available models (${i.data.length})`);let a=new yy.default({head:[$.bold(`Model`),$.bold(`Context in`),$.bold(`Context out`)],style:{border:[`grey`],head:[]},colWidths:[36,13,13]});for(let e of i.data)a.push([e.id,e.max_input_tokens?`${(e.max_input_tokens/1e3).toFixed(0)}k`:`—`,e.max_output_tokens?`${(e.max_output_tokens/1e3).toFixed(0)}k`:`—`]);by.print(a.toString())}var Ey=e=>void e.command(`models`).description(`Show Codex config or refresh the LiteLLM model list`).option(`--refresh`,`Refresh clubmed-models.json from the LiteLLM API`).action(async e=>{if(!e.refresh){Ty();return}by.info(`Fetching models from LiteLLM...`);try{let{data:e}=await Cy.getModels(),t=e.filter(e=>wy(e.id)),n={object:`list`,data:t.map(({id:e,object:t,owned_by:n})=>({id:e,object:t,owned_by:n??`clubmed`}))};L.default.writeFileSync(rr,JSON.stringify(n,null,2),`utf8`),by.ok(`${t.length} models written to ${rr}`);let r=new yy.default({head:[$.bold(`Model`),$.bold(`In`),$.bold(`Out`)],style:{border:[`grey`],head:[]},colWidths:[36,10,10]});for(let e of t)r.push([e.id,e.max_input_tokens?`${(e.max_input_tokens/1e3).toFixed(0)}k`:`—`,e.max_output_tokens?`${(e.max_output_tokens/1e3).toFixed(0)}k`:`—`]);by.print(r.toString())}catch(e){by.err(e instanceof Error?e.message:String(e)),process.exit(1)}});const Dy=new class extends K{constructor(){super(`git`)}init(...e){return this.run(`init`,...e)}add(...e){return this.run(`add`,...e)}status(...e){return this.sync(`status`,...e)}branch(...e){return this.run(`branch`,...e)}clean(...e){return this.run(`clean`,...e)}config(...e){return this.run(`config`,...e).get()}checkout(...e){return this.run(`checkout`,...e)}commit(...e){return this.run(`commit`,...e)}fetch(...e){return this.run(`fetch`,...e)}prune(...e){return this.run(`prune`,...e)}merge(...e){return this.sync(`merge`,...e)}reset(...e){return this.sync(`reset`,...e)}remote(...e){return this.run(`remote`,...e)}rebase(...e){return this.run(`rebase`,...e)}getCommitTag(e=`HEAD`){return this.get(`rev-parse`,`--short`,e)}getBranchName(e=`HEAD`){return this.get(`rev-parse`,`--abbrev-ref`,e)}getLastCommitMsg(){return this.get(`log`,`-1`,`--pretty=%B`)}push(...e){return this.run(`push`,...e)}clone(...e){return this.run(`clone`,...e)}branchExists(e,t=`origin`){return this.run(`branch`,`-a`).getRaw().trim().includes(`remotes/${t}/${e}`)}checkBranchRemoteStatus(e,t=`origin`){return this.run(`cherry`,e,`${t}/${e}`).get()}branches(...e){return this.run(`branch`,...e).get().split(`
|
|
365
|
+
`).map(e=>e.trim().replace(`* `,``)).filter(e=>!!e).filter(e=>!String(e).includes(`/HEAD`))}show(e){return this.run(`show`,`--format="%ci|%cr|%an"`,e,`--`).getRaw().split(`
|
|
366
|
+
`)[0].trim()}},Oy=new class extends K{constructor(){super(`npm`)}newVersion(e){return this.version(`--no-git-tag-version`,e)}version(...e){return this.sync(`version`,...e)}run(...e){return super.run(`run`,...e)}install(...e){return super.run(`install`,...e)}publish(...e){return super.run(`publish`,...e)}pack(...e){return super.run(`pack`,...e)}restore(){return super.run(`ci`)}};function ky(){let e=process.env.SHELL??``;return e.includes(`zsh`)?p(process.env.HOME??`~`,`.zshrc`):e.includes(`bash`)?p(process.env.HOME??`~`,`.bashrc`):null}function Ay(e,t){x_(`powershell`,[`-Command`,`[System.Environment]::SetEnvironmentVariable('${e}', '${t}', 'User')`]),process.env[e]=t}const jy=new class{load(){if(Qn)return;let e=ky();if(!e||!L.default.pathExistsSync(e))return;let t=!1;for(let n of L.default.readFileSync(e,`utf8`).split(`
|
|
367
|
+
`)){if(n.includes(`# --- Club Med AI Tools ---`)){t=!0;continue}if(!t)continue;let e=n.match(/^export\s+([A-Z_]+)="(.*)"$/);e&&!process.env[e[1]]&&(process.env[e[1]]=e[2])}}save(e){if(Qn){for(let[t,n]of Object.entries(e))Ay(t,n);return{platform:`windows`}}let t=ky();if(!t)return{platform:`unknown`};if(L.default.readFileSync(t,`utf8`).includes(`# --- Club Med AI Tools ---`))return{platform:`unix`,rc:t,written:!1};let n=[`
|
|
368
|
+
# --- Club Med AI Tools ---`,...Object.entries(e).map(([e,t])=>`export ${e}="${t}"`)];return L.default.appendFileSync(t,n.join(`
|
|
369
|
+
`)+`
|
|
370
|
+
`,`utf8`),{platform:`unix`,rc:t,written:!0}}},My=new K(`mise`);function Ny(){Dy.available()||(N.error(`git not found. Install Git from https://git-scm.com/downloads and re-run.`),process.exit(1)),N.success(`git ${Dy.get(`--version`).replace(`git version `,``)}`)}async function Py(){jy.load();let e=()=>{dn(`Setup cancelled.`),process.exit(0)},t=!!My.tryGet(`ls`,`--current`)?.includes(`python`);return await un({installDir:()=>process.env.CLUBMED_REPO_DIR?(N.info(`Repository directory: ${process.env.CLUBMED_REPO_DIR} (saved)`),Promise.resolve(process.env.CLUBMED_REPO_DIR)):bn({message:`Repository install directory`,placeholder:er,defaultValue:er}),installPython:()=>t?(N.info(`Python 3.12 already installed via mise.`),Promise.resolve(!0)):ln({message:`Install Python (optional)?`,initialValue:!1}),litellmKey:()=>process.env.LITELLM_API_KEY?(N.info(`LITELLM_API_KEY already set, reusing.`),Promise.resolve(process.env.LITELLM_API_KEY)):_n({message:`LITELLM_API_KEY (LiteLLM portal — VPN required)`}),anthropicKey:({results:e})=>process.env.ANTHROPIC_API_KEY?(N.info(`ANTHROPIC_API_KEY already set, reusing.`),Promise.resolve(process.env.ANTHROPIC_API_KEY)):e.litellmKey?(N.info(`ANTHROPIC_API_KEY ← LITELLM_API_KEY`),Promise.resolve(e.litellmKey)):_n({message:`ANTHROPIC_API_KEY (same LiteLLM portal)`}),clubmedApiKey:()=>process.env.CLUBMED_API_MCP_KEY?(N.info(`CLUBMED_API_MCP_KEY already set (${process.env.CLUBMED_API_MCP_KEY}), reusing.`),Promise.resolve(process.env.CLUBMED_API_MCP_KEY)):bn({message:`CLUBMED_API_MCP_KEY`,placeholder:ar,defaultValue:ar}),cmsToken:()=>process.env.CMS_API_MCP_TOKEN?(N.info(`CMS_API_MCP_TOKEN already set, reusing.`),Promise.resolve(process.env.CMS_API_MCP_TOKEN)):_n({message:`CMS_API_MCP_TOKEN (Directus — press Enter to skip)`})},{onCancel:e})}async function Fy(e){if(L.default.pathExistsSync(p(e,`.git`))){N.success(`Repository already present in ${e}`);let t=yn();t.start(`Updating from origin/main...`);try{await Dy.fetch(`origin`).cwd(e),await Dy.rebase(`origin/main`).cwd(e),t.stop(`Repository up to date`)}catch{t.stop(`Rebase failed — check the repository manually.`),N.warn(`Run: git -C `+e+` rebase --abort`)}}else{L.default.ensureDirSync(p(e,`..`));let t=yn();t.start(`Cloning repository...`),await Dy.clone(`https://github.com/ClubMediterranee/digital-api-team-skills.git`,e),t.stop(`Repository cloned to ${e}`)}}function Iy(e){let t=jy.save(e);t.platform===`windows`?(N.success(`Environment variables set (user scope)`),N.info(`→ Close and reopen any terminal or app for them to take effect.`)):t.platform===`unix`?t.written?(N.success(`Environment variables written to ${t.rc}`),N.info(`→ source ${t.rc} or restart the terminal.`)):N.success(`Env block already present in ${t.rc}`):N.warn(`Unknown shell — add env vars manually.`)}async function Ly(e){let t=yn();if(!av.available()||e?(t.start(`Installing Codex CLI...`),await Oy.install(`-g`,`@openai/codex`),t.stop(`Codex CLI installed`)):N.success(`Codex CLI already present`),!L.default.pathExistsSync(rr)||e){let e=p(import.meta.dirname,`..`,`..`,`scripts`,`clubmed-models.json`);L.default.pathExistsSync(e)&&(L.default.ensureDirSync(nr),L.default.copyFileSync(e,rr)),N.success(`~/.codex/clubmed-models.json written`)}else N.success(`~/.codex/clubmed-models.json already present`);if(!av.getConfig()||e){let t={model:ir.codex,model_provider:`litellm`,model_catalog_json:rr.replace(/\\/g,`/`),openai_base_url:tr,model_reasoning_effort:`medium`,personality:`pragmatic`,mcp_oauth_credentials_store:`file`,model_providers:{litellm:{name:`LiteLLM`,base_url:tr,env_key:`LITELLM_API_KEY`,wire_api:`responses`}}};av.writeBaseConfig(t,e)&&N.info(`Backup → ${R}.bak`),N.success(`~/.codex/config.toml written`)}av.removeMcp(`jira`)&&N.info(`Migration: [mcp_servers.jira] removed`);for(let[t,n]of Object.entries(or))N.success(av.addMcp(t,n,e)?`Codex MCP ${t} added`:`Codex MCP ${t} already present`)}async function Ry(e){let t=yn();!E_.available()||e?(t.start(`Installing Claude CLI...`),await Oy.install(`-g`,`@anthropic-ai/claude-code`),t.stop(`Claude CLI installed`)):N.success(`Claude CLI already present`),E_.removeMcp(`jira`),E_.removeMcp(`atlassian`);for(let[t,n]of Object.entries(sr))N.success(E_.addMcp(t,n,`user`,e)?`Claude MCP ${t} added`:`Claude MCP ${t} already present`);for(let n of cr){let r=n.split(`@`)[0];if(!E_.hasMcp(`plugin:${r}`)||e){t.start(`Installing Claude marketplace plugin ${r}...`);try{await E_.addMarketplace(n),t.stop(`Claude marketplace plugin ${r} installed`)}catch{t.stop(`Could not install ${r} automatically`),N.warn(`Install manually: claude plugin install ${n}`)}}else N.success(`Claude marketplace plugin ${r} already installed`)}try{E_.setDefaultModel(ir.sonnet),N.success(`Claude default model: ${ir.sonnet}`)}catch{N.warn(`Set model manually: claude config set --global model ${ir.sonnet}`)}}async function zy(e,t){if(!e){N.info(`Python skipped.`);return}let n=yn();!My.tryGet(`ls`,`python`)?.includes(`3.12`)||t?(n.start(`Installing Python 3.12 via mise...`),await My.run(`use`,`-g`,`python@3.12`),n.stop(`Python 3.12 installed`)):N.success(`Python 3.12 already installed`)}var By=e=>void e.command(`install`).description(`Install and configure AI tools (Codex, Claude, MCPs…)`).option(`--reinstall`,`Force reinstall of every tool`).action(async e=>{let t=!!e.reinstall;fn(`Club Med — AI Tools Setup (${Qn?`Windows`:`macOS/Linux`})`),t&&N.warn(`--reinstall mode: all tools will be reinstalled.`),N.step(`1 — Git`),Ny(),N.step(`2 — Configuration`);let{installDir:n,installPython:r,litellmKey:i,anthropicKey:a,clubmedApiKey:o,cmsToken:s}=await Py();N.step(`3 — Repository`),await Fy(n),N.step(`4 — Environment Variables`),Iy({LITELLM_API_KEY:i,ANTHROPIC_BASE_URL:`https://apim-prdaiplatform-frc.azure-api.net/litellm-api/`,ANTHROPIC_API_KEY:a,CLUBMED_API_MCP_KEY:o,ANTHROPIC_DEFAULT_FABLE_MODEL:ir.fable,ANTHROPIC_DEFAULT_OPUS_MODEL:ir.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:ir.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:ir.haiku,CLUBMED_REPO_DIR:n,...s?{CMS_API_MCP_TOKEN:s}:{}}),N.step(`5 — Codex CLI + configuration`),await Ly(t),N.step(`6 — Claude CLI + MCPs`),await Ry(t),N.step(`7 — Python`),await zy(r,t),gn([`1. Restart the terminal to load env vars.`,`2. Authenticate Atlassian for Codex:`,` codex mcp login atlassian`,`3. Install the ChatGPT app (Codex UI):`,` https://chatgpt.com/download`,`4. Install Claude Desktop:`,` https://claude.ai/download`,``,`Repository: ${n}`].join(`
|
|
371
|
+
`),`Manual steps remaining`),pn(`Setup complete!`)});const Vy=new $e;Vy.name(`cm-agents`).description(`Club Med — AI tools setup and configuration`).version(`3.4.0-alpha.1`),By(Vy),vv(Vy),Ey(Vy.command(`codex`).description(`Codex-related commands`)),await Vy.parseAsync(process.argv);export{};
|
|
372
|
+
//# sourceMappingURL=cm-agents.mjs.map
|