lean-agents 0.0.0-stage → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.es.md +454 -0
  3. package/README.md +453 -2
  4. package/core/AGENTS.es.md +60 -0
  5. package/core/AGENTS.md +60 -0
  6. package/core/README.md +8 -0
  7. package/core/agents/debug.md +14 -0
  8. package/core/agents/explore.md +13 -0
  9. package/core/agents/planner.md +14 -0
  10. package/core/agents/research.md +13 -0
  11. package/core/agents/review.md +13 -0
  12. package/core/copilot-usage-tui.js +186 -0
  13. package/core/mcp.json +38 -0
  14. package/core/pins.json +30 -0
  15. package/core/tiers.json +4 -0
  16. package/node_modules/@clack/core/LICENSE +9 -0
  17. package/node_modules/@clack/core/README.md +22 -0
  18. package/node_modules/@clack/core/dist/index.d.mts +503 -0
  19. package/node_modules/@clack/core/dist/index.mjs +1003 -0
  20. package/node_modules/@clack/core/package.json +63 -0
  21. package/node_modules/@clack/prompts/LICENSE +9 -0
  22. package/node_modules/@clack/prompts/README.md +396 -0
  23. package/node_modules/@clack/prompts/dist/index.d.mts +949 -0
  24. package/node_modules/@clack/prompts/dist/index.mjs +1423 -0
  25. package/node_modules/@clack/prompts/package.json +67 -0
  26. package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  27. package/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  28. package/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  29. package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  30. package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  31. package/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  32. package/node_modules/fast-string-truncated-width/license +21 -0
  33. package/node_modules/fast-string-truncated-width/package.json +35 -0
  34. package/node_modules/fast-string-truncated-width/readme.md +59 -0
  35. package/node_modules/fast-string-width/dist/index.d.ts +4 -0
  36. package/node_modules/fast-string-width/dist/index.js +14 -0
  37. package/node_modules/fast-string-width/license +21 -0
  38. package/node_modules/fast-string-width/package.json +34 -0
  39. package/node_modules/fast-string-width/readme.md +42 -0
  40. package/node_modules/fast-wrap-ansi/LICENSE +23 -0
  41. package/node_modules/fast-wrap-ansi/README.md +26 -0
  42. package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  43. package/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  44. package/node_modules/fast-wrap-ansi/package.json +51 -0
  45. package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  46. package/node_modules/jsonc-parser/LICENSE.md +21 -0
  47. package/node_modules/jsonc-parser/README.md +364 -0
  48. package/node_modules/jsonc-parser/SECURITY.md +41 -0
  49. package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  50. package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  51. package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  52. package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  53. package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  54. package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  55. package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  56. package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  57. package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  58. package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  59. package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  60. package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  61. package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  62. package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  63. package/node_modules/jsonc-parser/package.json +37 -0
  64. package/node_modules/sisteransi/license +21 -0
  65. package/node_modules/sisteransi/package.json +34 -0
  66. package/node_modules/sisteransi/readme.md +113 -0
  67. package/node_modules/sisteransi/src/index.js +58 -0
  68. package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  69. package/package.json +29 -4
  70. package/profiles/README.md +10 -0
  71. package/profiles/anthropic-api/gsd-defaults.json +26 -0
  72. package/profiles/anthropic-api.json +18 -0
  73. package/profiles/antigravity.json +12 -0
  74. package/profiles/claude-subscription/gsd-defaults.json +26 -0
  75. package/profiles/claude-subscription.json +17 -0
  76. package/profiles/github-copilot/gsd-defaults.json +26 -0
  77. package/profiles/github-copilot.json +17 -0
  78. package/profiles/openai-api/gsd-defaults.json +26 -0
  79. package/profiles/openai-api.json +17 -0
  80. package/profiles/opencode-go/gsd-defaults.json +26 -0
  81. package/profiles/opencode-go.json +17 -0
  82. package/profiles/vertex-gemini/gsd-defaults.json +26 -0
  83. package/profiles/vertex-gemini.json +18 -0
  84. package/scripts/adhd-skill.mjs +12 -0
  85. package/scripts/bump-pins.mjs +104 -0
  86. package/scripts/check-private.sh +52 -0
  87. package/scripts/check-readme.mjs +131 -0
  88. package/scripts/ci-download.sh +20 -0
  89. package/scripts/ci-install-opencode-v2.sh +6 -0
  90. package/scripts/ci-latest-report.mjs +38 -0
  91. package/scripts/copilot-context-mode.mjs +33 -0
  92. package/scripts/labels.sh +55 -0
  93. package/scripts/lean.mjs +700 -0
  94. package/scripts/lib/adapters/antigravity.mjs +72 -0
  95. package/scripts/lib/adapters/claude.mjs +122 -0
  96. package/scripts/lib/adapters/copilot-cli.mjs +81 -0
  97. package/scripts/lib/adapters/cursor.mjs +60 -0
  98. package/scripts/lib/adapters/opencode-v1.mjs +86 -0
  99. package/scripts/lib/adapters/opencode-v2.mjs +168 -0
  100. package/scripts/lib/adapters/vscode-copilot.mjs +56 -0
  101. package/scripts/lib/adhd.mjs +28 -0
  102. package/scripts/lib/adopt.mjs +474 -0
  103. package/scripts/lib/agent-lifecycle.mjs +163 -0
  104. package/scripts/lib/copilot-usage.mjs +49 -0
  105. package/scripts/lib/doctor.mjs +207 -0
  106. package/scripts/lib/feedback.mjs +30 -0
  107. package/scripts/lib/fsops.mjs +291 -0
  108. package/scripts/lib/gsd.mjs +42 -0
  109. package/scripts/lib/inventory.mjs +195 -0
  110. package/scripts/lib/lean-update.mjs +30 -0
  111. package/scripts/lib/migrate.mjs +407 -0
  112. package/scripts/lib/network.mjs +79 -0
  113. package/scripts/lib/node-runtime.mjs +85 -0
  114. package/scripts/lib/parallel.mjs +265 -0
  115. package/scripts/lib/pins.mjs +47 -0
  116. package/scripts/lib/project.mjs +38 -0
  117. package/scripts/lib/redact.mjs +30 -0
  118. package/scripts/lib/render.mjs +101 -0
  119. package/scripts/lib/system.mjs +178 -0
  120. package/scripts/lib/terminals.mjs +218 -0
  121. package/scripts/lib/ui.mjs +34 -0
  122. package/scripts/lib/unverified.mjs +49 -0
  123. package/scripts/lib/upgrade.mjs +130 -0
  124. package/scripts/lib/verify-commit.mjs +16 -0
  125. package/scripts/lib/verify-sha256.mjs +20 -0
  126. package/scripts/lint-workflows.mjs +25 -0
  127. package/scripts/models-refresh.mjs +58 -0
  128. package/scripts/parallel.mjs +59 -0
  129. package/scripts/pins-latest.mjs +43 -0
  130. package/scripts/release.mjs +46 -0
  131. package/scripts/verify-pins.mjs +36 -0
  132. package/scripts/version-watch.mjs +118 -0
