lean-agents 0.0.0-stage → 1.0.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 (148) hide show
  1. package/CHANGELOG.md +407 -0
  2. package/LICENSE +21 -0
  3. package/README.es.md +560 -0
  4. package/README.md +559 -2
  5. package/core/AGENTS.es.md +60 -0
  6. package/core/AGENTS.md +60 -0
  7. package/core/README.md +8 -0
  8. package/core/agents/debug.md +14 -0
  9. package/core/agents/explore.md +13 -0
  10. package/core/agents/planner.md +14 -0
  11. package/core/agents/research.md +13 -0
  12. package/core/agents/review.md +13 -0
  13. package/core/copilot-usage-tui.js +189 -0
  14. package/core/mcp.json +38 -0
  15. package/core/pins.json +39 -0
  16. package/core/tiers.json +4 -0
  17. package/node_modules/@clack/core/LICENSE +9 -0
  18. package/node_modules/@clack/core/README.md +22 -0
  19. package/node_modules/@clack/core/dist/index.d.mts +503 -0
  20. package/node_modules/@clack/core/dist/index.mjs +1003 -0
  21. package/node_modules/@clack/core/package.json +63 -0
  22. package/node_modules/@clack/prompts/LICENSE +9 -0
  23. package/node_modules/@clack/prompts/README.md +396 -0
  24. package/node_modules/@clack/prompts/dist/index.d.mts +949 -0
  25. package/node_modules/@clack/prompts/dist/index.mjs +1423 -0
  26. package/node_modules/@clack/prompts/package.json +67 -0
  27. package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  28. package/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  29. package/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  30. package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  31. package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  32. package/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  33. package/node_modules/fast-string-truncated-width/license +21 -0
  34. package/node_modules/fast-string-truncated-width/package.json +35 -0
  35. package/node_modules/fast-string-truncated-width/readme.md +59 -0
  36. package/node_modules/fast-string-width/dist/index.d.ts +4 -0
  37. package/node_modules/fast-string-width/dist/index.js +14 -0
  38. package/node_modules/fast-string-width/license +21 -0
  39. package/node_modules/fast-string-width/package.json +34 -0
  40. package/node_modules/fast-string-width/readme.md +42 -0
  41. package/node_modules/fast-wrap-ansi/LICENSE +23 -0
  42. package/node_modules/fast-wrap-ansi/README.md +26 -0
  43. package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  44. package/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  45. package/node_modules/fast-wrap-ansi/package.json +51 -0
  46. package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  47. package/node_modules/jsonc-parser/LICENSE.md +21 -0
  48. package/node_modules/jsonc-parser/README.md +364 -0
  49. package/node_modules/jsonc-parser/SECURITY.md +41 -0
  50. package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  51. package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  52. package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  53. package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  54. package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  55. package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  56. package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  57. package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  58. package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  59. package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  60. package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  61. package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  62. package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  63. package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  64. package/node_modules/jsonc-parser/package.json +37 -0
  65. package/node_modules/sisteransi/license +21 -0
  66. package/node_modules/sisteransi/package.json +34 -0
  67. package/node_modules/sisteransi/readme.md +113 -0
  68. package/node_modules/sisteransi/src/index.js +58 -0
  69. package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  70. package/package.json +30 -4
  71. package/profiles/README.md +10 -0
  72. package/profiles/anthropic-api/gsd-defaults.json +26 -0
  73. package/profiles/anthropic-api.json +18 -0
  74. package/profiles/antigravity.json +12 -0
  75. package/profiles/claude-subscription/gsd-defaults.json +26 -0
  76. package/profiles/claude-subscription.json +17 -0
  77. package/profiles/github-copilot/gsd-defaults.json +26 -0
  78. package/profiles/github-copilot.json +17 -0
  79. package/profiles/openai-api/gsd-defaults.json +26 -0
  80. package/profiles/openai-api.json +17 -0
  81. package/profiles/opencode-go/gsd-defaults.json +26 -0
  82. package/profiles/opencode-go.json +17 -0
  83. package/profiles/vertex-gemini/gsd-defaults.json +26 -0
  84. package/profiles/vertex-gemini.json +18 -0
  85. package/scripts/adhd-skill.mjs +12 -0
  86. package/scripts/behavior-diff.sh +47 -0
  87. package/scripts/bump-pins.mjs +115 -0
  88. package/scripts/check-private.sh +52 -0
  89. package/scripts/check-readme.mjs +131 -0
  90. package/scripts/ci-download.sh +20 -0
  91. package/scripts/ci-install-opencode-v2.sh +6 -0
  92. package/scripts/ci-latest-report.mjs +38 -0
  93. package/scripts/ci-timing.mjs +61 -0
  94. package/scripts/copilot-context-mode.mjs +33 -0
  95. package/scripts/labels.sh +56 -0
  96. package/scripts/lean.mjs +1319 -0
  97. package/scripts/lib/adapters/antigravity.mjs +83 -0
  98. package/scripts/lib/adapters/claude.mjs +127 -0
  99. package/scripts/lib/adapters/copilot-cli.mjs +82 -0
  100. package/scripts/lib/adapters/cursor.mjs +60 -0
  101. package/scripts/lib/adapters/opencode-v1.mjs +79 -0
  102. package/scripts/lib/adapters/opencode-v2.mjs +216 -0
  103. package/scripts/lib/adapters/vscode-copilot.mjs +56 -0
  104. package/scripts/lib/adhd.mjs +28 -0
  105. package/scripts/lib/adopt.mjs +619 -0
  106. package/scripts/lib/agent-lifecycle.mjs +280 -0
  107. package/scripts/lib/backup-stamp.mjs +25 -0
  108. package/scripts/lib/copilot-usage.mjs +49 -0
  109. package/scripts/lib/doctor.mjs +279 -0
  110. package/scripts/lib/feedback.mjs +48 -0
  111. package/scripts/lib/fsops.mjs +319 -0
  112. package/scripts/lib/gsd.mjs +42 -0
  113. package/scripts/lib/inventory.mjs +196 -0
  114. package/scripts/lib/lean-update.mjs +30 -0
  115. package/scripts/lib/logins.mjs +28 -0
  116. package/scripts/lib/migrate.mjs +407 -0
  117. package/scripts/lib/network.mjs +119 -0
  118. package/scripts/lib/node-runtime.mjs +85 -0
  119. package/scripts/lib/opencode-backup.mjs +204 -0
  120. package/scripts/lib/opencode-upgrade.mjs +441 -0
  121. package/scripts/lib/opencode1.mjs +203 -0
  122. package/scripts/lib/parallel.mjs +270 -0
  123. package/scripts/lib/pins-diff.mjs +33 -0
  124. package/scripts/lib/pins.mjs +52 -0
  125. package/scripts/lib/plugin-health.mjs +191 -0
  126. package/scripts/lib/prereqs.mjs +203 -0
  127. package/scripts/lib/project.mjs +38 -0
  128. package/scripts/lib/redact.mjs +30 -0
  129. package/scripts/lib/render.mjs +101 -0
  130. package/scripts/lib/shell-path.mjs +22 -0
  131. package/scripts/lib/summary-data.mjs +30 -0
  132. package/scripts/lib/summary-html.mjs +159 -0
  133. package/scripts/lib/system.mjs +269 -0
  134. package/scripts/lib/terminals.mjs +316 -0
  135. package/scripts/lib/ui.mjs +34 -0
  136. package/scripts/lib/unverified.mjs +49 -0
  137. package/scripts/lib/update-plan.mjs +60 -0
  138. package/scripts/lib/upgrade.mjs +231 -0
  139. package/scripts/lib/verify-commit.mjs +16 -0
  140. package/scripts/lib/verify-prompt.mjs +46 -0
  141. package/scripts/lib/verify-sha256.mjs +20 -0
  142. package/scripts/lint-workflows.mjs +25 -0
  143. package/scripts/models-refresh.mjs +58 -0
  144. package/scripts/parallel.mjs +59 -0
  145. package/scripts/pins-latest.mjs +66 -0
  146. package/scripts/release.mjs +71 -0
  147. package/scripts/verify-pins.mjs +36 -0
  148. package/scripts/version-watch.mjs +124 -0
