@storybook/core
Version:
Storybook framework-agnostic API
1,446 lines (1,415 loc) • 678 kB
JavaScript
"use strict";
var ov = Object.create;
var Wr = Object.defineProperty;
var uv = Object.getOwnPropertyDescriptor;
var av = Object.getOwnPropertyNames;
var lv = Object.getPrototypeOf, fv = Object.prototype.hasOwnProperty;
var n = (e, t) => Wr(e, "name", { value: t, configurable: !0 });
var b = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), hv = (e, t) => {
for (var r in t)
Wr(e, r, { get: t[r], enumerable: !0 });
}, pf = (e, t, r, i) => {
if (t && typeof t == "object" || typeof t == "function")
for (let s of av(t))
!fv.call(e, s) && s !== r && Wr(e, s, { get: () => t[s], enumerable: !(i = uv(t, s)) || i.enumerable });
return e;
};
var Y = (e, t, r) => (r = e != null ? ov(lv(e)) : {}, pf(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
t || !e || !e.__esModule ? Wr(r, "default", { value: e, enumerable: !0 }) : r,
e
)), cv = (e) => pf(Wr({}, "__esModule", { value: !0 }), e);
// ../node_modules/prompts/node_modules/kleur/index.js
var ue = b((A8, _f) => {
"use strict";
var { FORCE_COLOR: yv, NODE_DISABLE_COLORS: bv, TERM: vv } = process.env, G = {
enabled: !bv && vv !== "dumb" && yv !== "0",
// modifiers
reset: K(0, 0),
bold: K(1, 22),
dim: K(2, 22),
italic: K(3, 23),
underline: K(4, 24),
inverse: K(7, 27),
hidden: K(8, 28),
strikethrough: K(9, 29),
// colors
black: K(30, 39),
red: K(31, 39),
green: K(32, 39),
yellow: K(33, 39),
blue: K(34, 39),
magenta: K(35, 39),
cyan: K(36, 39),
white: K(37, 39),
gray: K(90, 39),
grey: K(90, 39),
// background colors
bgBlack: K(40, 49),
bgRed: K(41, 49),
bgGreen: K(42, 49),
bgYellow: K(43, 49),
bgBlue: K(44, 49),
bgMagenta: K(45, 49),
bgCyan: K(46, 49),
bgWhite: K(47, 49)
};
function wf(e, t) {
let r = 0, i, s = "", o = "";
for (; r < e.length; r++)
i = e[r], s += i.open, o += i.close, t.includes(i.close) && (t = t.replace(i.rgx, i.close + i.open));
return s + t + o;
}
n(wf, "run");
function wv(e, t) {
let r = { has: e, keys: t };
return r.reset = G.reset.bind(r), r.bold = G.bold.bind(r), r.dim = G.dim.bind(r), r.italic = G.italic.bind(r), r.underline = G.underline.
bind(r), r.inverse = G.inverse.bind(r), r.hidden = G.hidden.bind(r), r.strikethrough = G.strikethrough.bind(r), r.black = G.black.bind(r),
r.red = G.red.bind(r), r.green = G.green.bind(r), r.yellow = G.yellow.bind(r), r.blue = G.blue.bind(r), r.magenta = G.magenta.bind(r), r.
cyan = G.cyan.bind(r), r.white = G.white.bind(r), r.gray = G.gray.bind(r), r.grey = G.grey.bind(r), r.bgBlack = G.bgBlack.bind(r), r.bgRed =
G.bgRed.bind(r), r.bgGreen = G.bgGreen.bind(r), r.bgYellow = G.bgYellow.bind(r), r.bgBlue = G.bgBlue.bind(r), r.bgMagenta = G.bgMagenta.
bind(r), r.bgCyan = G.bgCyan.bind(r), r.bgWhite = G.bgWhite.bind(r), r;
}
n(wv, "chain");
function K(e, t) {
let r = {
open: `\x1B[${e}m`,
close: `\x1B[${t}m`,
rgx: new RegExp(`\\x1b\\[${t}m`, "g")
};
return function(i) {
return this !== void 0 && this.has !== void 0 ? (this.has.includes(e) || (this.has.push(e), this.keys.push(r)), i === void 0 ? this : G.
enabled ? wf(this.keys, i + "") : i + "") : i === void 0 ? wv([e], [r]) : G.enabled ? wf([r], i + "") : i + "";
};
}
n(K, "init");
_f.exports = G;
});
// ../node_modules/prompts/dist/util/action.js
var Cf = b((R8, Ef) => {
"use strict";
Ef.exports = (e, t) => {
if (!(e.meta && e.name !== "escape")) {
if (e.ctrl) {
if (e.name === "a") return "first";
if (e.name === "c" || e.name === "d") return "abort";
if (e.name === "e") return "last";
if (e.name === "g") return "reset";
}
if (t) {
if (e.name === "j") return "down";
if (e.name === "k") return "up";
}
return e.name === "return" || e.name === "enter" ? "submit" : e.name === "backspace" ? "delete" : e.name === "delete" ? "deleteForward" :
e.name === "abort" ? "abort" : e.name === "escape" ? "exit" : e.name === "tab" ? "next" : e.name === "pagedown" ? "nextPage" : e.name ===
"pageup" ? "prevPage" : e.name === "home" ? "home" : e.name === "end" ? "end" : e.name === "up" ? "up" : e.name === "down" ? "down" : e.
name === "right" ? "right" : e.name === "left" ? "left" : !1;
}
};
});
// ../node_modules/prompts/dist/util/strip.js
var on = b((B8, Ff) => {
"use strict";
Ff.exports = (e) => {
let t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"), r = new RegExp(t, "g");
return typeof e == "string" ? e.replace(r, "") : e;
};
});
// ../node_modules/sisteransi/src/index.js
var le = b((k8, xf) => {
"use strict";
var uo = "\x1B", ae = `${uo}[`, _v = "\x07", ao = {
to(e, t) {
return t ? `${ae}${t + 1};${e + 1}H` : `${ae}${e + 1}G`;
},
move(e, t) {
let r = "";
return e < 0 ? r += `${ae}${-e}D` : e > 0 && (r += `${ae}${e}C`), t < 0 ? r += `${ae}${-t}A` : t > 0 && (r += `${ae}${t}B`), r;
},
up: /* @__PURE__ */ n((e = 1) => `${ae}${e}A`, "up"),
down: /* @__PURE__ */ n((e = 1) => `${ae}${e}B`, "down"),
forward: /* @__PURE__ */ n((e = 1) => `${ae}${e}C`, "forward"),
backward: /* @__PURE__ */ n((e = 1) => `${ae}${e}D`, "backward"),
nextLine: /* @__PURE__ */ n((e = 1) => `${ae}E`.repeat(e), "nextLine"),
prevLine: /* @__PURE__ */ n((e = 1) => `${ae}F`.repeat(e), "prevLine"),
left: `${ae}G`,
hide: `${ae}?25l`,
show: `${ae}?25h`,
save: `${uo}7`,
restore: `${uo}8`
}, Ev = {
up: /* @__PURE__ */ n((e = 1) => `${ae}S`.repeat(e), "up"),
down: /* @__PURE__ */ n((e = 1) => `${ae}T`.repeat(e), "down")
}, Cv = {
screen: `${ae}2J`,
up: /* @__PURE__ */ n((e = 1) => `${ae}1J`.repeat(e), "up"),
down: /* @__PURE__ */ n((e = 1) => `${ae}J`.repeat(e), "down"),
line: `${ae}2K`,
lineEnd: `${ae}K`,
lineStart: `${ae}1K`,
lines(e) {
let t = "";
for (let r = 0; r < e; r++)
t += this.line + (r < e - 1 ? ao.up() : "");
return e && (t += ao.left), t;
}
};
xf.exports = { cursor: ao, scroll: Ev, erase: Cv, beep: _v };
});
// ../node_modules/prompts/dist/util/clear.js
var Bf = b((P8, Rf) => {
"use strict";
function Fv(e, t) {
var r = typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
if (!r) {
if (Array.isArray(e) || (r = xv(e)) || t && e && typeof e.length == "number") {
r && (e = r);
var i = 0, s = /* @__PURE__ */ n(function() {
}, "F");
return { s, n: /* @__PURE__ */ n(function() {
return i >= e.length ? { done: !0 } : { done: !1, value: e[i++] };
}, "n"), e: /* @__PURE__ */ n(function(f) {
throw f;
}, "e"), f: s };
}
throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var o = !0, u = !1, a;
return { s: /* @__PURE__ */ n(function() {
r = r.call(e);
}, "s"), n: /* @__PURE__ */ n(function() {
var f = r.next();
return o = f.done, f;
}, "n"), e: /* @__PURE__ */ n(function(f) {
u = !0, a = f;
}, "e"), f: /* @__PURE__ */ n(function() {
try {
!o && r.return != null && r.return();
} finally {
if (u) throw a;
}
}, "f") };
}
n(Fv, "_createForOfIteratorHelper");
function xv(e, t) {
if (e) {
if (typeof e == "string") return Sf(e, t);
var r = Object.prototype.toString.call(e).slice(8, -1);
if (r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set") return Array.from(e);
if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return Sf(e, t);
}
}
n(xv, "_unsupportedIterableToArray");
function Sf(e, t) {
(t == null || t > e.length) && (t = e.length);
for (var r = 0, i = new Array(t); r < t; r++) i[r] = e[r];
return i;
}
n(Sf, "_arrayLikeToArray");
var Sv = on(), Tf = le(), Af = Tf.erase, Av = Tf.cursor, Tv = /* @__PURE__ */ n((e) => [...Sv(e)].length, "width");
Rf.exports = function(e, t) {
if (!t) return Af.line + Av.to(0);
let r = 0, i = e.split(/\r?\n/);
var s = Fv(i), o;
try {
for (s.s(); !(o = s.n()).done; ) {
let u = o.value;
r += 1 + Math.floor(Math.max(Tv(u) - 1, 0) / t);
}
} catch (u) {
s.e(u);
} finally {
s.f();
}
return Af.lines(r);
};
});
// ../node_modules/prompts/dist/util/figures.js
var lo = b((M8, kf) => {
"use strict";
var $r = {
arrowUp: "\u2191",
arrowDown: "\u2193",
arrowLeft: "\u2190",
arrowRight: "\u2192",
radioOn: "\u25C9",
radioOff: "\u25EF",
tick: "\u2714",
cross: "\u2716",
ellipsis: "\u2026",
pointerSmall: "\u203A",
line: "\u2500",
pointer: "\u276F"
}, Rv = {
arrowUp: $r.arrowUp,
arrowDown: $r.arrowDown,
arrowLeft: $r.arrowLeft,
arrowRight: $r.arrowRight,
radioOn: "(*)",
radioOff: "( )",
tick: "\u221A",
cross: "\xD7",
ellipsis: "...",
pointerSmall: "\xBB",
line: "\u2500",
pointer: ">"
}, Bv = process.platform === "win32" ? Rv : $r;
kf.exports = Bv;
});
// ../node_modules/prompts/dist/util/style.js
var Pf = b((j8, Of) => {
"use strict";
var or = ue(), jt = lo(), fo = Object.freeze({
password: {
scale: 1,
render: /* @__PURE__ */ n((e) => "*".repeat(e.length), "render")
},
emoji: {
scale: 2,
render: /* @__PURE__ */ n((e) => "\u{1F603}".repeat(e.length), "render")
},
invisible: {
scale: 0,
render: /* @__PURE__ */ n((e) => "", "render")
},
default: {
scale: 1,
render: /* @__PURE__ */ n((e) => `${e}`, "render")
}
}), kv = /* @__PURE__ */ n((e) => fo[e] || fo.default, "render"), zr = Object.freeze({
aborted: or.red(jt.cross),
done: or.green(jt.tick),
exited: or.yellow(jt.cross),
default: or.cyan("?")
}), Ov = /* @__PURE__ */ n((e, t, r) => t ? zr.aborted : r ? zr.exited : e ? zr.done : zr.default, "symbol"), Pv = /* @__PURE__ */ n((e) => or.
gray(e ? jt.ellipsis : jt.pointerSmall), "delimiter"), qv = /* @__PURE__ */ n((e, t) => or.gray(e ? t ? jt.pointerSmall : "+" : jt.line), "\
item");
Of.exports = {
styles: fo,
render: kv,
symbols: zr,
symbol: Ov,
delimiter: Pv,
item: qv
};
});
// ../node_modules/prompts/dist/util/lines.js
var Mf = b((L8, qf) => {
"use strict";
var Mv = on();
qf.exports = function(e, t) {
let r = String(Mv(e) || "").split(/\r?\n/);
return t ? r.map((i) => Math.ceil(i.length / t)).reduce((i, s) => i + s) : r.length;
};
});
// ../node_modules/prompts/dist/util/wrap.js
var If = b((N8, jf) => {
"use strict";
jf.exports = (e, t = {}) => {
let r = Number.isSafeInteger(parseInt(t.margin)) ? new Array(parseInt(t.margin)).fill(" ").join("") : t.margin || "", i = t.width;
return (e || "").split(/\r?\n/g).map((s) => s.split(/\s+/g).reduce((o, u) => (u.length + r.length >= i || o[o.length - 1].length + u.length +
1 < i ? o[o.length - 1] += ` ${u}` : o.push(`${r}${u}`), o), [r]).join(`
`)).join(`
`);
};
});
// ../node_modules/prompts/dist/util/entriesToDisplay.js
var Nf = b((U8, Lf) => {
"use strict";
Lf.exports = (e, t, r) => {
r = r || t;
let i = Math.min(t - r, e - Math.floor(r / 2));
i < 0 && (i = 0);
let s = Math.min(i + r, t);
return {
startIndex: i,
endIndex: s
};
};
});
// ../node_modules/prompts/dist/util/index.js
var je = b((H8, Uf) => {
"use strict";
Uf.exports = {
action: Cf(),
clear: Bf(),
style: Pf(),
strip: on(),
figures: lo(),
lines: Mf(),
wrap: If(),
entriesToDisplay: Nf()
};
});
// ../node_modules/prompts/dist/elements/prompt.js
var tt = b((W8, $f) => {
"use strict";
var Hf = require("readline"), jv = je(), Iv = jv.action, Lv = require("events"), Wf = le(), Nv = Wf.beep, Uv = Wf.cursor, Hv = ue(), ho = class extends Lv {
static {
n(this, "Prompt");
}
constructor(t = {}) {
super(), this.firstRender = !0, this.in = t.stdin || process.stdin, this.out = t.stdout || process.stdout, this.onRender = (t.onRender ||
(() => {
})).bind(this);
let r = Hf.createInterface({
input: this.in,
escapeCodeTimeout: 50
});
Hf.emitKeypressEvents(this.in, r), this.in.isTTY && this.in.setRawMode(!0);
let i = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1, s = /* @__PURE__ */ n((o, u) => {
let a = Iv(u, i);
a === !1 ? this._ && this._(o, u) : typeof this[a] == "function" ? this[a](u) : this.bell();
}, "keypress");
this.close = () => {
this.out.write(Uv.show), this.in.removeListener("keypress", s), this.in.isTTY && this.in.setRawMode(!1), r.close(), this.emit(this.aborted ?
"abort" : this.exited ? "exit" : "submit", this.value), this.closed = !0;
}, this.in.on("keypress", s);
}
fire() {
this.emit("state", {
value: this.value,
aborted: !!this.aborted,
exited: !!this.exited
});
}
bell() {
this.out.write(Nv);
}
render() {
this.onRender(Hv), this.firstRender && (this.firstRender = !1);
}
};
$f.exports = ho;
});
// ../node_modules/prompts/dist/elements/text.js
var Jf = b((z8, Yf) => {
"use strict";
function zf(e, t, r, i, s, o, u) {
try {
var a = e[o](u), l = a.value;
} catch (f) {
r(f);
return;
}
a.done ? t(l) : Promise.resolve(l).then(i, s);
}
n(zf, "asyncGeneratorStep");
function Vf(e) {
return function() {
var t = this, r = arguments;
return new Promise(function(i, s) {
var o = e.apply(t, r);
function u(l) {
zf(o, i, s, u, a, "next", l);
}
n(u, "_next");
function a(l) {
zf(o, i, s, u, a, "throw", l);
}
n(a, "_throw"), u(void 0);
});
};
}
n(Vf, "_asyncToGenerator");
var un = ue(), Wv = tt(), Gf = le(), $v = Gf.erase, Vr = Gf.cursor, an = je(), co = an.style, po = an.clear, zv = an.lines, Vv = an.figures,
Do = class extends Wv {
static {
n(this, "TextPrompt");
}
constructor(t = {}) {
super(t), this.transform = co.render(t.style), this.scale = this.transform.scale, this.msg = t.message, this.initial = t.initial || "",
this.validator = t.validate || (() => !0), this.value = "", this.errorMsg = t.error || "Please Enter A Valid Value", this.cursor = +!!this.
initial, this.cursorOffset = 0, this.clear = po("", this.out.columns), this.render();
}
set value(t) {
!t && this.initial ? (this.placeholder = !0, this.rendered = un.gray(this.transform.render(this.initial))) : (this.placeholder = !1, this.
rendered = this.transform.render(t)), this._value = t, this.fire();
}
get value() {
return this._value;
}
reset() {
this.value = "", this.cursor = +!!this.initial, this.cursorOffset = 0, this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.value = this.value || this.initial, this.done = this.aborted = !0, this.error = !1, this.red = !1, this.fire(), this.render(), this.
out.write(`
`), this.close();
}
validate() {
var t = this;
return Vf(function* () {
let r = yield t.validator(t.value);
typeof r == "string" && (t.errorMsg = r, r = !1), t.error = !r;
})();
}
submit() {
var t = this;
return Vf(function* () {
if (t.value = t.value || t.initial, t.cursorOffset = 0, t.cursor = t.rendered.length, yield t.validate(), t.error) {
t.red = !0, t.fire(), t.render();
return;
}
t.done = !0, t.aborted = !1, t.fire(), t.render(), t.out.write(`
`), t.close();
})();
}
next() {
if (!this.placeholder) return this.bell();
this.value = this.initial, this.cursor = this.rendered.length, this.fire(), this.render();
}
moveCursor(t) {
this.placeholder || (this.cursor = this.cursor + t, this.cursorOffset += t);
}
_(t, r) {
let i = this.value.slice(0, this.cursor), s = this.value.slice(this.cursor);
this.value = `${i}${t}${s}`, this.red = !1, this.cursor = this.placeholder ? 0 : i.length + 1, this.render();
}
delete() {
if (this.isCursorAtStart()) return this.bell();
let t = this.value.slice(0, this.cursor - 1), r = this.value.slice(this.cursor);
this.value = `${t}${r}`, this.red = !1, this.isCursorAtStart() ? this.cursorOffset = 0 : (this.cursorOffset++, this.moveCursor(-1)), this.
render();
}
deleteForward() {
if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
let t = this.value.slice(0, this.cursor), r = this.value.slice(this.cursor + 1);
this.value = `${t}${r}`, this.red = !1, this.isCursorAtEnd() ? this.cursorOffset = 0 : this.cursorOffset++, this.render();
}
first() {
this.cursor = 0, this.render();
}
last() {
this.cursor = this.value.length, this.render();
}
left() {
if (this.cursor <= 0 || this.placeholder) return this.bell();
this.moveCursor(-1), this.render();
}
right() {
if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
this.moveCursor(1), this.render();
}
isCursorAtStart() {
return this.cursor === 0 || this.placeholder && this.cursor === 1;
}
isCursorAtEnd() {
return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
}
render() {
this.closed || (this.firstRender || (this.outputError && this.out.write(Vr.down(zv(this.outputError, this.out.columns) - 1) + po(this.
outputError, this.out.columns)), this.out.write(po(this.outputText, this.out.columns))), super.render(), this.outputError = "", this.outputText =
[co.symbol(this.done, this.aborted), un.bold(this.msg), co.delimiter(this.done), this.red ? un.red(this.rendered) : this.rendered].join(
" "), this.error && (this.outputError += this.errorMsg.split(`
`).reduce((t, r, i) => t + `
${i ? " " : Vv.pointerSmall} ${un.red().italic(r)}`, "")), this.out.write($v.line + Vr.to(0) + this.outputText + Vr.save + this.outputError +
Vr.restore + Vr.move(this.cursorOffset, 0)));
}
};
Yf.exports = Do;
});
// ../node_modules/prompts/dist/elements/select.js
var Zf = b((G8, Qf) => {
"use strict";
var rt = ue(), Gv = tt(), Gr = je(), Kf = Gr.style, Xf = Gr.clear, ln = Gr.figures, Yv = Gr.wrap, Jv = Gr.entriesToDisplay, Kv = le(), Xv = Kv.
cursor, mo = class extends Gv {
static {
n(this, "SelectPrompt");
}
constructor(t = {}) {
super(t), this.msg = t.message, this.hint = t.hint || "- Use arrow-keys. Return to submit.", this.warn = t.warn || "- This option is d\
isabled", this.cursor = t.initial || 0, this.choices = t.choices.map((r, i) => (typeof r == "string" && (r = {
title: r,
value: i
}), {
title: r && (r.title || r.value || r),
value: r && (r.value === void 0 ? i : r.value),
description: r && r.description,
selected: r && r.selected,
disabled: r && r.disabled
})), this.optionsPerPage = t.optionsPerPage || 10, this.value = (this.choices[this.cursor] || {}).value, this.clear = Xf("", this.out.
columns), this.render();
}
moveCursor(t) {
this.cursor = t, this.value = this.choices[t].value, this.fire();
}
reset() {
this.moveCursor(0), this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.fire(), this.render(), this.out.write(`
`), this.close();
}
submit() {
this.selection.disabled ? this.bell() : (this.done = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close());
}
first() {
this.moveCursor(0), this.render();
}
last() {
this.moveCursor(this.choices.length - 1), this.render();
}
up() {
this.cursor === 0 ? this.moveCursor(this.choices.length - 1) : this.moveCursor(this.cursor - 1), this.render();
}
down() {
this.cursor === this.choices.length - 1 ? this.moveCursor(0) : this.moveCursor(this.cursor + 1), this.render();
}
next() {
this.moveCursor((this.cursor + 1) % this.choices.length), this.render();
}
_(t, r) {
if (t === " ") return this.submit();
}
get selection() {
return this.choices[this.cursor];
}
render() {
if (this.closed) return;
this.firstRender ? this.out.write(Xv.hide) : this.out.write(Xf(this.outputText, this.out.columns)), super.render();
let t = Jv(this.cursor, this.choices.length, this.optionsPerPage), r = t.startIndex, i = t.endIndex;
if (this.outputText = [Kf.symbol(this.done, this.aborted), rt.bold(this.msg), Kf.delimiter(!1), this.done ? this.selection.title : this.
selection.disabled ? rt.yellow(this.warn) : rt.gray(this.hint)].join(" "), !this.done) {
this.outputText += `
`;
for (let s = r; s < i; s++) {
let o, u, a = "", l = this.choices[s];
s === r && r > 0 ? u = ln.arrowUp : s === i - 1 && i < this.choices.length ? u = ln.arrowDown : u = " ", l.disabled ? (o = this.cursor ===
s ? rt.gray().underline(l.title) : rt.strikethrough().gray(l.title), u = (this.cursor === s ? rt.bold().gray(ln.pointer) + " " : "\
") + u) : (o = this.cursor === s ? rt.cyan().underline(l.title) : l.title, u = (this.cursor === s ? rt.cyan(ln.pointer) + " " : " ") + u,
l.description && this.cursor === s && (a = ` - ${l.description}`, (u.length + o.length + a.length >= this.out.columns || l.description.
split(/\r?\n/).length > 1) && (a = `
` + Yv(l.description, {
margin: 3,
width: this.out.columns
})))), this.outputText += `${u} ${o}${rt.gray(a)}
`;
}
}
this.out.write(this.outputText);
}
};
Qf.exports = mo;
});
// ../node_modules/prompts/dist/elements/toggle.js
var sh = b((J8, nh) => {
"use strict";
var fn = ue(), Qv = tt(), rh = je(), eh = rh.style, Zv = rh.clear, ih = le(), th = ih.cursor, ew = ih.erase, go = class extends Qv {
static {
n(this, "TogglePrompt");
}
constructor(t = {}) {
super(t), this.msg = t.message, this.value = !!t.initial, this.active = t.active || "on", this.inactive = t.inactive || "off", this.initialValue =
this.value, this.render();
}
reset() {
this.value = this.initialValue, this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.fire(), this.render(), this.out.write(`
`), this.close();
}
submit() {
this.done = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
deactivate() {
if (this.value === !1) return this.bell();
this.value = !1, this.render();
}
activate() {
if (this.value === !0) return this.bell();
this.value = !0, this.render();
}
delete() {
this.deactivate();
}
left() {
this.deactivate();
}
right() {
this.activate();
}
down() {
this.deactivate();
}
up() {
this.activate();
}
next() {
this.value = !this.value, this.fire(), this.render();
}
_(t, r) {
if (t === " ")
this.value = !this.value;
else if (t === "1")
this.value = !0;
else if (t === "0")
this.value = !1;
else return this.bell();
this.render();
}
render() {
this.closed || (this.firstRender ? this.out.write(th.hide) : this.out.write(Zv(this.outputText, this.out.columns)), super.render(), this.
outputText = [eh.symbol(this.done, this.aborted), fn.bold(this.msg), eh.delimiter(this.done), this.value ? this.inactive : fn.cyan().underline(
this.inactive), fn.gray("/"), this.value ? fn.cyan().underline(this.active) : this.active].join(" "), this.out.write(ew.line + th.to(0) +
this.outputText));
}
};
nh.exports = go;
});
// ../node_modules/prompts/dist/dateparts/datepart.js
var We = b((X8, oh) => {
"use strict";
var yo = class e {
static {
n(this, "DatePart");
}
constructor({
token: t,
date: r,
parts: i,
locales: s
}) {
this.token = t, this.date = r || /* @__PURE__ */ new Date(), this.parts = i || [this], this.locales = s || {};
}
up() {
}
down() {
}
next() {
let t = this.parts.indexOf(this);
return this.parts.find((r, i) => i > t && r instanceof e);
}
setTo(t) {
}
prev() {
let t = [].concat(this.parts).reverse(), r = t.indexOf(this);
return t.find((i, s) => s > r && i instanceof e);
}
toString() {
return String(this.date);
}
};
oh.exports = yo;
});
// ../node_modules/prompts/dist/dateparts/meridiem.js
var ah = b((Z8, uh) => {
"use strict";
var tw = We(), bo = class extends tw {
static {
n(this, "Meridiem");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setHours((this.date.getHours() + 12) % 24);
}
down() {
this.up();
}
toString() {
let t = this.date.getHours() > 12 ? "pm" : "am";
return /\A/.test(this.token) ? t.toUpperCase() : t;
}
};
uh.exports = bo;
});
// ../node_modules/prompts/dist/dateparts/day.js
var fh = b((tB, lh) => {
"use strict";
var rw = We(), iw = /* @__PURE__ */ n((e) => (e = e % 10, e === 1 ? "st" : e === 2 ? "nd" : e === 3 ? "rd" : "th"), "pos"), vo = class extends rw {
static {
n(this, "Day");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setDate(this.date.getDate() + 1);
}
down() {
this.date.setDate(this.date.getDate() - 1);
}
setTo(t) {
this.date.setDate(parseInt(t.substr(-2)));
}
toString() {
let t = this.date.getDate(), r = this.date.getDay();
return this.token === "DD" ? String(t).padStart(2, "0") : this.token === "Do" ? t + iw(t) : this.token === "d" ? r + 1 : this.token ===
"ddd" ? this.locales.weekdaysShort[r] : this.token === "dddd" ? this.locales.weekdays[r] : t;
}
};
lh.exports = vo;
});
// ../node_modules/prompts/dist/dateparts/hours.js
var ch = b((iB, hh) => {
"use strict";
var nw = We(), wo = class extends nw {
static {
n(this, "Hours");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setHours(this.date.getHours() + 1);
}
down() {
this.date.setHours(this.date.getHours() - 1);
}
setTo(t) {
this.date.setHours(parseInt(t.substr(-2)));
}
toString() {
let t = this.date.getHours();
return /h/.test(this.token) && (t = t % 12 || 12), this.token.length > 1 ? String(t).padStart(2, "0") : t;
}
};
hh.exports = wo;
});
// ../node_modules/prompts/dist/dateparts/milliseconds.js
var ph = b((sB, dh) => {
"use strict";
var sw = We(), _o = class extends sw {
static {
n(this, "Milliseconds");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setMilliseconds(this.date.getMilliseconds() + 1);
}
down() {
this.date.setMilliseconds(this.date.getMilliseconds() - 1);
}
setTo(t) {
this.date.setMilliseconds(parseInt(t.substr(-this.token.length)));
}
toString() {
return String(this.date.getMilliseconds()).padStart(4, "0").substr(0, this.token.length);
}
};
dh.exports = _o;
});
// ../node_modules/prompts/dist/dateparts/minutes.js
var mh = b((uB, Dh) => {
"use strict";
var ow = We(), Eo = class extends ow {
static {
n(this, "Minutes");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setMinutes(this.date.getMinutes() + 1);
}
down() {
this.date.setMinutes(this.date.getMinutes() - 1);
}
setTo(t) {
this.date.setMinutes(parseInt(t.substr(-2)));
}
toString() {
let t = this.date.getMinutes();
return this.token.length > 1 ? String(t).padStart(2, "0") : t;
}
};
Dh.exports = Eo;
});
// ../node_modules/prompts/dist/dateparts/month.js
var yh = b((lB, gh) => {
"use strict";
var uw = We(), Co = class extends uw {
static {
n(this, "Month");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setMonth(this.date.getMonth() + 1);
}
down() {
this.date.setMonth(this.date.getMonth() - 1);
}
setTo(t) {
t = parseInt(t.substr(-2)) - 1, this.date.setMonth(t < 0 ? 0 : t);
}
toString() {
let t = this.date.getMonth(), r = this.token.length;
return r === 2 ? String(t + 1).padStart(2, "0") : r === 3 ? this.locales.monthsShort[t] : r === 4 ? this.locales.months[t] : String(t +
1);
}
};
gh.exports = Co;
});
// ../node_modules/prompts/dist/dateparts/seconds.js
var vh = b((hB, bh) => {
"use strict";
var aw = We(), Fo = class extends aw {
static {
n(this, "Seconds");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setSeconds(this.date.getSeconds() + 1);
}
down() {
this.date.setSeconds(this.date.getSeconds() - 1);
}
setTo(t) {
this.date.setSeconds(parseInt(t.substr(-2)));
}
toString() {
let t = this.date.getSeconds();
return this.token.length > 1 ? String(t).padStart(2, "0") : t;
}
};
bh.exports = Fo;
});
// ../node_modules/prompts/dist/dateparts/year.js
var _h = b((dB, wh) => {
"use strict";
var lw = We(), xo = class extends lw {
static {
n(this, "Year");
}
constructor(t = {}) {
super(t);
}
up() {
this.date.setFullYear(this.date.getFullYear() + 1);
}
down() {
this.date.setFullYear(this.date.getFullYear() - 1);
}
setTo(t) {
this.date.setFullYear(t.substr(-4));
}
toString() {
let t = String(this.date.getFullYear()).padStart(4, "0");
return this.token.length === 2 ? t.substr(-2) : t;
}
};
wh.exports = xo;
});
// ../node_modules/prompts/dist/dateparts/index.js
var Ch = b((DB, Eh) => {
"use strict";
Eh.exports = {
DatePart: We(),
Meridiem: ah(),
Day: fh(),
Hours: ch(),
Milliseconds: ph(),
Minutes: mh(),
Month: yh(),
Seconds: vh(),
Year: _h()
};
});
// ../node_modules/prompts/dist/elements/date.js
var Ph = b((mB, Oh) => {
"use strict";
function Fh(e, t, r, i, s, o, u) {
try {
var a = e[o](u), l = a.value;
} catch (f) {
r(f);
return;
}
a.done ? t(l) : Promise.resolve(l).then(i, s);
}
n(Fh, "asyncGeneratorStep");
function xh(e) {
return function() {
var t = this, r = arguments;
return new Promise(function(i, s) {
var o = e.apply(t, r);
function u(l) {
Fh(o, i, s, u, a, "next", l);
}
n(u, "_next");
function a(l) {
Fh(o, i, s, u, a, "throw", l);
}
n(a, "_throw"), u(void 0);
});
};
}
n(xh, "_asyncToGenerator");
var So = ue(), fw = tt(), To = je(), Sh = To.style, Ah = To.clear, hw = To.figures, kh = le(), cw = kh.erase, Th = kh.cursor, it = Ch(), Rh = it.
DatePart, dw = it.Meridiem, pw = it.Day, Dw = it.Hours, mw = it.Milliseconds, gw = it.Minutes, yw = it.Month, bw = it.Seconds, vw = it.Year,
ww = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g, Bh = {
1: ({
token: e
}) => e.replace(/\\(.)/g, "$1"),
2: (e) => new pw(e),
// Day // TODO
3: (e) => new yw(e),
// Month
4: (e) => new vw(e),
// Year
5: (e) => new dw(e),
// AM/PM // TODO (special)
6: (e) => new Dw(e),
// Hours
7: (e) => new gw(e),
// Minutes
8: (e) => new bw(e),
// Seconds
9: (e) => new mw(e)
// Fractional seconds
}, _w = {
months: "January,February,March,April,May,June,July,August,September,October,November,December".split(","),
monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),
weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
weekdaysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")
}, Ao = class extends fw {
static {
n(this, "DatePrompt");
}
constructor(t = {}) {
super(t), this.msg = t.message, this.cursor = 0, this.typed = "", this.locales = Object.assign(_w, t.locales), this._date = t.initial ||
/* @__PURE__ */ new Date(), this.errorMsg = t.error || "Please Enter A Valid Value", this.validator = t.validate || (() => !0), this.mask =
t.mask || "YYYY-MM-DD HH:mm:ss", this.clear = Ah("", this.out.columns), this.render();
}
get value() {
return this.date;
}
get date() {
return this._date;
}
set date(t) {
t && this._date.setTime(t.getTime());
}
set mask(t) {
let r;
for (this.parts = []; r = ww.exec(t); ) {
let s = r.shift(), o = r.findIndex((u) => u != null);
this.parts.push(o in Bh ? Bh[o]({
token: r[o] || s,
date: this.date,
parts: this.parts,
locales: this.locales
}) : r[o] || s);
}
let i = this.parts.reduce((s, o) => (typeof o == "string" && typeof s[s.length - 1] == "string" ? s[s.length - 1] += o : s.push(o), s),
[]);
this.parts.splice(0), this.parts.push(...i), this.reset();
}
moveCursor(t) {
this.typed = "", this.cursor = t, this.fire();
}
reset() {
this.moveCursor(this.parts.findIndex((t) => t instanceof Rh)), this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.error = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
validate() {
var t = this;
return xh(function* () {
let r = yield t.validator(t.value);
typeof r == "string" && (t.errorMsg = r, r = !1), t.error = !r;
})();
}
submit() {
var t = this;
return xh(function* () {
if (yield t.validate(), t.error) {
t.color = "red", t.fire(), t.render();
return;
}
t.done = !0, t.aborted = !1, t.fire(), t.render(), t.out.write(`
`), t.close();
})();
}
up() {
this.typed = "", this.parts[this.cursor].up(), this.render();
}
down() {
this.typed = "", this.parts[this.cursor].down(), this.render();
}
left() {
let t = this.parts[this.cursor].prev();
if (t == null) return this.bell();
this.moveCursor(this.parts.indexOf(t)), this.render();
}
right() {
let t = this.parts[this.cursor].next();
if (t == null) return this.bell();
this.moveCursor(this.parts.indexOf(t)), this.render();
}
next() {
let t = this.parts[this.cursor].next();
this.moveCursor(t ? this.parts.indexOf(t) : this.parts.findIndex((r) => r instanceof Rh)), this.render();
}
_(t) {
/\d/.test(t) && (this.typed += t, this.parts[this.cursor].setTo(this.typed), this.render());
}
render() {
this.closed || (this.firstRender ? this.out.write(Th.hide) : this.out.write(Ah(this.outputText, this.out.columns)), super.render(), this.
outputText = [Sh.symbol(this.done, this.aborted), So.bold(this.msg), Sh.delimiter(!1), this.parts.reduce((t, r, i) => t.concat(i === this.
cursor && !this.done ? So.cyan().underline(r.toString()) : r), []).join("")].join(" "), this.error && (this.outputText += this.errorMsg.
split(`
`).reduce((t, r, i) => t + `
${i ? " " : hw.pointerSmall} ${So.red().italic(r)}`, "")), this.out.write(cw.line + Th.to(0) + this.outputText));
}
};
Oh.exports = Ao;
});
// ../node_modules/prompts/dist/elements/number.js
var Uh = b((yB, Nh) => {
"use strict";
function qh(e, t, r, i, s, o, u) {
try {
var a = e[o](u), l = a.value;
} catch (f) {
r(f);
return;
}
a.done ? t(l) : Promise.resolve(l).then(i, s);
}
n(qh, "asyncGeneratorStep");
function Mh(e) {
return function() {
var t = this, r = arguments;
return new Promise(function(i, s) {
var o = e.apply(t, r);
function u(l) {
qh(o, i, s, u, a, "next", l);
}
n(u, "_next");
function a(l) {
qh(o, i, s, u, a, "throw", l);
}
n(a, "_throw"), u(void 0);
});
};
}
n(Mh, "_asyncToGenerator");
var hn = ue(), Ew = tt(), Lh = le(), cn = Lh.cursor, Cw = Lh.erase, dn = je(), Ro = dn.style, Fw = dn.figures, jh = dn.clear, xw = dn.lines,
Sw = /[0-9]/, Bo = /* @__PURE__ */ n((e) => e !== void 0, "isDef"), Ih = /* @__PURE__ */ n((e, t) => {
let r = Math.pow(10, t);
return Math.round(e * r) / r;
}, "round"), ko = class extends Ew {
static {
n(this, "NumberPrompt");
}
constructor(t = {}) {
super(t), this.transform = Ro.render(t.style), this.msg = t.message, this.initial = Bo(t.initial) ? t.initial : "", this.float = !!t.float,
this.round = t.round || 2, this.inc = t.increment || 1, this.min = Bo(t.min) ? t.min : -1 / 0, this.max = Bo(t.max) ? t.max : 1 / 0, this.
errorMsg = t.error || "Please Enter A Valid Value", this.validator = t.validate || (() => !0), this.color = "cyan", this.value = "", this.
typed = "", this.lastHit = 0, this.render();
}
set value(t) {
!t && t !== 0 ? (this.placeholder = !0, this.rendered = hn.gray(this.transform.render(`${this.initial}`)), this._value = "") : (this.placeholder =
!1, this.rendered = this.transform.render(`${Ih(t, this.round)}`), this._value = Ih(t, this.round)), this.fire();
}
get value() {
return this._value;
}
parse(t) {
return this.float ? parseFloat(t) : parseInt(t);
}
valid(t) {
return t === "-" || t === "." && this.float || Sw.test(t);
}
reset() {
this.typed = "", this.value = "", this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
let t = this.value;
this.value = t !== "" ? t : this.initial, this.done = this.aborted = !0, this.error = !1, this.fire(), this.render(), this.out.write(`\
`), this.close();
}
validate() {
var t = this;
return Mh(function* () {
let r = yield t.validator(t.value);
typeof r == "string" && (t.errorMsg = r, r = !1), t.error = !r;
})();
}
submit() {
var t = this;
return Mh(function* () {
if (yield t.validate(), t.error) {
t.color = "red", t.fire(), t.render();
return;
}
let r = t.value;
t.value = r !== "" ? r : t.initial, t.done = !0, t.aborted = !1, t.error = !1, t.fire(), t.render(), t.out.write(`
`), t.close();
})();
}
up() {
if (this.typed = "", this.value === "" && (this.value = this.min - this.inc), this.value >= this.max) return this.bell();
this.value += this.inc, this.color = "cyan", this.fire(), this.render();
}
down() {
if (this.typed = "", this.value === "" && (this.value = this.min + this.inc), this.value <= this.min) return this.bell();
this.value -= this.inc, this.color = "cyan", this.fire(), this.render();
}
delete() {
let t = this.value.toString();
if (t.length === 0) return this.bell();
this.value = this.parse(t = t.slice(0, -1)) || "", this.value !== "" && this.value < this.min && (this.value = this.min), this.color =
"cyan", this.fire(), this.render();
}
next() {
this.value = this.initial, this.fire(), this.render();
}
_(t, r) {
if (!this.valid(t)) return this.bell();
let i = Date.now();
if (i - this.lastHit > 1e3 && (this.typed = ""), this.typed += t, this.lastHit = i, this.color = "cyan", t === ".") return this.fire();
this.value = Math.min(this.parse(this.typed), this.max), this.value > this.max && (this.value = this.max), this.value < this.min && (this.
value = this.min), this.fire(), this.render();
}
render() {
this.closed || (this.firstRender || (this.outputError && this.out.write(cn.down(xw(this.outputError, this.out.columns) - 1) + jh(this.
outputError, this.out.columns)), this.out.write(jh(this.outputText, this.out.columns))), super.render(), this.outputError = "", this.outputText =
[Ro.symbol(this.done, this.aborted), hn.bold(this.msg), Ro.delimiter(this.done), !this.done || !this.done && !this.placeholder ? hn[this.
color]().underline(this.rendered) : this.rendered].join(" "), this.error && (this.outputError += this.errorMsg.split(`
`).reduce((t, r, i) => t + `
${i ? " " : Fw.pointerSmall} ${hn.red().italic(r)}`, "")), this.out.write(Cw.line + cn.to(0) + this.outputText + cn.save + this.outputError +
cn.restore));
}
};
Nh.exports = ko;
});
// ../node_modules/prompts/dist/elements/multiselect.js
var Po = b((vB, $h) => {
"use strict";
var $e = ue(), Aw = le(), Tw = Aw.cursor, Rw = tt(), Yr = je(), Hh = Yr.clear, _t = Yr.figures, Wh = Yr.style, Bw = Yr.wrap, kw = Yr.entriesToDisplay,
Oo = class extends Rw {
static {
n(this, "MultiselectPrompt");
}
constructor(t = {}) {
super(t), this.msg = t.message, this.cursor = t.cursor || 0, this.scrollIndex = t.cursor || 0, this.hint = t.hint || "", this.warn = t.
warn || "- This option is disabled -", this.minSelected = t.min, this.showMinError = !1, this.maxChoices = t.max, this.instructions = t.
instructions, this.optionsPerPage = t.optionsPerPage || 10, this.value = t.choices.map((r, i) => (typeof r == "string" && (r = {
title: r,
value: i
}), {
title: r && (r.title || r.value || r),
description: r && r.description,
value: r && (r.value === void 0 ? i : r.value),
selected: r && r.selected,
disabled: r && r.disabled
})), this.clear = Hh("", this.out.columns), t.overrideRender || this.render();
}
reset() {
this.value.map((t) => !t.selected), this.cursor = 0, this.fire(), this.render();
}
selected() {
return this.value.filter((t) => t.selected);
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.fire(), this.render(), this.out.write(`
`), this.close();
}
submit() {
let t = this.value.filter((r) => r.selected);
this.minSelected && t.length < this.minSelected ? (this.showMinError = !0, this.render()) : (this.done = !0, this.aborted = !1, this.fire(),
this.render(), this.out.write(`
`), this.close());
}
first() {
this.cursor = 0, this.render();
}
last() {
this.cursor = this.value.length - 1, this.render();
}
next() {
this.cursor = (this.cursor + 1) % this.value.length, this.render();
}
up() {
this.cursor === 0 ? this.cursor = this.value.length - 1 : this.cursor--, this.render();
}
down() {
this.cursor === this.value.length - 1 ? this.cursor = 0 : this.cursor++, this.render();
}
left() {
this.value[this.cursor].selected = !1, this.render();
}
right() {
if (this.value.filter((t) => t.selected).length >= this.maxChoices) return this.bell();
this.value[this.cursor].selected = !0, this.render();
}
handleSpaceToggle() {
let t = this.value[this.cursor];
if (t.selected)
t.selected = !1, this.render();
else {
if (t.disabled || this.value.filter((r) => r.selected).length >= this.maxChoices)
return this.bell();
t.selected = !0, this.render();
}
}
toggleAll() {
if (this.maxChoices !== void 0 || this.value[this.cursor].disabled)
return this.bell();
let t = !this.value[this.cursor].selected;
this.value.filter((r) => !r.disabled).forEach((r) => r.selected = t), this.render();
}
_(t, r) {
if (t === " ")
this.handleSpaceToggle();
else if (t === "a")
this.toggleAll();
else
return this.bell();
}
renderInstructions() {
return this.instructions === void 0 || this.instructions ? typeof this.instructions == "string" ? this.instructions : `
Instructions:
${_t.arrowUp}/${_t.arrowDown}: Highlight option
${_t.arrowLeft}/${_t.arrowRight}/[space]: Toggle selection
` + (this.maxChoices === void 0 ? ` a: Toggle all
` : "") + " enter/return: Complete answer" : "";
}
renderOption(t, r, i, s) {
let o = (r.selected ? $e.green(_t.radioOn) : _t.radioOff) + " " + s + " ", u, a;
return r.disabled ? u = t === i ? $e.gray().underline(r.title) : $e.strikethrough().gray(r.title) : (u = t === i ? $e.cyan().underline(
r.title) : r.title, t === i && r.description && (a = ` - ${r.description}`, (o.length + u.length + a.length >= this.out.columns || r.description.
split(/\r?\n/).length > 1) && (a = `
` + Bw(r.description, {
margin: o.length,
width: this.out.columns
})))), o + u + $e.gray(a || "");
}
// shared with autocompleteMultiselect
paginateOptions(t) {
if (t.length === 0)
return $e.red("No matches for this query.");
let r = kw(this.cursor, t.length, this.optionsPerPage), i = r.startIndex, s = r.endIndex, o, u = [];
for (let a = i; a < s; a++)
a === i && i > 0 ? o = _t.arrowUp : a === s - 1 && s < t.length ? o = _t.arrowDown : o = " ", u.push(this.renderOption(this.cursor, t[a],
a, o));
return `
` + u.join(`
`);
}
// shared with autocomleteMultiselect
renderOptions(t) {
return this.done ? "" : this.paginateOptions(t);
}
renderDoneOrInstructions() {
if (this.done)
return this.value.filter((r) => r.selected).map((r) => r.title).join(", ");
let t = [$e.gray(this.hint), this.renderInstructions()];
return this.value[this.cursor].disabled && t.push($e.yellow(this.warn)), t.join(" ");
}
render() {
if (this.closed) return;
this.firstRender && this.out.write(Tw.hide), super.render();
let t = [Wh.symbol(this.done, this.aborted), $e.bold(this.msg), Wh.delimiter(!1), this.renderDoneOrInstructions()].join(" ");
this.showMinError && (t += $e.red(`You must select a minimum of ${this.minSelected} choices.`), this.showMinError = !1), t += this.renderOptions(
this.value), this.out.write(this.clear + t), this.clear = Hh(t, this.out.columns);
}
};
$h.exports = Oo;
});
// ../node_modules/prompts/dist/elements/autocomplete.js
var Xh = b((_B, Kh) => {
"use strict";
function zh(e, t, r, i, s, o, u) {
try {
var a = e[o](u), l = a.value;
} catch (f) {
r(f);
return;
}
a.done ? t(l) : Promise.resolve(l).then(i, s);
}
n(zh, "asyncGeneratorStep");
function Ow(e) {
return function() {
var t = this, r = arguments;
return new Promise(function(i, s) {
var o = e.apply(t, r);
function u(l) {
zh(o, i, s, u, a, "next", l);
}
n(u, "_next");
function a(l) {
zh(o, i, s, u, a, "throw", l);
}
n(a, "_throw"), u(void 0);
});
};
}
n(Ow, "_asyncToGenerator");
var Jr = ue(), Pw = tt(), Jh = le(), qw = Jh.erase, Vh = Jh.cursor, Kr = je(), qo = Kr.style, Gh = Kr.clear, Mo = Kr.figures, Mw = Kr.wrap,
jw = Kr.entriesToDisplay, Yh = /* @__PURE__ */ n((e, t) => e[t] && (e[t].value || e[t].title || e[t]), "getVal"), Iw = /* @__PURE__ */ n((e, t) => e[t] &&
(e[t].title || e[t].value || e[t]), "getTitle"), Lw = /* @__PURE__ */ n((e, t) => {
let r = e.findIndex((i) => i.value === t || i.title === t);
return r > -1 ? r : void 0;
}, "getIndex"), jo = class extends Pw {
static {
n(this, "AutocompletePrompt");
}
constructor(t = {}) {
super(t), this.msg = t.message, this.suggest = t.suggest, this.choices = t.choices, this.initial = typeof t.initial == "number" ? t.initial :
Lw(t.choices, t.initial), this.select = this.initial || t.cursor || 0, this.i18n = {
noMatches: t.noMatches || "no matches found"
}, this.fallback = t.fallback || this.initial, this.clearFirst = t.clearFirst || !1, this.suggestions = [], this.input = "", this.limit =
t.limit || 10, this.cursor = 0, this.transform = qo.render(t.style), this.scale = this.transform.scale, this.render = this.render.bind(
this), this.complete = this.complete.bind(this), this.clear = Gh("", this.out.columns), this.complete(this.render), this.render();
}
set fallback(t) {
this._fb = Number.isSafeInteger(parseInt(t)) ? parseInt(t) : t;
}
get fallback() {
let t;
return typeof this._fb == "number" ? t = this.choices[this._fb] : typeof this._fb == "string" && (t = {
title: this._fb
}), t || this._fb || {
title: this.i18n.noMatches
};
}
moveSelect(t) {
this.select = t, this.suggestions.length > 0 ? this.value = Yh(this.suggestions, t) : this.value = this.fallback.value, this.fire();
}
complete(t) {
var r = this;
return Ow(function* () {
let i = r.completing = r.suggest(r.input, r.choices), s = yield i;
if (r.completing !== i) return;
r.suggestions = s.map((u, a, l) => ({
title: Iw(l, a),