@bizzywork/routing 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1405 @@
1
+ import { createRequire as __bizzyRequire } from "node:module";
2
+ import { fileURLToPath as __bizzyPath } from "node:url";
3
+ const require = __bizzyRequire(import.meta.url);
4
+ const __filename = __bizzyPath(import.meta.url);
5
+ const __dirname = __bizzyPath(new URL(".", import.meta.url));
6
+ import "./chunk-RYVRLJBJ.js";
7
+
8
+ // bizzy-routing/launcher/bin/clack-ui.ts
9
+ import { styleText as styleText3 } from "node:util";
10
+
11
+ // node_modules/@clack/core/dist/index.mjs
12
+ import { styleText } from "node:util";
13
+ import { stdout, stdin } from "node:process";
14
+ import * as f$1 from "node:readline";
15
+ import f__default from "node:readline";
16
+
17
+ // node_modules/fast-string-truncated-width/dist/utils.js
18
+ var getCodePointsLength = /* @__PURE__ */ (() => {
19
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
20
+ return (input) => {
21
+ let surrogatePairsNr = 0;
22
+ SURROGATE_PAIR_RE.lastIndex = 0;
23
+ while (SURROGATE_PAIR_RE.test(input)) {
24
+ surrogatePairsNr += 1;
25
+ }
26
+ return input.length - surrogatePairsNr;
27
+ };
28
+ })();
29
+ var isFullWidth = (x) => {
30
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
31
+ };
32
+ var isWideNotCJKTNotEmoji = (x) => {
33
+ 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;
34
+ };
35
+
36
+ // node_modules/fast-string-truncated-width/dist/index.js
37
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
38
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
39
+ var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
40
+ var TAB_RE = /\t{1,1000}/y;
41
+ var EMOJI_RE = new RegExp("[\\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?))*", "yu");
42
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
43
+ var MODIFIER_RE = new RegExp("\\p{M}+", "gu");
44
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
45
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
46
+ const LIMIT = truncationOptions.limit ?? Infinity;
47
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
48
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
49
+ const ANSI_WIDTH = 0;
50
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
51
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
52
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
53
+ const FULL_WIDTH_WIDTH = 2;
54
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
55
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
56
+ const PARSE_BLOCKS = [
57
+ [LATIN_RE, REGULAR_WIDTH],
58
+ [ANSI_RE, ANSI_WIDTH],
59
+ [CONTROL_RE, CONTROL_WIDTH],
60
+ [TAB_RE, TAB_WIDTH],
61
+ [EMOJI_RE, EMOJI_WIDTH],
62
+ [CJKT_WIDE_RE, WIDE_WIDTH]
63
+ ];
64
+ let indexPrev = 0;
65
+ let index = 0;
66
+ let length = input.length;
67
+ let lengthExtra = 0;
68
+ let truncationEnabled = false;
69
+ let truncationIndex = length;
70
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
71
+ let unmatchedStart = 0;
72
+ let unmatchedEnd = 0;
73
+ let width = 0;
74
+ let widthExtra = 0;
75
+ outer: while (true) {
76
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
77
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
78
+ lengthExtra = 0;
79
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
80
+ const codePoint = char.codePointAt(0) || 0;
81
+ if (isFullWidth(codePoint)) {
82
+ widthExtra = FULL_WIDTH_WIDTH;
83
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
84
+ widthExtra = WIDE_WIDTH;
85
+ } else {
86
+ widthExtra = REGULAR_WIDTH;
87
+ }
88
+ if (width + widthExtra > truncationLimit) {
89
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
90
+ }
91
+ if (width + widthExtra > LIMIT) {
92
+ truncationEnabled = true;
93
+ break outer;
94
+ }
95
+ lengthExtra += char.length;
96
+ width += widthExtra;
97
+ }
98
+ unmatchedStart = unmatchedEnd = 0;
99
+ }
100
+ if (index >= length) {
101
+ break outer;
102
+ }
103
+ for (let i2 = 0, l = PARSE_BLOCKS.length; i2 < l; i2++) {
104
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
105
+ BLOCK_RE.lastIndex = index;
106
+ if (BLOCK_RE.test(input)) {
107
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
108
+ widthExtra = lengthExtra * BLOCK_WIDTH;
109
+ if (width + widthExtra > truncationLimit) {
110
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
111
+ }
112
+ if (width + widthExtra > LIMIT) {
113
+ truncationEnabled = true;
114
+ break outer;
115
+ }
116
+ width += widthExtra;
117
+ unmatchedStart = indexPrev;
118
+ unmatchedEnd = index;
119
+ index = indexPrev = BLOCK_RE.lastIndex;
120
+ continue outer;
121
+ }
122
+ }
123
+ index += 1;
124
+ }
125
+ return {
126
+ width: truncationEnabled ? truncationLimit : width,
127
+ index: truncationEnabled ? truncationIndex : length,
128
+ truncated: truncationEnabled,
129
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
130
+ };
131
+ };
132
+ var dist_default = getStringTruncatedWidth;
133
+
134
+ // node_modules/fast-string-width/dist/index.js
135
+ var NO_TRUNCATION2 = {
136
+ limit: Infinity,
137
+ ellipsis: "",
138
+ ellipsisWidth: 0
139
+ };
140
+ var fastStringWidth = (input, options = {}) => {
141
+ return dist_default(input, NO_TRUNCATION2, options).width;
142
+ };
143
+ var dist_default2 = fastStringWidth;
144
+
145
+ // node_modules/fast-wrap-ansi/lib/main.js
146
+ var ESC = "\x1B";
147
+ var CSI = "\x9B";
148
+ var END_CODE = 39;
149
+ var ANSI_ESCAPE_BELL = "\x07";
150
+ var ANSI_CSI = "[";
151
+ var ANSI_OSC = "]";
152
+ var ANSI_SGR_TERMINATOR = "m";
153
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
154
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
155
+ var getClosingCode = (openingCode) => {
156
+ if (openingCode >= 30 && openingCode <= 37)
157
+ return 39;
158
+ if (openingCode >= 90 && openingCode <= 97)
159
+ return 39;
160
+ if (openingCode >= 40 && openingCode <= 47)
161
+ return 49;
162
+ if (openingCode >= 100 && openingCode <= 107)
163
+ return 49;
164
+ if (openingCode === 1 || openingCode === 2)
165
+ return 22;
166
+ if (openingCode === 3)
167
+ return 23;
168
+ if (openingCode === 4)
169
+ return 24;
170
+ if (openingCode === 7)
171
+ return 27;
172
+ if (openingCode === 8)
173
+ return 28;
174
+ if (openingCode === 9)
175
+ return 29;
176
+ if (openingCode === 0)
177
+ return 0;
178
+ return void 0;
179
+ };
180
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
181
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
182
+ var wrapWord = (rows, word, columns) => {
183
+ const characters = word[Symbol.iterator]();
184
+ let isInsideEscape = false;
185
+ let isInsideLinkEscape = false;
186
+ let lastRow = rows.at(-1);
187
+ let visible = lastRow === void 0 ? 0 : dist_default2(lastRow);
188
+ let currentCharacter = characters.next();
189
+ let nextCharacter = characters.next();
190
+ let rawCharacterIndex = 0;
191
+ while (!currentCharacter.done) {
192
+ const character = currentCharacter.value;
193
+ const characterLength = dist_default2(character);
194
+ if (visible + characterLength <= columns) {
195
+ rows[rows.length - 1] += character;
196
+ } else {
197
+ rows.push(character);
198
+ visible = 0;
199
+ }
200
+ if (character === ESC || character === CSI) {
201
+ isInsideEscape = true;
202
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
203
+ }
204
+ if (isInsideEscape) {
205
+ if (isInsideLinkEscape) {
206
+ if (character === ANSI_ESCAPE_BELL) {
207
+ isInsideEscape = false;
208
+ isInsideLinkEscape = false;
209
+ }
210
+ } else if (character === ANSI_SGR_TERMINATOR) {
211
+ isInsideEscape = false;
212
+ }
213
+ } else {
214
+ visible += characterLength;
215
+ if (visible === columns && !nextCharacter.done) {
216
+ rows.push("");
217
+ visible = 0;
218
+ }
219
+ }
220
+ currentCharacter = nextCharacter;
221
+ nextCharacter = characters.next();
222
+ rawCharacterIndex += character.length;
223
+ }
224
+ lastRow = rows.at(-1);
225
+ if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) {
226
+ rows[rows.length - 2] += rows.pop();
227
+ }
228
+ };
229
+ var stringVisibleTrimSpacesRight = (string) => {
230
+ const words = string.split(" ");
231
+ let last = words.length;
232
+ while (last) {
233
+ if (dist_default2(words[last - 1])) {
234
+ break;
235
+ }
236
+ last--;
237
+ }
238
+ if (last === words.length) {
239
+ return string;
240
+ }
241
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
242
+ };
243
+ var exec = (string, columns, options = {}) => {
244
+ if (options.trim !== false && string.trim() === "") {
245
+ return "";
246
+ }
247
+ let returnValue = "";
248
+ let escapeCode;
249
+ let escapeUrl;
250
+ const words = string.split(" ");
251
+ let rows = [""];
252
+ let rowLength = 0;
253
+ for (let index = 0; index < words.length; index++) {
254
+ const word = words[index];
255
+ if (options.trim !== false) {
256
+ const row = rows.at(-1) ?? "";
257
+ const trimmed = row.trimStart();
258
+ if (row.length !== trimmed.length) {
259
+ rows[rows.length - 1] = trimmed;
260
+ rowLength = dist_default2(trimmed);
261
+ }
262
+ }
263
+ if (index !== 0) {
264
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
265
+ rows.push("");
266
+ rowLength = 0;
267
+ }
268
+ if (rowLength || options.trim === false) {
269
+ rows[rows.length - 1] += " ";
270
+ rowLength++;
271
+ }
272
+ }
273
+ const wordLength = dist_default2(word);
274
+ if (options.hard && wordLength > columns) {
275
+ const remainingColumns = columns - rowLength;
276
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
277
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
278
+ if (breaksStartingNextLine < breaksStartingThisLine) {
279
+ rows.push("");
280
+ }
281
+ wrapWord(rows, word, columns);
282
+ rowLength = dist_default2(rows.at(-1) ?? "");
283
+ continue;
284
+ }
285
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
286
+ if (options.wordWrap === false && rowLength < columns) {
287
+ wrapWord(rows, word, columns);
288
+ rowLength = dist_default2(rows.at(-1) ?? "");
289
+ continue;
290
+ }
291
+ rows.push("");
292
+ rowLength = 0;
293
+ }
294
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
295
+ wrapWord(rows, word, columns);
296
+ rowLength = dist_default2(rows.at(-1) ?? "");
297
+ continue;
298
+ }
299
+ rows[rows.length - 1] += word;
300
+ rowLength += wordLength;
301
+ }
302
+ if (options.trim !== false) {
303
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
304
+ }
305
+ const preString = rows.join("\n");
306
+ let inSurrogate = false;
307
+ for (let i2 = 0; i2 < preString.length; i2++) {
308
+ const character = preString[i2];
309
+ returnValue += character;
310
+ if (!inSurrogate) {
311
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
312
+ if (inSurrogate) {
313
+ continue;
314
+ }
315
+ } else {
316
+ inSurrogate = false;
317
+ }
318
+ if (character === ESC || character === CSI) {
319
+ GROUP_REGEX.lastIndex = i2 + 1;
320
+ const groupsResult = GROUP_REGEX.exec(preString);
321
+ const groups = groupsResult?.groups;
322
+ if (groups?.code !== void 0) {
323
+ const code = Number.parseFloat(groups.code);
324
+ escapeCode = code === END_CODE ? void 0 : code;
325
+ } else if (groups?.uri !== void 0) {
326
+ escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
327
+ }
328
+ }
329
+ if (preString[i2 + 1] === "\n") {
330
+ if (escapeUrl) {
331
+ returnValue += wrapAnsiHyperlink("");
332
+ }
333
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
334
+ if (escapeCode && closingCode) {
335
+ returnValue += wrapAnsiCode(closingCode);
336
+ }
337
+ } else if (character === "\n") {
338
+ if (escapeCode && getClosingCode(escapeCode)) {
339
+ returnValue += wrapAnsiCode(escapeCode);
340
+ }
341
+ if (escapeUrl) {
342
+ returnValue += wrapAnsiHyperlink(escapeUrl);
343
+ }
344
+ }
345
+ }
346
+ return returnValue;
347
+ };
348
+ var CRLF_OR_LF = /\r?\n/;
349
+ function wrapAnsi(string, columns, options) {
350
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
351
+ }
352
+
353
+ // node_modules/@clack/core/node_modules/sisteransi/dist/index.js
354
+ var ESC2 = "\x1B";
355
+ var CSI2 = `${ESC2}[`;
356
+ var cursor = {
357
+ to(x, y) {
358
+ if (!y)
359
+ return `${CSI2}${x + 1}G`;
360
+ return `${CSI2}${y + 1};${x + 1}H`;
361
+ },
362
+ move(x, y) {
363
+ let ret = "";
364
+ if (x < 0)
365
+ ret += `${CSI2}${-x}D`;
366
+ else if (x > 0)
367
+ ret += `${CSI2}${x}C`;
368
+ if (y < 0)
369
+ ret += `${CSI2}${-y}A`;
370
+ else if (y > 0)
371
+ ret += `${CSI2}${y}B`;
372
+ return ret;
373
+ },
374
+ up: (count = 1) => `${CSI2}${count}A`,
375
+ down: (count = 1) => `${CSI2}${count}B`,
376
+ forward: (count = 1) => `${CSI2}${count}C`,
377
+ backward: (count = 1) => `${CSI2}${count}D`,
378
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
379
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
380
+ left: `${CSI2}G`,
381
+ hide: `${CSI2}?25l`,
382
+ show: `${CSI2}?25h`,
383
+ save: `${ESC2}7`,
384
+ restore: `${ESC2}8`
385
+ };
386
+ var erase = {
387
+ screen: `${CSI2}2J`,
388
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
389
+ down: (count = 1) => `${CSI2}J`.repeat(count),
390
+ line: `${CSI2}2K`,
391
+ lineEnd: `${CSI2}K`,
392
+ lineStart: `${CSI2}1K`,
393
+ lines(count) {
394
+ let clear3 = "";
395
+ for (let i2 = 0; i2 < count; i2++)
396
+ clear3 += this.line + (i2 < count - 1 ? cursor.up() : "");
397
+ if (count)
398
+ clear3 += cursor.left;
399
+ return clear3;
400
+ }
401
+ };
402
+ var clear = {
403
+ screen: `${ESC2}c`
404
+ };
405
+
406
+ // node_modules/@clack/core/dist/index.mjs
407
+ import { ReadStream } from "node:tty";
408
+ function findCursor(o, s, l) {
409
+ if (!l.some((r2) => !r2.disabled))
410
+ return o;
411
+ const t2 = o + s, n3 = Math.max(l.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
412
+ return l[e]?.disabled ? findCursor(e, s < 0 ? -1 : 1, l) : e;
413
+ }
414
+ var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
415
+ var t = [
416
+ "January",
417
+ "February",
418
+ "March",
419
+ "April",
420
+ "May",
421
+ "June",
422
+ "July",
423
+ "August",
424
+ "September",
425
+ "October",
426
+ "November",
427
+ "December"
428
+ ];
429
+ var settings = {
430
+ actions: new Set(a$1),
431
+ aliases: /* @__PURE__ */ new Map([
432
+ // vim support
433
+ ["k", "up"],
434
+ ["j", "down"],
435
+ ["h", "left"],
436
+ ["l", "right"],
437
+ ["", "cancel"],
438
+ // opinionated defaults!
439
+ ["escape", "cancel"]
440
+ ]),
441
+ messages: {
442
+ cancel: "Canceled",
443
+ error: "Something went wrong"
444
+ },
445
+ withGuide: true,
446
+ accessible: void 0,
447
+ date: {
448
+ monthNames: [...t],
449
+ messages: {
450
+ required: "Please enter a valid date",
451
+ invalidMonth: "There are only 12 months in a year",
452
+ invalidDay: (n3, e) => `There are only ${n3} days in ${e}`,
453
+ afterMin: (n3) => `Date must be on or after ${n3.toISOString().slice(0, 10)}`,
454
+ beforeMax: (n3) => `Date must be on or before ${n3.toISOString().slice(0, 10)}`
455
+ }
456
+ }
457
+ };
458
+ function isAccessible(n3) {
459
+ if (n3 !== void 0) return n3;
460
+ if (settings.accessible !== void 0) return settings.accessible;
461
+ const e = process.env.ACCESSIBLE;
462
+ return e !== void 0 && e !== "" && e !== "0" && e !== "false";
463
+ }
464
+ function isActionKey(n3, e) {
465
+ if (typeof n3 == "string")
466
+ return settings.aliases.get(n3) === e;
467
+ for (const s of n3)
468
+ if (s !== void 0 && isActionKey(s, e))
469
+ return true;
470
+ return false;
471
+ }
472
+ function diffLines(i2, s) {
473
+ if (i2 === s) return;
474
+ const e = i2.split(`
475
+ `), t2 = s.split(`
476
+ `), r2 = Math.max(e.length, t2.length), f = [];
477
+ for (let n3 = 0; n3 < r2; n3++)
478
+ e[n3] !== t2[n3] && f.push(n3);
479
+ return {
480
+ lines: f,
481
+ numLinesBefore: e.length,
482
+ numLinesAfter: t2.length,
483
+ numLines: r2
484
+ };
485
+ }
486
+ var R = globalThis.process.platform.startsWith("win");
487
+ var CANCEL_SYMBOL = /* @__PURE__ */ Symbol("clack:cancel");
488
+ function isCancel(e) {
489
+ return e === CANCEL_SYMBOL;
490
+ }
491
+ function setRawMode(e, r2) {
492
+ const o = e;
493
+ o.isTTY && o.setRawMode(r2);
494
+ }
495
+ function block({
496
+ input: e = stdin,
497
+ output: r2 = stdout,
498
+ overwrite: o = true,
499
+ hideCursor: n3 = true
500
+ } = {}) {
501
+ const s = f$1.createInterface({
502
+ input: e,
503
+ output: r2,
504
+ prompt: "",
505
+ tabSize: 1
506
+ });
507
+ f$1.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
508
+ const t2 = (l, { name: i2, sequence: p }) => {
509
+ const w = String(l);
510
+ if (isActionKey([w, i2, p], "cancel")) {
511
+ n3 && r2.write(cursor.show), process.exit(0);
512
+ return;
513
+ }
514
+ if (!o) return;
515
+ const c3 = i2 === "return" ? 0 : -1, a2 = i2 === "return" ? -1 : 0;
516
+ f$1.moveCursor(r2, c3, a2, () => {
517
+ f$1.clearLine(r2, 1, () => {
518
+ e.once("keypress", t2);
519
+ });
520
+ });
521
+ };
522
+ return n3 && r2.write(cursor.hide), e.once("keypress", t2), () => {
523
+ e.off("keypress", t2), n3 && r2.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
524
+ };
525
+ }
526
+ var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
527
+ var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
528
+ function wrapTextWithPrefix(e, r2, o, n3 = o, s = o, t2) {
529
+ const l = getColumns(e ?? stdout), i2 = dist_default2(o);
530
+ return wrapAnsi(r2, l - i2, {
531
+ hard: true,
532
+ trim: false
533
+ }).split(`
534
+ `).map((c3, a2, g) => {
535
+ const m = t2 ? t2(c3, a2) : c3;
536
+ return a2 === 0 ? `${n3}${m}` : a2 === g.length - 1 ? `${s}${m}` : `${o}${m}`;
537
+ }).join(`
538
+ `);
539
+ }
540
+ function runValidation(e, a2) {
541
+ if ("~standard" in e) {
542
+ const n3 = e["~standard"].validate(a2);
543
+ return n3 instanceof Promise ? n3.then((r2) => r2.issues?.at(0)?.message) : n3.issues?.at(0)?.message;
544
+ }
545
+ return e(a2);
546
+ }
547
+ var C$1 = class C {
548
+ input;
549
+ output;
550
+ _abortSignal;
551
+ rl;
552
+ opts;
553
+ _render;
554
+ _track = false;
555
+ _prevFrame = "";
556
+ _subscribers = /* @__PURE__ */ new Map();
557
+ _cursor = 0;
558
+ state = "initial";
559
+ error = "";
560
+ value;
561
+ userInput = "";
562
+ /**
563
+ * Whether accessible (static, screen-reader friendly) output is enabled for
564
+ * this prompt, resolved from the `accessible` option, the global setting,
565
+ * and the `ACCESSIBLE` env var.
566
+ */
567
+ get accessible() {
568
+ return isAccessible(this.opts.accessible);
569
+ }
570
+ constructor(t2, e = true) {
571
+ const { input: i2 = stdin, output: s = stdout, render: r2, signal: n3, ...o } = t2;
572
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r2.bind(this), this._track = e, this._abortSignal = n3, this.input = i2, this.output = s;
573
+ }
574
+ /**
575
+ * Unsubscribe all listeners
576
+ */
577
+ unsubscribe() {
578
+ this._subscribers.clear();
579
+ }
580
+ /**
581
+ * Set a subscriber with opts
582
+ * @param event - The event name
583
+ */
584
+ setSubscriber(t2, e) {
585
+ const i2 = this._subscribers.get(t2) ?? [];
586
+ i2.push(e), this._subscribers.set(t2, i2);
587
+ }
588
+ /**
589
+ * Subscribe to an event
590
+ * @param event - The event name
591
+ * @param cb - The callback
592
+ */
593
+ on(t2, e) {
594
+ this.setSubscriber(t2, { cb: e });
595
+ }
596
+ /**
597
+ * Subscribe to an event once
598
+ * @param event - The event name
599
+ * @param cb - The callback
600
+ */
601
+ once(t2, e) {
602
+ this.setSubscriber(t2, { cb: e, once: true });
603
+ }
604
+ /**
605
+ * Emit an event with data
606
+ * @param event - The event name
607
+ * @param data - The data to pass to the callback
608
+ */
609
+ emit(t2, ...e) {
610
+ const i2 = this._subscribers.get(t2) ?? [], s = [];
611
+ for (const r2 of i2)
612
+ r2.cb(...e), r2.once && s.push(() => i2.splice(i2.indexOf(r2), 1));
613
+ for (const r2 of s)
614
+ r2();
615
+ }
616
+ prompt() {
617
+ return new Promise((t2) => {
618
+ if (this._abortSignal) {
619
+ if (this._abortSignal.aborted)
620
+ return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
621
+ this._abortSignal.addEventListener(
622
+ "abort",
623
+ () => {
624
+ this.state = "cancel", this.close();
625
+ },
626
+ { once: true }
627
+ );
628
+ }
629
+ this.rl = f__default.createInterface({
630
+ input: this.input,
631
+ tabSize: 2,
632
+ prompt: "",
633
+ escapeCodeTimeout: 50,
634
+ terminal: true
635
+ }), 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", () => {
636
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
637
+ }), this.once("cancel", () => {
638
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
639
+ });
640
+ });
641
+ }
642
+ _isActionKey(t2, e) {
643
+ return t2 === " ";
644
+ }
645
+ _shouldSubmit(t2, e) {
646
+ return true;
647
+ }
648
+ _setValue(t2) {
649
+ this.value = t2, this.emit("value", this.value);
650
+ }
651
+ _setUserInput(t2, e) {
652
+ this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
653
+ }
654
+ _clearUserInput() {
655
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
656
+ }
657
+ async onKeypress(t2, e) {
658
+ if (this.state !== "validating") {
659
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), 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)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
660
+ if (this.opts.validate) {
661
+ const i2 = runValidation(this.opts.validate, this.value);
662
+ let s;
663
+ i2 instanceof Promise ? (this.state = "validating", this.render(), s = await i2) : s = i2, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
664
+ }
665
+ this.state !== "error" && (this.state = "submit");
666
+ }
667
+ isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
668
+ }
669
+ }
670
+ close() {
671
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
672
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
673
+ }
674
+ restoreCursor() {
675
+ const t2 = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
676
+ `).length - 1;
677
+ this.output.write(cursor.move(-999, t2 * -1));
678
+ }
679
+ render() {
680
+ const t2 = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
681
+ hard: true,
682
+ trim: false
683
+ });
684
+ if (t2 !== this._prevFrame) {
685
+ if (this.state === "initial")
686
+ this.output.write(cursor.hide);
687
+ else {
688
+ const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
689
+ if (this.restoreCursor(), e) {
690
+ const s = Math.max(0, e.numLinesAfter - i2), r2 = Math.max(0, e.numLinesBefore - i2);
691
+ let n3 = e.lines.find((o) => o >= s);
692
+ if (n3 === void 0) {
693
+ this._prevFrame = t2;
694
+ return;
695
+ }
696
+ if (e.lines.length === 1) {
697
+ this.output.write(cursor.move(0, n3 - r2)), this.output.write(erase.lines(1));
698
+ const o = t2.split(`
699
+ `);
700
+ this.output.write(o[n3]), this._prevFrame = t2, this.output.write(cursor.move(0, o.length - n3 - 1));
701
+ return;
702
+ } else if (e.lines.length > 1) {
703
+ if (s < r2)
704
+ n3 = s;
705
+ else {
706
+ const h2 = n3 - r2;
707
+ h2 > 0 && this.output.write(cursor.move(0, h2));
708
+ }
709
+ this.output.write(erase.down());
710
+ const m = t2.split(`
711
+ `).slice(n3);
712
+ this.output.write(m.join(`
713
+ `)), this._prevFrame = t2;
714
+ return;
715
+ }
716
+ }
717
+ this.output.write(erase.down());
718
+ }
719
+ this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
720
+ }
721
+ }
722
+ };
723
+ var r = class extends C$1 {
724
+ get cursor() {
725
+ return this.value ? 0 : 1;
726
+ }
727
+ get _value() {
728
+ return this.cursor === 0;
729
+ }
730
+ constructor(t2) {
731
+ super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
732
+ this.value = this._value;
733
+ }), this.on("confirm", (i2) => {
734
+ this.output.write(cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
735
+ }), this.on("cursor", () => {
736
+ this.value = !this.value;
737
+ });
738
+ }
739
+ };
740
+ var u = class extends C$1 {
741
+ _mask = "\u2022";
742
+ get cursor() {
743
+ return this._cursor;
744
+ }
745
+ get masked() {
746
+ return this.userInput.replaceAll(/./g, this._mask);
747
+ }
748
+ get userInputWithCursor() {
749
+ if (this.state === "submit" || this.state === "cancel")
750
+ return this.masked;
751
+ const t2 = this.userInput;
752
+ if (this.cursor >= t2.length)
753
+ return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
754
+ const s = this.masked, r2 = s.slice(0, this.cursor), i2 = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
755
+ return `${r2}${styleText("inverse", i2)}${o}`;
756
+ }
757
+ clear() {
758
+ this._clearUserInput();
759
+ }
760
+ constructor({ mask: t2, ...s }) {
761
+ super(s), this._mask = t2 ?? "\u2022", this.on("userInput", (r2) => {
762
+ this._setValue(r2);
763
+ }), this.on("finalize", () => {
764
+ this.value === void 0 && (this.value = "");
765
+ });
766
+ }
767
+ };
768
+ var n$1 = class n extends C$1 {
769
+ options;
770
+ cursor = 0;
771
+ get _selectedValue() {
772
+ return this.options[this.cursor];
773
+ }
774
+ changeValue() {
775
+ const e = this._selectedValue;
776
+ this.value = e === void 0 ? void 0 : e.value;
777
+ }
778
+ constructor(e) {
779
+ super(e, false), this.options = e.options;
780
+ const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t2 = o === -1 ? 0 : o;
781
+ this.cursor = this.options[t2]?.disabled ? findCursor(t2, 1, this.options) : t2, this.changeValue(), this.on("cursor", (s) => {
782
+ switch (s) {
783
+ case "left":
784
+ case "up":
785
+ this.cursor = findCursor(this.cursor, -1, this.options);
786
+ break;
787
+ case "down":
788
+ case "right":
789
+ this.cursor = findCursor(this.cursor, 1, this.options);
790
+ break;
791
+ }
792
+ this.changeValue();
793
+ });
794
+ }
795
+ };
796
+
797
+ // node_modules/@clack/prompts/dist/index.mjs
798
+ import { styleText as styleText2, stripVTControlCharacters } from "node:util";
799
+ import process$1 from "node:process";
800
+
801
+ // node_modules/@clack/prompts/node_modules/sisteransi/dist/index.js
802
+ var ESC3 = "\x1B";
803
+ var CSI3 = `${ESC3}[`;
804
+ var cursor2 = {
805
+ to(x, y) {
806
+ if (!y)
807
+ return `${CSI3}${x + 1}G`;
808
+ return `${CSI3}${y + 1};${x + 1}H`;
809
+ },
810
+ move(x, y) {
811
+ let ret = "";
812
+ if (x < 0)
813
+ ret += `${CSI3}${-x}D`;
814
+ else if (x > 0)
815
+ ret += `${CSI3}${x}C`;
816
+ if (y < 0)
817
+ ret += `${CSI3}${-y}A`;
818
+ else if (y > 0)
819
+ ret += `${CSI3}${y}B`;
820
+ return ret;
821
+ },
822
+ up: (count = 1) => `${CSI3}${count}A`,
823
+ down: (count = 1) => `${CSI3}${count}B`,
824
+ forward: (count = 1) => `${CSI3}${count}C`,
825
+ backward: (count = 1) => `${CSI3}${count}D`,
826
+ nextLine: (count = 1) => `${CSI3}E`.repeat(count),
827
+ prevLine: (count = 1) => `${CSI3}F`.repeat(count),
828
+ left: `${CSI3}G`,
829
+ hide: `${CSI3}?25l`,
830
+ show: `${CSI3}?25h`,
831
+ save: `${ESC3}7`,
832
+ restore: `${ESC3}8`
833
+ };
834
+ var erase2 = {
835
+ screen: `${CSI3}2J`,
836
+ up: (count = 1) => `${CSI3}1J`.repeat(count),
837
+ down: (count = 1) => `${CSI3}J`.repeat(count),
838
+ line: `${CSI3}2K`,
839
+ lineEnd: `${CSI3}K`,
840
+ lineStart: `${CSI3}1K`,
841
+ lines(count) {
842
+ let clear3 = "";
843
+ for (let i2 = 0; i2 < count; i2++)
844
+ clear3 += this.line + (i2 < count - 1 ? cursor2.up() : "");
845
+ if (count)
846
+ clear3 += cursor2.left;
847
+ return clear3;
848
+ }
849
+ };
850
+ var clear2 = {
851
+ screen: `${ESC3}c`
852
+ };
853
+
854
+ // node_modules/@clack/prompts/dist/index.mjs
855
+ function isUnicodeSupported() {
856
+ if (process$1.platform !== "win32") {
857
+ return process$1.env.TERM !== "linux";
858
+ }
859
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
860
+ }
861
+ var unicode = isUnicodeSupported();
862
+ var isCI = () => process.env.CI === "true";
863
+ var unicodeOr = (e, o) => unicode ? e : o;
864
+ var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
865
+ var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
866
+ var S_STEP_ERROR = unicodeOr("\u25B2", "x");
867
+ var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
868
+ var S_BAR_START = unicodeOr("\u250C", "T");
869
+ var S_BAR = unicodeOr("\u2502", "|");
870
+ var S_BAR_END = unicodeOr("\u2514", "\u2014");
871
+ var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
872
+ var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
873
+ var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
874
+ var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
875
+ var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
876
+ var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
877
+ var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
878
+ var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
879
+ var S_BAR_H = unicodeOr("\u2500", "-");
880
+ var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
881
+ var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
882
+ var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
883
+ var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
884
+ var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
885
+ var S_INFO = unicodeOr("\u25CF", "\u2022");
886
+ var S_SUCCESS = unicodeOr("\u25C6", "*");
887
+ var S_WARN = unicodeOr("\u25B2", "!");
888
+ var S_ERROR = unicodeOr("\u25A0", "x");
889
+ var symbol = (e) => {
890
+ switch (e) {
891
+ case "initial":
892
+ case "active":
893
+ return styleText2("cyan", S_STEP_ACTIVE);
894
+ case "cancel":
895
+ return styleText2("red", S_STEP_CANCEL);
896
+ case "error":
897
+ return styleText2("yellow", S_STEP_ERROR);
898
+ case "submit":
899
+ return styleText2("green", S_STEP_SUBMIT);
900
+ case "validating":
901
+ return styleText2("dim", S_STEP_ACTIVE);
902
+ }
903
+ };
904
+ var symbolBar = (e) => {
905
+ switch (e) {
906
+ case "initial":
907
+ case "active":
908
+ return styleText2("cyan", S_BAR);
909
+ case "cancel":
910
+ return styleText2("red", S_BAR);
911
+ case "error":
912
+ return styleText2("yellow", S_BAR);
913
+ case "submit":
914
+ return styleText2("green", S_BAR);
915
+ }
916
+ };
917
+ function formatInstructionFooter(e, o, r2) {
918
+ const s = r2 ? `${styleText2("cyan", S_BAR)} ` : "", n3 = wrapTextWithPrefix(e, o.join(" \u2022 "), s).split(`
919
+ `);
920
+ return r2 && n3.push(styleText2("cyan", S_BAR_END)), n3;
921
+ }
922
+ var E$1 = (l, e, w, p, b, C3 = false) => {
923
+ let r2 = e, O = 0;
924
+ if (C3)
925
+ for (let i2 = p - 1; i2 >= w; i2--) {
926
+ const m = l[i2];
927
+ if (m && (r2 -= m.length), O++, r2 <= b) break;
928
+ }
929
+ else
930
+ for (let i2 = w; i2 < p; i2++) {
931
+ const m = l[i2];
932
+ if (m && (r2 -= m.length), O++, r2 <= b) break;
933
+ }
934
+ return { lineCount: r2, removals: O };
935
+ };
936
+ var limitOptions = ({
937
+ cursor: l,
938
+ options: e,
939
+ style: w,
940
+ output: p = process.stdout,
941
+ maxItems: b = Number.POSITIVE_INFINITY,
942
+ columnPadding: C3 = 0,
943
+ rowPadding: r2 = 4
944
+ }) => {
945
+ const i2 = getColumns(p) - C3, m = getRows(p), M = styleText2("dim", "..."), v = Math.max(m - r2, 0), a2 = Math.max(Math.min(b, v), 5);
946
+ let f = 0;
947
+ l >= a2 - 3 && (f = Math.max(
948
+ Math.min(l - a2 + 3, e.length - a2),
949
+ 0
950
+ ));
951
+ let d = a2 < e.length && f > 0, c3 = a2 < e.length && f + a2 < e.length;
952
+ const I = Math.min(
953
+ f + a2,
954
+ e.length
955
+ ), s = [];
956
+ let g = 0;
957
+ d && g++, c3 && g++;
958
+ const T = f + (d ? 1 : 0), W2 = I - (c3 ? 1 : 0);
959
+ for (let t2 = T; t2 < W2; t2++) {
960
+ const n3 = e[t2], o = n3 !== void 0 ? w(n3, t2 === l) : "", h2 = wrapAnsi(o, i2, {
961
+ hard: true,
962
+ trim: false
963
+ }).split(`
964
+ `);
965
+ s.push(h2), g += h2.length;
966
+ }
967
+ if (g > v) {
968
+ let t2 = 0, n3 = 0, o = g;
969
+ const h2 = l - T;
970
+ let u3 = v;
971
+ const L = () => E$1(s, o, 0, h2, u3), y = () => E$1(
972
+ s,
973
+ o,
974
+ h2 + 1,
975
+ s.length,
976
+ u3,
977
+ true
978
+ );
979
+ d ? ({ lineCount: o, removals: t2 } = L(), o > u3 && (c3 || (u3 -= 1), { lineCount: o, removals: n3 } = y())) : (c3 || (u3 -= 1), { lineCount: o, removals: n3 } = y(), o > u3 && (u3 -= 1, { lineCount: o, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c3 = true, s.splice(s.length - n3, n3));
980
+ }
981
+ const x = [];
982
+ d && x.push(M);
983
+ for (const t2 of s)
984
+ for (const n3 of t2)
985
+ x.push(n3);
986
+ return c3 && x.push(M), x;
987
+ };
988
+ var confirm = (e) => {
989
+ const a2 = e.active ?? "Yes", o = e.inactive ?? "No";
990
+ return new r({
991
+ active: a2,
992
+ inactive: o,
993
+ signal: e.signal,
994
+ input: e.input,
995
+ output: e.output,
996
+ initialValue: e.initialValue ?? true,
997
+ render() {
998
+ const i2 = e.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l = i2 ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
999
+ e.output,
1000
+ e.message,
1001
+ l,
1002
+ u3
1003
+ ), s = `${i2 ? `${styleText2("gray", S_BAR)}
1004
+ ` : ""}${f}
1005
+ `, c3 = this.value ? a2 : o;
1006
+ switch (this.state) {
1007
+ case "submit": {
1008
+ const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
1009
+ return `${s}${r2}${styleText2("dim", c3)}`;
1010
+ }
1011
+ case "cancel": {
1012
+ const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
1013
+ return `${s}${r2}${styleText2(["strikethrough", "dim"], c3)}${i2 ? `
1014
+ ${styleText2("gray", S_BAR)}` : ""}`;
1015
+ }
1016
+ default: {
1017
+ const r2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", g = i2 ? styleText2("cyan", S_BAR_END) : "";
1018
+ return `${s}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a2}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`}${e.vertical ? i2 ? `
1019
+ ${styleText2("cyan", S_BAR)} ` : `
1020
+ ` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", o)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${o}`}
1021
+ ${g}
1022
+ `;
1023
+ }
1024
+ }
1025
+ }
1026
+ }).prompt();
1027
+ };
1028
+ var MULTISELECT_INSTRUCTIONS = [
1029
+ `${styleText2("dim", "\u2191/\u2193")} to navigate`,
1030
+ `${styleText2("dim", "Space:")} select`,
1031
+ `${styleText2("dim", "Enter:")} confirm`
1032
+ ];
1033
+ var log = {
1034
+ message: (s = [], {
1035
+ symbol: e = styleText2("gray", S_BAR),
1036
+ secondarySymbol: r2 = styleText2("gray", S_BAR),
1037
+ output: m = process.stdout,
1038
+ spacing: l = 1,
1039
+ withGuide: c3
1040
+ } = {}) => {
1041
+ const t2 = [], o = c3 ?? settings.withGuide, f = o ? r2 : "", O = o ? `${e} ` : "", u3 = o ? `${r2} ` : "";
1042
+ for (let i2 = 0; i2 < l; i2++)
1043
+ t2.push(f);
1044
+ const g = Array.isArray(s) ? s : s.split(`
1045
+ `);
1046
+ if (g.length > 0) {
1047
+ const [i2, ...y] = g;
1048
+ i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o ? e : "");
1049
+ for (const p of y)
1050
+ p.length > 0 ? t2.push(`${u3}${p}`) : t2.push(o ? r2 : "");
1051
+ }
1052
+ m.write(`${t2.join(`
1053
+ `)}
1054
+ `);
1055
+ },
1056
+ info: (s, e) => {
1057
+ log.message(s, { ...e, symbol: styleText2("blue", S_INFO) });
1058
+ },
1059
+ success: (s, e) => {
1060
+ log.message(s, { ...e, symbol: styleText2("green", S_SUCCESS) });
1061
+ },
1062
+ step: (s, e) => {
1063
+ log.message(s, { ...e, symbol: styleText2("green", S_STEP_SUBMIT) });
1064
+ },
1065
+ warn: (s, e) => {
1066
+ log.message(s, { ...e, symbol: styleText2("yellow", S_WARN) });
1067
+ },
1068
+ /** alias for `log.warn()`. */
1069
+ warning: (s, e) => {
1070
+ log.warn(s, e);
1071
+ },
1072
+ error: (s, e) => {
1073
+ log.message(s, { ...e, symbol: styleText2("red", S_ERROR) });
1074
+ }
1075
+ };
1076
+ var cancel = (o = "", t2) => {
1077
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
1078
+ i2.write(`${e}${styleText2("red", o)}
1079
+
1080
+ `);
1081
+ };
1082
+ var intro = (o = "", t2) => {
1083
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
1084
+ i2.write(`${e}${o}
1085
+ `);
1086
+ };
1087
+ var outro = (o = "", t2) => {
1088
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
1089
+ ${styleText2("gray", S_BAR_END)} ` : "";
1090
+ i2.write(`${e}${o}
1091
+
1092
+ `);
1093
+ };
1094
+ var W = (o) => o;
1095
+ var C2 = (o, e, s) => {
1096
+ const a2 = {
1097
+ hard: true,
1098
+ trim: false
1099
+ }, i2 = wrapAnsi(o, e, a2).split(`
1100
+ `), c3 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), u3 = i2.map(s).reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), g = e - (u3 - c3);
1101
+ return wrapAnsi(o, g, a2);
1102
+ };
1103
+ var note = (o = "", e = "", s) => {
1104
+ const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c3 = s?.format ?? W, g = ["", ...C2(o, getColumns(a2) - 6, c3).split(`
1105
+ `).map(c3), ""], n3 = dist_default2(e), t2 = Math.max(
1106
+ g.reduce((m, F) => {
1107
+ const O = dist_default2(F);
1108
+ return O > m ? O : m;
1109
+ }, 0),
1110
+ n3
1111
+ ) + 2, h2 = g.map(
1112
+ (m) => `${styleText2("gray", S_BAR)} ${m}${" ".repeat(t2 - dist_default2(m))}${styleText2("gray", S_BAR)}`
1113
+ ).join(`
1114
+ `), T = i2 ? `${styleText2("gray", S_BAR)}
1115
+ ` : "", l$1 = i2 ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
1116
+ a2.write(
1117
+ `${T}${styleText2("green", S_STEP_SUBMIT)} ${styleText2("reset", e)} ${styleText2(
1118
+ "gray",
1119
+ S_BAR_H.repeat(Math.max(t2 - n3 - 1, 1)) + S_CORNER_TOP_RIGHT
1120
+ )}
1121
+ ${h2}
1122
+ ${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
1123
+ `
1124
+ );
1125
+ };
1126
+ var password = (e) => new u({
1127
+ validate: e.validate,
1128
+ mask: e.mask ?? S_PASSWORD_MASK,
1129
+ signal: e.signal,
1130
+ input: e.input,
1131
+ output: e.output,
1132
+ render() {
1133
+ const r2 = e.withGuide ?? settings.withGuide, o = `${r2 ? `${styleText2("gray", S_BAR)}
1134
+ ` : ""}${symbol(this.state)} ${e.message}
1135
+ `, m = this.userInputWithCursor, i2 = this.masked;
1136
+ switch (this.state) {
1137
+ case "error": {
1138
+ const s = r2 ? `${styleText2("yellow", S_BAR)} ` : "", n3 = r2 ? `${styleText2("yellow", S_BAR_END)} ` : "", d = i2 ?? "";
1139
+ return e.clearOnError && this.clear(), `${o.trim()}
1140
+ ${s}${d}
1141
+ ${n3}${styleText2("yellow", this.error)}
1142
+ `;
1143
+ }
1144
+ case "submit": {
1145
+ const s = r2 ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2("dim", i2) : "";
1146
+ return `${o}${s}${n3}`;
1147
+ }
1148
+ case "cancel": {
1149
+ const s = r2 ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2(["strikethrough", "dim"], i2) : "";
1150
+ return `${o}${s}${n3}${i2 && r2 ? `
1151
+ ${styleText2("gray", S_BAR)}` : ""}`;
1152
+ }
1153
+ default: {
1154
+ const s = r2 ? `${styleText2("cyan", S_BAR)} ` : "", n3 = r2 ? styleText2("cyan", S_BAR_END) : "";
1155
+ return `${o}${s}${m}
1156
+ ${n3}
1157
+ `;
1158
+ }
1159
+ }
1160
+ }
1161
+ }).prompt();
1162
+ var Y = 3e4;
1163
+ var Z = (c3) => styleText2("magenta", c3);
1164
+ var spinner = ({
1165
+ indicator: c3 = "dots",
1166
+ onCancel: b,
1167
+ output: n3 = process.stdout,
1168
+ cancelMessage: _,
1169
+ errorMessage: C3,
1170
+ frames: M = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
1171
+ delay: O = unicode ? 80 : 120,
1172
+ signal: g,
1173
+ ...E
1174
+ } = {}) => {
1175
+ const u3 = isCI(), h2 = isAccessible(E.accessible);
1176
+ let x, I, p = false, l = false, r2 = "", v, w = performance.now();
1177
+ const y = getColumns(n3), F = E?.styleFrame ?? Z, S = (e) => {
1178
+ const s = e > 1 ? C3 ?? settings.messages.error : _ ?? settings.messages.cancel;
1179
+ l = e === 1, p && (m(s, e), l && typeof b == "function" && b());
1180
+ }, $ = () => S(2), a2 = () => S(1), H = () => {
1181
+ process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a2), process.on("SIGTERM", a2), process.on("exit", S), g && g.addEventListener("abort", a2);
1182
+ }, B = () => {
1183
+ process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a2), process.removeListener("SIGTERM", a2), process.removeListener("exit", S), g && g.removeEventListener("abort", a2);
1184
+ }, R2 = () => {
1185
+ if (v === void 0) return;
1186
+ u3 && n3.write(`
1187
+ `);
1188
+ const s = wrapAnsi(v, y, {
1189
+ hard: true,
1190
+ trim: false
1191
+ }).split(`
1192
+ `);
1193
+ s.length > 1 && n3.write(cursor2.up(s.length - 1)), n3.write(cursor2.to(0)), n3.write(erase2.down());
1194
+ }, L = (e) => e.replace(/\.+$/, ""), T = (e) => {
1195
+ const s = (performance.now() - e) / 1e3, i2 = Math.floor(s / 60), t2 = Math.floor(s % 60);
1196
+ return i2 > 0 ? `[${i2}m ${t2}s]` : `[${t2}s]`;
1197
+ }, N = E.withGuide ?? settings.withGuide, P = (e = "") => {
1198
+ if (p = true, l = false, r2 = L(e), w = performance.now(), H(), h2) {
1199
+ r2 !== "" && n3.write(`${r2}
1200
+ `), I = setInterval(() => {
1201
+ n3.write(r2 === "" ? `still working
1202
+ ` : `still working: ${r2}
1203
+ `);
1204
+ }, Y);
1205
+ return;
1206
+ }
1207
+ x = block({ output: n3 }), N && n3.write(`${styleText2("gray", S_BAR)}
1208
+ `);
1209
+ let s = 0, i2 = 0;
1210
+ I = setInterval(() => {
1211
+ if (u3 && r2 === v)
1212
+ return;
1213
+ R2(), v = r2;
1214
+ const t2 = F(M[s]);
1215
+ let o;
1216
+ if (u3)
1217
+ o = `${t2} ${r2}...`;
1218
+ else if (c3 === "timer")
1219
+ o = `${t2} ${r2} ${T(w)}`;
1220
+ else {
1221
+ const j = ".".repeat(Math.floor(i2)).slice(0, 3);
1222
+ o = `${t2} ${r2}${j}`;
1223
+ }
1224
+ const D = wrapAnsi(o, y, {
1225
+ hard: true,
1226
+ trim: false
1227
+ });
1228
+ n3.write(D), s = s + 1 < M.length ? s + 1 : 0, i2 = i2 < 4 ? i2 + 0.125 : 0;
1229
+ }, O);
1230
+ }, m = (e = "", s = 0, i2 = false) => {
1231
+ if (p) {
1232
+ if (p = false, l = s === 1, clearInterval(I), h2 || R2(), r2 = e ?? r2, !i2)
1233
+ if (h2) {
1234
+ const t2 = s === 1 ? _ ?? settings.messages.cancel : s === 2 ? C3 ?? settings.messages.error : "Done", o = r2 || t2;
1235
+ c3 === "timer" ? n3.write(`${o} ${T(w)}
1236
+ `) : n3.write(`${o}
1237
+ `);
1238
+ } else {
1239
+ const t2 = s === 0 ? styleText2("green", S_STEP_SUBMIT) : s === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
1240
+ c3 === "timer" ? n3.write(`${t2} ${r2} ${T(w)}
1241
+ `) : n3.write(`${t2} ${r2}
1242
+ `);
1243
+ }
1244
+ B(), x?.();
1245
+ }
1246
+ };
1247
+ return {
1248
+ start: P,
1249
+ stop: (e = "") => m(e, 0),
1250
+ message: (e = "") => {
1251
+ r2 = L(e ?? r2);
1252
+ },
1253
+ cancel: (e = "") => m(e, 1),
1254
+ error: (e = "") => m(e, 2),
1255
+ clear: () => m("", 0, true),
1256
+ get isCancelled() {
1257
+ return l;
1258
+ }
1259
+ };
1260
+ };
1261
+ var u2 = {
1262
+ light: unicodeOr("\u2500", "-"),
1263
+ heavy: unicodeOr("\u2501", "="),
1264
+ block: unicodeOr("\u2588", "#")
1265
+ };
1266
+ var SELECT_INSTRUCTIONS = [
1267
+ `${styleText2("dim", "\u2191/\u2193")} to navigate`,
1268
+ `${styleText2("dim", "Enter:")} confirm`
1269
+ ];
1270
+ var c2 = (t2, o) => t2.includes(`
1271
+ `) ? t2.split(`
1272
+ `).map((d) => o(d)).join(`
1273
+ `) : o(t2);
1274
+ var select = (t2) => {
1275
+ const o = (n3, m) => {
1276
+ if (n3 === void 0)
1277
+ return "";
1278
+ const s = n3.label ?? String(n3.value);
1279
+ switch (m) {
1280
+ case "disabled":
1281
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (i2) => styleText2("gray", i2))}${n3.hint ? ` ${styleText2("dim", `(${n3.hint ?? "disabled"})`)}` : ""}`;
1282
+ case "selected":
1283
+ return `${c2(s, (i2) => styleText2("dim", i2))}`;
1284
+ case "active":
1285
+ return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`;
1286
+ case "cancelled":
1287
+ return `${c2(s, (i2) => styleText2(["strikethrough", "dim"], i2))}`;
1288
+ default:
1289
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (i2) => styleText2("dim", i2))}`;
1290
+ }
1291
+ }, d = t2.showInstructions ?? true;
1292
+ return new n$1({
1293
+ options: t2.options,
1294
+ signal: t2.signal,
1295
+ input: t2.input,
1296
+ output: t2.output,
1297
+ initialValue: t2.initialValue,
1298
+ render() {
1299
+ const n3 = t2.withGuide ?? settings.withGuide, m = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i2 = wrapTextWithPrefix(
1300
+ t2.output,
1301
+ t2.message,
1302
+ s,
1303
+ m
1304
+ ), u3 = `${n3 ? `${styleText2("gray", S_BAR)}
1305
+ ` : ""}${i2}
1306
+ `;
1307
+ switch (this.state) {
1308
+ case "submit": {
1309
+ const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
1310
+ t2.output,
1311
+ o(this.options[this.cursor], "selected"),
1312
+ r2
1313
+ );
1314
+ return `${u3}${a2}`;
1315
+ }
1316
+ case "cancel": {
1317
+ const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
1318
+ t2.output,
1319
+ o(this.options[this.cursor], "cancelled"),
1320
+ r2
1321
+ );
1322
+ return `${u3}${a2}${n3 ? `
1323
+ ${styleText2("gray", S_BAR)}` : ""}`;
1324
+ }
1325
+ default: {
1326
+ const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u3.split(`
1327
+ `).length, p = d ? formatInstructionFooter(t2.output, SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], f = p.join(`
1328
+ `), b = p.length + 1;
1329
+ return `${u3}${r2}${limitOptions({
1330
+ output: t2.output,
1331
+ cursor: this.cursor,
1332
+ options: this.options,
1333
+ maxItems: t2.maxItems,
1334
+ columnPadding: r2.length,
1335
+ rowPadding: a2 + b,
1336
+ style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
1337
+ }).join(`
1338
+ ${r2}`)}
1339
+ ${f}
1340
+ `;
1341
+ }
1342
+ }
1343
+ }
1344
+ }).prompt();
1345
+ };
1346
+ var i = `${styleText2("gray", S_BAR)} `;
1347
+
1348
+ // bizzy-routing/launcher/bin/clack-ui.ts
1349
+ var Cancelled = class extends Error {
1350
+ };
1351
+ function showError(error) {
1352
+ if (error instanceof Cancelled) {
1353
+ cancel("Cancelled");
1354
+ return 130;
1355
+ }
1356
+ cancel(error instanceof Error ? error.message : String(error));
1357
+ return 1;
1358
+ }
1359
+ function answered(value) {
1360
+ if (isCancel(value)) throw new Cancelled("Cancelled");
1361
+ return value;
1362
+ }
1363
+ var mark = {
1364
+ ok: styleText3("green", "\u2713"),
1365
+ warn: styleText3("yellow", "\u25B2"),
1366
+ fail: styleText3("red", "\u2717")
1367
+ };
1368
+ function clackUi() {
1369
+ return {
1370
+ intro: (title) => intro(styleText3(["bgCyan", "black"], ` ${title} `)),
1371
+ outro: (message) => outro(message),
1372
+ note: (body, title) => note(body, title),
1373
+ message: (text) => log.message(text),
1374
+ warn: (message) => log.warn(message),
1375
+ step: async (message, work, done) => {
1376
+ const spin = spinner();
1377
+ spin.start(message);
1378
+ try {
1379
+ const result = await work();
1380
+ spin.stop(done(result));
1381
+ return result;
1382
+ } catch (error) {
1383
+ spin.error(message);
1384
+ throw error;
1385
+ }
1386
+ },
1387
+ select: async (message, choices) => answered(await select({ message, options: choices })),
1388
+ password: async (message, hint) => {
1389
+ log.message(styleText3("dim", hint));
1390
+ return answered(await password({ message }));
1391
+ },
1392
+ confirm: async (message) => answered(await confirm({ message, initialValue: false })),
1393
+ checks: (checks) => {
1394
+ const width = Math.max(...checks.map((check) => check.name.length));
1395
+ return checks.map(
1396
+ (check) => `${mark[check.status]} ${check.name.padEnd(width)} ${check.detail}${check.fix ? `
1397
+ ${" ".repeat(width)} ${styleText3("dim", `\u2192 ${check.fix}`)}` : ""}`
1398
+ ).join("\n");
1399
+ }
1400
+ };
1401
+ }
1402
+ export {
1403
+ clackUi,
1404
+ showError
1405
+ };