skilless 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/dist/bin.mjs +115 -0
  4. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aidan Bleser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # skilless
2
+
3
+ Author skills once, sync them everywhere, install them per project.
4
+
5
+ ```bash
6
+ npm install -g skilless
7
+ ```
8
+
9
+ ```bash
10
+ skilless init # create ~/.skilless and sign in
11
+ skilless create code-review # new skill, added here, path printed to edit
12
+ skilless add svelte-testing # add one you already have to this project
13
+ skilless sync # two way, including deletions
14
+ ```
15
+
16
+ In a cloud agent's setup step:
17
+
18
+ ```bash
19
+ SKILLESS_TOKEN=... npx skilless install
20
+ ```
21
+
22
+ Documentation: [github.com/ieedan/skilless](https://github.com/ieedan/skilless)
package/dist/bin.mjs ADDED
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as e}from"node:module";import{execFileSync as t,spawn as n}from"node:child_process";import r from"node:fs";import i from"node:os";import a from"node:crypto";import o from"node:http";var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:s(d(e)),m(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)),g=e(import.meta.url),_=p((e=>{var t=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}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),v=p((e=>{let{InvalidArgumentError:t}=_();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.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,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ee=p((e=>{let{humanReadableArgName:t}=v();var n=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 n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}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(`
3
+ `)}displayWidth(e){return r(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,`
4
+ `+` `.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(`
5
+ `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),te=p((e=>{let{InvalidArgumentError:t}=_();var n=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=a(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,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(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}},r=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?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(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}
6
+ - a short flag is a single dash and a single character
7
+ - either use a single dash and a single character (for a short flag)
8
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(t)?Error(`${n}
9
+ - too many short flags`):i.test(t)?Error(`${n}
10
+ - too many long flags`):Error(`${n}
11
+ - 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}}e.Option=n,e.DualOptions=r})),ne=p((e=>{function t(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=1;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 n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),re=p((e=>{let t=g(`node:events`).EventEmitter,n=g(`node:child_process`),r=g(`node:path`),i=g(`node:fs`),a=g(`node:process`),{Argument:o,humanReadableArgName:s}=v(),{CommanderError:c}=_(),{Help:l,stripColor:u}=ee(),{Option:d,DualOptions:f}=te(),{suggestSimilar:p}=ne();var m=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=>a.stdout.write(e),writeErr:e=>a.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>a.stdout.isTTY?a.stdout.columns:void 0,getErrHelpWidth:()=>a.stderr.isTTY?a.stderr.columns:void 0,getOutHasColors:()=>re()??(a.stdout.isTTY&&a.stdout.hasColors?.()),getErrHasColors:()=>re()??(a.stderr.isTTY&&a.stderr.hasColors?.()),stripColor:e=>u(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 l,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
12
+ - 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 o(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}'.
13
+ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new c(e,t,n)),a.exit(e)}action(e){return this._actionHandler=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)},this}createOption(e,t){return new d(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}'
14
+ - 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();if(e.negate){let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,`default`)}else 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=>{r(t,`error: option '${e.flags}' argument '${t}' is invalid.`,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{r(t,`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof d)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){a.versions?.electron&&(t.from=`electron`);let e=a.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=a.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`:a.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.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.
15
+ - 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(i.existsSync(e))return;let r=`'${e}' does not exist
16
+ - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
17
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
18
+ - ${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 o=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function l(e,t){let n=r.resolve(e,t);if(i.existsSync(n))return n;if(s.includes(r.extname(t)))return;let a=s.find(e=>i.existsSync(`${n}${e}`));if(a)return`${n}${a}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=i.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=r.resolve(r.dirname(e),d)}if(d){let t=l(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=r.basename(this._scriptPath,r.extname(this._scriptPath));n!==this._name&&(t=l(d,`${n}-${e._name}`))}u=t||u}o=s.includes(r.extname(u));let f;a.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.execPath,t,{stdio:`inherit`})):o?(t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.argv[0],t,{stdio:`inherit`})):f=n.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{a.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new c(e,`commander.executeSubCommandAsync`,`(close)`)):a.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)a.exit(1);else{let e=new c(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_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?!1: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}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else 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(`
19
+ `),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 a.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()}`,a.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new f(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=p(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=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{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=p(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=>s(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=r.basename(e,r.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(a.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.
20
+ 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 h(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 re(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=re}));const{program:ie,createCommand:ae,createArgument:oe,createOption:y,CommanderError:se,InvalidArgumentError:ce,InvalidOptionArgumentError:le,Command:b,Argument:ue,Option:de,Help:fe}=h(p((e=>{let{Argument:t}=v(),{Command:n}=re(),{CommanderError:r,InvalidArgumentError:i}=_(),{Help:a}=ee(),{Option:o}=te();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;function pe(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function me(e,t=`|`){return e.map(e=>Fe(e)).join(t)}function he(e,t){return typeof t==`bigint`?t.toString():t}var ge=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function x(e){return new ge(e)}function _e(e){return e==null}function ve(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ye(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function be(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xe(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function S(e){return xe(e._zod.def)??e._zod.def.shape}function Se(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return be(this,t,e),e},enumerable:!0,configurable:!0})}function Ce(e,t,n){t in e?be(e,t,n):e[t]=n}function we(e,t,n,r){let i=S(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Se(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ce(e,a,r?r(n.value,a):n.value))}}function Te(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Se(e,n,()=>t[n]):Ce(e,n,r.value))}}function C(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ee(e){return JSON.stringify(e)}function De(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Oe=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ke(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ae=x(()=>{if(k.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function je(e){if(ke(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ke(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Me(e){return je(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Ne=new Set([`string`,`number`,`symbol`]);function Pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function w(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function T(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Fe(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ie(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const Le={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Re={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ze(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return we(i,e,Be(e,t)),w(e,C(n,{shape:i,checks:[]}))}function Be(e,t){let n=S(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Ve(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Be(e,t)),a={};return we(a,e,Reflect.ownKeys(S(e)).filter(e=>!i.has(e))),w(e,C(n,{shape:a,checks:[]}))}function He(e,t){if(!je(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=S(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return w(e,C(e._zod.def,{shape:Ue(e,t)}))}function Ue(e,t){let n={};return we(n,e,Reflect.ownKeys(S(e))),Te(n,t),n}function We(e,t){if(!je(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return w(e,C(e._zod.def,{shape:Ue(e,t)}))}function Ge(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return we(n,e,Reflect.ownKeys(S(e))),we(n,t,Reflect.ownKeys(S(t))),w(e,C(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ke(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Be(t,n)):void 0,o={};return we(o,t,Reflect.ownKeys(S(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),w(t,C(t._zod.def,{shape:o,checks:[]}))}function qe(e,t,n){let r=n?new Set(Be(t,n)):void 0,i={};return we(i,t,Reflect.ownKeys(S(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),w(t,C(t._zod.def,{shape:i}))}function E(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Je(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ye(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Xe(e){return typeof e==`string`?e:e?.message}function Ze(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Qe(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Xe(e.inst?._zod.def?.error?.(e))??Xe(a?.(e))??Xe(t?.error?.(e))??Xe(n.customError?.(e))??Xe(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t===`inst`||t===`schema`||t===`continue`||t===`input`||t===`__proto__`||(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const $e=/[\uD800-\uDBFF]/;function et(e){let t=e.length;if(!$e.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function tt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function nt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function rt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function it(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ct(e,n,r.value)}}function at(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ot(e,t,n){return at(e,t,n,!1)}function st(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return at(this,n,r(this))},set(e){at(this,n,e)}})}return t}function ct(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:at(this,t,n.bind(this))},set(e){at(this,t,e)}})}function lt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let ut,dt=!1;const ft={configurable:!0,get(){dt=!0}};function D(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&ut!==e._zod){ut=void 0;return}ut=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ft);let e=dt;dt=!1;try{let r=n(this);return dt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),dt||=e,r}catch(n){throw delete this[t],dt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function pt(e,t,n,r){let i=lt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function mt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var ht;const gt={value:void 0,enumerable:!1};let _t=`captureStackTrace`in Error?Error:null;function vt(e){let t=_t;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return _t=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function O(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{gt.value=new a(r);try{Object.defineProperty(n,`_zod`,gt)}finally{gt.value=void 0}}if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),it(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,`name`,{value:e});function d(e){let t=r?.Parent?vt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,`init`,{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,`name`,{value:e}),d}var yt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},bt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ht=globalThis).__zod_globalConfig??(ht.__zod_globalConfig={});const k=globalThis.__zod_globalConfig;function xt(e){return e&&Object.assign(k,e),k}function St(){let e=this._zod;return e.message??=JSON.stringify(e.def,he,2),e.message}function Ct(e){this._zod.message=e}const wt={get:St,set:Ct,enumerable:!0,configurable:!0},Tt={value:void 0,enumerable:!1},Et=new WeakSet([Object.prototype,Error.prototype]),Dt=(e,t)=>{e.name=`$ZodError`,Tt.value=t,Object.defineProperty(e,`issues`,Tt),Tt.value=void 0,Object.defineProperty(e,`message`,wt);let n=Object.getPrototypeOf(e);Et.has(n)||(Et.add(n),Object.defineProperty(n,`toString`,{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0})}}))},Ot=O(`$ZodError`,Dt);O(`$ZodError`,Dt,void 0,{Parent:Error});function kt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function At(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?kt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function jt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Mt(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Nt=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new yt;if(s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>Qe(e,o,xt())));throw Oe(n,a?.callee??t),n}return s.value};return t},Pt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>Qe(e,o,xt())));throw Oe(n,a?.callee??t),n}return s.value};return t},Ft=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new yt;return a.issues.length?It(e,a.issues,i):{success:!0,data:a.value}};function It(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Qe(e,n,xt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Lt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?It(e,a.issues,i):{success:!0,data:a.value}},Rt=Symbol.for(`zod.compile.invalid`),zt=Symbol.for(`zod.compile.fallback`),Bt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Rt)return!0;if(r.definite===!0&&n===void 0)return!1}return Vt(e,t,n)});function Vt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[zt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new yt;return a.issues.length===0}const Ht=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Ut=e=>{let t=Nt(e),n=(e,r,i,a)=>t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},Mt(n,a));return n},Wt=e=>{let t=Nt(e),n=(e,r,i,a)=>t(e,r,i,Mt(n,a));return n},Gt=e=>{let t=Pt(e),n=async(e,r,i,a)=>await t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},Mt(n,a));return n},Kt=e=>{let t=Pt(e),n=async(e,r,i,a)=>await t(e,r,i,Mt(n,a));return n},qt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ft(e)(t,n,i)},Jt=e=>(t,n,r)=>Ft(e)(t,n,r),Yt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Lt(e)(t,n,i)},Xt=e=>async(t,n,r)=>Lt(e)(t,n,r),Zt=/^[cC][0-9a-z]{6,}$/,Qt=/^[0-9a-z]+$/,$t=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,en=/^[0-9a-vA-V]{20}$/,tn=/^[A-Za-z0-9]{27}$/,nn=/^[a-zA-Z0-9_-]{21}$/;function rn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const an=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,on=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,sn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,cn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function ln(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const un=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,dn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,fn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,pn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,gn=/^https?$/,_n=/^\+[1-9]\d{6,14}$/,vn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function yn(e){return RegExp(`^${e}$`)}const bn=yn(vn);function xn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Sn(e){return RegExp(`^${xn(e)}$`)}function Cn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${xn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${xn({precision:e.precision})}`:n;return RegExp(`^${vn}T(?:${r})$`)}const wn=/^[\s\S]{0,}$/,Tn=/^-?\d+(?:\.\d+)?$/,En=/^(?:true|false)$/i,Dn=/^[^A-Z]*$/,On=/^[^a-z]*$/,A=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),kn=e=>{let t=e.value;return!_e(t)&&t.length!==void 0},An={number:`number`,bigint:`bigint`,object:`date`},jn=O(`$ZodCheckLessThan`,(e,t)=>{A.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:An[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mn=O(`$ZodCheckGreaterThan`,(e,t)=>{A.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:An[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Nn=O(`$ZodCheckMultipleOf`,(e,t)=>{A.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):ye(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Pn=O(`$ZodCheckNumberFormat`,(e,t)=>{A.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Le[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Fn=O(`$ZodCheckMaxLength`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?et(r):i)<=t.maximum)return;let a=tt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),In=O(`$ZodCheckMinLength`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?et(r):i)>=t.minimum)return;let a=tt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ln=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?et(r):i;if(a===t.length)return;let o=tt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Rn=O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;A.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),zn=O(`$ZodCheckRegex`,(e,t)=>{Rn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Bn=O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Dn,Rn.init(e,t)}),Vn=O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=On,Rn.init(e,t)}),Hn=O(`$ZodCheckIncludes`,(e,t)=>{A.init(e,t);let n=Pe(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Un=O(`$ZodCheckStartsWith`,(e,t)=>{A.init(e,t);let n=RegExp(`^${Pe(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Wn=O(`$ZodCheckEndsWith`,(e,t)=>{A.init(e,t);let n=RegExp(`.*${Pe(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Gn=O(`$ZodCheckOverwrite`,(e,t)=>{A.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Kn=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
21
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
22
+ `)}\n};`)(...Object.values(this.closed))}};const qn={major:4,minor:6,patch:5},j=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qn;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=E(t),a;for(let o of n){if(o._zod.def.when){if(Je(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new yt;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ze(t.issues,n,e),i||=E(t,n))});else{if(t.issues.length===n)continue;Ze(t.issues,n,e),i||=E(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(E(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new yt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new yt;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return ot(this,`~standard`,Xn(this))},set"~standard"(e){at(this,`~standard`,e)}}),Jn=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Qe(e,t,xt()))}:{value:e.value};async function Yn(e,t){let n={async:!0};return Jn(await e._zod.run({value:t,issues:[]},n),n)}function Xn(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Jn(r,n)}catch{}return Yn(e,t)},vendor:`zod`,version:1}}const Zn=O(`$ZodString`,(e,t)=>{j.init(e,t),e._zod.pattern=t.pattern??wn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),M=O(`$ZodStringFormat`,(e,t)=>{Rn.init(e,t),Zn.init(e,t)}),Qn=O(`$ZodGUID`,(e,t)=>{t.pattern??=on,M.init(e,t)}),$n=O(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=sn(e)}else t.pattern??=sn();M.init(e,t)}),er=O(`$ZodEmail`,(e,t)=>{t.pattern??=cn,M.init(e,t)});function tr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function nr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?tr(e)||2:rr(e,t)}function rr(e,t){if(!t.normalize&&t.protocol?.source===gn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const ir=/[\t\n\r]/g;function ar(e){return e.replace(ir,``)}function or(e,t){return t.lastIndex=0,t.test(e.hostname)}function sr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const cr=O(`$ZodURL`,(e,t)=>{M.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=nr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=ar(r);return}t.hostname&&!or(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!sr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:ar(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),lr=O(`$ZodEmoji`,(e,t)=>{t.pattern??=ln(),M.init(e,t)}),ur=O(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?nn:rn(t.length),M.init(e,t)}),dr=O(`$ZodCUID`,(e,t)=>{t.pattern??=Zt,M.init(e,t)}),fr=O(`$ZodCUID2`,(e,t)=>{t.pattern??=Qt,M.init(e,t)}),pr=O(`$ZodULID`,(e,t)=>{t.pattern??=$t,M.init(e,t)}),mr=O(`$ZodXID`,(e,t)=>{t.pattern??=en,M.init(e,t)}),hr=O(`$ZodKSUID`,(e,t)=>{t.pattern??=tn,M.init(e,t)}),gr=O(`$ZodISODateTime`,(e,t)=>{t.pattern??=Cn(t),M.init(e,t)}),_r=O(`$ZodISODate`,(e,t)=>{t.pattern??=bn,M.init(e,t)}),vr=O(`$ZodISOTime`,(e,t)=>{t.pattern??=Sn(t),M.init(e,t)}),yr=O(`$ZodISODuration`,(e,t)=>{t.pattern??=an,M.init(e,t)}),br=O(`$ZodIPv4`,(e,t)=>{t.pattern??=un,M.init(e,t)}),xr=/^[0-9a-fA-F:.]+$/;function Sr(e){return xr.test(e)?tr(`http://[${e}]`):!1}const Cr=O(`$ZodIPv6`,(e,t)=>{t.pattern??=dn,M.init(e,t),e._zod.check=n=>{Sr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),wr=O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=fn,M.init(e,t)});function Tr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Sr(n)}const Er=O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=pn,M.init(e,t),e._zod.check=n=>{Tr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Dr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Or=/^[0-9a-zA-Z+/]*={0,2}$/,kr=O(`$ZodBase64`,(e,t)=>{t.pattern??=Or,M.init(e,t),e._zod.check=n=>{Dr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ar=/^[A-Za-z0-9_-]*$/;function jr(e){if(!Ar.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Dr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Mr=O(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ar,M.init(e,t),e._zod.check=n=>{jr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Nr=O(`$ZodE164`,(e,t)=>{t.pattern??=_n,M.init(e,t)});function Pr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Fr=O(`$ZodJWT`,(e,t)=>{M.init(e,t),e._zod.check=n=>{Pr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ir=O(`$ZodNumber`,(e,t)=>{j.init(e,t),e._zod.pattern=Tn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Lr=O(`$ZodNumberFormat`,(e,t)=>{Pn.init(e,t),Ir.init(e,t)}),Rr=O(`$ZodBoolean`,(e,t)=>{j.init(e,t),e._zod.pattern=En,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),zr=O(`$ZodUnknown`,(e,t)=>{j.init(e,t),e._zod.parse=e=>e}),Br=O(`$ZodNever`,(e,t)=>{j.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Vr(e,t,n){e.issues.length&&t.issues.push(...Ye(n,e.issues)),t.value[n]=e.value}const Hr=O(`$ZodArray`,(e,t)=>{j.init(e,t);let n=k.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Vr(t,r,e)));else if(Vr(c,r,e),s&&c.issues.length!==0&&E(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Ur(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Ye(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const Wr=[];function Gr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Wr,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Ie(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Kr(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(E(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ur(e,n,i,t,d,f))):Ur(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const qr=O(`$ZodObject`,(e,t)=>{j.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,`shape`,{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,`shape`,{get:e})}let i=x(()=>Gr(t));D(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||be(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=ke,o=t.catchall,s,c=k.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(E(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Ur(n,t,e,r,a,o))):Ur(s,t,e,r,a,o)}return o?Kr(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Jr=O(`$ZodObjectJIT`,(e,t)=>{qr.init(e,t);let n=e._zod.parse,r=x(()=>Gr(t)),i=k.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Kn([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
23
+ let ${e}_ab = false;
24
+ for (let i = 0; i < ${e}.issues.length; i++) {
25
+ const iss = ${e}.issues[i];
26
+ iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
27
+ payload.issues.push(iss);
28
+ if (iss.continue !== true) ${e}_ab = true;
29
+ }
30
+ if (${e}_ab && ctx && ctx.abortEarly) {
31
+ payload.value = newResult;
32
+ return payload;
33
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Ee(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
34
+ const ${n}_present = ${i};
35
+ if (!${n}.issues.length || ${n}_present) {
36
+ if (${n}.issues.length) {${c(n,r)}
37
+ }
38
+
39
+ if (${e}) {
40
+ newResult[${r}] = ${n}.value;
41
+ }
42
+ }
43
+
44
+ `)}else f?(o.write(`
45
+ if (${n}.issues.length) {${c(n,r)}
46
+ }
47
+ `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
48
+ if (${n}.value !== undefined || ${i}) {
49
+ newResult[${r}] = ${n}.value;
50
+ }
51
+ `)):o.write(`
52
+ const ${n}_present = ${i};
53
+ if (${n}.issues.length) {${c(n,r)}
54
+ }
55
+ if (!${n}_present && !${n}.issues.length) {
56
+ payload.issues.push({
57
+ code: "invalid_type",
58
+ expected: "nonoptional",
59
+ input: undefined,
60
+ path: [${r}]
61
+ });
62
+ if (ctx && ctx.abortEarly) {
63
+ payload.value = newResult;
64
+ return payload;
65
+ }
66
+ }
67
+
68
+ if (${n}_present) {
69
+ newResult[${r}] = ${n}.value;
70
+ }
71
+
72
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=ke,c=!k.jitless,l=c&&Ae.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Kr([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Yr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!E(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Qe(e,r,xt())))}),t)}const Xr=O(`$ZodUnion`,(e,t)=>{j.init(e,t),D(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),D(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),D(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),D(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ve(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Yr(t,r,e,i)):Yr(o,r,e,i)}}),Zr=O(`$ZodIntersection`,(e,t)=>{j.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>$r(e,t,n)):$r(e,i,a)}});function Qr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(je(e)&&je(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Qr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Qr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function $r(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Qr(t.value,n.value);if(!c.valid){if(E(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const ei=O(`$ZodEnum`,(e,t)=>{j.init(e,t);let n=pe(t.entries),r=new Set(n);e._zod.values=r,D(e,`pattern`,e=>{let t=pe(e.def.entries).filter(e=>Ne.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Pe(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),ti=O(`$ZodTransform`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,k.memoizer.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new bt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new yt;return n.value=i,n}});function ni(e,t){return e.value=t.issues.length?void 0:t.value,e}const ri=O(`$ZodOptional`,(e,t)=>{j.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,D(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ve(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>ni(e,t)):ni(e,r)}return t.innerType._zod.run(e,n)}}),ii=O(`$ZodExactOptional`,(e,t)=>{ri.init(e,t),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ai=O(`$ZodNullable`,(e,t)=>{j.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin),D(e,`optout`,e=>e.def.innerType._zod.optout),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ve(t.source)}|null)$`):void 0}),D(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),oi=O(`$ZodDefault`,(e,t)=>{j.init(e,t),e._zod.optin=`defaulted`,D(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>si(e,t)):si(r,t)}});function si(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ci=O(`$ZodPrefault`,(e,t)=>{j.init(e,t),e._zod.optin=`defaulted`,D(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),li=O(`$ZodNonOptional`,(e,t)=>{j.init(e,t),D(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ui(t,e)):ui(i,e)}});function ui(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function di(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Qe(e,r,xt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const fi=O(`$ZodCatch`,(e,t)=>{j.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),D(e,`optout`,e=>e.def.innerType._zod.optout),D(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>di(e,r,t,n)):di(e,r,t,n)}}),pi=O(`$ZodPipe`,(e,t)=>{j.init(e,t),D(e,`values`,e=>e.def.in._zod.values),D(e,`optin`,e=>e.def.in._zod.optin),D(e,`optout`,e=>e.def.out._zod.optout),D(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>mi(e,t.in,n)):mi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mi(e,t.out,n)):mi(r,t.out,n)}});function mi(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const hi=O(`$ZodReadonly`,(e,t)=>{j.init(e,t),D(e,`propValues`,e=>e.def.innerType._zod.propValues),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`optin`,e=>e.def.innerType?._zod?.optin),D(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(gi):gi(r)}});function gi(e){return e.memo||(e.value=Object.freeze(e.value)),e}const _i=O(`$ZodCustom`,(e,t)=>{A.init(e,t),j.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>vi(t,n,r,e));vi(i,n,r,e)}});function vi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(rt(e))}}var yi=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const bi=`~memo`,xi=[];function Si(e){return typeof e==`object`&&!!e}function Ci(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const wi=new WeakMap;function Ti(e,t,n){let r=wi.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=Ti(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?Ti(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=xe(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Ti(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Ei(e,i)}function Ei(e,t){return t!==1&&wi.set(e,t===2),t}function Di(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let Oi;const ki=[],Ai={alloc(e,t,n){let r=Oi;if(!r)return n;Oi=void 0;let i={value:n,issues:null};return r.set(t.value,i),ki.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Mi(n,e.value))throw new yi;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Ti(e,new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!Si(l))return t(s,c);let u=c[bi];u||(u={buckets:new WeakMap,backEdges:void 0},c[bi]=u);let d;i===c?d=a:(d=Di(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Ci(f.issues)):(s.memo=!0,u.backEdges??=new WeakSet,u.backEdges.add(f.value)),s;Oi=d;let p=ki.length,m=t(s,c);Oi=void 0;let h=ki.length>p?ki.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Ci(e.issues):xi),e)):(h&&(h.issues=m.issues.length?Ci(m.issues):xi),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ji(){return Ai}function Mi(e,t){let n=e[bi]?.backEdges;return n!==void 0&&Si(t)&&n.has(t)}const Ni=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(nt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Fe(e.values[0])}`:`Invalid option: expected one of ${me(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${me(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Pi(){return{localeError:Ni()}}var Fi,Ii=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Li(){return new Ii}(Fi=globalThis).__zod_globalRegistry??(Fi.__zod_globalRegistry=Li());const Ri=globalThis.__zod_globalRegistry;function zi(e){return e.checks&&=[...e.checks],e}function Bi(e,t){return new e(zi({type:`string`,...T(t)}))}function Vi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...T(t)})}function Hi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...T(t)})}function Ui(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...T(t)})}function Wi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...T(t)})}function Gi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...T(t)})}function Ki(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...T(t)})}function qi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...T(t)})}function Ji(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...T(t)})}function Yi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...T(t)})}function Xi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...T(t)})}function Zi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...T(t)})}function Qi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...T(t)})}function $i(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...T(t)})}function ea(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...T(t)})}function ta(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...T(t)})}function na(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...T(t)})}function ra(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...T(t)})}function ia(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...T(t)})}function aa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...T(t)})}function oa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...T(t)})}function sa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...T(t)})}function ca(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...T(t)})}function la(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...T(t)})}function ua(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...T(t)})}function da(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...T(t)})}function fa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...T(t)})}function pa(e,t){return new e(zi({type:`number`,checks:[],...T(t)}))}function ma(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...T(t)})}function ha(e,t){return new e({type:`boolean`,...T(t)})}function ga(e){return new e({type:`unknown`})}function _a(e,t){return new e({type:`never`,...T(t)})}function va(e,t){return new jn({check:`less_than`,...T(t),value:e,inclusive:!1})}function ya(e,t){return new jn({check:`less_than`,...T(t),value:e,inclusive:!0})}function ba(e,t){return new Mn({check:`greater_than`,...T(t),value:e,inclusive:!1})}function xa(e,t){return new Mn({check:`greater_than`,...T(t),value:e,inclusive:!0})}function Sa(e,t){return new Nn({check:`multiple_of`,...T(t),value:e})}function Ca(e,t){return new Fn({check:`max_length`,...T(t),maximum:e})}function wa(e,t){return new In({check:`min_length`,...T(t),minimum:e})}function Ta(e,t){return new Ln({check:`length_equals`,...T(t),length:e})}function Ea(e,t){return new zn({check:`string_format`,format:`regex`,...T(t),pattern:e})}function Da(e){return new Bn({check:`string_format`,format:`lowercase`,...T(e)})}function Oa(e){return new Vn({check:`string_format`,format:`uppercase`,...T(e)})}function ka(e,t){return new Hn({check:`string_format`,format:`includes`,...T(t),includes:e})}function Aa(e,t){return new Un({check:`string_format`,format:`starts_with`,...T(t),prefix:e})}function ja(e,t){return new Wn({check:`string_format`,format:`ends_with`,...T(t),suffix:e})}function Ma(e){return new Gn({check:`overwrite`,tx:e})}function Na(e){return Ma(t=>t.normalize(e))}function Pa(){return Ma(e=>e.trim())}function Fa(){return Ma(e=>e.toLowerCase())}function Ia(){return Ma(e=>e.toUpperCase())}function La(){return Ma(e=>De(e))}function Ra(e,t,n){return new e({type:`array`,element:t,...T(n)})}function za(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...T(n)})}function Ba(e,t){let n=Va(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(rt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(rt(r))}},e(t.value,t)),t);return n}function Va(e,t){let n=new A({check:`custom`,...T(t)});return n._zod.check=e,n}function Ha(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&be(e,t,n[t]);return e}function Ua(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ri,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Wa(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function N(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,N(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ha(o.schema,c),t.io===`input`&&P(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ga(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ka(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ga(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ga(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
73
+
74
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function qa(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;qa(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Ja=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ya=[`oneOf`,`anyOf`];function Xa(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Za(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ja.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Xa(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}be(n,r,e.length===1?e[0]:Za(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Xa(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Qa(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ja)if(t in e)return;let n=t.filter(e=>Ya.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Za(t);else{let e=n[0],i=Ya.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Za([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ha(e,r))}function $a(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ha(i,s),Ha(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())qa(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Qa(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Ha(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,be(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:to(t,`input`,e.processors),output:to(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function P(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return P(r.element,n);if(r.type===`set`)return P(r.valueType,n);if(r.type===`lazy`)return P(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`||r.type===`catch`)return P(r.innerType,n);if(r.type===`intersection`)return P(r.left,n)||P(r.right,n);if(r.type===`record`||r.type===`map`)return P(r.keyType,n)||P(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:P(r.in,n)||P(r.out,n);if(r.type===`object`){for(let e in r.shape)if(P(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(P(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(P(e,n))return!0;return!!(r.rest&&P(r.rest,n))}return!1}const eo=(e,t={})=>n=>{let r=Ua({...n,processors:t});return N(e,r),Ka(r,e),$a(r,e)},to=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ua({...i??{},target:a,io:t,processors:n});return N(e,o),Ka(o,e),$a(o,e)},no=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ro=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},io=(e,t)=>{no(e,`minimum`,t),ro(e,`maximum`,t)},ao=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},oo=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},so=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},co=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},lo=(e,t)=>no(e,`minimum`,t.minimum),uo=(e,t)=>ro(e,`maximum`,t.maximum),fo=e=>(t,n)=>{co(t,n.format);let[r,i]=e[n.format];no(t,`minimum`,r),ro(t,`maximum`,i)},po={greater_than:(e,t)=>no(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>ro(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>ao(e,t.value),number_format:fo(Le),bigint_format:fo(Re),min_length:lo,max_length:uo,length_equals:(e,t)=>io(e,t.length),min_size:lo,max_size:uo,size_equals:(e,t)=>io(e,t.size),string_format:(e,t)=>{co(e,t.format),t.pattern&&oo(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>so(e,t.mime)};function F(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)po[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&no(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&no(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&ro(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&ro(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&ao(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&so(t,i.mime);for(let e of i.patterns??[])oo(t,e);return t}const mo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ho=new Map([[Or,mn],[Ar,hn]]),go=e=>ho.get(e)??e,_o=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=F(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=mo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(go);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},vo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=F(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Wa(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},yo=(e,t,n,r)=>{n.type=`boolean`},bo=(e,t,n,r)=>{n.not={}},xo=(e,t,n,r)=>{let i=e._zod.def,a=pe(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},So=(e,t,n,r)=>{Wa(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{Wa(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},wo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=F(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=N(a.element,t,{...r,path:[...r.path,`items`]})};function To(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?To(t.out):t.type===`catch`?To(t.innerType):e._zod.optin}const Eo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Wa(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;for(let e in i.type=`object`,i.properties={},o)be(i.properties,e,N(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?To(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=N(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Do=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>N(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Oo=(e,t,n,r)=>{let i=e._zod.def,a=N(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=N(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},ko=(e,t,n,r)=>{let i=e._zod.def,a=N(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ao=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jo=Symbol();function Mo(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Wa(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),jo):JSON.parse(o)}const No=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Mo(i.defaultValue,e,t,n,r);o!==jo&&(n.default=o)},Po=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Mo(i.defaultValue,e,t,n,r);o!==jo&&(n._prefault=o)},Fo=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Wa(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Io=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;N(o,t,r);let s=t.seen.get(e);s.ref=o},Lo=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ro=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},zo=new WeakSet([Object.prototype,Error.prototype]);function Bo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const I=O(`ZodError`,(e,t)=>{Ot.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);zo.has(n)||(zo.add(n),Bo(n,`format`,e=>t=>jt(e,t)),Bo(n,`flatten`,e=>t=>At(e,t)),Bo(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,he,2)}),Bo(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,he,2)}),Object.defineProperty(n,`isEmpty`,{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Vo=Nt(I),Ho=Pt(I),Uo=Ft(I),Wo=Lt(I),Go=Ut(I),Ko=Wt(I),qo=Gt(I),Jo=Kt(I),Yo=qt(I),Xo=Jt(I),Zo=Yt(I),Qo=Xt(I);function $o(){k.localeError||xt(Pi())}function es(){k.memoizer||xt({memoizer:ji()})}const L=O(`ZodType`,(e,t)=>($o(),j.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(C(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return w(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(fc(e,t))},superRefine(e,t){return this.check(pc(e,t))},overwrite(e){return this.check(Ma(e))},optional(){return Js(this)},exactOptional(){return Xs(this)},nullable(){return Qs(this)},nullish(){return Js(Qs(this))},nonoptional(e){return ic(this,e)},array(){return Is(this)},or(e){return Bs([this,e])},and(e){return Hs(this,e)},transform(e){return cc(this,Ks(e))},default(e){return ec(this,e)},prefault(e){return nc(this,e)},catch(e){return oc(this,e)},pipe(e){return cc(this,e)},readonly(){return uc(this)},describe(e){let t=this.clone();return Ri.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ri.get(this);let t=this.clone();return Ri.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ot(this,`~standard`,{...Xn(this),jsonSchema:{input:to(this,`input`),output:to(this,`output`)}})},set"~standard"(e){at(this,`~standard`,e)},parse:function e(t,n){return Vo(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ho(this,t,n,{callee:e})},safeParse(e,t){return Uo(this,e,t)},async safeParseAsync(e,t){return Wo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){at(this,`spa`,e)},validate(e,t){return Bt(this,e,t)},validateAsync(e,t){return Ht(this,e,t)},encode:function e(t,n){return Go(this,t,n,{callee:e})},decode:function e(t,n){return Ko(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await qo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Jo(this,t,n,{callee:e})},safeEncode(e,t){return Yo(this,e,t)},safeDecode(e,t){return Xo(this,e,t)},async safeEncodeAsync(e,t){return Zo(this,e,t)},async safeDecodeAsync(e,t){return Qo(this,e,t)},toJSONSchema(e){return eo(this,{})(e)},get description(){return Ri.get(this)?.description},get _def(){return this._zod.def}}),ts=O(`_ZodString`,(e,t)=>{Zn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r)},st({format:e=>F(e).format??null,minLength:e=>F(e).minimum??null,maxLength:e=>F(e).maximum??null},{regex(...e){return this.check(Ea(...e))},includes(...e){return this.check(ka(...e))},startsWith(...e){return this.check(Aa(...e))},endsWith(...e){return this.check(ja(...e))},min(...e){return this.check(wa(...e))},max(...e){return this.check(Ca(...e))},length(...e){return this.check(Ta(...e))},nonempty(...e){return this.check(wa(1,...e))},lowercase(e){return this.check(Da(e))},uppercase(e){return this.check(Oa(e))},trim(){return this.check(Pa())},normalize(...e){return this.check(Na(...e))},toLowerCase(){return this.check(Fa())},toUpperCase(){return this.check(Ia())},slugify(){return this.check(La())}})),ns=O(`ZodString`,(e,t)=>{Zn.init(e,t),ts.init(e,t)},{email(e){return this.check(Vi(ss,e))},url(e){return this.check(qi(us,e))},jwt(e){return this.check(ca(Ts,e))},emoji(e){return this.check(Ji(ds,e))},guid(e){return this.check(Hi(cs,e))},uuid(e){return this.check(Ui(ls,e))},uuidv4(e){return this.check(Wi(ls,e))},uuidv6(e){return this.check(Gi(ls,e))},uuidv7(e){return this.check(Ki(ls,e))},nanoid(e){return this.check(Yi(fs,e))},cuid(e){return this.check(Xi(ps,e))},cuid2(e){return this.check(Zi(ms,e))},ulid(e){return this.check(Qi(hs,e))},base64(e){return this.check(aa(Ss,e))},base64url(e){return this.check(oa(Cs,e))},xid(e){return this.check($i(gs,e))},ksuid(e){return this.check(ea(_s,e))},ipv4(e){return this.check(ta(vs,e))},ipv6(e){return this.check(na(ys,e))},cidrv4(e){return this.check(ra(bs,e))},cidrv6(e){return this.check(ia(xs,e))},e164(e){return this.check(sa(ws,e))},datetime(e){return this.check(la(rs,e))},date(e){return this.check(ua(is,e))},time(e){return this.check(da(as,e))},duration(e){return this.check(fa(os,e))}});function R(e){return Bi(ns,e)}const z=O(`ZodStringFormat`,(e,t)=>{M.init(e,t),ts.init(e,t)}),rs=O(`ZodISODateTime`,(e,t)=>{gr.init(e,t),z.init(e,t)}),is=O(`ZodISODate`,(e,t)=>{_r.init(e,t),z.init(e,t)}),as=O(`ZodISOTime`,(e,t)=>{vr.init(e,t),z.init(e,t)}),os=O(`ZodISODuration`,(e,t)=>{yr.init(e,t),z.init(e,t)}),ss=O(`ZodEmail`,(e,t)=>{er.init(e,t),z.init(e,t)}),cs=O(`ZodGUID`,(e,t)=>{Qn.init(e,t),z.init(e,t)}),ls=O(`ZodUUID`,(e,t)=>{$n.init(e,t),z.init(e,t)}),us=O(`ZodURL`,(e,t)=>{cr.init(e,t),z.init(e,t)}),ds=O(`ZodEmoji`,(e,t)=>{lr.init(e,t),z.init(e,t)}),fs=O(`ZodNanoID`,(e,t)=>{ur.init(e,t),z.init(e,t)}),ps=O(`ZodCUID`,(e,t)=>{dr.init(e,t),z.init(e,t)}),ms=O(`ZodCUID2`,(e,t)=>{fr.init(e,t),z.init(e,t)}),hs=O(`ZodULID`,(e,t)=>{pr.init(e,t),z.init(e,t)}),gs=O(`ZodXID`,(e,t)=>{mr.init(e,t),z.init(e,t)}),_s=O(`ZodKSUID`,(e,t)=>{hr.init(e,t),z.init(e,t)}),vs=O(`ZodIPv4`,(e,t)=>{br.init(e,t),z.init(e,t)}),ys=O(`ZodIPv6`,(e,t)=>{Cr.init(e,t),z.init(e,t)}),bs=O(`ZodCIDRv4`,(e,t)=>{wr.init(e,t),z.init(e,t)}),xs=O(`ZodCIDRv6`,(e,t)=>{Er.init(e,t),z.init(e,t)}),Ss=O(`ZodBase64`,(e,t)=>{kr.init(e,t),z.init(e,t)}),Cs=O(`ZodBase64URL`,(e,t)=>{Mr.init(e,t),z.init(e,t)}),ws=O(`ZodE164`,(e,t)=>{Nr.init(e,t),z.init(e,t)}),Ts=O(`ZodJWT`,(e,t)=>{Fr.init(e,t),z.init(e,t)}),Es=O(`ZodNumber`,(e,t)=>{Ir.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e.isFinite=!0},st({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=F(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=F(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=F(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>F(e).format??null},{gt(e,t){return this.check(ba(e,t))},gte(e,t){return this.check(xa(e,t))},min(e,t){return this.check(xa(e,t))},lt(e,t){return this.check(va(e,t))},lte(e,t){return this.check(ya(e,t))},max(e,t){return this.check(ya(e,t))},int(e){return this.check(ks(e))},safe(e){return this.check(ks(e))},positive(e){return this.check(ba(0,e))},nonnegative(e){return this.check(xa(0,e))},negative(e){return this.check(va(0,e))},nonpositive(e){return this.check(ya(0,e))},multipleOf(e,t){return this.check(Sa(e,t))},step(e,t){return this.check(Sa(e,t))},finite(){return this}}));function Ds(e){return pa(Es,e)}const Os=O(`ZodNumberFormat`,(e,t)=>{Lr.init(e,t),Es.init(e,t)});function ks(e){return ma(Os,e)}const As=O(`ZodBoolean`,(e,t)=>{Rr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r)});function B(e){return ha(As,e)}const js=O(`ZodUnknown`,(e,t)=>{zr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ms(){return ga(js)}const Ns=O(`ZodNever`,(e,t)=>{Br.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r)});function Ps(e){return _a(Ns,e)}const Fs=O(`ZodArray`,(e,t)=>{es(),Hr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.element=t.element},{min(e,t){return this.check(wa(e,t))},nonempty(e){return this.check(wa(1,e))},max(e,t){return this.check(Ca(e,t))},length(e,t){return this.check(Ta(e,t))},unwrap(){return this.element}});function Is(e,t){return Ra(Fs,e,t)}const Ls=O(`ZodObject`,(e,t)=>{es(),Jr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),pt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ws(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(C(this._zod.def,{catchall:e}))},passthrough(){return this.clone(C(this._zod.def,{catchall:Ms()}))},loose(){return this.clone(C(this._zod.def,{catchall:Ms()}))},strict(){return this.clone(C(this._zod.def,{catchall:Ps()}))},strip(){return this.clone(C(this._zod.def,{catchall:void 0}))},extend(e){return He(this,e)},safeExtend(e){return We(this,e)},merge(e){return Ge(this,e)},pick(e){return ze(this,e)},omit(e){return Ve(this,e)},partial(...e){return Ke(qs,this,e[0])},exactPartial(...e){return Ke(Ys,this,e[0],`exactPartial`)},required(...e){return qe(rc,this,e[0])}});function Rs(e,t){return new Ls({type:`object`,shape:e??{},...T(t)})}const zs=O(`ZodUnion`,(e,t)=>{Xr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.options=t.options});function Bs(e,t){return new zs({type:`union`,options:e,...T(t)})}const Vs=O(`ZodIntersection`,(e,t)=>{Zr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r)});function Hs(e,t){return new Vs({type:`intersection`,left:e,right:t})}const Us=O(`ZodEnum`,(e,t)=>{ei.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Us({...t,checks:[],...T(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Us({...t,checks:[],...T(r),entries:i})}});function Ws(e,t){return new Us({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...T(t)})}const Gs=O(`ZodTransform`,(e,t)=>{es(),ti.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new bt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(rt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(rt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Ks(e){return new Gs({type:`transform`,transform:e})}const qs=O(`ZodOptional`,(e,t)=>{ri.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Js(e){return new qs({type:`optional`,innerType:e})}const Ys=O(`ZodExactOptional`,(e,t)=>{ii.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xs(e){return new Ys({type:`optional`,innerType:e})}const Zs=O(`ZodNullable`,(e,t)=>{ai.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e){return new Zs({type:`nullable`,innerType:e})}const $s=O(`ZodDefault`,(e,t)=>{oi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ec(e,t){return new $s({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Me(t)}})}const tc=O(`ZodPrefault`,(e,t)=>{ci.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nc(e,t){return new tc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Me(t)}})}const rc=O(`ZodNonOptional`,(e,t)=>{li.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ic(e,t){return new rc({type:`nonoptional`,innerType:e,...T(t)})}const ac=O(`ZodCatch`,(e,t)=>{fi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function oc(e,t){return new ac({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:mt(t)})}const sc=O(`ZodPipe`,(e,t)=>{pi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.in=t.in,e.out=t.out});function cc(e,t){return new sc({type:`pipe`,in:e,out:t})}const lc=O(`ZodReadonly`,(e,t)=>{hi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uc(e){return new lc({type:`readonly`,innerType:e})}const dc=O(`ZodCustom`,(e,t)=>{_i.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r)});function fc(e,t={}){return za(dc,e,t)}function pc(e,t){return Ba(e,t)}var V=class extends Error{suggestion;constructor(e,t){super(e,{cause:t?.cause}),this.name=`SkillessError`,this.suggestion=t?.suggestion}toString(){return this.suggestion?`${this.message}\n${this.suggestion}`:this.message}},mc=class extends V{constructor(){super(`You are not signed in.`,{suggestion:"Run `skilless init` to sign in, or set SKILLESS_TOKEN."})}},hc=class extends V{constructor(){super(`This directory has no git remote, so it has no project key.`,{suggestion:`skilless identifies a project by its git remote. Add one, or pass --project <key>.`})}};let gc=()=>{var e=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})},a=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of n(a))!r.call(i,c)&&c!==o&&e(i,c,{get:()=>a[c],enumerable:!(s=t(a,c))||s.enumerable});return i},o=t=>a(e({},`__esModule`,{value:!0}),t),s={};i(s,{default:()=>Ge});var c=e=>Array.isArray(e),l=e=>typeof e==`function`,u=e=>e.length===0,d=e=>typeof e==`number`,f=e=>typeof e==`object`&&!!e,p=e=>e instanceof RegExp,m=e=>typeof e==`string`,h=e=>e===void 0,g=e=>{let t=new Map;return n=>{let r=t.get(n);if(r)return r;let i=e(n);return t.set(n,i),i}},_=(e,t,n={})=>{let r={cache:{},input:e,index:0,indexMax:0,options:n,output:[]};if(ue(t)(r)&&r.index===e.length)return r.output;throw Error(`Failed to parse at index ${r.indexMax}`)},v=(e,t)=>c(e)?ee(e,t):m(e)?ne(e,t):te(e,t),ee=(e,t)=>{let n={};for(let t of e){if(t.length!==1)throw Error(`Invalid character: "${t}"`);let e=t.charCodeAt(0);n[e]=!0}return e=>{let r=e.index,i=e.input;for(;e.index<i.length&&i.charCodeAt(e.index)in n;)e.index+=1;let a=e.index;if(a>r){if(!h(t)&&!e.options.silent){let n=e.input.slice(r,a),o=l(t)?t(n,i,String(r)):t;h(o)||e.output.push(o)}e.indexMax=Math.max(e.indexMax,e.index)}return!0}},te=(e,t)=>{let n=e.source,r=e.flags.replace(/y|$/,`y`),i=new RegExp(n,r);return le(e=>{i.lastIndex=e.index;let n=i.exec(e.input);if(n){if(!h(t)&&!e.options.silent){let r=l(t)?t(...n,e.input,String(e.index)):t;h(r)||e.output.push(r)}return e.index+=n[0].length,e.indexMax=Math.max(e.indexMax,e.index),!0}else return!1})},ne=(e,t)=>n=>{if(n.input.startsWith(e,n.index)){if(!h(t)&&!n.options.silent){let r=l(t)?t(e,n.input,String(n.index)):t;h(r)||n.output.push(r)}return n.index+=e.length,n.indexMax=Math.max(n.indexMax,n.index),!0}else return!1},re=(e,t,n,r)=>{let i=ue(e);return le(ce(se(e=>{let r=0;for(;r<n;){let t=e.index;if(!i(e)||(r+=1,e.index===t))break}return r>=t})))},ie=(e,t)=>re(e,0,1),ae=(e,t)=>re(e,0,1/0),oe=(e,t)=>{let n=e.map(ue);return le(ce(se(e=>{for(let t=0,r=n.length;t<r;t++)if(!n[t](e))return!1;return!0})))},y=(e,t)=>{let n=e.map(ue);return le(ce(e=>{for(let t=0,r=n.length;t<r;t++)if(n[t](e))return!0;return!1}))},se=(e,t=!1)=>{let n=ue(e);return e=>{let r=e.index,i=e.output.length,a=n(e);return(!a||t)&&(e.index=r,e.output.length!==i&&(e.output.length=i)),a}},ce=(e,t)=>ue(e),le=(()=>{let e=0;return t=>{let n=ue(t),r=e+=1;return e=>{var t;if(e.options.memoization===!1)return n(e);let i=e.index,a=(t=e.cache)[r]||(t[r]=new Map),o=a.get(i);if(o===!1)return!1;if(d(o))return e.index=o,!0;if(o)return e.index=o.index,o.output?.length&&e.output.push(...o.output),!0;{let t=e.output.length;if(n(e)){let n=e.index,r=e.output.length;if(r>t){let o=e.output.slice(t,r);a.set(i,{index:n,output:o})}else a.set(i,n);return!0}else return a.set(i,!1),!1}}}})(),b=e=>{let t;return n=>(t||=ue(e()),t(n))},ue=g(e=>{if(l(e))return u(e)?b(e):e;if(m(e)||p(e))return v(e);if(c(e))return oe(e);if(f(e))return y(Object.values(e));throw Error(`Invalid rule`)}),de=`abcdefghijklmnopqrstuvwxyz`,fe=e=>{let t=``;for(;e>0;)t=de[(e-1)%26]+t,e=Math.floor((e-1)/26);return t},pe=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t=t*26+de.indexOf(e[n])+1;return t},me=(e,t)=>{if(t<e)return me(t,e);let n=[];for(;e<=t;)n.push(e++);return n},he=(e,t,n)=>me(e,t).map(e=>String(e).padStart(n,`0`)),ge=(e,t)=>me(pe(e),pe(t)).map(fe),x=e=>e,_e=e=>ve(t=>_(t,e,{memoization:!1}).join(``)),ve=e=>{let t={};return n=>t[n]??(t[n]=e(n))},ye=v(/^\*\*\/\*$/,`.*`),be=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,t,n)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}`),xe=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,t,n,r)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}(?:${r.replaceAll(`,`,`|`).replaceAll(`.`,`\\.`)})`),S=v(/\\./,x),Se=v(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ce=v(/./,x),we=y([v(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${Be(t)}$).*?`),v(/^(!!)+/,``)]),Te=y([v(/\/(\*\*\/)+/,`(?:/.+/|/)`),v(/^(\*\*\/)+/,`(?:^|.*/)`),v(/\/(\*\*)$/,`(?:/.*|$)`),v(/\*\*/,`.*`)]),C=y([v(/\*\/(?!\*\*\/)/,`[^/]*/`),v(/\*/,`[^/]*`)]),Ee=v(`?`,`[^/]`),De=v(`[`,x),Oe=v(`]`,x),ke=v(/[!^]/,`^/`),Ae=v(/[a-z]-[a-z]|[0-9]-[0-9]/i,x),je=y([S,v(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ae,v(/[^\]]/,x)]),Me=oe([De,ie(ke),ae(je),Oe]),Ne=v(`{`,`(?:`),Pe=v(`}`,`)`),w=oe([Ne,y([v(/(\d+)\.\.(\d+)/,(e,t,n)=>he(+t,+n,Math.min(t.length,n.length)).join(`|`)),v(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>ge(t,n).join(`|`)),v(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>ge(t.toLowerCase(),n.toLowerCase()).join(`|`).toUpperCase())]),Pe]),T=v(`{`,`(?:`),Fe=v(`}`,`)`),Ie=v(`,`,`|`),Le=v(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),Re=v(/[^}]/,x),ze=oe([T,ae(y([Te,C,Ee,Me,w,b(()=>ze),S,Le,Ie,Re])),Fe]),Be=_e(ae(y([ye,be,xe,we,Te,C,Ee,Me,w,ze,S,Se,Ce]))),Ve=v(/\\./,x),He=v(/./,x),Ue=_e(ae(y([Ve,v(/\*\*\*+/,`*`),v(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),v(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),He]))),We=(e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return!1;let r=n.map(We.compile),i=n.every(e=>/(\/(?:\*\*)?|\[\/\])$/.test(e)),a=t.replace(/[\\\/]+/g,`/`).replace(/\/$/,i?`/`:``);return r.some(e=>e.test(a))};We.compile=e=>RegExp(`^${Be(Ue(e))}$`,`s`);var Ge=We;return o(s)})();return e.default||e},_c;const vc=(e,t)=>(_c||(_c=gc(),gc=null),_c(e,t)),yc=/^[A-Za-z]:\//;function bc(e=``){return e&&e.replace(/\\/g,`/`).replace(yc,e=>e.toUpperCase())}const xc=/^[/\\]{2}/,Sc=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Cc=/^[A-Za-z]:$/,wc=/^\/([A-Za-z]:)?$/,Tc=/.(\.[^./]+|\.)$/,Ec=/^[/\\]|^[a-zA-Z]:[/\\]/,Dc=function(e){if(e.length===0)return`.`;e=bc(e);let t=e.match(xc),n=Mc(e),r=e[e.length-1]===`/`;return e=jc(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Cc.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!Mc(e)?`/${e}`:e)},Oc=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return Dc(t)};function kc(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const Ac=function(...e){e=e.map(e=>bc(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:kc();!i||i.length===0||(t=`${i}/${t}`,n=Mc(i))}return t=jc(t,!n),n&&!Mc(t)?`/${t}`:t.length>0?t:`.`};function jc(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const Mc=function(e){return Sc.test(e)},Nc=function(e){return bc(e)},Pc=function(e){if(e===`..`)return``;let t=Tc.exec(bc(e));return t&&t[1]||``},Fc=function(e,t){let n=Ac(e).replace(wc,`$1`).split(`/`),r=Ac(t).replace(wc,`$1`).split(`/`);if(r[0][1]===`:`&&n[0][1]===`:`&&n[0]!==r[0])return r.join(`/`);let i=[...n];for(let e of i){if(r[0]!==e)break;n.shift(),r.shift()}return[...n.map(()=>`..`),...r].join(`/`)},Ic=function(e){let t=bc(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&Cc.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(Mc(e)?`/`:`.`)},Lc=function(e){let t=e.ext?e.ext.startsWith(`.`)?e.ext:`.${e.ext}`:``,n=[e.root,e.dir,e.base??(e.name??``)+t].filter(Boolean);return bc(e.root?Ac(...n):n.join(`/`))},Rc=function(e,t){let n=bc(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r},zc={__proto__:null,basename:Rc,dirname:Ic,extname:Pc,format:Lc,isAbsolute:Mc,join:Oc,matchesGlob:(e,t)=>vc(t,Dc(e)),normalize:Dc,normalizeString:jc,parse:function(e){let t=Ec.exec(e)?.[0]?.replace(/\\/g,`/`)||``,n=Rc(e),r=Pc(n);return{root:t,dir:Ic(e),base:n,ext:r,name:n.slice(0,n.length-r.length)}},relative:Fc,resolve:Ac,sep:`/`,toNamespacedPath:Nc},Bc=globalThis.process?.platform===`win32`?`;`:`:`,Vc={posix:void 0,win32:void 0},Hc=(e=Bc)=>new Proxy(zc,{get(t,n){return n===`delimiter`?e:n===`posix`?H:n===`win32`?Uc:Vc[n]||zc[n]}}),H=Hc(`:`),Uc=Hc(`;`);function U(e){try{return r.lstatSync(e),!0}catch{return!1}}function Wc(e){try{return r.lstatSync(e).isSymbolicLink()}catch{return!1}}function Gc(e){return Wc(e)?!r.existsSync(e):!1}function Kc(e){r.mkdirSync(e,{recursive:!0})}function W(e){U(e)&&r.rmSync(e,{recursive:!0,force:!0})}function qc(e,t){let n=[],i=(e,a)=>{let o=r.readdirSync(e,{withFileTypes:!0});for(let r of o){if(t(r.name))continue;let o=a?H.join(a,r.name):r.name,s=H.join(e,r.name);r.isDirectory()?i(s,o):r.isFile()&&n.push(o)}};return i(e,``),n.sort()}function Jc(e,t){Kc(H.dirname(e)),r.writeFileSync(e,t,`utf8`)}function Yc(e,t){try{return JSON.parse(r.readFileSync(e,`utf8`))}catch{return t}}function Xc(e,t,n){Kc(H.dirname(e)),r.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,{encoding:`utf8`,mode:n})}function Zc(e,t){Kc(t),r.cpSync(e,t,{recursive:!0,dereference:!0})}const Qc=process.env.SKILLESS_HOME?H.resolve(process.env.SKILLESS_HOME):H.join(i.homedir(),`.skilless`),$c=H.join(Qc,`skills`),el=H.join(Qc,`auth.json`),tl=H.join(Qc,`state.json`),nl=H.join(Qc,`conflicts`);function G(e){return H.join($c,e)}const rl=`.agents/skills`,il=`.claude/skills`,al=`.agents/skills/.skilless.json`;function ol(e,n){try{return t(`git`,e,{cwd:n,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function sl(e){let t=ol([`rev-parse`,`--show-toplevel`],e);return t?H.normalize(t):null}function cl(e){return ol([`remote`,`get-url`,`origin`],e)}function ll(e){let t=e.trim().replace(/\.git$/i,``);if(!t)return null;let n,r,i=/^(?:[^@/]+@)?([^/:]+):(.+)$/.exec(t);if(i&&!t.includes(`://`))n=i[1]??``,r=i[2]??``;else{t.includes(`://`)||(t=`https://${t}`);let e;try{e=new URL(t)}catch{return null}n=e.hostname,r=e.pathname}return n=n.replace(/:\d+$/,``).toLowerCase(),r=r.replace(/^\/+|\/+$/g,``).toLowerCase(),!n||!r?null:`${n}/${r}`}function ul(e){let t=cl(e);return t?ll(t):null}function dl(e){let t=ol([`rev-parse`,`--git-common-dir`],e);return t?H.isAbsolute(t)?H.normalize(t):H.resolve(e,t):null}function fl(e){let t=dl(e);return t?H.join(t,`info`,`exclude`):null}function pl(e,t){return ol([`ls-files`,`--error-unmatch`,`--`,t],e)!==null}function ml(e,t){let n=fl(e);if(!n)return!1;let i=U(n)?r.readFileSync(n,`utf8`):``,a=new Set(i.split(`
75
+ `).map(e=>e.trim()).filter(Boolean)),o=t.filter(e=>!a.has(e));if(o.length===0)return!0;let s=i.includes(`# skilless`)?``:`
76
+ # skilless
77
+ `,c=i.length>0&&!i.endsWith(`
78
+ `)?`
79
+ `:``;return Kc(H.dirname(n)),r.appendFileSync(n,`${c}${s}${o.join(`
80
+ `)}\n`,`utf8`),!0}function hl(e,t){let n=fl(e);if(!n||!U(n))return;let i=new Set(t),a=r.readFileSync(n,`utf8`).split(`
81
+ `).filter(e=>!i.has(e.trim()));r.writeFileSync(n,a.join(`
82
+ `),`utf8`)}const gl=`SKILL.md`,_l=new Set([`.git`,`node_modules`,`.DS_Store`,`.skilless.json`]),vl=/^[a-z0-9][a-z0-9._-]*$/;function yl(e){return _l.has(e)}function bl(e){return e.length<=64&&vl.test(e)}function xl(e){if(!bl(e))throw new V(`\`${e}\` is not a valid skill name.`,{suggestion:`Use lowercase letters, digits, dots, dashes and underscores, starting with a letter or digit.`})}function Sl(e){let t=a.createHash(`sha256`);for(let n of[...e].sort((e,t)=>e.path.localeCompare(t.path)))t.update(n.path),t.update(`\0`),t.update(n.contents),t.update(`\0`);return t.digest(`hex`)}function Cl(e,t){if(!U(H.join(e,gl)))throw new V(`\`${t}\` has no ${gl}.`,{suggestion:`Every skill needs a ${gl} at its root.`});let n=qc(e,yl),i=[],a=0,o=0;for(let s of n){let n=H.join(e,s),c=r.readFileSync(n);if(c.includes(0))throw new V(`\`${t}/${s}\` looks like a binary file.`,{suggestion:`v0 syncs text only. Remove the file or keep it outside the skill.`});if(o+=c.byteLength,o>1048576)throw new V(`\`${t}\` is larger than 1MB.`,{suggestion:`Skills are prose — move large assets out of the skill directory.`});i.push({path:s,contents:c.toString(`utf8`)}),a=Math.max(a,r.statSync(n).mtimeMs)}return{name:t,dir:e,files:i,contentHash:Sl(i),editedAt:a}}function wl(e,t,n){let i=G(e);W(i),Kc(i);for(let e of t)Jc(H.join(i,e.path),e.contents);if(n!==void 0){let e=new Date(n);for(let n of t)r.utimesSync(H.join(i,n.path),e,e)}}function Tl(){return U($c)?r.readdirSync($c,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!yl(e.name)).map(e=>e.name).sort():[]}function El(){return Tl().map(e=>Cl(G(e),e))}function Dl(e){let t=G(e);return U(t)?Cl(t,e):null}function Ol(e,t){return[{path:gl,contents:`---\nname: ${e}\ndescription: ${t}\n---\n\n# ${e}\n\nDescribe what this skill does and when an agent should reach for it.\n`}]}const kl={version:1,mode:`link`,skills:[]};function Al(e){return H.join(e,al)}function jl(e){let t=Yc(Al(e),kl);return{version:1,mode:t.mode??`link`,skills:t.skills??[]}}function Ml(e,t){if(t.skills.length===0){W(Al(e));return}Xc(Al(e),t)}function Nl(e,t){return H.join(e,rl,t)}function Pl(e,t){return H.join(e,il,t)}function Fl(e){return[`/${al}`,...e.flatMap(e=>[`/${rl}/${e}`,`/${il}/${e}`])]}function Il(e,t,n){Kc(H.dirname(t));try{r.symlinkSync(e,t,`dir`)}catch{n()}}function Ll(e,t,n){let r=jl(e),i=new Set(r.skills),a=[],o=[];for(let r of t){let t=`${rl}/${r.name}`,s=`${il}/${r.name}`;if(pl(e,t)||pl(e,s)){o.push({name:r.name,reason:`tracked`});continue}let c=Nl(e,r.name),l=Pl(e,r.name);if(U(c)&&!i.has(r.name)&&!Wc(c)){o.push({name:r.name,reason:`occupied`});continue}if(W(c),W(l),n.copy){Kc(c);for(let e of r.files??[])Jc(H.join(c,e.path),e.contents)}else{let e=G(r.name);Il(e,c,()=>Zc(e,c))}Il(H.relative(H.dirname(l),c),l,()=>Zc(c,l)),i.add(r.name),a.push(r.name)}return Ml(e,{version:1,mode:n.copy?`copy`:`link`,skills:[...i].sort()}),ml(e,Fl([...i])),{written:a,skipped:o}}function Rl(e,t){let n=jl(e),r=new Set(n.skills),i=[];for(let n of t)r.has(n)&&(W(Nl(e,n)),W(Pl(e,n)),r.delete(n),i.push(n));return Ml(e,{version:1,mode:n.mode,skills:[...r].sort()}),hl(e,Fl(i)),i}function zl(e){let t=jl(e).skills.filter(t=>{let n=Nl(e,t);return Gc(n)||!U(n)});return t.length===0?[]:Rl(e,t)}function Bl(e){return sl(e)??e}const Vl={version:1,skills:{}};function Hl(){return{version:1,skills:Yc(tl,Vl).skills??{}}}function Ul(e){Xc(tl,e)}function Wl(e){return e??!U($c)}async function Gl(e,t,n={}){let r=Wl(n.copy),i=[];if(!r){let e=Hl();for(let n of t)Dl(n.name)||(wl(n.name,n.files,n.editedAt),e.skills[n.name]={contentHash:n.contentHash,editedAt:n.editedAt,syncedAt:Date.now()},i.push(n.name));Ul(e)}return{...Ll(e,t,{copy:r}),fetched:i}}var Kl=p(((e,t)=>{let n=typeof process<`u`&&process.env.TERM_PROGRAM===`Hyper`,r=typeof process<`u`&&process.platform===`win32`,i=typeof process<`u`&&process.platform===`linux`,a={ballotDisabled:`☒`,ballotOff:`☐`,ballotOn:`☑`,bullet:`•`,bulletWhite:`◦`,fullBlock:`█`,heart:`❤`,identicalTo:`≡`,line:`─`,mark:`※`,middot:`·`,minus:`-`,multiplication:`×`,obelus:`÷`,pencilDownRight:`✎`,pencilRight:`✏`,pencilUpRight:`✐`,percent:`%`,pilcrow2:`❡`,pilcrow:`¶`,plusMinus:`±`,question:`?`,section:`§`,starsOff:`☆`,starsOn:`★`,upDownArrow:`↕`},o=Object.assign({},a,{check:`√`,cross:`×`,ellipsisLarge:`...`,ellipsis:`...`,info:`i`,questionSmall:`?`,pointer:`>`,pointerSmall:`»`,radioOff:`( )`,radioOn:`(*)`,warning:`‼`}),s=Object.assign({},a,{ballotCross:`✘`,check:`✔`,cross:`✖`,ellipsisLarge:`⋯`,ellipsis:`…`,info:`ℹ`,questionFull:`?`,questionSmall:`﹖`,pointer:i?`▸`:`❯`,pointerSmall:i?`‣`:`›`,radioOff:`◯`,radioOn:`◉`,warning:`⚠`});t.exports=r&&!n?o:s,Reflect.defineProperty(t.exports,`common`,{enumerable:!1,value:a}),Reflect.defineProperty(t.exports,`windows`,{enumerable:!1,value:o}),Reflect.defineProperty(t.exports,`other`,{enumerable:!1,value:s})})),ql=p(((e,t)=>{let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,i=()=>typeof process<`u`?process.env.FORCE_COLOR!==`0`:!1,a=()=>{let e={enabled:i(),visible:!0,styles:{},keys:{}},t=e=>{let t=e.open=`\u001b[${e.codes[0]}m`,n=e.close=`\u001b[${e.codes[1]}m`,r=e.regex=RegExp(`\\u001b\\[${e.codes[1]}m`,`g`);return e.wrap=(e,i)=>{e.includes(n)&&(e=e.replace(r,n+t));let a=t+e+n;return i?a.replace(/\r*\n/g,`${n}$&${t}`):a},e},a=(e,t,n)=>typeof e==`function`?e(t):e.wrap(t,n),o=(t,n)=>{if(t===``||t==null)return``;if(e.enabled===!1)return t;if(e.visible===!1)return``;let r=``+t,i=r.includes(`
83
+ `),o=n.length;for(o>0&&n.includes(`unstyle`)&&(n=[...new Set([`unstyle`,...n])].reverse());o-- >0;)r=a(e.styles[n[o]],r,i);return r},s=(n,r,i)=>{e.styles[n]=t({name:n,codes:r}),(e.keys[i]||(e.keys[i]=[])).push(n),Reflect.defineProperty(e,n,{configurable:!0,enumerable:!0,set(t){e.alias(n,t)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(n):[n],t}})};return s(`reset`,[0,0],`modifier`),s(`bold`,[1,22],`modifier`),s(`dim`,[2,22],`modifier`),s(`italic`,[3,23],`modifier`),s(`underline`,[4,24],`modifier`),s(`inverse`,[7,27],`modifier`),s(`hidden`,[8,28],`modifier`),s(`strikethrough`,[9,29],`modifier`),s(`black`,[30,39],`color`),s(`red`,[31,39],`color`),s(`green`,[32,39],`color`),s(`yellow`,[33,39],`color`),s(`blue`,[34,39],`color`),s(`magenta`,[35,39],`color`),s(`cyan`,[36,39],`color`),s(`white`,[37,39],`color`),s(`gray`,[90,39],`color`),s(`grey`,[90,39],`color`),s(`bgBlack`,[40,49],`bg`),s(`bgRed`,[41,49],`bg`),s(`bgGreen`,[42,49],`bg`),s(`bgYellow`,[43,49],`bg`),s(`bgBlue`,[44,49],`bg`),s(`bgMagenta`,[45,49],`bg`),s(`bgCyan`,[46,49],`bg`),s(`bgWhite`,[47,49],`bg`),s(`blackBright`,[90,39],`bright`),s(`redBright`,[91,39],`bright`),s(`greenBright`,[92,39],`bright`),s(`yellowBright`,[93,39],`bright`),s(`blueBright`,[94,39],`bright`),s(`magentaBright`,[95,39],`bright`),s(`cyanBright`,[96,39],`bright`),s(`whiteBright`,[97,39],`bright`),s(`bgBlackBright`,[100,49],`bgBright`),s(`bgRedBright`,[101,49],`bgBright`),s(`bgGreenBright`,[102,49],`bgBright`),s(`bgYellowBright`,[103,49],`bgBright`),s(`bgBlueBright`,[104,49],`bgBright`),s(`bgMagentaBright`,[105,49],`bgBright`),s(`bgCyanBright`,[106,49],`bgBright`),s(`bgWhiteBright`,[107,49],`bgBright`),e.ansiRegex=r,e.hasColor=e.hasAnsi=t=>(e.ansiRegex.lastIndex=0,typeof t==`string`&&t!==``&&e.ansiRegex.test(t)),e.alias=(t,n)=>{let r=typeof n==`string`?e[n]:n;if(typeof r!=`function`)throw TypeError(`Expected alias to be the name of an existing color (string) or a function`);r.stack||=(Reflect.defineProperty(r,`name`,{value:t}),e.styles[t]=r,[t]),Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,set(n){e.alias(t,n)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(r.stack):r.stack,t}})},e.theme=t=>{if(!n(t))throw TypeError(`Expected theme to be an object`);for(let n of Object.keys(t))e.alias(n,t[n]);return e},e.alias(`unstyle`,t=>typeof t==`string`&&t!==``?(e.ansiRegex.lastIndex=0,t.replace(e.ansiRegex,``)):``),e.alias(`noop`,e=>e),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=Kl(),e.define=s,e};t.exports=a(),t.exports.create=a})),K=p((e=>{let t=Object.prototype.toString,n=ql(),r=!1,i=new Set,a={yellow:`blue`,cyan:`red`,green:`magenta`,black:`white`,blue:`yellow`,red:`cyan`,magenta:`green`,white:`black`};e.longest=(e,t)=>e.reduce((e,n)=>Math.max(e,t?n[t].length:n.length),0),e.hasColor=e=>!!e&&n.hasColor(e);let o=e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e);e.nativeType=e=>t.call(e).slice(8,-1).toLowerCase().replace(/\s/g,``),e.isAsyncFn=t=>e.nativeType(t)===`asyncfunction`,e.isPrimitive=e=>e!=null&&typeof e!=`object`&&typeof e!=`function`,e.resolve=(e,t,...n)=>typeof t==`function`?t.call(e,...n):t,e.scrollDown=(e=[])=>[...e.slice(1),e[0]],e.scrollUp=(e=[])=>[e.pop(),...e],e.reorder=(e=[])=>{let t=e.slice();return t.sort((e,t)=>e.index>t.index?1:e.index<t.index?-1:0),t},e.swap=(e,t,n)=>{let r=e.length,i=n===r?0:n<0?r-1:n,a=e[t];e[t]=e[i],e[i]=a},e.width=(e,t=80)=>{let n=e&&e.columns?e.columns:t;return e&&typeof e.getWindowSize==`function`&&(n=e.getWindowSize()[0]),process.platform===`win32`?n-1:n},e.height=(e,t=20)=>{let n=e&&e.rows?e.rows:t;return e&&typeof e.getWindowSize==`function`&&(n=e.getWindowSize()[1]),n},e.wordWrap=(e,t={})=>{if(!e)return e;typeof t==`number`&&(t={width:t});let{indent:n=``,newline:r=`
84
+ `+n,width:i=80}=t,a=(r+n).match(/[^\S\n]/g)||[];i-=a.length;let o=`.{1,${i}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,s=e.trim(),c=new RegExp(o,`g`),l=s.match(c)||[];return l=l.map(e=>e.replace(/\n$/,``)),t.padEnd&&(l=l.map(e=>e.padEnd(i,` `))),t.padStart&&(l=l.map(e=>e.padStart(i,` `))),n+l.join(r)},e.unmute=e=>{let t=e.stack.find(e=>n.keys.color.includes(e));return t?n[t]:e.stack.find(e=>e.slice(2)===`bg`)?n[t.slice(2)]:e=>e},e.pascal=e=>e?e[0].toUpperCase()+e.slice(1):``,e.inverse=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e));if(r){let i=n[`bg`+e.pascal(r)];return i?i.black:t}let i=t.stack.find(e=>e.slice(0,2)===`bg`);return i?n[i.slice(2).toLowerCase()]||t:n.none},e.complement=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e)),i=t.stack.find(e=>e.slice(0,2)===`bg`);if(r&&!i)return n[a[r]||r];if(i){let r=a[i.slice(2).toLowerCase()];return r&&n[`bg`+e.pascal(r)]||t}return n.none},e.meridiem=e=>{let t=e.getHours(),n=e.getMinutes(),r=t>=12?`pm`:`am`;t%=12;let i=t===0?12:t,a=n<10?`0`+n:n;return i+`:`+a+` `+r},e.set=(t={},n=``,r)=>n.split(`.`).reduce((t,n,i,a)=>{let o=a.length-1>i?t[n]||{}:r;return!e.isObject(o)&&i<a.length-1&&(o={}),t[n]=o},t),e.get=(e={},t=``,n)=>(e[t]==null?t.split(`.`).reduce((e,t)=>e&&e[t],e):e[t])??n,e.mixin=(t,n)=>{if(!o(t))return n;if(!o(n))return t;for(let r of Object.keys(n)){let i=Object.getOwnPropertyDescriptor(n,r);if(hasOwnProperty.call(i,`value`))if(hasOwnProperty.call(t,r)&&o(i.value)){let a=Object.getOwnPropertyDescriptor(t,r);o(a.value)&&a.value!==i.value?t[r]=e.merge({},t[r],n[r]):Reflect.defineProperty(t,r,i)}else Reflect.defineProperty(t,r,i);else Reflect.defineProperty(t,r,i)}return t},e.merge=(...t)=>{let n={};for(let r of t)e.mixin(n,r);return n},e.mixinEmitter=(t,n)=>{let r=n.constructor.prototype;for(let i of Object.keys(r)){let a=r[i];typeof a==`function`?e.define(t,i,a.bind(n)):e.define(t,i,a)}};let s=(e,t)=>{r||(r=!0,i.forEach(e=>e()),e===!0&&process.exit(128+t))},c=s.bind(null,!0,15),l=s.bind(null,!0,2);e.onExit=e=>(i.size===0&&(process.once(`SIGTERM`,c),process.once(`SIGINT`,l),process.once(`exit`,s)),i.add(e),()=>{i.delete(e),i.size===0&&(process.off(`SIGTERM`,c),process.off(`SIGINT`,l),process.off(`exit`,s))}),e.define=(e,t,n)=>{Reflect.defineProperty(e,t,{value:n})},e.defineExport=(e,t,n)=>{let r;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(e){r=e},get(){return r?r():n()}})}})),Jl=p(((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`)}})),Yl=p(((e,t)=>{let n=Jl();t.exports=e=>typeof e==`string`?e.replace(n(),``):e})),Xl=p((e=>{e.ctrl={a:`first`,b:`backward`,c:`cancel`,d:`deleteForward`,e:`last`,f:`forward`,g:`reset`,i:`tab`,k:`cutForward`,l:`reset`,n:`newItem`,m:`cancel`,j:`submit`,p:`search`,r:`remove`,s:`save`,u:`undo`,w:`cutLeft`,x:`toggleCursor`,v:`paste`},e.shift={up:`shiftUp`,down:`shiftDown`,left:`shiftLeft`,right:`shiftRight`,tab:`prev`},e.fn={up:`pageUp`,down:`pageDown`,left:`pageLeft`,right:`pageRight`,delete:`deleteForward`},e.option={b:`backward`,f:`forward`,d:`cutRight`,left:`cutLeft`,up:`altUp`,down:`altDown`},e.keys={pageup:`pageUp`,pagedown:`pageDown`,home:`home`,end:`end`,cancel:`cancel`,delete:`deleteForward`,backspace:`delete`,down:`down`,enter:`submit`,escape:`cancel`,left:`left`,space:`space`,number:`number`,return:`submit`,right:`right`,tab:`next`,up:`up`}})),Zl=p(((e,t)=>{t.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(e){this._jobRunner=e}enqueue=(...e)=>{this._queue.push(e),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){this._executing||!this._queue.length||(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}})),Ql=p(((e,t)=>{let n=g(`readline`),r=Xl(),i=Zl(),a=/^(?:\x1b)([a-zA-Z0-9])$/,o=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,s={OP:`f1`,OQ:`f2`,OR:`f3`,OS:`f4`,"[11~":`f1`,"[12~":`f2`,"[13~":`f3`,"[14~":`f4`,"[[A":`f1`,"[[B":`f2`,"[[C":`f3`,"[[D":`f4`,"[[E":`f5`,"[15~":`f5`,"[17~":`f6`,"[18~":`f7`,"[19~":`f8`,"[20~":`f9`,"[21~":`f10`,"[23~":`f11`,"[24~":`f12`,"[A":`up`,"[B":`down`,"[C":`right`,"[D":`left`,"[E":`clear`,"[F":`end`,"[H":`home`,OA:`up`,OB:`down`,OC:`right`,OD:`left`,OE:`clear`,OF:`end`,OH:`home`,"[1~":`home`,"[2~":`insert`,"[3~":`delete`,"[4~":`end`,"[5~":`pageup`,"[6~":`pagedown`,"[[5~":`pageup`,"[[6~":`pagedown`,"[7~":`home`,"[8~":`end`,"[a":`up`,"[b":`down`,"[c":`right`,"[d":`left`,"[e":`clear`,"[2$":`insert`,"[3$":`delete`,"[5$":`pageup`,"[6$":`pagedown`,"[7$":`home`,"[8$":`end`,Oa:`up`,Ob:`down`,Oc:`right`,Od:`left`,Oe:`clear`,"[2^":`insert`,"[3^":`delete`,"[5^":`pageup`,"[6^":`pagedown`,"[7^":`home`,"[8^":`end`,"[Z":`tab`};function c(e){return[`[a`,`[b`,`[c`,`[d`,`[e`,`[2$`,`[3$`,`[5$`,`[6$`,`[7$`,`[8$`,`[Z`].includes(e)}function l(e){return[`Oa`,`Ob`,`Oc`,`Od`,`Oe`,`[2^`,`[3^`,`[5^`,`[6^`,`[7^`,`[8^`].includes(e)}let u=(e=``,t={})=>{let n,r={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B`+String(e)):e=String(e):e!==void 0&&typeof e!=`string`?e=String(e):e||=r.sequence||``,r.sequence=r.sequence||e||r.name,e===`\r`)r.raw=void 0,r.name=`return`;else if(e===`
85
+ `)r.name=`enter`;else if(e===` `)r.name=`tab`;else if(e===`\b`||e===``||e===`\x1B`||e===`\x1B\b`)r.name=`backspace`,r.meta=e.charAt(0)===`\x1B`;else if(e===`\x1B`||e===`\x1B\x1B`)r.name=`escape`,r.meta=e.length===2;else if(e===` `||e===`\x1B `)r.name=`space`,r.meta=e.length===2;else if(e<=``)r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>=`0`&&e<=`9`)r.name=`number`;else if(e.length===1&&e>=`a`&&e<=`z`)r.name=e;else if(e.length===1&&e>=`A`&&e<=`Z`)r.name=e.toLowerCase(),r.shift=!0;else if(n=a.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(n[1]);else if(n=o.exec(e)){let t=[...e];t[0]===`\x1B`&&t[1]===`\x1B`&&(r.option=!0);let i=[n[1],n[2],n[4],n[6]].filter(Boolean).join(``),a=(n[3]||n[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=i,r.name=s[i],r.shift=c(i)||r.shift,r.ctrl=l(i)||r.ctrl}return r};u.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw Error(`Invalid stream passed`);let a=n.createInterface({terminal:!0,input:r});n.emitKeypressEvents(r,a);let o=new i((e,n)=>t(e,u(e,n),a)),s=r.isRaw;return r.isTTY&&r.setRawMode(!0),r.on(`keypress`,o.enqueue),a.resume(),()=>{r.isTTY&&r.setRawMode(s),r.removeListener(`keypress`,o.enqueue),o.destroy(),a.pause(),a.close()}},u.action=(e,t,n)=>{let i={...r,...n};return t.ctrl?(t.action=i.ctrl[t.name],t):t.option&&i.option?(t.action=i.option[t.name],t):t.shift?(t.action=i.shift[t.name],t):(t.action=i.keys[t.name],t)},t.exports=u})),$l=p(((e,t)=>{t.exports=e=>{e.timers=e.timers||{};let t=e.options.timers;if(t)for(let r of Object.keys(t)){let i=t[r];typeof i==`number`&&(i={interval:i}),n(e,r,i)}};function n(e,t,n={}){let r=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},i=n.interval||120;r.frames=n.frames||[],r.loading=!0;let a=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,e.render()},i);return r.stop=()=>{r.loading=!1,clearInterval(a)},Reflect.defineProperty(r,`interval`,{value:a}),e.once(`close`,()=>r.stop()),r.stop}})),eu=p(((e,t)=>{let{define:n,width:r}=K();t.exports=class{constructor(e){let t=e.options;n(this,`_prompt`,e),this.type=e.type,this.name=e.name,this.message=``,this.header=``,this.footer=``,this.error=``,this.hint=``,this.input=``,this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt=``,this.buffer=``,this.width=r(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t==`function`?t:e.pending}set loading(e){this._loading=e}get loading(){return typeof this._loading==`boolean`?this._loading:this.loadingChoices?`choices`:!1}get status(){return this.cancelled?`cancelled`:this.submitted?`submitted`:`pending`}}})),tu=p(((e,t)=>{let n=K(),r=ql(),i={default:r.noop,noop:r.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||n.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||n.complement(this.primary)},primary:r.cyan,success:r.green,danger:r.magenta,strong:r.bold,warning:r.yellow,muted:r.dim,disabled:r.gray,dark:r.dim.gray,underline:r.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};i.merge=(e={})=>{e.styles&&typeof e.styles.enabled==`boolean`&&(r.enabled=e.styles.enabled),e.styles&&typeof e.styles.visible==`boolean`&&(r.visible=e.styles.visible);let t=n.merge({},i,e.styles);delete t.merge;for(let e of Object.keys(r))hasOwnProperty.call(t,e)||Reflect.defineProperty(t,e,{get:()=>r[e]});for(let e of Object.keys(r.styles))hasOwnProperty.call(t,e)||Reflect.defineProperty(t,e,{get:()=>r[e]});return t},t.exports=i})),nu=p(((e,t)=>{let n=process.platform===`win32`,r=ql(),i=K(),a={...r.symbols,upDownDoubleArrow:`⇕`,upDownDoubleArrow2:`⬍`,upDownArrow:`↕`,asterisk:`*`,asterism:`⁂`,bulletWhite:`◦`,electricArrow:`⌁`,ellipsisLarge:`⋯`,ellipsisSmall:`…`,fullBlock:`█`,identicalTo:`≡`,indicator:r.symbols.check,leftAngle:`‹`,mark:`※`,minus:`−`,multiplication:`×`,obelus:`÷`,percent:`%`,pilcrow:`¶`,pilcrow2:`❡`,pencilUpRight:`✐`,pencilDownRight:`✎`,pencilRight:`✏`,plus:`+`,plusMinus:`±`,pointRight:`☞`,rightAngle:`›`,section:`§`,hexagon:{off:`⬡`,on:`⬢`,disabled:`⬢`},ballot:{on:`☑`,off:`☐`,disabled:`☒`},stars:{on:`★`,off:`☆`,disabled:`☆`},folder:{on:`▼`,off:`▶`,disabled:`▶`},prefix:{pending:r.symbols.question,submitted:r.symbols.check,cancelled:r.symbols.cross},separator:{pending:r.symbols.pointerSmall,submitted:r.symbols.middot,cancelled:r.symbols.middot},radio:{off:n?`( )`:`◯`,on:n?`(*)`:`◉`,disabled:n?`(|)`:`Ⓘ`},numbers:`⓪.①.②.③.④.⑤.⑥.⑦.⑧.⑨.⑩.⑪.⑫.⑬.⑭.⑮.⑯.⑰.⑱.⑲.⑳.㉑.㉒.㉓.㉔.㉕.㉖.㉗.㉘.㉙.㉚.㉛.㉜.㉝.㉞.㉟.㊱.㊲.㊳.㊴.㊵.㊶.㊷.㊸.㊹.㊺.㊻.㊼.㊽.㊾.㊿`.split(`.`)};a.merge=e=>{let t=i.merge({},r.symbols,a,e.symbols);return delete t.merge,t},t.exports=a})),ru=p(((e,t)=>{let n=tu(),r=nu(),i=K();t.exports=e=>{e.options=i.merge({},e.options.theme,e.options),e.symbols=r.merge(e.options),e.styles=n.merge(e.options)}})),iu=p(((e,t)=>{let n=process.env.TERM_PROGRAM===`Apple_Terminal`,r=Yl(),i=K(),a=t.exports=e,o=!1,s=a.code={bell:`\x07`,beep:`\x07`,beginning:`\x1B[G`,down:`\x1B[J`,esc:`\x1B[`,getPosition:`\x1B[6n`,hide:`\x1B[?25l`,line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,restorePosition:`\x1B[`+(n?`8`:`u`),savePosition:`\x1B[`+(n?`7`:`s`),screen:`\x1B[2J`,show:`\x1B[?25h`,up:`\x1B[1J`},c=a.cursor={get hidden(){return o},hide(){return o=!0,s.hide},show(){return o=!1,s.show},forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),up:(e=1)=>e?`[${e}A`:``,down:(e=1)=>e?`[${e}B`:``,right:(e=1)=>e?`[${e}C`:``,left:(e=1)=>e?`[${e}D`:``,to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e=0,t=0){let n=``;return n+=e<0?c.left(-e):e>0?c.right(e):``,n+=t<0?c.up(-t):t>0?c.down(t):``,n},strLen(e){for(var t=0,n=e.length,r=-1,i=0;i<n;i++)r=e.charCodeAt(i),r>=0&&r<=128?t+=1:t+=2;return t},restore(e={}){let{after:t,cursor:n,initial:r,input:o,prompt:s,size:c,value:l}=e;if(r=i.isPrimitive(r)?String(r):``,o=i.isPrimitive(o)?String(o):``,l=i.isPrimitive(l)?String(l):``,c){let e=a.cursor.up(c)+a.cursor.to(this.strLen(s)),t=o.length-n;return t>0&&(e+=a.cursor.left(t)),e}if(l||t){let e=!o&&r?-this.strLen(r):-this.strLen(o)+n;return t&&(e-=this.strLen(t)),o===``&&r&&!s.includes(r)&&(e+=this.strLen(r)),a.cursor.move(e)}}},l=a.erase={screen:s.screen,up:s.up,down:s.down,line:s.line,lineEnd:s.lineEnd,lineStart:s.lineStart,lines(e){let t=``;for(let n=0;n<e;n++)t+=a.erase.line+(n<e-1?a.cursor.up(1):``);return e&&(t+=a.code.beginning),t}};a.clear=(e=``,t=process.stdout.columns)=>{if(!t)return l.line+c.to(0);let n=e=>[...r(e)].length,i=e.split(/\r?\n/),a=0;for(let e of i)a+=1+Math.floor(Math.max(n(e)-1,0)/t);return(l.line+c.prevLine()).repeat(a-1)+l.line+c.to(0)}})),au=p(((e,t)=>{let n=g(`events`),r=Yl(),i=Ql(),a=$l(),o=eu(),s=ru(),c=K(),l=iu();var u=class e extends n{constructor(e={}){super(),this.name=e.name,this.type=e.type,this.options=e,s(this),a(this),this.state=new o(this),this.initial=[e.initial,e.default].find(e=>e!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=f(this.options.margin),this.setMaxListeners(0),d(this)}async keypress(e,t={}){this.keypressed=!0;let n=i.action(e,i(e,t),this.options.actions);this.state.keypress=n,this.emit(`keypress`,e,n),this.emit(`state`,this.state.clone());let r=this.options[n.action]||this[n.action]||this.dispatch;if(typeof r==`function`)return await r.call(this,e,n);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit(`alert`):this.stdout.write(l.code.beep)}cursorHide(){this.stdout.write(l.cursor.hide());let e=c.onExit(()=>this.cursorShow());this.on(`close`,()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(l.cursor.show())}write(e){e&&(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer=``,!(!t&&!e||this.options.show===!1)&&this.stdout.write(l.cursor.down(e)+l.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:n}=this.sections(),{cursor:r,initial:i=``,input:a=``,value:o=``}=this,s={after:t,cursor:r,initial:i,input:a,prompt:e,size:this.state.size=n.length,value:o},c=l.cursor.restore(s);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:n}=this.state;n=r(n);let i=r(e),a=i.indexOf(n),o=i.slice(0,a),s=i.slice(a).split(`
86
+ `),c=s[0],l=s[s.length-1],u=(n+(t?` `+t:``)).length;return{header:o,prompt:c,after:u<c.length?c.slice(u+1):``,rest:s.slice(1),last:l}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
87
+ `+this.symbols.pointer+` `;typeof e==`string`?t+=e.trim():t+=`Invalid input`,this.state.error=`
88
+ `+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit(`submit`,this.value)}async cancel(e){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel==`function`&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit(`cancel`,await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(l.cursor.down(e.rest.length)),this.write(`
89
+ `.repeat(t))}catch{}this.emit(`close`)}start(){!this.stop&&this.options.show!==!1&&(this.stop=i.listen(this,this.keypress.bind(this)),this.once(`close`,this.stop),this.emit(`start`,this))}async skip(){return this.skipped=this.options.skip===!0,typeof this.options.skip==`function`&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:e,options:t,result:n}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>n.call(this,this.value),typeof t.initial==`function`&&(this.initial=await t.initial.call(this,this)),typeof t.onRun==`function`&&await t.onRun.call(this,this),typeof t.onSubmit==`function`){let e=t.onSubmit.bind(this),n=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await e(this.name,this.value,this),n())}await this.start(),await this.render()}render(){throw Error(`expected prompt to have a custom render method`)}run(){return new Promise(async(e,t)=>{if(this.once(`submit`,e),this.once(`cancel`,t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit(`run`)})}async element(e,t,n){let{options:r,state:i,symbols:a,timers:o}=this;i.timer=o&&o[e];let s=r[e]||i[e]||a[e],c=t&&t[e]!=null?t[e]:await s;if(c===``)return c;let l=await this.resolve(c,i,t,n);return!l&&t&&t[e]?this.resolve(s,i,t,n):l}async prefix(){let e=await this.element(`prefix`)||this.symbols,t=this.timers&&this.timers.prefix,n=this.state;return n.timer=t,c.isObject(e)&&(e=e[n.status]||e.pending),c.hasColor(e)?e:(this.styles[n.status]||this.styles.pending)(e)}async message(){let e=await this.element(`message`);return c.hasColor(e)?e:this.styles.strong(e)}async separator(){let e=await this.element(`separator`)||this.symbols,t=this.timers&&this.timers.separator,n=this.state;n.timer=t;let r=e[n.status]||e.pending||n.separator,i=await this.resolve(r,n);return c.isObject(i)&&(i=i[n.status]||i.pending),c.hasColor(i)?i:this.styles.muted(i)}async pointer(e,t){let n=await this.element(`pointer`,e,t);if(typeof n==`string`&&c.hasColor(n))return n;if(n){let e=this.styles,r=this.index===t,i=r?e.primary:e=>e,a=await this.resolve(n[r?`on`:`off`]||n,this.state),o=c.hasColor(a)?a:i(a);return r?o:` `.repeat(a.length)}}async indicator(e,t){let n=await this.element(`indicator`,e,t);if(typeof n==`string`&&c.hasColor(n))return n;if(n){let t=this.styles,r=e.enabled===!0,i=r?t.success:t.dark,a=n[r?`on`:`off`]||n;return c.hasColor(a)?a:i(a)}return``}body(){return null}footer(){if(this.state.status===`pending`)return this.element(`footer`)}header(){if(this.state.status===`pending`)return this.element(`header`)}async hint(){if(this.state.status===`pending`&&!this.isValue(this.state.input)){let e=await this.element(`hint`);return c.hasColor(e)?e:this.styles.muted(e)}}error(e){return this.state.submitted?``:e||this.state.error}format(e){return e}result(e){return e}validate(e){return this.options.required===!0?this.isValue(e):!0}isValue(e){return e!=null&&e!==``}resolve(e,...t){return c.resolve(this,e,...t)}get base(){return e.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||c.height(this.stdout,25)}get width(){return this.options.columns||c.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,n=[t,e].find(this.isValue.bind(this));return this.isValue(n)?n:this.initial}static get prompt(){return e=>new this(e).run()}};function d(e){let t=t=>e[t]===void 0||typeof e[t]==`function`,n=[`actions`,`choices`,`initial`,`margin`,`roles`,`styles`,`symbols`,`theme`,`timers`,`value`],r=[`body`,`footer`,`error`,`header`,`hint`,`indicator`,`message`,`prefix`,`separator`,`skip`];for(let i of Object.keys(e.options)){if(n.includes(i)||/^on[A-Z]/.test(i))continue;let a=e.options[i];typeof a==`function`&&t(i)?r.includes(i)||(e[i]=a.bind(e)):typeof e[i]!=`function`&&(e[i]=a)}}function f(e){typeof e==`number`&&(e=[e,e,e,e]);let t=[].concat(e||[]),n=e=>e%2==0?`
90
+ `:` `,r=[];for(let e=0;e<4;e++){let i=n(e);t[e]?r.push(i.repeat(t[e])):r.push(``)}return r}t.exports=u})),ou=p(((e,t)=>{let n=K(),r={default(e,t){return t},checkbox(e,t){throw Error(`checkbox role is not implemented yet`)},editable(e,t){throw Error(`editable role is not implemented yet`)},expandable(e,t){throw Error(`expandable role is not implemented yet`)},heading(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||``,t},input(e,t){throw Error(`input role is not implemented yet`)},option(e,t){return r.default(e,t)},radio(e,t){throw Error(`radio role is not implemented yet`)},separator(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};t.exports=(e,t={})=>{let i=n.merge({},r,t.roles);return i[e]||i.default}})),su=p(((e,t)=>{let n=Yl(),r=au(),i=ou(),a=K(),{reorder:o,scrollUp:s,scrollDown:c,isObject:l,swap:u}=a;var d=class extends r{constructor(e){super(e),this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=``}async initialize(){typeof this.options.initial==`function`&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:n,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(e=>e.enabled=!1),typeof r!=`function`&&this.selectable.length===0)throw Error(`At least one choice must be selectable`);l(t)&&(t=Object.keys(t)),Array.isArray(t)?(n!=null&&(this.index=this.findIndex(n)),t.forEach(e=>this.enable(this.find(e))),await this.render()):(n!=null&&(t=n),typeof t==`string`&&(t=this.findIndex(t)),typeof t==`number`&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let n=[],r=0,i=async(e,t)=>{typeof e==`function`&&(e=await e.call(this)),e instanceof Promise&&(e=await e);for(let a=0;a<e.length;a++){let o=e[a]=await this.toChoice(e[a],r++,t);n.push(o),o.choices&&await i(o.choices,o)}return n};return i(e,t).then(e=>(this.state.loadingChoices=!1,e))}async toChoice(e,t,r){if(typeof e==`function`&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e==`string`&&(e={name:e}),e.normalized)return e;e.normalized=!0;let o=e.value;if(e=i(e.role,this.options)(this,e),typeof e.disabled==`string`&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint=`(disabled)`),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||``,e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input=``,e.index=t,e.cursor=0,a.define(e,`parent`,r),e.level=r?r.level+1:1,e.indent??=r?r.indent+` `:e.indent||``,e.path=r?r.path+`.`+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,n(e.message).length));let s={...e};return e.reset=(t=s.input,n=s.value)=>{for(let t of Object.keys(s))e[t]=s[t];e.input=t,e.value=n},o==null&&typeof e.initial==`function`&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit(`choice`,e,t,this),typeof e.onChoice==`function`&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,n){let r=await this.toChoice(e,t,n);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,n){let r={name:`New choice name?`,editable:!0,newChoice:!0,...e},i=await this.addChoice(r,t,n);return i.updateChoice=()=>{delete i.newChoice,i.name=i.message=i.input,i.input=``,i.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?` `.repeat(e.level-1):``:e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!=`boolean`&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!this.isDisabled(e),e)}space(){if(!this.multiple)return this.alert();if(this.focused)return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(e=>e.enabled);return this.choices.forEach(t=>t.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(){if(!this.choices.some(e=>!!e.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!=`boolean`&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(e=>this.toggle(e,t));let n=e.parent;for(;n;){let e=n.choices.filter(e=>this.isDisabled(e));n.enabled=e.every(e=>e.enabled===!0),n=n.parent}return f(this,this.choices),this.emit(`toggle`,e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=e=>{let t=Number(e);if(t>this.choices.length-1)return this.alert();let n=this.focused,r=this.choices.find(e=>t===e.index);if(!r.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(r)===-1){let e=o(this.choices),t=e.indexOf(r);if(n.index>t){let n=e.slice(t,t+this.limit),r=e.filter(e=>!n.includes(e));this.choices=n.concat(r)}else{let n=t-this.limit+1;this.choices=e.slice(n).concat(e.slice(0,n))}}return this.index=this.choices.indexOf(r),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(e=>{let n=this.choices.length,r=this.num,i=(n=!1,i)=>{clearTimeout(this.numberTimeout),n&&(i=t(r)),this.num=``,e(i)};if(r===`0`||r.length===1&&Number(r+`0`)>n)return i(!0);if(Number(r)>n)return i(!1,this.alert());this.numberTimeout=setTimeout(()=>i(!0),this.delay)})}home(){return this.choices=o(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=o(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===0?this.alert():e>t&&n===0?this.scrollUp():(this.index=(n-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===t-1?this.alert():e>t&&n===t-1?this.scrollDown():(this.index=(n+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=s(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=c(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){u(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every(e=>this.isDisabled(e))}isDisabled(e=this.focused){return e&&[`disabled`,`collapsed`,`hidden`,`completing`,`readonly`].some(t=>e[t]===!0)?!0:e&&e.role===`heading`}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(e=>this.isEnabled(e));if(e.choices){let t=e.choices.filter(e=>!this.isDisabled(e));return e.enabled&&t.every(e=>this.isEnabled(e))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t=`value`){return[].concat(e||[]).reduce((e,n)=>(e[n]=this.find(n,t),e),{})}filter(e,t){let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=(this.options.multiple?this.state._choices:this.choices).filter(n);return t?r.map(e=>e[t]):r}find(e,t){if(l(e))return t?e[t]:e;let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=this.choices.find(n);if(r)return t?r[t]:r}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(e=>e.newChoice))return this.alert();let{reorder:t,sort:n}=this.options,r=this.multiple===!0,i=this.selected;return i===void 0?this.alert():(Array.isArray(i)&&t!==!1&&n!==!0&&(i=a.reorder(i)),this.value=r?i.map(e=>e.name):i.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(e=>e.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let e=this.initial;if(typeof e==`string`||typeof e==`number`){let t=this.find(e);t&&(this.initial=t.index,this.focus(t,!0))}}}get choices(){return f(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:n}=this,r=e.limit||this._limit||t.limit||n.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){return typeof super.value!=`string`&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function f(e,t){if(t instanceof Promise)return t;if(typeof t==`function`){if(a.isAsyncFn(t))return t;t=t.call(e,e)}for(let n of t)Array.isArray(n.choices)&&(n.enabled=n.choices.filter(t=>!e.isDisabled(t)).every(e=>e.enabled===!0)),e.isDisabled(n)===!0&&delete n.enabled;return t}t.exports=d})),cu=p(((e,t)=>{let n=su(),r=K();t.exports=class extends n{constructor(e){super(e),this.emptyError=this.options.emptyError||`No items were selected`}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):``}indicator(e,t){return this.multiple?super.indicator(e,t):``}choiceMessage(e,t){let n=this.resolve(e.message,this.state,e,t);return e.role===`heading`&&!r.hasColor(n)&&(n=this.styles.strong(n)),this.resolve(n,this.state,e,t)}choiceSeparator(){return`:`}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,i=await this.pointer(e,t),a=await this.indicator(e,t)+(e.pad||``),o=await this.resolve(e.hint,this.state,e,t);o&&!r.hasColor(o)&&(o=this.styles.muted(o));let s=this.indent(e),c=await this.choiceMessage(e,t),l=()=>[this.margin[3],s+i+a,c,this.margin[1],o].filter(Boolean).join(` `);return e.role===`heading`?l():e.disabled?(r.hasColor(c)||(c=this.styles.disabled(c)),l()):(n&&(c=this.styles.em(c)),l())}async renderChoices(){if(this.state.loading===`choices`)return this.styles.warning(`Loading choices`);if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);t.length||t.push(this.styles.danger(`No matching choices`));let n=this.margin[0]+t.join(`
91
+ `),r;return this.options.choicesHeader&&(r=await this.resolve(this.options.choicesHeader,this.state)),[r,n].filter(Boolean).join(`
92
+ `)}format(){return!this.state.submitted||this.state.cancelled?``:Array.isArray(this.selected)?this.selected.map(e=>this.styles.primary(e.name)).join(`, `):this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,n=``,r=await this.header(),i=await this.prefix(),a=await this.separator(),o=await this.message();this.options.promptLine!==!1&&(n=[i,o,a,``].join(` `),this.state.prompt=n);let s=await this.format(),c=await this.error()||await this.hint(),l=await this.renderChoices(),u=await this.footer();s&&(n+=s),c&&!n.includes(c)&&(n+=` `+c),e&&!s&&!l.trim()&&this.multiple&&this.emptyError!=null&&(n+=this.styles.danger(this.emptyError)),this.clear(t),this.write([r,n,l,u].filter(Boolean).join(`
93
+ `)),this.write(this.margin[2]),this.restore()}}})),lu=p(((e,t)=>{let n=cu(),r=(e,t)=>{let n=e?new RegExp(e,`ig`):/$^/;return r=>e?r.replace(n,e=>t(e)):r};t.exports=class extends n{constructor(e){super(e),this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:n}=this.state;return this.input=n.slice(0,t)+e+n.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;return t?(this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:t}=this.state;return t[e]===void 0?this.alert():(this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete())}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest==`function`)return this.options.suggest.call(this,e,t);let n=e.toLowerCase();return t.filter(e=>e.message.toLowerCase().includes(n))}pointer(){return``}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(e=>this.styles.primary(e.message)).join(`, `);if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!==`pending`)return super.render();let e=this.options.highlight||this.styles.complement,t=r(this.input,(t,n)=>t&&(e.stack?e(t):e.call(this,t))),n=this.choices;this.choices=n.map(e=>({...e,message:t(e.message)})),await super.render(),this.choices=n}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}}})),uu=p(((e,t)=>{let n=K();t.exports=(e,t={})=>{e.cursorHide();let{input:r=``,initial:i=``,pos:a,showCursor:o=!0,color:s}=t,c=s||e.styles.placeholder,l=n.inverse(e.styles.primary),u=t=>l(e.styles.black(t)),d=r,f=u(` `);if(e.blink&&e.blink.off===!0&&(u=e=>e,f=``),o&&a===0&&i===``&&r===``)return u(` `);if(o&&a===0&&(r===i||r===``))return u(i[0])+c(i.slice(1));i=n.isPrimitive(i)?`${i}`:``,r=n.isPrimitive(r)?`${r}`:``;let p=i&&i.startsWith(r)&&i!==r,m=p?u(i[r.length]):f;if(a!==r.length&&o===!0&&(d=r.slice(0,a)+u(r[a])+r.slice(a+1),m=``),o===!1&&(m=``),p){let t=e.styles.unstyle(d+m);return d+m+c(i.slice(t.length))}return d+m}})),du=p(((e,t)=>{let n=Yl(),r=cu(),i=uu();t.exports=class extends r{constructor(e){super({...e,multiple:!0}),this.type=`form`,this.initial=this.options.initial,this.align=[this.options.align,`right`].find(e=>e!=null),this.emptyError=``,this.values={}}async reset(e){return await super.reset(),e===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(e=>e.reset&&e.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:n,input:r}=t;return t.value=t.input=r.slice(0,n)+e+r.slice(n),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:n}=e;return e.value=e.input=n.slice(0,t-1)+n.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:n}=e;return n[t]===void 0?this.alert():(e.value=e.input=`${n}`.slice(0,t)+`${n}`.slice(t+1),this.render())}right(){let e=this.focused;return!e||e.cursor>=e.input.length?this.alert():(e.cursor++,this.render())}left(){let e=this.focused;return!e||e.cursor<=0?this.alert():(e.cursor--,this.render())}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:n}=e;return t&&t.startsWith(n)&&n!==t?(e.value=e.input=t,e.cursor=e.value.length,this.render()):super.next()}prev(){let e=this.focused;return e?e.cursor===0?super.prev():(e.value=e.input=``,e.cursor=0,this.render()):this.alert()}separator(){return``}format(e){return this.state.submitted?``:super.format(e)}pointer(){return``}indicator(e){return e.input?`⦿`:`⊙`}async choiceSeparator(e,t){let n=await this.resolve(e.separator,this.state,e,t)||`:`;return n?` `+this.styles.disabled(n):``}async renderChoice(e,t){await this.onChoice(e,t);let{state:r,styles:a}=this,{cursor:o,initial:s=``,name:c,input:l=``}=e,{muted:u,submitted:d,primary:f,danger:p}=a,m=this.index===t,h=e.validate||(()=>!0),g=await this.choiceSeparator(e,t),_=e.message;this.align===`right`&&(_=_.padStart(this.longest+1,` `)),this.align===`left`&&(_=_.padEnd(this.longest+1,` `));let v=this.values[c]=l||s,ee=l?`success`:`dark`;await h.call(e,v,this.state)!==!0&&(ee=`danger`);let te=a[ee],ne=te(await this.indicator(e,t))+(e.pad||``),re=this.indent(e),ie=()=>[re,ne,_+g,l].filter(Boolean).join(` `);if(r.submitted)return _=n(_),l=d(l),ie();if(e.format)l=await e.format.call(this,l,e,t);else{let e=this.styles.muted;l=i(this,{input:l,initial:s,pos:o,showCursor:m,color:e})}return this.isValue(l)||(l=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[c]=await e.result.call(this,v,e,t)),m&&(_=f(_)),e.error?l+=(l?` `:``)+p(e.error.trim()):e.hint&&(l+=(l?` `:``)+u(e.hint.trim())),ie()}async submit(){return this.value=this.values,super.base.submit.call(this)}}})),fu=p(((e,t)=>{let n=du(),r=()=>{throw Error(`expected prompt to have a custom authenticate method`)},i=(e=r)=>{class t extends n{constructor(e){super(e)}async submit(){this.value=await e.call(this,this.values,this.state),super.base.submit.call(this)}static create(e){return i(e)}}return t};t.exports=i()})),pu=p(((e,t)=>{let n=fu();function r(e,t){return e.username===this.options.username&&e.password===this.options.password}let i=(e=r)=>{let t=[{name:`username`,message:`username`},{name:`password`,message:`password`,format(e){return this.options.showPassword?e:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length))}}];class a extends n.create(e){constructor(e){super({...e,choices:t})}static create(e){return i(e)}}return a};t.exports=i()})),mu=p(((e,t)=>{let n=au(),{isPrimitive:r,hasColor:i}=K();t.exports=class extends n{constructor(e){super(e),this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:t,state:n}=this;return n.submitted?t.success(e):t.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return r(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status===`pending`){let e=await this.element(`hint`);return i(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=[n,await this.message(),this.styles.muted(this.default),r].filter(Boolean).join(` `);this.state.prompt=i;let a=await this.header(),o=this.value=this.cast(e),s=await this.format(o),c=await this.error()||await this.hint(),l=await this.footer();c&&!i.includes(c)&&(s+=` `+c),i+=` `+s,this.clear(t),this.write([a,i,l].filter(Boolean).join(`
94
+ `)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}})),hu=p(((e,t)=>{let n=mu();t.exports=class extends n{constructor(e){super(e),this.default=this.options.default||(this.initial?`(Y/n)`:`(y/N)`)}}})),gu=p(((e,t)=>{let n=cu(),r=du().prototype;t.exports=class extends n{constructor(e){super({...e,multiple:!0}),this.align=[this.options.align,`left`].find(e=>e!=null),this.emptyError=``,this.values={}}dispatch(e,t){let n=this.focused,i=n.parent||{};return!n.editable&&!i.editable&&(e===`a`||e===`i`)?super[e]():r.dispatch.call(this,e,t)}append(e,t){return r.append.call(this,e,t)}delete(e,t){return r.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?r.next.call(this):super.next()}prev(){return this.focused.editable?r.prev.call(this):super.prev()}async indicator(e,t){let n=e.indicator||``,r=e.editable?n:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||``}indent(e){return e.role===`heading`?``:e.editable?` `:` `}async renderChoice(e,t){return e.indent=``,e.editable?r.renderChoice.call(this,e,t):super.renderChoice(e,t)}error(){return``}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!=`function`||t.role===`heading`)continue;let n=t.parent?this.value[t.parent.name]:this.value;if(t.editable?n=t.value===t.name?t.initial||``:t.value:this.isDisabled(t)||(n=t.enabled===!0),e=await t.validate(n,this.state),e!==!0)break}return e!==!0&&(this.state.error=typeof e==`string`?e:`Invalid Input`),e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(e=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role===`heading`){this.value[e.name]={};continue}e.editable?t[e.name]=e.value===e.name?e.initial||``:e.value:this.isDisabled(e)||(t[e.name]=e.enabled===!0)}return this.base.submit.call(this)}}})),_u=p(((e,t)=>{let n=au(),r=Ql(),i=uu(),{isPrimitive:a}=K();t.exports=class extends n{constructor(e){super(e),this.initial=a(this.initial)?String(this.initial):``,this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout===void 0?null:this.options.keypressTimeout}async keypress(e,t=e?r(e,{}):{}){let n=Date.now(),i=n-this.lastKeypress;this.lastKeypress=n;let a=t.name===`return`||t.name===`enter`,o=this.state.prevKeypress,s;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&a){if(i<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||``,this.state.multilineBuffer+=e,s=!0,o=null}return(s||this.options.multiline&&a)&&(!o||o.name!==`return`)?this.append(`
95
+ `,t):super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value=``,this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:n}=this.state;this.input=`${n}`.slice(0,t)+e+`${n}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),n=this.input.slice(e),r=t.split(` `);this.state.clipboard.push(r.pop()),this.input=r.join(` `),this.cursor=this.input.length,this.input+=n,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial==null?``:String(this.initial);if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(e||t):i(this,{input:e,initial:t,pos:this.cursor})}async render(){let e=this.state.size,t=await this.prefix(),n=await this.separator(),r=[t,await this.message(),n].filter(Boolean).join(` `);this.state.prompt=r;let i=await this.header(),a=await this.format(),o=await this.error()||await this.hint(),s=await this.footer();o&&!a.includes(o)&&(a+=` `+o),r+=` `+a,this.clear(e),this.write([i,r,s].filter(Boolean).join(`
96
+ `)),this.restore()}}})),vu=p(((e,t)=>{let n=e=>e.filter((t,n)=>e.lastIndexOf(t)===n),r=e=>n(e).filter(Boolean);t.exports=(e,t={},n=``)=>{let{past:i=[],present:a=``}=t,o,s;switch(e){case`prev`:case`undo`:return o=i.slice(0,i.length-1),s=i[i.length-1]||``,{past:r([n,...o]),present:s};case`next`:case`redo`:return o=i.slice(1),s=i[0]||``,{past:r([...o,n]),present:s};case`save`:return{past:r([...i,n]),present:``};case`remove`:return s=r(i.filter(e=>e!==n)),a=``,s.length&&(a=s.pop()),{past:s,present:a};default:throw Error(`Invalid action: "${e}"`)}}})),yu=p(((e,t)=>{let n=_u(),r=vu();t.exports=class extends n{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let e=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get(`values`)||{past:[],present:e},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){return!this.store||(this.data=r(e,this.data,this.input),!this.data.present)?this.alert():(this.input=this.data.present,this.cursor=this.input.length,this.render())}altUp(){return this.completion(`prev`)}altDown(){return this.completion(`next`)}prev(){return this.save(),super.prev()}save(){this.store&&(this.data=r(`save`,this.data,this.input),this.store.set(`values`,this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}}})),bu=p(((e,t)=>{let n=_u();t.exports=class extends n{format(){return``}}})),xu=p(((e,t)=>{let n=_u();t.exports=class extends n{constructor(e={}){super(e),this.sep=this.options.separator||/, */,this.initial=e.initial||``}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:e=>e;return this.list.map(e).join(`, `)}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);return t===!0?(this.value=this.list,super.submit()):(this.state.error=t,super.submit())}get list(){return this.split()}}})),Su=p(((e,t)=>{let n=cu();t.exports=class extends n{constructor(e){super({...e,multiple:!0})}}})),Cu=p(((e,t)=>{let n=_u();t.exports=class extends n{constructor(e={}){super({style:`number`,...e}),this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay==null?1e3:e.delay,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial==null?``:e.initial,this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){return!/[-+.]/.test(e)||e===`.`&&this.input.includes(`.`)?this.alert(`invalid number`):super.append(e)}number(e){return super.append(e)}next(){return this.input&&this.input!==this.initial||!this.isValue(this.initial)?this.alert():(this.input=this.initial,this.cursor=String(this.initial).length,this.render())}up(e){let t=e||this.minor,n=this.toNumber(this.input);return n>this.max+t?this.alert():(this.input=`${n+t}`,this.render())}down(e){let t=e||this.minor,n=this.toNumber(this.input);return n<this.min-t?this.alert():(this.input=`${n-t}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){return typeof this.options.format==`function`?this.options.format.call(this,e):this.styles.info(e)}toNumber(e=``){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find(e=>this.isValue(e));return this.value=this.toNumber(e||0),super.submit()}}})),wu=p(((e,t)=>{t.exports=Cu()})),Tu=p(((e,t)=>{let n=_u();t.exports=class extends n{constructor(e){super(e),this.cursorShow()}format(e=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length)):``}}})),Eu=p(((e,t)=>{let n=Yl(),r=su(),i=K();t.exports=class extends r{constructor(e={}){super(e),this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||`left`),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
97
+ `;let t=e.startNumber||1;typeof this.scale==`number`&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((e,n)=>({name:n+t})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let e=0;e<this.scale.length;e++)t.scale.push({index:e})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,n){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIndex>=this.scale.length-1?this.alert():(e.scaleIndex++,this.render())}left(){let e=this.focused;return e.scaleIndex<=0?this.alert():(e.scaleIndex--,this.render())}indent(){return``}format(){return this.state.submitted?this.choices.map(e=>this.styles.info(e.index)).join(`, `):``}pointer(){return``}renderScaleKey(){return this.scaleKey===!1||this.state.submitted?``:[``,...this.scale.map(e=>` ${e.name} - ${e.message}`)].map(e=>this.styles.muted(e)).join(`
98
+ `)}renderScaleHeading(e){let t=this.scale.map(e=>e.name);typeof this.options.renderScaleHeading==`function`&&(t=this.options.renderScaleHeading.call(this,e));let n=this.scaleLength-t.join(``).length,r=Math.round(n/(t.length-1)),i=t.map(e=>this.styles.strong(e)).join(` `.repeat(r)),a=` `.repeat(this.widths[0]);return this.margin[3]+a+this.margin[1]+i}scaleIndicator(e,t,n){if(typeof this.options.scaleIndicator==`function`)return this.options.scaleIndicator.call(this,e,t,n);let r=e.scaleIndex===t.index;return t.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(e,t){let n=e.scale.map(n=>this.scaleIndicator(e,n,t)),r=this.term===`Hyper`?``:` `;return n.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let r=this.index===t,a=await this.pointer(e,t),o=await e.hint;o&&!i.hasColor(o)&&(o=this.styles.muted(o));let s=e=>this.margin[3]+e.replace(/\s+$/,``).padEnd(this.widths[0],` `),c=this.newline,l=this.indent(e),u=await this.resolve(e.message,this.state,e,t),d=await this.renderScale(e,t),f=this.margin[1]+this.margin[3];this.scaleLength=n(d).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-f.length);let p=i.wordWrap(u,{width:this.widths[0],newline:c}).split(`
99
+ `).map(e=>s(e)+this.margin[1]);return r&&(d=this.styles.info(d),p=p.map(e=>this.styles.info(e))),p[0]+=d,this.linebreak&&p.push(``),[l+a,p.join(`
100
+ `)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return``;this.tableize();let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e),n=await this.renderScaleHeading();return this.margin[0]+[n,...t.map(e=>e.join(` `))].join(`
101
+ `)}async render(){let{submitted:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=await this.message(),a=``;this.options.promptLine!==!1&&(a=[n,i,r,``].join(` `),this.state.prompt=a);let o=await this.header(),s=await this.format(),c=await this.renderScaleKey(),l=await this.error()||await this.hint(),u=await this.renderChoices(),d=await this.footer(),f=this.emptyError;s&&(a+=s),l&&!a.includes(l)&&(a+=` `+l),e&&!s&&!u.trim()&&this.multiple&&f!=null&&(a+=this.styles.danger(f)),this.clear(t),this.write([o,a,c,u,d].filter(Boolean).join(`
102
+ `)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}})),Du=p(((e,t)=>{let n=Yl(),r=(e=``)=>typeof e==`string`?e.replace(/^['"]|['"]$/g,``):``;var i=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=r(e.initial||this.field.initial||``),this.message=e.message||this.name,this.cursor=0,this.input=``,this.lines=[]}};let a=async(e={},t={},n=e=>e)=>{let r=new Set,a=e.fields||[],o=e.template,s=[],c=[],l=[],u=1;typeof o==`function`&&(o=await o());let d=-1,f=()=>o[++d],p=()=>o[d+1],m=e=>{e.line=u,s.push(e)};for(m({type:`bos`,value:``});d<o.length-1;){let e=f();if(/^[^\S\n ]$/.test(e)){m({type:`text`,value:e});continue}if(e===`
103
+ `){m({type:`newline`,value:e}),u++;continue}if(e===`\\`){e+=f(),m({type:`text`,value:e});continue}if((e===`$`||e===`#`||e===`{`)&&p()===`{`){let o=f();e+=o;let s={type:`template`,open:e,inner:``,close:``,value:e},u;for(;u=f();){if(u===`}`){p()===`}`&&(u+=f()),s.value+=u,s.close=u;break}u===`:`?(s.initial=``,s.key=s.inner):s.initial!==void 0&&(s.initial+=u),s.value+=u,s.inner+=u}s.template=s.open+(s.initial||s.inner)+s.close,s.key=s.key||s.inner,hasOwnProperty.call(t,s.key)&&(s.initial=t[s.key]),s=n(s),m(s),l.push(s.key),r.add(s.key);let d=c.find(e=>e.name===s.key);s.field=a.find(e=>e.name===s.key),d||(d=new i(s),c.push(d)),d.lines.push(s.line-1);continue}let o=s[s.length-1];o.type===`text`&&o.line===u?o.value+=e:m({type:`text`,value:e})}return m({type:`eos`,value:``}),{input:o,tabstops:s,unique:r,keys:l,items:c}};t.exports=async e=>{let t=e.options,r=new Set(t.required===!0?[]:t.required||[]),{tabstops:i,items:s,keys:c}=await a(t,{...t.values,...t.initial}),l=o(`result`,e,t),u=o(`format`,e,t),d=o(`validate`,e,t,!0),f=e.isValue.bind(e);return async(a={},o=!1)=>{let p=0;a.required=r,a.items=s,a.keys=c,a.output=``;let m=async(e,t,n,r)=>{let i=await d(e,t,n,r);return i===!1?`Invalid field `+n.name:i};for(let r of i){let i=r.value,c=r.key;if(r.type!==`template`){i&&(a.output+=i);continue}if(r.type===`template`){let d=s.find(e=>e.name===c);t.required===!0&&a.required.add(d.name);let h=[d.input,a.values[d.value],d.value,i].find(f),g=(d.field||{}).message||r.inner;if(o){let e=await m(a.values[c],a,d,p);if(e&&typeof e==`string`||e===!1){a.invalid.set(c,e);continue}a.invalid.delete(c);let t=await l(a.values[c],a,d,p);a.output+=n(t);continue}d.placeholder=!1;let _=i;i=await u(i,a,d,p),h===i?(a.values[c]=void 0,h=`<${g}>`,i=e.styles.primary(h),d.placeholder=!0,a.required.has(c)&&a.missing.add(g)):(a.values[c]=h,i=e.styles.typing(h),a.missing.delete(g)),a.missing.has(g)&&a.validating&&(i=e.styles.warning(h)),a.invalid.has(c)&&a.validating&&(i=e.styles.danger(h)),p===a.index&&(i=_===i?e.styles.heading(n(i)):e.styles.underline(i)),p++}i&&(a.output+=i)}let h=a.output.split(`
104
+ `).map(e=>` `+e),g=s.length,_=0;for(let t of s)a.invalid.has(t.name)&&t.lines.forEach(e=>{h[e][0]===` `&&(h[e]=a.styles.danger(a.symbols.bullet)+h[e].slice(1))}),e.isValue(a.values[t.name])&&_++;return a.completed=(_/g*100).toFixed(0),a.output=h.join(`
105
+ `),a.output}};function o(e,t,n,r){return(n,i,a,o)=>typeof a.field[e]==`function`?a.field[e].call(t,n,i,a,o):[r,n].find(e=>t.isValue(e))}})),Ou=p(((e,t)=>{let n=Yl(),r=Du(),i=au();t.exports=class extends i{constructor(e){super(e),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await r(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let n=this.getItem();this.input=n.input=`${n.input.slice(0,this.cursor)}${e}${n.input.slice(this.cursor)}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor);this.input=e.input=`${e.input.slice(0,this.cursor-1)}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:n,size:r}=this.state,i=[this.options.newline,`
106
+ `].find(e=>e!=null),a=await this.prefix(),o=await this.separator(),s=[a,await this.message(),o].filter(Boolean).join(` `);this.state.prompt=s;let c=await this.header(),l=await this.error()||``,u=await this.hint()||``,d=n?``:await this.interpolate(this.state),f=this.state.key=t[e]||``,p=await this.format(f),m=await this.footer();p&&(s+=` `+p),u&&!p&&this.state.completed===0&&(s+=` `+u),this.clear(r);let h=[c,s,d,m,l.trim()];this.write(h.filter(Boolean).join(i)),this.restore()}getItem(e){let{items:t,keys:n,index:r}=this.state,i=t.find(e=>e.name===n[r]);return i&&i.input!=null&&(this.input=i.input,this.cursor=i.cursor),i}async submit(){typeof this.interpolate!=`function`&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:r,values:i}=this.state;if(e.size){let t=``;for(let[n,r]of e)t+=`Invalid ${n}: ${r}\n`;return this.state.error=t,super.submit()}return t.size?(this.state.error=`Required: `+[...t.keys()].join(`, `),super.submit()):(this.value={values:i,result:n(r).split(`
107
+ `).map(e=>e.slice(1)).join(`
108
+ `)},super.submit())}}})),ku=p(((e,t)=>{let n=cu();t.exports=class extends n{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,`(Use <shift>+<up/down> to sort)`].find(this.isValue.bind(this))}indicator(){return``}async renderChoice(e,t){let n=await super.renderChoice(e,t),r=this.symbols.identicalTo+` `,i=this.index===t&&this.sorting?this.styles.muted(r):` `;return this.options.drag===!1&&(i=``),this.options.numbered===!0?i+`${t+1} - `+n:i+n}get selected(){return this.choices}submit(){return this.value=this.choices.map(e=>e.value),super.submit()}}})),Au=p(((e,t)=>{let n=su();var r=class extends n{constructor(e={}){if(super(e),this.emptyError=e.emptyError||`No items were selected`,this.term=process.env.TERM_PROGRAM,!this.options.header){let e=[``,`4 - Strongly Agree`,`3 - Agree`,`2 - Neutral`,`1 - Disagree`,`0 - Strongly Disagree`,``];e=e.map(e=>this.styles.muted(e)),this.state.header=e.join(`
109
+ `)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let e of t)e.scale=i(5,this.options),e.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],n=t.selected;return e.scale.forEach(e=>e.selected=!1),t.selected=!n,this.render()}indicator(){return``}pointer(){return``}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIdx>=e.scale.length-1?this.alert():(e.scaleIdx++,this.render())}left(){let e=this.focused;return e.scaleIdx<=0?this.alert():(e.scaleIdx--,this.render())}indent(){return` `}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,r=this.term===`Hyper`,i=r?9:8,a=r?``:` `,o=this.symbols.line.repeat(i),s=` `.repeat(i+(r?0:1)),c=e=>(e?this.styles.success(`◉`):`◯`)+a,l=t+1+`.`,u=n?this.styles.heading:this.styles.noop,d=await this.resolve(e.message,this.state,e,t),f=this.indent(e),p=f+e.scale.map((t,n)=>c(n===e.scaleIdx)).join(o),m=t=>t===e.scaleIdx?u(t):t,h=f+e.scale.map((e,t)=>m(t)).join(s);return n&&(p=this.styles.cyan(p),h=this.styles.cyan(h)),[[l,d].filter(Boolean).join(` `),p,h,` `].filter(Boolean).join(`
110
+ `)}async renderChoices(){if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);return t.length||t.push(this.styles.danger(`No matching choices`)),t.join(`
111
+ `)}format(){return this.state.submitted?this.choices.map(e=>this.styles.info(e.scaleIdx)).join(`, `):``}async render(){let{submitted:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=[n,await this.message(),r].filter(Boolean).join(` `);this.state.prompt=i;let a=await this.header(),o=await this.format(),s=await this.error()||await this.hint(),c=await this.renderChoices(),l=await this.footer();(o||!s)&&(i+=` `+o),s&&!i.includes(s)&&(i+=` `+s),e&&!o&&!c&&this.multiple&&this.type!==`form`&&(i+=this.styles.danger(this.emptyError)),this.clear(t),this.write([i,a,c,l].filter(Boolean).join(`
112
+ `)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function i(e,t={}){if(Array.isArray(t.scale))return t.scale.map(e=>({...e}));let n=[];for(let t=1;t<e+1;t++)n.push({i:t,selected:!1});return n}t.exports=r})),ju=p(((e,t)=>{t.exports=yu()})),Mu=p(((e,t)=>{let n=mu();t.exports=class extends n{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||`no`,this.enabled=this.options.enabled||`yes`,await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e=``,t){switch(e.toLowerCase()){case` `:return this.toggle();case`1`:case`y`:case`t`:return this.enable();case`0`:case`n`:case`f`:return this.disable();default:return this.alert()}}format(){let e=e=>this.styles.primary.underline(e);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(` / `))}async render(){let{size:e}=this.state,t=await this.header(),n=await this.prefix(),r=await this.separator(),i=await this.message(),a=await this.format(),o=await this.error()||await this.hint(),s=await this.footer(),c=[n,i,r,a].join(` `);this.state.prompt=c,o&&!c.includes(o)&&(c+=` `+o),this.clear(e),this.write([t,c,s].filter(Boolean).join(`
113
+ `)),this.write(this.margin[2]),this.restore()}}})),Nu=p(((e,t)=>{let n=cu();t.exports=class extends n{constructor(e){if(super(e),typeof this.options.correctChoice!=`number`||this.options.correctChoice<0)throw Error(`Please specify the index of the correct answer from the list of choices`)}async toChoices(e,t){let n=await super.toChoices(e,t);if(n.length<2)throw Error(`Please give at least two choices to the user`);if(this.options.correctChoice>n.length)throw Error(`Please specify the index of the correct answer from the list of choices`);return n}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}}})),Pu=p((e=>{let t=K(),n=(n,r)=>{t.defineExport(e,n,r),t.defineExport(e,n.toLowerCase(),r)};n(`AutoComplete`,()=>lu()),n(`BasicAuth`,()=>pu()),n(`Confirm`,()=>hu()),n(`Editable`,()=>gu()),n(`Form`,()=>du()),n(`Input`,()=>yu()),n(`Invisible`,()=>bu()),n(`List`,()=>xu()),n(`MultiSelect`,()=>Su()),n(`Numeral`,()=>wu()),n(`Password`,()=>Tu()),n(`Scale`,()=>Eu()),n(`Select`,()=>cu()),n(`Snippet`,()=>Ou()),n(`Sort`,()=>ku()),n(`Survey`,()=>Au()),n(`Text`,()=>ju()),n(`Toggle`,()=>Mu()),n(`Quiz`,()=>Nu())})),Fu=p(((e,t)=>{t.exports={ArrayPrompt:su(),AuthPrompt:fu(),BooleanPrompt:mu(),NumberPrompt:Cu(),StringPrompt:_u()}})),Iu=p(((e,t)=>{let n=g(`assert`),r=g(`events`),i=K();var a=class extends r{constructor(e,t){super(),this.options=i.merge({},e),this.answers={...t}}register(e,t){if(i.isObject(e)){for(let t of Object.keys(e))this.register(t,e[t]);return this}n.equal(typeof t,`function`,`expected a function`);let r=e.toLowerCase();return t.prototype instanceof this.Prompt?this.prompts[r]=t:this.prompts[r]=t(this.Prompt,this),this}async prompt(e=[]){for(let t of[].concat(e))try{typeof t==`function`&&(t=await t.call(this)),await this.ask(i.merge({},this.options,t))}catch(e){return Promise.reject(e)}return this.answers}async ask(e){typeof e==`function`&&(e=await e.call(this));let t=i.merge({},this.options,e),{type:r,name:a}=e,{set:o,get:s}=i;if(typeof r==`function`&&(r=await r.call(this,e,this.answers)),!r)return this.answers[a];r===`number`&&(r=`numeral`),n(this.prompts[r],`Prompt "${r}" is not registered`);let c=new this.prompts[r](t),l=s(this.answers,a);c.state.answers=this.answers,c.enquirer=this,a&&c.on(`submit`,e=>{this.emit(`answer`,a,e,c),o(this.answers,a,e)});let u=c.emit.bind(c);return c.emit=(...e)=>(this.emit.call(this,...e),u(...e)),this.emit(`prompt`,c,this),t.autofill&&l!=null?(c.value=c.input=l,t.autofill===`show`&&await c.submit()):l=c.value=await c.run(),l}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||au()}static get prompts(){return Pu()}static get types(){return Fu()}static get prompt(){let e=(t,...n)=>{let r=new this(...n),i=r.emit.bind(r);return r.emit=(...t)=>(e.emit(...t),i(...t)),r.prompt(t)};return i.mixinEmitter(e,new r),e}};i.mixinEmitter(a,new r);let o=a.prompts;for(let e of Object.keys(o)){let t=e.toLowerCase(),n=t=>new o[e](t).run();a.prompt[t]=n,a[t]=n,a[e]||Reflect.defineProperty(a,e,{get:()=>o[e]})}let s=e=>{i.defineExport(a,e,()=>a.types[e])};s(`ArrayPrompt`),s(`AuthPrompt`),s(`BooleanPrompt`),s(`NumberPrompt`),s(`StringPrompt`),t.exports=a})),Lu=p(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),Ru=h(Iu(),1),q=h(Lu(),1);const zu=Ru.default.prompt;async function Bu(e,t){try{return await zu(e)}catch{return Vu(),t}}function Vu(){process.stdout.write(`${q.default.red(`✖`)} Cancelled\n`),process.exit(1)}async function Hu(e,t=!1){return(await Bu({type:`confirm`,name:`value`,message:e,initial:t},{value:!1})).value}async function Uu(e,t){return(await Bu({type:`input`,name:`value`,message:e,initial:t},{value:``})).value.trim()}async function Wu(e,t){return t.length===0?[]:(await Bu({type:`multiselect`,name:`value`,message:e,choices:t},{value:[]})).value}const J={intro(e){process.stdout.write(`${q.default.bgWhite(q.default.black(` skilless `))}${q.default.gray(` v${e}`)}\n\n`)},info(e){process.stdout.write(`${q.default.blue(`·`)} ${e}\n`)},step(e){process.stdout.write(`${q.default.green(`✓`)} ${e}\n`)},warn(e){process.stdout.write(`${q.default.yellow(`!`)} ${e}\n`)},error(e){process.stderr.write(`${q.default.red(`✖`)} ${e}\n`)},dim(e){process.stdout.write(`${q.default.gray(e)}\n`)},blank(){process.stdout.write(`
114
+ `)}};var Gu=`skilless`,Ku=`Author skills once, sync them everywhere, install them per project.`;const Y=`0.0.1`,qu=Gu,Ju=Ku,Yu=Rs({path:R(),contents:R()}),Xu=Rs({name:R(),contentHash:R(),editedAt:Ds(),updatedAt:Ds()}),Zu=Xu.extend({files:Is(Yu)}),Qu=Rs({bound:Is(R()),unknown:Is(R())}),$u=Rs({error:R(),message:R().optional()});var ed=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async#n(e,t,n,r){let i;try{i=await fetch(`${this.#t}/api/v1${t}`,{method:e,headers:{Authorization:`Bearer ${this.#e}`,...r===void 0?{}:{"Content-Type":`application/json`}},body:r===void 0?void 0:JSON.stringify(r)})}catch(e){throw new V(`Could not reach ${this.#t}.`,{suggestion:`Check your connection, or set SKILLESS_API_URL to point elsewhere.`,cause:e})}if(i.status===401)throw new mc;if(!i.ok){let n=$u.safeParse(await i.json().catch(()=>null));throw new V(n.success?n.data.message??n.data.error:`${e} ${t} failed with ${i.status}.`)}if(i.status===204)return n.parse(void 0);let a=await i.json(),o=n.safeParse(a);if(!o.success)throw new V(`Unexpected response from ${e} ${t}.`,{suggestion:`This is likely a version mismatch — try updating skilless.`});return o.data}async listSkills(){return await this.#n(`GET`,`/skills`,Is(Xu))}async getSkill(e){return await this.#n(`GET`,`/skills/${encodeURIComponent(e)}`,Zu.nullable())}async putSkill(e,t,n){return await this.#n(`PUT`,`/skills/${encodeURIComponent(e)}`,Xu,{files:t,editedAt:n})}async deleteSkill(e){await this.#n(`DELETE`,`/skills/${encodeURIComponent(e)}`,Ms())}async getBindings(e){return await this.#n(`GET`,`/projects/skills?key=${encodeURIComponent(e)}`,Is(Zu))}async setBindings(e,t){return await this.#n(`PUT`,`/projects/skills`,Qu,{key:e,names:t})}};function td(){return process.env.SKILLESS_TOKEN||Yc(el,{}).token}function nd(e){Xc(el,{token:e},384)}function rd(){W(el)}function id(){return(process.env.SKILLESS_API_URL??`https://skilless.dev`).replace(/\/$/,``)}const ad=`SKILLESS_TRACE`,X=Rs({cwd:R()}),Z={cwd:new de(`--cwd <path>`,`The current working directory.`).default(process.cwd()),yes:new de(`-y, --yes`,`Skip confirmation prompts.`).default(!1),project:new de(`--project <key>`,`Override the project key. Defaults to the normalized git remote.`)};function Q(e,t){let n=e.safeParse(t);return n.success?n.data:od(new V(`Invalid options.`,{suggestion:n.error.issues.map(e=>` ${e.message}`).join(`
115
+ `)}))}function od(e){process.env[ad]===`1`?console.trace(e):J.error(q.default.red(e.toString())),process.exit(1)}async function $(e){try{return await e()}catch(e){return e instanceof V?od(e):od(new V(e instanceof Error?e.message:String(e),{suggestion:`Run with ${ad}=1 for a stack trace.`,cause:e}))}}function sd(){let e=td();if(!e)throw new mc;return new ed(e,id())}function cd(e,t){if(t)return t;let n=ul(e);if(!n)throw new hc;return n}const ld=X.extend({project:R().optional(),copy:B().optional()}),ud=new b(`add`).description(`Add skills from your library to this project.`).argument(`[skills...]`,`Skills to add. Omit to pick from a list.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(ld,t);J.intro(Y),await $(async()=>{let t=sd(),r=cd(n.cwd,n.project),i=await t.listSkills(),a=new Set((await t.getBindings(r)).map(e=>e.name)),o=e;if(o.length===0){let e=i.filter(e=>!a.has(e.name));if(e.length===0){J.info(`Every skill in your library is already in this project.`);return}if(o=await Wu(`Add to ${r}`,e.map(e=>({name:e.name}))),o.length===0){J.info(`Nothing selected.`);return}}let s=new Set(i.map(e=>e.name)),c=o.filter(e=>!s.has(e));if(c.length>0)throw new V(`Not in your library: ${c.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});let l=await t.setBindings(r,[...new Set([...a,...o])]),u=await Gl(Bl(n.cwd),await t.getBindings(r),{copy:n.copy});for(let e of o)l.bound.includes(e)&&J.step(`Added \`${e}\`.`);for(let e of u.skipped)J.warn(e.reason===`tracked`?`\`${e.name}\` is tracked by git here — left alone.`:`\`${e.name}\` already exists here and is not ours — left alone.`)})});function dd(e){let t=process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`;try{n(t,[e],{stdio:`ignore`,detached:!0,shell:process.platform===`win32`}).unref()}catch{}}async function fd(){let e=a.randomBytes(16).toString(`hex`),t=id(),n=new URL(t).origin,r={"Access-Control-Allow-Origin":n,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`,"Access-Control-Allow-Private-Network":`true`},i,s=new Promise((e,t)=>{i={resolve:e,reject:t}}),c=o.createServer((t,n)=>{if(t.method===`OPTIONS`){n.writeHead(204,r),n.end();return}if(t.method!==`POST`){n.writeHead(405,r),n.end();return}let a=``;t.on(`data`,e=>{a+=e}),t.on(`end`,()=>{let t;try{t=JSON.parse(a)}catch{n.writeHead(400,r),n.end();return}if(t.state!==e||!t.token){n.writeHead(400,r),n.end();return}n.writeHead(200,{...r,"Content-Type":`application/json`}),n.end(JSON.stringify({ok:!0})),i.resolve(t.token)})}),l=setTimeout(()=>{i.reject(new V(`Timed out waiting for sign in.`,{suggestion:"Run `skilless auth` again, or paste a token with `skilless auth --token <token>`."}))},3e5);try{await new Promise((e,t)=>{c.once(`error`,t),c.listen(0,`127.0.0.1`,e)});let{port:n}=c.address(),r=`${t}/cli/auth?port=${n}&state=${e}`;J.info(`Opening your browser to sign in…`),J.dim(r),J.blank(),dd(r),nd(await s)}finally{clearTimeout(l),c.close()}}const pd=X.extend({logout:B(),token:R().optional()}),md=new b(`auth`).description(`Sign in to skilless.dev, or sign out.`).addOption(new de(`--logout`,`Sign out on this machine.`).default(!1)).addOption(new de(`--token <token>`,`Save a token directly, for when the browser flow cannot reach localhost.`)).addOption(Z.cwd).action(async e=>{let t=Q(pd,e);J.intro(Y),await $(async()=>{if(t.logout){if(!td()){J.info(`You were not signed in.`);return}rd(),J.step(`Signed out.`);return}if(t.token){nd(t.token),J.step(`Token saved.`);return}await fd(),J.step(`Signed in.`)})}),hd=X.extend({description:R().optional(),project:R().optional()}),gd=new b(`create`).description(`Create a skill, add it to this project, and print the path to edit it.`).argument(`<name>`,`The name of the skill.`).option(`-d, --description <description>`,`What the skill does, for the frontmatter.`).addOption(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(hd,t);J.intro(Y),await $(async()=>{xl(e);let t=sd();if(Dl(e))throw new V(`\`${e}\` already exists in your library.`,{suggestion:`Edit it at ${G(e)}`});if(await t.getSkill(e))throw new V(`\`${e}\` already exists in your library.`,{suggestion:"Run `skilless sync` to bring it down to this machine."});wl(e,Ol(e,n.description??await Uu(`What does this skill do?`,``)));let r=Cl(G(e),e);await t.putSkill(e,r.files,r.editedAt);let i=Hl();i.skills[e]={contentHash:r.contentHash,editedAt:r.editedAt,syncedAt:Date.now()},Ul(i),J.step(`Created \`${e}\`.`);let a=n.project??ul(n.cwd);if(a){let i=(await t.getBindings(a)).map(e=>e.name);await t.setBindings(a,[...new Set([...i,e])]),await Gl(Bl(n.cwd),[{...r,updatedAt:Date.now(),files:r.files}]),J.step(`Added to ${a}.`)}else J.warn(`No git remote here, so it was not added to a project.`);J.blank(),J.dim(`Edit it at ${H.join(G(e),`SKILL.md`)}`),J.dim("Run `skilless sync` when you are happy with it.")})}),_d=X.extend({yes:B(),overwrite:B()});function vd(e){return r.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(t=>({name:t.name,dir:H.join(e,t.name)})).filter(e=>U(H.join(e.dir,gl))).sort((e,t)=>e.name.localeCompare(t.name))}const yd=new b(`import`).description(`Import a directory of existing skills into your library.`).argument(`<dir>`,`A directory whose subdirectories each contain a SKILL.md.`).option(`--overwrite`,`Replace skills that already exist.`,!1).addOption(Z.yes).addOption(Z.cwd).action(async(e,t)=>{let n=Q(_d,t);J.intro(Y),await $(async()=>{let t=sd(),r=H.resolve(n.cwd,e);if(!U(r))throw new V(`${r} does not exist.`);let i=vd(r);if(i.length===0)throw new V(`No skills found in ${r}.`,{suggestion:`A skill is a directory containing a ${gl}.`});let a=new Set((await t.listSkills()).map(e=>e.name)),o=[],s=[];for(let e of i){if(!bl(e.name)){s.push({name:e.name,reason:`invalid name`});continue}if(a.has(e.name)&&!n.overwrite){s.push({name:e.name,reason:`already in your library`});continue}try{o.push(Cl(e.dir,e.name))}catch(t){s.push({name:e.name,reason:t instanceof Error?t.message:`unreadable`})}}for(let e of s)J.warn(`${e.name} — ${e.reason}`);if(o.length===0){J.info(`Nothing to import.`);return}if(J.blank(),J.info(`Importing: ${o.map(e=>e.name).join(`, `)}`),!(n.yes||await Hu(`Import ${o.length} skill(s)?`,!0)))return;let c=Hl();for(let e of o)wl(e.name,e.files,e.editedAt),await t.putSkill(e.name,e.files,e.editedAt),c.skills[e.name]={contentHash:e.contentHash,editedAt:e.editedAt,syncedAt:Date.now()},J.step(`Imported \`${e.name}\`.`);Ul(c),J.blank(),J.dim("Add them to a project with `skilless add <skill>`.")})}),bd=X.extend({}),xd=new b(`init`).description(`Create the local skilless directory and sign in.`).addOption(Z.cwd).action(async e=>{Q(bd,e),J.intro(Y),await $(async()=>{let e=!U($c);if(Kc($c),J.step(`${e?`Created`:`Found`} your library at ${Qc}`),td()&&!await Hu(`You are already signed in. Sign in again?`,!1)){J.blank(),J.dim("Nothing to do. Try `skilless create <name>`.");return}await fd(),J.step(`Signed in.`),J.blank(),J.dim("Next: `skilless create <name>` or `skilless add <skill>`.")})}),Sd=X.extend({project:R().optional(),copy:B().optional()}),Cd=new b(`install`).description(`Install every skill added to this project.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(Z.project).addOption(Z.cwd).action(async e=>{let t=Q(Sd,e);J.intro(Y),await $(async()=>{let e=sd(),n=cd(t.cwd,t.project),r=Bl(t.cwd),i=zl(r);for(let e of i)J.dim(`pruned ${e} (no longer in your library)`);let a=await e.getBindings(n);if(a.length===0){J.info(`No skills added to ${n} yet.`),J.dim("Add one with `skilless add <skill>`.");return}let o=await Gl(r,a,{copy:t.copy});for(let e of o.fetched)J.dim(`fetched ${e}`);for(let e of o.written)J.step(`Installed \`${e}\`.`);for(let e of o.skipped)J.warn(e.reason===`tracked`?`\`${e.name}\` is tracked by git here — left alone.`:`\`${e.name}\` already exists here and is not ours — left alone.`);J.blank(),J.dim(Wl(t.copy)?`Wrote real files.`:`Linked from your library.`)})}),wd=X.extend({project:Bs([B(),R()]).optional()}),Td=new b(`list`).description(`List your skills, or the ones added to this project.`).option(`-p, --project [key]`,`List this project’s skills instead of your library.`).addOption(Z.cwd).action(async e=>{let t=Q(wd,e);J.intro(Y),await $(async()=>{let e=sd();if(t.project!==void 0){let n=cd(t.cwd,typeof t.project==`string`?t.project:void 0),r=await e.getBindings(n);if(J.info(`${q.default.bold(n)}`),J.blank(),r.length===0){J.dim("No skills added yet. Try `skilless add <skill>`.");return}for(let e of r)J.dim(` ${e.name}`);return}let n=await e.listSkills();if(n.length===0){J.dim("Your library is empty. Try `skilless create <name>`.");return}for(let e of n){let t=new Date(e.updatedAt).toISOString().slice(0,10);J.dim(` ${e.name.padEnd(28)} ${q.default.gray(t)}`)}})}),Ed=X.extend({yes:B()}),Dd=new b(`remove`).description(`Delete skills from your library, everywhere.`).argument(`<skills...>`,`Skills to delete.`).addOption(Z.yes).addOption(Z.cwd).action(async(e,t)=>{let n=Q(Ed,t);J.intro(Y),await $(async()=>{let t=sd();if(J.warn(`This deletes ${e.join(`, `)} from every project, on every machine.`),!(n.yes||await Hu(`Delete ${e.length} skill(s)?`,!1))){J.info(`Nothing was deleted.`);return}let r=Hl(),i=Bl(n.cwd);for(let n of e)await t.deleteSkill(n),W(G(n)),delete r.skills[n],J.step(`Deleted \`${n}\`.`);Ul(r),Rl(i,e),J.blank(),J.dim("Other checkouts will clean up on their next `skilless install`."),J.dim(`Restore within 30 days at skilless.dev.`)})});function Od(e,t,n,r){let i=[...new Set([...e.keys(),...t.keys()])].sort(),a=[];for(let o of i){let i=e.get(o),s=t.get(o),c=n.skills[o];if(i&&s){if(i.contentHash===s.contentHash){a.push({type:`noop`,name:o});continue}let e=!c||c.contentHash!==i.contentHash,t=!c||c.contentHash!==s.contentHash;if(e&&!t)a.push({type:`push`,name:o});else if(!e&&t)a.push({type:`pull`,name:o});else{let e=r??(i.editedAt>=s.editedAt?`push`:`pull`);a.push({type:e===`push`?`conflict-push`:`conflict-pull`,name:o})}continue}if(i&&!s){a.push({type:c?`delete-local`:`push`,name:o});continue}!i&&s&&a.push({type:c?`delete-remote`:`pull`,name:o})}return a}function kd(e,t,n){let r=new Date().toISOString().replace(/[:.]/g,`-`),i=H.join(nl,e,`${r}-${t===`push`?`remote`:`local`}`);for(let e of n)Jc(H.join(i,e.path),e.contents);return i}async function Ad(e,t,n){let r={actions:[],conflicts:[],skipped:[]},i=Date.now();for(let a of t){let{name:t}=a,o=n.local.get(t);switch(a.type){case`noop`:o&&(n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i});break;case`push`:case`conflict-push`:if(!o)break;if(a.type===`conflict-push`){let n=await e.getSkill(t);n&&r.conflicts.push({name:t,kept:`push`,stashedAt:kd(t,`push`,n.files)})}await e.putSkill(t,o.files,o.editedAt),n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i};break;case`pull`:case`conflict-pull`:{let s=await e.getSkill(t);if(!s)break;a.type===`conflict-pull`&&o&&r.conflicts.push({name:t,kept:`pull`,stashedAt:kd(t,`pull`,o.files)}),wl(t,s.files,s.editedAt),n.state.skills[t]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i};break}case`delete-local`:if(!(n.yes||await Hu(`Delete \`${t}\`? It was removed elsewhere.`,!0))){r.skipped.push(t);continue}W(G(t)),delete n.state.skills[t];break;case`delete-remote`:if(!(n.yes||await Hu(`Delete \`${t}\` everywhere? It was removed here.`,!0))){r.skipped.push(t);continue}await e.deleteSkill(t),delete n.state.skills[t];break}r.actions.push(a)}return r}function jd(e){switch(e.type){case`push`:return`pushed ${e.name}`;case`pull`:return`pulled ${e.name}`;case`conflict-push`:return`${e.name} — kept your local copy`;case`conflict-pull`:return`${e.name} — kept the remote copy`;case`delete-local`:return`deleted ${e.name} locally`;case`delete-remote`:return`deleted ${e.name} everywhere`;default:return null}}const Md=X.extend({yes:B(),push:B().optional(),pull:B().optional()}),Nd=new b(`sync`).description(`Sync your library with skilless.dev, in both directions.`).option(`--push`,`On a conflict, keep the local copy.`).option(`--pull`,`On a conflict, keep the remote copy.`).addOption(Z.yes).addOption(Z.cwd).action(async e=>{let t=Q(Md,e);J.intro(Y),await $(async()=>{let e=sd(),n=new Map(El().map(e=>[e.name,e])),r=new Map((await e.listSkills()).map(e=>[e.name,e])),i=Hl(),a=await Ad(e,Od(n,r,i,t.push?`push`:t.pull?`pull`:void 0),{local:n,state:i,yes:t.yes});Ul(i);let o=a.actions.map(jd).filter(e=>e!==null);if(o.length===0){J.info(`Everything is already in sync.`);return}for(let e of o)J.step(e);if(a.conflicts.length>0){J.blank(),J.warn(`${a.conflicts.length} conflict(s) resolved by last write. Losing copies kept:`);for(let e of a.conflicts)J.dim(` ${e.stashedAt}`)}a.skipped.length>0&&(J.blank(),J.dim(`Skipped: ${a.skipped.join(`, `)}`))})});ie.name(qu).description(Ju).version(Y).addCommand(xd).addCommand(md).addCommand(gd).addCommand(ud).addCommand(Dd).addCommand(Cd).addCommand(Nd).addCommand(yd).addCommand(Td).parse();export{};
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "skilless",
3
+ "description": "Author skills once, sync them everywhere, install them per project.",
4
+ "version": "0.0.1",
5
+ "license": "MIT",
6
+ "homepage": "https://skilless.dev",
7
+ "author": {
8
+ "name": "Aidan Bleser",
9
+ "url": "https://github.com/ieedan"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/ieedan/skilless",
14
+ "directory": "packages/skilless"
15
+ },
16
+ "keywords": [
17
+ "skills",
18
+ "agents",
19
+ "claude",
20
+ "ai",
21
+ "cli"
22
+ ],
23
+ "type": "module",
24
+ "bin": "./dist/bin.mjs",
25
+ "files": [
26
+ "dist/**/*",
27
+ "!dist/**/*.map"
28
+ ],
29
+ "engines": {
30
+ "node": ">=22"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^26.1.0",
34
+ "commander": "^14.0.3",
35
+ "enquirer": "^2.4.1",
36
+ "pathe": "^2.0.3",
37
+ "picocolors": "^1.1.1",
38
+ "tsdown": "0.19.0-beta.3",
39
+ "typescript": "^5.9.3",
40
+ "vitest": "^4.0.18",
41
+ "zod": "^4.4.3"
42
+ },
43
+ "scripts": {
44
+ "start": "node ./dist/bin.mjs",
45
+ "build": "tsdown",
46
+ "dev": "tsdown --watch",
47
+ "check": "tsc --noEmit",
48
+ "test": "vitest run"
49
+ }
50
+ }