truecourse 0.1.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 (31) hide show
  1. package/cli.mjs +3886 -0
  2. package/db/migrations/0000_daily_paper_doll.sql +82 -0
  3. package/db/migrations/meta/0000_snapshot.json +569 -0
  4. package/db/migrations/meta/_journal.json +13 -0
  5. package/package.json +34 -0
  6. package/public/404.html +12 -0
  7. package/public/_next/static/chunks/414-8318b3e90e55d32a.js +1 -0
  8. package/public/_next/static/chunks/597-63908a91b482ecc2.js +1 -0
  9. package/public/_next/static/chunks/7273c211-8e9085ce5065411a.js +1 -0
  10. package/public/_next/static/chunks/728-8bf3f63c2116a9f4.js +1 -0
  11. package/public/_next/static/chunks/a51c26f2-7912c8e37f20294d.js +1 -0
  12. package/public/_next/static/chunks/app/_not-found/page-fa912e0095c03faf.js +1 -0
  13. package/public/_next/static/chunks/app/layout-8b7c9093ed7416a9.js +1 -0
  14. package/public/_next/static/chunks/app/page-a584f9a9455d99db.js +1 -0
  15. package/public/_next/static/chunks/app/repos/[[...slug]]/page-e5fdcbd6e95a0351.js +1 -0
  16. package/public/_next/static/chunks/framework-cd8a7ea2c29e04e3.js +1 -0
  17. package/public/_next/static/chunks/main-75f848718c47ce7f.js +1 -0
  18. package/public/_next/static/chunks/main-app-6713e5440a400899.js +1 -0
  19. package/public/_next/static/chunks/pages/_app-cbca4c5e73429fb7.js +1 -0
  20. package/public/_next/static/chunks/pages/_error-b3f1a96c07a42193.js +1 -0
  21. package/public/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  22. package/public/_next/static/chunks/webpack-2f0ed87fd33e9d1c.js +1 -0
  23. package/public/_next/static/css/2de88e1f79a8a35f.css +1 -0
  24. package/public/_next/static/css/599369d853c61df7.css +31 -0
  25. package/public/_next/static/jBjG46wvKRKD4-YnOkixD/_buildManifest.js +1 -0
  26. package/public/_next/static/jBjG46wvKRKD4-YnOkixD/_ssgManifest.js +1 -0
  27. package/public/index.html +12 -0
  28. package/public/index.txt +19 -0
  29. package/public/repos.html +1 -0
  30. package/public/repos.txt +17 -0
  31. package/server.mjs +107306 -0
