@vite-hub/cli 0.6.1 → 0.8.0

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.
@@ -0,0 +1,2495 @@
1
+ import { existsSync, lstatSync, readdirSync } from "node:fs";
2
+ import process$1, { stdin, stdout } from "node:process";
3
+ import { dirname, join } from "node:path";
4
+ import { stripVTControlCharacters, styleText } from "node:util";
5
+ import f__default, * as f$1 from "node:readline";
6
+ import { ReadStream } from "node:tty";
7
+ // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
8
+ const getCodePointsLength = (() => {
9
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
10
+ return (input) => {
11
+ let surrogatePairsNr = 0;
12
+ SURROGATE_PAIR_RE.lastIndex = 0;
13
+ while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
14
+ return input.length - surrogatePairsNr;
15
+ };
16
+ })();
17
+ const isFullWidth = (x) => {
18
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
19
+ };
20
+ const isWideNotCJKTNotEmoji = (x) => {
21
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
22
+ };
23
+ // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
24
+ const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
25
+ const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
26
+ const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
27
+ const TAB_RE = /\t{1,1000}/y;
28
+ const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
29
+ const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
30
+ const MODIFIER_RE = /\p{M}+/gu;
31
+ const NO_TRUNCATION$1 = {
32
+ limit: Infinity,
33
+ ellipsis: ""
34
+ };
35
+ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
36
+ const LIMIT = truncationOptions.limit ?? Infinity;
37
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
38
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
39
+ const ANSI_WIDTH = 0;
40
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
41
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
42
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
43
+ const FULL_WIDTH_WIDTH = 2;
44
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
45
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
46
+ const PARSE_BLOCKS = [
47
+ [LATIN_RE, REGULAR_WIDTH],
48
+ [ANSI_RE, ANSI_WIDTH],
49
+ [CONTROL_RE, CONTROL_WIDTH],
50
+ [TAB_RE, TAB_WIDTH],
51
+ [EMOJI_RE, EMOJI_WIDTH],
52
+ [CJKT_WIDE_RE, WIDE_WIDTH]
53
+ ];
54
+ let indexPrev = 0;
55
+ let index = 0;
56
+ let length = input.length;
57
+ let lengthExtra = 0;
58
+ let truncationEnabled = false;
59
+ let truncationIndex = length;
60
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
61
+ let unmatchedStart = 0;
62
+ let unmatchedEnd = 0;
63
+ let width = 0;
64
+ let widthExtra = 0;
65
+ outer: while (true) {
66
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
67
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
68
+ lengthExtra = 0;
69
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
70
+ const codePoint = char.codePointAt(0) || 0;
71
+ if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
72
+ else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
73
+ else widthExtra = REGULAR_WIDTH;
74
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
75
+ if (width + widthExtra > LIMIT) {
76
+ truncationEnabled = true;
77
+ break outer;
78
+ }
79
+ lengthExtra += char.length;
80
+ width += widthExtra;
81
+ }
82
+ unmatchedStart = unmatchedEnd = 0;
83
+ }
84
+ if (index >= length) break outer;
85
+ for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
86
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
87
+ BLOCK_RE.lastIndex = index;
88
+ if (BLOCK_RE.test(input)) {
89
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
90
+ widthExtra = lengthExtra * BLOCK_WIDTH;
91
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
92
+ if (width + widthExtra > LIMIT) {
93
+ truncationEnabled = true;
94
+ break outer;
95
+ }
96
+ width += widthExtra;
97
+ unmatchedStart = indexPrev;
98
+ unmatchedEnd = index;
99
+ index = indexPrev = BLOCK_RE.lastIndex;
100
+ continue outer;
101
+ }
102
+ }
103
+ index += 1;
104
+ }
105
+ return {
106
+ width: truncationEnabled ? truncationLimit : width,
107
+ index: truncationEnabled ? truncationIndex : length,
108
+ truncated: truncationEnabled,
109
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
110
+ };
111
+ };
112
+ // ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
113
+ const NO_TRUNCATION = {
114
+ limit: Infinity,
115
+ ellipsis: "",
116
+ ellipsisWidth: 0
117
+ };
118
+ const fastStringWidth = (input, options = {}) => {
119
+ return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
120
+ };
121
+ // ../../node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
122
+ const ESC$1 = "\x1B";
123
+ const CSI$1 = "›";
124
+ const END_CODE = 39;
125
+ const ANSI_ESCAPE_BELL = "\x07";
126
+ const ANSI_CSI = "[";
127
+ const ANSI_OSC = "]";
128
+ const ANSI_SGR_TERMINATOR = "m";
129
+ const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
130
+ const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
131
+ const getClosingCode = (openingCode) => {
132
+ if (openingCode >= 30 && openingCode <= 37) return 39;
133
+ if (openingCode >= 90 && openingCode <= 97) return 39;
134
+ if (openingCode >= 40 && openingCode <= 47) return 49;
135
+ if (openingCode >= 100 && openingCode <= 107) return 49;
136
+ if (openingCode === 1 || openingCode === 2) return 22;
137
+ if (openingCode === 3) return 23;
138
+ if (openingCode === 4) return 24;
139
+ if (openingCode === 7) return 27;
140
+ if (openingCode === 8) return 28;
141
+ if (openingCode === 9) return 29;
142
+ if (openingCode === 0) return 0;
143
+ };
144
+ const wrapAnsiCode = (code) => `${ESC$1}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
145
+ const wrapAnsiHyperlink = (url) => `${ESC$1}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
146
+ const wrapWord = (rows, word, columns) => {
147
+ const characters = word[Symbol.iterator]();
148
+ let isInsideEscape = false;
149
+ let isInsideLinkEscape = false;
150
+ let lastRow = rows.at(-1);
151
+ let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
152
+ let currentCharacter = characters.next();
153
+ let nextCharacter = characters.next();
154
+ let rawCharacterIndex = 0;
155
+ while (!currentCharacter.done) {
156
+ const character = currentCharacter.value;
157
+ const characterLength = fastStringWidth(character);
158
+ if (visible + characterLength <= columns) rows[rows.length - 1] += character;
159
+ else {
160
+ rows.push(character);
161
+ visible = 0;
162
+ }
163
+ if (character === ESC$1 || character === CSI$1) {
164
+ isInsideEscape = true;
165
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
166
+ }
167
+ if (isInsideEscape) {
168
+ if (isInsideLinkEscape) {
169
+ if (character === ANSI_ESCAPE_BELL) {
170
+ isInsideEscape = false;
171
+ isInsideLinkEscape = false;
172
+ }
173
+ } else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
174
+ } else {
175
+ visible += characterLength;
176
+ if (visible === columns && !nextCharacter.done) {
177
+ rows.push("");
178
+ visible = 0;
179
+ }
180
+ }
181
+ currentCharacter = nextCharacter;
182
+ nextCharacter = characters.next();
183
+ rawCharacterIndex += character.length;
184
+ }
185
+ lastRow = rows.at(-1);
186
+ if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
187
+ };
188
+ const stringVisibleTrimSpacesRight = (string) => {
189
+ const words = string.split(" ");
190
+ let last = words.length;
191
+ while (last) {
192
+ if (fastStringWidth(words[last - 1])) break;
193
+ last--;
194
+ }
195
+ if (last === words.length) return string;
196
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
197
+ };
198
+ const exec = (string, columns, options = {}) => {
199
+ if (options.trim !== false && string.trim() === "") return "";
200
+ let returnValue = "";
201
+ let escapeCode;
202
+ let escapeUrl;
203
+ const words = string.split(" ");
204
+ let rows = [""];
205
+ let rowLength = 0;
206
+ for (let index = 0; index < words.length; index++) {
207
+ const word = words[index];
208
+ if (options.trim !== false) {
209
+ const row = rows.at(-1) ?? "";
210
+ const trimmed = row.trimStart();
211
+ if (row.length !== trimmed.length) {
212
+ rows[rows.length - 1] = trimmed;
213
+ rowLength = fastStringWidth(trimmed);
214
+ }
215
+ }
216
+ if (index !== 0) {
217
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
218
+ rows.push("");
219
+ rowLength = 0;
220
+ }
221
+ if (rowLength || options.trim === false) {
222
+ rows[rows.length - 1] += " ";
223
+ rowLength++;
224
+ }
225
+ }
226
+ const wordLength = fastStringWidth(word);
227
+ if (options.hard && wordLength > columns) {
228
+ const remainingColumns = columns - rowLength;
229
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
230
+ if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
231
+ wrapWord(rows, word, columns);
232
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
233
+ continue;
234
+ }
235
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
236
+ if (options.wordWrap === false && rowLength < columns) {
237
+ wrapWord(rows, word, columns);
238
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
239
+ continue;
240
+ }
241
+ rows.push("");
242
+ rowLength = 0;
243
+ }
244
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
245
+ wrapWord(rows, word, columns);
246
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
247
+ continue;
248
+ }
249
+ rows[rows.length - 1] += word;
250
+ rowLength += wordLength;
251
+ }
252
+ if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
253
+ const preString = rows.join("\n");
254
+ let inSurrogate = false;
255
+ for (let i = 0; i < preString.length; i++) {
256
+ const character = preString[i];
257
+ returnValue += character;
258
+ if (!inSurrogate) {
259
+ inSurrogate = character >= "\ud800" && character <= "\udbff";
260
+ if (inSurrogate) continue;
261
+ } else inSurrogate = false;
262
+ if (character === ESC$1 || character === CSI$1) {
263
+ GROUP_REGEX.lastIndex = i + 1;
264
+ const groups = GROUP_REGEX.exec(preString)?.groups;
265
+ if (groups?.code !== void 0) {
266
+ const code = Number.parseFloat(groups.code);
267
+ escapeCode = code === END_CODE ? void 0 : code;
268
+ } else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
269
+ }
270
+ if (preString[i + 1] === "\n") {
271
+ if (escapeUrl) returnValue += wrapAnsiHyperlink("");
272
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
273
+ if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
274
+ } else if (character === "\n") {
275
+ if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
276
+ if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
277
+ }
278
+ }
279
+ return returnValue;
280
+ };
281
+ const CRLF_OR_LF = /\r?\n/;
282
+ function wrapAnsi(string, columns, options) {
283
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
284
+ }
285
+ // ../../node_modules/.pnpm/sisteransi@2.0.0/node_modules/sisteransi/dist/index.js
286
+ const ESC = "\x1B";
287
+ const CSI = `${ESC}[`;
288
+ const cursor = {
289
+ to(x, y) {
290
+ if (!y) return `${CSI}${x + 1}G`;
291
+ return `${CSI}${y + 1};${x + 1}H`;
292
+ },
293
+ move(x, y) {
294
+ let ret = "";
295
+ if (x < 0) ret += `${CSI}${-x}D`;
296
+ else if (x > 0) ret += `${CSI}${x}C`;
297
+ if (y < 0) ret += `${CSI}${-y}A`;
298
+ else if (y > 0) ret += `${CSI}${y}B`;
299
+ return ret;
300
+ },
301
+ up: (count = 1) => `${CSI}${count}A`,
302
+ down: (count = 1) => `${CSI}${count}B`,
303
+ forward: (count = 1) => `${CSI}${count}C`,
304
+ backward: (count = 1) => `${CSI}${count}D`,
305
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
306
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
307
+ left: `${CSI}G`,
308
+ hide: `${CSI}?25l`,
309
+ show: `${CSI}?25h`,
310
+ save: `${ESC}7`,
311
+ restore: `${ESC}8`
312
+ };
313
+ const erase = {
314
+ screen: `${CSI}2J`,
315
+ up: (count = 1) => `${CSI}1J`.repeat(count),
316
+ down: (count = 1) => `${CSI}J`.repeat(count),
317
+ line: `${CSI}2K`,
318
+ lineEnd: `${CSI}K`,
319
+ lineStart: `${CSI}1K`,
320
+ lines(count) {
321
+ let clear = "";
322
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
323
+ if (count) clear += cursor.left;
324
+ return clear;
325
+ }
326
+ };
327
+ // ../../node_modules/.pnpm/@clack+core@1.6.0/node_modules/@clack/core/dist/index.mjs
328
+ function findCursor(o, s, l) {
329
+ if (!l.some((r) => !r.disabled)) return o;
330
+ const t = o + s, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
331
+ return l[e]?.disabled ? findCursor(e, s < 0 ? -1 : 1, l) : e;
332
+ }
333
+ function findTextCursor(o, s, l, i) {
334
+ const t = i.split(`
335
+ `);
336
+ let n = 0, e = o;
337
+ for (const r of t) {
338
+ if (e <= r.length) break;
339
+ e -= r.length + 1, n++;
340
+ }
341
+ for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + s; e < 0 && n > 0;) n--, e += t[n].length + 1;
342
+ for (; e > t[n].length && n < t.length - 1;) e -= t[n].length + 1, n++;
343
+ e = Math.max(0, Math.min(t[n].length, e));
344
+ let h = 0;
345
+ for (let r = 0; r < n; r++) h += t[r].length + 1;
346
+ return h + e;
347
+ }
348
+ const settings = {
349
+ actions: /* @__PURE__ */ new Set([
350
+ "up",
351
+ "down",
352
+ "left",
353
+ "right",
354
+ "space",
355
+ "enter",
356
+ "cancel"
357
+ ]),
358
+ aliases: /* @__PURE__ */ new Map([
359
+ ["k", "up"],
360
+ ["j", "down"],
361
+ ["h", "left"],
362
+ ["l", "right"],
363
+ ["", "cancel"],
364
+ ["escape", "cancel"]
365
+ ]),
366
+ messages: {
367
+ cancel: "Canceled",
368
+ error: "Something went wrong"
369
+ },
370
+ withGuide: true,
371
+ accessible: void 0,
372
+ date: {
373
+ monthNames: [...[
374
+ "January",
375
+ "February",
376
+ "March",
377
+ "April",
378
+ "May",
379
+ "June",
380
+ "July",
381
+ "August",
382
+ "September",
383
+ "October",
384
+ "November",
385
+ "December"
386
+ ]],
387
+ messages: {
388
+ required: "Please enter a valid date",
389
+ invalidMonth: "There are only 12 months in a year",
390
+ invalidDay: (n, e) => `There are only ${n} days in ${e}`,
391
+ afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
392
+ beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
393
+ }
394
+ }
395
+ };
396
+ function updateSettings(n) {
397
+ if (n.aliases !== void 0) {
398
+ const e = n.aliases;
399
+ for (const s in e) {
400
+ if (!Object.hasOwn(e, s)) continue;
401
+ const i = e[s];
402
+ i === void 0 || !settings.actions.has(i) || settings.aliases.has(s) || settings.aliases.set(s, i);
403
+ }
404
+ }
405
+ if (n.messages !== void 0) {
406
+ const e = n.messages;
407
+ e.cancel !== void 0 && (settings.messages.cancel = e.cancel), e.error !== void 0 && (settings.messages.error = e.error);
408
+ }
409
+ if (n.withGuide !== void 0 && (settings.withGuide = n.withGuide !== false), n.accessible !== void 0 && (settings.accessible = n.accessible === true), n.date !== void 0) {
410
+ const e = n.date;
411
+ e.monthNames !== void 0 && (settings.date.monthNames = [...e.monthNames]), e.messages !== void 0 && (e.messages.required !== void 0 && (settings.date.messages.required = e.messages.required), e.messages.invalidMonth !== void 0 && (settings.date.messages.invalidMonth = e.messages.invalidMonth), e.messages.invalidDay !== void 0 && (settings.date.messages.invalidDay = e.messages.invalidDay), e.messages.afterMin !== void 0 && (settings.date.messages.afterMin = e.messages.afterMin), e.messages.beforeMax !== void 0 && (settings.date.messages.beforeMax = e.messages.beforeMax));
412
+ }
413
+ }
414
+ function isAccessible(n) {
415
+ if (n !== void 0) return n;
416
+ if (settings.accessible !== void 0) return settings.accessible;
417
+ const e = process.env.ACCESSIBLE;
418
+ return e !== void 0 && e !== "" && e !== "0" && e !== "false";
419
+ }
420
+ function isActionKey(n, e) {
421
+ if (typeof n == "string") return settings.aliases.get(n) === e;
422
+ for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
423
+ return false;
424
+ }
425
+ function diffLines(i, s) {
426
+ if (i === s) return;
427
+ const e = i.split(`
428
+ `), t = s.split(`
429
+ `), r = Math.max(e.length, t.length), f = [];
430
+ for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
431
+ return {
432
+ lines: f,
433
+ numLinesBefore: e.length,
434
+ numLinesAfter: t.length,
435
+ numLines: r
436
+ };
437
+ }
438
+ const R = globalThis.process.platform.startsWith("win");
439
+ const CANCEL_SYMBOL = Symbol("clack:cancel");
440
+ function isCancel(e) {
441
+ return e === CANCEL_SYMBOL;
442
+ }
443
+ function setRawMode(e, r) {
444
+ const o = e;
445
+ o.isTTY && o.setRawMode(r);
446
+ }
447
+ function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: n = true } = {}) {
448
+ const s = f$1.createInterface({
449
+ input: e,
450
+ output: r,
451
+ prompt: "",
452
+ tabSize: 1
453
+ });
454
+ f$1.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
455
+ const t = (l, { name: i, sequence: p }) => {
456
+ if (isActionKey([
457
+ String(l),
458
+ i,
459
+ p
460
+ ], "cancel")) {
461
+ n && r.write(cursor.show), process.exit(0);
462
+ return;
463
+ }
464
+ if (!o) return;
465
+ const c = i === "return" ? 0 : -1, a = i === "return" ? -1 : 0;
466
+ f$1.moveCursor(r, c, a, () => {
467
+ f$1.clearLine(r, 1, () => {
468
+ e.once("keypress", t);
469
+ });
470
+ });
471
+ };
472
+ return n && r.write(cursor.hide), e.once("keypress", t), () => {
473
+ e.off("keypress", t), n && r.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
474
+ };
475
+ }
476
+ const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
477
+ const getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
478
+ function wrapTextWithPrefix(e, r, o, n = o, s = o, t) {
479
+ return wrapAnsi(r, getColumns(e ?? stdout) - fastStringWidth(o), {
480
+ hard: true,
481
+ trim: false
482
+ }).split(`
483
+ `).map((c, a, g) => {
484
+ const m = t ? t(c, a) : c;
485
+ return a === 0 ? `${n}${m}` : a === g.length - 1 ? `${s}${m}` : `${o}${m}`;
486
+ }).join(`
487
+ `);
488
+ }
489
+ function runValidation(e, a) {
490
+ if ("~standard" in e) {
491
+ const n = e["~standard"].validate(a);
492
+ return n instanceof Promise ? n.then((r) => r.issues?.at(0)?.message) : n.issues?.at(0)?.message;
493
+ }
494
+ return e(a);
495
+ }
496
+ let C$1 = class C {
497
+ input;
498
+ output;
499
+ _abortSignal;
500
+ rl;
501
+ opts;
502
+ _render;
503
+ _track = false;
504
+ _prevFrame = "";
505
+ _subscribers = /* @__PURE__ */ new Map();
506
+ _cursor = 0;
507
+ state = "initial";
508
+ error = "";
509
+ value;
510
+ userInput = "";
511
+ /**
512
+ * Whether accessible (static, screen-reader friendly) output is enabled for
513
+ * this prompt, resolved from the `accessible` option, the global setting,
514
+ * and the `ACCESSIBLE` env var.
515
+ */
516
+ get accessible() {
517
+ return isAccessible(this.opts.accessible);
518
+ }
519
+ constructor(t, e = true) {
520
+ const { input: i = stdin, output: s = stdout, render: r, signal: n, ...o } = t;
521
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r.bind(this), this._track = e, this._abortSignal = n, this.input = i, this.output = s;
522
+ }
523
+ /**
524
+ * Unsubscribe all listeners
525
+ */
526
+ unsubscribe() {
527
+ this._subscribers.clear();
528
+ }
529
+ /**
530
+ * Set a subscriber with opts
531
+ * @param event - The event name
532
+ */
533
+ setSubscriber(t, e) {
534
+ const i = this._subscribers.get(t) ?? [];
535
+ i.push(e), this._subscribers.set(t, i);
536
+ }
537
+ /**
538
+ * Subscribe to an event
539
+ * @param event - The event name
540
+ * @param cb - The callback
541
+ */
542
+ on(t, e) {
543
+ this.setSubscriber(t, { cb: e });
544
+ }
545
+ /**
546
+ * Subscribe to an event once
547
+ * @param event - The event name
548
+ * @param cb - The callback
549
+ */
550
+ once(t, e) {
551
+ this.setSubscriber(t, {
552
+ cb: e,
553
+ once: true
554
+ });
555
+ }
556
+ /**
557
+ * Emit an event with data
558
+ * @param event - The event name
559
+ * @param data - The data to pass to the callback
560
+ */
561
+ emit(t, ...e) {
562
+ const i = this._subscribers.get(t) ?? [], s = [];
563
+ for (const r of i) r.cb(...e), r.once && s.push(() => i.splice(i.indexOf(r), 1));
564
+ for (const r of s) r();
565
+ }
566
+ prompt() {
567
+ return new Promise((t) => {
568
+ if (this._abortSignal) {
569
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
570
+ this._abortSignal.addEventListener("abort", () => {
571
+ this.state = "cancel", this.close();
572
+ }, { once: true });
573
+ }
574
+ this.rl = f__default.createInterface({
575
+ input: this.input,
576
+ tabSize: 2,
577
+ prompt: "",
578
+ escapeCodeTimeout: 50,
579
+ terminal: true
580
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
581
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
582
+ }), this.once("cancel", () => {
583
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
584
+ });
585
+ });
586
+ }
587
+ _isActionKey(t, e) {
588
+ return t === " ";
589
+ }
590
+ _shouldSubmit(t, e) {
591
+ return true;
592
+ }
593
+ _setValue(t) {
594
+ this.value = t, this.emit("value", this.value);
595
+ }
596
+ _setUserInput(t, e) {
597
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
598
+ }
599
+ _clearUserInput() {
600
+ this.rl?.write(null, {
601
+ ctrl: true,
602
+ name: "u"
603
+ }), this._setUserInput("");
604
+ }
605
+ async onKeypress(t, e) {
606
+ if (this.state !== "validating") {
607
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
608
+ ctrl: true,
609
+ name: "h"
610
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
611
+ if (this.opts.validate) {
612
+ const i = runValidation(this.opts.validate, this.value);
613
+ let s;
614
+ i instanceof Promise ? (this.state = "validating", this.render(), s = await i) : s = i, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
615
+ }
616
+ this.state !== "error" && (this.state = "submit");
617
+ }
618
+ isActionKey([
619
+ t,
620
+ e?.name,
621
+ e?.sequence
622
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
623
+ }
624
+ }
625
+ close() {
626
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
627
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
628
+ }
629
+ restoreCursor() {
630
+ const t = wrapAnsi(this._prevFrame, getColumns(this.output), {
631
+ hard: true,
632
+ trim: false
633
+ }).split(`
634
+ `).length - 1;
635
+ this.output.write(cursor.move(-999, t * -1));
636
+ }
637
+ render() {
638
+ const t = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
639
+ hard: true,
640
+ trim: false
641
+ });
642
+ if (t !== this._prevFrame) {
643
+ if (this.state === "initial") this.output.write(cursor.hide);
644
+ else {
645
+ const e = diffLines(this._prevFrame, t), i = getRows(this.output);
646
+ if (this.restoreCursor(), e) {
647
+ const s = Math.max(0, e.numLinesAfter - i), r = Math.max(0, e.numLinesBefore - i);
648
+ let n = e.lines.find((o) => o >= s);
649
+ if (n === void 0) {
650
+ this._prevFrame = t;
651
+ return;
652
+ }
653
+ if (e.lines.length === 1) {
654
+ this.output.write(cursor.move(0, n - r)), this.output.write(erase.lines(1));
655
+ const o = t.split(`
656
+ `);
657
+ this.output.write(o[n]), this._prevFrame = t, this.output.write(cursor.move(0, o.length - n - 1));
658
+ return;
659
+ } else if (e.lines.length > 1) {
660
+ if (s < r) n = s;
661
+ else {
662
+ const h = n - r;
663
+ h > 0 && this.output.write(cursor.move(0, h));
664
+ }
665
+ this.output.write(erase.down());
666
+ const m = t.split(`
667
+ `).slice(n);
668
+ this.output.write(m.join(`
669
+ `)), this._prevFrame = t;
670
+ return;
671
+ }
672
+ }
673
+ this.output.write(erase.down());
674
+ }
675
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
676
+ }
677
+ }
678
+ };
679
+ function p$1(l, e) {
680
+ if (l === void 0 || e.length === 0) return 0;
681
+ const i = e.findIndex((s) => s.value === l);
682
+ return i !== -1 ? i : 0;
683
+ }
684
+ function m$1(l, e) {
685
+ return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
686
+ }
687
+ function g(l, e) {
688
+ if (e) return l ? e : e[0];
689
+ }
690
+ let T$1 = class T extends C$1 {
691
+ filteredOptions;
692
+ multiple;
693
+ isNavigating = false;
694
+ selectedValues = [];
695
+ focusedValue;
696
+ #e = 0;
697
+ #s = "";
698
+ #t;
699
+ #i;
700
+ #n;
701
+ #l;
702
+ get cursor() {
703
+ return this.#e;
704
+ }
705
+ get userInputWithCursor() {
706
+ if (!this.userInput) return styleText(["inverse", "hidden"], "_");
707
+ if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
708
+ const e = this.userInput.slice(0, this.cursor), t = this.userInput.slice(this.cursor, this.cursor + 1), i = this.userInput.slice(this.cursor + 1);
709
+ return `${e}${styleText("inverse", t)}${i}`;
710
+ }
711
+ get options() {
712
+ return typeof this.#i == "function" ? this.#i() : this.#i;
713
+ }
714
+ constructor(e) {
715
+ super(e), this.#i = e.options, this.#n = e.placeholder, this.#l = e.completeOnTab === true;
716
+ const t = this.options;
717
+ this.filteredOptions = [...t], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? m$1;
718
+ let i;
719
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0]?.value]), i) for (const s of i) {
720
+ const n = t.findIndex((r) => r.value === s);
721
+ n !== -1 && (this.toggleSelected(s), this.#e = n);
722
+ }
723
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#u(s, n)), this.on("userInput", (s) => this.#o(s));
724
+ }
725
+ _isActionKey(e, t) {
726
+ return e === " " || this.multiple && this.isNavigating && t.name === "space" && e !== void 0 && e !== "";
727
+ }
728
+ #u(e, t) {
729
+ const i = t.name === "up", s = t.name === "down", n = t.name === "return", r = this.userInput === "" || this.userInput === " ", u = this.#n, d = this.options, c = u !== void 0 && u !== "" && d.some((o) => !o.disabled && (this.#t ? this.#t(u, o) : true));
730
+ if (t.name === "tab" && r && c) {
731
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
732
+ return;
733
+ }
734
+ if (t.name === "tab" && this.#l && !this.multiple && this.focusedValue !== void 0) {
735
+ const o = String(this.focusedValue);
736
+ this._clearUserInput(), this._setUserInput(o, true), this.isNavigating = false;
737
+ return;
738
+ }
739
+ i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = g(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (t.name === "tab" || this.isNavigating && t.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
740
+ }
741
+ deselectAll() {
742
+ this.selectedValues = [];
743
+ }
744
+ toggleSelected(e) {
745
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t) => t !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
746
+ }
747
+ #o(e) {
748
+ if (e !== this.#s) {
749
+ this.#s = e;
750
+ const t = this.options;
751
+ e && this.#t ? this.filteredOptions = t.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t];
752
+ const i = p$1(this.focusedValue, this.filteredOptions);
753
+ this.#e = findCursor(i, 0, this.filteredOptions);
754
+ const s = this.filteredOptions[this.#e];
755
+ s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
756
+ }
757
+ }
758
+ };
759
+ var r = class extends C$1 {
760
+ get cursor() {
761
+ return this.value ? 0 : 1;
762
+ }
763
+ get _value() {
764
+ return this.cursor === 0;
765
+ }
766
+ constructor(t) {
767
+ super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
768
+ this.value = this._value;
769
+ }), this.on("confirm", (i) => {
770
+ this.output.write(cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
771
+ }), this.on("cursor", () => {
772
+ this.value = !this.value;
773
+ });
774
+ }
775
+ };
776
+ const _ = {
777
+ Y: {
778
+ type: "year",
779
+ len: 4
780
+ },
781
+ M: {
782
+ type: "month",
783
+ len: 2
784
+ },
785
+ D: {
786
+ type: "day",
787
+ len: 2
788
+ }
789
+ };
790
+ function M(r) {
791
+ return [...r].map((t) => _[t]);
792
+ }
793
+ function P$1(r) {
794
+ const i = new Intl.DateTimeFormat(r, {
795
+ year: "numeric",
796
+ month: "2-digit",
797
+ day: "2-digit"
798
+ }).formatToParts(new Date(2e3, 0, 15)), s = [];
799
+ let n = "/";
800
+ for (const e of i) e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({
801
+ type: e.type,
802
+ len: e.type === "year" ? 4 : 2
803
+ });
804
+ return {
805
+ segments: s,
806
+ separator: n
807
+ };
808
+ }
809
+ function p$2(r) {
810
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
811
+ }
812
+ function f(r) {
813
+ return {
814
+ year: p$2(r.year),
815
+ month: p$2(r.month),
816
+ day: p$2(r.day)
817
+ };
818
+ }
819
+ function c$1(r, t) {
820
+ return new Date(r || 2001, t || 1, 0).getDate();
821
+ }
822
+ function b$1(r) {
823
+ const { year: t, month: i, day: s } = f(r);
824
+ if (!t || t < 0 || t > 9999 || !i || i < 1 || i > 12 || !s || s < 1) return;
825
+ const n = new Date(Date.UTC(t, i - 1, s));
826
+ if (!(n.getUTCFullYear() !== t || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s)) return {
827
+ year: t,
828
+ month: i,
829
+ day: s
830
+ };
831
+ }
832
+ function C$2(r) {
833
+ const t = b$1(r);
834
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
835
+ }
836
+ function T(r, t, i, s) {
837
+ const n = i ? {
838
+ year: i.getUTCFullYear(),
839
+ month: i.getUTCMonth() + 1,
840
+ day: i.getUTCDate()
841
+ } : null, e = s ? {
842
+ year: s.getUTCFullYear(),
843
+ month: s.getUTCMonth() + 1,
844
+ day: s.getUTCDate()
845
+ } : null;
846
+ return r === "year" ? {
847
+ min: n?.year ?? 1,
848
+ max: e?.year ?? 9999
849
+ } : r === "month" ? {
850
+ min: n && t.year === n.year ? n.month : 1,
851
+ max: e && t.year === e.year ? e.month : 12
852
+ } : {
853
+ min: n && t.year === n.year && t.month === n.month ? n.day : 1,
854
+ max: e && t.year === e.year && t.month === e.month ? e.day : c$1(t.year, t.month)
855
+ };
856
+ }
857
+ var U$1 = class extends C$1 {
858
+ #i;
859
+ #o;
860
+ #t;
861
+ #h;
862
+ #u;
863
+ #e = {
864
+ segmentIndex: 0,
865
+ positionInSegment: 0
866
+ };
867
+ #n = true;
868
+ #s = null;
869
+ inlineError = "";
870
+ get segmentCursor() {
871
+ return { ...this.#e };
872
+ }
873
+ get segmentValues() {
874
+ return { ...this.#t };
875
+ }
876
+ get segments() {
877
+ return this.#i;
878
+ }
879
+ get separator() {
880
+ return this.#o;
881
+ }
882
+ get formattedValue() {
883
+ return this.#l(this.#t);
884
+ }
885
+ #l(t) {
886
+ return this.#i.map((i) => t[i.type]).join(this.#o);
887
+ }
888
+ #r() {
889
+ this._setUserInput(this.#l(this.#t)), this._setValue(C$2(this.#t) ?? void 0);
890
+ }
891
+ constructor(t) {
892
+ const i = t.format ? {
893
+ segments: M(t.format),
894
+ separator: t.separator ?? "/"
895
+ } : P$1(t.locale), s = t.separator ?? i.separator, n = t.format ? M(t.format) : i.segments, e = t.initialValue ?? t.defaultValue, m = e ? {
896
+ year: String(e.getUTCFullYear()).padStart(4, "0"),
897
+ month: String(e.getUTCMonth() + 1).padStart(2, "0"),
898
+ day: String(e.getUTCDate()).padStart(2, "0")
899
+ } : {
900
+ year: "____",
901
+ month: "__",
902
+ day: "__"
903
+ }, o = n.map((a) => m[a.type]).join(s);
904
+ super({
905
+ ...t,
906
+ initialUserInput: o
907
+ }, false), this.#i = n, this.#o = s, this.#t = m, this.#h = t.minDate, this.#u = t.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t));
908
+ }
909
+ #a() {
910
+ const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t];
911
+ if (i) return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), {
912
+ segment: i,
913
+ index: t
914
+ };
915
+ }
916
+ #m(t) {
917
+ this.inlineError = "", this.#s = null;
918
+ const i = this.#a();
919
+ i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t)), this.#e.positionInSegment = 0, this.#n = true);
920
+ }
921
+ #d(t) {
922
+ const i = this.#a();
923
+ if (!i) return;
924
+ const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T(s.type, f(this.#t), this.#h, this.#u);
925
+ let a;
926
+ e ? a = t === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m + t), o.min), this.#t = {
927
+ ...this.#t,
928
+ [s.type]: a.toString().padStart(s.len, "0")
929
+ }, this.#n = true, this.#s = null, this.#r();
930
+ }
931
+ #f(t) {
932
+ if (t) switch (t) {
933
+ case "right": return this.#m(1);
934
+ case "left": return this.#m(-1);
935
+ case "up": return this.#d(1);
936
+ case "down": return this.#d(-1);
937
+ }
938
+ }
939
+ #y(t, i) {
940
+ if (i?.name === "backspace" || i?.sequence === "" || i?.sequence === "\b" || t === "" || t === "\b") {
941
+ this.inlineError = "";
942
+ const n = this.#a();
943
+ if (!n) return;
944
+ if (!this.#t[n.segment.type].replace(/_/g, "")) {
945
+ this.#m(-1);
946
+ return;
947
+ }
948
+ this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
949
+ return;
950
+ }
951
+ if (i?.name === "tab") {
952
+ this.inlineError = "";
953
+ const n = this.#a();
954
+ if (!n) return;
955
+ const e = i.shift ? -1 : 1, m = n.index + e;
956
+ m >= 0 && m < this.#i.length && (this.#e.segmentIndex = m, this.#e.positionInSegment = 0, this.#n = true);
957
+ return;
958
+ }
959
+ if (t && /^[0-9]$/.test(t)) {
960
+ const n = this.#a();
961
+ if (!n) return;
962
+ const { segment: e } = n, m = !this.#t[e.type].replace(/_/g, "");
963
+ if (this.#n && this.#s !== null && !m) {
964
+ const h = this.#s + t, d = {
965
+ ...this.#t,
966
+ [e.type]: h
967
+ }, g = this.#g(d, e);
968
+ if (g) {
969
+ this.inlineError = g, this.#s = null, this.#n = false;
970
+ return;
971
+ }
972
+ this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
973
+ return;
974
+ }
975
+ this.#n && !m && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
976
+ const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
977
+ if (u < 0 || u >= e.len) return;
978
+ let l = o.slice(0, u) + t + o.slice(u + 1), D = false;
979
+ if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
980
+ const h = Number.parseInt(t, 10);
981
+ l = `0${t}`, D = h <= (e.type === "month" ? 1 : 2);
982
+ }
983
+ if (e.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(e.len, "_")), !l.includes("_")) {
984
+ const h = {
985
+ ...this.#t,
986
+ [e.type]: l
987
+ }, d = this.#g(h, e);
988
+ if (d) {
989
+ this.inlineError = d;
990
+ return;
991
+ }
992
+ }
993
+ this.inlineError = "", this.#t[e.type] = l;
994
+ const y = l.includes("_") ? void 0 : b$1(this.#t);
995
+ if (y) {
996
+ const { year: h, month: d } = y, g = c$1(h, d);
997
+ this.#t = {
998
+ year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
999
+ month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
1000
+ day: String(Math.max(1, Math.min(g, y.day))).padStart(2, "0")
1001
+ };
1002
+ }
1003
+ this.#r();
1004
+ const S = l.indexOf("_");
1005
+ D ? (this.#n = true, this.#s = t) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
1006
+ }
1007
+ }
1008
+ #g(t, i) {
1009
+ const { month: s, day: n } = f(t);
1010
+ if (i.type === "month" && (s < 0 || s > 12)) return settings.date.messages.invalidMonth;
1011
+ if (i.type === "day" && (n < 0 || n > 31)) return settings.date.messages.invalidDay(31, "any month");
1012
+ }
1013
+ #p(t) {
1014
+ const { year: i, month: s, day: n } = f(this.#t);
1015
+ if (i && s && n) {
1016
+ const e = c$1(i, s);
1017
+ this.#t = {
1018
+ ...this.#t,
1019
+ day: String(Math.min(n, e)).padStart(2, "0")
1020
+ };
1021
+ }
1022
+ this.value = C$2(this.#t) ?? t.defaultValue ?? void 0;
1023
+ }
1024
+ };
1025
+ let u$1 = class u extends C$1 {
1026
+ options;
1027
+ cursor = 0;
1028
+ #e;
1029
+ getGroupItems(t) {
1030
+ return this.options.filter((i) => i.group === t);
1031
+ }
1032
+ isGroupSelected(t) {
1033
+ const i = this.getGroupItems(t), e = this.value;
1034
+ return e === void 0 ? false : i.every((s) => e.includes(s.value));
1035
+ }
1036
+ toggleValue() {
1037
+ const t = this.options[this.cursor];
1038
+ if (t !== void 0) if (this.value === void 0 && (this.value = []), t.group === true) {
1039
+ const i = t.value, e = this.getGroupItems(i);
1040
+ this.isGroupSelected(i) ? this.value = this.value.filter((s) => e.findIndex((r) => r.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
1041
+ } else {
1042
+ const i = this.value.includes(t.value);
1043
+ this.value = i ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
1044
+ }
1045
+ }
1046
+ constructor(t) {
1047
+ super(t, false);
1048
+ const { options: i } = t;
1049
+ this.#e = t.selectableGroups !== false, this.options = Object.entries(i).flatMap(([e, s]) => [{
1050
+ value: e,
1051
+ group: true,
1052
+ label: e
1053
+ }, ...s.map((r) => ({
1054
+ ...r,
1055
+ group: e
1056
+ }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), this.#e ? 0 : 1), this.on("key", (e, s) => {
1057
+ s.name === void 0 && e === " " && this.toggleValue();
1058
+ }), this.on("cursor", (e) => {
1059
+ switch (e) {
1060
+ case "left":
1061
+ case "up": {
1062
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
1063
+ const s = this.options[this.cursor]?.group === true;
1064
+ !this.#e && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
1065
+ break;
1066
+ }
1067
+ case "down":
1068
+ case "right": {
1069
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
1070
+ const s = this.options[this.cursor]?.group === true;
1071
+ !this.#e && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
1072
+ break;
1073
+ }
1074
+ case "space": this.toggleValue();
1075
+ }
1076
+ });
1077
+ }
1078
+ };
1079
+ const o = /* @__PURE__ */ new Set([
1080
+ "up",
1081
+ "down",
1082
+ "left",
1083
+ "right"
1084
+ ]);
1085
+ var h = class extends C$1 {
1086
+ #t = false;
1087
+ #s;
1088
+ focused = "editor";
1089
+ get userInputWithCursor() {
1090
+ if (this.state === "submit") return this.userInput;
1091
+ const t = this.userInput;
1092
+ if (this.cursor >= t.length) return `${t}\u2588`;
1093
+ const s = t.slice(0, this.cursor), r = t.slice(this.cursor, this.cursor + 1), i = t.slice(this.cursor + 1);
1094
+ return r === `
1095
+ ` ? `${s}\u2588
1096
+ ${i}` : `${s}${styleText("inverse", r)}${i}`;
1097
+ }
1098
+ get cursor() {
1099
+ return this._cursor;
1100
+ }
1101
+ #r(t) {
1102
+ if (this.userInput.length === 0) {
1103
+ this._setUserInput(t);
1104
+ return;
1105
+ }
1106
+ this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
1107
+ }
1108
+ #i(t) {
1109
+ const s = this.value ?? "";
1110
+ switch (t) {
1111
+ case "up":
1112
+ this._cursor = findTextCursor(this._cursor, 0, -1, s);
1113
+ return;
1114
+ case "down":
1115
+ this._cursor = findTextCursor(this._cursor, 0, 1, s);
1116
+ return;
1117
+ case "left":
1118
+ this._cursor = findTextCursor(this._cursor, -1, 0, s);
1119
+ return;
1120
+ case "right":
1121
+ this._cursor = findTextCursor(this._cursor, 1, 0, s);
1122
+ return;
1123
+ }
1124
+ }
1125
+ _shouldSubmit(t, s) {
1126
+ if (this.#s) return this.focused === "submit" ? true : (this.#r(`
1127
+ `), this._cursor++, false);
1128
+ const r = this.#t;
1129
+ return this.#t = true, r && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
1130
+ ` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
1131
+ `), this._cursor++, false);
1132
+ }
1133
+ constructor(t) {
1134
+ const s = t.initialUserInput ?? t.initialValue;
1135
+ super({
1136
+ ...t,
1137
+ initialUserInput: s
1138
+ }, false), s !== void 0 && (this._cursor = s.length), this.#s = t.showSubmit ?? false, this.on("key", (r, i) => {
1139
+ if (i?.name && o.has(i.name)) {
1140
+ this.#t = false, this.#i(i.name);
1141
+ return;
1142
+ }
1143
+ if (r === " " && this.#s) {
1144
+ this.focused = this.focused === "editor" ? "submit" : "editor";
1145
+ return;
1146
+ }
1147
+ if (i?.name !== "return") {
1148
+ if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
1149
+ this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
1150
+ return;
1151
+ }
1152
+ if (i?.name === "delete" && this.cursor < this.userInput.length) {
1153
+ this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
1154
+ return;
1155
+ }
1156
+ r && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r ?? ""), this._cursor++);
1157
+ }
1158
+ }), this.on("userInput", (r) => {
1159
+ this._setValue(r);
1160
+ }), this.on("finalize", () => {
1161
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
1162
+ });
1163
+ }
1164
+ };
1165
+ var a = class extends C$1 {
1166
+ options;
1167
+ cursor = 0;
1168
+ get _value() {
1169
+ return this.options[this.cursor]?.value;
1170
+ }
1171
+ get _enabledOptions() {
1172
+ return this.options.filter((e) => e.disabled !== true);
1173
+ }
1174
+ toggleAll() {
1175
+ const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
1176
+ this.value = i ? [] : e.map((t) => t.value);
1177
+ }
1178
+ toggleInvert() {
1179
+ const e = this.value;
1180
+ if (!e) return;
1181
+ const i = this._enabledOptions.filter((t) => !e.includes(t.value));
1182
+ this.value = i.map((t) => t.value);
1183
+ }
1184
+ toggleValue() {
1185
+ this.value === void 0 && (this.value = []);
1186
+ const e = this.value.includes(this._value);
1187
+ this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
1188
+ }
1189
+ constructor(e) {
1190
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
1191
+ const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
1192
+ this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, s) => {
1193
+ s.name === "a" && this.toggleAll(), s.name === "i" && this.toggleInvert(), s.name === void 0 && t === " " && this.toggleValue();
1194
+ }), this.on("cursor", (t) => {
1195
+ switch (t) {
1196
+ case "left":
1197
+ case "up":
1198
+ this.cursor = findCursor(this.cursor, -1, this.options);
1199
+ break;
1200
+ case "down":
1201
+ case "right":
1202
+ this.cursor = findCursor(this.cursor, 1, this.options);
1203
+ break;
1204
+ case "space": this.toggleValue();
1205
+ }
1206
+ });
1207
+ }
1208
+ };
1209
+ var u$2 = class extends C$1 {
1210
+ _mask = "•";
1211
+ get cursor() {
1212
+ return this._cursor;
1213
+ }
1214
+ get masked() {
1215
+ return this.userInput.replaceAll(/./g, this._mask);
1216
+ }
1217
+ get userInputWithCursor() {
1218
+ if (this.state === "submit" || this.state === "cancel") return this.masked;
1219
+ const t = this.userInput;
1220
+ if (this.cursor >= t.length) return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
1221
+ const s = this.masked, r = s.slice(0, this.cursor), i = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
1222
+ return `${r}${styleText("inverse", i)}${o}`;
1223
+ }
1224
+ clear() {
1225
+ this._clearUserInput();
1226
+ }
1227
+ constructor({ mask: t, ...s }) {
1228
+ super(s), this._mask = t ?? "•", this.on("userInput", (r) => {
1229
+ this._setValue(r);
1230
+ }), this.on("finalize", () => {
1231
+ this.value === void 0 && (this.value = "");
1232
+ });
1233
+ }
1234
+ };
1235
+ let n$1 = class n extends C$1 {
1236
+ options;
1237
+ cursor = 0;
1238
+ get _selectedValue() {
1239
+ return this.options[this.cursor];
1240
+ }
1241
+ changeValue() {
1242
+ const e = this._selectedValue;
1243
+ this.value = e === void 0 ? void 0 : e.value;
1244
+ }
1245
+ constructor(e) {
1246
+ super(e, false), this.options = e.options;
1247
+ const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t = o === -1 ? 0 : o;
1248
+ this.cursor = this.options[t]?.disabled ? findCursor(t, 1, this.options) : t, this.changeValue(), this.on("cursor", (s) => {
1249
+ switch (s) {
1250
+ case "left":
1251
+ case "up":
1252
+ this.cursor = findCursor(this.cursor, -1, this.options);
1253
+ break;
1254
+ case "down":
1255
+ case "right": this.cursor = findCursor(this.cursor, 1, this.options);
1256
+ }
1257
+ this.changeValue();
1258
+ });
1259
+ }
1260
+ };
1261
+ var c$2 = class extends C$1 {
1262
+ options;
1263
+ cursor = 0;
1264
+ constructor(t) {
1265
+ super(t, false), this.options = t.options;
1266
+ const s = t.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase()), n = Math.max(i.indexOf(t.initialValue), 0);
1267
+ this.cursor = this.options[n]?.disabled ? 0 : n, this.on("key", (e) => {
1268
+ if (!e) return;
1269
+ const o = s ? e : e.toLowerCase();
1270
+ if (!i.includes(o)) return;
1271
+ const r = this.options.find(({ value: [a], disabled: u }) => u ? false : s ? a === o : a?.toLowerCase() === o);
1272
+ r && (this.value = r.value, this.state = "submit", this.emit("submit"));
1273
+ });
1274
+ }
1275
+ };
1276
+ var n = class extends C$1 {
1277
+ get userInputWithCursor() {
1278
+ if (this.state === "submit") return this.userInput;
1279
+ const t = this.userInput;
1280
+ if (this.cursor >= t.length) return `${this.userInput}\u2588`;
1281
+ const r = t.slice(0, this.cursor), s = t.slice(this.cursor, this.cursor + 1), e = t.slice(this.cursor + 1);
1282
+ return `${r}${styleText("inverse", s)}${e}`;
1283
+ }
1284
+ get cursor() {
1285
+ return this._cursor;
1286
+ }
1287
+ constructor(t) {
1288
+ super({
1289
+ ...t,
1290
+ initialUserInput: t.initialUserInput ?? t.initialValue
1291
+ }), this.on("userInput", (r) => {
1292
+ this._setValue(r);
1293
+ }), this.on("finalize", () => {
1294
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
1295
+ });
1296
+ }
1297
+ };
1298
+ // ../../node_modules/.pnpm/@clack+prompts@1.9.0/node_modules/@clack/prompts/dist/index.mjs
1299
+ function isUnicodeSupported() {
1300
+ if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
1301
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1302
+ }
1303
+ const unicode = isUnicodeSupported();
1304
+ const isCI = () => process.env.CI === "true";
1305
+ const isTTY = (e) => e.isTTY === true;
1306
+ const unicodeOr = (e, o) => unicode ? e : o;
1307
+ const S_STEP_ACTIVE = unicodeOr("◆", "*");
1308
+ const S_STEP_CANCEL = unicodeOr("■", "x");
1309
+ const S_STEP_ERROR = unicodeOr("▲", "x");
1310
+ const S_STEP_SUBMIT = unicodeOr("◇", "o");
1311
+ const S_BAR_START = unicodeOr("┌", "T");
1312
+ const S_BAR = unicodeOr("│", "|");
1313
+ const S_BAR_END = unicodeOr("└", "—");
1314
+ const S_BAR_START_RIGHT = unicodeOr("┐", "T");
1315
+ const S_BAR_END_RIGHT = unicodeOr("┘", "—");
1316
+ const S_RADIO_ACTIVE = unicodeOr("●", ">");
1317
+ const S_RADIO_INACTIVE = unicodeOr("○", " ");
1318
+ const S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
1319
+ const S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
1320
+ const S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
1321
+ const S_PASSWORD_MASK = unicodeOr("▪", "•");
1322
+ const S_BAR_H = unicodeOr("─", "-");
1323
+ const S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
1324
+ const S_CONNECT_LEFT = unicodeOr("├", "+");
1325
+ const S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
1326
+ const S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
1327
+ const S_CORNER_TOP_LEFT = unicodeOr("╭", "+");
1328
+ const S_INFO = unicodeOr("●", "•");
1329
+ const S_SUCCESS = unicodeOr("◆", "*");
1330
+ const S_WARN = unicodeOr("▲", "!");
1331
+ const S_ERROR = unicodeOr("■", "x");
1332
+ const symbol = (e) => {
1333
+ switch (e) {
1334
+ case "initial":
1335
+ case "active": return styleText("cyan", S_STEP_ACTIVE);
1336
+ case "cancel": return styleText("red", S_STEP_CANCEL);
1337
+ case "error": return styleText("yellow", S_STEP_ERROR);
1338
+ case "submit": return styleText("green", S_STEP_SUBMIT);
1339
+ case "validating": return styleText("dim", S_STEP_ACTIVE);
1340
+ }
1341
+ };
1342
+ const symbolBar = (e) => {
1343
+ switch (e) {
1344
+ case "initial":
1345
+ case "active": return styleText("cyan", S_BAR);
1346
+ case "cancel": return styleText("red", S_BAR);
1347
+ case "error": return styleText("yellow", S_BAR);
1348
+ case "submit": return styleText("green", S_BAR);
1349
+ }
1350
+ };
1351
+ function formatInstructionFooter(e, o, r) {
1352
+ const s = r ? `${styleText("cyan", S_BAR)} ` : "", n = wrapTextWithPrefix(e, o.join(" • "), s).split(`
1353
+ `);
1354
+ return r && n.push(styleText("cyan", S_BAR_END)), n;
1355
+ }
1356
+ const E$1 = (l, e, w, p, b, C = false) => {
1357
+ let r = e, O = 0;
1358
+ if (C) for (let i = p - 1; i >= w; i--) {
1359
+ const m = l[i];
1360
+ if (m && (r -= m.length), O++, r <= b) break;
1361
+ }
1362
+ else for (let i = w; i < p; i++) {
1363
+ const m = l[i];
1364
+ if (m && (r -= m.length), O++, r <= b) break;
1365
+ }
1366
+ return {
1367
+ lineCount: r,
1368
+ removals: O
1369
+ };
1370
+ };
1371
+ const limitOptions = ({ cursor: l, options: e, style: w, output: p = process.stdout, maxItems: b = Number.POSITIVE_INFINITY, columnPadding: C = 0, rowPadding: r = 4 }) => {
1372
+ const i = getColumns(p) - C, m = getRows(p), M = styleText("dim", "..."), v = Math.max(m - r, 0), a = Math.max(Math.min(b, v), 5);
1373
+ let f = 0;
1374
+ l >= a - 3 && (f = Math.max(Math.min(l - a + 3, e.length - a), 0));
1375
+ let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
1376
+ const I = Math.min(f + a, e.length), s = [];
1377
+ let g = 0;
1378
+ d && g++, c && g++;
1379
+ const T = f + (d ? 1 : 0), W = I - (c ? 1 : 0);
1380
+ for (let t = T; t < W; t++) {
1381
+ const n = e[t], h = wrapAnsi(n !== void 0 ? w(n, t === l) : "", i, {
1382
+ hard: true,
1383
+ trim: false
1384
+ }).split(`
1385
+ `);
1386
+ s.push(h), g += h.length;
1387
+ }
1388
+ if (g > v) {
1389
+ let t = 0, n = 0, o = g;
1390
+ const h = l - T;
1391
+ let u = v;
1392
+ const L = () => E$1(s, o, 0, h, u), y = () => E$1(s, o, h + 1, s.length, u, true);
1393
+ d ? ({lineCount: o, removals: t} = L(), o > u && (c || (u -= 1), {lineCount: o, removals: n} = y())) : (c || (u -= 1), {lineCount: o, removals: n} = y(), o > u && (u -= 1, {lineCount: o, removals: t} = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
1394
+ }
1395
+ const x = [];
1396
+ d && x.push(M);
1397
+ for (const t of s) for (const n of t) x.push(n);
1398
+ return c && x.push(M), x;
1399
+ };
1400
+ function E(t) {
1401
+ return t.label ?? String(t.value ?? "");
1402
+ }
1403
+ function P(t, c) {
1404
+ if (!t) return true;
1405
+ const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), r = String(c.value).toLowerCase(), o = t.toLowerCase();
1406
+ return n.includes(o) || i.includes(o) || r.includes(o);
1407
+ }
1408
+ function j(t, c) {
1409
+ const n = [];
1410
+ for (const i of c) t.includes(i.value) && n.push(i);
1411
+ return n;
1412
+ }
1413
+ const autocomplete = (t) => new T$1({
1414
+ options: t.options,
1415
+ initialValue: t.initialValue !== void 0 ? [t.initialValue] : void 0,
1416
+ initialUserInput: t.initialUserInput,
1417
+ placeholder: t.placeholder,
1418
+ completeOnTab: t.completeOnTab,
1419
+ filter: t.filter ?? ((n, i) => P(n, i)),
1420
+ signal: t.signal,
1421
+ input: t.input,
1422
+ output: t.output,
1423
+ validate: t.validate,
1424
+ render() {
1425
+ const n = t.withGuide ?? settings.withGuide, i = n ? [`${styleText("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], r = this.userInput, o = this.options, m = t.placeholder, p = r === "" && m !== void 0, $ = (l, s) => {
1426
+ const a = E(l), u = l.hint && l.value === this.focusedValue ? styleText("dim", ` (${l.hint})`) : "";
1427
+ switch (s) {
1428
+ case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${a}${u}`;
1429
+ case "inactive": return `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`;
1430
+ case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${styleText(["strikethrough", "gray"], a)}`;
1431
+ }
1432
+ };
1433
+ switch (this.state) {
1434
+ case "submit": {
1435
+ const l = j(this.selectedValues, o), s = l.length > 0 ? ` ${styleText("dim", l.map(E).join(", "))}` : "", a = n ? styleText("gray", S_BAR) : "";
1436
+ return `${i.join(`
1437
+ `)}
1438
+ ${a}${s}`;
1439
+ }
1440
+ case "cancel": {
1441
+ const l = r ? ` ${styleText(["strikethrough", "dim"], r)}` : "", s = n ? styleText("gray", S_BAR) : "";
1442
+ return `${i.join(`
1443
+ `)}
1444
+ ${s}${l}`;
1445
+ }
1446
+ default: {
1447
+ const l = this.state === "error" ? "yellow" : "cyan", s = n ? `${styleText(l, S_BAR)} ` : "", a = n ? styleText(l, S_BAR_END) : "";
1448
+ let u = "";
1449
+ if (this.isNavigating || p) {
1450
+ const d = p ? m : r;
1451
+ u = d !== "" ? ` ${styleText("dim", d)}` : "";
1452
+ } else u = ` ${this.userInputWithCursor}`;
1453
+ const V = this.filteredOptions.length !== o.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", b = this.filteredOptions.length === 0 && r ? [`${s}${styleText("yellow", "No matches found")}`] : [], y = this.state === "error" ? [`${s}${styleText("yellow", this.error)}`] : [];
1454
+ n && i.push(`${s.trimEnd()}`), i.push(`${s}${styleText("dim", "Search:")}${u}${V}`, ...b, ...y);
1455
+ const g = [`${s}${[
1456
+ `${styleText("dim", "↑/↓")} to select`,
1457
+ ...t.completeOnTab ? [`${styleText("dim", "Tab:")} complete`] : [],
1458
+ `${styleText("dim", "Enter:")} confirm`,
1459
+ `${styleText("dim", "Type:")} to search`
1460
+ ].join(" • ")}`, a], O = this.filteredOptions.length === 0 ? [] : limitOptions({
1461
+ cursor: this.cursor,
1462
+ options: this.filteredOptions,
1463
+ columnPadding: n ? 3 : 0,
1464
+ rowPadding: i.length + g.length,
1465
+ style: (d, f) => $(d, d.disabled ? "disabled" : f ? "active" : "inactive"),
1466
+ maxItems: t.maxItems,
1467
+ output: t.output
1468
+ });
1469
+ return [
1470
+ ...i,
1471
+ ...O.map((d) => `${s}${d}`),
1472
+ ...g
1473
+ ].join(`
1474
+ `);
1475
+ }
1476
+ }
1477
+ }
1478
+ }).prompt();
1479
+ const autocompleteMultiselect = (t) => {
1480
+ const c = (i, r, o, m) => {
1481
+ const p = o.includes(i.value), $ = i.label ?? String(i.value ?? ""), l = i.hint && m !== void 0 && i.value === m ? styleText("dim", ` (${i.hint})`) : "", s = p ? styleText("green", S_CHECKBOX_SELECTED) : styleText("dim", S_CHECKBOX_INACTIVE);
1482
+ return i.disabled ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${styleText(["strikethrough", "gray"], $)}` : r ? `${s} ${$}${l}` : `${s} ${styleText("dim", $)}`;
1483
+ }, n = new T$1({
1484
+ options: t.options,
1485
+ multiple: true,
1486
+ placeholder: t.placeholder,
1487
+ filter: t.filter ?? ((i, r) => P(i, r)),
1488
+ validate: () => {
1489
+ if (t.required && n.selectedValues.length === 0) return "Please select at least one item";
1490
+ },
1491
+ initialValue: t.initialValues,
1492
+ signal: t.signal,
1493
+ input: t.input,
1494
+ output: t.output,
1495
+ render() {
1496
+ const i = t.withGuide ?? settings.withGuide, r = `${i ? `${styleText("gray", S_BAR)}
1497
+ ` : ""}${symbol(this.state)} ${t.message}
1498
+ `, o = this.userInput, m = t.placeholder, p = o === "" && m !== void 0, $ = this.isNavigating || p ? styleText("dim", p ? m : o) : this.userInputWithCursor, l = this.options, s = this.filteredOptions.length !== l.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
1499
+ switch (this.state) {
1500
+ case "submit": return `${r}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText("dim", `${this.selectedValues.length} items selected`)}`;
1501
+ case "cancel": return `${r}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(["strikethrough", "dim"], o)}`;
1502
+ default: {
1503
+ const a = this.state === "error" ? "yellow" : "cyan", u = i ? `${styleText(a, S_BAR)} ` : "", V = i ? styleText(a, S_BAR_END) : "", b = [
1504
+ `${styleText("dim", "↑/↓")} to navigate`,
1505
+ `${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
1506
+ `${styleText("dim", "Enter:")} confirm`,
1507
+ `${styleText("dim", "Type:")} to search`
1508
+ ], y = this.filteredOptions.length === 0 && o ? [`${u}${styleText("yellow", "No matches found")}`] : [], S = this.state === "error" ? [`${u}${styleText("yellow", this.error)}`] : [], g = [
1509
+ ...`${r}${i ? styleText(a, S_BAR) : ""}`.split(`
1510
+ `),
1511
+ `${u}${styleText("dim", "Search:")} ${$}${s}`,
1512
+ ...y,
1513
+ ...S
1514
+ ], O = [`${u}${b.join(" • ")}`, V], d = limitOptions({
1515
+ cursor: this.cursor,
1516
+ options: this.filteredOptions,
1517
+ style: (f, L) => c(f, L, this.selectedValues, this.focusedValue),
1518
+ maxItems: t.maxItems,
1519
+ output: t.output,
1520
+ rowPadding: g.length + O.length
1521
+ });
1522
+ return [
1523
+ ...g,
1524
+ ...d.map((f) => `${u}${f}`),
1525
+ ...O
1526
+ ].join(`
1527
+ `);
1528
+ }
1529
+ }
1530
+ }
1531
+ });
1532
+ return n.prompt();
1533
+ };
1534
+ const K = [
1535
+ S_CORNER_TOP_LEFT,
1536
+ S_CORNER_TOP_RIGHT,
1537
+ S_CORNER_BOTTOM_LEFT,
1538
+ S_CORNER_BOTTOM_RIGHT
1539
+ ];
1540
+ const Q = [
1541
+ S_BAR_START,
1542
+ S_BAR_START_RIGHT,
1543
+ S_BAR_END,
1544
+ S_BAR_END_RIGHT
1545
+ ];
1546
+ function A$1(n, e, t, o) {
1547
+ let i = t, f = t;
1548
+ return o === "center" ? i = Math.floor((e - n) / 2) : o === "right" && (i = e - n - t), f = e - i - n, [i, f];
1549
+ }
1550
+ const U = (n) => n;
1551
+ const box = (n = "", e = "", t) => {
1552
+ const o = t?.output ?? process.stdout, i = getColumns(o), R = 2, u = t?.titlePadding ?? 1, h = t?.contentPadding ?? 2, w = t?.width === void 0 || t.width === "auto" ? 1 : Math.min(1, t.width), m = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)} ` : "", b = t?.formatBorder ?? U, a = (t?.rounded ? K : Q).map(b), _ = b(S_BAR_H), p = b(S_BAR), x = fastStringWidth(m), B = fastStringWidth(e), y = i - x;
1553
+ let r = Math.floor(i * w) - x;
1554
+ if (t?.width === "auto") {
1555
+ const c = n.split(`
1556
+ `);
1557
+ let s = B + u * 2;
1558
+ for (const G of c) {
1559
+ const P = fastStringWidth(G) + h * 2;
1560
+ P > s && (s = P);
1561
+ }
1562
+ const g = s + R;
1563
+ g < r && (r = g);
1564
+ }
1565
+ r % 2 !== 0 && (r < y ? r++ : r--);
1566
+ const d = r - R, T = d - u * 2, S = B > T ? `${e.slice(0, T - 3)}...` : e, [O, W] = A$1(fastStringWidth(S), d, u, t?.titleAlign), L = wrapAnsi(n, d - h * 2, {
1567
+ hard: true,
1568
+ trim: false
1569
+ });
1570
+ o.write(`${m}${a[0]}${_.repeat(O)}${S}${_.repeat(W)}${a[1]}
1571
+ `);
1572
+ const E = L.split(`
1573
+ `);
1574
+ for (const c of E) {
1575
+ const [s, g] = A$1(fastStringWidth(c), d, h, t?.contentAlign);
1576
+ o.write(`${m}${p}${" ".repeat(s)}${c}${" ".repeat(g)}${p}
1577
+ `);
1578
+ }
1579
+ o.write(`${m}${a[2]}${_.repeat(d)}${a[3]}
1580
+ `);
1581
+ };
1582
+ const confirm = (e) => {
1583
+ const a = e.active ?? "Yes", o = e.inactive ?? "No";
1584
+ return new r({
1585
+ active: a,
1586
+ inactive: o,
1587
+ signal: e.signal,
1588
+ input: e.input,
1589
+ output: e.output,
1590
+ initialValue: e.initialValue ?? true,
1591
+ render() {
1592
+ const i = e.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = i ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(e.output, e.message, l, u), s = `${i ? `${styleText("gray", S_BAR)}
1593
+ ` : ""}${f}
1594
+ `, c = this.value ? a : o;
1595
+ switch (this.state) {
1596
+ case "submit": return `${s}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText("dim", c)}`;
1597
+ case "cancel": return `${s}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(["strikethrough", "dim"], c)}${i ? `
1598
+ ${styleText("gray", S_BAR)}` : ""}`;
1599
+ default: {
1600
+ const r = i ? `${styleText("cyan", S_BAR)} ` : "", g = i ? styleText("cyan", S_BAR_END) : "";
1601
+ return `${s}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${e.vertical ? i ? `
1602
+ ${styleText("cyan", S_BAR)} ` : `
1603
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", o)}` : `${styleText("green", S_RADIO_ACTIVE)} ${o}`}
1604
+ ${g}
1605
+ `;
1606
+ }
1607
+ }
1608
+ }
1609
+ }).prompt();
1610
+ };
1611
+ const date = (e) => {
1612
+ const r = e.validate;
1613
+ return new U$1({
1614
+ ...e,
1615
+ validate(t) {
1616
+ if (t === void 0) return e.defaultValue !== void 0 ? void 0 : r ? runValidation(r, t) : settings.date.messages.required;
1617
+ const o = (i) => i.toISOString().slice(0, 10);
1618
+ if (e.minDate && o(t) < o(e.minDate)) return settings.date.messages.afterMin(e.minDate);
1619
+ if (e.maxDate && o(t) > o(e.maxDate)) return settings.date.messages.beforeMax(e.maxDate);
1620
+ if (r) return runValidation(r, t);
1621
+ },
1622
+ render() {
1623
+ const t = (e?.withGuide ?? settings.withGuide) !== false, i = `${`${t ? `${styleText("gray", S_BAR)}
1624
+ ` : ""}${symbol(this.state)} `}${e.message}
1625
+ `, l = this.state !== "initial" ? this.state : "active", d = b(this, l), c = this.value instanceof Date ? this.formattedValue : "";
1626
+ switch (this.state) {
1627
+ case "error": {
1628
+ const a = this.error ? ` ${styleText("yellow", this.error)}` : "", s = t ? `${styleText("yellow", S_BAR)} ` : "", f = t ? styleText("yellow", S_BAR_END) : "";
1629
+ return `${i.trim()}
1630
+ ${s}${d}
1631
+ ${f}${a}
1632
+ `;
1633
+ }
1634
+ case "submit": {
1635
+ const a = c ? ` ${styleText("dim", c)}` : "";
1636
+ return `${i}${t ? styleText("gray", S_BAR) : ""}${a}`;
1637
+ }
1638
+ case "cancel": {
1639
+ const a = c ? ` ${styleText(["strikethrough", "dim"], c)}` : "", s = t ? styleText("gray", S_BAR) : "";
1640
+ return `${i}${s}${a}${c.trim() ? `
1641
+ ${s}` : ""}`;
1642
+ }
1643
+ default: {
1644
+ const a = t ? `${styleText("cyan", S_BAR)} ` : "", s = t ? styleText("cyan", S_BAR_END) : "", f = t ? `${styleText("cyan", S_BAR)} ` : "";
1645
+ return `${i}${a}${d}${this.inlineError ? `
1646
+ ${f}${styleText("yellow", this.inlineError)}` : ""}
1647
+ ${s}
1648
+ `;
1649
+ }
1650
+ }
1651
+ }
1652
+ }).prompt();
1653
+ };
1654
+ function b(e, r) {
1655
+ const t = e.segmentValues, o = e.segmentCursor;
1656
+ if (r === "submit" || r === "cancel") return e.formattedValue;
1657
+ const i = styleText("gray", e.separator);
1658
+ return e.segments.map((l, d) => {
1659
+ const c = d === o.segmentIndex && !["submit", "cancel"].includes(r), a = p[l.type];
1660
+ return x(t[l.type], {
1661
+ isActive: c,
1662
+ label: a
1663
+ });
1664
+ }).join(i);
1665
+ }
1666
+ function x(e, r) {
1667
+ const t = !e || e.replace(/_/g, "") === "";
1668
+ return r.isActive ? styleText("inverse", t ? r.label : e.replace(/_/g, " ")) : t ? styleText("dim", r.label) : e.replace(/_/g, styleText("dim", " "));
1669
+ }
1670
+ const p = {
1671
+ year: "yyyy",
1672
+ month: "mm",
1673
+ day: "dd"
1674
+ };
1675
+ const group = async (o, r) => {
1676
+ const t = {}, p = Object.keys(o);
1677
+ for (const e of p) {
1678
+ const i = o[e], n = await i({ results: t })?.catch((a) => {
1679
+ throw a;
1680
+ });
1681
+ if (typeof r?.onCancel == "function" && isCancel(n)) {
1682
+ t[e] = "canceled", r.onCancel({ results: t });
1683
+ continue;
1684
+ }
1685
+ t[e] = n;
1686
+ }
1687
+ return t;
1688
+ };
1689
+ const MULTISELECT_INSTRUCTIONS = [
1690
+ `${styleText("dim", "↑/↓")} to navigate`,
1691
+ `${styleText("dim", "Space:")} select`,
1692
+ `${styleText("dim", "Enter:")} confirm`
1693
+ ];
1694
+ const m = (n, u) => n.split(`
1695
+ `).map((d) => u(d)).join(`
1696
+ `);
1697
+ const multiselect = (n) => {
1698
+ const u = (t, a) => {
1699
+ const r = t.label ?? String(t.value);
1700
+ return a === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${m(r, (o) => styleText(["strikethrough", "gray"], o))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${m(r, (o) => styleText("dim", o))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "cancelled" ? `${m(r, (o) => styleText(["strikethrough", "dim"], o))}` : a === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "submitted" ? `${m(r, (o) => styleText("dim", o))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${m(r, (o) => styleText("dim", o))}`;
1701
+ }, d = n.required ?? true, x = n.showInstructions ?? true;
1702
+ return new a({
1703
+ options: n.options,
1704
+ signal: n.signal,
1705
+ input: n.input,
1706
+ output: n.output,
1707
+ initialValues: n.initialValues,
1708
+ required: d,
1709
+ cursorAt: n.cursorAt,
1710
+ validate(t) {
1711
+ if (d && (t === void 0 || t.length === 0)) return `Please select at least one option.
1712
+ ${styleText("reset", styleText("dim", `Press ${styleText([
1713
+ "gray",
1714
+ "bgWhite",
1715
+ "inverse"
1716
+ ], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
1717
+ },
1718
+ render() {
1719
+ const t = n.withGuide ?? settings.withGuide, a = wrapTextWithPrefix(n.output, n.message, t ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r = `${t ? `${styleText("gray", S_BAR)}
1720
+ ` : ""}${a}
1721
+ `, o = this.value ?? [], g = (i, l) => {
1722
+ if (i.disabled) return u(i, "disabled");
1723
+ const s = o.includes(i.value);
1724
+ return l && s ? u(i, "active-selected") : s ? u(i, "selected") : u(i, l ? "active" : "inactive");
1725
+ };
1726
+ switch (this.state) {
1727
+ case "submit": {
1728
+ const i = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
1729
+ return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}`;
1730
+ }
1731
+ case "cancel": {
1732
+ const i = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "cancelled")).join(styleText("dim", ", "));
1733
+ if (i.trim() === "") return `${r}${styleText("gray", S_BAR)}`;
1734
+ return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}${t ? `
1735
+ ${styleText("gray", S_BAR)}` : ""}`;
1736
+ }
1737
+ case "error": {
1738
+ const i = t ? `${styleText("yellow", S_BAR)} ` : "", l = this.error.split(`
1739
+ `).map(($, v) => v === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", $)}` : ` ${$}`).join(`
1740
+ `), s = r.split(`
1741
+ `).length, h = l.split(`
1742
+ `).length + 1;
1743
+ return `${r}${i}${limitOptions({
1744
+ output: n.output,
1745
+ options: this.options,
1746
+ cursor: this.cursor,
1747
+ maxItems: n.maxItems,
1748
+ columnPadding: i.length,
1749
+ rowPadding: s + h,
1750
+ style: g
1751
+ }).join(`
1752
+ ${i}`)}
1753
+ ${l}
1754
+ `;
1755
+ }
1756
+ default: {
1757
+ const i = t ? `${styleText("cyan", S_BAR)} ` : "", l = r.split(`
1758
+ `).length, s = x ? formatInstructionFooter(n.output, MULTISELECT_INSTRUCTIONS, t) : t ? [styleText("cyan", S_BAR_END)] : [], h = s.join(`
1759
+ `), $ = s.length + 1;
1760
+ return `${r}${i}${limitOptions({
1761
+ output: n.output,
1762
+ options: this.options,
1763
+ cursor: this.cursor,
1764
+ maxItems: n.maxItems,
1765
+ columnPadding: i.length,
1766
+ rowPadding: l + $,
1767
+ style: g
1768
+ }).join(`
1769
+ ${i}`)}
1770
+ ${h}
1771
+ `;
1772
+ }
1773
+ }
1774
+ }
1775
+ }).prompt();
1776
+ };
1777
+ const groupMultiselect = (r) => {
1778
+ const { selectableGroups: f = true, groupSpacing: x = 0 } = r, d = (n, l, p = []) => {
1779
+ const a = n.label ?? String(n.value), t = typeof n.group == "string", u = t && (p[p.indexOf(n) + 1] ?? { group: true }), s = t && u && u.group === true;
1780
+ let o = "", c = "";
1781
+ t && (f ? (o = s ? `${S_BAR_END} ` : `${S_BAR} `, c = s ? " " : `${S_BAR} `) : o = " ");
1782
+ let i = "";
1783
+ if (x > 0 && !t && (i = `
1784
+ `.repeat(x)), l === "active") return wrapTextWithPrefix(r.output, `${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`, `${i}${styleText("dim", o)} `, `${i}${styleText("dim", o)}${styleText("cyan", S_CHECKBOX_ACTIVE)} `, `${i}${styleText("dim", c)} `);
1785
+ if (l === "group-active") return wrapTextWithPrefix(r.output, a, `${i}${o} `, `${i}${o}${styleText("cyan", S_CHECKBOX_ACTIVE)} `, `${i}${c} `, (m) => styleText("dim", m));
1786
+ if (l === "group-active-selected") return wrapTextWithPrefix(r.output, a, `${i}${o} `, `${i}${o}${styleText("green", S_CHECKBOX_SELECTED)} `, `${i}${c} `, (m) => styleText("dim", m));
1787
+ if (l === "selected") {
1788
+ const m = t || f ? styleText("green", S_CHECKBOX_SELECTED) : "";
1789
+ return wrapTextWithPrefix(r.output, `${a}${n.hint ? ` (${n.hint})` : ""}`, `${i}${styleText("dim", o)} `, `${i}${styleText("dim", o)}${m} `, `${i}${styleText("dim", c)} `, (I) => styleText("dim", I));
1790
+ }
1791
+ if (l === "cancelled") return `${styleText(["strikethrough", "dim"], a)}`;
1792
+ if (l === "active-selected") return wrapTextWithPrefix(r.output, `${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`, `${i}${styleText("dim", o)} `, `${i}${styleText("dim", o)}${styleText("green", S_CHECKBOX_SELECTED)} `, `${i}${styleText("dim", c)} `);
1793
+ if (l === "submitted") return `${styleText("dim", a)}`;
1794
+ const h = t || f ? styleText("dim", S_CHECKBOX_INACTIVE) : "";
1795
+ return wrapTextWithPrefix(r.output, a, `${i}${styleText("dim", o)} `, `${i}${styleText("dim", o)}${h} `, `${i}${styleText("dim", c)} `, (m) => styleText("dim", m));
1796
+ }, y = r.required ?? true, S = r.showInstructions ?? true;
1797
+ return new u$1({
1798
+ options: r.options,
1799
+ signal: r.signal,
1800
+ input: r.input,
1801
+ output: r.output,
1802
+ initialValues: r.initialValues,
1803
+ required: y,
1804
+ cursorAt: r.cursorAt,
1805
+ selectableGroups: f,
1806
+ validate(n) {
1807
+ if (y && (n === void 0 || n.length === 0)) return `Please select at least one option.
1808
+ ${styleText("reset", styleText("dim", `Press ${styleText([
1809
+ "gray",
1810
+ "bgWhite",
1811
+ "inverse"
1812
+ ], " space ")} to select, ${styleText("gray", styleText(["bgWhite", "inverse"], " enter "))} to submit`))}`;
1813
+ },
1814
+ render() {
1815
+ const n = r.withGuide ?? settings.withGuide, l = `${n ? `${styleText("gray", S_BAR)}
1816
+ ` : ""}${symbol(this.state)} ${r.message}
1817
+ `, p = this.value ?? [], a = (t, u) => {
1818
+ const s = this.options, o = p.includes(t.value) || t.group === true && this.isGroupSelected(`${t.value}`);
1819
+ return !u && typeof t.group == "string" && this.options[this.cursor]?.value === t.group ? d(t, o ? "group-active-selected" : "group-active", s) : u && o ? d(t, "active-selected", s) : o ? d(t, "selected", s) : d(t, u ? "active" : "inactive", s);
1820
+ };
1821
+ switch (this.state) {
1822
+ case "submit": {
1823
+ const t = this.options.filter(({ value: s }) => p.includes(s)).map((s) => d(s, "submitted")), u = t.length === 0 ? "" : ` ${t.join(styleText("dim", ", "))}`;
1824
+ return `${l}${n ? styleText("gray", S_BAR) : ""}${u}`;
1825
+ }
1826
+ case "cancel": {
1827
+ const t = this.options.filter(({ value: u }) => p.includes(u)).map((u) => d(u, "cancelled")).join(styleText("dim", ", "));
1828
+ return `${l}${n ? `${styleText("gray", S_BAR)} ` : ""}${t.trim() ? `${t}${n ? `
1829
+ ${styleText("gray", S_BAR)}` : ""}` : ""}`;
1830
+ }
1831
+ case "error": {
1832
+ const t = n ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
1833
+ `).map((i, h) => h === 0 ? `${n ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", i)}` : ` ${i}`).join(`
1834
+ `), s = l.split(`
1835
+ `).length, o = u.split(`
1836
+ `).length + 1;
1837
+ return `${l}${t}${limitOptions({
1838
+ output: r.output,
1839
+ options: this.options,
1840
+ cursor: this.cursor,
1841
+ maxItems: r.maxItems,
1842
+ columnPadding: t.length,
1843
+ rowPadding: s + o,
1844
+ style: a
1845
+ }).join(`
1846
+ ${t}`)}
1847
+ ${u}
1848
+ `;
1849
+ }
1850
+ default: {
1851
+ const t = n ? `${styleText("cyan", S_BAR)} ` : "", u = l.split(`
1852
+ `).length, s = S ? formatInstructionFooter(r.output, MULTISELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], o = s.join(`
1853
+ `), c = s.length + 1;
1854
+ return `${l}${t}${limitOptions({
1855
+ output: r.output,
1856
+ options: this.options,
1857
+ cursor: this.cursor,
1858
+ maxItems: r.maxItems,
1859
+ columnPadding: t.length,
1860
+ rowPadding: u + c,
1861
+ style: a
1862
+ }).join(`
1863
+ ${t}`)}
1864
+ ${o}
1865
+ `;
1866
+ }
1867
+ }
1868
+ }
1869
+ }).prompt();
1870
+ };
1871
+ const log = {
1872
+ message: (s = [], { symbol: e = styleText("gray", S_BAR), secondarySymbol: r = styleText("gray", S_BAR), output: m = process.stdout, spacing: l = 1, withGuide: c } = {}) => {
1873
+ const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
1874
+ for (let i = 0; i < l; i++) t.push(f);
1875
+ const g = Array.isArray(s) ? s : s.split(`
1876
+ `);
1877
+ if (g.length > 0) {
1878
+ const [i, ...y] = g;
1879
+ i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
1880
+ for (const p of y) p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
1881
+ }
1882
+ m.write(`${t.join(`
1883
+ `)}
1884
+ `);
1885
+ },
1886
+ info: (s, e) => {
1887
+ log.message(s, {
1888
+ ...e,
1889
+ symbol: styleText("blue", S_INFO)
1890
+ });
1891
+ },
1892
+ success: (s, e) => {
1893
+ log.message(s, {
1894
+ ...e,
1895
+ symbol: styleText("green", S_SUCCESS)
1896
+ });
1897
+ },
1898
+ step: (s, e) => {
1899
+ log.message(s, {
1900
+ ...e,
1901
+ symbol: styleText("green", S_STEP_SUBMIT)
1902
+ });
1903
+ },
1904
+ warn: (s, e) => {
1905
+ log.message(s, {
1906
+ ...e,
1907
+ symbol: styleText("yellow", S_WARN)
1908
+ });
1909
+ },
1910
+ /** alias for `log.warn()`. */
1911
+ warning: (s, e) => {
1912
+ log.warn(s, e);
1913
+ },
1914
+ error: (s, e) => {
1915
+ log.message(s, {
1916
+ ...e,
1917
+ symbol: styleText("red", S_ERROR)
1918
+ });
1919
+ }
1920
+ };
1921
+ const cancel = (o = "", t) => {
1922
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_END)} ` : "";
1923
+ i.write(`${e}${styleText("red", o)}
1924
+
1925
+ `);
1926
+ };
1927
+ const intro = (o = "", t) => {
1928
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
1929
+ i.write(`${e}${o}
1930
+ `);
1931
+ };
1932
+ const outro = (o = "", t) => {
1933
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
1934
+ ${styleText("gray", S_BAR_END)} ` : "";
1935
+ i.write(`${e}${o}
1936
+
1937
+ `);
1938
+ };
1939
+ const multiline = (e) => new h({
1940
+ validate: e.validate,
1941
+ placeholder: e.placeholder,
1942
+ defaultValue: e.defaultValue,
1943
+ initialValue: e.initialValue,
1944
+ showSubmit: e.showSubmit,
1945
+ output: e.output,
1946
+ signal: e.signal,
1947
+ input: e.input,
1948
+ render() {
1949
+ const i = e?.withGuide ?? settings.withGuide, o = `${`${i ? `${styleText("gray", S_BAR)}
1950
+ ` : ""}${symbol(this.state)} `}${e.message}
1951
+ `, h = e.placeholder && e.placeholder.length > 0 ? styleText("inverse", e.placeholder[0]) + styleText("dim", e.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), a = this.userInput ? this.userInputWithCursor : h, l = this.value ?? "", d = e.showSubmit ? `
1952
+ ${styleText(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
1953
+ switch (this.state) {
1954
+ case "error": {
1955
+ const n = `${styleText("yellow", S_BAR)} `;
1956
+ return `${o}${i ? wrapTextWithPrefix(e.output, a, n, void 0) : a}
1957
+ ${styleText("yellow", S_BAR_END)} ${styleText("yellow", this.error)}${d}
1958
+ `;
1959
+ }
1960
+ case "submit": {
1961
+ const n = `${styleText("gray", S_BAR)} `;
1962
+ return `${o}${i ? wrapTextWithPrefix(e.output, l, n, void 0, void 0, (u) => styleText("dim", u)) : l ? styleText("dim", l) : ""}`;
1963
+ }
1964
+ case "cancel": {
1965
+ const n = `${styleText("gray", S_BAR)} `;
1966
+ return `${o}${i ? wrapTextWithPrefix(e.output, l, n, void 0, void 0, (u) => styleText(["strikethrough", "dim"], u)) : l ? styleText(["strikethrough", "dim"], l) : ""}`;
1967
+ }
1968
+ default: {
1969
+ const n = i ? `${styleText("cyan", S_BAR)} ` : "", r = i ? styleText("cyan", S_BAR_END) : "";
1970
+ return `${o}${i ? wrapTextWithPrefix(e.output, a, n) : a}
1971
+ ${r}${d}
1972
+ `;
1973
+ }
1974
+ }
1975
+ }
1976
+ }).prompt();
1977
+ const W = (o) => o;
1978
+ const C = (o, e, s) => {
1979
+ const a = {
1980
+ hard: true,
1981
+ trim: false
1982
+ }, i = wrapAnsi(o, e, a).split(`
1983
+ `), c = i.reduce((n, t) => Math.max(fastStringWidth(t), n), 0);
1984
+ return wrapAnsi(o, e - (i.map(s).reduce((n, t) => Math.max(fastStringWidth(t), n), 0) - c), a);
1985
+ };
1986
+ const note = (o = "", e = "", s) => {
1987
+ const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W, g = [
1988
+ "",
1989
+ ...C(o, getColumns(a) - 6, c).split(`
1990
+ `).map(c),
1991
+ ""
1992
+ ], n = fastStringWidth(e), t = Math.max(g.reduce((m, F) => {
1993
+ const O = fastStringWidth(F);
1994
+ return O > m ? O : m;
1995
+ }, 0), n) + 2, h = g.map((m) => `${styleText("gray", S_BAR)} ${m}${" ".repeat(t - fastStringWidth(m))}${styleText("gray", S_BAR)}`).join(`
1996
+ `), T = i ? `${styleText("gray", S_BAR)}
1997
+ ` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
1998
+ a.write(`${T}${styleText("green", S_STEP_SUBMIT)} ${styleText("reset", e)} ${styleText("gray", S_BAR_H.repeat(Math.max(t - n - 1, 1)) + S_CORNER_TOP_RIGHT)}
1999
+ ${h}
2000
+ ${styleText("gray", l$1 + S_BAR_H.repeat(t + 2) + S_CORNER_BOTTOM_RIGHT)}
2001
+ `);
2002
+ };
2003
+ const password = (e) => new u$2({
2004
+ validate: e.validate,
2005
+ mask: e.mask ?? S_PASSWORD_MASK,
2006
+ signal: e.signal,
2007
+ input: e.input,
2008
+ output: e.output,
2009
+ render() {
2010
+ const r = e.withGuide ?? settings.withGuide, o = `${r ? `${styleText("gray", S_BAR)}
2011
+ ` : ""}${symbol(this.state)} ${e.message}
2012
+ `, m = this.userInputWithCursor, i = this.masked;
2013
+ switch (this.state) {
2014
+ case "error": {
2015
+ const s = r ? `${styleText("yellow", S_BAR)} ` : "", n = r ? `${styleText("yellow", S_BAR_END)} ` : "", d = i ?? "";
2016
+ return e.clearOnError && this.clear(), `${o.trim()}
2017
+ ${s}${d}
2018
+ ${n}${styleText("yellow", this.error)}
2019
+ `;
2020
+ }
2021
+ case "submit": return `${o}${r ? `${styleText("gray", S_BAR)} ` : ""}${i ? styleText("dim", i) : ""}`;
2022
+ case "cancel": return `${o}${r ? `${styleText("gray", S_BAR)} ` : ""}${i ? styleText(["strikethrough", "dim"], i) : ""}${i && r ? `
2023
+ ${styleText("gray", S_BAR)}` : ""}`;
2024
+ default: return `${o}${r ? `${styleText("cyan", S_BAR)} ` : ""}${m}
2025
+ ${r ? styleText("cyan", S_BAR_END) : ""}
2026
+ `;
2027
+ }
2028
+ }
2029
+ }).prompt();
2030
+ const path = (e) => {
2031
+ const a = e.validate;
2032
+ return autocomplete({
2033
+ ...e,
2034
+ initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
2035
+ maxItems: 5,
2036
+ completeOnTab: true,
2037
+ validate(t) {
2038
+ if (!Array.isArray(t)) {
2039
+ if (!t) return "Please select a path";
2040
+ if (a) return runValidation(a, t);
2041
+ }
2042
+ },
2043
+ options() {
2044
+ const t = this.userInput;
2045
+ if (t === "") return [];
2046
+ try {
2047
+ let i;
2048
+ const o = t.endsWith("/") || t.endsWith("\\");
2049
+ existsSync(t) ? lstatSync(t).isDirectory() && (!e.directory || o) ? i = t : i = dirname(t) : i = dirname(t);
2050
+ const m = t.length > 1 && o ? t.slice(0, -1) : t;
2051
+ return readdirSync(i).map((r) => {
2052
+ const n = join(i, r);
2053
+ return {
2054
+ name: r,
2055
+ path: n,
2056
+ isDirectory: lstatSync(n).isDirectory()
2057
+ };
2058
+ }).filter(({ path: r, isDirectory: n }) => r.startsWith(m) && (n || !e.directory)).map((r) => ({ value: r.path }));
2059
+ } catch {
2060
+ return [];
2061
+ }
2062
+ }
2063
+ });
2064
+ };
2065
+ const Y = 3e4;
2066
+ const Z = (c) => styleText("magenta", c);
2067
+ const spinner = ({ indicator: c = "dots", onCancel: b, output: n = process.stdout, cancelMessage: _, errorMessage: C, frames: M = unicode ? [
2068
+ "◒",
2069
+ "◐",
2070
+ "◓",
2071
+ "◑"
2072
+ ] : [
2073
+ "•",
2074
+ "o",
2075
+ "O",
2076
+ "0"
2077
+ ], delay: O = unicode ? 80 : 120, signal: g, ...E } = {}) => {
2078
+ const u = isCI(), h = isAccessible(E.accessible);
2079
+ let x, I, p = false, l = false, r = "", v, w = performance.now();
2080
+ const y = getColumns(n), F = E?.styleFrame ?? Z, S = (e) => {
2081
+ const s = e > 1 ? C ?? settings.messages.error : _ ?? settings.messages.cancel;
2082
+ l = e === 1, p && (m(s, e), l && typeof b == "function" && b());
2083
+ }, $ = () => S(2), a = () => S(1), H = () => {
2084
+ process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a), process.on("SIGTERM", a), process.on("exit", S), g && g.addEventListener("abort", a);
2085
+ }, B = () => {
2086
+ process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a), process.removeListener("SIGTERM", a), process.removeListener("exit", S), g && g.removeEventListener("abort", a);
2087
+ }, R = () => {
2088
+ if (v === void 0) return;
2089
+ u && n.write(`
2090
+ `);
2091
+ const s = wrapAnsi(v, y, {
2092
+ hard: true,
2093
+ trim: false
2094
+ }).split(`
2095
+ `);
2096
+ s.length > 1 && n.write(cursor.up(s.length - 1)), n.write(cursor.to(0)), n.write(erase.down());
2097
+ }, L = (e) => e.replace(/\.+$/, ""), T = (e) => {
2098
+ const s = (performance.now() - e) / 1e3, i = Math.floor(s / 60), t = Math.floor(s % 60);
2099
+ return i > 0 ? `[${i}m ${t}s]` : `[${t}s]`;
2100
+ }, N = E.withGuide ?? settings.withGuide, P = (e = "") => {
2101
+ if (p = true, l = false, r = L(e), w = performance.now(), H(), h) {
2102
+ r !== "" && n.write(`${r}
2103
+ `), I = setInterval(() => {
2104
+ n.write(r === "" ? `still working
2105
+ ` : `still working: ${r}
2106
+ `);
2107
+ }, Y);
2108
+ return;
2109
+ }
2110
+ x = block({ output: n }), N && n.write(`${styleText("gray", S_BAR)}
2111
+ `);
2112
+ let s = 0, i = 0;
2113
+ I = setInterval(() => {
2114
+ if (u && r === v) return;
2115
+ R(), v = r;
2116
+ const t = F(M[s]);
2117
+ let o;
2118
+ if (u) o = `${t} ${r}...`;
2119
+ else if (c === "timer") o = `${t} ${r} ${T(w)}`;
2120
+ else {
2121
+ const j = ".".repeat(Math.floor(i)).slice(0, 3);
2122
+ o = `${t} ${r}${j}`;
2123
+ }
2124
+ const D = wrapAnsi(o, y, {
2125
+ hard: true,
2126
+ trim: false
2127
+ });
2128
+ n.write(D), s = s + 1 < M.length ? s + 1 : 0, i = i < 4 ? i + .125 : 0;
2129
+ }, O);
2130
+ }, m = (e = "", s = 0, i = false) => {
2131
+ if (p) {
2132
+ if (p = false, l = s === 1, clearInterval(I), h || R(), r = e ?? r, !i) if (h) {
2133
+ const t = s === 1 ? _ ?? settings.messages.cancel : s === 2 ? C ?? settings.messages.error : "Done", o = r || t;
2134
+ c === "timer" ? n.write(`${o} ${T(w)}
2135
+ `) : n.write(`${o}
2136
+ `);
2137
+ } else {
2138
+ const t = s === 0 ? styleText("green", S_STEP_SUBMIT) : s === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
2139
+ c === "timer" ? n.write(`${t} ${r} ${T(w)}
2140
+ `) : n.write(`${t} ${r}
2141
+ `);
2142
+ }
2143
+ B(), x?.();
2144
+ }
2145
+ };
2146
+ return {
2147
+ start: P,
2148
+ stop: (e = "") => m(e, 0),
2149
+ message: (e = "") => {
2150
+ r = L(e ?? r);
2151
+ },
2152
+ cancel: (e = "") => m(e, 1),
2153
+ error: (e = "") => m(e, 2),
2154
+ clear: () => m("", 0, true),
2155
+ get isCancelled() {
2156
+ return l;
2157
+ }
2158
+ };
2159
+ };
2160
+ const u = {
2161
+ light: unicodeOr("─", "-"),
2162
+ heavy: unicodeOr("━", "="),
2163
+ block: unicodeOr("█", "#")
2164
+ };
2165
+ function progress({ style: o = "heavy", max: d = 100, size: v = 40, ...x } = {}) {
2166
+ const r = spinner(x);
2167
+ let a = 0, n = "";
2168
+ const c = Math.max(1, d), l = Math.max(1, v), S = (t) => {
2169
+ switch (t) {
2170
+ case "initial":
2171
+ case "active": return (e) => styleText("magenta", e);
2172
+ case "error":
2173
+ case "cancel": return (e) => styleText("red", e);
2174
+ case "submit": return (e) => styleText("green", e);
2175
+ default: return (e) => styleText("magenta", e);
2176
+ }
2177
+ }, p = (t, e) => {
2178
+ const m = Math.floor(a / c * l);
2179
+ return `${S(t)(u[o].repeat(m))}${styleText("dim", u[o].repeat(l - m))} ${e}`;
2180
+ }, h = (t = "") => {
2181
+ n = t, r.start(p("initial", t));
2182
+ }, g = (t = 1, e) => {
2183
+ a = Math.min(c, t + a), r.message(p("active", e ?? n)), n = e ?? n;
2184
+ };
2185
+ return {
2186
+ start: h,
2187
+ stop: r.stop,
2188
+ cancel: r.cancel,
2189
+ error: r.error,
2190
+ clear: r.clear,
2191
+ advance: g,
2192
+ get isCancelled() {
2193
+ return r.isCancelled;
2194
+ },
2195
+ message: (t) => g(0, t)
2196
+ };
2197
+ }
2198
+ const SELECT_INSTRUCTIONS = [`${styleText("dim", "↑/↓")} to navigate`, `${styleText("dim", "Enter:")} confirm`];
2199
+ const c = (t, o) => t.includes(`
2200
+ `) ? t.split(`
2201
+ `).map((d) => o(d)).join(`
2202
+ `) : o(t);
2203
+ const select = (t) => {
2204
+ const o = (n, m) => {
2205
+ if (n === void 0) return "";
2206
+ const s = n.label ?? String(n.value);
2207
+ switch (m) {
2208
+ case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (i) => styleText("gray", i))}${n.hint ? ` ${styleText("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
2209
+ case "selected": return `${c(s, (i) => styleText("dim", i))}`;
2210
+ case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${s}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
2211
+ case "cancelled": return `${c(s, (i) => styleText(["strikethrough", "dim"], i))}`;
2212
+ default: return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (i) => styleText("dim", i))}`;
2213
+ }
2214
+ }, d = t.showInstructions ?? true;
2215
+ return new n$1({
2216
+ options: t.options,
2217
+ signal: t.signal,
2218
+ input: t.input,
2219
+ output: t.output,
2220
+ initialValue: t.initialValue,
2221
+ render() {
2222
+ const n = t.withGuide ?? settings.withGuide, m = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i = wrapTextWithPrefix(t.output, t.message, s, m), u = `${n ? `${styleText("gray", S_BAR)}
2223
+ ` : ""}${i}
2224
+ `;
2225
+ switch (this.state) {
2226
+ case "submit": {
2227
+ const r = n ? `${styleText("gray", S_BAR)} ` : "";
2228
+ return `${u}${wrapTextWithPrefix(t.output, o(this.options[this.cursor], "selected"), r)}`;
2229
+ }
2230
+ case "cancel": {
2231
+ const r = n ? `${styleText("gray", S_BAR)} ` : "";
2232
+ return `${u}${wrapTextWithPrefix(t.output, o(this.options[this.cursor], "cancelled"), r)}${n ? `
2233
+ ${styleText("gray", S_BAR)}` : ""}`;
2234
+ }
2235
+ default: {
2236
+ const r = n ? `${styleText("cyan", S_BAR)} ` : "", a = u.split(`
2237
+ `).length, p = d ? formatInstructionFooter(t.output, SELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], f = p.join(`
2238
+ `), b = p.length + 1;
2239
+ return `${u}${r}${limitOptions({
2240
+ output: t.output,
2241
+ cursor: this.cursor,
2242
+ options: this.options,
2243
+ maxItems: t.maxItems,
2244
+ columnPadding: r.length,
2245
+ rowPadding: a + b,
2246
+ style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
2247
+ }).join(`
2248
+ ${r}`)}
2249
+ ${f}
2250
+ `;
2251
+ }
2252
+ }
2253
+ }
2254
+ }).prompt();
2255
+ };
2256
+ const selectKey = (i) => {
2257
+ const c = (e, a = "inactive") => {
2258
+ if (e === void 0) return "";
2259
+ const n = e.label ?? String(e.value);
2260
+ return a === "disabled" ? `${styleText("dim", ` ${e.value} `)} ${styleText("gray", n)}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : a === "selected" ? `${styleText("dim", n)}` : a === "cancelled" ? `${styleText(["strikethrough", "dim"], n)}` : a === "active" ? `${styleText(["bgCyan", "gray"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : `${styleText([
2261
+ "gray",
2262
+ "bgWhite",
2263
+ "inverse"
2264
+ ], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}`;
2265
+ };
2266
+ return new c$2({
2267
+ options: i.options,
2268
+ signal: i.signal,
2269
+ input: i.input,
2270
+ output: i.output,
2271
+ initialValue: i.initialValue,
2272
+ caseSensitive: i.caseSensitive,
2273
+ render() {
2274
+ const e = i.withGuide ?? settings.withGuide, a = `${e ? `${styleText("gray", S_BAR)}
2275
+ ` : ""}${symbol(this.state)} ${i.message}
2276
+ `;
2277
+ switch (this.state) {
2278
+ case "submit": {
2279
+ const n = e ? `${styleText("gray", S_BAR)} ` : "", r = this.options.find((l) => l.value === this.value) ?? i.options[0];
2280
+ return `${a}${wrapTextWithPrefix(i.output, c(r, "selected"), n)}`;
2281
+ }
2282
+ case "cancel": {
2283
+ const n = e ? `${styleText("gray", S_BAR)} ` : "";
2284
+ return `${a}${wrapTextWithPrefix(i.output, c(this.options[0], "cancelled"), n)}${e ? `
2285
+ ${styleText("gray", S_BAR)}` : ""}`;
2286
+ }
2287
+ default: {
2288
+ const n = e ? `${styleText("cyan", S_BAR)} ` : "", r = e ? styleText("cyan", S_BAR_END) : "";
2289
+ return `${a}${this.options.map((l, $) => wrapTextWithPrefix(i.output, c(l, l.disabled ? "disabled" : $ === this.cursor ? "active" : "inactive"), n)).join(`
2290
+ `)}
2291
+ ${r}
2292
+ `;
2293
+ }
2294
+ }
2295
+ }
2296
+ }).prompt();
2297
+ };
2298
+ const i = `${styleText("gray", S_BAR)} `;
2299
+ const stream = {
2300
+ message: async (e, { symbol: l = styleText("gray", S_BAR) } = {}) => {
2301
+ process.stdout.write(`${styleText("gray", S_BAR)}
2302
+ ${l} `);
2303
+ let s = 3;
2304
+ for await (let r of e) {
2305
+ r = r.replace(/\n/g, `
2306
+ ${i}`), r.includes(`
2307
+ `) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
2308
+ `))).length);
2309
+ const o = stripVTControlCharacters(r).length;
2310
+ s + o < process.stdout.columns ? (s += o, process.stdout.write(r)) : (process.stdout.write(`
2311
+ ${i}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
2312
+ }
2313
+ process.stdout.write(`
2314
+ `);
2315
+ },
2316
+ info: (e) => stream.message(e, { symbol: styleText("blue", S_INFO) }),
2317
+ success: (e) => stream.message(e, { symbol: styleText("green", S_SUCCESS) }),
2318
+ step: (e) => stream.message(e, { symbol: styleText("green", S_STEP_SUBMIT) }),
2319
+ warn: (e) => stream.message(e, { symbol: styleText("yellow", S_WARN) }),
2320
+ /** alias for `log.warn()`. */
2321
+ warning: (e) => stream.warn(e),
2322
+ error: (e) => stream.message(e, { symbol: styleText("red", S_ERROR) })
2323
+ };
2324
+ const tasks = async (o, e) => {
2325
+ for (const t of o) {
2326
+ if (t.enabled === false) continue;
2327
+ const s = spinner(e);
2328
+ s.start(t.title);
2329
+ const n = await t.task(s.message);
2330
+ s.stop(n || t.title);
2331
+ }
2332
+ };
2333
+ const A = (l) => l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
2334
+ const taskLog = (l) => {
2335
+ const r = l.output ?? process.stdout, O = getColumns(r), i = styleText("gray", S_BAR), p = l.spacing ?? 1, k = 3, m = l.retainLog === true, d = !isCI() && isTTY(r);
2336
+ r.write(`${i}
2337
+ `), r.write(`${styleText("green", S_STEP_SUBMIT)} ${l.title}
2338
+ `);
2339
+ for (let e = 0; e < p; e++) r.write(`${i}
2340
+ `);
2341
+ const n = [{
2342
+ value: "",
2343
+ full: ""
2344
+ }];
2345
+ let v = false;
2346
+ const f = (e) => {
2347
+ if (n.length === 0) return;
2348
+ let s = 0;
2349
+ e && (s += p + 2);
2350
+ for (const t of n) {
2351
+ const { value: o, result: a } = t;
2352
+ let g = a?.message ?? o;
2353
+ if (g.length === 0) continue;
2354
+ a === void 0 && t.header !== void 0 && t.header !== "" && (g += `
2355
+ ${t.header}`);
2356
+ const E = g.split(`
2357
+ `).reduce((b, w) => w === "" ? b + 1 : b + Math.ceil((w.length + k) / O), 0);
2358
+ s += E;
2359
+ }
2360
+ s > 0 && (s += 1, r.write(erase.lines(s)));
2361
+ }, h = (e, s, t) => {
2362
+ const o = t ? `${e.full}
2363
+ ${e.value}` : e.value;
2364
+ e.header !== void 0 && e.header !== "" && log.message(e.header.split(`
2365
+ `).map((a) => styleText("bold", a)), {
2366
+ output: r,
2367
+ secondarySymbol: i,
2368
+ symbol: i,
2369
+ spacing: 0
2370
+ }), log.message(o.split(`
2371
+ `).map((a) => styleText("dim", a)), {
2372
+ output: r,
2373
+ secondarySymbol: i,
2374
+ symbol: i,
2375
+ spacing: s ?? p
2376
+ });
2377
+ }, T = () => {
2378
+ for (const e of n) {
2379
+ const { header: s, value: t, full: o } = e;
2380
+ (s === void 0 || s.length === 0) && t.length === 0 || h(e, void 0, m === true && o.length > 0);
2381
+ }
2382
+ }, L = (e, s, t) => {
2383
+ if (f(false), (t?.raw !== true || !v) && e.value !== "" && (e.value += `
2384
+ `), e.value += A(s), v = t?.raw === true, l.limit !== void 0) {
2385
+ const o = e.value.split(`
2386
+ `), a = o.length - l.limit;
2387
+ if (a > 0) {
2388
+ const g = o.splice(0, a);
2389
+ m && (e.full += (e.full === "" ? "" : `
2390
+ `) + g.join(`
2391
+ `));
2392
+ }
2393
+ e.value = o.join(`
2394
+ `);
2395
+ }
2396
+ d && y();
2397
+ }, y = () => {
2398
+ for (const e of n) e.result ? e.result.status === "error" ? log.error(e.result.message, {
2399
+ output: r,
2400
+ secondarySymbol: i,
2401
+ spacing: 0
2402
+ }) : log.success(e.result.message, {
2403
+ output: r,
2404
+ secondarySymbol: i,
2405
+ spacing: 0
2406
+ }) : e.value !== "" && h(e, 0);
2407
+ }, B = (e, s) => {
2408
+ f(false), e.result = s, d && y();
2409
+ };
2410
+ return {
2411
+ message(e, s) {
2412
+ L(n[0], e, s);
2413
+ },
2414
+ group(e) {
2415
+ const s = {
2416
+ header: e,
2417
+ value: "",
2418
+ full: ""
2419
+ };
2420
+ return n.push(s), {
2421
+ message(t, o) {
2422
+ L(s, t, o);
2423
+ },
2424
+ error(t) {
2425
+ B(s, {
2426
+ status: "error",
2427
+ message: t
2428
+ });
2429
+ },
2430
+ success(t) {
2431
+ B(s, {
2432
+ status: "success",
2433
+ message: t
2434
+ });
2435
+ }
2436
+ };
2437
+ },
2438
+ error(e, s) {
2439
+ f(true), log.error(e, {
2440
+ output: r,
2441
+ secondarySymbol: i,
2442
+ spacing: 1
2443
+ }), s?.showLog !== false && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
2444
+ },
2445
+ success(e, s) {
2446
+ f(true), log.success(e, {
2447
+ output: r,
2448
+ secondarySymbol: i,
2449
+ spacing: 1
2450
+ }), s?.showLog === true && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
2451
+ }
2452
+ };
2453
+ };
2454
+ const text = (t) => new n({
2455
+ validate: t.validate,
2456
+ placeholder: t.placeholder,
2457
+ defaultValue: t.defaultValue,
2458
+ initialValue: t.initialValue,
2459
+ output: t.output,
2460
+ signal: t.signal,
2461
+ input: t.input,
2462
+ render() {
2463
+ const r = t?.withGuide ?? settings.withGuide, l = `${`${r ? `${styleText("gray", S_BAR)}
2464
+ ` : ""}${symbol(this.state)} `}${t.message}
2465
+ `, d = t.placeholder && t.placeholder.length > 0 ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
2466
+ switch (this.state) {
2467
+ case "validating": {
2468
+ const n = r ? `${styleText("cyan", S_BAR)} ` : "", i = r ? styleText("cyan", S_BAR_END) : "";
2469
+ return `${l}${n}${styleText("dim", o)}
2470
+ ${i} ${styleText("dim", "Validating...")}
2471
+ `;
2472
+ }
2473
+ case "error": {
2474
+ const n = this.error ? ` ${styleText("yellow", this.error)}` : "", i = r ? `${styleText("yellow", S_BAR)} ` : "", c = r ? styleText("yellow", S_BAR_END) : "";
2475
+ return `${l.trim()}
2476
+ ${i}${o}
2477
+ ${c}${n}
2478
+ `;
2479
+ }
2480
+ case "submit": {
2481
+ const n = s ? `${r ? " " : ""}${styleText("dim", s)}` : "";
2482
+ return `${l}${r ? styleText("gray", S_BAR) : ""}${n}`;
2483
+ }
2484
+ case "cancel": {
2485
+ const n = s ? ` ${styleText(["strikethrough", "dim"], s)}` : "", i = r ? styleText("gray", S_BAR) : "";
2486
+ return `${l}${i}${n}${s.trim() ? `
2487
+ ${i}` : ""}`;
2488
+ }
2489
+ default: return `${l}${r ? `${styleText("cyan", S_BAR)} ` : ""}${o}
2490
+ ${r ? styleText("cyan", S_BAR_END) : ""}
2491
+ `;
2492
+ }
2493
+ }
2494
+ }).prompt();
2495
+ export { CANCEL_SYMBOL, MULTISELECT_INSTRUCTIONS, SELECT_INSTRUCTIONS, S_BAR, S_BAR_END, S_BAR_END_RIGHT, S_BAR_H, S_BAR_START, S_BAR_START_RIGHT, S_CHECKBOX_ACTIVE, S_CHECKBOX_INACTIVE, S_CHECKBOX_SELECTED, S_CONNECT_LEFT, S_CORNER_BOTTOM_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_TOP_LEFT, S_CORNER_TOP_RIGHT, S_ERROR, S_INFO, S_PASSWORD_MASK, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_SUCCESS, S_WARN, autocomplete, autocompleteMultiselect, box, cancel, confirm, date, formatInstructionFooter, group, groupMultiselect, intro, isCI, isCancel, isTTY, limitOptions, log, multiline, multiselect, note, outro, password, path, progress, select, selectKey, settings, spinner, stream, symbol, symbolBar, taskLog, tasks, text, unicode, unicodeOr, updateSettings };