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