package/cli.mjs ADDED
@@ -0,0 +1,3886 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
10
+ get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
11
+ }) : x2)(function(x2) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x2 + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+
35
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/error.js
36
+ var require_error = __commonJS({
37
+ "node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/error.js"(exports) {
38
+ var CommanderError2 = class extends Error {
39
+ /**
40
+ * Constructs the CommanderError class
41
+ * @param {number} exitCode suggested exit code which could be used with process.exit
42
+ * @param {string} code an id string representing the error
43
+ * @param {string} message human-readable description of the error
44
+ */
45
+ constructor(exitCode, code, message) {
46
+ super(message);
47
+ Error.captureStackTrace(this, this.constructor);
48
+ this.name = this.constructor.name;
49
+ this.code = code;
50
+ this.exitCode = exitCode;
51
+ this.nestedError = void 0;
52
+ }
53
+ };
54
+ var InvalidArgumentError2 = class extends CommanderError2 {
55
+ /**
56
+ * Constructs the InvalidArgumentError class
57
+ * @param {string} [message] explanation of why argument is invalid
58
+ */
59
+ constructor(message) {
60
+ super(1, "commander.invalidArgument", message);
61
+ Error.captureStackTrace(this, this.constructor);
62
+ this.name = this.constructor.name;
63
+ }
64
+ };
65
+ exports.CommanderError = CommanderError2;
66
+ exports.InvalidArgumentError = InvalidArgumentError2;
67
+ }
68
+ });
69
+
70
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/argument.js
71
+ var require_argument = __commonJS({
72
+ "node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/argument.js"(exports) {
73
+ var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
74
+ var Argument2 = class {
75
+ /**
76
+ * Initialize a new command argument with the given name and description.
77
+ * The default is that the argument is required, and you can explicitly
78
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
79
+ *
80
+ * @param {string} name
81
+ * @param {string} [description]
82
+ */
83
+ constructor(name, description) {
84
+ this.description = description || "";
85
+ this.variadic = false;
86
+ this.parseArg = void 0;
87
+ this.defaultValue = void 0;
88
+ this.defaultValueDescription = void 0;
89
+ this.argChoices = void 0;
90
+ switch (name[0]) {
91
+ case "<":
92
+ this.required = true;
93
+ this._name = name.slice(1, -1);
94
+ break;
95
+ case "[":
96
+ this.required = false;
97
+ this._name = name.slice(1, -1);
98
+ break;
99
+ default:
100
+ this.required = true;
101
+ this._name = name;
102
+ break;
103
+ }
104
+ if (this._name.length > 3 && this._name.slice(-3) === "...") {
105
+ this.variadic = true;
106
+ this._name = this._name.slice(0, -3);
107
+ }
108
+ }
109
+ /**
110
+ * Return argument name.
111
+ *
112
+ * @return {string}
113
+ */
114
+ name() {
115
+ return this._name;
116
+ }
117
+ /**
118
+ * @package
119
+ */
120
+ _concatValue(value, previous) {
121
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
122
+ return [value];
123
+ }
124
+ return previous.concat(value);
125
+ }
126
+ /**
127
+ * Set the default value, and optionally supply the description to be displayed in the help.
128
+ *
129
+ * @param {*} value
130
+ * @param {string} [description]
131
+ * @return {Argument}
132
+ */
133
+ default(value, description) {
134
+ this.defaultValue = value;
135
+ this.defaultValueDescription = description;
136
+ return this;
137
+ }
138
+ /**
139
+ * Set the custom handler for processing CLI command arguments into argument values.
140
+ *
141
+ * @param {Function} [fn]
142
+ * @return {Argument}
143
+ */
144
+ argParser(fn) {
145
+ this.parseArg = fn;
146
+ return this;
147
+ }
148
+ /**
149
+ * Only allow argument value to be one of choices.
150
+ *
151
+ * @param {string[]} values
152
+ * @return {Argument}
153
+ */
154
+ choices(values) {
155
+ this.argChoices = values.slice();
156
+ this.parseArg = (arg, previous) => {
157
+ if (!this.argChoices.includes(arg)) {
158
+ throw new InvalidArgumentError2(
159
+ `Allowed choices are ${this.argChoices.join(", ")}.`
160
+ );
161
+ }
162
+ if (this.variadic) {
163
+ return this._concatValue(arg, previous);
164
+ }
165
+ return arg;
166
+ };
167
+ return this;
168
+ }
169
+ /**
170
+ * Make argument required.
171
+ *
172
+ * @returns {Argument}
173
+ */
174
+ argRequired() {
175
+ this.required = true;
176
+ return this;
177
+ }
178
+ /**
179
+ * Make argument optional.
180
+ *
181
+ * @returns {Argument}
182
+ */
183
+ argOptional() {
184
+ this.required = false;
185
+ return this;
186
+ }
187
+ };
188
+ function humanReadableArgName(arg) {
189
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
190
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
191
+ }
192
+ exports.Argument = Argument2;
193
+ exports.humanReadableArgName = humanReadableArgName;
194
+ }
195
+ });
196
+
197
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/help.js
198
+ var require_help = __commonJS({
199
+ "node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/help.js"(exports) {
200
+ var { humanReadableArgName } = require_argument();
201
+ var Help2 = class {
202
+ constructor() {
203
+ this.helpWidth = void 0;
204
+ this.sortSubcommands = false;
205
+ this.sortOptions = false;
206
+ this.showGlobalOptions = false;
207
+ }
208
+ /**
209
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
210
+ *
211
+ * @param {Command} cmd
212
+ * @returns {Command[]}
213
+ */
214
+ visibleCommands(cmd) {
215
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
216
+ const helpCommand = cmd._getHelpCommand();
217
+ if (helpCommand && !helpCommand._hidden) {
218
+ visibleCommands.push(helpCommand);
219
+ }
220
+ if (this.sortSubcommands) {
221
+ visibleCommands.sort((a2, b2) => {
222
+ return a2.name().localeCompare(b2.name());
223
+ });
224
+ }
225
+ return visibleCommands;
226
+ }
227
+ /**
228
+ * Compare options for sort.
229
+ *
230
+ * @param {Option} a
231
+ * @param {Option} b
232
+ * @returns {number}
233
+ */
234
+ compareOptions(a2, b2) {
235
+ const getSortKey = (option) => {
236
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
237
+ };
238
+ return getSortKey(a2).localeCompare(getSortKey(b2));
239
+ }
240
+ /**
241
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
242
+ *
243
+ * @param {Command} cmd
244
+ * @returns {Option[]}
245
+ */
246
+ visibleOptions(cmd) {
247
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
248
+ const helpOption = cmd._getHelpOption();
249
+ if (helpOption && !helpOption.hidden) {
250
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
251
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
252
+ if (!removeShort && !removeLong) {
253
+ visibleOptions.push(helpOption);
254
+ } else if (helpOption.long && !removeLong) {
255
+ visibleOptions.push(
256
+ cmd.createOption(helpOption.long, helpOption.description)
257
+ );
258
+ } else if (helpOption.short && !removeShort) {
259
+ visibleOptions.push(
260
+ cmd.createOption(helpOption.short, helpOption.description)
261
+ );
262
+ }
263
+ }
264
+ if (this.sortOptions) {
265
+ visibleOptions.sort(this.compareOptions);
266
+ }
267
+ return visibleOptions;
268
+ }
269
+ /**
270
+ * Get an array of the visible global options. (Not including help.)
271
+ *
272
+ * @param {Command} cmd
273
+ * @returns {Option[]}
274
+ */
275
+ visibleGlobalOptions(cmd) {
276
+ if (!this.showGlobalOptions) return [];
277
+ const globalOptions = [];
278
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
279
+ const visibleOptions = ancestorCmd.options.filter(
280
+ (option) => !option.hidden
281
+ );
282
+ globalOptions.push(...visibleOptions);
283
+ }
284
+ if (this.sortOptions) {
285
+ globalOptions.sort(this.compareOptions);
286
+ }
287
+ return globalOptions;
288
+ }
289
+ /**
290
+ * Get an array of the arguments if any have a description.
291
+ *
292
+ * @param {Command} cmd
293
+ * @returns {Argument[]}
294
+ */
295
+ visibleArguments(cmd) {
296
+ if (cmd._argsDescription) {
297
+ cmd.registeredArguments.forEach((argument) => {
298
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
299
+ });
300
+ }
301
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
302
+ return cmd.registeredArguments;
303
+ }
304
+ return [];
305
+ }
306
+ /**
307
+ * Get the command term to show in the list of subcommands.
308
+ *
309
+ * @param {Command} cmd
310
+ * @returns {string}
311
+ */
312
+ subcommandTerm(cmd) {
313
+ const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
314
+ return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
315
+ (args ? " " + args : "");
316
+ }
317
+ /**
318
+ * Get the option term to show in the list of options.
319
+ *
320
+ * @param {Option} option
321
+ * @returns {string}
322
+ */
323
+ optionTerm(option) {
324
+ return option.flags;
325
+ }
326
+ /**
327
+ * Get the argument term to show in the list of arguments.
328
+ *
329
+ * @param {Argument} argument
330
+ * @returns {string}
331
+ */
332
+ argumentTerm(argument) {
333
+ return argument.name();
334
+ }
335
+ /**
336
+ * Get the longest command term length.
337
+ *
338
+ * @param {Command} cmd
339
+ * @param {Help} helper
340
+ * @returns {number}
341
+ */
342
+ longestSubcommandTermLength(cmd, helper) {
343
+ return helper.visibleCommands(cmd).reduce((max, command) => {
344
+ return Math.max(max, helper.subcommandTerm(command).length);
345
+ }, 0);
346
+ }
347
+ /**
348
+ * Get the longest option term length.
349
+ *
350
+ * @param {Command} cmd
351
+ * @param {Help} helper
352
+ * @returns {number}
353
+ */
354
+ longestOptionTermLength(cmd, helper) {
355
+ return helper.visibleOptions(cmd).reduce((max, option) => {
356
+ return Math.max(max, helper.optionTerm(option).length);
357
+ }, 0);
358
+ }
359
+ /**
360
+ * Get the longest global option term length.
361
+ *
362
+ * @param {Command} cmd
363
+ * @param {Help} helper
364
+ * @returns {number}
365
+ */
366
+ longestGlobalOptionTermLength(cmd, helper) {
367
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
368
+ return Math.max(max, helper.optionTerm(option).length);
369
+ }, 0);
370
+ }
371
+ /**
372
+ * Get the longest argument term length.
373
+ *
374
+ * @param {Command} cmd
375
+ * @param {Help} helper
376
+ * @returns {number}
377
+ */
378
+ longestArgumentTermLength(cmd, helper) {
379
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
380
+ return Math.max(max, helper.argumentTerm(argument).length);
381
+ }, 0);
382
+ }
383
+ /**
384
+ * Get the command usage to be displayed at the top of the built-in help.
385
+ *
386
+ * @param {Command} cmd
387
+ * @returns {string}
388
+ */
389
+ commandUsage(cmd) {
390
+ let cmdName = cmd._name;
391
+ if (cmd._aliases[0]) {
392
+ cmdName = cmdName + "|" + cmd._aliases[0];
393
+ }
394
+ let ancestorCmdNames = "";
395
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
396
+ ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
397
+ }
398
+ return ancestorCmdNames + cmdName + " " + cmd.usage();
399
+ }
400
+ /**
401
+ * Get the description for the command.
402
+ *
403
+ * @param {Command} cmd
404
+ * @returns {string}
405
+ */
406
+ commandDescription(cmd) {
407
+ return cmd.description();
408
+ }
409
+ /**
410
+ * Get the subcommand summary to show in the list of subcommands.
411
+ * (Fallback to description for backwards compatibility.)
412
+ *
413
+ * @param {Command} cmd
414
+ * @returns {string}
415
+ */
416
+ subcommandDescription(cmd) {
417
+ return cmd.summary() || cmd.description();
418
+ }
419
+ /**
420
+ * Get the option description to show in the list of options.
421
+ *
422
+ * @param {Option} option
423
+ * @return {string}
424
+ */
425
+ optionDescription(option) {
426
+ const extraInfo = [];
427
+ if (option.argChoices) {
428
+ extraInfo.push(
429
+ // use stringify to match the display of the default value
430
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
431
+ );
432
+ }
433
+ if (option.defaultValue !== void 0) {
434
+ const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
435
+ if (showDefault) {
436
+ extraInfo.push(
437
+ `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`
438
+ );
439
+ }
440
+ }
441
+ if (option.presetArg !== void 0 && option.optional) {
442
+ extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
443
+ }
444
+ if (option.envVar !== void 0) {
445
+ extraInfo.push(`env: ${option.envVar}`);
446
+ }
447
+ if (extraInfo.length > 0) {
448
+ return `${option.description} (${extraInfo.join(", ")})`;
449
+ }
450
+ return option.description;
451
+ }
452
+ /**
453
+ * Get the argument description to show in the list of arguments.
454
+ *
455
+ * @param {Argument} argument
456
+ * @return {string}
457
+ */
458
+ argumentDescription(argument) {
459
+ const extraInfo = [];
460
+ if (argument.argChoices) {
461
+ extraInfo.push(
462
+ // use stringify to match the display of the default value
463
+ `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
464
+ );
465
+ }
466
+ if (argument.defaultValue !== void 0) {
467
+ extraInfo.push(
468
+ `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`
469
+ );
470
+ }
471
+ if (extraInfo.length > 0) {
472
+ const extraDescripton = `(${extraInfo.join(", ")})`;
473
+ if (argument.description) {
474
+ return `${argument.description} ${extraDescripton}`;
475
+ }
476
+ return extraDescripton;
477
+ }
478
+ return argument.description;
479
+ }
480
+ /**
481
+ * Generate the built-in help text.
482
+ *
483
+ * @param {Command} cmd
484
+ * @param {Help} helper
485
+ * @returns {string}
486
+ */
487
+ formatHelp(cmd, helper) {
488
+ const termWidth = helper.padWidth(cmd, helper);
489
+ const helpWidth = helper.helpWidth || 80;
490
+ const itemIndentWidth = 2;
491
+ const itemSeparatorWidth = 2;
492
+ function formatItem(term, description) {
493
+ if (description) {
494
+ const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
495
+ return helper.wrap(
496
+ fullText,
497
+ helpWidth - itemIndentWidth,
498
+ termWidth + itemSeparatorWidth
499
+ );
500
+ }
501
+ return term;
502
+ }
503
+ function formatList(textArray) {
504
+ return textArray.join("\n").replace(/^/gm, " ".repeat(itemIndentWidth));
505
+ }
506
+ let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
507
+ const commandDescription = helper.commandDescription(cmd);
508
+ if (commandDescription.length > 0) {
509
+ output = output.concat([
510
+ helper.wrap(commandDescription, helpWidth, 0),
511
+ ""
512
+ ]);
513
+ }
514
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
515
+ return formatItem(
516
+ helper.argumentTerm(argument),
517
+ helper.argumentDescription(argument)
518
+ );
519
+ });
520
+ if (argumentList.length > 0) {
521
+ output = output.concat(["Arguments:", formatList(argumentList), ""]);
522
+ }
523
+ const optionList = helper.visibleOptions(cmd).map((option) => {
524
+ return formatItem(
525
+ helper.optionTerm(option),
526
+ helper.optionDescription(option)
527
+ );
528
+ });
529
+ if (optionList.length > 0) {
530
+ output = output.concat(["Options:", formatList(optionList), ""]);
531
+ }
532
+ if (this.showGlobalOptions) {
533
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
534
+ return formatItem(
535
+ helper.optionTerm(option),
536
+ helper.optionDescription(option)
537
+ );
538
+ });
539
+ if (globalOptionList.length > 0) {
540
+ output = output.concat([
541
+ "Global Options:",
542
+ formatList(globalOptionList),
543
+ ""
544
+ ]);
545
+ }
546
+ }
547
+ const commandList = helper.visibleCommands(cmd).map((cmd2) => {
548
+ return formatItem(
549
+ helper.subcommandTerm(cmd2),
550
+ helper.subcommandDescription(cmd2)
551
+ );
552
+ });
553
+ if (commandList.length > 0) {
554
+ output = output.concat(["Commands:", formatList(commandList), ""]);
555
+ }
556
+ return output.join("\n");
557
+ }
558
+ /**
559
+ * Calculate the pad width from the maximum term length.
560
+ *
561
+ * @param {Command} cmd
562
+ * @param {Help} helper
563
+ * @returns {number}
564
+ */
565
+ padWidth(cmd, helper) {
566
+ return Math.max(
567
+ helper.longestOptionTermLength(cmd, helper),
568
+ helper.longestGlobalOptionTermLength(cmd, helper),
569
+ helper.longestSubcommandTermLength(cmd, helper),
570
+ helper.longestArgumentTermLength(cmd, helper)
571
+ );
572
+ }
573
+ /**
574
+ * Wrap the given string to width characters per line, with lines after the first indented.
575
+ * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
576
+ *
577
+ * @param {string} str
578
+ * @param {number} width
579
+ * @param {number} indent
580
+ * @param {number} [minColumnWidth=40]
581
+ * @return {string}
582
+ *
583
+ */
584
+ wrap(str, width, indent, minColumnWidth = 40) {
585
+ const indents = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF";
586
+ const manualIndent = new RegExp(`[\\n][${indents}]+`);
587
+ if (str.match(manualIndent)) return str;
588
+ const columnWidth = width - indent;
589
+ if (columnWidth < minColumnWidth) return str;
590
+ const leadingStr = str.slice(0, indent);
591
+ const columnText = str.slice(indent).replace("\r\n", "\n");
592
+ const indentString = " ".repeat(indent);
593
+ const zeroWidthSpace = "\u200B";
594
+ const breaks = `\\s${zeroWidthSpace}`;
595
+ const regex = new RegExp(
596
+ `
597
+ |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
598
+ "g"
599
+ );
600
+ const lines = columnText.match(regex) || [];
601
+ return leadingStr + lines.map((line, i) => {
602
+ if (line === "\n") return "";
603
+ return (i > 0 ? indentString : "") + line.trimEnd();
604
+ }).join("\n");
605
+ }
606
+ };
607
+ exports.Help = Help2;
608
+ }
609
+ });
610
+
611
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/option.js
612
+ var require_option = __commonJS({
613
+ "node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/option.js"(exports) {
614
+ var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
615
+ var Option2 = class {
616
+ /**
617
+ * Initialize a new `Option` with the given `flags` and `description`.
618
+ *
619
+ * @param {string} flags
620
+ * @param {string} [description]
621
+ */
622
+ constructor(flags, description) {
623
+ this.flags = flags;
624
+ this.description = description || "";
625
+ this.required = flags.includes("<");
626
+ this.optional = flags.includes("[");
627
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
628
+ this.mandatory = false;
629
+ const optionFlags = splitOptionFlags(flags);
630
+ this.short = optionFlags.shortFlag;
631
+ this.long = optionFlags.longFlag;
632
+ this.negate = false;
633
+ if (this.long) {
634
+ this.negate = this.long.startsWith("--no-");
635
+ }
636
+ this.defaultValue = void 0;
637
+ this.defaultValueDescription = void 0;
638
+ this.presetArg = void 0;
639
+ this.envVar = void 0;
640
+ this.parseArg = void 0;
641
+ this.hidden = false;
642
+ this.argChoices = void 0;
643
+ this.conflictsWith = [];
644
+ this.implied = void 0;
645
+ }
646
+ /**
647
+ * Set the default value, and optionally supply the description to be displayed in the help.
648
+ *
649
+ * @param {*} value
650
+ * @param {string} [description]
651
+ * @return {Option}
652
+ */
653
+ default(value, description) {
654
+ this.defaultValue = value;
655
+ this.defaultValueDescription = description;
656
+ return this;
657
+ }
658
+ /**
659
+ * Preset to use when option used without option-argument, especially optional but also boolean and negated.
660
+ * The custom processing (parseArg) is called.
661
+ *
662
+ * @example
663
+ * new Option('--color').default('GREYSCALE').preset('RGB');
664
+ * new Option('--donate [amount]').preset('20').argParser(parseFloat);
665
+ *
666
+ * @param {*} arg
667
+ * @return {Option}
668
+ */
669
+ preset(arg) {
670
+ this.presetArg = arg;
671
+ return this;
672
+ }
673
+ /**
674
+ * Add option name(s) that conflict with this option.
675
+ * An error will be displayed if conflicting options are found during parsing.
676
+ *
677
+ * @example
678
+ * new Option('--rgb').conflicts('cmyk');
679
+ * new Option('--js').conflicts(['ts', 'jsx']);
680
+ *
681
+ * @param {(string | string[])} names
682
+ * @return {Option}
683
+ */
684
+ conflicts(names) {
685
+ this.conflictsWith = this.conflictsWith.concat(names);
686
+ return this;
687
+ }
688
+ /**
689
+ * Specify implied option values for when this option is set and the implied options are not.
690
+ *
691
+ * The custom processing (parseArg) is not called on the implied values.
692
+ *
693
+ * @example
694
+ * program
695
+ * .addOption(new Option('--log', 'write logging information to file'))
696
+ * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
697
+ *
698
+ * @param {object} impliedOptionValues
699
+ * @return {Option}
700
+ */
701
+ implies(impliedOptionValues) {
702
+ let newImplied = impliedOptionValues;
703
+ if (typeof impliedOptionValues === "string") {
704
+ newImplied = { [impliedOptionValues]: true };
705
+ }
706
+ this.implied = Object.assign(this.implied || {}, newImplied);
707
+ return this;
708
+ }
709
+ /**
710
+ * Set environment variable to check for option value.
711
+ *
712
+ * An environment variable is only used if when processed the current option value is
713
+ * undefined, or the source of the current value is 'default' or 'config' or 'env'.
714
+ *
715
+ * @param {string} name
716
+ * @return {Option}
717
+ */
718
+ env(name) {
719
+ this.envVar = name;
720
+ return this;
721
+ }
722
+ /**
723
+ * Set the custom handler for processing CLI option arguments into option values.
724
+ *
725
+ * @param {Function} [fn]
726
+ * @return {Option}
727
+ */
728
+ argParser(fn) {
729
+ this.parseArg = fn;
730
+ return this;
731
+ }
732
+ /**
733
+ * Whether the option is mandatory and must have a value after parsing.
734
+ *
735
+ * @param {boolean} [mandatory=true]
736
+ * @return {Option}
737
+ */
738
+ makeOptionMandatory(mandatory = true) {
739
+ this.mandatory = !!mandatory;
740
+ return this;
741
+ }
742
+ /**
743
+ * Hide option in help.
744
+ *
745
+ * @param {boolean} [hide=true]
746
+ * @return {Option}
747
+ */
748
+ hideHelp(hide = true) {
749
+ this.hidden = !!hide;
750
+ return this;
751
+ }
752
+ /**
753
+ * @package
754
+ */
755
+ _concatValue(value, previous) {
756
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
757
+ return [value];
758
+ }
759
+ return previous.concat(value);
760
+ }
761
+ /**
762
+ * Only allow option value to be one of choices.
763
+ *
764
+ * @param {string[]} values
765
+ * @return {Option}
766
+ */
767
+ choices(values) {
768
+ this.argChoices = values.slice();
769
+ this.parseArg = (arg, previous) => {
770
+ if (!this.argChoices.includes(arg)) {
771
+ throw new InvalidArgumentError2(
772
+ `Allowed choices are ${this.argChoices.join(", ")}.`
773
+ );
774
+ }
775
+ if (this.variadic) {
776
+ return this._concatValue(arg, previous);
777
+ }
778
+ return arg;
779
+ };
780
+ return this;
781
+ }
782
+ /**
783
+ * Return option name.
784
+ *
785
+ * @return {string}
786
+ */
787
+ name() {
788
+ if (this.long) {
789
+ return this.long.replace(/^--/, "");
790
+ }
791
+ return this.short.replace(/^-/, "");
792
+ }
793
+ /**
794
+ * Return option name, in a camelcase format that can be used
795
+ * as a object attribute key.
796
+ *
797
+ * @return {string}
798
+ */
799
+ attributeName() {
800
+ return camelcase(this.name().replace(/^no-/, ""));
801
+ }
802
+ /**
803
+ * Check if `arg` matches the short or long flag.
804
+ *
805
+ * @param {string} arg
806
+ * @return {boolean}
807
+ * @package
808
+ */
809
+ is(arg) {
810
+ return this.short === arg || this.long === arg;
811
+ }
812
+ /**
813
+ * Return whether a boolean option.
814
+ *
815
+ * Options are one of boolean, negated, required argument, or optional argument.
816
+ *
817
+ * @return {boolean}
818
+ * @package
819
+ */
820
+ isBoolean() {
821
+ return !this.required && !this.optional && !this.negate;
822
+ }
823
+ };
824
+ var DualOptions = class {
825
+ /**
826
+ * @param {Option[]} options
827
+ */
828
+ constructor(options) {
829
+ this.positiveOptions = /* @__PURE__ */ new Map();
830
+ this.negativeOptions = /* @__PURE__ */ new Map();
831
+ this.dualOptions = /* @__PURE__ */ new Set();
832
+ options.forEach((option) => {
833
+ if (option.negate) {
834
+ this.negativeOptions.set(option.attributeName(), option);
835
+ } else {
836
+ this.positiveOptions.set(option.attributeName(), option);
837
+ }
838
+ });
839
+ this.negativeOptions.forEach((value, key) => {
840
+ if (this.positiveOptions.has(key)) {
841
+ this.dualOptions.add(key);
842
+ }
843
+ });
844
+ }
845
+ /**
846
+ * Did the value come from the option, and not from possible matching dual option?
847
+ *
848
+ * @param {*} value
849
+ * @param {Option} option
850
+ * @returns {boolean}
851
+ */
852
+ valueFromOption(value, option) {
853
+ const optionKey = option.attributeName();
854
+ if (!this.dualOptions.has(optionKey)) return true;
855
+ const preset = this.negativeOptions.get(optionKey).presetArg;
856
+ const negativeValue = preset !== void 0 ? preset : false;
857
+ return option.negate === (negativeValue === value);
858
+ }
859
+ };
860
+ function camelcase(str) {
861
+ return str.split("-").reduce((str2, word) => {
862
+ return str2 + word[0].toUpperCase() + word.slice(1);
863
+ });
864
+ }
865
+ function splitOptionFlags(flags) {
866
+ let shortFlag;
867
+ let longFlag;
868
+ const flagParts = flags.split(/[ |,]+/);
869
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
870
+ shortFlag = flagParts.shift();
871
+ longFlag = flagParts.shift();
872
+ if (!shortFlag && /^-[^-]$/.test(longFlag)) {
873
+ shortFlag = longFlag;
874
+ longFlag = void 0;
875
+ }
876
+ return { shortFlag, longFlag };
877
+ }
878
+ exports.Option = Option2;
879
+ exports.DualOptions = DualOptions;
880
+ }
881
+ });
882
+
883
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/suggestSimilar.js
884
+ var require_suggestSimilar = __commonJS({
885
+ "node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/suggestSimilar.js"(exports) {
886
+ var maxDistance = 3;
887
+ function editDistance(a2, b2) {
888
+ if (Math.abs(a2.length - b2.length) > maxDistance)
889
+ return Math.max(a2.length, b2.length);
890
+ const d2 = [];
891
+ for (let i = 0; i <= a2.length; i++) {
892
+ d2[i] = [i];
893
+ }
894
+ for (let j3 = 0; j3 <= b2.length; j3++) {
895
+ d2[0][j3] = j3;
896
+ }
897
+ for (let j3 = 1; j3 <= b2.length; j3++) {
898
+ for (let i = 1; i <= a2.length; i++) {
899
+ let cost = 1;
900
+ if (a2[i - 1] === b2[j3 - 1]) {
901
+ cost = 0;
902
+ } else {
903
+ cost = 1;
904
+ }
905
+ d2[i][j3] = Math.min(
906
+ d2[i - 1][j3] + 1,
907
+ // deletion
908
+ d2[i][j3 - 1] + 1,
909
+ // insertion
910
+ d2[i - 1][j3 - 1] + cost
911
+ // substitution
912
+ );
913
+ if (i > 1 && j3 > 1 && a2[i - 1] === b2[j3 - 2] && a2[i - 2] === b2[j3 - 1]) {
914
+ d2[i][j3] = Math.min(d2[i][j3], d2[i - 2][j3 - 2] + 1);
915
+ }
916
+ }
917
+ }
918
+ return d2[a2.length][b2.length];
919
+ }
920
+ function suggestSimilar(word, candidates) {
921
+ if (!candidates || candidates.length === 0) return "";
922
+ candidates = Array.from(new Set(candidates));
923
+ const searchingOptions = word.startsWith("--");
924
+ if (searchingOptions) {
925
+ word = word.slice(2);
926
+ candidates = candidates.map((candidate) => candidate.slice(2));
927
+ }
928
+ let similar = [];
929
+ let bestDistance = maxDistance;
930
+ const minSimilarity = 0.4;
931
+ candidates.forEach((candidate) => {
932
+ if (candidate.length <= 1) return;
933
+ const distance = editDistance(word, candidate);
934
+ const length = Math.max(word.length, candidate.length);
935
+ const similarity = (length - distance) / length;
936
+ if (similarity > minSimilarity) {
937
+ if (distance < bestDistance) {
938
+ bestDistance = distance;
939
+ similar = [candidate];
940
+ } else if (distance === bestDistance) {
941
+ similar.push(candidate);
942
+ }
943
+ }
944
+ });
945
+ similar.sort((a2, b2) => a2.localeCompare(b2));
946
+ if (searchingOptions) {
947
+ similar = similar.map((candidate) => `--${candidate}`);
948
+ }
949
+ if (similar.length > 1) {
950
+ return `
951
+ (Did you mean one of ${similar.join(", ")}?)`;
952
+ }
953
+ if (similar.length === 1) {
954
+ return `
955
+ (Did you mean ${similar[0]}?)`;
956
+ }
957
+ return "";
958
+ }
959
+ exports.suggestSimilar = suggestSimilar;
960
+ }
961
+ });
962
+
963
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js
964
+ var require_command = __commonJS({
965
+ "node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports) {
966
+ var EventEmitter = __require("node:events").EventEmitter;
967
+ var childProcess = __require("node:child_process");
968
+ var path4 = __require("node:path");
969
+ var fs3 = __require("node:fs");
970
+ var process2 = __require("node:process");
971
+ var { Argument: Argument2, humanReadableArgName } = require_argument();
972
+ var { CommanderError: CommanderError2 } = require_error();
973
+ var { Help: Help2 } = require_help();
974
+ var { Option: Option2, DualOptions } = require_option();
975
+ var { suggestSimilar } = require_suggestSimilar();
976
+ var Command2 = class _Command extends EventEmitter {
977
+ /**
978
+ * Initialize a new `Command`.
979
+ *
980
+ * @param {string} [name]
981
+ */
982
+ constructor(name) {
983
+ super();
984
+ this.commands = [];
985
+ this.options = [];
986
+ this.parent = null;
987
+ this._allowUnknownOption = false;
988
+ this._allowExcessArguments = true;
989
+ this.registeredArguments = [];
990
+ this._args = this.registeredArguments;
991
+ this.args = [];
992
+ this.rawArgs = [];
993
+ this.processedArgs = [];
994
+ this._scriptPath = null;
995
+ this._name = name || "";
996
+ this._optionValues = {};
997
+ this._optionValueSources = {};
998
+ this._storeOptionsAsProperties = false;
999
+ this._actionHandler = null;
1000
+ this._executableHandler = false;
1001
+ this._executableFile = null;
1002
+ this._executableDir = null;
1003
+ this._defaultCommandName = null;
1004
+ this._exitCallback = null;
1005
+ this._aliases = [];
1006
+ this._combineFlagAndOptionalValue = true;
1007
+ this._description = "";
1008
+ this._summary = "";
1009
+ this._argsDescription = void 0;
1010
+ this._enablePositionalOptions = false;
1011
+ this._passThroughOptions = false;
1012
+ this._lifeCycleHooks = {};
1013
+ this._showHelpAfterError = false;
1014
+ this._showSuggestionAfterError = true;
1015
+ this._outputConfiguration = {
1016
+ writeOut: (str) => process2.stdout.write(str),
1017
+ writeErr: (str) => process2.stderr.write(str),
1018
+ getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : void 0,
1019
+ getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : void 0,
1020
+ outputError: (str, write) => write(str)
1021
+ };
1022
+ this._hidden = false;
1023
+ this._helpOption = void 0;
1024
+ this._addImplicitHelpCommand = void 0;
1025
+ this._helpCommand = void 0;
1026
+ this._helpConfiguration = {};
1027
+ }
1028
+ /**
1029
+ * Copy settings that are useful to have in common across root command and subcommands.
1030
+ *
1031
+ * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
1032
+ *
1033
+ * @param {Command} sourceCommand
1034
+ * @return {Command} `this` command for chaining
1035
+ */
1036
+ copyInheritedSettings(sourceCommand) {
1037
+ this._outputConfiguration = sourceCommand._outputConfiguration;
1038
+ this._helpOption = sourceCommand._helpOption;
1039
+ this._helpCommand = sourceCommand._helpCommand;
1040
+ this._helpConfiguration = sourceCommand._helpConfiguration;
1041
+ this._exitCallback = sourceCommand._exitCallback;
1042
+ this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
1043
+ this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
1044
+ this._allowExcessArguments = sourceCommand._allowExcessArguments;
1045
+ this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
1046
+ this._showHelpAfterError = sourceCommand._showHelpAfterError;
1047
+ this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
1048
+ return this;
1049
+ }
1050
+ /**
1051
+ * @returns {Command[]}
1052
+ * @private
1053
+ */
1054
+ _getCommandAndAncestors() {
1055
+ const result = [];
1056
+ for (let command = this; command; command = command.parent) {
1057
+ result.push(command);
1058
+ }
1059
+ return result;
1060
+ }
1061
+ /**
1062
+ * Define a command.
1063
+ *
1064
+ * There are two styles of command: pay attention to where to put the description.
1065
+ *
1066
+ * @example
1067
+ * // Command implemented using action handler (description is supplied separately to `.command`)
1068
+ * program
1069
+ * .command('clone <source> [destination]')
1070
+ * .description('clone a repository into a newly created directory')
1071
+ * .action((source, destination) => {
1072
+ * console.log('clone command called');
1073
+ * });
1074
+ *
1075
+ * // Command implemented using separate executable file (description is second parameter to `.command`)
1076
+ * program
1077
+ * .command('start <service>', 'start named service')
1078
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
1079
+ *
1080
+ * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
1081
+ * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1082
+ * @param {object} [execOpts] - configuration options (for executable)
1083
+ * @return {Command} returns new command for action handler, or `this` for executable command
1084
+ */
1085
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
1086
+ let desc = actionOptsOrExecDesc;
1087
+ let opts = execOpts;
1088
+ if (typeof desc === "object" && desc !== null) {
1089
+ opts = desc;
1090
+ desc = null;
1091
+ }
1092
+ opts = opts || {};
1093
+ const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
1094
+ const cmd = this.createCommand(name);
1095
+ if (desc) {
1096
+ cmd.description(desc);
1097
+ cmd._executableHandler = true;
1098
+ }
1099
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
1100
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
1101
+ cmd._executableFile = opts.executableFile || null;
1102
+ if (args) cmd.arguments(args);
1103
+ this._registerCommand(cmd);
1104
+ cmd.parent = this;
1105
+ cmd.copyInheritedSettings(this);
1106
+ if (desc) return this;
1107
+ return cmd;
1108
+ }
1109
+ /**
1110
+ * Factory routine to create a new unattached command.
1111
+ *
1112
+ * See .command() for creating an attached subcommand, which uses this routine to
1113
+ * create the command. You can override createCommand to customise subcommands.
1114
+ *
1115
+ * @param {string} [name]
1116
+ * @return {Command} new command
1117
+ */
1118
+ createCommand(name) {
1119
+ return new _Command(name);
1120
+ }
1121
+ /**
1122
+ * You can customise the help with a subclass of Help by overriding createHelp,
1123
+ * or by overriding Help properties using configureHelp().
1124
+ *
1125
+ * @return {Help}
1126
+ */
1127
+ createHelp() {
1128
+ return Object.assign(new Help2(), this.configureHelp());
1129
+ }
1130
+ /**
1131
+ * You can customise the help by overriding Help properties using configureHelp(),
1132
+ * or with a subclass of Help by overriding createHelp().
1133
+ *
1134
+ * @param {object} [configuration] - configuration options
1135
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1136
+ */
1137
+ configureHelp(configuration) {
1138
+ if (configuration === void 0) return this._helpConfiguration;
1139
+ this._helpConfiguration = configuration;
1140
+ return this;
1141
+ }
1142
+ /**
1143
+ * The default output goes to stdout and stderr. You can customise this for special
1144
+ * applications. You can also customise the display of errors by overriding outputError.
1145
+ *
1146
+ * The configuration properties are all functions:
1147
+ *
1148
+ * // functions to change where being written, stdout and stderr
1149
+ * writeOut(str)
1150
+ * writeErr(str)
1151
+ * // matching functions to specify width for wrapping help
1152
+ * getOutHelpWidth()
1153
+ * getErrHelpWidth()
1154
+ * // functions based on what is being written out
1155
+ * outputError(str, write) // used for displaying errors, and not used for displaying help
1156
+ *
1157
+ * @param {object} [configuration] - configuration options
1158
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1159
+ */
1160
+ configureOutput(configuration) {
1161
+ if (configuration === void 0) return this._outputConfiguration;
1162
+ Object.assign(this._outputConfiguration, configuration);
1163
+ return this;
1164
+ }
1165
+ /**
1166
+ * Display the help or a custom message after an error occurs.
1167
+ *
1168
+ * @param {(boolean|string)} [displayHelp]
1169
+ * @return {Command} `this` command for chaining
1170
+ */
1171
+ showHelpAfterError(displayHelp = true) {
1172
+ if (typeof displayHelp !== "string") displayHelp = !!displayHelp;
1173
+ this._showHelpAfterError = displayHelp;
1174
+ return this;
1175
+ }
1176
+ /**
1177
+ * Display suggestion of similar commands for unknown commands, or options for unknown options.
1178
+ *
1179
+ * @param {boolean} [displaySuggestion]
1180
+ * @return {Command} `this` command for chaining
1181
+ */
1182
+ showSuggestionAfterError(displaySuggestion = true) {
1183
+ this._showSuggestionAfterError = !!displaySuggestion;
1184
+ return this;
1185
+ }
1186
+ /**
1187
+ * Add a prepared subcommand.
1188
+ *
1189
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
1190
+ *
1191
+ * @param {Command} cmd - new subcommand
1192
+ * @param {object} [opts] - configuration options
1193
+ * @return {Command} `this` command for chaining
1194
+ */
1195
+ addCommand(cmd, opts) {
1196
+ if (!cmd._name) {
1197
+ throw new Error(`Command passed to .addCommand() must have a name
1198
+ - specify the name in Command constructor or using .name()`);
1199
+ }
1200
+ opts = opts || {};
1201
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
1202
+ if (opts.noHelp || opts.hidden) cmd._hidden = true;
1203
+ this._registerCommand(cmd);
1204
+ cmd.parent = this;
1205
+ cmd._checkForBrokenPassThrough();
1206
+ return this;
1207
+ }
1208
+ /**
1209
+ * Factory routine to create a new unattached argument.
1210
+ *
1211
+ * See .argument() for creating an attached argument, which uses this routine to
1212
+ * create the argument. You can override createArgument to return a custom argument.
1213
+ *
1214
+ * @param {string} name
1215
+ * @param {string} [description]
1216
+ * @return {Argument} new argument
1217
+ */
1218
+ createArgument(name, description) {
1219
+ return new Argument2(name, description);
1220
+ }
1221
+ /**
1222
+ * Define argument syntax for command.
1223
+ *
1224
+ * The default is that the argument is required, and you can explicitly
1225
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
1226
+ *
1227
+ * @example
1228
+ * program.argument('<input-file>');
1229
+ * program.argument('[output-file]');
1230
+ *
1231
+ * @param {string} name
1232
+ * @param {string} [description]
1233
+ * @param {(Function|*)} [fn] - custom argument processing function
1234
+ * @param {*} [defaultValue]
1235
+ * @return {Command} `this` command for chaining
1236
+ */
1237
+ argument(name, description, fn, defaultValue) {
1238
+ const argument = this.createArgument(name, description);
1239
+ if (typeof fn === "function") {
1240
+ argument.default(defaultValue).argParser(fn);
1241
+ } else {
1242
+ argument.default(fn);
1243
+ }
1244
+ this.addArgument(argument);
1245
+ return this;
1246
+ }
1247
+ /**
1248
+ * Define argument syntax for command, adding multiple at once (without descriptions).
1249
+ *
1250
+ * See also .argument().
1251
+ *
1252
+ * @example
1253
+ * program.arguments('<cmd> [env]');
1254
+ *
1255
+ * @param {string} names
1256
+ * @return {Command} `this` command for chaining
1257
+ */
1258
+ arguments(names) {
1259
+ names.trim().split(/ +/).forEach((detail) => {
1260
+ this.argument(detail);
1261
+ });
1262
+ return this;
1263
+ }
1264
+ /**
1265
+ * Define argument syntax for command, adding a prepared argument.
1266
+ *
1267
+ * @param {Argument} argument
1268
+ * @return {Command} `this` command for chaining
1269
+ */
1270
+ addArgument(argument) {
1271
+ const previousArgument = this.registeredArguments.slice(-1)[0];
1272
+ if (previousArgument && previousArgument.variadic) {
1273
+ throw new Error(
1274
+ `only the last argument can be variadic '${previousArgument.name()}'`
1275
+ );
1276
+ }
1277
+ if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
1278
+ throw new Error(
1279
+ `a default value for a required argument is never used: '${argument.name()}'`
1280
+ );
1281
+ }
1282
+ this.registeredArguments.push(argument);
1283
+ return this;
1284
+ }
1285
+ /**
1286
+ * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
1287
+ *
1288
+ * @example
1289
+ * program.helpCommand('help [cmd]');
1290
+ * program.helpCommand('help [cmd]', 'show help');
1291
+ * program.helpCommand(false); // suppress default help command
1292
+ * program.helpCommand(true); // add help command even if no subcommands
1293
+ *
1294
+ * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added
1295
+ * @param {string} [description] - custom description
1296
+ * @return {Command} `this` command for chaining
1297
+ */
1298
+ helpCommand(enableOrNameAndArgs, description) {
1299
+ if (typeof enableOrNameAndArgs === "boolean") {
1300
+ this._addImplicitHelpCommand = enableOrNameAndArgs;
1301
+ return this;
1302
+ }
1303
+ enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]";
1304
+ const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
1305
+ const helpDescription = description ?? "display help for command";
1306
+ const helpCommand = this.createCommand(helpName);
1307
+ helpCommand.helpOption(false);
1308
+ if (helpArgs) helpCommand.arguments(helpArgs);
1309
+ if (helpDescription) helpCommand.description(helpDescription);
1310
+ this._addImplicitHelpCommand = true;
1311
+ this._helpCommand = helpCommand;
1312
+ return this;
1313
+ }
1314
+ /**
1315
+ * Add prepared custom help command.
1316
+ *
1317
+ * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`
1318
+ * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only
1319
+ * @return {Command} `this` command for chaining
1320
+ */
1321
+ addHelpCommand(helpCommand, deprecatedDescription) {
1322
+ if (typeof helpCommand !== "object") {
1323
+ this.helpCommand(helpCommand, deprecatedDescription);
1324
+ return this;
1325
+ }
1326
+ this._addImplicitHelpCommand = true;
1327
+ this._helpCommand = helpCommand;
1328
+ return this;
1329
+ }
1330
+ /**
1331
+ * Lazy create help command.
1332
+ *
1333
+ * @return {(Command|null)}
1334
+ * @package
1335
+ */
1336
+ _getHelpCommand() {
1337
+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
1338
+ if (hasImplicitHelpCommand) {
1339
+ if (this._helpCommand === void 0) {
1340
+ this.helpCommand(void 0, void 0);
1341
+ }
1342
+ return this._helpCommand;
1343
+ }
1344
+ return null;
1345
+ }
1346
+ /**
1347
+ * Add hook for life cycle event.
1348
+ *
1349
+ * @param {string} event
1350
+ * @param {Function} listener
1351
+ * @return {Command} `this` command for chaining
1352
+ */
1353
+ hook(event, listener) {
1354
+ const allowedValues = ["preSubcommand", "preAction", "postAction"];
1355
+ if (!allowedValues.includes(event)) {
1356
+ throw new Error(`Unexpected value for event passed to hook : '${event}'.
1357
+ Expecting one of '${allowedValues.join("', '")}'`);
1358
+ }
1359
+ if (this._lifeCycleHooks[event]) {
1360
+ this._lifeCycleHooks[event].push(listener);
1361
+ } else {
1362
+ this._lifeCycleHooks[event] = [listener];
1363
+ }
1364
+ return this;
1365
+ }
1366
+ /**
1367
+ * Register callback to use as replacement for calling process.exit.
1368
+ *
1369
+ * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
1370
+ * @return {Command} `this` command for chaining
1371
+ */
1372
+ exitOverride(fn) {
1373
+ if (fn) {
1374
+ this._exitCallback = fn;
1375
+ } else {
1376
+ this._exitCallback = (err) => {
1377
+ if (err.code !== "commander.executeSubCommandAsync") {
1378
+ throw err;
1379
+ } else {
1380
+ }
1381
+ };
1382
+ }
1383
+ return this;
1384
+ }
1385
+ /**
1386
+ * Call process.exit, and _exitCallback if defined.
1387
+ *
1388
+ * @param {number} exitCode exit code for using with process.exit
1389
+ * @param {string} code an id string representing the error
1390
+ * @param {string} message human-readable description of the error
1391
+ * @return never
1392
+ * @private
1393
+ */
1394
+ _exit(exitCode, code, message) {
1395
+ if (this._exitCallback) {
1396
+ this._exitCallback(new CommanderError2(exitCode, code, message));
1397
+ }
1398
+ process2.exit(exitCode);
1399
+ }
1400
+ /**
1401
+ * Register callback `fn` for the command.
1402
+ *
1403
+ * @example
1404
+ * program
1405
+ * .command('serve')
1406
+ * .description('start service')
1407
+ * .action(function() {
1408
+ * // do work here
1409
+ * });
1410
+ *
1411
+ * @param {Function} fn
1412
+ * @return {Command} `this` command for chaining
1413
+ */
1414
+ action(fn) {
1415
+ const listener = (args) => {
1416
+ const expectedArgsCount = this.registeredArguments.length;
1417
+ const actionArgs = args.slice(0, expectedArgsCount);
1418
+ if (this._storeOptionsAsProperties) {
1419
+ actionArgs[expectedArgsCount] = this;
1420
+ } else {
1421
+ actionArgs[expectedArgsCount] = this.opts();
1422
+ }
1423
+ actionArgs.push(this);
1424
+ return fn.apply(this, actionArgs);
1425
+ };
1426
+ this._actionHandler = listener;
1427
+ return this;
1428
+ }
1429
+ /**
1430
+ * Factory routine to create a new unattached option.
1431
+ *
1432
+ * See .option() for creating an attached option, which uses this routine to
1433
+ * create the option. You can override createOption to return a custom option.
1434
+ *
1435
+ * @param {string} flags
1436
+ * @param {string} [description]
1437
+ * @return {Option} new option
1438
+ */
1439
+ createOption(flags, description) {
1440
+ return new Option2(flags, description);
1441
+ }
1442
+ /**
1443
+ * Wrap parseArgs to catch 'commander.invalidArgument'.
1444
+ *
1445
+ * @param {(Option | Argument)} target
1446
+ * @param {string} value
1447
+ * @param {*} previous
1448
+ * @param {string} invalidArgumentMessage
1449
+ * @private
1450
+ */
1451
+ _callParseArg(target, value, previous, invalidArgumentMessage) {
1452
+ try {
1453
+ return target.parseArg(value, previous);
1454
+ } catch (err) {
1455
+ if (err.code === "commander.invalidArgument") {
1456
+ const message = `${invalidArgumentMessage} ${err.message}`;
1457
+ this.error(message, { exitCode: err.exitCode, code: err.code });
1458
+ }
1459
+ throw err;
1460
+ }
1461
+ }
1462
+ /**
1463
+ * Check for option flag conflicts.
1464
+ * Register option if no conflicts found, or throw on conflict.
1465
+ *
1466
+ * @param {Option} option
1467
+ * @private
1468
+ */
1469
+ _registerOption(option) {
1470
+ const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
1471
+ if (matchingOption) {
1472
+ const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
1473
+ throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1474
+ - already used by option '${matchingOption.flags}'`);
1475
+ }
1476
+ this.options.push(option);
1477
+ }
1478
+ /**
1479
+ * Check for command name and alias conflicts with existing commands.
1480
+ * Register command if no conflicts found, or throw on conflict.
1481
+ *
1482
+ * @param {Command} command
1483
+ * @private
1484
+ */
1485
+ _registerCommand(command) {
1486
+ const knownBy = (cmd) => {
1487
+ return [cmd.name()].concat(cmd.aliases());
1488
+ };
1489
+ const alreadyUsed = knownBy(command).find(
1490
+ (name) => this._findCommand(name)
1491
+ );
1492
+ if (alreadyUsed) {
1493
+ const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
1494
+ const newCmd = knownBy(command).join("|");
1495
+ throw new Error(
1496
+ `cannot add command '${newCmd}' as already have command '${existingCmd}'`
1497
+ );
1498
+ }
1499
+ this.commands.push(command);
1500
+ }
1501
+ /**
1502
+ * Add an option.
1503
+ *
1504
+ * @param {Option} option
1505
+ * @return {Command} `this` command for chaining
1506
+ */
1507
+ addOption(option) {
1508
+ this._registerOption(option);
1509
+ const oname = option.name();
1510
+ const name = option.attributeName();
1511
+ if (option.negate) {
1512
+ const positiveLongFlag = option.long.replace(/^--no-/, "--");
1513
+ if (!this._findOption(positiveLongFlag)) {
1514
+ this.setOptionValueWithSource(
1515
+ name,
1516
+ option.defaultValue === void 0 ? true : option.defaultValue,
1517
+ "default"
1518
+ );
1519
+ }
1520
+ } else if (option.defaultValue !== void 0) {
1521
+ this.setOptionValueWithSource(name, option.defaultValue, "default");
1522
+ }
1523
+ const handleOptionValue = (val, invalidValueMessage, valueSource) => {
1524
+ if (val == null && option.presetArg !== void 0) {
1525
+ val = option.presetArg;
1526
+ }
1527
+ const oldValue = this.getOptionValue(name);
1528
+ if (val !== null && option.parseArg) {
1529
+ val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1530
+ } else if (val !== null && option.variadic) {
1531
+ val = option._concatValue(val, oldValue);
1532
+ }
1533
+ if (val == null) {
1534
+ if (option.negate) {
1535
+ val = false;
1536
+ } else if (option.isBoolean() || option.optional) {
1537
+ val = true;
1538
+ } else {
1539
+ val = "";
1540
+ }
1541
+ }
1542
+ this.setOptionValueWithSource(name, val, valueSource);
1543
+ };
1544
+ this.on("option:" + oname, (val) => {
1545
+ const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1546
+ handleOptionValue(val, invalidValueMessage, "cli");
1547
+ });
1548
+ if (option.envVar) {
1549
+ this.on("optionEnv:" + oname, (val) => {
1550
+ const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1551
+ handleOptionValue(val, invalidValueMessage, "env");
1552
+ });
1553
+ }
1554
+ return this;
1555
+ }
1556
+ /**
1557
+ * Internal implementation shared by .option() and .requiredOption()
1558
+ *
1559
+ * @return {Command} `this` command for chaining
1560
+ * @private
1561
+ */
1562
+ _optionEx(config, flags, description, fn, defaultValue) {
1563
+ if (typeof flags === "object" && flags instanceof Option2) {
1564
+ throw new Error(
1565
+ "To add an Option object use addOption() instead of option() or requiredOption()"
1566
+ );
1567
+ }
1568
+ const option = this.createOption(flags, description);
1569
+ option.makeOptionMandatory(!!config.mandatory);
1570
+ if (typeof fn === "function") {
1571
+ option.default(defaultValue).argParser(fn);
1572
+ } else if (fn instanceof RegExp) {
1573
+ const regex = fn;
1574
+ fn = (val, def) => {
1575
+ const m3 = regex.exec(val);
1576
+ return m3 ? m3[0] : def;
1577
+ };
1578
+ option.default(defaultValue).argParser(fn);
1579
+ } else {
1580
+ option.default(fn);
1581
+ }
1582
+ return this.addOption(option);
1583
+ }
1584
+ /**
1585
+ * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
1586
+ *
1587
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
1588
+ * option-argument is indicated by `<>` and an optional option-argument by `[]`.
1589
+ *
1590
+ * See the README for more details, and see also addOption() and requiredOption().
1591
+ *
1592
+ * @example
1593
+ * program
1594
+ * .option('-p, --pepper', 'add pepper')
1595
+ * .option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
1596
+ * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
1597
+ * .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
1598
+ *
1599
+ * @param {string} flags
1600
+ * @param {string} [description]
1601
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1602
+ * @param {*} [defaultValue]
1603
+ * @return {Command} `this` command for chaining
1604
+ */
1605
+ option(flags, description, parseArg, defaultValue) {
1606
+ return this._optionEx({}, flags, description, parseArg, defaultValue);
1607
+ }
1608
+ /**
1609
+ * Add a required option which must have a value after parsing. This usually means
1610
+ * the option must be specified on the command line. (Otherwise the same as .option().)
1611
+ *
1612
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1613
+ *
1614
+ * @param {string} flags
1615
+ * @param {string} [description]
1616
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1617
+ * @param {*} [defaultValue]
1618
+ * @return {Command} `this` command for chaining
1619
+ */
1620
+ requiredOption(flags, description, parseArg, defaultValue) {
1621
+ return this._optionEx(
1622
+ { mandatory: true },
1623
+ flags,
1624
+ description,
1625
+ parseArg,
1626
+ defaultValue
1627
+ );
1628
+ }
1629
+ /**
1630
+ * Alter parsing of short flags with optional values.
1631
+ *
1632
+ * @example
1633
+ * // for `.option('-f,--flag [value]'):
1634
+ * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1635
+ * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1636
+ *
1637
+ * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
1638
+ * @return {Command} `this` command for chaining
1639
+ */
1640
+ combineFlagAndOptionalValue(combine = true) {
1641
+ this._combineFlagAndOptionalValue = !!combine;
1642
+ return this;
1643
+ }
1644
+ /**
1645
+ * Allow unknown options on the command line.
1646
+ *
1647
+ * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
1648
+ * @return {Command} `this` command for chaining
1649
+ */
1650
+ allowUnknownOption(allowUnknown = true) {
1651
+ this._allowUnknownOption = !!allowUnknown;
1652
+ return this;
1653
+ }
1654
+ /**
1655
+ * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1656
+ *
1657
+ * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
1658
+ * @return {Command} `this` command for chaining
1659
+ */
1660
+ allowExcessArguments(allowExcess = true) {
1661
+ this._allowExcessArguments = !!allowExcess;
1662
+ return this;
1663
+ }
1664
+ /**
1665
+ * Enable positional options. Positional means global options are specified before subcommands which lets
1666
+ * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1667
+ * The default behaviour is non-positional and global options may appear anywhere on the command line.
1668
+ *
1669
+ * @param {boolean} [positional]
1670
+ * @return {Command} `this` command for chaining
1671
+ */
1672
+ enablePositionalOptions(positional = true) {
1673
+ this._enablePositionalOptions = !!positional;
1674
+ return this;
1675
+ }
1676
+ /**
1677
+ * Pass through options that come after command-arguments rather than treat them as command-options,
1678
+ * so actual command-options come before command-arguments. Turning this on for a subcommand requires
1679
+ * positional options to have been enabled on the program (parent commands).
1680
+ * The default behaviour is non-positional and options may appear before or after command-arguments.
1681
+ *
1682
+ * @param {boolean} [passThrough] for unknown options.
1683
+ * @return {Command} `this` command for chaining
1684
+ */
1685
+ passThroughOptions(passThrough = true) {
1686
+ this._passThroughOptions = !!passThrough;
1687
+ this._checkForBrokenPassThrough();
1688
+ return this;
1689
+ }
1690
+ /**
1691
+ * @private
1692
+ */
1693
+ _checkForBrokenPassThrough() {
1694
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
1695
+ throw new Error(
1696
+ `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
1697
+ );
1698
+ }
1699
+ }
1700
+ /**
1701
+ * Whether to store option values as properties on command object,
1702
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
1703
+ *
1704
+ * @param {boolean} [storeAsProperties=true]
1705
+ * @return {Command} `this` command for chaining
1706
+ */
1707
+ storeOptionsAsProperties(storeAsProperties = true) {
1708
+ if (this.options.length) {
1709
+ throw new Error("call .storeOptionsAsProperties() before adding options");
1710
+ }
1711
+ if (Object.keys(this._optionValues).length) {
1712
+ throw new Error(
1713
+ "call .storeOptionsAsProperties() before setting option values"
1714
+ );
1715
+ }
1716
+ this._storeOptionsAsProperties = !!storeAsProperties;
1717
+ return this;
1718
+ }
1719
+ /**
1720
+ * Retrieve option value.
1721
+ *
1722
+ * @param {string} key
1723
+ * @return {object} value
1724
+ */
1725
+ getOptionValue(key) {
1726
+ if (this._storeOptionsAsProperties) {
1727
+ return this[key];
1728
+ }
1729
+ return this._optionValues[key];
1730
+ }
1731
+ /**
1732
+ * Store option value.
1733
+ *
1734
+ * @param {string} key
1735
+ * @param {object} value
1736
+ * @return {Command} `this` command for chaining
1737
+ */
1738
+ setOptionValue(key, value) {
1739
+ return this.setOptionValueWithSource(key, value, void 0);
1740
+ }
1741
+ /**
1742
+ * Store option value and where the value came from.
1743
+ *
1744
+ * @param {string} key
1745
+ * @param {object} value
1746
+ * @param {string} source - expected values are default/config/env/cli/implied
1747
+ * @return {Command} `this` command for chaining
1748
+ */
1749
+ setOptionValueWithSource(key, value, source) {
1750
+ if (this._storeOptionsAsProperties) {
1751
+ this[key] = value;
1752
+ } else {
1753
+ this._optionValues[key] = value;
1754
+ }
1755
+ this._optionValueSources[key] = source;
1756
+ return this;
1757
+ }
1758
+ /**
1759
+ * Get source of option value.
1760
+ * Expected values are default | config | env | cli | implied
1761
+ *
1762
+ * @param {string} key
1763
+ * @return {string}
1764
+ */
1765
+ getOptionValueSource(key) {
1766
+ return this._optionValueSources[key];
1767
+ }
1768
+ /**
1769
+ * Get source of option value. See also .optsWithGlobals().
1770
+ * Expected values are default | config | env | cli | implied
1771
+ *
1772
+ * @param {string} key
1773
+ * @return {string}
1774
+ */
1775
+ getOptionValueSourceWithGlobals(key) {
1776
+ let source;
1777
+ this._getCommandAndAncestors().forEach((cmd) => {
1778
+ if (cmd.getOptionValueSource(key) !== void 0) {
1779
+ source = cmd.getOptionValueSource(key);
1780
+ }
1781
+ });
1782
+ return source;
1783
+ }
1784
+ /**
1785
+ * Get user arguments from implied or explicit arguments.
1786
+ * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
1787
+ *
1788
+ * @private
1789
+ */
1790
+ _prepareUserArgs(argv, parseOptions) {
1791
+ if (argv !== void 0 && !Array.isArray(argv)) {
1792
+ throw new Error("first parameter to parse must be array or undefined");
1793
+ }
1794
+ parseOptions = parseOptions || {};
1795
+ if (argv === void 0 && parseOptions.from === void 0) {
1796
+ if (process2.versions?.electron) {
1797
+ parseOptions.from = "electron";
1798
+ }
1799
+ const execArgv = process2.execArgv ?? [];
1800
+ if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1801
+ parseOptions.from = "eval";
1802
+ }
1803
+ }
1804
+ if (argv === void 0) {
1805
+ argv = process2.argv;
1806
+ }
1807
+ this.rawArgs = argv.slice();
1808
+ let userArgs;
1809
+ switch (parseOptions.from) {
1810
+ case void 0:
1811
+ case "node":
1812
+ this._scriptPath = argv[1];
1813
+ userArgs = argv.slice(2);
1814
+ break;
1815
+ case "electron":
1816
+ if (process2.defaultApp) {
1817
+ this._scriptPath = argv[1];
1818
+ userArgs = argv.slice(2);
1819
+ } else {
1820
+ userArgs = argv.slice(1);
1821
+ }
1822
+ break;
1823
+ case "user":
1824
+ userArgs = argv.slice(0);
1825
+ break;
1826
+ case "eval":
1827
+ userArgs = argv.slice(1);
1828
+ break;
1829
+ default:
1830
+ throw new Error(
1831
+ `unexpected parse option { from: '${parseOptions.from}' }`
1832
+ );
1833
+ }
1834
+ if (!this._name && this._scriptPath)
1835
+ this.nameFromFilename(this._scriptPath);
1836
+ this._name = this._name || "program";
1837
+ return userArgs;
1838
+ }
1839
+ /**
1840
+ * Parse `argv`, setting options and invoking commands when defined.
1841
+ *
1842
+ * Use parseAsync instead of parse if any of your action handlers are async.
1843
+ *
1844
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1845
+ *
1846
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1847
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1848
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1849
+ * - `'user'`: just user arguments
1850
+ *
1851
+ * @example
1852
+ * program.parse(); // parse process.argv and auto-detect electron and special node flags
1853
+ * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
1854
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1855
+ *
1856
+ * @param {string[]} [argv] - optional, defaults to process.argv
1857
+ * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
1858
+ * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
1859
+ * @return {Command} `this` command for chaining
1860
+ */
1861
+ parse(argv, parseOptions) {
1862
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1863
+ this._parseCommand([], userArgs);
1864
+ return this;
1865
+ }
1866
+ /**
1867
+ * Parse `argv`, setting options and invoking commands when defined.
1868
+ *
1869
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1870
+ *
1871
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1872
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1873
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1874
+ * - `'user'`: just user arguments
1875
+ *
1876
+ * @example
1877
+ * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
1878
+ * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
1879
+ * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1880
+ *
1881
+ * @param {string[]} [argv]
1882
+ * @param {object} [parseOptions]
1883
+ * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
1884
+ * @return {Promise}
1885
+ */
1886
+ async parseAsync(argv, parseOptions) {
1887
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1888
+ await this._parseCommand([], userArgs);
1889
+ return this;
1890
+ }
1891
+ /**
1892
+ * Execute a sub-command executable.
1893
+ *
1894
+ * @private
1895
+ */
1896
+ _executeSubCommand(subcommand, args) {
1897
+ args = args.slice();
1898
+ let launchWithNode = false;
1899
+ const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1900
+ function findFile(baseDir, baseName) {
1901
+ const localBin = path4.resolve(baseDir, baseName);
1902
+ if (fs3.existsSync(localBin)) return localBin;
1903
+ if (sourceExt.includes(path4.extname(baseName))) return void 0;
1904
+ const foundExt = sourceExt.find(
1905
+ (ext) => fs3.existsSync(`${localBin}${ext}`)
1906
+ );
1907
+ if (foundExt) return `${localBin}${foundExt}`;
1908
+ return void 0;
1909
+ }
1910
+ this._checkForMissingMandatoryOptions();
1911
+ this._checkForConflictingOptions();
1912
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
1913
+ let executableDir = this._executableDir || "";
1914
+ if (this._scriptPath) {
1915
+ let resolvedScriptPath;
1916
+ try {
1917
+ resolvedScriptPath = fs3.realpathSync(this._scriptPath);
1918
+ } catch (err) {
1919
+ resolvedScriptPath = this._scriptPath;
1920
+ }
1921
+ executableDir = path4.resolve(
1922
+ path4.dirname(resolvedScriptPath),
1923
+ executableDir
1924
+ );
1925
+ }
1926
+ if (executableDir) {
1927
+ let localFile = findFile(executableDir, executableFile);
1928
+ if (!localFile && !subcommand._executableFile && this._scriptPath) {
1929
+ const legacyName = path4.basename(
1930
+ this._scriptPath,
1931
+ path4.extname(this._scriptPath)
1932
+ );
1933
+ if (legacyName !== this._name) {
1934
+ localFile = findFile(
1935
+ executableDir,
1936
+ `${legacyName}-${subcommand._name}`
1937
+ );
1938
+ }
1939
+ }
1940
+ executableFile = localFile || executableFile;
1941
+ }
1942
+ launchWithNode = sourceExt.includes(path4.extname(executableFile));
1943
+ let proc;
1944
+ if (process2.platform !== "win32") {
1945
+ if (launchWithNode) {
1946
+ args.unshift(executableFile);
1947
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1948
+ proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
1949
+ } else {
1950
+ proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1951
+ }
1952
+ } else {
1953
+ args.unshift(executableFile);
1954
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1955
+ proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
1956
+ }
1957
+ if (!proc.killed) {
1958
+ const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1959
+ signals.forEach((signal) => {
1960
+ process2.on(signal, () => {
1961
+ if (proc.killed === false && proc.exitCode === null) {
1962
+ proc.kill(signal);
1963
+ }
1964
+ });
1965
+ });
1966
+ }
1967
+ const exitCallback = this._exitCallback;
1968
+ proc.on("close", (code) => {
1969
+ code = code ?? 1;
1970
+ if (!exitCallback) {
1971
+ process2.exit(code);
1972
+ } else {
1973
+ exitCallback(
1974
+ new CommanderError2(
1975
+ code,
1976
+ "commander.executeSubCommandAsync",
1977
+ "(close)"
1978
+ )
1979
+ );
1980
+ }
1981
+ });
1982
+ proc.on("error", (err) => {
1983
+ if (err.code === "ENOENT") {
1984
+ const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
1985
+ const executableMissing = `'${executableFile}' does not exist
1986
+ - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
1987
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
1988
+ - ${executableDirMessage}`;
1989
+ throw new Error(executableMissing);
1990
+ } else if (err.code === "EACCES") {
1991
+ throw new Error(`'${executableFile}' not executable`);
1992
+ }
1993
+ if (!exitCallback) {
1994
+ process2.exit(1);
1995
+ } else {
1996
+ const wrappedError = new CommanderError2(
1997
+ 1,
1998
+ "commander.executeSubCommandAsync",
1999
+ "(error)"
2000
+ );
2001
+ wrappedError.nestedError = err;
2002
+ exitCallback(wrappedError);
2003
+ }
2004
+ });
2005
+ this.runningCommand = proc;
2006
+ }
2007
+ /**
2008
+ * @private
2009
+ */
2010
+ _dispatchSubcommand(commandName, operands, unknown) {
2011
+ const subCommand = this._findCommand(commandName);
2012
+ if (!subCommand) this.help({ error: true });
2013
+ let promiseChain;
2014
+ promiseChain = this._chainOrCallSubCommandHook(
2015
+ promiseChain,
2016
+ subCommand,
2017
+ "preSubcommand"
2018
+ );
2019
+ promiseChain = this._chainOrCall(promiseChain, () => {
2020
+ if (subCommand._executableHandler) {
2021
+ this._executeSubCommand(subCommand, operands.concat(unknown));
2022
+ } else {
2023
+ return subCommand._parseCommand(operands, unknown);
2024
+ }
2025
+ });
2026
+ return promiseChain;
2027
+ }
2028
+ /**
2029
+ * Invoke help directly if possible, or dispatch if necessary.
2030
+ * e.g. help foo
2031
+ *
2032
+ * @private
2033
+ */
2034
+ _dispatchHelpCommand(subcommandName) {
2035
+ if (!subcommandName) {
2036
+ this.help();
2037
+ }
2038
+ const subCommand = this._findCommand(subcommandName);
2039
+ if (subCommand && !subCommand._executableHandler) {
2040
+ subCommand.help();
2041
+ }
2042
+ return this._dispatchSubcommand(
2043
+ subcommandName,
2044
+ [],
2045
+ [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
2046
+ );
2047
+ }
2048
+ /**
2049
+ * Check this.args against expected this.registeredArguments.
2050
+ *
2051
+ * @private
2052
+ */
2053
+ _checkNumberOfArguments() {
2054
+ this.registeredArguments.forEach((arg, i) => {
2055
+ if (arg.required && this.args[i] == null) {
2056
+ this.missingArgument(arg.name());
2057
+ }
2058
+ });
2059
+ if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
2060
+ return;
2061
+ }
2062
+ if (this.args.length > this.registeredArguments.length) {
2063
+ this._excessArguments(this.args);
2064
+ }
2065
+ }
2066
+ /**
2067
+ * Process this.args using this.registeredArguments and save as this.processedArgs!
2068
+ *
2069
+ * @private
2070
+ */
2071
+ _processArguments() {
2072
+ const myParseArg = (argument, value, previous) => {
2073
+ let parsedValue = value;
2074
+ if (value !== null && argument.parseArg) {
2075
+ const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
2076
+ parsedValue = this._callParseArg(
2077
+ argument,
2078
+ value,
2079
+ previous,
2080
+ invalidValueMessage
2081
+ );
2082
+ }
2083
+ return parsedValue;
2084
+ };
2085
+ this._checkNumberOfArguments();
2086
+ const processedArgs = [];
2087
+ this.registeredArguments.forEach((declaredArg, index) => {
2088
+ let value = declaredArg.defaultValue;
2089
+ if (declaredArg.variadic) {
2090
+ if (index < this.args.length) {
2091
+ value = this.args.slice(index);
2092
+ if (declaredArg.parseArg) {
2093
+ value = value.reduce((processed, v3) => {
2094
+ return myParseArg(declaredArg, v3, processed);
2095
+ }, declaredArg.defaultValue);
2096
+ }
2097
+ } else if (value === void 0) {
2098
+ value = [];
2099
+ }
2100
+ } else if (index < this.args.length) {
2101
+ value = this.args[index];
2102
+ if (declaredArg.parseArg) {
2103
+ value = myParseArg(declaredArg, value, declaredArg.defaultValue);
2104
+ }
2105
+ }
2106
+ processedArgs[index] = value;
2107
+ });
2108
+ this.processedArgs = processedArgs;
2109
+ }
2110
+ /**
2111
+ * Once we have a promise we chain, but call synchronously until then.
2112
+ *
2113
+ * @param {(Promise|undefined)} promise
2114
+ * @param {Function} fn
2115
+ * @return {(Promise|undefined)}
2116
+ * @private
2117
+ */
2118
+ _chainOrCall(promise, fn) {
2119
+ if (promise && promise.then && typeof promise.then === "function") {
2120
+ return promise.then(() => fn());
2121
+ }
2122
+ return fn();
2123
+ }
2124
+ /**
2125
+ *
2126
+ * @param {(Promise|undefined)} promise
2127
+ * @param {string} event
2128
+ * @return {(Promise|undefined)}
2129
+ * @private
2130
+ */
2131
+ _chainOrCallHooks(promise, event) {
2132
+ let result = promise;
2133
+ const hooks = [];
2134
+ this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
2135
+ hookedCommand._lifeCycleHooks[event].forEach((callback) => {
2136
+ hooks.push({ hookedCommand, callback });
2137
+ });
2138
+ });
2139
+ if (event === "postAction") {
2140
+ hooks.reverse();
2141
+ }
2142
+ hooks.forEach((hookDetail) => {
2143
+ result = this._chainOrCall(result, () => {
2144
+ return hookDetail.callback(hookDetail.hookedCommand, this);
2145
+ });
2146
+ });
2147
+ return result;
2148
+ }
2149
+ /**
2150
+ *
2151
+ * @param {(Promise|undefined)} promise
2152
+ * @param {Command} subCommand
2153
+ * @param {string} event
2154
+ * @return {(Promise|undefined)}
2155
+ * @private
2156
+ */
2157
+ _chainOrCallSubCommandHook(promise, subCommand, event) {
2158
+ let result = promise;
2159
+ if (this._lifeCycleHooks[event] !== void 0) {
2160
+ this._lifeCycleHooks[event].forEach((hook) => {
2161
+ result = this._chainOrCall(result, () => {
2162
+ return hook(this, subCommand);
2163
+ });
2164
+ });
2165
+ }
2166
+ return result;
2167
+ }
2168
+ /**
2169
+ * Process arguments in context of this command.
2170
+ * Returns action result, in case it is a promise.
2171
+ *
2172
+ * @private
2173
+ */
2174
+ _parseCommand(operands, unknown) {
2175
+ const parsed = this.parseOptions(unknown);
2176
+ this._parseOptionsEnv();
2177
+ this._parseOptionsImplied();
2178
+ operands = operands.concat(parsed.operands);
2179
+ unknown = parsed.unknown;
2180
+ this.args = operands.concat(unknown);
2181
+ if (operands && this._findCommand(operands[0])) {
2182
+ return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
2183
+ }
2184
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
2185
+ return this._dispatchHelpCommand(operands[1]);
2186
+ }
2187
+ if (this._defaultCommandName) {
2188
+ this._outputHelpIfRequested(unknown);
2189
+ return this._dispatchSubcommand(
2190
+ this._defaultCommandName,
2191
+ operands,
2192
+ unknown
2193
+ );
2194
+ }
2195
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
2196
+ this.help({ error: true });
2197
+ }
2198
+ this._outputHelpIfRequested(parsed.unknown);
2199
+ this._checkForMissingMandatoryOptions();
2200
+ this._checkForConflictingOptions();
2201
+ const checkForUnknownOptions = () => {
2202
+ if (parsed.unknown.length > 0) {
2203
+ this.unknownOption(parsed.unknown[0]);
2204
+ }
2205
+ };
2206
+ const commandEvent = `command:${this.name()}`;
2207
+ if (this._actionHandler) {
2208
+ checkForUnknownOptions();
2209
+ this._processArguments();
2210
+ let promiseChain;
2211
+ promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
2212
+ promiseChain = this._chainOrCall(
2213
+ promiseChain,
2214
+ () => this._actionHandler(this.processedArgs)
2215
+ );
2216
+ if (this.parent) {
2217
+ promiseChain = this._chainOrCall(promiseChain, () => {
2218
+ this.parent.emit(commandEvent, operands, unknown);
2219
+ });
2220
+ }
2221
+ promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
2222
+ return promiseChain;
2223
+ }
2224
+ if (this.parent && this.parent.listenerCount(commandEvent)) {
2225
+ checkForUnknownOptions();
2226
+ this._processArguments();
2227
+ this.parent.emit(commandEvent, operands, unknown);
2228
+ } else if (operands.length) {
2229
+ if (this._findCommand("*")) {
2230
+ return this._dispatchSubcommand("*", operands, unknown);
2231
+ }
2232
+ if (this.listenerCount("command:*")) {
2233
+ this.emit("command:*", operands, unknown);
2234
+ } else if (this.commands.length) {
2235
+ this.unknownCommand();
2236
+ } else {
2237
+ checkForUnknownOptions();
2238
+ this._processArguments();
2239
+ }
2240
+ } else if (this.commands.length) {
2241
+ checkForUnknownOptions();
2242
+ this.help({ error: true });
2243
+ } else {
2244
+ checkForUnknownOptions();
2245
+ this._processArguments();
2246
+ }
2247
+ }
2248
+ /**
2249
+ * Find matching command.
2250
+ *
2251
+ * @private
2252
+ * @return {Command | undefined}
2253
+ */
2254
+ _findCommand(name) {
2255
+ if (!name) return void 0;
2256
+ return this.commands.find(
2257
+ (cmd) => cmd._name === name || cmd._aliases.includes(name)
2258
+ );
2259
+ }
2260
+ /**
2261
+ * Return an option matching `arg` if any.
2262
+ *
2263
+ * @param {string} arg
2264
+ * @return {Option}
2265
+ * @package
2266
+ */
2267
+ _findOption(arg) {
2268
+ return this.options.find((option) => option.is(arg));
2269
+ }
2270
+ /**
2271
+ * Display an error message if a mandatory option does not have a value.
2272
+ * Called after checking for help flags in leaf subcommand.
2273
+ *
2274
+ * @private
2275
+ */
2276
+ _checkForMissingMandatoryOptions() {
2277
+ this._getCommandAndAncestors().forEach((cmd) => {
2278
+ cmd.options.forEach((anOption) => {
2279
+ if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) {
2280
+ cmd.missingMandatoryOptionValue(anOption);
2281
+ }
2282
+ });
2283
+ });
2284
+ }
2285
+ /**
2286
+ * Display an error message if conflicting options are used together in this.
2287
+ *
2288
+ * @private
2289
+ */
2290
+ _checkForConflictingLocalOptions() {
2291
+ const definedNonDefaultOptions = this.options.filter((option) => {
2292
+ const optionKey = option.attributeName();
2293
+ if (this.getOptionValue(optionKey) === void 0) {
2294
+ return false;
2295
+ }
2296
+ return this.getOptionValueSource(optionKey) !== "default";
2297
+ });
2298
+ const optionsWithConflicting = definedNonDefaultOptions.filter(
2299
+ (option) => option.conflictsWith.length > 0
2300
+ );
2301
+ optionsWithConflicting.forEach((option) => {
2302
+ const conflictingAndDefined = definedNonDefaultOptions.find(
2303
+ (defined) => option.conflictsWith.includes(defined.attributeName())
2304
+ );
2305
+ if (conflictingAndDefined) {
2306
+ this._conflictingOption(option, conflictingAndDefined);
2307
+ }
2308
+ });
2309
+ }
2310
+ /**
2311
+ * Display an error message if conflicting options are used together.
2312
+ * Called after checking for help flags in leaf subcommand.
2313
+ *
2314
+ * @private
2315
+ */
2316
+ _checkForConflictingOptions() {
2317
+ this._getCommandAndAncestors().forEach((cmd) => {
2318
+ cmd._checkForConflictingLocalOptions();
2319
+ });
2320
+ }
2321
+ /**
2322
+ * Parse options from `argv` removing known options,
2323
+ * and return argv split into operands and unknown arguments.
2324
+ *
2325
+ * Examples:
2326
+ *
2327
+ * argv => operands, unknown
2328
+ * --known kkk op => [op], []
2329
+ * op --known kkk => [op], []
2330
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
2331
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
2332
+ *
2333
+ * @param {string[]} argv
2334
+ * @return {{operands: string[], unknown: string[]}}
2335
+ */
2336
+ parseOptions(argv) {
2337
+ const operands = [];
2338
+ const unknown = [];
2339
+ let dest = operands;
2340
+ const args = argv.slice();
2341
+ function maybeOption(arg) {
2342
+ return arg.length > 1 && arg[0] === "-";
2343
+ }
2344
+ let activeVariadicOption = null;
2345
+ while (args.length) {
2346
+ const arg = args.shift();
2347
+ if (arg === "--") {
2348
+ if (dest === unknown) dest.push(arg);
2349
+ dest.push(...args);
2350
+ break;
2351
+ }
2352
+ if (activeVariadicOption && !maybeOption(arg)) {
2353
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
2354
+ continue;
2355
+ }
2356
+ activeVariadicOption = null;
2357
+ if (maybeOption(arg)) {
2358
+ const option = this._findOption(arg);
2359
+ if (option) {
2360
+ if (option.required) {
2361
+ const value = args.shift();
2362
+ if (value === void 0) this.optionMissingArgument(option);
2363
+ this.emit(`option:${option.name()}`, value);
2364
+ } else if (option.optional) {
2365
+ let value = null;
2366
+ if (args.length > 0 && !maybeOption(args[0])) {
2367
+ value = args.shift();
2368
+ }
2369
+ this.emit(`option:${option.name()}`, value);
2370
+ } else {
2371
+ this.emit(`option:${option.name()}`);
2372
+ }
2373
+ activeVariadicOption = option.variadic ? option : null;
2374
+ continue;
2375
+ }
2376
+ }
2377
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
2378
+ const option = this._findOption(`-${arg[1]}`);
2379
+ if (option) {
2380
+ if (option.required || option.optional && this._combineFlagAndOptionalValue) {
2381
+ this.emit(`option:${option.name()}`, arg.slice(2));
2382
+ } else {
2383
+ this.emit(`option:${option.name()}`);
2384
+ args.unshift(`-${arg.slice(2)}`);
2385
+ }
2386
+ continue;
2387
+ }
2388
+ }
2389
+ if (/^--[^=]+=/.test(arg)) {
2390
+ const index = arg.indexOf("=");
2391
+ const option = this._findOption(arg.slice(0, index));
2392
+ if (option && (option.required || option.optional)) {
2393
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
2394
+ continue;
2395
+ }
2396
+ }
2397
+ if (maybeOption(arg)) {
2398
+ dest = unknown;
2399
+ }
2400
+ if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2401
+ if (this._findCommand(arg)) {
2402
+ operands.push(arg);
2403
+ if (args.length > 0) unknown.push(...args);
2404
+ break;
2405
+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
2406
+ operands.push(arg);
2407
+ if (args.length > 0) operands.push(...args);
2408
+ break;
2409
+ } else if (this._defaultCommandName) {
2410
+ unknown.push(arg);
2411
+ if (args.length > 0) unknown.push(...args);
2412
+ break;
2413
+ }
2414
+ }
2415
+ if (this._passThroughOptions) {
2416
+ dest.push(arg);
2417
+ if (args.length > 0) dest.push(...args);
2418
+ break;
2419
+ }
2420
+ dest.push(arg);
2421
+ }
2422
+ return { operands, unknown };
2423
+ }
2424
+ /**
2425
+ * Return an object containing local option values as key-value pairs.
2426
+ *
2427
+ * @return {object}
2428
+ */
2429
+ opts() {
2430
+ if (this._storeOptionsAsProperties) {
2431
+ const result = {};
2432
+ const len = this.options.length;
2433
+ for (let i = 0; i < len; i++) {
2434
+ const key = this.options[i].attributeName();
2435
+ result[key] = key === this._versionOptionName ? this._version : this[key];
2436
+ }
2437
+ return result;
2438
+ }
2439
+ return this._optionValues;
2440
+ }
2441
+ /**
2442
+ * Return an object containing merged local and global option values as key-value pairs.
2443
+ *
2444
+ * @return {object}
2445
+ */
2446
+ optsWithGlobals() {
2447
+ return this._getCommandAndAncestors().reduce(
2448
+ (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),
2449
+ {}
2450
+ );
2451
+ }
2452
+ /**
2453
+ * Display error message and exit (or call exitOverride).
2454
+ *
2455
+ * @param {string} message
2456
+ * @param {object} [errorOptions]
2457
+ * @param {string} [errorOptions.code] - an id string representing the error
2458
+ * @param {number} [errorOptions.exitCode] - used with process.exit
2459
+ */
2460
+ error(message, errorOptions) {
2461
+ this._outputConfiguration.outputError(
2462
+ `${message}
2463
+ `,
2464
+ this._outputConfiguration.writeErr
2465
+ );
2466
+ if (typeof this._showHelpAfterError === "string") {
2467
+ this._outputConfiguration.writeErr(`${this._showHelpAfterError}
2468
+ `);
2469
+ } else if (this._showHelpAfterError) {
2470
+ this._outputConfiguration.writeErr("\n");
2471
+ this.outputHelp({ error: true });
2472
+ }
2473
+ const config = errorOptions || {};
2474
+ const exitCode = config.exitCode || 1;
2475
+ const code = config.code || "commander.error";
2476
+ this._exit(exitCode, code, message);
2477
+ }
2478
+ /**
2479
+ * Apply any option related environment variables, if option does
2480
+ * not have a value from cli or client code.
2481
+ *
2482
+ * @private
2483
+ */
2484
+ _parseOptionsEnv() {
2485
+ this.options.forEach((option) => {
2486
+ if (option.envVar && option.envVar in process2.env) {
2487
+ const optionKey = option.attributeName();
2488
+ if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
2489
+ this.getOptionValueSource(optionKey)
2490
+ )) {
2491
+ if (option.required || option.optional) {
2492
+ this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
2493
+ } else {
2494
+ this.emit(`optionEnv:${option.name()}`);
2495
+ }
2496
+ }
2497
+ }
2498
+ });
2499
+ }
2500
+ /**
2501
+ * Apply any implied option values, if option is undefined or default value.
2502
+ *
2503
+ * @private
2504
+ */
2505
+ _parseOptionsImplied() {
2506
+ const dualHelper = new DualOptions(this.options);
2507
+ const hasCustomOptionValue = (optionKey) => {
2508
+ return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
2509
+ };
2510
+ this.options.filter(
2511
+ (option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(
2512
+ this.getOptionValue(option.attributeName()),
2513
+ option
2514
+ )
2515
+ ).forEach((option) => {
2516
+ Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
2517
+ this.setOptionValueWithSource(
2518
+ impliedKey,
2519
+ option.implied[impliedKey],
2520
+ "implied"
2521
+ );
2522
+ });
2523
+ });
2524
+ }
2525
+ /**
2526
+ * Argument `name` is missing.
2527
+ *
2528
+ * @param {string} name
2529
+ * @private
2530
+ */
2531
+ missingArgument(name) {
2532
+ const message = `error: missing required argument '${name}'`;
2533
+ this.error(message, { code: "commander.missingArgument" });
2534
+ }
2535
+ /**
2536
+ * `Option` is missing an argument.
2537
+ *
2538
+ * @param {Option} option
2539
+ * @private
2540
+ */
2541
+ optionMissingArgument(option) {
2542
+ const message = `error: option '${option.flags}' argument missing`;
2543
+ this.error(message, { code: "commander.optionMissingArgument" });
2544
+ }
2545
+ /**
2546
+ * `Option` does not have a value, and is a mandatory option.
2547
+ *
2548
+ * @param {Option} option
2549
+ * @private
2550
+ */
2551
+ missingMandatoryOptionValue(option) {
2552
+ const message = `error: required option '${option.flags}' not specified`;
2553
+ this.error(message, { code: "commander.missingMandatoryOptionValue" });
2554
+ }
2555
+ /**
2556
+ * `Option` conflicts with another option.
2557
+ *
2558
+ * @param {Option} option
2559
+ * @param {Option} conflictingOption
2560
+ * @private
2561
+ */
2562
+ _conflictingOption(option, conflictingOption) {
2563
+ const findBestOptionFromValue = (option2) => {
2564
+ const optionKey = option2.attributeName();
2565
+ const optionValue = this.getOptionValue(optionKey);
2566
+ const negativeOption = this.options.find(
2567
+ (target) => target.negate && optionKey === target.attributeName()
2568
+ );
2569
+ const positiveOption = this.options.find(
2570
+ (target) => !target.negate && optionKey === target.attributeName()
2571
+ );
2572
+ if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
2573
+ return negativeOption;
2574
+ }
2575
+ return positiveOption || option2;
2576
+ };
2577
+ const getErrorMessage = (option2) => {
2578
+ const bestOption = findBestOptionFromValue(option2);
2579
+ const optionKey = bestOption.attributeName();
2580
+ const source = this.getOptionValueSource(optionKey);
2581
+ if (source === "env") {
2582
+ return `environment variable '${bestOption.envVar}'`;
2583
+ }
2584
+ return `option '${bestOption.flags}'`;
2585
+ };
2586
+ const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2587
+ this.error(message, { code: "commander.conflictingOption" });
2588
+ }
2589
+ /**
2590
+ * Unknown option `flag`.
2591
+ *
2592
+ * @param {string} flag
2593
+ * @private
2594
+ */
2595
+ unknownOption(flag) {
2596
+ if (this._allowUnknownOption) return;
2597
+ let suggestion = "";
2598
+ if (flag.startsWith("--") && this._showSuggestionAfterError) {
2599
+ let candidateFlags = [];
2600
+ let command = this;
2601
+ do {
2602
+ const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
2603
+ candidateFlags = candidateFlags.concat(moreFlags);
2604
+ command = command.parent;
2605
+ } while (command && !command._enablePositionalOptions);
2606
+ suggestion = suggestSimilar(flag, candidateFlags);
2607
+ }
2608
+ const message = `error: unknown option '${flag}'${suggestion}`;
2609
+ this.error(message, { code: "commander.unknownOption" });
2610
+ }
2611
+ /**
2612
+ * Excess arguments, more than expected.
2613
+ *
2614
+ * @param {string[]} receivedArgs
2615
+ * @private
2616
+ */
2617
+ _excessArguments(receivedArgs) {
2618
+ if (this._allowExcessArguments) return;
2619
+ const expected = this.registeredArguments.length;
2620
+ const s = expected === 1 ? "" : "s";
2621
+ const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
2622
+ const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
2623
+ this.error(message, { code: "commander.excessArguments" });
2624
+ }
2625
+ /**
2626
+ * Unknown command.
2627
+ *
2628
+ * @private
2629
+ */
2630
+ unknownCommand() {
2631
+ const unknownName = this.args[0];
2632
+ let suggestion = "";
2633
+ if (this._showSuggestionAfterError) {
2634
+ const candidateNames = [];
2635
+ this.createHelp().visibleCommands(this).forEach((command) => {
2636
+ candidateNames.push(command.name());
2637
+ if (command.alias()) candidateNames.push(command.alias());
2638
+ });
2639
+ suggestion = suggestSimilar(unknownName, candidateNames);
2640
+ }
2641
+ const message = `error: unknown command '${unknownName}'${suggestion}`;
2642
+ this.error(message, { code: "commander.unknownCommand" });
2643
+ }
2644
+ /**
2645
+ * Get or set the program version.
2646
+ *
2647
+ * This method auto-registers the "-V, --version" option which will print the version number.
2648
+ *
2649
+ * You can optionally supply the flags and description to override the defaults.
2650
+ *
2651
+ * @param {string} [str]
2652
+ * @param {string} [flags]
2653
+ * @param {string} [description]
2654
+ * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
2655
+ */
2656
+ version(str, flags, description) {
2657
+ if (str === void 0) return this._version;
2658
+ this._version = str;
2659
+ flags = flags || "-V, --version";
2660
+ description = description || "output the version number";
2661
+ const versionOption = this.createOption(flags, description);
2662
+ this._versionOptionName = versionOption.attributeName();
2663
+ this._registerOption(versionOption);
2664
+ this.on("option:" + versionOption.name(), () => {
2665
+ this._outputConfiguration.writeOut(`${str}
2666
+ `);
2667
+ this._exit(0, "commander.version", str);
2668
+ });
2669
+ return this;
2670
+ }
2671
+ /**
2672
+ * Set the description.
2673
+ *
2674
+ * @param {string} [str]
2675
+ * @param {object} [argsDescription]
2676
+ * @return {(string|Command)}
2677
+ */
2678
+ description(str, argsDescription) {
2679
+ if (str === void 0 && argsDescription === void 0)
2680
+ return this._description;
2681
+ this._description = str;
2682
+ if (argsDescription) {
2683
+ this._argsDescription = argsDescription;
2684
+ }
2685
+ return this;
2686
+ }
2687
+ /**
2688
+ * Set the summary. Used when listed as subcommand of parent.
2689
+ *
2690
+ * @param {string} [str]
2691
+ * @return {(string|Command)}
2692
+ */
2693
+ summary(str) {
2694
+ if (str === void 0) return this._summary;
2695
+ this._summary = str;
2696
+ return this;
2697
+ }
2698
+ /**
2699
+ * Set an alias for the command.
2700
+ *
2701
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
2702
+ *
2703
+ * @param {string} [alias]
2704
+ * @return {(string|Command)}
2705
+ */
2706
+ alias(alias) {
2707
+ if (alias === void 0) return this._aliases[0];
2708
+ let command = this;
2709
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
2710
+ command = this.commands[this.commands.length - 1];
2711
+ }
2712
+ if (alias === command._name)
2713
+ throw new Error("Command alias can't be the same as its name");
2714
+ const matchingCommand = this.parent?._findCommand(alias);
2715
+ if (matchingCommand) {
2716
+ const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
2717
+ throw new Error(
2718
+ `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`
2719
+ );
2720
+ }
2721
+ command._aliases.push(alias);
2722
+ return this;
2723
+ }
2724
+ /**
2725
+ * Set aliases for the command.
2726
+ *
2727
+ * Only the first alias is shown in the auto-generated help.
2728
+ *
2729
+ * @param {string[]} [aliases]
2730
+ * @return {(string[]|Command)}
2731
+ */
2732
+ aliases(aliases) {
2733
+ if (aliases === void 0) return this._aliases;
2734
+ aliases.forEach((alias) => this.alias(alias));
2735
+ return this;
2736
+ }
2737
+ /**
2738
+ * Set / get the command usage `str`.
2739
+ *
2740
+ * @param {string} [str]
2741
+ * @return {(string|Command)}
2742
+ */
2743
+ usage(str) {
2744
+ if (str === void 0) {
2745
+ if (this._usage) return this._usage;
2746
+ const args = this.registeredArguments.map((arg) => {
2747
+ return humanReadableArgName(arg);
2748
+ });
2749
+ return [].concat(
2750
+ this.options.length || this._helpOption !== null ? "[options]" : [],
2751
+ this.commands.length ? "[command]" : [],
2752
+ this.registeredArguments.length ? args : []
2753
+ ).join(" ");
2754
+ }
2755
+ this._usage = str;
2756
+ return this;
2757
+ }
2758
+ /**
2759
+ * Get or set the name of the command.
2760
+ *
2761
+ * @param {string} [str]
2762
+ * @return {(string|Command)}
2763
+ */
2764
+ name(str) {
2765
+ if (str === void 0) return this._name;
2766
+ this._name = str;
2767
+ return this;
2768
+ }
2769
+ /**
2770
+ * Set the name of the command from script filename, such as process.argv[1],
2771
+ * or require.main.filename, or __filename.
2772
+ *
2773
+ * (Used internally and public although not documented in README.)
2774
+ *
2775
+ * @example
2776
+ * program.nameFromFilename(require.main.filename);
2777
+ *
2778
+ * @param {string} filename
2779
+ * @return {Command}
2780
+ */
2781
+ nameFromFilename(filename) {
2782
+ this._name = path4.basename(filename, path4.extname(filename));
2783
+ return this;
2784
+ }
2785
+ /**
2786
+ * Get or set the directory for searching for executable subcommands of this command.
2787
+ *
2788
+ * @example
2789
+ * program.executableDir(__dirname);
2790
+ * // or
2791
+ * program.executableDir('subcommands');
2792
+ *
2793
+ * @param {string} [path]
2794
+ * @return {(string|null|Command)}
2795
+ */
2796
+ executableDir(path5) {
2797
+ if (path5 === void 0) return this._executableDir;
2798
+ this._executableDir = path5;
2799
+ return this;
2800
+ }
2801
+ /**
2802
+ * Return program help documentation.
2803
+ *
2804
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
2805
+ * @return {string}
2806
+ */
2807
+ helpInformation(contextOptions) {
2808
+ const helper = this.createHelp();
2809
+ if (helper.helpWidth === void 0) {
2810
+ helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
2811
+ }
2812
+ return helper.formatHelp(this, helper);
2813
+ }
2814
+ /**
2815
+ * @private
2816
+ */
2817
+ _getHelpContext(contextOptions) {
2818
+ contextOptions = contextOptions || {};
2819
+ const context = { error: !!contextOptions.error };
2820
+ let write;
2821
+ if (context.error) {
2822
+ write = (arg) => this._outputConfiguration.writeErr(arg);
2823
+ } else {
2824
+ write = (arg) => this._outputConfiguration.writeOut(arg);
2825
+ }
2826
+ context.write = contextOptions.write || write;
2827
+ context.command = this;
2828
+ return context;
2829
+ }
2830
+ /**
2831
+ * Output help information for this command.
2832
+ *
2833
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2834
+ *
2835
+ * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2836
+ */
2837
+ outputHelp(contextOptions) {
2838
+ let deprecatedCallback;
2839
+ if (typeof contextOptions === "function") {
2840
+ deprecatedCallback = contextOptions;
2841
+ contextOptions = void 0;
2842
+ }
2843
+ const context = this._getHelpContext(contextOptions);
2844
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", context));
2845
+ this.emit("beforeHelp", context);
2846
+ let helpInformation = this.helpInformation(context);
2847
+ if (deprecatedCallback) {
2848
+ helpInformation = deprecatedCallback(helpInformation);
2849
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
2850
+ throw new Error("outputHelp callback must return a string or a Buffer");
2851
+ }
2852
+ }
2853
+ context.write(helpInformation);
2854
+ if (this._getHelpOption()?.long) {
2855
+ this.emit(this._getHelpOption().long);
2856
+ }
2857
+ this.emit("afterHelp", context);
2858
+ this._getCommandAndAncestors().forEach(
2859
+ (command) => command.emit("afterAllHelp", context)
2860
+ );
2861
+ }
2862
+ /**
2863
+ * You can pass in flags and a description to customise the built-in help option.
2864
+ * Pass in false to disable the built-in help option.
2865
+ *
2866
+ * @example
2867
+ * program.helpOption('-?, --help' 'show help'); // customise
2868
+ * program.helpOption(false); // disable
2869
+ *
2870
+ * @param {(string | boolean)} flags
2871
+ * @param {string} [description]
2872
+ * @return {Command} `this` command for chaining
2873
+ */
2874
+ helpOption(flags, description) {
2875
+ if (typeof flags === "boolean") {
2876
+ if (flags) {
2877
+ this._helpOption = this._helpOption ?? void 0;
2878
+ } else {
2879
+ this._helpOption = null;
2880
+ }
2881
+ return this;
2882
+ }
2883
+ flags = flags ?? "-h, --help";
2884
+ description = description ?? "display help for command";
2885
+ this._helpOption = this.createOption(flags, description);
2886
+ return this;
2887
+ }
2888
+ /**
2889
+ * Lazy create help option.
2890
+ * Returns null if has been disabled with .helpOption(false).
2891
+ *
2892
+ * @returns {(Option | null)} the help option
2893
+ * @package
2894
+ */
2895
+ _getHelpOption() {
2896
+ if (this._helpOption === void 0) {
2897
+ this.helpOption(void 0, void 0);
2898
+ }
2899
+ return this._helpOption;
2900
+ }
2901
+ /**
2902
+ * Supply your own option to use for the built-in help option.
2903
+ * This is an alternative to using helpOption() to customise the flags and description etc.
2904
+ *
2905
+ * @param {Option} option
2906
+ * @return {Command} `this` command for chaining
2907
+ */
2908
+ addHelpOption(option) {
2909
+ this._helpOption = option;
2910
+ return this;
2911
+ }
2912
+ /**
2913
+ * Output help information and exit.
2914
+ *
2915
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2916
+ *
2917
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2918
+ */
2919
+ help(contextOptions) {
2920
+ this.outputHelp(contextOptions);
2921
+ let exitCode = process2.exitCode || 0;
2922
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2923
+ exitCode = 1;
2924
+ }
2925
+ this._exit(exitCode, "commander.help", "(outputHelp)");
2926
+ }
2927
+ /**
2928
+ * Add additional text to be displayed with the built-in help.
2929
+ *
2930
+ * Position is 'before' or 'after' to affect just this command,
2931
+ * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
2932
+ *
2933
+ * @param {string} position - before or after built-in help
2934
+ * @param {(string | Function)} text - string to add, or a function returning a string
2935
+ * @return {Command} `this` command for chaining
2936
+ */
2937
+ addHelpText(position, text) {
2938
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
2939
+ if (!allowedValues.includes(position)) {
2940
+ throw new Error(`Unexpected value for position to addHelpText.
2941
+ Expecting one of '${allowedValues.join("', '")}'`);
2942
+ }
2943
+ const helpEvent = `${position}Help`;
2944
+ this.on(helpEvent, (context) => {
2945
+ let helpStr;
2946
+ if (typeof text === "function") {
2947
+ helpStr = text({ error: context.error, command: context.command });
2948
+ } else {
2949
+ helpStr = text;
2950
+ }
2951
+ if (helpStr) {
2952
+ context.write(`${helpStr}
2953
+ `);
2954
+ }
2955
+ });
2956
+ return this;
2957
+ }
2958
+ /**
2959
+ * Output help information if help flags specified
2960
+ *
2961
+ * @param {Array} args - array of options to search for help flags
2962
+ * @private
2963
+ */
2964
+ _outputHelpIfRequested(args) {
2965
+ const helpOption = this._getHelpOption();
2966
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
2967
+ if (helpRequested) {
2968
+ this.outputHelp();
2969
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
2970
+ }
2971
+ }
2972
+ };
2973
+ function incrementNodeInspectorPort(args) {
2974
+ return args.map((arg) => {
2975
+ if (!arg.startsWith("--inspect")) {
2976
+ return arg;
2977
+ }
2978
+ let debugOption;
2979
+ let debugHost = "127.0.0.1";
2980
+ let debugPort = "9229";
2981
+ let match;
2982
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
2983
+ debugOption = match[1];
2984
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2985
+ debugOption = match[1];
2986
+ if (/^\d+$/.test(match[3])) {
2987
+ debugPort = match[3];
2988
+ } else {
2989
+ debugHost = match[3];
2990
+ }
2991
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2992
+ debugOption = match[1];
2993
+ debugHost = match[3];
2994
+ debugPort = match[4];
2995
+ }
2996
+ if (debugOption && debugPort !== "0") {
2997
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
2998
+ }
2999
+ return arg;
3000
+ });
3001
+ }
3002
+ exports.Command = Command2;
3003
+ }
3004
+ });
3005
+
3006
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/index.js
3007
+ var require_commander = __commonJS({
3008
+ "node_modules/.pnpm/commander@12.1.0/node_modules/commander/index.js"(exports) {
3009
+ var { Argument: Argument2 } = require_argument();
3010
+ var { Command: Command2 } = require_command();
3011
+ var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
3012
+ var { Help: Help2 } = require_help();
3013
+ var { Option: Option2 } = require_option();
3014
+ exports.program = new Command2();
3015
+ exports.createCommand = (name) => new Command2(name);
3016
+ exports.createOption = (flags, description) => new Option2(flags, description);
3017
+ exports.createArgument = (name, description) => new Argument2(name, description);
3018
+ exports.Command = Command2;
3019
+ exports.Option = Option2;
3020
+ exports.Argument = Argument2;
3021
+ exports.Help = Help2;
3022
+ exports.CommanderError = CommanderError2;
3023
+ exports.InvalidArgumentError = InvalidArgumentError2;
3024
+ exports.InvalidOptionArgumentError = InvalidArgumentError2;
3025
+ }
3026
+ });
3027
+
3028
+ // node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
3029
+ var require_src = __commonJS({
3030
+ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
3031
+ "use strict";
3032
+ var ESC = "\x1B";
3033
+ var CSI = `${ESC}[`;
3034
+ var beep = "\x07";
3035
+ var cursor = {
3036
+ to(x2, y3) {
3037
+ if (!y3) return `${CSI}${x2 + 1}G`;
3038
+ return `${CSI}${y3 + 1};${x2 + 1}H`;
3039
+ },
3040
+ move(x2, y3) {
3041
+ let ret = "";
3042
+ if (x2 < 0) ret += `${CSI}${-x2}D`;
3043
+ else if (x2 > 0) ret += `${CSI}${x2}C`;
3044
+ if (y3 < 0) ret += `${CSI}${-y3}A`;
3045
+ else if (y3 > 0) ret += `${CSI}${y3}B`;
3046
+ return ret;
3047
+ },
3048
+ up: (count = 1) => `${CSI}${count}A`,
3049
+ down: (count = 1) => `${CSI}${count}B`,
3050
+ forward: (count = 1) => `${CSI}${count}C`,
3051
+ backward: (count = 1) => `${CSI}${count}D`,
3052
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
3053
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
3054
+ left: `${CSI}G`,
3055
+ hide: `${CSI}?25l`,
3056
+ show: `${CSI}?25h`,
3057
+ save: `${ESC}7`,
3058
+ restore: `${ESC}8`
3059
+ };
3060
+ var scroll = {
3061
+ up: (count = 1) => `${CSI}S`.repeat(count),
3062
+ down: (count = 1) => `${CSI}T`.repeat(count)
3063
+ };
3064
+ var erase = {
3065
+ screen: `${CSI}2J`,
3066
+ up: (count = 1) => `${CSI}1J`.repeat(count),
3067
+ down: (count = 1) => `${CSI}J`.repeat(count),
3068
+ line: `${CSI}2K`,
3069
+ lineEnd: `${CSI}K`,
3070
+ lineStart: `${CSI}1K`,
3071
+ lines(count) {
3072
+ let clear = "";
3073
+ for (let i = 0; i < count; i++)
3074
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
3075
+ if (count)
3076
+ clear += cursor.left;
3077
+ return clear;
3078
+ }
3079
+ };
3080
+ module.exports = { cursor, scroll, erase, beep };
3081
+ }
3082
+ });
3083
+
3084
+ // node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
3085
+ var require_picocolors = __commonJS({
3086
+ "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
3087
+ var p2 = process || {};
3088
+ var argv = p2.argv || [];
3089
+ var env = p2.env || {};
3090
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
3091
+ var formatter = (open, close, replace = open) => (input) => {
3092
+ let string = "" + input, index = string.indexOf(close, open.length);
3093
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
3094
+ };
3095
+ var replaceClose = (string, close, replace, index) => {
3096
+ let result = "", cursor = 0;
3097
+ do {
3098
+ result += string.substring(cursor, index) + replace;
3099
+ cursor = index + close.length;
3100
+ index = string.indexOf(close, cursor);
3101
+ } while (~index);
3102
+ return result + string.substring(cursor);
3103
+ };
3104
+ var createColors = (enabled = isColorSupported) => {
3105
+ let f = enabled ? formatter : () => String;
3106
+ return {
3107
+ isColorSupported: enabled,
3108
+ reset: f("\x1B[0m", "\x1B[0m"),
3109
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
3110
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
3111
+ italic: f("\x1B[3m", "\x1B[23m"),
3112
+ underline: f("\x1B[4m", "\x1B[24m"),
3113
+ inverse: f("\x1B[7m", "\x1B[27m"),
3114
+ hidden: f("\x1B[8m", "\x1B[28m"),
3115
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
3116
+ black: f("\x1B[30m", "\x1B[39m"),
3117
+ red: f("\x1B[31m", "\x1B[39m"),
3118
+ green: f("\x1B[32m", "\x1B[39m"),
3119
+ yellow: f("\x1B[33m", "\x1B[39m"),
3120
+ blue: f("\x1B[34m", "\x1B[39m"),
3121
+ magenta: f("\x1B[35m", "\x1B[39m"),
3122
+ cyan: f("\x1B[36m", "\x1B[39m"),
3123
+ white: f("\x1B[37m", "\x1B[39m"),
3124
+ gray: f("\x1B[90m", "\x1B[39m"),
3125
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
3126
+ bgRed: f("\x1B[41m", "\x1B[49m"),
3127
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
3128
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
3129
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
3130
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
3131
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
3132
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
3133
+ blackBright: f("\x1B[90m", "\x1B[39m"),
3134
+ redBright: f("\x1B[91m", "\x1B[39m"),
3135
+ greenBright: f("\x1B[92m", "\x1B[39m"),
3136
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
3137
+ blueBright: f("\x1B[94m", "\x1B[39m"),
3138
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
3139
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
3140
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
3141
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
3142
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
3143
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
3144
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
3145
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
3146
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
3147
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
3148
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
3149
+ };
3150
+ };
3151
+ module.exports = createColors();
3152
+ module.exports.createColors = createColors;
3153
+ }
3154
+ });
3155
+
3156
+ // node_modules/.pnpm/commander@12.1.0/node_modules/commander/esm.mjs
3157
+ var import_index = __toESM(require_commander(), 1);
3158
+ var {
3159
+ program,
3160
+ createCommand,
3161
+ createArgument,
3162
+ createOption,
3163
+ CommanderError,
3164
+ InvalidArgumentError,
3165
+ InvalidOptionArgumentError,
3166
+ // deprecated old name
3167
+ Command,
3168
+ Argument,
3169
+ Option,
3170
+ Help
3171
+ } = import_index.default;
3172
+
3173
+ // tools/cli/src/index.ts
3174
+ import fs2 from "node:fs";
3175
+ import path3 from "node:path";
3176
+ import os2 from "node:os";
3177
+
3178
+ // node_modules/.pnpm/@clack+core@0.4.1/node_modules/@clack/core/dist/index.mjs
3179
+ var import_sisteransi = __toESM(require_src(), 1);
3180
+ import { stdin as $, stdout as j } from "node:process";
3181
+ var import_picocolors = __toESM(require_picocolors(), 1);
3182
+ import M from "node:readline";
3183
+ import { WriteStream as U } from "node:tty";
3184
+ function J({ onlyFirst: t = false } = {}) {
3185
+ const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
3186
+ return new RegExp(F, t ? void 0 : "g");
3187
+ }
3188
+ var Q = J();
3189
+ function T(t) {
3190
+ if (typeof t != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);
3191
+ return t.replace(Q, "");
3192
+ }
3193
+ function O(t) {
3194
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3195
+ }
3196
+ var P = { exports: {} };
3197
+ (function(t) {
3198
+ var u2 = {};
3199
+ t.exports = u2, u2.eastAsianWidth = function(e2) {
3200
+ var s = e2.charCodeAt(0), i = e2.length == 2 ? e2.charCodeAt(1) : 0, D = s;
3201
+ return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D = s << 10 | i, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
3202
+ }, u2.characterLength = function(e2) {
3203
+ var s = this.eastAsianWidth(e2);
3204
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
3205
+ };
3206
+ function F(e2) {
3207
+ return e2.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
3208
+ }
3209
+ u2.length = function(e2) {
3210
+ for (var s = F(e2), i = 0, D = 0; D < s.length; D++) i = i + this.characterLength(s[D]);
3211
+ return i;
3212
+ }, u2.slice = function(e2, s, i) {
3213
+ textLen = u2.length(e2), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
3214
+ for (var D = "", C = 0, o = F(e2), E2 = 0; E2 < o.length; E2++) {
3215
+ var a2 = o[E2], n = u2.length(a2);
3216
+ if (C >= s - (n == 2 ? 1 : 0)) if (C + n <= i) D += a2;
3217
+ else break;
3218
+ C += n;
3219
+ }
3220
+ return D;
3221
+ };
3222
+ })(P);
3223
+ var X = P.exports;
3224
+ var DD = O(X);
3225
+ var uD = function() {
3226
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
3227
+ };
3228
+ var FD = O(uD);
3229
+ function A(t, u2 = {}) {
3230
+ if (typeof t != "string" || t.length === 0 || (u2 = { ambiguousIsNarrow: true, ...u2 }, t = T(t), t.length === 0)) return 0;
3231
+ t = t.replace(FD(), " ");
3232
+ const F = u2.ambiguousIsNarrow ? 1 : 2;
3233
+ let e2 = 0;
3234
+ for (const s of t) {
3235
+ const i = s.codePointAt(0);
3236
+ if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
3237
+ switch (DD.eastAsianWidth(s)) {
3238
+ case "F":
3239
+ case "W":
3240
+ e2 += 2;
3241
+ break;
3242
+ case "A":
3243
+ e2 += F;
3244
+ break;
3245
+ default:
3246
+ e2 += 1;
3247
+ }
3248
+ }
3249
+ return e2;
3250
+ }
3251
+ var m = 10;
3252
+ var L = (t = 0) => (u2) => `\x1B[${u2 + t}m`;
3253
+ var N = (t = 0) => (u2) => `\x1B[${38 + t};5;${u2}m`;
3254
+ var I = (t = 0) => (u2, F, e2) => `\x1B[${38 + t};2;${u2};${F};${e2}m`;
3255
+ var r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
3256
+ Object.keys(r.modifier);
3257
+ var tD = Object.keys(r.color);
3258
+ var eD = Object.keys(r.bgColor);
3259
+ [...tD, ...eD];
3260
+ function sD() {
3261
+ const t = /* @__PURE__ */ new Map();
3262
+ for (const [u2, F] of Object.entries(r)) {
3263
+ for (const [e2, s] of Object.entries(F)) r[e2] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[e2] = r[e2], t.set(s[0], s[1]);
3264
+ Object.defineProperty(r, u2, { value: F, enumerable: false });
3265
+ }
3266
+ return Object.defineProperty(r, "codes", { value: t, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = L(), r.color.ansi256 = N(), r.color.ansi16m = I(), r.bgColor.ansi = L(m), r.bgColor.ansi256 = N(m), r.bgColor.ansi16m = I(m), Object.defineProperties(r, { rgbToAnsi256: { value: (u2, F, e2) => u2 === F && F === e2 ? u2 < 8 ? 16 : u2 > 248 ? 231 : Math.round((u2 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u2 / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(e2 / 255 * 5), enumerable: false }, hexToRgb: { value: (u2) => {
3267
+ const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u2.toString(16));
3268
+ if (!F) return [0, 0, 0];
3269
+ let [e2] = F;
3270
+ e2.length === 3 && (e2 = [...e2].map((i) => i + i).join(""));
3271
+ const s = Number.parseInt(e2, 16);
3272
+ return [s >> 16 & 255, s >> 8 & 255, s & 255];
3273
+ }, enumerable: false }, hexToAnsi256: { value: (u2) => r.rgbToAnsi256(...r.hexToRgb(u2)), enumerable: false }, ansi256ToAnsi: { value: (u2) => {
3274
+ if (u2 < 8) return 30 + u2;
3275
+ if (u2 < 16) return 90 + (u2 - 8);
3276
+ let F, e2, s;
3277
+ if (u2 >= 232) F = ((u2 - 232) * 10 + 8) / 255, e2 = F, s = F;
3278
+ else {
3279
+ u2 -= 16;
3280
+ const C = u2 % 36;
3281
+ F = Math.floor(u2 / 36) / 5, e2 = Math.floor(C / 6) / 5, s = C % 6 / 5;
3282
+ }
3283
+ const i = Math.max(F, e2, s) * 2;
3284
+ if (i === 0) return 30;
3285
+ let D = 30 + (Math.round(s) << 2 | Math.round(e2) << 1 | Math.round(F));
3286
+ return i === 2 && (D += 60), D;
3287
+ }, enumerable: false }, rgbToAnsi: { value: (u2, F, e2) => r.ansi256ToAnsi(r.rgbToAnsi256(u2, F, e2)), enumerable: false }, hexToAnsi: { value: (u2) => r.ansi256ToAnsi(r.hexToAnsi256(u2)), enumerable: false } }), r;
3288
+ }
3289
+ var iD = sD();
3290
+ var v = /* @__PURE__ */ new Set(["\x1B", "\x9B"]);
3291
+ var CD = 39;
3292
+ var w = "\x07";
3293
+ var W = "[";
3294
+ var rD = "]";
3295
+ var R = "m";
3296
+ var y = `${rD}8;;`;
3297
+ var V = (t) => `${v.values().next().value}${W}${t}${R}`;
3298
+ var z = (t) => `${v.values().next().value}${y}${t}${w}`;
3299
+ var ED = (t) => t.split(" ").map((u2) => A(u2));
3300
+ var _ = (t, u2, F) => {
3301
+ const e2 = [...u2];
3302
+ let s = false, i = false, D = A(T(t[t.length - 1]));
3303
+ for (const [C, o] of e2.entries()) {
3304
+ const E2 = A(o);
3305
+ if (D + E2 <= F ? t[t.length - 1] += o : (t.push(o), D = 0), v.has(o) && (s = true, i = e2.slice(C + 1).join("").startsWith(y)), s) {
3306
+ i ? o === w && (s = false, i = false) : o === R && (s = false);
3307
+ continue;
3308
+ }
3309
+ D += E2, D === F && C < e2.length - 1 && (t.push(""), D = 0);
3310
+ }
3311
+ !D && t[t.length - 1].length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
3312
+ };
3313
+ var nD = (t) => {
3314
+ const u2 = t.split(" ");
3315
+ let F = u2.length;
3316
+ for (; F > 0 && !(A(u2[F - 1]) > 0); ) F--;
3317
+ return F === u2.length ? t : u2.slice(0, F).join(" ") + u2.slice(F).join("");
3318
+ };
3319
+ var oD = (t, u2, F = {}) => {
3320
+ if (F.trim !== false && t.trim() === "") return "";
3321
+ let e2 = "", s, i;
3322
+ const D = ED(t);
3323
+ let C = [""];
3324
+ for (const [E2, a2] of t.split(" ").entries()) {
3325
+ F.trim !== false && (C[C.length - 1] = C[C.length - 1].trimStart());
3326
+ let n = A(C[C.length - 1]);
3327
+ if (E2 !== 0 && (n >= u2 && (F.wordWrap === false || F.trim === false) && (C.push(""), n = 0), (n > 0 || F.trim === false) && (C[C.length - 1] += " ", n++)), F.hard && D[E2] > u2) {
3328
+ const B2 = u2 - n, p2 = 1 + Math.floor((D[E2] - B2 - 1) / u2);
3329
+ Math.floor((D[E2] - 1) / u2) < p2 && C.push(""), _(C, a2, u2);
3330
+ continue;
3331
+ }
3332
+ if (n + D[E2] > u2 && n > 0 && D[E2] > 0) {
3333
+ if (F.wordWrap === false && n < u2) {
3334
+ _(C, a2, u2);
3335
+ continue;
3336
+ }
3337
+ C.push("");
3338
+ }
3339
+ if (n + D[E2] > u2 && F.wordWrap === false) {
3340
+ _(C, a2, u2);
3341
+ continue;
3342
+ }
3343
+ C[C.length - 1] += a2;
3344
+ }
3345
+ F.trim !== false && (C = C.map((E2) => nD(E2)));
3346
+ const o = [...C.join(`
3347
+ `)];
3348
+ for (const [E2, a2] of o.entries()) {
3349
+ if (e2 += a2, v.has(a2)) {
3350
+ const { groups: B2 } = new RegExp(`(?:\\${W}(?<code>\\d+)m|\\${y}(?<uri>.*)${w})`).exec(o.slice(E2).join("")) || { groups: {} };
3351
+ if (B2.code !== void 0) {
3352
+ const p2 = Number.parseFloat(B2.code);
3353
+ s = p2 === CD ? void 0 : p2;
3354
+ } else B2.uri !== void 0 && (i = B2.uri.length === 0 ? void 0 : B2.uri);
3355
+ }
3356
+ const n = iD.codes.get(Number(s));
3357
+ o[E2 + 1] === `
3358
+ ` ? (i && (e2 += z("")), s && n && (e2 += V(n))) : a2 === `
3359
+ ` && (s && n && (e2 += V(s)), i && (e2 += z(i)));
3360
+ }
3361
+ return e2;
3362
+ };
3363
+ function G(t, u2, F) {
3364
+ return String(t).normalize().replace(/\r\n/g, `
3365
+ `).split(`
3366
+ `).map((e2) => oD(e2, u2, F)).join(`
3367
+ `);
3368
+ }
3369
+ var aD = ["up", "down", "left", "right", "space", "enter", "cancel"];
3370
+ var c = { actions: new Set(aD), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]) };
3371
+ function k(t, u2) {
3372
+ if (typeof t == "string") return c.aliases.get(t) === u2;
3373
+ for (const F of t) if (F !== void 0 && k(F, u2)) return true;
3374
+ return false;
3375
+ }
3376
+ function lD(t, u2) {
3377
+ if (t === u2) return;
3378
+ const F = t.split(`
3379
+ `), e2 = u2.split(`
3380
+ `), s = [];
3381
+ for (let i = 0; i < Math.max(F.length, e2.length); i++) F[i] !== e2[i] && s.push(i);
3382
+ return s;
3383
+ }
3384
+ var xD = globalThis.process.platform.startsWith("win");
3385
+ var S = Symbol("clack:cancel");
3386
+ function BD(t) {
3387
+ return t === S;
3388
+ }
3389
+ function d(t, u2) {
3390
+ const F = t;
3391
+ F.isTTY && F.setRawMode(u2);
3392
+ }
3393
+ var AD = Object.defineProperty;
3394
+ var pD = (t, u2, F) => u2 in t ? AD(t, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t[u2] = F;
3395
+ var h = (t, u2, F) => (pD(t, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
3396
+ var x = class {
3397
+ constructor(u2, F = true) {
3398
+ h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
3399
+ const { input: e2 = $, output: s = j, render: i, signal: D, ...C } = u2;
3400
+ this.opts = C, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = F, this._abortSignal = D, this.input = e2, this.output = s;
3401
+ }
3402
+ unsubscribe() {
3403
+ this._subscribers.clear();
3404
+ }
3405
+ setSubscriber(u2, F) {
3406
+ const e2 = this._subscribers.get(u2) ?? [];
3407
+ e2.push(F), this._subscribers.set(u2, e2);
3408
+ }
3409
+ on(u2, F) {
3410
+ this.setSubscriber(u2, { cb: F });
3411
+ }
3412
+ once(u2, F) {
3413
+ this.setSubscriber(u2, { cb: F, once: true });
3414
+ }
3415
+ emit(u2, ...F) {
3416
+ const e2 = this._subscribers.get(u2) ?? [], s = [];
3417
+ for (const i of e2) i.cb(...F), i.once && s.push(() => e2.splice(e2.indexOf(i), 1));
3418
+ for (const i of s) i();
3419
+ }
3420
+ prompt() {
3421
+ return new Promise((u2, F) => {
3422
+ if (this._abortSignal) {
3423
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u2(S);
3424
+ this._abortSignal.addEventListener("abort", () => {
3425
+ this.state = "cancel", this.close();
3426
+ }, { once: true });
3427
+ }
3428
+ const e2 = new U(0);
3429
+ e2._write = (s, i, D) => {
3430
+ this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
3431
+ }, this.input.pipe(e2), this.rl = M.createInterface({ input: this.input, output: e2, tabSize: 2, prompt: "", escapeCodeTimeout: 50 }), M.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== void 0 && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), d(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
3432
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), d(this.input, false), u2(this.value);
3433
+ }), this.once("cancel", () => {
3434
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), d(this.input, false), u2(S);
3435
+ });
3436
+ });
3437
+ }
3438
+ onKeypress(u2, F) {
3439
+ if (this.state === "error" && (this.state = "active"), F?.name && (!this._track && c.aliases.has(F.name) && this.emit("cursor", c.aliases.get(F.name)), c.actions.has(F.name) && this.emit("cursor", F.name)), u2 && (u2.toLowerCase() === "y" || u2.toLowerCase() === "n") && this.emit("confirm", u2.toLowerCase() === "y"), u2 === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u2 && this.emit("key", u2.toLowerCase()), F?.name === "return") {
3440
+ if (this.opts.validate) {
3441
+ const e2 = this.opts.validate(this.value);
3442
+ e2 && (this.error = e2 instanceof Error ? e2.message : e2, this.state = "error", this.rl?.write(this.value));
3443
+ }
3444
+ this.state !== "error" && (this.state = "submit");
3445
+ }
3446
+ k([u2, F?.name, F?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
3447
+ }
3448
+ close() {
3449
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
3450
+ `), d(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
3451
+ }
3452
+ restoreCursor() {
3453
+ const u2 = G(this._prevFrame, process.stdout.columns, { hard: true }).split(`
3454
+ `).length - 1;
3455
+ this.output.write(import_sisteransi.cursor.move(-999, u2 * -1));
3456
+ }
3457
+ render() {
3458
+ const u2 = G(this._render(this) ?? "", process.stdout.columns, { hard: true });
3459
+ if (u2 !== this._prevFrame) {
3460
+ if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
3461
+ else {
3462
+ const F = lD(this._prevFrame, u2);
3463
+ if (this.restoreCursor(), F && F?.length === 1) {
3464
+ const e2 = F[0];
3465
+ this.output.write(import_sisteransi.cursor.move(0, e2)), this.output.write(import_sisteransi.erase.lines(1));
3466
+ const s = u2.split(`
3467
+ `);
3468
+ this.output.write(s[e2]), this._prevFrame = u2, this.output.write(import_sisteransi.cursor.move(0, s.length - e2 - 1));
3469
+ return;
3470
+ }
3471
+ if (F && F?.length > 1) {
3472
+ const e2 = F[0];
3473
+ this.output.write(import_sisteransi.cursor.move(0, e2)), this.output.write(import_sisteransi.erase.down());
3474
+ const s = u2.split(`
3475
+ `).slice(e2);
3476
+ this.output.write(s.join(`
3477
+ `)), this._prevFrame = u2;
3478
+ return;
3479
+ }
3480
+ this.output.write(import_sisteransi.erase.down());
3481
+ }
3482
+ this.output.write(u2), this.state === "initial" && (this.state = "active"), this._prevFrame = u2;
3483
+ }
3484
+ }
3485
+ };
3486
+ var fD = class extends x {
3487
+ get cursor() {
3488
+ return this.value ? 0 : 1;
3489
+ }
3490
+ get _value() {
3491
+ return this.cursor === 0;
3492
+ }
3493
+ constructor(u2) {
3494
+ super(u2, false), this.value = !!u2.initialValue, this.on("value", () => {
3495
+ this.value = this._value;
3496
+ }), this.on("confirm", (F) => {
3497
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = F, this.state = "submit", this.close();
3498
+ }), this.on("cursor", () => {
3499
+ this.value = !this.value;
3500
+ });
3501
+ }
3502
+ };
3503
+ var SD = Object.defineProperty;
3504
+ var $D = (t, u2, F) => u2 in t ? SD(t, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t[u2] = F;
3505
+ var q = (t, u2, F) => ($D(t, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
3506
+ var jD = class extends x {
3507
+ constructor(u2) {
3508
+ super(u2, false), q(this, "options"), q(this, "cursor", 0), this.options = u2.options, this.cursor = this.options.findIndex(({ value: F }) => F === u2.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F) => {
3509
+ switch (F) {
3510
+ case "left":
3511
+ case "up":
3512
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
3513
+ break;
3514
+ case "down":
3515
+ case "right":
3516
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
3517
+ break;
3518
+ }
3519
+ this.changeValue();
3520
+ });
3521
+ }
3522
+ get _value() {
3523
+ return this.options[this.cursor];
3524
+ }
3525
+ changeValue() {
3526
+ this.value = this._value.value;
3527
+ }
3528
+ };
3529
+ var PD = class extends x {
3530
+ get valueWithCursor() {
3531
+ if (this.state === "submit") return this.value;
3532
+ if (this.cursor >= this.value.length) return `${this.value}\u2588`;
3533
+ const u2 = this.value.slice(0, this.cursor), [F, ...e2] = this.value.slice(this.cursor);
3534
+ return `${u2}${import_picocolors.default.inverse(F)}${e2.join("")}`;
3535
+ }
3536
+ get cursor() {
3537
+ return this._cursor;
3538
+ }
3539
+ constructor(u2) {
3540
+ super(u2), this.on("finalize", () => {
3541
+ this.value || (this.value = u2.defaultValue);
3542
+ });
3543
+ }
3544
+ };
3545
+
3546
+ // node_modules/.pnpm/@clack+prompts@0.9.1/node_modules/@clack/prompts/dist/index.mjs
3547
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
3548
+ var import_sisteransi2 = __toESM(require_src(), 1);
3549
+ import p from "node:process";
3550
+ function X2() {
3551
+ return p.platform !== "win32" ? p.env.TERM !== "linux" : !!p.env.CI || !!p.env.WT_SESSION || !!p.env.TERMINUS_SUBLIME || p.env.ConEmuTask === "{cmd::Cmder}" || p.env.TERM_PROGRAM === "Terminus-Sublime" || p.env.TERM_PROGRAM === "vscode" || p.env.TERM === "xterm-256color" || p.env.TERM === "alacritty" || p.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
3552
+ }
3553
+ var E = X2();
3554
+ var u = (s, n) => E ? s : n;
3555
+ var ee = u("\u25C6", "*");
3556
+ var A2 = u("\u25A0", "x");
3557
+ var B = u("\u25B2", "x");
3558
+ var S2 = u("\u25C7", "o");
3559
+ var te = u("\u250C", "T");
3560
+ var a = u("\u2502", "|");
3561
+ var m2 = u("\u2514", "\u2014");
3562
+ var j2 = u("\u25CF", ">");
3563
+ var R2 = u("\u25CB", " ");
3564
+ var V2 = u("\u25FB", "[\u2022]");
3565
+ var M2 = u("\u25FC", "[+]");
3566
+ var G2 = u("\u25FB", "[ ]");
3567
+ var se = u("\u25AA", "\u2022");
3568
+ var N2 = u("\u2500", "-");
3569
+ var re = u("\u256E", "+");
3570
+ var ie = u("\u251C", "+");
3571
+ var ne = u("\u256F", "+");
3572
+ var ae = u("\u25CF", "\u2022");
3573
+ var oe = u("\u25C6", "*");
3574
+ var ce = u("\u25B2", "!");
3575
+ var le = u("\u25A0", "x");
3576
+ var y2 = (s) => {
3577
+ switch (s) {
3578
+ case "initial":
3579
+ case "active":
3580
+ return import_picocolors2.default.cyan(ee);
3581
+ case "cancel":
3582
+ return import_picocolors2.default.red(A2);
3583
+ case "error":
3584
+ return import_picocolors2.default.yellow(B);
3585
+ case "submit":
3586
+ return import_picocolors2.default.green(S2);
3587
+ }
3588
+ };
3589
+ var k2 = (s) => {
3590
+ const { cursor: n, options: t, style: i } = s, r2 = s.maxItems ?? Number.POSITIVE_INFINITY, c2 = Math.max(process.stdout.rows - 4, 0), o = Math.min(c2, Math.max(r2, 5));
3591
+ let l2 = 0;
3592
+ n >= l2 + o - 3 ? l2 = Math.max(Math.min(n - o + 3, t.length - o), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
3593
+ const $2 = o < t.length && l2 > 0, d2 = o < t.length && l2 + o < t.length;
3594
+ return t.slice(l2, l2 + o).map((w2, b2, C) => {
3595
+ const I2 = b2 === 0 && $2, x2 = b2 === C.length - 1 && d2;
3596
+ return I2 || x2 ? import_picocolors2.default.dim("...") : i(w2, b2 + l2 === n);
3597
+ });
3598
+ };
3599
+ var ue = (s) => new PD({ validate: s.validate, placeholder: s.placeholder, defaultValue: s.defaultValue, initialValue: s.initialValue, render() {
3600
+ const n = `${import_picocolors2.default.gray(a)}
3601
+ ${y2(this.state)} ${s.message}
3602
+ `, t = s.placeholder ? import_picocolors2.default.inverse(s.placeholder[0]) + import_picocolors2.default.dim(s.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : t;
3603
+ switch (this.state) {
3604
+ case "error":
3605
+ return `${n.trim()}
3606
+ ${import_picocolors2.default.yellow(a)} ${i}
3607
+ ${import_picocolors2.default.yellow(m2)} ${import_picocolors2.default.yellow(this.error)}
3608
+ `;
3609
+ case "submit":
3610
+ return `${n}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.dim(this.value || s.placeholder)}`;
3611
+ case "cancel":
3612
+ return `${n}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
3613
+ ${import_picocolors2.default.gray(a)}` : ""}`;
3614
+ default:
3615
+ return `${n}${import_picocolors2.default.cyan(a)} ${i}
3616
+ ${import_picocolors2.default.cyan(m2)}
3617
+ `;
3618
+ }
3619
+ } }).prompt();
3620
+ var me = (s) => {
3621
+ const n = s.active ?? "Yes", t = s.inactive ?? "No";
3622
+ return new fD({ active: n, inactive: t, initialValue: s.initialValue ?? true, render() {
3623
+ const i = `${import_picocolors2.default.gray(a)}
3624
+ ${y2(this.state)} ${s.message}
3625
+ `, r2 = this.value ? n : t;
3626
+ switch (this.state) {
3627
+ case "submit":
3628
+ return `${i}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.dim(r2)}`;
3629
+ case "cancel":
3630
+ return `${i}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}
3631
+ ${import_picocolors2.default.gray(a)}`;
3632
+ default:
3633
+ return `${i}${import_picocolors2.default.cyan(a)} ${this.value ? `${import_picocolors2.default.green(j2)} ${n}` : `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(t)}` : `${import_picocolors2.default.green(j2)} ${t}`}
3634
+ ${import_picocolors2.default.cyan(m2)}
3635
+ `;
3636
+ }
3637
+ } }).prompt();
3638
+ };
3639
+ var de = (s) => {
3640
+ const n = (t, i) => {
3641
+ const r2 = t.label ?? String(t.value);
3642
+ switch (i) {
3643
+ case "selected":
3644
+ return `${import_picocolors2.default.dim(r2)}`;
3645
+ case "active":
3646
+ return `${import_picocolors2.default.green(j2)} ${r2} ${t.hint ? import_picocolors2.default.dim(`(${t.hint})`) : ""}`;
3647
+ case "cancelled":
3648
+ return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}`;
3649
+ default:
3650
+ return `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(r2)}`;
3651
+ }
3652
+ };
3653
+ return new jD({ options: s.options, initialValue: s.initialValue, render() {
3654
+ const t = `${import_picocolors2.default.gray(a)}
3655
+ ${y2(this.state)} ${s.message}
3656
+ `;
3657
+ switch (this.state) {
3658
+ case "submit":
3659
+ return `${t}${import_picocolors2.default.gray(a)} ${n(this.options[this.cursor], "selected")}`;
3660
+ case "cancel":
3661
+ return `${t}${import_picocolors2.default.gray(a)} ${n(this.options[this.cursor], "cancelled")}
3662
+ ${import_picocolors2.default.gray(a)}`;
3663
+ default:
3664
+ return `${t}${import_picocolors2.default.cyan(a)} ${k2({ cursor: this.cursor, options: this.options, maxItems: s.maxItems, style: (i, r2) => n(i, r2 ? "active" : "inactive") }).join(`
3665
+ ${import_picocolors2.default.cyan(a)} `)}
3666
+ ${import_picocolors2.default.cyan(m2)}
3667
+ `;
3668
+ }
3669
+ } }).prompt();
3670
+ };
3671
+ var ve = (s = "") => {
3672
+ process.stdout.write(`${import_picocolors2.default.gray(m2)} ${import_picocolors2.default.red(s)}
3673
+
3674
+ `);
3675
+ };
3676
+ var we = (s = "") => {
3677
+ process.stdout.write(`${import_picocolors2.default.gray(te)} ${s}
3678
+ `);
3679
+ };
3680
+ var fe = (s = "") => {
3681
+ process.stdout.write(`${import_picocolors2.default.gray(a)}
3682
+ ${import_picocolors2.default.gray(m2)} ${s}
3683
+
3684
+ `);
3685
+ };
3686
+ var v2 = { message: (s = "", { symbol: n = import_picocolors2.default.gray(a) } = {}) => {
3687
+ const t = [`${import_picocolors2.default.gray(a)}`];
3688
+ if (s) {
3689
+ const [i, ...r2] = s.split(`
3690
+ `);
3691
+ t.push(`${n} ${i}`, ...r2.map((c2) => `${import_picocolors2.default.gray(a)} ${c2}`));
3692
+ }
3693
+ process.stdout.write(`${t.join(`
3694
+ `)}
3695
+ `);
3696
+ }, info: (s) => {
3697
+ v2.message(s, { symbol: import_picocolors2.default.blue(ae) });
3698
+ }, success: (s) => {
3699
+ v2.message(s, { symbol: import_picocolors2.default.green(oe) });
3700
+ }, step: (s) => {
3701
+ v2.message(s, { symbol: import_picocolors2.default.green(S2) });
3702
+ }, warn: (s) => {
3703
+ v2.message(s, { symbol: import_picocolors2.default.yellow(ce) });
3704
+ }, warning: (s) => {
3705
+ v2.warn(s);
3706
+ }, error: (s) => {
3707
+ v2.message(s, { symbol: import_picocolors2.default.red(le) });
3708
+ } };
3709
+
3710
+ // tools/cli/src/commands/setup.ts
3711
+ import fs from "node:fs";
3712
+ import path from "node:path";
3713
+ import os from "node:os";
3714
+ function buildEnvContents(config) {
3715
+ const lines = [
3716
+ "# TrueCourse Environment Configuration",
3717
+ `# Generated by truecourse setup on ${(/* @__PURE__ */ new Date()).toISOString()}`,
3718
+ ""
3719
+ ];
3720
+ if (config.anthropicKey) {
3721
+ lines.push(`ANTHROPIC_API_KEY=${config.anthropicKey}`);
3722
+ }
3723
+ if (config.openaiKey) {
3724
+ lines.push(`OPENAI_API_KEY=${config.openaiKey}`);
3725
+ }
3726
+ if (config.langfusePublicKey && config.langfuseSecretKey) {
3727
+ lines.push("");
3728
+ lines.push("# Langfuse Tracing");
3729
+ lines.push(`LANGFUSE_PUBLIC_KEY=${config.langfusePublicKey}`);
3730
+ lines.push(`LANGFUSE_SECRET_KEY=${config.langfuseSecretKey}`);
3731
+ }
3732
+ lines.push("");
3733
+ return lines.join("\n");
3734
+ }
3735
+ async function runSetup() {
3736
+ we("Welcome to TrueCourse");
3737
+ const provider = await de({
3738
+ message: "Which LLM provider would you like to use?",
3739
+ options: [
3740
+ { value: "anthropic", label: "Anthropic (Claude)" },
3741
+ { value: "openai", label: "OpenAI (GPT)" },
3742
+ { value: "both", label: "Both Anthropic & OpenAI" },
3743
+ { value: "skip", label: "Skip for now" }
3744
+ ]
3745
+ });
3746
+ if (BD(provider)) {
3747
+ ve("Setup cancelled.");
3748
+ process.exit(0);
3749
+ }
3750
+ const config = {};
3751
+ if (provider === "anthropic" || provider === "both") {
3752
+ const anthropicKey = await ue({
3753
+ message: "Enter your Anthropic API key:",
3754
+ placeholder: "sk-ant-...",
3755
+ validate(value) {
3756
+ if (!value || value.trim().length === 0) {
3757
+ return "API key is required";
3758
+ }
3759
+ }
3760
+ });
3761
+ if (BD(anthropicKey)) {
3762
+ ve("Setup cancelled.");
3763
+ process.exit(0);
3764
+ }
3765
+ config.anthropicKey = anthropicKey;
3766
+ }
3767
+ if (provider === "openai" || provider === "both") {
3768
+ const openaiKey = await ue({
3769
+ message: "Enter your OpenAI API key:",
3770
+ placeholder: "sk-...",
3771
+ validate(value) {
3772
+ if (!value || value.trim().length === 0) {
3773
+ return "API key is required";
3774
+ }
3775
+ }
3776
+ });
3777
+ if (BD(openaiKey)) {
3778
+ ve("Setup cancelled.");
3779
+ process.exit(0);
3780
+ }
3781
+ config.openaiKey = openaiKey;
3782
+ }
3783
+ const useLangfuse = await me({
3784
+ message: "Would you like to enable Langfuse tracing?",
3785
+ initialValue: false
3786
+ });
3787
+ if (BD(useLangfuse)) {
3788
+ ve("Setup cancelled.");
3789
+ process.exit(0);
3790
+ }
3791
+ if (useLangfuse) {
3792
+ const langfusePublicKey = await ue({
3793
+ message: "Enter your Langfuse public key:",
3794
+ placeholder: "pk-lf-...",
3795
+ validate(value) {
3796
+ if (!value || value.trim().length === 0) {
3797
+ return "Public key is required";
3798
+ }
3799
+ }
3800
+ });
3801
+ if (BD(langfusePublicKey)) {
3802
+ ve("Setup cancelled.");
3803
+ process.exit(0);
3804
+ }
3805
+ const langfuseSecretKey = await ue({
3806
+ message: "Enter your Langfuse secret key:",
3807
+ placeholder: "sk-lf-...",
3808
+ validate(value) {
3809
+ if (!value || value.trim().length === 0) {
3810
+ return "Secret key is required";
3811
+ }
3812
+ }
3813
+ });
3814
+ if (BD(langfuseSecretKey)) {
3815
+ ve("Setup cancelled.");
3816
+ process.exit(0);
3817
+ }
3818
+ config.langfusePublicKey = langfusePublicKey;
3819
+ config.langfuseSecretKey = langfuseSecretKey;
3820
+ }
3821
+ const configDir = path.join(os.homedir(), ".truecourse");
3822
+ fs.mkdirSync(configDir, { recursive: true });
3823
+ const envPath = path.join(configDir, ".env");
3824
+ fs.writeFileSync(envPath, buildEnvContents(config), "utf-8");
3825
+ v2.success(`Configuration saved to ${envPath}`);
3826
+ v2.info("Embedded PostgreSQL will start automatically when the server runs.");
3827
+ v2.info("Database migrations are applied on server startup.");
3828
+ fe("Setup complete! Run `npx truecourse` to start.");
3829
+ }
3830
+
3831
+ // tools/cli/src/commands/start.ts
3832
+ import { spawn } from "node:child_process";
3833
+ import path2 from "node:path";
3834
+ import { fileURLToPath } from "node:url";
3835
+ var __dirname = path2.dirname(fileURLToPath(import.meta.url));
3836
+ async function runStart() {
3837
+ we("Starting TrueCourse");
3838
+ const serverPath = path2.join(__dirname, "server.mjs");
3839
+ v2.step(
3840
+ "Starting server (embedded PostgreSQL starts automatically)..."
3841
+ );
3842
+ const serverProcess = spawn(
3843
+ process.execPath,
3844
+ [serverPath],
3845
+ {
3846
+ stdio: "inherit",
3847
+ env: { ...process.env }
3848
+ }
3849
+ );
3850
+ serverProcess.on("error", (error) => {
3851
+ v2.error(`Failed to start server: ${error.message}`);
3852
+ process.exit(1);
3853
+ });
3854
+ serverProcess.on("close", (code) => {
3855
+ if (code !== null && code !== 0) {
3856
+ v2.error(`Server exited with code ${code}`);
3857
+ process.exit(code);
3858
+ }
3859
+ });
3860
+ const cleanup = () => {
3861
+ serverProcess.kill("SIGTERM");
3862
+ };
3863
+ process.on("SIGINT", cleanup);
3864
+ process.on("SIGTERM", cleanup);
3865
+ }
3866
+
3867
+ // tools/cli/src/index.ts
3868
+ var program2 = new Command();
3869
+ program2.name("truecourse").version("0.1.0").description("TrueCourse CLI - Setup and manage your TrueCourse instance");
3870
+ program2.command("setup").description("Run the setup wizard to configure TrueCourse").action(async () => {
3871
+ await runSetup();
3872
+ });
3873
+ program2.command("start").description("Start TrueCourse services").action(async () => {
3874
+ await runStart();
3875
+ });
3876
+ program2.action(async () => {
3877
+ const configDir = path3.join(os2.homedir(), ".truecourse");
3878
+ const envPath = path3.join(configDir, ".env");
3879
+ const isFirstRun = !fs2.existsSync(envPath);
3880
+ if (isFirstRun) {
3881
+ await runSetup();
3882
+ } else {
3883
+ await runStart();
3884
+ }
3885
+ });
3886
+ program2.parse();