@@ -0,0 +1,1423 @@
1
+ import { getColumns, getRows, AutocompletePrompt, settings, ConfirmPrompt, wrapTextWithPrefix, DatePrompt, runValidation, isCancel, MultiSelectPrompt, GroupMultiSelectPrompt, MultiLinePrompt, PasswordPrompt, block, SelectPrompt, SelectKeyPrompt, TextPrompt } from '@clack/core';
2
+ export { CANCEL_SYMBOL, isCancel, settings, updateSettings } from '@clack/core';
3
+ import { styleText, stripVTControlCharacters } from 'node:util';
4
+ import process$1 from 'node:process';
5
+ import { wrapAnsi } from 'fast-wrap-ansi';
6
+ import l from 'fast-string-width';
7
+ import { existsSync, lstatSync, readdirSync } from 'node:fs';
8
+ import { dirname, join } from 'node:path';
9
+ import { cursor, erase } from 'sisteransi';
10
+
11
+ function isUnicodeSupported() {
12
+ if (process$1.platform !== 'win32') {
13
+ return process$1.env.TERM !== 'linux'; // Linux console (kernel)
14
+ }
15
+
16
+ return Boolean(process$1.env.CI)
17
+ || Boolean(process$1.env.WT_SESSION) // Windows Terminal
18
+ || Boolean(process$1.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
19
+ || process$1.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
20
+ || process$1.env.TERM_PROGRAM === 'Terminus-Sublime'
21
+ || process$1.env.TERM_PROGRAM === 'vscode'
22
+ || process$1.env.TERM === 'xterm-256color'
23
+ || process$1.env.TERM === 'alacritty'
24
+ || process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
25
+ }
26
+
27
+ const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", isTTY = (o) => o.isTTY === true, unicodeOr = (o, e) => unicode ? o : e, S_STEP_ACTIVE = unicodeOr("\u25C6", "*"), S_STEP_CANCEL = unicodeOr("\u25A0", "x"), S_STEP_ERROR = unicodeOr("\u25B2", "x"), S_STEP_SUBMIT = unicodeOr("\u25C7", "o"), S_BAR_START = unicodeOr("\u250C", "T"), S_BAR = unicodeOr("\u2502", "|"), S_BAR_END = unicodeOr("\u2514", "\u2014"), S_BAR_START_RIGHT = unicodeOr("\u2510", "T"), S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014"), S_RADIO_ACTIVE = unicodeOr("\u25CF", ">"), S_RADIO_INACTIVE = unicodeOr("\u25CB", " "), S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]"), S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]"), S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]"), S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022"), S_BAR_H = unicodeOr("\u2500", "-"), S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+"), S_CONNECT_LEFT = unicodeOr("\u251C", "+"), S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+"), S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+"), S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+"), S_INFO = unicodeOr("\u25CF", "\u2022"), S_SUCCESS = unicodeOr("\u25C6", "*"), S_WARN = unicodeOr("\u25B2", "!"), S_ERROR = unicodeOr("\u25A0", "x"), symbol = (o) => {
28
+ switch (o) {
29
+ case "initial":
30
+ case "active":
31
+ return styleText("cyan", S_STEP_ACTIVE);
32
+ case "cancel":
33
+ return styleText("red", S_STEP_CANCEL);
34
+ case "error":
35
+ return styleText("yellow", S_STEP_ERROR);
36
+ case "submit":
37
+ return styleText("green", S_STEP_SUBMIT);
38
+ case "validating":
39
+ return styleText("dim", S_STEP_ACTIVE);
40
+ }
41
+ }, symbolBar = (o) => {
42
+ switch (o) {
43
+ case "initial":
44
+ case "active":
45
+ return styleText("cyan", S_BAR);
46
+ case "cancel":
47
+ return styleText("red", S_BAR);
48
+ case "error":
49
+ return styleText("yellow", S_BAR);
50
+ case "submit":
51
+ return styleText("green", S_BAR);
52
+ }
53
+ };
54
+ function formatInstructionFooter(o, e) {
55
+ const r = [`${e ? `${styleText("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
56
+ return e && r.push(styleText("cyan", S_BAR_END)), r;
57
+ }
58
+
59
+ const I = (l, e, w, p, b, C = false) => {
60
+ let r = e, O = 0;
61
+ if (C)
62
+ for (let i = p - 1; i >= w; i--) {
63
+ const m = l[i];
64
+ if (m && (r -= m.length), O++, r <= b) break;
65
+ }
66
+ else
67
+ for (let i = w; i < p; i++) {
68
+ const m = l[i];
69
+ if (m && (r -= m.length), O++, r <= b) break;
70
+ }
71
+ return { lineCount: r, removals: O };
72
+ };
73
+ const limitOptions = ({
74
+ cursor: l,
75
+ options: e,
76
+ style: w,
77
+ output: p = process.stdout,
78
+ maxItems: b = Number.POSITIVE_INFINITY,
79
+ columnPadding: C = 0,
80
+ rowPadding: r = 4
81
+ }) => {
82
+ const i = getColumns(p) - C, m = getRows(p), M = styleText("dim", "..."), v = Math.max(m - r, 0), a = Math.max(Math.min(b, v), 5);
83
+ let f = 0;
84
+ l >= a - 3 && (f = Math.max(
85
+ Math.min(l - a + 3, e.length - a),
86
+ 0
87
+ ));
88
+ let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
89
+ const W = Math.min(
90
+ f + a,
91
+ e.length
92
+ ), s = [];
93
+ let g = 0;
94
+ d && g++, c && g++;
95
+ const T = f + (d ? 1 : 0), y = W - (c ? 1 : 0);
96
+ for (let t = T; t < y; t++) {
97
+ const n = e[t], o = n ? w(n, t === l) : "", h = wrapAnsi(o, i, {
98
+ hard: true,
99
+ trim: false
100
+ }).split(`
101
+ `);
102
+ s.push(h), g += h.length;
103
+ }
104
+ if (g > v) {
105
+ let t = 0, n = 0, o = g;
106
+ const h = l - T;
107
+ let u = v;
108
+ const L = () => I(s, o, 0, h, u), E = () => I(
109
+ s,
110
+ o,
111
+ h + 1,
112
+ s.length,
113
+ u,
114
+ true
115
+ );
116
+ 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));
117
+ }
118
+ const x = [];
119
+ d && x.push(M);
120
+ for (const t of s)
121
+ for (const n of t)
122
+ x.push(n);
123
+ return c && x.push(M), x;
124
+ };
125
+
126
+ function E(t) {
127
+ return t.label ?? String(t.value ?? "");
128
+ }
129
+ function P(t, c) {
130
+ if (!t)
131
+ return true;
132
+ const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), r = String(c.value).toLowerCase(), o = t.toLowerCase();
133
+ return n.includes(o) || i.includes(o) || r.includes(o);
134
+ }
135
+ function j(t, c) {
136
+ const n = [];
137
+ for (const i of c)
138
+ t.includes(i.value) && n.push(i);
139
+ return n;
140
+ }
141
+ const autocomplete = (t) => new AutocompletePrompt({
142
+ options: t.options,
143
+ initialValue: t.initialValue ? [t.initialValue] : void 0,
144
+ initialUserInput: t.initialUserInput,
145
+ placeholder: t.placeholder,
146
+ completeOnTab: t.completeOnTab,
147
+ filter: t.filter ?? ((n, i) => P(n, i)),
148
+ signal: t.signal,
149
+ input: t.input,
150
+ output: t.output,
151
+ validate: t.validate,
152
+ render() {
153
+ const n = t.withGuide ?? settings.withGuide, i = n ? [`${styleText("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], r = this.userInput, o = this.options, m = t.placeholder, p = r === "" && m !== void 0, $ = (l, s) => {
154
+ const a = E(l), u = l.hint && l.value === this.focusedValue ? styleText("dim", ` (${l.hint})`) : "";
155
+ switch (s) {
156
+ case "active":
157
+ return `${styleText("green", S_RADIO_ACTIVE)} ${a}${u}`;
158
+ case "inactive":
159
+ return `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`;
160
+ case "disabled":
161
+ return `${styleText("gray", S_RADIO_INACTIVE)} ${styleText(["strikethrough", "gray"], a)}`;
162
+ }
163
+ };
164
+ switch (this.state) {
165
+ case "submit": {
166
+ const l = j(this.selectedValues, o), s = l.length > 0 ? ` ${styleText("dim", l.map(E).join(", "))}` : "", a = n ? styleText("gray", S_BAR) : "";
167
+ return `${i.join(`
168
+ `)}
169
+ ${a}${s}`;
170
+ }
171
+ case "cancel": {
172
+ const l = r ? ` ${styleText(["strikethrough", "dim"], r)}` : "", s = n ? styleText("gray", S_BAR) : "";
173
+ return `${i.join(`
174
+ `)}
175
+ ${s}${l}`;
176
+ }
177
+ default: {
178
+ const l = this.state === "error" ? "yellow" : "cyan", s = n ? `${styleText(l, S_BAR)} ` : "", a = n ? styleText(l, S_BAR_END) : "";
179
+ let u = "";
180
+ if (this.isNavigating || p) {
181
+ const d = p ? m : r;
182
+ u = d !== "" ? ` ${styleText("dim", d)}` : "";
183
+ } else
184
+ u = ` ${this.userInputWithCursor}`;
185
+ const V = this.filteredOptions.length !== o.length ? styleText(
186
+ "dim",
187
+ ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
188
+ ) : "", b = this.filteredOptions.length === 0 && r ? [`${s}${styleText("yellow", "No matches found")}`] : [], y = this.state === "error" ? [`${s}${styleText("yellow", this.error)}`] : [];
189
+ n && i.push(`${s.trimEnd()}`), i.push(
190
+ `${s}${styleText("dim", "Search:")}${u}${V}`,
191
+ ...b,
192
+ ...y
193
+ );
194
+ const S = [
195
+ `${styleText("dim", "\u2191/\u2193")} to select`,
196
+ ...t.completeOnTab ? [`${styleText("dim", "Tab:")} complete`] : [],
197
+ `${styleText("dim", "Enter:")} confirm`,
198
+ `${styleText("dim", "Type:")} to search`
199
+ ], g = [`${s}${S.join(" \u2022 ")}`, a], O = this.filteredOptions.length === 0 ? [] : limitOptions({
200
+ cursor: this.cursor,
201
+ options: this.filteredOptions,
202
+ columnPadding: n ? 3 : 0,
203
+ // for `| ` when guide is shown
204
+ rowPadding: i.length + g.length,
205
+ style: (d, f) => $(
206
+ d,
207
+ d.disabled ? "disabled" : f ? "active" : "inactive"
208
+ ),
209
+ maxItems: t.maxItems,
210
+ output: t.output
211
+ });
212
+ return [
213
+ ...i,
214
+ ...O.map((d) => `${s}${d}`),
215
+ ...g
216
+ ].join(`
217
+ `);
218
+ }
219
+ }
220
+ }
221
+ }).prompt(), autocompleteMultiselect = (t) => {
222
+ const c = (i, r, o, m) => {
223
+ const p = o.includes(i.value), $ = i.label ?? String(i.value ?? ""), l = i.hint && m !== void 0 && i.value === m ? styleText("dim", ` (${i.hint})`) : "", s = p ? styleText("green", S_CHECKBOX_SELECTED) : styleText("dim", S_CHECKBOX_INACTIVE);
224
+ return i.disabled ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${styleText(["strikethrough", "gray"], $)}` : r ? `${s} ${$}${l}` : `${s} ${styleText("dim", $)}`;
225
+ }, n = new AutocompletePrompt({
226
+ options: t.options,
227
+ multiple: true,
228
+ placeholder: t.placeholder,
229
+ filter: t.filter ?? ((i, r) => P(i, r)),
230
+ validate: () => {
231
+ if (t.required && n.selectedValues.length === 0)
232
+ return "Please select at least one item";
233
+ },
234
+ initialValue: t.initialValues,
235
+ signal: t.signal,
236
+ input: t.input,
237
+ output: t.output,
238
+ render() {
239
+ const i = t.withGuide ?? settings.withGuide, r = `${i ? `${styleText("gray", S_BAR)}
240
+ ` : ""}${symbol(this.state)} ${t.message}
241
+ `, o = this.userInput, m = t.placeholder, p = o === "" && m !== void 0, $ = this.isNavigating || p ? styleText("dim", p ? m : o) : this.userInputWithCursor, l = this.options, s = this.filteredOptions.length !== l.length ? styleText(
242
+ "dim",
243
+ ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
244
+ ) : "";
245
+ switch (this.state) {
246
+ case "submit":
247
+ return `${r}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(
248
+ "dim",
249
+ `${this.selectedValues.length} items selected`
250
+ )}`;
251
+ case "cancel":
252
+ return `${r}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(
253
+ ["strikethrough", "dim"],
254
+ o
255
+ )}`;
256
+ default: {
257
+ const a = this.state === "error" ? "yellow" : "cyan", u = i ? `${styleText(a, S_BAR)} ` : "", V = i ? styleText(a, S_BAR_END) : "", b = [
258
+ `${styleText("dim", "\u2191/\u2193")} to navigate`,
259
+ `${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
260
+ `${styleText("dim", "Enter:")} confirm`,
261
+ `${styleText("dim", "Type:")} to search`
262
+ ], y = this.filteredOptions.length === 0 && o ? [`${u}${styleText("yellow", "No matches found")}`] : [], S = this.state === "error" ? [`${u}${styleText("yellow", this.error)}`] : [], g = [
263
+ ...`${r}${i ? styleText(a, S_BAR) : ""}`.split(`
264
+ `),
265
+ `${u}${styleText("dim", "Search:")} ${$}${s}`,
266
+ ...y,
267
+ ...S
268
+ ], O = [`${u}${b.join(" \u2022 ")}`, V], d = limitOptions({
269
+ cursor: this.cursor,
270
+ options: this.filteredOptions,
271
+ style: (f, L) => c(f, L, this.selectedValues, this.focusedValue),
272
+ maxItems: t.maxItems,
273
+ output: t.output,
274
+ rowPadding: g.length + O.length
275
+ });
276
+ return [
277
+ ...g,
278
+ ...d.map((f) => `${u}${f}`),
279
+ ...O
280
+ ].join(`
281
+ `);
282
+ }
283
+ }
284
+ }
285
+ });
286
+ return n.prompt();
287
+ };
288
+
289
+ const K = [
290
+ S_CORNER_TOP_LEFT,
291
+ S_CORNER_TOP_RIGHT,
292
+ S_CORNER_BOTTOM_LEFT,
293
+ S_CORNER_BOTTOM_RIGHT
294
+ ], Q = [S_BAR_START, S_BAR_START_RIGHT, S_BAR_END, S_BAR_END_RIGHT];
295
+ function A$1(n, e, t, o) {
296
+ let i = t, f = t;
297
+ return o === "center" ? i = Math.floor((e - n) / 2) : o === "right" && (i = e - n - t), f = e - i - n, [i, f];
298
+ }
299
+ const U = (n) => n;
300
+ const box = (n = "", e = "", t) => {
301
+ const o = t?.output ?? process.stdout, i = getColumns(o), R = 1 * 2, u = t?.titlePadding ?? 1, h = t?.contentPadding ?? 2, w = t?.width === void 0 || t.width === "auto" ? 1 : Math.min(1, t.width), m = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)} ` : "", b = t?.formatBorder ?? U, a = (t?.rounded ? K : Q).map(b), _ = b(S_BAR_H), p = b(S_BAR), x = l(m), B = l(e), y = i - x;
302
+ let r = Math.floor(i * w) - x;
303
+ if (t?.width === "auto") {
304
+ const c = n.split(`
305
+ `);
306
+ let s = B + u * 2;
307
+ for (const G of c) {
308
+ const P = l(G) + h * 2;
309
+ P > s && (s = P);
310
+ }
311
+ const g = s + R;
312
+ g < r && (r = g);
313
+ }
314
+ r % 2 !== 0 && (r < y ? r++ : r--);
315
+ const d = r - R, T = d - u * 2, S = B > T ? `${e.slice(0, T - 3)}...` : e, [O, W] = A$1(
316
+ l(S),
317
+ d,
318
+ u,
319
+ t?.titleAlign
320
+ ), L = wrapAnsi(n, d - h * 2, {
321
+ hard: true,
322
+ trim: false
323
+ });
324
+ o.write(
325
+ `${m}${a[0]}${_.repeat(O)}${S}${_.repeat(W)}${a[1]}
326
+ `
327
+ );
328
+ const E = L.split(`
329
+ `);
330
+ for (const c of E) {
331
+ const [s, g] = A$1(
332
+ l(c),
333
+ d,
334
+ h,
335
+ t?.contentAlign
336
+ );
337
+ o.write(
338
+ `${m}${p}${" ".repeat(s)}${c}${" ".repeat(g)}${p}
339
+ `
340
+ );
341
+ }
342
+ o.write(`${m}${a[2]}${_.repeat(d)}${a[3]}
343
+ `);
344
+ };
345
+
346
+ const confirm = (e) => {
347
+ const a = e.active ?? "Yes", o = e.inactive ?? "No";
348
+ return new ConfirmPrompt({
349
+ active: a,
350
+ inactive: o,
351
+ signal: e.signal,
352
+ input: e.input,
353
+ output: e.output,
354
+ initialValue: e.initialValue ?? true,
355
+ render() {
356
+ const i = e.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = i ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
357
+ e.output,
358
+ e.message,
359
+ l,
360
+ u
361
+ ), s = `${i ? `${styleText("gray", S_BAR)}
362
+ ` : ""}${f}
363
+ `, c = this.value ? a : o;
364
+ switch (this.state) {
365
+ case "submit": {
366
+ const r = i ? `${styleText("gray", S_BAR)} ` : "";
367
+ return `${s}${r}${styleText("dim", c)}`;
368
+ }
369
+ case "cancel": {
370
+ const r = i ? `${styleText("gray", S_BAR)} ` : "";
371
+ return `${s}${r}${styleText(["strikethrough", "dim"], c)}${i ? `
372
+ ${styleText("gray", S_BAR)}` : ""}`;
373
+ }
374
+ default: {
375
+ const r = i ? `${styleText("cyan", S_BAR)} ` : "", g = i ? styleText("cyan", S_BAR_END) : "";
376
+ return `${s}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${e.vertical ? i ? `
377
+ ${styleText("cyan", S_BAR)} ` : `
378
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", o)}` : `${styleText("green", S_RADIO_ACTIVE)} ${o}`}
379
+ ${g}
380
+ `;
381
+ }
382
+ }
383
+ }
384
+ }).prompt();
385
+ };
386
+
387
+ const date = (e) => {
388
+ const r = e.validate;
389
+ return new DatePrompt({
390
+ ...e,
391
+ validate(t) {
392
+ if (t === void 0)
393
+ return e.defaultValue !== void 0 ? void 0 : r ? runValidation(r, t) : settings.date.messages.required;
394
+ const o = (i) => i.toISOString().slice(0, 10);
395
+ if (e.minDate && o(t) < o(e.minDate))
396
+ return settings.date.messages.afterMin(e.minDate);
397
+ if (e.maxDate && o(t) > o(e.maxDate))
398
+ return settings.date.messages.beforeMax(e.maxDate);
399
+ if (r) return runValidation(r, t);
400
+ },
401
+ render() {
402
+ const t = (e?.withGuide ?? settings.withGuide) !== false, i = `${`${t ? `${styleText("gray", S_BAR)}
403
+ ` : ""}${symbol(this.state)} `}${e.message}
404
+ `, l = this.state !== "initial" ? this.state : "active", d = b(this, l), c = this.value instanceof Date ? this.formattedValue : "";
405
+ switch (this.state) {
406
+ case "error": {
407
+ const a = this.error ? ` ${styleText("yellow", this.error)}` : "", s = t ? `${styleText("yellow", S_BAR)} ` : "", f = t ? styleText("yellow", S_BAR_END) : "";
408
+ return `${i.trim()}
409
+ ${s}${d}
410
+ ${f}${a}
411
+ `;
412
+ }
413
+ case "submit": {
414
+ const a = c ? ` ${styleText("dim", c)}` : "", s = t ? styleText("gray", S_BAR) : "";
415
+ return `${i}${s}${a}`;
416
+ }
417
+ case "cancel": {
418
+ const a = c ? ` ${styleText(["strikethrough", "dim"], c)}` : "", s = t ? styleText("gray", S_BAR) : "";
419
+ return `${i}${s}${a}${c.trim() ? `
420
+ ${s}` : ""}`;
421
+ }
422
+ default: {
423
+ const a = t ? `${styleText("cyan", S_BAR)} ` : "", s = t ? styleText("cyan", S_BAR_END) : "", f = t ? `${styleText("cyan", S_BAR)} ` : "", g = this.inlineError ? `
424
+ ${f}${styleText("yellow", this.inlineError)}` : "";
425
+ return `${i}${a}${d}${g}
426
+ ${s}
427
+ `;
428
+ }
429
+ }
430
+ }
431
+ }).prompt();
432
+ };
433
+ function b(e, r) {
434
+ const t = e.segmentValues, o = e.segmentCursor;
435
+ if (r === "submit" || r === "cancel")
436
+ return e.formattedValue;
437
+ const i = styleText("gray", e.separator);
438
+ return e.segments.map((l, d) => {
439
+ const c = d === o.segmentIndex && !["submit", "cancel"].includes(r), a = p[l.type];
440
+ return x(t[l.type], { isActive: c, label: a });
441
+ }).join(i);
442
+ }
443
+ function x(e, r) {
444
+ const t = !e || e.replace(/_/g, "") === "";
445
+ return r.isActive ? styleText("inverse", t ? r.label : e.replace(/_/g, " ")) : t ? styleText("dim", r.label) : e.replace(/_/g, styleText("dim", " "));
446
+ }
447
+ const p = {
448
+ year: "yyyy",
449
+ month: "mm",
450
+ day: "dd"
451
+ };
452
+
453
+ const group = async (o, r) => {
454
+ const t = {}, p = Object.keys(o);
455
+ for (const e of p) {
456
+ const i = o[e], n = await i({ results: t })?.catch((a) => {
457
+ throw a;
458
+ });
459
+ if (typeof r?.onCancel == "function" && isCancel(n)) {
460
+ t[e] = "canceled", r.onCancel({ results: t });
461
+ continue;
462
+ }
463
+ t[e] = n;
464
+ }
465
+ return t;
466
+ };
467
+
468
+ const MULTISELECT_INSTRUCTIONS = [
469
+ `${styleText("dim", "\u2191/\u2193")} to navigate`,
470
+ `${styleText("dim", "Space:")} select`,
471
+ `${styleText("dim", "Enter:")} confirm`
472
+ ];
473
+ const m = (i, u) => i.split(`
474
+ `).map((d) => u(d)).join(`
475
+ `);
476
+ const multiselect = (i) => {
477
+ const u = (t, a) => {
478
+ const r = t.label ?? String(t.value);
479
+ return a === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${m(r, (o) => styleText(["strikethrough", "gray"], o))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${m(r, (o) => styleText("dim", o))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "cancelled" ? `${m(r, (o) => styleText(["strikethrough", "dim"], o))}` : a === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "submitted" ? `${m(r, (o) => styleText("dim", o))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${m(r, (o) => styleText("dim", o))}`;
480
+ }, d = i.required ?? true, x = i.showInstructions ?? true;
481
+ return new MultiSelectPrompt({
482
+ options: i.options,
483
+ signal: i.signal,
484
+ input: i.input,
485
+ output: i.output,
486
+ initialValues: i.initialValues,
487
+ required: d,
488
+ cursorAt: i.cursorAt,
489
+ validate(t) {
490
+ if (d && (t === void 0 || t.length === 0))
491
+ return `Please select at least one option.
492
+ ${styleText(
493
+ "reset",
494
+ styleText(
495
+ "dim",
496
+ `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText(
497
+ "gray",
498
+ styleText("bgWhite", styleText("inverse", " enter "))
499
+ )} to submit`
500
+ )
501
+ )}`;
502
+ },
503
+ render() {
504
+ const t = i.withGuide ?? settings.withGuide, a = wrapTextWithPrefix(
505
+ i.output,
506
+ i.message,
507
+ t ? `${symbolBar(this.state)} ` : "",
508
+ `${symbol(this.state)} `
509
+ ), r = `${t ? `${styleText("gray", S_BAR)}
510
+ ` : ""}${a}
511
+ `, o = this.value ?? [], g = (n, l) => {
512
+ if (n.disabled)
513
+ return u(n, "disabled");
514
+ const s = o.includes(n.value);
515
+ return l && s ? u(n, "active-selected") : s ? u(n, "selected") : u(n, l ? "active" : "inactive");
516
+ };
517
+ switch (this.state) {
518
+ case "submit": {
519
+ const n = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = wrapTextWithPrefix(
520
+ i.output,
521
+ n,
522
+ t ? `${styleText("gray", S_BAR)} ` : ""
523
+ );
524
+ return `${r}${l}`;
525
+ }
526
+ case "cancel": {
527
+ const n = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "cancelled")).join(styleText("dim", ", "));
528
+ if (n.trim() === "")
529
+ return `${r}${styleText("gray", S_BAR)}`;
530
+ const l = wrapTextWithPrefix(
531
+ i.output,
532
+ n,
533
+ t ? `${styleText("gray", S_BAR)} ` : ""
534
+ );
535
+ return `${r}${l}${t ? `
536
+ ${styleText("gray", S_BAR)}` : ""}`;
537
+ }
538
+ case "error": {
539
+ const n = t ? `${styleText("yellow", S_BAR)} ` : "", l = this.error.split(`
540
+ `).map(
541
+ ($, v) => v === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", $)}` : ` ${$}`
542
+ ).join(`
543
+ `), s = r.split(`
544
+ `).length, h = l.split(`
545
+ `).length + 1;
546
+ return `${r}${n}${limitOptions({
547
+ output: i.output,
548
+ options: this.options,
549
+ cursor: this.cursor,
550
+ maxItems: i.maxItems,
551
+ columnPadding: n.length,
552
+ rowPadding: s + h,
553
+ style: g
554
+ }).join(`
555
+ ${n}`)}
556
+ ${l}
557
+ `;
558
+ }
559
+ default: {
560
+ const n = t ? `${styleText("cyan", S_BAR)} ` : "", l = r.split(`
561
+ `).length, s = x ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t) : t ? [styleText("cyan", S_BAR_END)] : [], h = s.join(`
562
+ `), $ = s.length + 1;
563
+ return `${r}${n}${limitOptions({
564
+ output: i.output,
565
+ options: this.options,
566
+ cursor: this.cursor,
567
+ maxItems: i.maxItems,
568
+ columnPadding: n.length,
569
+ rowPadding: l + $,
570
+ style: g
571
+ }).join(`
572
+ ${n}`)}
573
+ ${h}
574
+ `;
575
+ }
576
+ }
577
+ }
578
+ }).prompt();
579
+ };
580
+
581
+ const groupMultiselect = (o) => {
582
+ const { selectableGroups: f = true, groupSpacing: x = 0 } = o, d = (n, l, p = []) => {
583
+ 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;
584
+ let r = "", c = "";
585
+ t && (f ? (r = u ? `${S_BAR_END} ` : `${S_BAR} `, c = u ? " " : `${S_BAR} `) : r = " ");
586
+ let i = "";
587
+ if (x > 0 && !t && (i = `
588
+ `.repeat(x)), l === "active")
589
+ return wrapTextWithPrefix(
590
+ o.output,
591
+ `${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
592
+ `${i}${styleText("dim", r)} `,
593
+ `${i}${styleText("dim", r)}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
594
+ `${i}${styleText("dim", c)} `
595
+ );
596
+ if (l === "group-active")
597
+ return wrapTextWithPrefix(
598
+ o.output,
599
+ a,
600
+ `${i}${r} `,
601
+ `${i}${r}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
602
+ `${i}${c} `,
603
+ (m) => styleText("dim", m)
604
+ );
605
+ if (l === "group-active-selected")
606
+ return wrapTextWithPrefix(
607
+ o.output,
608
+ a,
609
+ `${i}${r} `,
610
+ `${i}${r}${styleText("green", S_CHECKBOX_SELECTED)} `,
611
+ `${i}${c} `,
612
+ (m) => styleText("dim", m)
613
+ );
614
+ if (l === "selected") {
615
+ const m = t || f ? styleText("green", S_CHECKBOX_SELECTED) : "";
616
+ return wrapTextWithPrefix(
617
+ o.output,
618
+ `${a}${n.hint ? ` (${n.hint})` : ""}`,
619
+ `${i}${styleText("dim", r)} `,
620
+ `${i}${styleText("dim", r)}${m} `,
621
+ `${i}${styleText("dim", c)} `,
622
+ (I) => styleText("dim", I)
623
+ );
624
+ }
625
+ if (l === "cancelled")
626
+ return `${styleText(["strikethrough", "dim"], a)}`;
627
+ if (l === "active-selected")
628
+ return wrapTextWithPrefix(
629
+ o.output,
630
+ `${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
631
+ `${i}${styleText("dim", r)} `,
632
+ `${i}${styleText("dim", r)}${styleText("green", S_CHECKBOX_SELECTED)} `,
633
+ `${i}${styleText("dim", c)} `
634
+ );
635
+ if (l === "submitted")
636
+ return `${styleText("dim", a)}`;
637
+ const h = t || f ? styleText("dim", S_CHECKBOX_INACTIVE) : "";
638
+ return wrapTextWithPrefix(
639
+ o.output,
640
+ a,
641
+ `${i}${styleText("dim", r)} `,
642
+ `${i}${styleText("dim", r)}${h} `,
643
+ `${i}${styleText("dim", c)} `,
644
+ (m) => styleText("dim", m)
645
+ );
646
+ }, y = o.required ?? true, S = o.showInstructions ?? true;
647
+ return new GroupMultiSelectPrompt({
648
+ options: o.options,
649
+ signal: o.signal,
650
+ input: o.input,
651
+ output: o.output,
652
+ initialValues: o.initialValues,
653
+ required: y,
654
+ cursorAt: o.cursorAt,
655
+ selectableGroups: f,
656
+ validate(n) {
657
+ if (y && (n === void 0 || n.length === 0))
658
+ return `Please select at least one option.
659
+ ${styleText(
660
+ "reset",
661
+ styleText(
662
+ "dim",
663
+ `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText(
664
+ "gray",
665
+ styleText(["bgWhite", "inverse"], " enter ")
666
+ )} to submit`
667
+ )
668
+ )}`;
669
+ },
670
+ render() {
671
+ const n = o.withGuide ?? settings.withGuide, l = `${n ? `${styleText("gray", S_BAR)}
672
+ ` : ""}${symbol(this.state)} ${o.message}
673
+ `, p = this.value ?? [], a = (t, s) => {
674
+ const u = this.options, r = p.includes(t.value) || t.group === true && this.isGroupSelected(`${t.value}`);
675
+ 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);
676
+ };
677
+ switch (this.state) {
678
+ case "submit": {
679
+ const t = this.options.filter(({ value: u }) => p.includes(u)).map((u) => d(u, "submitted")), s = t.length === 0 ? "" : ` ${t.join(styleText("dim", ", "))}`;
680
+ return `${l}${n ? styleText("gray", S_BAR) : ""}${s}`;
681
+ }
682
+ case "cancel": {
683
+ const t = this.options.filter(({ value: s }) => p.includes(s)).map((s) => d(s, "cancelled")).join(styleText("dim", ", "));
684
+ return `${l}${n ? `${styleText("gray", S_BAR)} ` : ""}${t.trim() ? `${t}${n ? `
685
+ ${styleText("gray", S_BAR)}` : ""}` : ""}`;
686
+ }
687
+ case "error": {
688
+ const t = n ? `${styleText("yellow", S_BAR)} ` : "", s = this.error.split(`
689
+ `).map(
690
+ (i, h) => h === 0 ? `${n ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", i)}` : ` ${i}`
691
+ ).join(`
692
+ `), u = l.split(`
693
+ `).length, r = s.split(`
694
+ `).length + 1, c = limitOptions({
695
+ output: o.output,
696
+ options: this.options,
697
+ cursor: this.cursor,
698
+ maxItems: o.maxItems,
699
+ columnPadding: t.length,
700
+ rowPadding: u + r,
701
+ style: a
702
+ }).join(`
703
+ ${t}`);
704
+ return `${l}${t}${c}
705
+ ${s}
706
+ `;
707
+ }
708
+ default: {
709
+ const t = n ? `${styleText("cyan", S_BAR)} ` : "", s = l.split(`
710
+ `).length, u = S ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], r = u.join(`
711
+ `), c = u.length + 1, i = limitOptions({
712
+ output: o.output,
713
+ options: this.options,
714
+ cursor: this.cursor,
715
+ maxItems: o.maxItems,
716
+ columnPadding: t.length,
717
+ rowPadding: s + c,
718
+ style: a
719
+ }).join(`
720
+ ${t}`);
721
+ return `${l}${t}${i}
722
+ ${r}
723
+ `;
724
+ }
725
+ }
726
+ }
727
+ }).prompt();
728
+ };
729
+
730
+ const log = {
731
+ message: (s = [], {
732
+ symbol: e = styleText("gray", S_BAR),
733
+ secondarySymbol: r = styleText("gray", S_BAR),
734
+ output: m = process.stdout,
735
+ spacing: l = 1,
736
+ withGuide: c
737
+ } = {}) => {
738
+ const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
739
+ for (let i = 0; i < l; i++)
740
+ t.push(f);
741
+ const g = Array.isArray(s) ? s : s.split(`
742
+ `);
743
+ if (g.length > 0) {
744
+ const [i, ...y] = g;
745
+ i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
746
+ for (const p of y)
747
+ p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
748
+ }
749
+ m.write(`${t.join(`
750
+ `)}
751
+ `);
752
+ },
753
+ info: (s, e) => {
754
+ log.message(s, { ...e, symbol: styleText("blue", S_INFO) });
755
+ },
756
+ success: (s, e) => {
757
+ log.message(s, { ...e, symbol: styleText("green", S_SUCCESS) });
758
+ },
759
+ step: (s, e) => {
760
+ log.message(s, { ...e, symbol: styleText("green", S_STEP_SUBMIT) });
761
+ },
762
+ warn: (s, e) => {
763
+ log.message(s, { ...e, symbol: styleText("yellow", S_WARN) });
764
+ },
765
+ /** alias for `log.warn()`. */
766
+ warning: (s, e) => {
767
+ log.warn(s, e);
768
+ },
769
+ error: (s, e) => {
770
+ log.message(s, { ...e, symbol: styleText("red", S_ERROR) });
771
+ }
772
+ };
773
+
774
+ const cancel = (o = "", t) => {
775
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_END)} ` : "";
776
+ i.write(`${e}${styleText("red", o)}
777
+
778
+ `);
779
+ }, intro = (o = "", t) => {
780
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
781
+ i.write(`${e}${o}
782
+ `);
783
+ }, outro = (o = "", t) => {
784
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
785
+ ${styleText("gray", S_BAR_END)} ` : "";
786
+ i.write(`${e}${o}
787
+
788
+ `);
789
+ };
790
+
791
+ const multiline = (e) => new MultiLinePrompt({
792
+ validate: e.validate,
793
+ placeholder: e.placeholder,
794
+ defaultValue: e.defaultValue,
795
+ initialValue: e.initialValue,
796
+ showSubmit: e.showSubmit,
797
+ output: e.output,
798
+ signal: e.signal,
799
+ input: e.input,
800
+ render() {
801
+ const i = e?.withGuide ?? settings.withGuide, o = `${`${i ? `${styleText("gray", S_BAR)}
802
+ ` : ""}${symbol(this.state)} `}${e.message}
803
+ `, h = e.placeholder && e.placeholder.length > 0 ? (
804
+ // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
805
+ styleText("inverse", e.placeholder[0]) + styleText("dim", e.placeholder.slice(1))
806
+ ) : styleText(["inverse", "hidden"], "_"), a = this.userInput ? this.userInputWithCursor : h, l = this.value ?? "", d = e.showSubmit ? `
807
+ ${styleText(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
808
+ switch (this.state) {
809
+ case "error": {
810
+ const n = `${styleText("yellow", S_BAR)} `, r = i ? wrapTextWithPrefix(e.output, a, n, void 0) : a, u = styleText("yellow", S_BAR_END);
811
+ return `${o}${r}
812
+ ${u} ${styleText("yellow", this.error)}${d}
813
+ `;
814
+ }
815
+ case "submit": {
816
+ const n = `${styleText("gray", S_BAR)} `, r = i ? wrapTextWithPrefix(
817
+ e.output,
818
+ l,
819
+ n,
820
+ void 0,
821
+ void 0,
822
+ (u) => styleText("dim", u)
823
+ ) : l ? styleText("dim", l) : "";
824
+ return `${o}${r}`;
825
+ }
826
+ case "cancel": {
827
+ const n = `${styleText("gray", S_BAR)} `, r = i ? wrapTextWithPrefix(
828
+ e.output,
829
+ l,
830
+ n,
831
+ void 0,
832
+ void 0,
833
+ (u) => styleText(["strikethrough", "dim"], u)
834
+ ) : l ? styleText(["strikethrough", "dim"], l) : "";
835
+ return `${o}${r}`;
836
+ }
837
+ default: {
838
+ const n = i ? `${styleText("cyan", S_BAR)} ` : "", r = i ? styleText("cyan", S_BAR_END) : "", u = i ? wrapTextWithPrefix(e.output, a, n) : a;
839
+ return `${o}${u}
840
+ ${r}${d}
841
+ `;
842
+ }
843
+ }
844
+ }
845
+ }).prompt();
846
+
847
+ const W$1 = (o) => o, C = (o, e, s) => {
848
+ const a = {
849
+ hard: true,
850
+ trim: false
851
+ }, i = wrapAnsi(o, e, a).split(`
852
+ `), c = i.reduce((n, t) => Math.max(l(t), n), 0), u = i.map(s).reduce((n, t) => Math.max(l(t), n), 0), g = e - (u - c);
853
+ return wrapAnsi(o, g, a);
854
+ };
855
+ const note = (o = "", e = "", s) => {
856
+ const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W$1, g = ["", ...C(o, getColumns(a) - 6, c).split(`
857
+ `).map(c), ""], n = l(e), t = Math.max(
858
+ g.reduce((m, F) => {
859
+ const O = l(F);
860
+ return O > m ? O : m;
861
+ }, 0),
862
+ n
863
+ ) + 2, h = g.map(
864
+ (m) => `${styleText("gray", S_BAR)} ${m}${" ".repeat(t - l(m))}${styleText("gray", S_BAR)}`
865
+ ).join(`
866
+ `), T = i ? `${styleText("gray", S_BAR)}
867
+ ` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
868
+ a.write(
869
+ `${T}${styleText("green", S_STEP_SUBMIT)} ${styleText("reset", e)} ${styleText(
870
+ "gray",
871
+ S_BAR_H.repeat(Math.max(t - n - 1, 1)) + S_CORNER_TOP_RIGHT
872
+ )}
873
+ ${h}
874
+ ${styleText("gray", l$1 + S_BAR_H.repeat(t + 2) + S_CORNER_BOTTOM_RIGHT)}
875
+ `
876
+ );
877
+ };
878
+
879
+ const password = (e) => new PasswordPrompt({
880
+ validate: e.validate,
881
+ mask: e.mask ?? S_PASSWORD_MASK,
882
+ signal: e.signal,
883
+ input: e.input,
884
+ output: e.output,
885
+ render() {
886
+ const r = e.withGuide ?? settings.withGuide, o = `${r ? `${styleText("gray", S_BAR)}
887
+ ` : ""}${symbol(this.state)} ${e.message}
888
+ `, m = this.userInputWithCursor, i = this.masked;
889
+ switch (this.state) {
890
+ case "error": {
891
+ const s = r ? `${styleText("yellow", S_BAR)} ` : "", n = r ? `${styleText("yellow", S_BAR_END)} ` : "", d = i ?? "";
892
+ return e.clearOnError && this.clear(), `${o.trim()}
893
+ ${s}${d}
894
+ ${n}${styleText("yellow", this.error)}
895
+ `;
896
+ }
897
+ case "submit": {
898
+ const s = r ? `${styleText("gray", S_BAR)} ` : "", n = i ? styleText("dim", i) : "";
899
+ return `${o}${s}${n}`;
900
+ }
901
+ case "cancel": {
902
+ const s = r ? `${styleText("gray", S_BAR)} ` : "", n = i ? styleText(["strikethrough", "dim"], i) : "";
903
+ return `${o}${s}${n}${i && r ? `
904
+ ${styleText("gray", S_BAR)}` : ""}`;
905
+ }
906
+ default: {
907
+ const s = r ? `${styleText("cyan", S_BAR)} ` : "", n = r ? styleText("cyan", S_BAR_END) : "";
908
+ return `${o}${s}${m}
909
+ ${n}
910
+ `;
911
+ }
912
+ }
913
+ }
914
+ }).prompt();
915
+
916
+ const path = (e) => {
917
+ const a = e.validate;
918
+ return autocomplete({
919
+ ...e,
920
+ initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
921
+ maxItems: 5,
922
+ completeOnTab: true,
923
+ validate(t) {
924
+ if (!Array.isArray(t)) {
925
+ if (!t)
926
+ return "Please select a path";
927
+ if (a)
928
+ return runValidation(a, t);
929
+ }
930
+ },
931
+ options() {
932
+ const t = this.userInput;
933
+ if (t === "")
934
+ return [];
935
+ try {
936
+ let i;
937
+ existsSync(t) ? lstatSync(t).isDirectory() && (!e.directory || t.endsWith("/")) ? i = t : i = dirname(t) : i = dirname(t);
938
+ const c = t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
939
+ return readdirSync(i).map((r) => {
940
+ const n = join(i, r), m = lstatSync(n);
941
+ return {
942
+ name: r,
943
+ path: n,
944
+ isDirectory: m.isDirectory()
945
+ };
946
+ }).filter(
947
+ ({ path: r, isDirectory: n }) => r.startsWith(c) && (n || !e.directory)
948
+ ).map((r) => ({
949
+ value: r.path
950
+ }));
951
+ } catch {
952
+ return [];
953
+ }
954
+ }
955
+ });
956
+ };
957
+
958
+ const W = (l) => styleText("magenta", l);
959
+ const spinner = ({
960
+ indicator: l = "dots",
961
+ onCancel: h,
962
+ output: n = process.stdout,
963
+ cancelMessage: G,
964
+ errorMessage: O,
965
+ frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
966
+ delay: F = unicode ? 80 : 120,
967
+ signal: m,
968
+ ...I
969
+ } = {}) => {
970
+ const u = isCI();
971
+ let M, T, d = false, S = false, s = "", p, w = performance.now();
972
+ const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
973
+ const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
974
+ S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
975
+ }, f = () => g(2), i = () => g(1), A = () => {
976
+ 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);
977
+ }, H = () => {
978
+ 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);
979
+ }, y = () => {
980
+ if (p === void 0) return;
981
+ u && n.write(`
982
+ `);
983
+ const r = wrapAnsi(p, x, {
984
+ hard: true,
985
+ trim: false
986
+ }).split(`
987
+ `);
988
+ r.length > 1 && n.write(cursor.up(r.length - 1)), n.write(cursor.to(0)), n.write(erase.down());
989
+ }, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
990
+ const r = (performance.now() - e) / 1e3, t = Math.floor(r / 60), o = Math.floor(r % 60);
991
+ return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
992
+ }, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
993
+ d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText("gray", S_BAR)}
994
+ `);
995
+ let r = 0, t = 0;
996
+ A(), T = setInterval(() => {
997
+ if (u && s === p)
998
+ return;
999
+ y(), p = s;
1000
+ const o = k(E[r]);
1001
+ let v;
1002
+ if (u)
1003
+ v = `${o} ${s}...`;
1004
+ else if (l === "timer")
1005
+ v = `${o} ${s} ${_(w)}`;
1006
+ else {
1007
+ const B = ".".repeat(Math.floor(t)).slice(0, 3);
1008
+ v = `${o} ${s}${B}`;
1009
+ }
1010
+ const j = wrapAnsi(v, x, {
1011
+ hard: true,
1012
+ trim: false
1013
+ });
1014
+ n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + 0.125 : 0;
1015
+ }, F);
1016
+ }, a = (e = "", r = 0, t = false) => {
1017
+ if (!d) return;
1018
+ d = false, clearInterval(T), y();
1019
+ const o = r === 0 ? styleText("green", S_STEP_SUBMIT) : r === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
1020
+ s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
1021
+ `) : n.write(`${o} ${s}
1022
+ `)), H(), M();
1023
+ };
1024
+ return {
1025
+ start: P,
1026
+ stop: (e = "") => a(e, 0),
1027
+ message: (e = "") => {
1028
+ s = C(e ?? s);
1029
+ },
1030
+ cancel: (e = "") => a(e, 1),
1031
+ error: (e = "") => a(e, 2),
1032
+ clear: () => a("", 0, true),
1033
+ get isCancelled() {
1034
+ return S;
1035
+ }
1036
+ };
1037
+ };
1038
+
1039
+ const u = {
1040
+ light: unicodeOr("\u2500", "-"),
1041
+ heavy: unicodeOr("\u2501", "="),
1042
+ block: unicodeOr("\u2588", "#")
1043
+ };
1044
+ function progress({
1045
+ style: o = "heavy",
1046
+ max: d = 100,
1047
+ size: v = 40,
1048
+ ...x
1049
+ } = {}) {
1050
+ const r = spinner(x);
1051
+ let a = 0, n = "";
1052
+ const c = Math.max(1, d), l = Math.max(1, v), S = (t) => {
1053
+ switch (t) {
1054
+ case "initial":
1055
+ case "active":
1056
+ return (e) => styleText("magenta", e);
1057
+ case "error":
1058
+ case "cancel":
1059
+ return (e) => styleText("red", e);
1060
+ case "submit":
1061
+ return (e) => styleText("green", e);
1062
+ default:
1063
+ return (e) => styleText("magenta", e);
1064
+ }
1065
+ }, p = (t, e) => {
1066
+ const m = Math.floor(a / c * l);
1067
+ return `${S(t)(u[o].repeat(m))}${styleText("dim", u[o].repeat(l - m))} ${e}`;
1068
+ }, h = (t = "") => {
1069
+ n = t, r.start(p("initial", t));
1070
+ }, g = (t = 1, e) => {
1071
+ a = Math.min(c, t + a), r.message(p("active", e ?? n)), n = e ?? n;
1072
+ };
1073
+ return {
1074
+ start: h,
1075
+ stop: r.stop,
1076
+ cancel: r.cancel,
1077
+ error: r.error,
1078
+ clear: r.clear,
1079
+ advance: g,
1080
+ isCancelled: r.isCancelled,
1081
+ message: (t) => g(0, t)
1082
+ };
1083
+ }
1084
+
1085
+ const SELECT_INSTRUCTIONS = [
1086
+ `${styleText("dim", "\u2191/\u2193")} to navigate`,
1087
+ `${styleText("dim", "Enter:")} confirm`
1088
+ ];
1089
+ const c = (t, o) => t.includes(`
1090
+ `) ? t.split(`
1091
+ `).map((d) => o(d)).join(`
1092
+ `) : o(t);
1093
+ const select = (t) => {
1094
+ const o = (n, m) => {
1095
+ if (n === void 0)
1096
+ return "";
1097
+ const s = n.label ?? String(n.value);
1098
+ switch (m) {
1099
+ case "disabled":
1100
+ return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (i) => styleText("gray", i))}${n.hint ? ` ${styleText("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
1101
+ case "selected":
1102
+ return `${c(s, (i) => styleText("dim", i))}`;
1103
+ case "active":
1104
+ return `${styleText("green", S_RADIO_ACTIVE)} ${s}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
1105
+ case "cancelled":
1106
+ return `${c(s, (i) => styleText(["strikethrough", "dim"], i))}`;
1107
+ default:
1108
+ return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (i) => styleText("dim", i))}`;
1109
+ }
1110
+ }, d = t.showInstructions ?? true;
1111
+ return new SelectPrompt({
1112
+ options: t.options,
1113
+ signal: t.signal,
1114
+ input: t.input,
1115
+ output: t.output,
1116
+ initialValue: t.initialValue,
1117
+ render() {
1118
+ const n = t.withGuide ?? settings.withGuide, m = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i = wrapTextWithPrefix(
1119
+ t.output,
1120
+ t.message,
1121
+ s,
1122
+ m
1123
+ ), u = `${n ? `${styleText("gray", S_BAR)}
1124
+ ` : ""}${i}
1125
+ `;
1126
+ switch (this.state) {
1127
+ case "submit": {
1128
+ const r = n ? `${styleText("gray", S_BAR)} ` : "", a = wrapTextWithPrefix(
1129
+ t.output,
1130
+ o(this.options[this.cursor], "selected"),
1131
+ r
1132
+ );
1133
+ return `${u}${a}`;
1134
+ }
1135
+ case "cancel": {
1136
+ const r = n ? `${styleText("gray", S_BAR)} ` : "", a = wrapTextWithPrefix(
1137
+ t.output,
1138
+ o(this.options[this.cursor], "cancelled"),
1139
+ r
1140
+ );
1141
+ return `${u}${a}${n ? `
1142
+ ${styleText("gray", S_BAR)}` : ""}`;
1143
+ }
1144
+ default: {
1145
+ const r = n ? `${styleText("cyan", S_BAR)} ` : "", a = u.split(`
1146
+ `).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], f = p.join(`
1147
+ `), b = p.length + 1;
1148
+ return `${u}${r}${limitOptions({
1149
+ output: t.output,
1150
+ cursor: this.cursor,
1151
+ options: this.options,
1152
+ maxItems: t.maxItems,
1153
+ columnPadding: r.length,
1154
+ rowPadding: a + b,
1155
+ style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
1156
+ }).join(`
1157
+ ${r}`)}
1158
+ ${f}
1159
+ `;
1160
+ }
1161
+ }
1162
+ }
1163
+ }).prompt();
1164
+ };
1165
+
1166
+ const selectKey = (t) => {
1167
+ const c = (e, a = "inactive") => {
1168
+ if (e === void 0)
1169
+ return "";
1170
+ const n = e.label ?? String(e.value);
1171
+ return a === "selected" ? `${styleText("dim", n)}` : a === "cancelled" ? `${styleText(["strikethrough", "dim"], n)}` : a === "active" ? `${styleText(["bgCyan", "gray"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : `${styleText(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}`;
1172
+ };
1173
+ return new SelectKeyPrompt({
1174
+ options: t.options,
1175
+ signal: t.signal,
1176
+ input: t.input,
1177
+ output: t.output,
1178
+ initialValue: t.initialValue,
1179
+ caseSensitive: t.caseSensitive,
1180
+ render() {
1181
+ const e = t.withGuide ?? settings.withGuide, a = `${e ? `${styleText("gray", S_BAR)}
1182
+ ` : ""}${symbol(this.state)} ${t.message}
1183
+ `;
1184
+ switch (this.state) {
1185
+ case "submit": {
1186
+ const n = e ? `${styleText("gray", S_BAR)} ` : "", r = this.options.find((u) => u.value === this.value) ?? t.options[0], l = wrapTextWithPrefix(
1187
+ t.output,
1188
+ c(r, "selected"),
1189
+ n
1190
+ );
1191
+ return `${a}${l}`;
1192
+ }
1193
+ case "cancel": {
1194
+ const n = e ? `${styleText("gray", S_BAR)} ` : "", r = wrapTextWithPrefix(
1195
+ t.output,
1196
+ c(this.options[0], "cancelled"),
1197
+ n
1198
+ );
1199
+ return `${a}${r}${e ? `
1200
+ ${styleText("gray", S_BAR)}` : ""}`;
1201
+ }
1202
+ default: {
1203
+ const n = e ? `${styleText("cyan", S_BAR)} ` : "", r = e ? styleText("cyan", S_BAR_END) : "", l = this.options.map(
1204
+ (u, d) => wrapTextWithPrefix(
1205
+ t.output,
1206
+ c(u, d === this.cursor ? "active" : "inactive"),
1207
+ n
1208
+ )
1209
+ ).join(`
1210
+ `);
1211
+ return `${a}${l}
1212
+ ${r}
1213
+ `;
1214
+ }
1215
+ }
1216
+ }
1217
+ }).prompt();
1218
+ };
1219
+
1220
+ const i = `${styleText("gray", S_BAR)} `;
1221
+ const stream = {
1222
+ message: async (e, { symbol: l = styleText("gray", S_BAR) } = {}) => {
1223
+ process.stdout.write(`${styleText("gray", S_BAR)}
1224
+ ${l} `);
1225
+ let s = 3;
1226
+ for await (let r of e) {
1227
+ r = r.replace(/\n/g, `
1228
+ ${i}`), r.includes(`
1229
+ `) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
1230
+ `))).length);
1231
+ const o = stripVTControlCharacters(r).length;
1232
+ s + o < process.stdout.columns ? (s += o, process.stdout.write(r)) : (process.stdout.write(`
1233
+ ${i}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
1234
+ }
1235
+ process.stdout.write(`
1236
+ `);
1237
+ },
1238
+ info: (e) => stream.message(e, { symbol: styleText("blue", S_INFO) }),
1239
+ success: (e) => stream.message(e, { symbol: styleText("green", S_SUCCESS) }),
1240
+ step: (e) => stream.message(e, { symbol: styleText("green", S_STEP_SUBMIT) }),
1241
+ warn: (e) => stream.message(e, { symbol: styleText("yellow", S_WARN) }),
1242
+ /** alias for `log.warn()`. */
1243
+ warning: (e) => stream.warn(e),
1244
+ error: (e) => stream.message(e, { symbol: styleText("red", S_ERROR) })
1245
+ };
1246
+
1247
+ const tasks = async (o, e) => {
1248
+ for (const t of o) {
1249
+ if (t.enabled === false) continue;
1250
+ const s = spinner(e);
1251
+ s.start(t.title);
1252
+ const n = await t.task(s.message);
1253
+ s.stop(n || t.title);
1254
+ }
1255
+ };
1256
+
1257
+ const A = (l) => l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
1258
+ const taskLog = (l) => {
1259
+ const r = l.output ?? process.stdout, O = getColumns(r), i = styleText("gray", S_BAR), p = l.spacing ?? 1, k = 3, m = l.retainLog === true, d = !isCI() && isTTY(r);
1260
+ r.write(`${i}
1261
+ `), r.write(`${styleText("green", S_STEP_SUBMIT)} ${l.title}
1262
+ `);
1263
+ for (let e = 0; e < p; e++)
1264
+ r.write(`${i}
1265
+ `);
1266
+ const n = [
1267
+ {
1268
+ value: "",
1269
+ full: ""
1270
+ }
1271
+ ];
1272
+ let v = false;
1273
+ const f = (e) => {
1274
+ if (n.length === 0)
1275
+ return;
1276
+ let s = 0;
1277
+ e && (s += p + 2);
1278
+ for (const t of n) {
1279
+ const { value: o, result: a } = t;
1280
+ let g = a?.message ?? o;
1281
+ if (g.length === 0)
1282
+ continue;
1283
+ a === void 0 && t.header !== void 0 && t.header !== "" && (g += `
1284
+ ${t.header}`);
1285
+ const E = g.split(`
1286
+ `).reduce((b, w) => w === "" ? b + 1 : b + Math.ceil((w.length + k) / O), 0);
1287
+ s += E;
1288
+ }
1289
+ s > 0 && (s += 1, r.write(erase.lines(s)));
1290
+ }, h = (e, s, t) => {
1291
+ const o = t ? `${e.full}
1292
+ ${e.value}` : e.value;
1293
+ e.header !== void 0 && e.header !== "" && log.message(
1294
+ e.header.split(`
1295
+ `).map((a) => styleText("bold", a)),
1296
+ {
1297
+ output: r,
1298
+ secondarySymbol: i,
1299
+ symbol: i,
1300
+ spacing: 0
1301
+ }
1302
+ ), log.message(
1303
+ o.split(`
1304
+ `).map((a) => styleText("dim", a)),
1305
+ {
1306
+ output: r,
1307
+ secondarySymbol: i,
1308
+ symbol: i,
1309
+ spacing: s ?? p
1310
+ }
1311
+ );
1312
+ }, T = () => {
1313
+ for (const e of n) {
1314
+ const { header: s, value: t, full: o } = e;
1315
+ (s === void 0 || s.length === 0) && t.length === 0 || h(e, void 0, m === true && o.length > 0);
1316
+ }
1317
+ }, L = (e, s, t) => {
1318
+ if (f(false), (t?.raw !== true || !v) && e.value !== "" && (e.value += `
1319
+ `), e.value += A(s), v = t?.raw === true, l.limit !== void 0) {
1320
+ const o = e.value.split(`
1321
+ `), a = o.length - l.limit;
1322
+ if (a > 0) {
1323
+ const g = o.splice(0, a);
1324
+ m && (e.full += (e.full === "" ? "" : `
1325
+ `) + g.join(`
1326
+ `));
1327
+ }
1328
+ e.value = o.join(`
1329
+ `);
1330
+ }
1331
+ d && y();
1332
+ }, y = () => {
1333
+ for (const e of n)
1334
+ e.result ? e.result.status === "error" ? log.error(e.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : log.success(e.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : e.value !== "" && h(e, 0);
1335
+ }, B = (e, s) => {
1336
+ f(false), e.result = s, d && y();
1337
+ };
1338
+ return {
1339
+ message(e, s) {
1340
+ L(n[0], e, s);
1341
+ },
1342
+ group(e) {
1343
+ const s = {
1344
+ header: e,
1345
+ value: "",
1346
+ full: ""
1347
+ };
1348
+ return n.push(s), {
1349
+ message(t, o) {
1350
+ L(s, t, o);
1351
+ },
1352
+ error(t) {
1353
+ B(s, {
1354
+ status: "error",
1355
+ message: t
1356
+ });
1357
+ },
1358
+ success(t) {
1359
+ B(s, {
1360
+ status: "success",
1361
+ message: t
1362
+ });
1363
+ }
1364
+ };
1365
+ },
1366
+ error(e, s) {
1367
+ f(true), log.error(e, { output: r, secondarySymbol: i, spacing: 1 }), s?.showLog !== false && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
1368
+ },
1369
+ success(e, s) {
1370
+ f(true), log.success(e, { output: r, secondarySymbol: i, spacing: 1 }), s?.showLog === true && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
1371
+ }
1372
+ };
1373
+ };
1374
+
1375
+ const text = (t) => new TextPrompt({
1376
+ validate: t.validate,
1377
+ placeholder: t.placeholder,
1378
+ defaultValue: t.defaultValue,
1379
+ initialValue: t.initialValue,
1380
+ output: t.output,
1381
+ signal: t.signal,
1382
+ input: t.input,
1383
+ render() {
1384
+ const r = t?.withGuide ?? settings.withGuide, l = `${`${r ? `${styleText("gray", S_BAR)}
1385
+ ` : ""}${symbol(this.state)} `}${t.message}
1386
+ `, d = t.placeholder && t.placeholder.length > 0 ? (
1387
+ // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
1388
+ styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1))
1389
+ ) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
1390
+ switch (this.state) {
1391
+ case "validating": {
1392
+ const n = r ? `${styleText("cyan", S_BAR)} ` : "", i = r ? styleText("cyan", S_BAR_END) : "", c = styleText("dim", o), $ = styleText("dim", "Validating...");
1393
+ return `${l}${n}${c}
1394
+ ${i} ${$}
1395
+ `;
1396
+ }
1397
+ case "error": {
1398
+ const n = this.error ? ` ${styleText("yellow", this.error)}` : "", i = r ? `${styleText("yellow", S_BAR)} ` : "", c = r ? styleText("yellow", S_BAR_END) : "";
1399
+ return `${l.trim()}
1400
+ ${i}${o}
1401
+ ${c}${n}
1402
+ `;
1403
+ }
1404
+ case "submit": {
1405
+ const n = s ? `${r ? " " : ""}${styleText("dim", s)}` : "", i = r ? styleText("gray", S_BAR) : "";
1406
+ return `${l}${i}${n}`;
1407
+ }
1408
+ case "cancel": {
1409
+ const n = s ? ` ${styleText(["strikethrough", "dim"], s)}` : "", i = r ? styleText("gray", S_BAR) : "";
1410
+ return `${l}${i}${n}${s.trim() ? `
1411
+ ${i}` : ""}`;
1412
+ }
1413
+ default: {
1414
+ const n = r ? `${styleText("cyan", S_BAR)} ` : "", i = r ? styleText("cyan", S_BAR_END) : "";
1415
+ return `${l}${n}${o}
1416
+ ${i}
1417
+ `;
1418
+ }
1419
+ }
1420
+ }
1421
+ }).prompt();
1422
+
1423
+ export { MULTISELECT_INSTRUCTIONS, SELECT_INSTRUCTIONS, S_BAR, S_BAR_END, S_BAR_END_RIGHT, S_BAR_H, S_BAR_START, S_BAR_START_RIGHT, S_CHECKBOX_ACTIVE, S_CHECKBOX_INACTIVE, S_CHECKBOX_SELECTED, S_CONNECT_LEFT, S_CORNER_BOTTOM_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_TOP_LEFT, S_CORNER_TOP_RIGHT, S_ERROR, S_INFO, S_PASSWORD_MASK, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_SUCCESS, S_WARN, autocomplete, autocompleteMultiselect, box, cancel, confirm, date, formatInstructionFooter, group, groupMultiselect, intro, isCI, isTTY, limitOptions, log, multiline, multiselect, note, outro, password, path, progress, select, selectKey, spinner, stream, symbol, symbolBar, taskLog, tasks, text, unicode, unicodeOr };