proxitor 0.2.1 → 0.4.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.
package/dist/dist.mjs ADDED
@@ -0,0 +1,1325 @@
1
+ import { a as __commonJSMin } from "./cli.mjs";
2
+ import V, { stdin, stdout } from "node:process";
3
+ import { ReadStream } from "node:tty";
4
+ import { stripVTControlCharacters, styleText } from "node:util";
5
+ import "node:fs";
6
+ import "node:path";
7
+ import * as b from "node:readline";
8
+ import G from "node:readline";
9
+ //#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
10
+ const getCodePointsLength = (() => {
11
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
12
+ return (input) => {
13
+ let surrogatePairsNr = 0;
14
+ SURROGATE_PAIR_RE.lastIndex = 0;
15
+ while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
16
+ return input.length - surrogatePairsNr;
17
+ };
18
+ })();
19
+ const isFullWidth = (x) => {
20
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
21
+ };
22
+ const isWideNotCJKTNotEmoji = (x) => {
23
+ 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;
24
+ };
25
+ //#endregion
26
+ //#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
27
+ const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
28
+ const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
29
+ 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;
30
+ const TAB_RE = /\t{1,1000}/y;
31
+ 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;
32
+ const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
33
+ const MODIFIER_RE = /\p{M}+/gu;
34
+ const NO_TRUNCATION$1 = {
35
+ limit: Infinity,
36
+ ellipsis: ""
37
+ };
38
+ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
39
+ const LIMIT = truncationOptions.limit ?? Infinity;
40
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
41
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
42
+ const ANSI_WIDTH = 0;
43
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
44
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
45
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
46
+ const FULL_WIDTH_WIDTH = 2;
47
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
48
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
49
+ const PARSE_BLOCKS = [
50
+ [LATIN_RE, REGULAR_WIDTH],
51
+ [ANSI_RE, ANSI_WIDTH],
52
+ [CONTROL_RE, CONTROL_WIDTH],
53
+ [TAB_RE, TAB_WIDTH],
54
+ [EMOJI_RE, EMOJI_WIDTH],
55
+ [CJKT_WIDE_RE, WIDE_WIDTH]
56
+ ];
57
+ let indexPrev = 0;
58
+ let index = 0;
59
+ let length = input.length;
60
+ let lengthExtra = 0;
61
+ let truncationEnabled = false;
62
+ let truncationIndex = length;
63
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
64
+ let unmatchedStart = 0;
65
+ let unmatchedEnd = 0;
66
+ let width = 0;
67
+ let widthExtra = 0;
68
+ outer: while (true) {
69
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
70
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
71
+ lengthExtra = 0;
72
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
73
+ const codePoint = char.codePointAt(0) || 0;
74
+ if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
75
+ else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
76
+ else widthExtra = REGULAR_WIDTH;
77
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
78
+ if (width + widthExtra > LIMIT) {
79
+ truncationEnabled = true;
80
+ break outer;
81
+ }
82
+ lengthExtra += char.length;
83
+ width += widthExtra;
84
+ }
85
+ unmatchedStart = unmatchedEnd = 0;
86
+ }
87
+ if (index >= length) break outer;
88
+ for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
89
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
90
+ BLOCK_RE.lastIndex = index;
91
+ if (BLOCK_RE.test(input)) {
92
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
93
+ widthExtra = lengthExtra * BLOCK_WIDTH;
94
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
95
+ if (width + widthExtra > LIMIT) {
96
+ truncationEnabled = true;
97
+ break outer;
98
+ }
99
+ width += widthExtra;
100
+ unmatchedStart = indexPrev;
101
+ unmatchedEnd = index;
102
+ index = indexPrev = BLOCK_RE.lastIndex;
103
+ continue outer;
104
+ }
105
+ }
106
+ index += 1;
107
+ }
108
+ return {
109
+ width: truncationEnabled ? truncationLimit : width,
110
+ index: truncationEnabled ? truncationIndex : length,
111
+ truncated: truncationEnabled,
112
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
113
+ };
114
+ };
115
+ //#endregion
116
+ //#region node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
117
+ const NO_TRUNCATION = {
118
+ limit: Infinity,
119
+ ellipsis: "",
120
+ ellipsisWidth: 0
121
+ };
122
+ const fastStringWidth = (input, options = {}) => {
123
+ return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
124
+ };
125
+ //#endregion
126
+ //#region node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
127
+ const ESC = "\x1B";
128
+ const CSI = "›";
129
+ const END_CODE = 39;
130
+ const ANSI_ESCAPE_BELL = "\x07";
131
+ const ANSI_CSI = "[";
132
+ const ANSI_OSC = "]";
133
+ const ANSI_SGR_TERMINATOR = "m";
134
+ const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
135
+ const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
136
+ const getClosingCode = (openingCode) => {
137
+ if (openingCode >= 30 && openingCode <= 37) return 39;
138
+ if (openingCode >= 90 && openingCode <= 97) return 39;
139
+ if (openingCode >= 40 && openingCode <= 47) return 49;
140
+ if (openingCode >= 100 && openingCode <= 107) return 49;
141
+ if (openingCode === 1 || openingCode === 2) return 22;
142
+ if (openingCode === 3) return 23;
143
+ if (openingCode === 4) return 24;
144
+ if (openingCode === 7) return 27;
145
+ if (openingCode === 8) return 28;
146
+ if (openingCode === 9) return 29;
147
+ if (openingCode === 0) return 0;
148
+ };
149
+ const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
150
+ const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
151
+ const wrapWord = (rows, word, columns) => {
152
+ const characters = word[Symbol.iterator]();
153
+ let isInsideEscape = false;
154
+ let isInsideLinkEscape = false;
155
+ let lastRow = rows.at(-1);
156
+ let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
157
+ let currentCharacter = characters.next();
158
+ let nextCharacter = characters.next();
159
+ let rawCharacterIndex = 0;
160
+ while (!currentCharacter.done) {
161
+ const character = currentCharacter.value;
162
+ const characterLength = fastStringWidth(character);
163
+ if (visible + characterLength <= columns) rows[rows.length - 1] += character;
164
+ else {
165
+ rows.push(character);
166
+ visible = 0;
167
+ }
168
+ if (character === ESC || character === CSI) {
169
+ isInsideEscape = true;
170
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
171
+ }
172
+ if (isInsideEscape) {
173
+ if (isInsideLinkEscape) {
174
+ if (character === ANSI_ESCAPE_BELL) {
175
+ isInsideEscape = false;
176
+ isInsideLinkEscape = false;
177
+ }
178
+ } else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
179
+ } else {
180
+ visible += characterLength;
181
+ if (visible === columns && !nextCharacter.done) {
182
+ rows.push("");
183
+ visible = 0;
184
+ }
185
+ }
186
+ currentCharacter = nextCharacter;
187
+ nextCharacter = characters.next();
188
+ rawCharacterIndex += character.length;
189
+ }
190
+ lastRow = rows.at(-1);
191
+ if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
192
+ };
193
+ const stringVisibleTrimSpacesRight = (string) => {
194
+ const words = string.split(" ");
195
+ let last = words.length;
196
+ while (last) {
197
+ if (fastStringWidth(words[last - 1])) break;
198
+ last--;
199
+ }
200
+ if (last === words.length) return string;
201
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
202
+ };
203
+ const exec = (string, columns, options = {}) => {
204
+ if (options.trim !== false && string.trim() === "") return "";
205
+ let returnValue = "";
206
+ let escapeCode;
207
+ let escapeUrl;
208
+ const words = string.split(" ");
209
+ let rows = [""];
210
+ let rowLength = 0;
211
+ for (let index = 0; index < words.length; index++) {
212
+ const word = words[index];
213
+ if (options.trim !== false) {
214
+ const row = rows.at(-1) ?? "";
215
+ const trimmed = row.trimStart();
216
+ if (row.length !== trimmed.length) {
217
+ rows[rows.length - 1] = trimmed;
218
+ rowLength = fastStringWidth(trimmed);
219
+ }
220
+ }
221
+ if (index !== 0) {
222
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
223
+ rows.push("");
224
+ rowLength = 0;
225
+ }
226
+ if (rowLength || options.trim === false) {
227
+ rows[rows.length - 1] += " ";
228
+ rowLength++;
229
+ }
230
+ }
231
+ const wordLength = fastStringWidth(word);
232
+ if (options.hard && wordLength > columns) {
233
+ const remainingColumns = columns - rowLength;
234
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
235
+ if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
236
+ wrapWord(rows, word, columns);
237
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
238
+ continue;
239
+ }
240
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
241
+ if (options.wordWrap === false && rowLength < columns) {
242
+ wrapWord(rows, word, columns);
243
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
244
+ continue;
245
+ }
246
+ rows.push("");
247
+ rowLength = 0;
248
+ }
249
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
250
+ wrapWord(rows, word, columns);
251
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
252
+ continue;
253
+ }
254
+ rows[rows.length - 1] += word;
255
+ rowLength += wordLength;
256
+ }
257
+ if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
258
+ const preString = rows.join("\n");
259
+ let inSurrogate = false;
260
+ for (let i = 0; i < preString.length; i++) {
261
+ const character = preString[i];
262
+ returnValue += character;
263
+ if (!inSurrogate) {
264
+ inSurrogate = character >= "\ud800" && character <= "\udbff";
265
+ if (inSurrogate) continue;
266
+ } else inSurrogate = false;
267
+ if (character === ESC || character === CSI) {
268
+ GROUP_REGEX.lastIndex = i + 1;
269
+ const groups = GROUP_REGEX.exec(preString)?.groups;
270
+ if (groups?.code !== void 0) {
271
+ const code = Number.parseFloat(groups.code);
272
+ escapeCode = code === END_CODE ? void 0 : code;
273
+ } else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
274
+ }
275
+ if (preString[i + 1] === "\n") {
276
+ if (escapeUrl) returnValue += wrapAnsiHyperlink("");
277
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
278
+ if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
279
+ } else if (character === "\n") {
280
+ if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
281
+ if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
282
+ }
283
+ }
284
+ return returnValue;
285
+ };
286
+ const CRLF_OR_LF = /\r?\n/;
287
+ function wrapAnsi(string, columns, options) {
288
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
289
+ }
290
+ //#endregion
291
+ //#region node_modules/.pnpm/@clack+core@1.4.0/node_modules/@clack/core/dist/index.mjs
292
+ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
293
+ const ESC = "\x1B";
294
+ const CSI = `${ESC}[`;
295
+ const beep = "\x07";
296
+ const cursor = {
297
+ to(x, y) {
298
+ if (!y) return `${CSI}${x + 1}G`;
299
+ return `${CSI}${y + 1};${x + 1}H`;
300
+ },
301
+ move(x, y) {
302
+ let ret = "";
303
+ if (x < 0) ret += `${CSI}${-x}D`;
304
+ else if (x > 0) ret += `${CSI}${x}C`;
305
+ if (y < 0) ret += `${CSI}${-y}A`;
306
+ else if (y > 0) ret += `${CSI}${y}B`;
307
+ return ret;
308
+ },
309
+ up: (count = 1) => `${CSI}${count}A`,
310
+ down: (count = 1) => `${CSI}${count}B`,
311
+ forward: (count = 1) => `${CSI}${count}C`,
312
+ backward: (count = 1) => `${CSI}${count}D`,
313
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
314
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
315
+ left: `${CSI}G`,
316
+ hide: `${CSI}?25l`,
317
+ show: `${CSI}?25h`,
318
+ save: `${ESC}7`,
319
+ restore: `${ESC}8`
320
+ };
321
+ module.exports = {
322
+ cursor,
323
+ scroll: {
324
+ up: (count = 1) => `${CSI}S`.repeat(count),
325
+ down: (count = 1) => `${CSI}T`.repeat(count)
326
+ },
327
+ erase: {
328
+ screen: `${CSI}2J`,
329
+ up: (count = 1) => `${CSI}1J`.repeat(count),
330
+ down: (count = 1) => `${CSI}J`.repeat(count),
331
+ line: `${CSI}2K`,
332
+ lineEnd: `${CSI}K`,
333
+ lineStart: `${CSI}1K`,
334
+ lines(count) {
335
+ let clear = "";
336
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
337
+ if (count) clear += cursor.left;
338
+ return clear;
339
+ }
340
+ },
341
+ beep
342
+ };
343
+ })))();
344
+ function f(r, t, s) {
345
+ if (!s.some((o) => !o.disabled)) return r;
346
+ const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
347
+ return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
348
+ }
349
+ const h = {
350
+ actions: new Set([
351
+ "up",
352
+ "down",
353
+ "left",
354
+ "right",
355
+ "space",
356
+ "enter",
357
+ "cancel"
358
+ ]),
359
+ aliases: new Map([
360
+ ["k", "up"],
361
+ ["j", "down"],
362
+ ["h", "left"],
363
+ ["l", "right"],
364
+ ["", "cancel"],
365
+ ["escape", "cancel"]
366
+ ]),
367
+ messages: {
368
+ cancel: "Canceled",
369
+ error: "Something went wrong"
370
+ },
371
+ withGuide: !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: (r, t) => `There are only ${r} days in ${t}`,
391
+ afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`,
392
+ beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}`
393
+ }
394
+ }
395
+ };
396
+ function C(r, t) {
397
+ if (typeof r == "string") return h.aliases.get(r) === t;
398
+ for (const s of r) if (s !== void 0 && C(s, t)) return !0;
399
+ return !1;
400
+ }
401
+ function Y$1(r, t) {
402
+ if (r === t) return;
403
+ const s = r.split(`
404
+ `), e = t.split(`
405
+ `), i = Math.max(s.length, e.length), n = [];
406
+ for (let o = 0; o < i; o++) s[o] !== e[o] && n.push(o);
407
+ return {
408
+ lines: n,
409
+ numLinesBefore: s.length,
410
+ numLinesAfter: e.length,
411
+ numLines: i
412
+ };
413
+ }
414
+ const q$1 = globalThis.process.platform.startsWith("win"), k = Symbol("clack:cancel");
415
+ function R(r) {
416
+ return r === k;
417
+ }
418
+ function w$1(r, t) {
419
+ const s = r;
420
+ s.isTTY && s.setRawMode(t);
421
+ }
422
+ function W({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor: e = !0 } = {}) {
423
+ const i = b.createInterface({
424
+ input: r,
425
+ output: t,
426
+ prompt: "",
427
+ tabSize: 1
428
+ });
429
+ b.emitKeypressEvents(r, i), r instanceof ReadStream && r.isTTY && r.setRawMode(!0);
430
+ const n = (o, { name: u, sequence: a }) => {
431
+ if (C([
432
+ String(o),
433
+ u,
434
+ a
435
+ ], "cancel")) {
436
+ e && t.write(import_src.cursor.show), process.exit(0);
437
+ return;
438
+ }
439
+ if (!s) return;
440
+ const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
441
+ b.moveCursor(t, c, y, () => {
442
+ b.clearLine(t, 1, () => {
443
+ r.once("keypress", n);
444
+ });
445
+ });
446
+ };
447
+ return e && t.write(import_src.cursor.hide), r.once("keypress", n), () => {
448
+ r.off("keypress", n), e && t.write(import_src.cursor.show), r instanceof ReadStream && r.isTTY && !q$1 && r.setRawMode(!1), i.terminal = !1, i.close();
449
+ };
450
+ }
451
+ const A = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80, L = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
452
+ function B(r, t, s, e = s, i = s, n) {
453
+ return wrapAnsi(t, A(r ?? stdout) - s.length, {
454
+ hard: !0,
455
+ trim: !1
456
+ }).split(`
457
+ `).map((u, a, l) => {
458
+ const c = n ? n(u, a) : u;
459
+ return a === 0 ? `${e}${c}` : a === l.length - 1 ? `${i}${c}` : `${s}${c}`;
460
+ }).join(`
461
+ `);
462
+ }
463
+ function P$1(r, t) {
464
+ if ("~standard" in r) {
465
+ const s = r["~standard"].validate(t);
466
+ if (s instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
467
+ return s.issues?.at(0)?.message;
468
+ }
469
+ return r(t);
470
+ }
471
+ var m = class {
472
+ input;
473
+ output;
474
+ _abortSignal;
475
+ rl;
476
+ opts;
477
+ _render;
478
+ _track = !1;
479
+ _prevFrame = "";
480
+ _subscribers = /* @__PURE__ */ new Map();
481
+ _cursor = 0;
482
+ state = "initial";
483
+ error = "";
484
+ value;
485
+ userInput = "";
486
+ constructor(t, s = !0) {
487
+ const { input: e = stdin, output: i = stdout, render: n, signal: o, ...u } = t;
488
+ this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e, this.output = i;
489
+ }
490
+ unsubscribe() {
491
+ this._subscribers.clear();
492
+ }
493
+ setSubscriber(t, s) {
494
+ const e = this._subscribers.get(t) ?? [];
495
+ e.push(s), this._subscribers.set(t, e);
496
+ }
497
+ on(t, s) {
498
+ this.setSubscriber(t, { cb: s });
499
+ }
500
+ once(t, s) {
501
+ this.setSubscriber(t, {
502
+ cb: s,
503
+ once: !0
504
+ });
505
+ }
506
+ emit(t, ...s) {
507
+ const e = this._subscribers.get(t) ?? [], i = [];
508
+ for (const n of e) n.cb(...s), n.once && i.push(() => e.splice(e.indexOf(n), 1));
509
+ for (const n of i) n();
510
+ }
511
+ prompt() {
512
+ return new Promise((t) => {
513
+ if (this._abortSignal) {
514
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k);
515
+ this._abortSignal.addEventListener("abort", () => {
516
+ this.state = "cancel", this.close();
517
+ }, { once: !0 });
518
+ }
519
+ this.rl = G.createInterface({
520
+ input: this.input,
521
+ tabSize: 2,
522
+ prompt: "",
523
+ escapeCodeTimeout: 50,
524
+ terminal: !0
525
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
526
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(this.value);
527
+ }), this.once("cancel", () => {
528
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(k);
529
+ });
530
+ });
531
+ }
532
+ _isActionKey(t, s) {
533
+ return t === " ";
534
+ }
535
+ _shouldSubmit(t, s) {
536
+ return !0;
537
+ }
538
+ _setValue(t) {
539
+ this.value = t, this.emit("value", this.value);
540
+ }
541
+ _setUserInput(t, s) {
542
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
543
+ }
544
+ _clearUserInput() {
545
+ this.rl?.write(null, {
546
+ ctrl: !0,
547
+ name: "u"
548
+ }), this._setUserInput("");
549
+ }
550
+ onKeypress(t, s) {
551
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, {
552
+ ctrl: !0,
553
+ name: "h"
554
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, s), s?.name === "return" && this._shouldSubmit(t, s)) {
555
+ if (this.opts.validate) {
556
+ const e = P$1(this.opts.validate, this.value);
557
+ e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
558
+ }
559
+ this.state !== "error" && (this.state = "submit");
560
+ }
561
+ C([
562
+ t,
563
+ s?.name,
564
+ s?.sequence
565
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
566
+ }
567
+ close() {
568
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
569
+ `), w$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
570
+ }
571
+ restoreCursor() {
572
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
573
+ hard: !0,
574
+ trim: !1
575
+ }).split(`
576
+ `).length - 1;
577
+ this.output.write(import_src.cursor.move(-999, t * -1));
578
+ }
579
+ render() {
580
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
581
+ hard: !0,
582
+ trim: !1
583
+ });
584
+ if (t !== this._prevFrame) {
585
+ if (this.state === "initial") this.output.write(import_src.cursor.hide);
586
+ else {
587
+ const s = Y$1(this._prevFrame, t), e = L(this.output);
588
+ if (this.restoreCursor(), s) {
589
+ const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
590
+ let o = s.lines.find((u) => u >= i);
591
+ if (o === void 0) {
592
+ this._prevFrame = t;
593
+ return;
594
+ }
595
+ if (s.lines.length === 1) {
596
+ this.output.write(import_src.cursor.move(0, o - n)), this.output.write(import_src.erase.lines(1));
597
+ const u = t.split(`
598
+ `);
599
+ this.output.write(u[o]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, u.length - o - 1));
600
+ return;
601
+ } else if (s.lines.length > 1) {
602
+ if (i < n) o = i;
603
+ else {
604
+ const a = o - n;
605
+ a > 0 && this.output.write(import_src.cursor.move(0, a));
606
+ }
607
+ this.output.write(import_src.erase.down());
608
+ const u = t.split(`
609
+ `).slice(o);
610
+ this.output.write(u.join(`
611
+ `)), this._prevFrame = t;
612
+ return;
613
+ }
614
+ }
615
+ this.output.write(import_src.erase.down());
616
+ }
617
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
618
+ }
619
+ }
620
+ };
621
+ function J(r, t) {
622
+ if (r === void 0 || t.length === 0) return 0;
623
+ const s = t.findIndex((e) => e.value === r);
624
+ return s !== -1 ? s : 0;
625
+ }
626
+ function H$1(r, t) {
627
+ return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
628
+ }
629
+ function Q$1(r, t) {
630
+ if (t) return r ? t : t[0];
631
+ }
632
+ let X = class extends m {
633
+ filteredOptions;
634
+ multiple;
635
+ isNavigating = !1;
636
+ selectedValues = [];
637
+ focusedValue;
638
+ #s = 0;
639
+ #r = "";
640
+ #t;
641
+ #n;
642
+ #u;
643
+ get cursor() {
644
+ return this.#s;
645
+ }
646
+ get userInputWithCursor() {
647
+ if (!this.userInput) return styleText(["inverse", "hidden"], "_");
648
+ if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
649
+ const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
650
+ return `${t}${styleText("inverse", s)}${e.join("")}`;
651
+ }
652
+ get options() {
653
+ return typeof this.#n == "function" ? this.#n() : this.#n;
654
+ }
655
+ constructor(t) {
656
+ super(t), this.#n = t.options, this.#u = t.placeholder;
657
+ const s = this.options;
658
+ this.filteredOptions = [...s], this.multiple = t.multiple === !0, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? H$1;
659
+ let e;
660
+ if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e = t.initialValue : e = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e = [this.options[0].value]), e) for (const i of e) {
661
+ const n = s.findIndex((o) => o.value === i);
662
+ n !== -1 && (this.toggleSelected(i), this.#s = n);
663
+ }
664
+ this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
665
+ }
666
+ _isActionKey(t, s) {
667
+ return t === " " || this.multiple && this.isNavigating && s.name === "space" && t !== void 0 && t !== "";
668
+ }
669
+ #e(t, s) {
670
+ const e = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#u, a = this.options, l = u !== void 0 && u !== "" && a.some((c) => !c.disabled && (this.#t ? this.#t(u, c) : !0));
671
+ if (s.name === "tab" && o && l) {
672
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u, !0), this.isNavigating = !1;
673
+ return;
674
+ }
675
+ e || i ? (this.#s = f(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = Q$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
676
+ }
677
+ deselectAll() {
678
+ this.selectedValues = [];
679
+ }
680
+ toggleSelected(t) {
681
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
682
+ }
683
+ #i(t) {
684
+ if (t !== this.#r) {
685
+ this.#r = t;
686
+ const s = this.options;
687
+ t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
688
+ const e = J(this.focusedValue, this.filteredOptions);
689
+ this.#s = f(e, 0, this.filteredOptions);
690
+ const i = this.filteredOptions[this.#s];
691
+ i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
692
+ }
693
+ }
694
+ };
695
+ var Z = class extends m {
696
+ get cursor() {
697
+ return this.value ? 0 : 1;
698
+ }
699
+ get _value() {
700
+ return this.cursor === 0;
701
+ }
702
+ constructor(t) {
703
+ super(t, !1), this.value = !!t.initialValue, this.on("userInput", () => {
704
+ this.value = this._value;
705
+ }), this.on("confirm", (s) => {
706
+ this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
707
+ }), this.on("cursor", () => {
708
+ this.value = !this.value;
709
+ });
710
+ }
711
+ };
712
+ new Set([
713
+ "up",
714
+ "down",
715
+ "left",
716
+ "right"
717
+ ]);
718
+ let ut$1 = class extends m {
719
+ options;
720
+ cursor = 0;
721
+ get _value() {
722
+ return this.options[this.cursor].value;
723
+ }
724
+ get _enabledOptions() {
725
+ return this.options.filter((t) => t.disabled !== !0);
726
+ }
727
+ toggleAll() {
728
+ const t = this._enabledOptions, s = this.value !== void 0 && this.value.length === t.length;
729
+ this.value = s ? [] : t.map((e) => e.value);
730
+ }
731
+ toggleInvert() {
732
+ const t = this.value;
733
+ if (!t) return;
734
+ const s = this._enabledOptions.filter((e) => !t.includes(e.value));
735
+ this.value = s.map((e) => e.value);
736
+ }
737
+ toggleValue() {
738
+ this.value === void 0 && (this.value = []);
739
+ const t = this.value.includes(this._value);
740
+ this.value = t ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
741
+ }
742
+ constructor(t) {
743
+ super(t, !1), this.options = t.options, this.value = [...t.initialValues ?? []];
744
+ const s = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), 0);
745
+ this.cursor = this.options[s].disabled ? f(s, 1, this.options) : s, this.on("key", (e, i) => {
746
+ i.name === "a" && this.toggleAll(), i.name === "i" && this.toggleInvert();
747
+ }), this.on("cursor", (e) => {
748
+ switch (e) {
749
+ case "left":
750
+ case "up":
751
+ this.cursor = f(this.cursor, -1, this.options);
752
+ break;
753
+ case "down":
754
+ case "right":
755
+ this.cursor = f(this.cursor, 1, this.options);
756
+ break;
757
+ case "space":
758
+ this.toggleValue();
759
+ break;
760
+ }
761
+ });
762
+ }
763
+ };
764
+ var ht$1 = class extends m {
765
+ options;
766
+ cursor = 0;
767
+ get _selectedValue() {
768
+ return this.options[this.cursor];
769
+ }
770
+ changeValue() {
771
+ this.value = this._selectedValue.value;
772
+ }
773
+ constructor(t) {
774
+ super(t, !1), this.options = t.options;
775
+ const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e = s === -1 ? 0 : s;
776
+ this.cursor = this.options[e].disabled ? f(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i) => {
777
+ switch (i) {
778
+ case "left":
779
+ case "up":
780
+ this.cursor = f(this.cursor, -1, this.options);
781
+ break;
782
+ case "down":
783
+ case "right":
784
+ this.cursor = f(this.cursor, 1, this.options);
785
+ break;
786
+ }
787
+ this.changeValue();
788
+ });
789
+ }
790
+ };
791
+ var ct$1 = class extends m {
792
+ get userInputWithCursor() {
793
+ if (this.state === "submit") return this.userInput;
794
+ const t = this.userInput;
795
+ if (this.cursor >= t.length) return `${this.userInput}\u2588`;
796
+ const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
797
+ return `${s}${styleText("inverse", e)}${i.join("")}`;
798
+ }
799
+ get cursor() {
800
+ return this._cursor;
801
+ }
802
+ constructor(t) {
803
+ super({
804
+ ...t,
805
+ initialUserInput: t.initialUserInput ?? t.initialValue
806
+ }), this.on("userInput", (s) => {
807
+ this._setValue(s);
808
+ }), this.on("finalize", () => {
809
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
810
+ });
811
+ }
812
+ };
813
+ //#endregion
814
+ //#region node_modules/.pnpm/@clack+prompts@1.5.0/node_modules/@clack/prompts/dist/index.mjs
815
+ function se() {
816
+ return V.platform !== "win32" ? V.env.TERM !== "linux" : !!V.env.CI || !!V.env.WT_SESSION || !!V.env.TERMINUS_SUBLIME || V.env.ConEmuTask === "{cmd::Cmder}" || V.env.TERM_PROGRAM === "Terminus-Sublime" || V.env.TERM_PROGRAM === "vscode" || V.env.TERM === "xterm-256color" || V.env.TERM === "alacritty" || V.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
817
+ }
818
+ const tt = se(), at = () => process.env.CI === "true", w = (t, i) => tt ? t : i, _t = w("◆", "*"), ut = w("■", "x"), lt = w("▲", "x"), H = w("◇", "o"), ct = w("┌", "T"), $ = w("│", "|"), x = w("└", "—"), z = w("●", ">"), U = w("○", " "), et = w("◻", "[•]"), K = w("◼", "[+]"), Y = w("◻", "[ ]"), st = w("─", "-"), $t = w("╮", "+"), Mt = w("├", "+"), dt = w("╯", "+"), ht = w("╰", "+"), pt = w("●", "•"), mt = w("◆", "*"), gt = w("▲", "!"), yt = w("■", "x"), P = (t) => {
819
+ switch (t) {
820
+ case "initial":
821
+ case "active": return styleText("cyan", _t);
822
+ case "cancel": return styleText("red", ut);
823
+ case "error": return styleText("yellow", lt);
824
+ case "submit": return styleText("green", H);
825
+ }
826
+ }, ft = (t) => {
827
+ switch (t) {
828
+ case "initial":
829
+ case "active": return styleText("cyan", $);
830
+ case "cancel": return styleText("red", $);
831
+ case "error": return styleText("yellow", $);
832
+ case "submit": return styleText("green", $);
833
+ }
834
+ }, Pt = (t, i, s, r, u, n = !1) => {
835
+ let a = i, c = 0;
836
+ if (n) for (let o = r - 1; o >= s && (a -= t[o].length, c++, !(a <= u)); o--);
837
+ else for (let o = s; o < r && (a -= t[o].length, c++, !(a <= u)); o++);
838
+ return {
839
+ lineCount: a,
840
+ removals: c
841
+ };
842
+ }, F = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: a = 4 }) => {
843
+ const c = A(r) - n, o = L(r), l = styleText("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
844
+ let p = 0;
845
+ t >= g - 3 && (p = Math.max(Math.min(t - g + 3, i.length - g), 0));
846
+ let f = g < i.length && p > 0, h = g < i.length && p + g < i.length;
847
+ const I = Math.min(p + g, i.length), m = [];
848
+ let y = 0;
849
+ f && y++, h && y++;
850
+ const v = p + (f ? 1 : 0), C = I - (h ? 1 : 0);
851
+ for (let b = v; b < C; b++) {
852
+ const G = wrapAnsi(s(i[b], b === t), c, {
853
+ hard: !0,
854
+ trim: !1
855
+ }).split(`
856
+ `);
857
+ m.push(G), y += G.length;
858
+ }
859
+ if (y > d) {
860
+ let b = 0, G = 0, M = y;
861
+ const N = t - v;
862
+ let O = d;
863
+ const j = () => Pt(m, M, 0, N, O), k = () => Pt(m, M, N + 1, m.length, O, !0);
864
+ f ? ({lineCount: M, removals: b} = j(), M > O && (h || (O -= 1), {lineCount: M, removals: G} = k())) : (h || (O -= 1), {lineCount: M, removals: G} = k(), M > O && (O -= 1, {lineCount: M, removals: b} = j())), b > 0 && (f = !0, m.splice(0, b)), G > 0 && (h = !0, m.splice(m.length - G, G));
865
+ }
866
+ const S = [];
867
+ f && S.push(l);
868
+ for (const b of m) for (const G of b) S.push(G);
869
+ return h && S.push(l), S;
870
+ };
871
+ function Rt(t) {
872
+ return t.label ?? String(t.value ?? "");
873
+ }
874
+ function At(t, i) {
875
+ if (!t) return !0;
876
+ const s = (i.label ?? String(i.value ?? "")).toLowerCase(), r = (i.hint ?? "").toLowerCase(), u = String(i.value).toLowerCase(), n = t.toLowerCase();
877
+ return s.includes(n) || r.includes(n) || u.includes(n);
878
+ }
879
+ function ie(t, i) {
880
+ const s = [];
881
+ for (const r of i) t.includes(r.value) && s.push(r);
882
+ return s;
883
+ }
884
+ const Vt = (t) => new X({
885
+ options: t.options,
886
+ initialValue: t.initialValue ? [t.initialValue] : void 0,
887
+ initialUserInput: t.initialUserInput,
888
+ placeholder: t.placeholder,
889
+ filter: t.filter ?? ((i, s) => At(i, s)),
890
+ signal: t.signal,
891
+ input: t.input,
892
+ output: t.output,
893
+ validate: t.validate,
894
+ render() {
895
+ const i = t.withGuide ?? h.withGuide, s = i ? [`${styleText("gray", $)}`, `${P(this.state)} ${t.message}`] : [`${P(this.state)} ${t.message}`], r = this.userInput, u = this.options, n = t.placeholder, a = r === "" && n !== void 0, c = (o, l) => {
896
+ const d = Rt(o), g = o.hint && o.value === this.focusedValue ? styleText("dim", ` (${o.hint})`) : "";
897
+ switch (l) {
898
+ case "active": return `${styleText("green", z)} ${d}${g}`;
899
+ case "inactive": return `${styleText("dim", U)} ${styleText("dim", d)}`;
900
+ case "disabled": return `${styleText("gray", U)} ${styleText(["strikethrough", "gray"], d)}`;
901
+ }
902
+ };
903
+ switch (this.state) {
904
+ case "submit": {
905
+ const o = ie(this.selectedValues, u), l = o.length > 0 ? ` ${styleText("dim", o.map(Rt).join(", "))}` : "", d = i ? styleText("gray", $) : "";
906
+ return `${s.join(`
907
+ `)}
908
+ ${d}${l}`;
909
+ }
910
+ case "cancel": {
911
+ const o = r ? ` ${styleText(["strikethrough", "dim"], r)}` : "", l = i ? styleText("gray", $) : "";
912
+ return `${s.join(`
913
+ `)}
914
+ ${l}${o}`;
915
+ }
916
+ default: {
917
+ const o = this.state === "error" ? "yellow" : "cyan", l = i ? `${styleText(o, $)} ` : "", d = i ? styleText(o, x) : "";
918
+ let g = "";
919
+ if (this.isNavigating || a) {
920
+ const v = a ? n : r;
921
+ g = v !== "" ? ` ${styleText("dim", v)}` : "";
922
+ } else g = ` ${this.userInputWithCursor}`;
923
+ const p = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", f = this.filteredOptions.length === 0 && r ? [`${l}${styleText("yellow", "No matches found")}`] : [], h = this.state === "error" ? [`${l}${styleText("yellow", this.error)}`] : [];
924
+ i && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${g}${p}`, ...f, ...h);
925
+ const m = [`${l}${[
926
+ `${styleText("dim", "↑/↓")} to select`,
927
+ `${styleText("dim", "Enter:")} confirm`,
928
+ `${styleText("dim", "Type:")} to search`
929
+ ].join(" • ")}`, d], y = this.filteredOptions.length === 0 ? [] : F({
930
+ cursor: this.cursor,
931
+ options: this.filteredOptions,
932
+ columnPadding: i ? 3 : 0,
933
+ rowPadding: s.length + m.length,
934
+ style: (v, C) => c(v, v.disabled ? "disabled" : C ? "active" : "inactive"),
935
+ maxItems: t.maxItems,
936
+ output: t.output
937
+ });
938
+ return [
939
+ ...s,
940
+ ...y.map((v) => `${l}${v}`),
941
+ ...m
942
+ ].join(`
943
+ `);
944
+ }
945
+ }
946
+ }
947
+ }).prompt(), le = (t) => {
948
+ const i = t.active ?? "Yes", s = t.inactive ?? "No";
949
+ return new Z({
950
+ active: i,
951
+ inactive: s,
952
+ signal: t.signal,
953
+ input: t.input,
954
+ output: t.output,
955
+ initialValue: t.initialValue ?? !0,
956
+ render() {
957
+ const r = t.withGuide ?? h.withGuide, u = `${P(this.state)} `, n = r ? `${styleText("gray", $)} ` : "", a = B(t.output, t.message, n, u), c = `${r ? `${styleText("gray", $)}
958
+ ` : ""}${a}
959
+ `, o = this.value ? i : s;
960
+ switch (this.state) {
961
+ case "submit": return `${c}${r ? `${styleText("gray", $)} ` : ""}${styleText("dim", o)}`;
962
+ case "cancel": return `${c}${r ? `${styleText("gray", $)} ` : ""}${styleText(["strikethrough", "dim"], o)}${r ? `
963
+ ${styleText("gray", $)}` : ""}`;
964
+ default: {
965
+ const l = r ? `${styleText("cyan", $)} ` : "", d = r ? styleText("cyan", x) : "";
966
+ return `${c}${l}${this.value ? `${styleText("green", z)} ${i}` : `${styleText("dim", U)} ${styleText("dim", i)}`}${t.vertical ? r ? `
967
+ ${styleText("cyan", $)} ` : `
968
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", U)} ${styleText("dim", s)}` : `${styleText("green", z)} ${s}`}
969
+ ${d}
970
+ `;
971
+ }
972
+ }
973
+ }
974
+ }).prompt();
975
+ }, R$1 = {
976
+ message: (t = [], { symbol: i = styleText("gray", $), secondarySymbol: s = styleText("gray", $), output: r = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
977
+ const a = [], c = n ?? h.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
978
+ for (let p = 0; p < u; p++) a.push(o);
979
+ const g = Array.isArray(t) ? t : t.split(`
980
+ `);
981
+ if (g.length > 0) {
982
+ const [p, ...f] = g;
983
+ p.length > 0 ? a.push(`${l}${p}`) : a.push(c ? i : "");
984
+ for (const h of f) h.length > 0 ? a.push(`${d}${h}`) : a.push(c ? s : "");
985
+ }
986
+ r.write(`${a.join(`
987
+ `)}
988
+ `);
989
+ },
990
+ info: (t, i) => {
991
+ R$1.message(t, {
992
+ ...i,
993
+ symbol: styleText("blue", pt)
994
+ });
995
+ },
996
+ success: (t, i) => {
997
+ R$1.message(t, {
998
+ ...i,
999
+ symbol: styleText("green", mt)
1000
+ });
1001
+ },
1002
+ step: (t, i) => {
1003
+ R$1.message(t, {
1004
+ ...i,
1005
+ symbol: styleText("green", H)
1006
+ });
1007
+ },
1008
+ warn: (t, i) => {
1009
+ R$1.message(t, {
1010
+ ...i,
1011
+ symbol: styleText("yellow", gt)
1012
+ });
1013
+ },
1014
+ warning: (t, i) => {
1015
+ R$1.warn(t, i);
1016
+ },
1017
+ error: (t, i) => {
1018
+ R$1.message(t, {
1019
+ ...i,
1020
+ symbol: styleText("red", yt)
1021
+ });
1022
+ }
1023
+ }, ye = (t = "", i) => {
1024
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${styleText("gray", ct)} ` : "";
1025
+ s.write(`${r}${t}
1026
+ `);
1027
+ }, fe = (t = "", i) => {
1028
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${styleText("gray", $)}
1029
+ ${styleText("gray", x)} ` : "";
1030
+ s.write(`${r}${t}
1031
+
1032
+ `);
1033
+ }, Q = (t, i) => t.split(`
1034
+ `).map((s) => i(s)).join(`
1035
+ `), we = (t) => {
1036
+ const i = (r, u) => {
1037
+ const n = r.label ?? String(r.value);
1038
+ return u === "disabled" ? `${styleText("gray", Y)} ${Q(n, (a) => styleText(["strikethrough", "gray"], a))}${r.hint ? ` ${styleText("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${styleText("cyan", et)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "selected" ? `${styleText("green", K)} ${Q(n, (a) => styleText("dim", a))}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "cancelled" ? `${Q(n, (a) => styleText(["strikethrough", "dim"], a))}` : u === "active-selected" ? `${styleText("green", K)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "submitted" ? `${Q(n, (a) => styleText("dim", a))}` : `${styleText("dim", Y)} ${Q(n, (a) => styleText("dim", a))}`;
1039
+ }, s = t.required ?? !0;
1040
+ return new ut$1({
1041
+ options: t.options,
1042
+ signal: t.signal,
1043
+ input: t.input,
1044
+ output: t.output,
1045
+ initialValues: t.initialValues,
1046
+ required: s,
1047
+ cursorAt: t.cursorAt,
1048
+ validate(r) {
1049
+ if (s && (r === void 0 || r.length === 0)) return `Please select at least one option.
1050
+ ${styleText("reset", styleText("dim", `Press ${styleText([
1051
+ "gray",
1052
+ "bgWhite",
1053
+ "inverse"
1054
+ ], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
1055
+ },
1056
+ render() {
1057
+ const r = t.withGuide ?? h.withGuide, u = B(t.output, t.message, r ? `${ft(this.state)} ` : "", `${P(this.state)} `), n = `${r ? `${styleText("gray", $)}
1058
+ ` : ""}${u}
1059
+ `, a = this.value ?? [], c = (o, l) => {
1060
+ if (o.disabled) return i(o, "disabled");
1061
+ const d = a.includes(o.value);
1062
+ return l && d ? i(o, "active-selected") : d ? i(o, "selected") : i(o, l ? "active" : "inactive");
1063
+ };
1064
+ switch (this.state) {
1065
+ case "submit": {
1066
+ const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
1067
+ return `${n}${B(t.output, o, r ? `${styleText("gray", $)} ` : "")}`;
1068
+ }
1069
+ case "cancel": {
1070
+ const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "cancelled")).join(styleText("dim", ", "));
1071
+ if (o.trim() === "") return `${n}${styleText("gray", $)}`;
1072
+ return `${n}${B(t.output, o, r ? `${styleText("gray", $)} ` : "")}${r ? `
1073
+ ${styleText("gray", $)}` : ""}`;
1074
+ }
1075
+ case "error": {
1076
+ const o = r ? `${styleText("yellow", $)} ` : "", l = this.error.split(`
1077
+ `).map((p, f) => f === 0 ? `${r ? `${styleText("yellow", x)} ` : ""}${styleText("yellow", p)}` : ` ${p}`).join(`
1078
+ `), d = n.split(`
1079
+ `).length, g = l.split(`
1080
+ `).length + 1;
1081
+ return `${n}${o}${F({
1082
+ output: t.output,
1083
+ options: this.options,
1084
+ cursor: this.cursor,
1085
+ maxItems: t.maxItems,
1086
+ columnPadding: o.length,
1087
+ rowPadding: d + g,
1088
+ style: c
1089
+ }).join(`
1090
+ ${o}`)}
1091
+ ${l}
1092
+ `;
1093
+ }
1094
+ default: {
1095
+ const o = r ? `${styleText("cyan", $)} ` : "", l = n.split(`
1096
+ `).length, d = r ? 2 : 1;
1097
+ return `${n}${o}${F({
1098
+ output: t.output,
1099
+ options: this.options,
1100
+ cursor: this.cursor,
1101
+ maxItems: t.maxItems,
1102
+ columnPadding: o.length,
1103
+ rowPadding: l + d,
1104
+ style: c
1105
+ }).join(`
1106
+ ${o}`)}
1107
+ ${r ? styleText("cyan", x) : ""}
1108
+ `;
1109
+ }
1110
+ }
1111
+ }
1112
+ }).prompt();
1113
+ }, be = (t) => styleText("dim", t), Se = (t, i, s) => {
1114
+ const r = {
1115
+ hard: !0,
1116
+ trim: !1
1117
+ }, u = wrapAnsi(t, i, r).split(`
1118
+ `), n = u.reduce((o, l) => Math.max(fastStringWidth(l), o), 0);
1119
+ return wrapAnsi(t, i - (u.map(s).reduce((o, l) => Math.max(fastStringWidth(l), o), 0) - n), r);
1120
+ }, Ce = (t = "", i = "", s) => {
1121
+ const r = s?.output ?? V.stdout, u = s?.withGuide ?? h.withGuide, n = s?.format ?? be, a = [
1122
+ "",
1123
+ ...Se(t, A(r) - 6, n).split(`
1124
+ `).map(n),
1125
+ ""
1126
+ ], c = fastStringWidth(i), o = Math.max(a.reduce((p, f) => {
1127
+ const h = fastStringWidth(f);
1128
+ return h > p ? h : p;
1129
+ }, 0), c) + 2, l = a.map((p) => `${styleText("gray", $)} ${p}${" ".repeat(o - fastStringWidth(p))}${styleText("gray", $)}`).join(`
1130
+ `), d = u ? `${styleText("gray", $)}
1131
+ ` : "", g = u ? Mt : ht;
1132
+ r.write(`${d}${styleText("green", H)} ${styleText("reset", i)} ${styleText("gray", st.repeat(Math.max(o - c - 1, 1)) + $t)}
1133
+ ${l}
1134
+ ${styleText("gray", g + st.repeat(o + 2) + dt)}
1135
+ `);
1136
+ }, _e = (t) => styleText("magenta", t), vt = ({ indicator: t = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u, frames: n = tt ? [
1137
+ "◒",
1138
+ "◐",
1139
+ "◓",
1140
+ "◑"
1141
+ ] : [
1142
+ "•",
1143
+ "o",
1144
+ "O",
1145
+ "0"
1146
+ ], delay: a = tt ? 80 : 120, signal: c, ...o } = {}) => {
1147
+ const l = at();
1148
+ let d, g, p = !1, f = !1, h$2 = "", I, m = performance.now();
1149
+ const y = A(s), v = o?.styleFrame ?? _e, C = (_) => {
1150
+ const A = _ > 1 ? u ?? h.messages.error : r ?? h.messages.cancel;
1151
+ f = _ === 1, p && (W$1(A, _), f && typeof i == "function" && i());
1152
+ }, S = () => C(2), b = () => C(1), G = () => {
1153
+ process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", C), c && c.addEventListener("abort", b);
1154
+ }, M = () => {
1155
+ process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", C), c && c.removeEventListener("abort", b);
1156
+ }, N = () => {
1157
+ if (I === void 0) return;
1158
+ l && s.write(`
1159
+ `);
1160
+ const _ = wrapAnsi(I, y, {
1161
+ hard: !0,
1162
+ trim: !1
1163
+ }).split(`
1164
+ `);
1165
+ _.length > 1 && s.write(import_src.cursor.up(_.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
1166
+ }, O = (_) => _.replace(/\.+$/, ""), j = (_) => {
1167
+ const A = (performance.now() - _) / 1e3, L = Math.floor(A / 60), D = Math.floor(A % 60);
1168
+ return L > 0 ? `[${L}m ${D}s]` : `[${D}s]`;
1169
+ }, k = o.withGuide ?? h.withGuide, rt = (_ = "") => {
1170
+ p = !0, d = W({ output: s }), h$2 = O(_), m = performance.now(), k && s.write(`${styleText("gray", $)}
1171
+ `);
1172
+ let A = 0, L = 0;
1173
+ G(), g = setInterval(() => {
1174
+ if (l && h$2 === I) return;
1175
+ N(), I = h$2;
1176
+ const D = v(n[A]);
1177
+ let Z;
1178
+ if (l) Z = `${D} ${h$2}...`;
1179
+ else if (t === "timer") Z = `${D} ${h$2} ${j(m)}`;
1180
+ else {
1181
+ const Lt = ".".repeat(Math.floor(L)).slice(0, 3);
1182
+ Z = `${D} ${h$2}${Lt}`;
1183
+ }
1184
+ const kt = wrapAnsi(Z, y, {
1185
+ hard: !0,
1186
+ trim: !1
1187
+ });
1188
+ s.write(kt), A = A + 1 < n.length ? A + 1 : 0, L = L < 4 ? L + .125 : 0;
1189
+ }, a);
1190
+ }, W$1 = (_ = "", A = 0, L = !1) => {
1191
+ if (!p) return;
1192
+ p = !1, clearInterval(g), N();
1193
+ const D = A === 0 ? styleText("green", H) : A === 1 ? styleText("red", ut) : styleText("red", lt);
1194
+ h$2 = _ ?? h$2, L || (t === "timer" ? s.write(`${D} ${h$2} ${j(m)}
1195
+ `) : s.write(`${D} ${h$2}
1196
+ `)), M(), d();
1197
+ };
1198
+ return {
1199
+ start: rt,
1200
+ stop: (_ = "") => W$1(_, 0),
1201
+ message: (_ = "") => {
1202
+ h$2 = O(_ ?? h$2);
1203
+ },
1204
+ cancel: (_ = "") => W$1(_, 1),
1205
+ error: (_ = "") => W$1(_, 2),
1206
+ clear: () => W$1("", 0, !0),
1207
+ get isCancelled() {
1208
+ return f;
1209
+ }
1210
+ };
1211
+ }, it = (t, i) => t.includes(`
1212
+ `) ? t.split(`
1213
+ `).map((s) => i(s)).join(`
1214
+ `) : i(t), Ee = (t) => {
1215
+ const i = (s, r) => {
1216
+ const u = s.label ?? String(s.value);
1217
+ switch (r) {
1218
+ case "disabled": return `${styleText("gray", U)} ${it(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
1219
+ case "selected": return `${it(u, (n) => styleText("dim", n))}`;
1220
+ case "active": return `${styleText("green", z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
1221
+ case "cancelled": return `${it(u, (n) => styleText(["strikethrough", "dim"], n))}`;
1222
+ default: return `${styleText("dim", U)} ${it(u, (n) => styleText("dim", n))}`;
1223
+ }
1224
+ };
1225
+ return new ht$1({
1226
+ options: t.options,
1227
+ signal: t.signal,
1228
+ input: t.input,
1229
+ output: t.output,
1230
+ initialValue: t.initialValue,
1231
+ render() {
1232
+ const s = t.withGuide ?? h.withGuide, r = `${P(this.state)} `, u = `${ft(this.state)} `, n = B(t.output, t.message, u, r), a = `${s ? `${styleText("gray", $)}
1233
+ ` : ""}${n}
1234
+ `;
1235
+ switch (this.state) {
1236
+ case "submit": {
1237
+ const c = s ? `${styleText("gray", $)} ` : "";
1238
+ return `${a}${B(t.output, i(this.options[this.cursor], "selected"), c)}`;
1239
+ }
1240
+ case "cancel": {
1241
+ const c = s ? `${styleText("gray", $)} ` : "";
1242
+ return `${a}${B(t.output, i(this.options[this.cursor], "cancelled"), c)}${s ? `
1243
+ ${styleText("gray", $)}` : ""}`;
1244
+ }
1245
+ default: {
1246
+ const c = s ? `${styleText("cyan", $)} ` : "", o = s ? styleText("cyan", x) : "", l = a.split(`
1247
+ `).length, d = s ? 2 : 1;
1248
+ return `${a}${c}${F({
1249
+ output: t.output,
1250
+ cursor: this.cursor,
1251
+ options: this.options,
1252
+ maxItems: t.maxItems,
1253
+ columnPadding: c.length,
1254
+ rowPadding: l + d,
1255
+ style: (g, p) => i(g, g.disabled ? "disabled" : p ? "active" : "inactive")
1256
+ }).join(`
1257
+ ${c}`)}
1258
+ ${o}
1259
+ `;
1260
+ }
1261
+ }
1262
+ }
1263
+ }).prompt();
1264
+ }, Bt = `${styleText("gray", $)} `, q = {
1265
+ message: async (t, { symbol: i = styleText("gray", $) } = {}) => {
1266
+ process.stdout.write(`${styleText("gray", $)}
1267
+ ${i} `);
1268
+ let s = 3;
1269
+ for await (let r of t) {
1270
+ r = r.replace(/\n/g, `
1271
+ ${Bt}`), r.includes(`
1272
+ `) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
1273
+ `))).length);
1274
+ const u = stripVTControlCharacters(r).length;
1275
+ s + u < process.stdout.columns ? (s += u, process.stdout.write(r)) : (process.stdout.write(`
1276
+ ${Bt}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
1277
+ }
1278
+ process.stdout.write(`
1279
+ `);
1280
+ },
1281
+ info: (t) => q.message(t, { symbol: styleText("blue", pt) }),
1282
+ success: (t) => q.message(t, { symbol: styleText("green", mt) }),
1283
+ step: (t) => q.message(t, { symbol: styleText("green", H) }),
1284
+ warn: (t) => q.message(t, { symbol: styleText("yellow", gt) }),
1285
+ warning: (t) => q.warn(t),
1286
+ error: (t) => q.message(t, { symbol: styleText("red", yt) })
1287
+ }, Re = (t) => new ct$1({
1288
+ validate: t.validate,
1289
+ placeholder: t.placeholder,
1290
+ defaultValue: t.defaultValue,
1291
+ initialValue: t.initialValue,
1292
+ output: t.output,
1293
+ signal: t.signal,
1294
+ input: t.input,
1295
+ render() {
1296
+ const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${styleText("gray", $)}
1297
+ ` : ""}${P(this.state)} `}${t.message}
1298
+ `, r = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
1299
+ switch (this.state) {
1300
+ case "error": {
1301
+ const a = this.error ? ` ${styleText("yellow", this.error)}` : "", c = i ? `${styleText("yellow", $)} ` : "", o = i ? styleText("yellow", x) : "";
1302
+ return `${s.trim()}
1303
+ ${c}${u}
1304
+ ${o}${a}
1305
+ `;
1306
+ }
1307
+ case "submit": {
1308
+ const a = n ? ` ${styleText("dim", n)}` : "";
1309
+ return `${s}${i ? styleText("gray", $) : ""}${a}`;
1310
+ }
1311
+ case "cancel": {
1312
+ const a = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c = i ? styleText("gray", $) : "";
1313
+ return `${s}${c}${a}${n.trim() ? `
1314
+ ${c}` : ""}`;
1315
+ }
1316
+ default: return `${s}${i ? `${styleText("cyan", $)} ` : ""}${u}
1317
+ ${i ? styleText("cyan", x) : ""}
1318
+ `;
1319
+ }
1320
+ }
1321
+ }).prompt();
1322
+ //#endregion
1323
+ export { Vt as autocomplete, le as confirm, ye as intro, R as isCancel, R$1 as log, we as multiselect, Ce as note, fe as outro, Ee as select, vt as spinner, Re as text };
1324
+
1325
+ //# sourceMappingURL=dist.mjs.map