@@ -0,0 +1,1003 @@
1
+ import { styleText } from 'node:util';
2
+ import { stdout, stdin } from 'node:process';
3
+ import * as l from 'node:readline';
4
+ import l__default from 'node:readline';
5
+ import { wrapAnsi } from 'fast-wrap-ansi';
6
+ import { cursor, erase } from 'sisteransi';
7
+ import { ReadStream } from 'node:tty';
8
+
9
+ function findCursor(s, o, l) {
10
+ if (!l.some((r) => !r.disabled))
11
+ return s;
12
+ const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
13
+ return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
14
+ }
15
+ function findTextCursor(s, o, l, i) {
16
+ const t = i.split(`
17
+ `);
18
+ let n = 0, e = s;
19
+ for (const r of t) {
20
+ if (e <= r.length)
21
+ break;
22
+ e -= r.length + 1, n++;
23
+ }
24
+ for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + o; e < 0 && n > 0; )
25
+ n--, e += t[n].length + 1;
26
+ for (; e > t[n].length && n < t.length - 1; )
27
+ e -= t[n].length + 1, n++;
28
+ e = Math.max(0, Math.min(t[n].length, e));
29
+ let h = 0;
30
+ for (let r = 0; r < n; r++)
31
+ h += t[r].length + 1;
32
+ return h + e;
33
+ }
34
+
35
+ const a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"], t = [
36
+ "January",
37
+ "February",
38
+ "March",
39
+ "April",
40
+ "May",
41
+ "June",
42
+ "July",
43
+ "August",
44
+ "September",
45
+ "October",
46
+ "November",
47
+ "December"
48
+ ];
49
+ const settings = {
50
+ actions: new Set(a$1),
51
+ aliases: /* @__PURE__ */ new Map([
52
+ // vim support
53
+ ["k", "up"],
54
+ ["j", "down"],
55
+ ["h", "left"],
56
+ ["l", "right"],
57
+ ["", "cancel"],
58
+ // opinionated defaults!
59
+ ["escape", "cancel"]
60
+ ]),
61
+ messages: {
62
+ cancel: "Canceled",
63
+ error: "Something went wrong"
64
+ },
65
+ withGuide: true,
66
+ accessible: void 0,
67
+ date: {
68
+ monthNames: [...t],
69
+ messages: {
70
+ required: "Please enter a valid date",
71
+ invalidMonth: "There are only 12 months in a year",
72
+ invalidDay: (n, e) => `There are only ${n} days in ${e}`,
73
+ afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
74
+ beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
75
+ }
76
+ }
77
+ };
78
+ function updateSettings(n) {
79
+ if (n.aliases !== void 0) {
80
+ const e = n.aliases;
81
+ for (const s in e) {
82
+ if (!Object.hasOwn(e, s)) continue;
83
+ const i = e[s];
84
+ i === void 0 || !settings.actions.has(i) || settings.aliases.has(s) || settings.aliases.set(s, i);
85
+ }
86
+ }
87
+ if (n.messages !== void 0) {
88
+ const e = n.messages;
89
+ e.cancel !== void 0 && (settings.messages.cancel = e.cancel), e.error !== void 0 && (settings.messages.error = e.error);
90
+ }
91
+ if (n.withGuide !== void 0 && (settings.withGuide = n.withGuide !== false), n.accessible !== void 0 && (settings.accessible = n.accessible === true), n.date !== void 0) {
92
+ const e = n.date;
93
+ e.monthNames !== void 0 && (settings.date.monthNames = [...e.monthNames]), e.messages !== void 0 && (e.messages.required !== void 0 && (settings.date.messages.required = e.messages.required), e.messages.invalidMonth !== void 0 && (settings.date.messages.invalidMonth = e.messages.invalidMonth), e.messages.invalidDay !== void 0 && (settings.date.messages.invalidDay = e.messages.invalidDay), e.messages.afterMin !== void 0 && (settings.date.messages.afterMin = e.messages.afterMin), e.messages.beforeMax !== void 0 && (settings.date.messages.beforeMax = e.messages.beforeMax));
94
+ }
95
+ }
96
+ function isAccessible(n) {
97
+ if (n !== void 0) return n;
98
+ if (settings.accessible !== void 0) return settings.accessible;
99
+ const e = process.env.ACCESSIBLE;
100
+ return e !== void 0 && e !== "" && e !== "0" && e !== "false";
101
+ }
102
+ function isActionKey(n, e) {
103
+ if (typeof n == "string")
104
+ return settings.aliases.get(n) === e;
105
+ for (const s of n)
106
+ if (s !== void 0 && isActionKey(s, e))
107
+ return true;
108
+ return false;
109
+ }
110
+
111
+ function diffLines(i, s) {
112
+ if (i === s) return;
113
+ const e = i.split(`
114
+ `), t = s.split(`
115
+ `), r = Math.max(e.length, t.length), f = [];
116
+ for (let n = 0; n < r; n++)
117
+ e[n] !== t[n] && f.push(n);
118
+ return {
119
+ lines: f,
120
+ numLinesBefore: e.length,
121
+ numLinesAfter: t.length,
122
+ numLines: r
123
+ };
124
+ }
125
+
126
+ const R = globalThis.process.platform.startsWith("win");
127
+ const CANCEL_SYMBOL = Symbol("clack:cancel");
128
+ function isCancel(e) {
129
+ return e === CANCEL_SYMBOL;
130
+ }
131
+ function setRawMode(e, r) {
132
+ const o = e;
133
+ o.isTTY && o.setRawMode(r);
134
+ }
135
+ function block({
136
+ input: e = stdin,
137
+ output: r = stdout,
138
+ overwrite: o = true,
139
+ hideCursor: n = true
140
+ } = {}) {
141
+ const s = l.createInterface({
142
+ input: e,
143
+ output: r,
144
+ prompt: "",
145
+ tabSize: 1
146
+ });
147
+ l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
148
+ const t = (f, { name: a, sequence: w }) => {
149
+ const c = String(f);
150
+ if (isActionKey([c, a, w], "cancel")) {
151
+ n && r.write(cursor.show), process.exit(0);
152
+ return;
153
+ }
154
+ if (!o) return;
155
+ const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
156
+ l.moveCursor(r, i, m, () => {
157
+ l.clearLine(r, 1, () => {
158
+ e.once("keypress", t);
159
+ });
160
+ });
161
+ };
162
+ return n && r.write(cursor.hide), e.once("keypress", t), () => {
163
+ e.off("keypress", t), n && r.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
164
+ };
165
+ }
166
+ const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
167
+ function wrapTextWithPrefix(e, r, o, n = o, s = o, t) {
168
+ const f = getColumns(e ?? stdout);
169
+ return wrapAnsi(r, f - o.length, {
170
+ hard: true,
171
+ trim: false
172
+ }).split(`
173
+ `).map((c, i, m) => {
174
+ const d = t ? t(c, i) : c;
175
+ return i === 0 ? `${n}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
176
+ }).join(`
177
+ `);
178
+ }
179
+
180
+ function runValidation(e, a) {
181
+ if ("~standard" in e) {
182
+ const n = e["~standard"].validate(a);
183
+ return n instanceof Promise ? n.then((r) => r.issues?.at(0)?.message) : n.issues?.at(0)?.message;
184
+ }
185
+ return e(a);
186
+ }
187
+
188
+ class y {
189
+ input;
190
+ output;
191
+ _abortSignal;
192
+ rl;
193
+ opts;
194
+ _render;
195
+ _track = false;
196
+ _prevFrame = "";
197
+ _subscribers = /* @__PURE__ */ new Map();
198
+ _cursor = 0;
199
+ state = "initial";
200
+ error = "";
201
+ value;
202
+ userInput = "";
203
+ /**
204
+ * Whether accessible (static, screen-reader friendly) output is enabled for
205
+ * this prompt, resolved from the `accessible` option, the global setting,
206
+ * and the `ACCESSIBLE` env var.
207
+ */
208
+ get accessible() {
209
+ return isAccessible(this.opts.accessible);
210
+ }
211
+ constructor(t, e = true) {
212
+ const { input: i = stdin, output: s = stdout, render: r, signal: n, ...o } = t;
213
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r.bind(this), this._track = e, this._abortSignal = n, this.input = i, this.output = s;
214
+ }
215
+ /**
216
+ * Unsubscribe all listeners
217
+ */
218
+ unsubscribe() {
219
+ this._subscribers.clear();
220
+ }
221
+ /**
222
+ * Set a subscriber with opts
223
+ * @param event - The event name
224
+ */
225
+ setSubscriber(t, e) {
226
+ const i = this._subscribers.get(t) ?? [];
227
+ i.push(e), this._subscribers.set(t, i);
228
+ }
229
+ /**
230
+ * Subscribe to an event
231
+ * @param event - The event name
232
+ * @param cb - The callback
233
+ */
234
+ on(t, e) {
235
+ this.setSubscriber(t, { cb: e });
236
+ }
237
+ /**
238
+ * Subscribe to an event once
239
+ * @param event - The event name
240
+ * @param cb - The callback
241
+ */
242
+ once(t, e) {
243
+ this.setSubscriber(t, { cb: e, once: true });
244
+ }
245
+ /**
246
+ * Emit an event with data
247
+ * @param event - The event name
248
+ * @param data - The data to pass to the callback
249
+ */
250
+ emit(t, ...e) {
251
+ const i = this._subscribers.get(t) ?? [], s = [];
252
+ for (const r of i)
253
+ r.cb(...e), r.once && s.push(() => i.splice(i.indexOf(r), 1));
254
+ for (const r of s)
255
+ r();
256
+ }
257
+ prompt() {
258
+ return new Promise((t) => {
259
+ if (this._abortSignal) {
260
+ if (this._abortSignal.aborted)
261
+ return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
262
+ this._abortSignal.addEventListener(
263
+ "abort",
264
+ () => {
265
+ this.state = "cancel", this.close();
266
+ },
267
+ { once: true }
268
+ );
269
+ }
270
+ this.rl = l__default.createInterface({
271
+ input: this.input,
272
+ tabSize: 2,
273
+ prompt: "",
274
+ escapeCodeTimeout: 50,
275
+ terminal: true
276
+ }), 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", () => {
277
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
278
+ }), this.once("cancel", () => {
279
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
280
+ });
281
+ });
282
+ }
283
+ _isActionKey(t, e) {
284
+ return t === " ";
285
+ }
286
+ _shouldSubmit(t, e) {
287
+ return true;
288
+ }
289
+ _setValue(t) {
290
+ this.value = t, this.emit("value", this.value);
291
+ }
292
+ _setUserInput(t, e) {
293
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
294
+ }
295
+ _clearUserInput() {
296
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
297
+ }
298
+ async onKeypress(t, e) {
299
+ if (this.state !== "validating") {
300
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, 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)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
301
+ if (this.opts.validate) {
302
+ const i = runValidation(this.opts.validate, this.value);
303
+ let s;
304
+ i instanceof Promise ? (this.state = "validating", this.render(), s = await i) : s = i, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
305
+ }
306
+ this.state !== "error" && (this.state = "submit");
307
+ }
308
+ isActionKey([t, 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();
309
+ }
310
+ }
311
+ close() {
312
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
313
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
314
+ }
315
+ restoreCursor() {
316
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
317
+ `).length - 1;
318
+ this.output.write(cursor.move(-999, t * -1));
319
+ }
320
+ render() {
321
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
322
+ hard: true,
323
+ trim: false
324
+ });
325
+ if (t !== this._prevFrame) {
326
+ if (this.state === "initial")
327
+ this.output.write(cursor.hide);
328
+ else {
329
+ const e = diffLines(this._prevFrame, t), i = getRows(this.output);
330
+ if (this.restoreCursor(), e) {
331
+ const s = Math.max(0, e.numLinesAfter - i), r = Math.max(0, e.numLinesBefore - i);
332
+ let n = e.lines.find((o) => o >= s);
333
+ if (n === void 0) {
334
+ this._prevFrame = t;
335
+ return;
336
+ }
337
+ if (e.lines.length === 1) {
338
+ this.output.write(cursor.move(0, n - r)), this.output.write(erase.lines(1));
339
+ const o = t.split(`
340
+ `);
341
+ this.output.write(o[n]), this._prevFrame = t, this.output.write(cursor.move(0, o.length - n - 1));
342
+ return;
343
+ } else if (e.lines.length > 1) {
344
+ if (s < r)
345
+ n = s;
346
+ else {
347
+ const h = n - r;
348
+ h > 0 && this.output.write(cursor.move(0, h));
349
+ }
350
+ this.output.write(erase.down());
351
+ const f = t.split(`
352
+ `).slice(n);
353
+ this.output.write(f.join(`
354
+ `)), this._prevFrame = t;
355
+ return;
356
+ }
357
+ }
358
+ this.output.write(erase.down());
359
+ }
360
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
361
+ }
362
+ }
363
+ }
364
+
365
+ function p$1(l, e) {
366
+ if (l === void 0 || e.length === 0)
367
+ return 0;
368
+ const i = e.findIndex((s) => s.value === l);
369
+ return i !== -1 ? i : 0;
370
+ }
371
+ function m(l, e) {
372
+ return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
373
+ }
374
+ function g(l, e) {
375
+ if (e)
376
+ return l ? e : e[0];
377
+ }
378
+ let T$1 = class T extends y {
379
+ filteredOptions;
380
+ multiple;
381
+ isNavigating = false;
382
+ selectedValues = [];
383
+ focusedValue;
384
+ #e = 0;
385
+ #s = "";
386
+ #t;
387
+ #i;
388
+ #n;
389
+ #l;
390
+ get cursor() {
391
+ return this.#e;
392
+ }
393
+ get userInputWithCursor() {
394
+ if (!this.userInput)
395
+ return styleText(["inverse", "hidden"], "_");
396
+ if (this._cursor >= this.userInput.length)
397
+ return `${this.userInput}\u2588`;
398
+ const e = this.userInput.slice(0, this.cursor), t = this.userInput.slice(this.cursor, this.cursor + 1), i = this.userInput.slice(this.cursor + 1);
399
+ return `${e}${styleText("inverse", t)}${i}`;
400
+ }
401
+ get options() {
402
+ return typeof this.#i == "function" ? this.#i() : this.#i;
403
+ }
404
+ constructor(e) {
405
+ super(e), this.#i = e.options, this.#n = e.placeholder, this.#l = e.completeOnTab === true;
406
+ const t = this.options;
407
+ this.filteredOptions = [...t], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? m;
408
+ let i;
409
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0]?.value]), i)
410
+ for (const s of i) {
411
+ const n = t.findIndex((r) => r.value === s);
412
+ n !== -1 && (this.toggleSelected(s), this.#e = n);
413
+ }
414
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#u(s, n)), this.on("userInput", (s) => this.#o(s));
415
+ }
416
+ _isActionKey(e, t) {
417
+ return e === " " || this.multiple && this.isNavigating && t.name === "space" && e !== void 0 && e !== "";
418
+ }
419
+ #u(e, t) {
420
+ const i = t.name === "up", s = t.name === "down", n = t.name === "return", r = this.userInput === "" || this.userInput === " ", u = this.#n, d = this.options, c = u !== void 0 && u !== "" && d.some(
421
+ (o) => !o.disabled && (this.#t ? this.#t(u, o) : true)
422
+ );
423
+ if (t.name === "tab" && r && c) {
424
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
425
+ return;
426
+ }
427
+ if (t.name === "tab" && this.#l && !this.multiple && this.focusedValue !== void 0) {
428
+ const o = String(this.focusedValue);
429
+ this._clearUserInput(), this._setUserInput(o, true), this.isNavigating = false;
430
+ return;
431
+ }
432
+ i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = g(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (t.name === "tab" || this.isNavigating && t.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
433
+ }
434
+ deselectAll() {
435
+ this.selectedValues = [];
436
+ }
437
+ toggleSelected(e) {
438
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t) => t !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
439
+ }
440
+ #o(e) {
441
+ if (e !== this.#s) {
442
+ this.#s = e;
443
+ const t = this.options;
444
+ e && this.#t ? this.filteredOptions = t.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t];
445
+ const i = p$1(this.focusedValue, this.filteredOptions);
446
+ this.#e = findCursor(i, 0, this.filteredOptions);
447
+ const s = this.filteredOptions[this.#e];
448
+ s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
449
+ }
450
+ }
451
+ };
452
+
453
+ class r extends y {
454
+ get cursor() {
455
+ return this.value ? 0 : 1;
456
+ }
457
+ get _value() {
458
+ return this.cursor === 0;
459
+ }
460
+ constructor(t) {
461
+ super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
462
+ this.value = this._value;
463
+ }), this.on("confirm", (i) => {
464
+ this.output.write(cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
465
+ }), this.on("cursor", () => {
466
+ this.value = !this.value;
467
+ });
468
+ }
469
+ }
470
+
471
+ const _ = {
472
+ Y: { type: "year", len: 4 },
473
+ M: { type: "month", len: 2 },
474
+ D: { type: "day", len: 2 }
475
+ };
476
+ function M(r) {
477
+ return [...r].map((t) => _[t]);
478
+ }
479
+ function P(r) {
480
+ const i = new Intl.DateTimeFormat(r, {
481
+ year: "numeric",
482
+ month: "2-digit",
483
+ day: "2-digit"
484
+ }).formatToParts(new Date(2e3, 0, 15)), s = [];
485
+ let n = "/";
486
+ for (const e of i)
487
+ e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
488
+ return { segments: s, separator: n };
489
+ }
490
+ function p(r) {
491
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
492
+ }
493
+ function f(r) {
494
+ return {
495
+ year: p(r.year),
496
+ month: p(r.month),
497
+ day: p(r.day)
498
+ };
499
+ }
500
+ function c(r, t) {
501
+ return new Date(r || 2001, t || 1, 0).getDate();
502
+ }
503
+ function b(r) {
504
+ const { year: t, month: i, day: s } = f(r);
505
+ if (!t || t < 0 || t > 9999 || !i || i < 1 || i > 12 || !s || s < 1) return;
506
+ const n = new Date(Date.UTC(t, i - 1, s));
507
+ if (!(n.getUTCFullYear() !== t || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
508
+ return { year: t, month: i, day: s };
509
+ }
510
+ function C(r) {
511
+ const t = b(r);
512
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
513
+ }
514
+ function T(r, t, i, s) {
515
+ const n = i ? {
516
+ year: i.getUTCFullYear(),
517
+ month: i.getUTCMonth() + 1,
518
+ day: i.getUTCDate()
519
+ } : null, e = s ? {
520
+ year: s.getUTCFullYear(),
521
+ month: s.getUTCMonth() + 1,
522
+ day: s.getUTCDate()
523
+ } : null;
524
+ return r === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r === "month" ? {
525
+ min: n && t.year === n.year ? n.month : 1,
526
+ max: e && t.year === e.year ? e.month : 12
527
+ } : {
528
+ min: n && t.year === n.year && t.month === n.month ? n.day : 1,
529
+ max: e && t.year === e.year && t.month === e.month ? e.day : c(t.year, t.month)
530
+ };
531
+ }
532
+ class U extends y {
533
+ #i;
534
+ #o;
535
+ #t;
536
+ #h;
537
+ #u;
538
+ #e = { segmentIndex: 0, positionInSegment: 0 };
539
+ #n = true;
540
+ #s = null;
541
+ inlineError = "";
542
+ get segmentCursor() {
543
+ return { ...this.#e };
544
+ }
545
+ get segmentValues() {
546
+ return { ...this.#t };
547
+ }
548
+ get segments() {
549
+ return this.#i;
550
+ }
551
+ get separator() {
552
+ return this.#o;
553
+ }
554
+ get formattedValue() {
555
+ return this.#l(this.#t);
556
+ }
557
+ #l(t) {
558
+ return this.#i.map((i) => t[i.type]).join(this.#o);
559
+ }
560
+ #r() {
561
+ this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? void 0);
562
+ }
563
+ constructor(t) {
564
+ const i = t.format ? { segments: M(t.format), separator: t.separator ?? "/" } : P(t.locale), s = t.separator ?? i.separator, n = t.format ? M(t.format) : i.segments, e = t.initialValue ?? t.defaultValue, m = e ? {
565
+ year: String(e.getUTCFullYear()).padStart(4, "0"),
566
+ month: String(e.getUTCMonth() + 1).padStart(2, "0"),
567
+ day: String(e.getUTCDate()).padStart(2, "0")
568
+ } : { year: "____", month: "__", day: "__" }, o = n.map((a) => m[a.type]).join(s);
569
+ super({ ...t, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m, this.#h = t.minDate, this.#u = t.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t));
570
+ }
571
+ #a() {
572
+ const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t];
573
+ if (i)
574
+ return this.#e.positionInSegment = Math.max(
575
+ 0,
576
+ Math.min(this.#e.positionInSegment, i.len - 1)
577
+ ), { segment: i, index: t };
578
+ }
579
+ #m(t) {
580
+ this.inlineError = "", this.#s = null;
581
+ const i = this.#a();
582
+ i && (this.#e.segmentIndex = Math.max(
583
+ 0,
584
+ Math.min(this.#i.length - 1, i.index + t)
585
+ ), this.#e.positionInSegment = 0, this.#n = true);
586
+ }
587
+ #d(t) {
588
+ const i = this.#a();
589
+ if (!i) return;
590
+ const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T(
591
+ s.type,
592
+ f(this.#t),
593
+ this.#h,
594
+ this.#u
595
+ );
596
+ let a;
597
+ e ? a = t === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m + t), o.min), this.#t = {
598
+ ...this.#t,
599
+ [s.type]: a.toString().padStart(s.len, "0")
600
+ }, this.#n = true, this.#s = null, this.#r();
601
+ }
602
+ #f(t) {
603
+ if (t)
604
+ switch (t) {
605
+ case "right":
606
+ return this.#m(1);
607
+ case "left":
608
+ return this.#m(-1);
609
+ case "up":
610
+ return this.#d(1);
611
+ case "down":
612
+ return this.#d(-1);
613
+ }
614
+ }
615
+ #y(t, i) {
616
+ if (i?.name === "backspace" || i?.sequence === "\x7F" || i?.sequence === "\b" || t === "\x7F" || t === "\b") {
617
+ this.inlineError = "";
618
+ const n = this.#a();
619
+ if (!n) return;
620
+ if (!this.#t[n.segment.type].replace(/_/g, "")) {
621
+ this.#m(-1);
622
+ return;
623
+ }
624
+ this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
625
+ return;
626
+ }
627
+ if (i?.name === "tab") {
628
+ this.inlineError = "";
629
+ const n = this.#a();
630
+ if (!n) return;
631
+ const e = i.shift ? -1 : 1, m = n.index + e;
632
+ m >= 0 && m < this.#i.length && (this.#e.segmentIndex = m, this.#e.positionInSegment = 0, this.#n = true);
633
+ return;
634
+ }
635
+ if (t && /^[0-9]$/.test(t)) {
636
+ const n = this.#a();
637
+ if (!n) return;
638
+ const { segment: e } = n, m = !this.#t[e.type].replace(/_/g, "");
639
+ if (this.#n && this.#s !== null && !m) {
640
+ const h = this.#s + t, d = { ...this.#t, [e.type]: h }, g = this.#g(d, e);
641
+ if (g) {
642
+ this.inlineError = g, this.#s = null, this.#n = false;
643
+ return;
644
+ }
645
+ this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
646
+ return;
647
+ }
648
+ this.#n && !m && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
649
+ const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
650
+ if (u < 0 || u >= e.len) return;
651
+ let l = o.slice(0, u) + t + o.slice(u + 1), D = false;
652
+ if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
653
+ const h = Number.parseInt(t, 10);
654
+ l = `0${t}`, D = h <= (e.type === "month" ? 1 : 2);
655
+ }
656
+ if (e.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(e.len, "_")), !l.includes("_")) {
657
+ const h = { ...this.#t, [e.type]: l }, d = this.#g(h, e);
658
+ if (d) {
659
+ this.inlineError = d;
660
+ return;
661
+ }
662
+ }
663
+ this.inlineError = "", this.#t[e.type] = l;
664
+ const y = l.includes("_") ? void 0 : b(this.#t);
665
+ if (y) {
666
+ const { year: h, month: d } = y, g = c(h, d);
667
+ this.#t = {
668
+ year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
669
+ month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
670
+ day: String(Math.max(1, Math.min(g, y.day))).padStart(2, "0")
671
+ };
672
+ }
673
+ this.#r();
674
+ const S = l.indexOf("_");
675
+ D ? (this.#n = true, this.#s = t) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
676
+ }
677
+ }
678
+ #g(t, i) {
679
+ const { month: s, day: n } = f(t);
680
+ if (i.type === "month" && (s < 0 || s > 12))
681
+ return settings.date.messages.invalidMonth;
682
+ if (i.type === "day" && (n < 0 || n > 31))
683
+ return settings.date.messages.invalidDay(31, "any month");
684
+ }
685
+ #p(t) {
686
+ const { year: i, month: s, day: n } = f(this.#t);
687
+ if (i && s && n) {
688
+ const e = c(i, s);
689
+ this.#t = {
690
+ ...this.#t,
691
+ day: String(Math.min(n, e)).padStart(2, "0")
692
+ };
693
+ }
694
+ this.value = C(this.#t) ?? t.defaultValue ?? void 0;
695
+ }
696
+ }
697
+
698
+ let u$2 = class u extends y {
699
+ options;
700
+ cursor = 0;
701
+ #t;
702
+ getGroupItems(t) {
703
+ return this.options.filter((r) => r.group === t);
704
+ }
705
+ isGroupSelected(t) {
706
+ const r = this.getGroupItems(t), e = this.value;
707
+ return e === void 0 ? false : r.every((s) => e.includes(s.value));
708
+ }
709
+ toggleValue() {
710
+ const t = this.options[this.cursor];
711
+ if (t !== void 0)
712
+ if (this.value === void 0 && (this.value = []), t.group === true) {
713
+ const r = t.value, e = this.getGroupItems(r);
714
+ this.isGroupSelected(r) ? this.value = this.value.filter(
715
+ (s) => e.findIndex((i) => i.value === s) === -1
716
+ ) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
717
+ } else {
718
+ const r = this.value.includes(t.value);
719
+ this.value = r ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
720
+ }
721
+ }
722
+ constructor(t) {
723
+ super(t, false);
724
+ const { options: r } = t;
725
+ this.#t = t.selectableGroups !== false, this.options = Object.entries(r).flatMap(([e, s]) => [
726
+ { value: e, group: true, label: e },
727
+ ...s.map((i) => ({ ...i, group: e }))
728
+ ]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(
729
+ this.options.findIndex(({ value: e }) => e === t.cursorAt),
730
+ this.#t ? 0 : 1
731
+ ), this.on("cursor", (e) => {
732
+ switch (e) {
733
+ case "left":
734
+ case "up": {
735
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
736
+ const s = this.options[this.cursor]?.group === true;
737
+ !this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
738
+ break;
739
+ }
740
+ case "down":
741
+ case "right": {
742
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
743
+ const s = this.options[this.cursor]?.group === true;
744
+ !this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
745
+ break;
746
+ }
747
+ case "space":
748
+ this.toggleValue();
749
+ break;
750
+ }
751
+ });
752
+ }
753
+ };
754
+
755
+ const o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
756
+ class h extends y {
757
+ #t = false;
758
+ #s;
759
+ focused = "editor";
760
+ get userInputWithCursor() {
761
+ if (this.state === "submit")
762
+ return this.userInput;
763
+ const t = this.userInput;
764
+ if (this.cursor >= t.length)
765
+ return `${t}\u2588`;
766
+ const s = t.slice(0, this.cursor), r = t.slice(this.cursor, this.cursor + 1), i = t.slice(this.cursor + 1);
767
+ return r === `
768
+ ` ? `${s}\u2588
769
+ ${i}` : `${s}${styleText("inverse", r)}${i}`;
770
+ }
771
+ get cursor() {
772
+ return this._cursor;
773
+ }
774
+ #r(t) {
775
+ if (this.userInput.length === 0) {
776
+ this._setUserInput(t);
777
+ return;
778
+ }
779
+ this._setUserInput(
780
+ this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor)
781
+ );
782
+ }
783
+ #i(t) {
784
+ const s = this.value ?? "";
785
+ switch (t) {
786
+ case "up":
787
+ this._cursor = findTextCursor(this._cursor, 0, -1, s);
788
+ return;
789
+ case "down":
790
+ this._cursor = findTextCursor(this._cursor, 0, 1, s);
791
+ return;
792
+ case "left":
793
+ this._cursor = findTextCursor(this._cursor, -1, 0, s);
794
+ return;
795
+ case "right":
796
+ this._cursor = findTextCursor(this._cursor, 1, 0, s);
797
+ return;
798
+ }
799
+ }
800
+ _shouldSubmit(t, s) {
801
+ if (this.#s)
802
+ return this.focused === "submit" ? true : (this.#r(`
803
+ `), this._cursor++, false);
804
+ const r = this.#t;
805
+ return this.#t = true, r && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
806
+ ` && (this._setUserInput(
807
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
808
+ ), this._cursor--), true) : (this.#r(`
809
+ `), this._cursor++, false);
810
+ }
811
+ constructor(t) {
812
+ const s = t.initialUserInput ?? t.initialValue;
813
+ super(
814
+ {
815
+ ...t,
816
+ initialUserInput: s
817
+ },
818
+ false
819
+ ), s !== void 0 && (this._cursor = s.length), this.#s = t.showSubmit ?? false, this.on("key", (r, i) => {
820
+ if (i?.name && o.has(i.name)) {
821
+ this.#t = false, this.#i(i.name);
822
+ return;
823
+ }
824
+ if (r === " " && this.#s) {
825
+ this.focused = this.focused === "editor" ? "submit" : "editor";
826
+ return;
827
+ }
828
+ if (i?.name !== "return") {
829
+ if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
830
+ this._setUserInput(
831
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
832
+ ), this._cursor--;
833
+ return;
834
+ }
835
+ if (i?.name === "delete" && this.cursor < this.userInput.length) {
836
+ this._setUserInput(
837
+ this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1)
838
+ );
839
+ return;
840
+ }
841
+ r && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r ?? ""), this._cursor++);
842
+ }
843
+ }), this.on("userInput", (r) => {
844
+ this._setValue(r);
845
+ }), this.on("finalize", () => {
846
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
847
+ });
848
+ }
849
+ }
850
+
851
+ class a extends y {
852
+ options;
853
+ cursor = 0;
854
+ get _value() {
855
+ return this.options[this.cursor]?.value;
856
+ }
857
+ get _enabledOptions() {
858
+ return this.options.filter((e) => e.disabled !== true);
859
+ }
860
+ toggleAll() {
861
+ const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
862
+ this.value = i ? [] : e.map((t) => t.value);
863
+ }
864
+ toggleInvert() {
865
+ const e = this.value;
866
+ if (!e)
867
+ return;
868
+ const i = this._enabledOptions.filter((t) => !e.includes(t.value));
869
+ this.value = i.map((t) => t.value);
870
+ }
871
+ toggleValue() {
872
+ this.value === void 0 && (this.value = []);
873
+ const e = this.value.includes(this._value);
874
+ this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
875
+ }
876
+ constructor(e) {
877
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
878
+ const i = Math.max(
879
+ this.options.findIndex(({ value: t }) => t === e.cursorAt),
880
+ 0
881
+ );
882
+ this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
883
+ l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
884
+ }), this.on("cursor", (t) => {
885
+ switch (t) {
886
+ case "left":
887
+ case "up":
888
+ this.cursor = findCursor(this.cursor, -1, this.options);
889
+ break;
890
+ case "down":
891
+ case "right":
892
+ this.cursor = findCursor(this.cursor, 1, this.options);
893
+ break;
894
+ case "space":
895
+ this.toggleValue();
896
+ break;
897
+ }
898
+ });
899
+ }
900
+ }
901
+
902
+ let u$1 = class u extends y {
903
+ _mask = "\u2022";
904
+ get cursor() {
905
+ return this._cursor;
906
+ }
907
+ get masked() {
908
+ return this.userInput.replaceAll(/./g, this._mask);
909
+ }
910
+ get userInputWithCursor() {
911
+ if (this.state === "submit" || this.state === "cancel")
912
+ return this.masked;
913
+ const t = this.userInput;
914
+ if (this.cursor >= t.length)
915
+ return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
916
+ const s = this.masked, r = s.slice(0, this.cursor), i = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
917
+ return `${r}${styleText("inverse", i)}${o}`;
918
+ }
919
+ clear() {
920
+ this._clearUserInput();
921
+ }
922
+ constructor({ mask: t, ...s }) {
923
+ super(s), this._mask = t ?? "\u2022", this.on("userInput", (r) => {
924
+ this._setValue(r);
925
+ }), this.on("finalize", () => {
926
+ this.value === void 0 && (this.value = "");
927
+ });
928
+ }
929
+ };
930
+
931
+ let n$1 = class n extends y {
932
+ options;
933
+ cursor = 0;
934
+ get _selectedValue() {
935
+ return this.options[this.cursor];
936
+ }
937
+ changeValue() {
938
+ const e = this._selectedValue;
939
+ this.value = e === void 0 ? void 0 : e.value;
940
+ }
941
+ constructor(e) {
942
+ super(e, false), this.options = e.options;
943
+ const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t = o === -1 ? 0 : o;
944
+ this.cursor = this.options[t]?.disabled ? findCursor(t, 1, this.options) : t, this.changeValue(), this.on("cursor", (s) => {
945
+ switch (s) {
946
+ case "left":
947
+ case "up":
948
+ this.cursor = findCursor(this.cursor, -1, this.options);
949
+ break;
950
+ case "down":
951
+ case "right":
952
+ this.cursor = findCursor(this.cursor, 1, this.options);
953
+ break;
954
+ }
955
+ this.changeValue();
956
+ });
957
+ }
958
+ };
959
+
960
+ class u extends y {
961
+ options;
962
+ cursor = 0;
963
+ constructor(t) {
964
+ super(t, false), this.options = t.options;
965
+ const s = t.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
966
+ this.cursor = Math.max(i.indexOf(t.initialValue), 0), this.on("key", (e) => {
967
+ if (!e)
968
+ return;
969
+ const o = s ? e : e.toLowerCase();
970
+ if (!i.includes(o))
971
+ return;
972
+ const n = this.options.find(({ value: [r] }) => s ? r === o : r?.toLowerCase() === o);
973
+ n && (this.value = n.value, this.state = "submit", this.emit("submit"));
974
+ });
975
+ }
976
+ }
977
+
978
+ class n extends y {
979
+ get userInputWithCursor() {
980
+ if (this.state === "submit")
981
+ return this.userInput;
982
+ const t = this.userInput;
983
+ if (this.cursor >= t.length)
984
+ return `${this.userInput}\u2588`;
985
+ const r = t.slice(0, this.cursor), s = t.slice(this.cursor, this.cursor + 1), e = t.slice(this.cursor + 1);
986
+ return `${r}${styleText("inverse", s)}${e}`;
987
+ }
988
+ get cursor() {
989
+ return this._cursor;
990
+ }
991
+ constructor(t) {
992
+ super({
993
+ ...t,
994
+ initialUserInput: t.initialUserInput ?? t.initialValue
995
+ }), this.on("userInput", (r) => {
996
+ this._setValue(r);
997
+ }), this.on("finalize", () => {
998
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
999
+ });
1000
+ }
1001
+ }
1002
+
1003
+ export { T$1 as AutocompletePrompt, CANCEL_SYMBOL, r as ConfirmPrompt, U as DatePrompt, u$2 as GroupMultiSelectPrompt, h as MultiLinePrompt, a as MultiSelectPrompt, u$1 as PasswordPrompt, y as Prompt, u as SelectKeyPrompt, n$1 as SelectPrompt, n as TextPrompt, block, getColumns, getRows, isAccessible, isCancel, runValidation, settings, updateSettings, wrapTextWithPrefix };