e2sm 0.1.0 → 0.2.1

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.
package/dist/index.mjs ADDED
@@ -0,0 +1,3237 @@
1
+ #!/usr/bin/env node
2
+ import { inspect, stripVTControlCharacters } from "node:util";
3
+ import y, { stdin, stdout } from "node:process";
4
+ import * as g from "node:readline";
5
+ import O from "node:readline";
6
+ import { Writable } from "node:stream";
7
+ import { spawn } from "node:child_process";
8
+ import { access, readFile } from "node:fs/promises";
9
+
10
+ //#region rolldown:runtime
11
+ var __create = Object.create;
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __getProtoOf = Object.getPrototypeOf;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
+ key = keys[i];
22
+ if (!__hasOwnProp.call(to, key) && key !== except) {
23
+ __defProp(to, key, {
24
+ get: ((k$2) => from[k$2]).bind(null, key),
25
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
26
+ });
27
+ }
28
+ }
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
33
+ value: mod,
34
+ enumerable: true
35
+ }) : target, mod));
36
+
37
+ //#endregion
38
+ //#region node_modules/sisteransi/src/index.js
39
+ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40
+ const ESC = "\x1B";
41
+ const CSI = `${ESC}[`;
42
+ const beep = "\x07";
43
+ const cursor = {
44
+ to(x$2, y$2) {
45
+ if (!y$2) return `${CSI}${x$2 + 1}G`;
46
+ return `${CSI}${y$2 + 1};${x$2 + 1}H`;
47
+ },
48
+ move(x$2, y$2) {
49
+ let ret = "";
50
+ if (x$2 < 0) ret += `${CSI}${-x$2}D`;
51
+ else if (x$2 > 0) ret += `${CSI}${x$2}C`;
52
+ if (y$2 < 0) ret += `${CSI}${-y$2}A`;
53
+ else if (y$2 > 0) ret += `${CSI}${y$2}B`;
54
+ return ret;
55
+ },
56
+ up: (count = 1) => `${CSI}${count}A`,
57
+ down: (count = 1) => `${CSI}${count}B`,
58
+ forward: (count = 1) => `${CSI}${count}C`,
59
+ backward: (count = 1) => `${CSI}${count}D`,
60
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
61
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
62
+ left: `${CSI}G`,
63
+ hide: `${CSI}?25l`,
64
+ show: `${CSI}?25h`,
65
+ save: `${ESC}7`,
66
+ restore: `${ESC}8`
67
+ };
68
+ const scroll = {
69
+ up: (count = 1) => `${CSI}S`.repeat(count),
70
+ down: (count = 1) => `${CSI}T`.repeat(count)
71
+ };
72
+ const erase = {
73
+ screen: `${CSI}2J`,
74
+ up: (count = 1) => `${CSI}1J`.repeat(count),
75
+ down: (count = 1) => `${CSI}J`.repeat(count),
76
+ line: `${CSI}2K`,
77
+ lineEnd: `${CSI}K`,
78
+ lineStart: `${CSI}1K`,
79
+ lines(count) {
80
+ let clear = "";
81
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
82
+ if (count) clear += cursor.left;
83
+ return clear;
84
+ }
85
+ };
86
+ module.exports = {
87
+ cursor,
88
+ scroll,
89
+ erase,
90
+ beep
91
+ };
92
+ }));
93
+
94
+ //#endregion
95
+ //#region node_modules/picocolors/picocolors.js
96
+ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
97
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
98
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
99
+ let formatter = (open, close, replace = open) => (input) => {
100
+ let string = "" + input, index = string.indexOf(close, open.length);
101
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
102
+ };
103
+ let replaceClose = (string, close, replace, index) => {
104
+ let result = "", cursor = 0;
105
+ do {
106
+ result += string.substring(cursor, index) + replace;
107
+ cursor = index + close.length;
108
+ index = string.indexOf(close, cursor);
109
+ } while (~index);
110
+ return result + string.substring(cursor);
111
+ };
112
+ let createColors = (enabled = isColorSupported) => {
113
+ let f = enabled ? formatter : () => String;
114
+ return {
115
+ isColorSupported: enabled,
116
+ reset: f("\x1B[0m", "\x1B[0m"),
117
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
118
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
119
+ italic: f("\x1B[3m", "\x1B[23m"),
120
+ underline: f("\x1B[4m", "\x1B[24m"),
121
+ inverse: f("\x1B[7m", "\x1B[27m"),
122
+ hidden: f("\x1B[8m", "\x1B[28m"),
123
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
124
+ black: f("\x1B[30m", "\x1B[39m"),
125
+ red: f("\x1B[31m", "\x1B[39m"),
126
+ green: f("\x1B[32m", "\x1B[39m"),
127
+ yellow: f("\x1B[33m", "\x1B[39m"),
128
+ blue: f("\x1B[34m", "\x1B[39m"),
129
+ magenta: f("\x1B[35m", "\x1B[39m"),
130
+ cyan: f("\x1B[36m", "\x1B[39m"),
131
+ white: f("\x1B[37m", "\x1B[39m"),
132
+ gray: f("\x1B[90m", "\x1B[39m"),
133
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
134
+ bgRed: f("\x1B[41m", "\x1B[49m"),
135
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
136
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
137
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
138
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
139
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
140
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
141
+ blackBright: f("\x1B[90m", "\x1B[39m"),
142
+ redBright: f("\x1B[91m", "\x1B[39m"),
143
+ greenBright: f("\x1B[92m", "\x1B[39m"),
144
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
145
+ blueBright: f("\x1B[94m", "\x1B[39m"),
146
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
147
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
148
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
149
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
150
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
151
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
152
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
153
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
154
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
155
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
156
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
157
+ };
158
+ };
159
+ module.exports = createColors();
160
+ module.exports.createColors = createColors;
161
+ }));
162
+
163
+ //#endregion
164
+ //#region node_modules/@clack/core/dist/index.mjs
165
+ var import_src = require_src();
166
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
167
+ function DD({ onlyFirst: e$1 = !1 } = {}) {
168
+ const t = ["[\\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("|");
169
+ return new RegExp(t, e$1 ? void 0 : "g");
170
+ }
171
+ const uD = DD();
172
+ function P$1(e$1) {
173
+ if (typeof e$1 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e$1}\``);
174
+ return e$1.replace(uD, "");
175
+ }
176
+ function L$1(e$1) {
177
+ return e$1 && e$1.__esModule && Object.prototype.hasOwnProperty.call(e$1, "default") ? e$1.default : e$1;
178
+ }
179
+ var W$1 = { exports: {} };
180
+ (function(e$1) {
181
+ var u$1 = {};
182
+ e$1.exports = u$1, u$1.eastAsianWidth = function(F$1) {
183
+ var s = F$1.charCodeAt(0), i = F$1.length == 2 ? F$1.charCodeAt(1) : 0, D$1 = s;
184
+ return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D$1 = s << 10 | i, D$1 += 65536), D$1 == 12288 || 65281 <= D$1 && D$1 <= 65376 || 65504 <= D$1 && D$1 <= 65510 ? "F" : D$1 == 8361 || 65377 <= D$1 && D$1 <= 65470 || 65474 <= D$1 && D$1 <= 65479 || 65482 <= D$1 && D$1 <= 65487 || 65490 <= D$1 && D$1 <= 65495 || 65498 <= D$1 && D$1 <= 65500 || 65512 <= D$1 && D$1 <= 65518 ? "H" : 4352 <= D$1 && D$1 <= 4447 || 4515 <= D$1 && D$1 <= 4519 || 4602 <= D$1 && D$1 <= 4607 || 9001 <= D$1 && D$1 <= 9002 || 11904 <= D$1 && D$1 <= 11929 || 11931 <= D$1 && D$1 <= 12019 || 12032 <= D$1 && D$1 <= 12245 || 12272 <= D$1 && D$1 <= 12283 || 12289 <= D$1 && D$1 <= 12350 || 12353 <= D$1 && D$1 <= 12438 || 12441 <= D$1 && D$1 <= 12543 || 12549 <= D$1 && D$1 <= 12589 || 12593 <= D$1 && D$1 <= 12686 || 12688 <= D$1 && D$1 <= 12730 || 12736 <= D$1 && D$1 <= 12771 || 12784 <= D$1 && D$1 <= 12830 || 12832 <= D$1 && D$1 <= 12871 || 12880 <= D$1 && D$1 <= 13054 || 13056 <= D$1 && D$1 <= 19903 || 19968 <= D$1 && D$1 <= 42124 || 42128 <= D$1 && D$1 <= 42182 || 43360 <= D$1 && D$1 <= 43388 || 44032 <= D$1 && D$1 <= 55203 || 55216 <= D$1 && D$1 <= 55238 || 55243 <= D$1 && D$1 <= 55291 || 63744 <= D$1 && D$1 <= 64255 || 65040 <= D$1 && D$1 <= 65049 || 65072 <= D$1 && D$1 <= 65106 || 65108 <= D$1 && D$1 <= 65126 || 65128 <= D$1 && D$1 <= 65131 || 110592 <= D$1 && D$1 <= 110593 || 127488 <= D$1 && D$1 <= 127490 || 127504 <= D$1 && D$1 <= 127546 || 127552 <= D$1 && D$1 <= 127560 || 127568 <= D$1 && D$1 <= 127569 || 131072 <= D$1 && D$1 <= 194367 || 177984 <= D$1 && D$1 <= 196605 || 196608 <= D$1 && D$1 <= 262141 ? "W" : 32 <= D$1 && D$1 <= 126 || 162 <= D$1 && D$1 <= 163 || 165 <= D$1 && D$1 <= 166 || D$1 == 172 || D$1 == 175 || 10214 <= D$1 && D$1 <= 10221 || 10629 <= D$1 && D$1 <= 10630 ? "Na" : D$1 == 161 || D$1 == 164 || 167 <= D$1 && D$1 <= 168 || D$1 == 170 || 173 <= D$1 && D$1 <= 174 || 176 <= D$1 && D$1 <= 180 || 182 <= D$1 && D$1 <= 186 || 188 <= D$1 && D$1 <= 191 || D$1 == 198 || D$1 == 208 || 215 <= D$1 && D$1 <= 216 || 222 <= D$1 && D$1 <= 225 || D$1 == 230 || 232 <= D$1 && D$1 <= 234 || 236 <= D$1 && D$1 <= 237 || D$1 == 240 || 242 <= D$1 && D$1 <= 243 || 247 <= D$1 && D$1 <= 250 || D$1 == 252 || D$1 == 254 || D$1 == 257 || D$1 == 273 || D$1 == 275 || D$1 == 283 || 294 <= D$1 && D$1 <= 295 || D$1 == 299 || 305 <= D$1 && D$1 <= 307 || D$1 == 312 || 319 <= D$1 && D$1 <= 322 || D$1 == 324 || 328 <= D$1 && D$1 <= 331 || D$1 == 333 || 338 <= D$1 && D$1 <= 339 || 358 <= D$1 && D$1 <= 359 || D$1 == 363 || D$1 == 462 || D$1 == 464 || D$1 == 466 || D$1 == 468 || D$1 == 470 || D$1 == 472 || D$1 == 474 || D$1 == 476 || D$1 == 593 || D$1 == 609 || D$1 == 708 || D$1 == 711 || 713 <= D$1 && D$1 <= 715 || D$1 == 717 || D$1 == 720 || 728 <= D$1 && D$1 <= 731 || D$1 == 733 || D$1 == 735 || 768 <= D$1 && D$1 <= 879 || 913 <= D$1 && D$1 <= 929 || 931 <= D$1 && D$1 <= 937 || 945 <= D$1 && D$1 <= 961 || 963 <= D$1 && D$1 <= 969 || D$1 == 1025 || 1040 <= D$1 && D$1 <= 1103 || D$1 == 1105 || D$1 == 8208 || 8211 <= D$1 && D$1 <= 8214 || 8216 <= D$1 && D$1 <= 8217 || 8220 <= D$1 && D$1 <= 8221 || 8224 <= D$1 && D$1 <= 8226 || 8228 <= D$1 && D$1 <= 8231 || D$1 == 8240 || 8242 <= D$1 && D$1 <= 8243 || D$1 == 8245 || D$1 == 8251 || D$1 == 8254 || D$1 == 8308 || D$1 == 8319 || 8321 <= D$1 && D$1 <= 8324 || D$1 == 8364 || D$1 == 8451 || D$1 == 8453 || D$1 == 8457 || D$1 == 8467 || D$1 == 8470 || 8481 <= D$1 && D$1 <= 8482 || D$1 == 8486 || D$1 == 8491 || 8531 <= D$1 && D$1 <= 8532 || 8539 <= D$1 && D$1 <= 8542 || 8544 <= D$1 && D$1 <= 8555 || 8560 <= D$1 && D$1 <= 8569 || D$1 == 8585 || 8592 <= D$1 && D$1 <= 8601 || 8632 <= D$1 && D$1 <= 8633 || D$1 == 8658 || D$1 == 8660 || D$1 == 8679 || D$1 == 8704 || 8706 <= D$1 && D$1 <= 8707 || 8711 <= D$1 && D$1 <= 8712 || D$1 == 8715 || D$1 == 8719 || D$1 == 8721 || D$1 == 8725 || D$1 == 8730 || 8733 <= D$1 && D$1 <= 8736 || D$1 == 8739 || D$1 == 8741 || 8743 <= D$1 && D$1 <= 8748 || D$1 == 8750 || 8756 <= D$1 && D$1 <= 8759 || 8764 <= D$1 && D$1 <= 8765 || D$1 == 8776 || D$1 == 8780 || D$1 == 8786 || 8800 <= D$1 && D$1 <= 8801 || 8804 <= D$1 && D$1 <= 8807 || 8810 <= D$1 && D$1 <= 8811 || 8814 <= D$1 && D$1 <= 8815 || 8834 <= D$1 && D$1 <= 8835 || 8838 <= D$1 && D$1 <= 8839 || D$1 == 8853 || D$1 == 8857 || D$1 == 8869 || D$1 == 8895 || D$1 == 8978 || 9312 <= D$1 && D$1 <= 9449 || 9451 <= D$1 && D$1 <= 9547 || 9552 <= D$1 && D$1 <= 9587 || 9600 <= D$1 && D$1 <= 9615 || 9618 <= D$1 && D$1 <= 9621 || 9632 <= D$1 && D$1 <= 9633 || 9635 <= D$1 && D$1 <= 9641 || 9650 <= D$1 && D$1 <= 9651 || 9654 <= D$1 && D$1 <= 9655 || 9660 <= D$1 && D$1 <= 9661 || 9664 <= D$1 && D$1 <= 9665 || 9670 <= D$1 && D$1 <= 9672 || D$1 == 9675 || 9678 <= D$1 && D$1 <= 9681 || 9698 <= D$1 && D$1 <= 9701 || D$1 == 9711 || 9733 <= D$1 && D$1 <= 9734 || D$1 == 9737 || 9742 <= D$1 && D$1 <= 9743 || 9748 <= D$1 && D$1 <= 9749 || D$1 == 9756 || D$1 == 9758 || D$1 == 9792 || D$1 == 9794 || 9824 <= D$1 && D$1 <= 9825 || 9827 <= D$1 && D$1 <= 9829 || 9831 <= D$1 && D$1 <= 9834 || 9836 <= D$1 && D$1 <= 9837 || D$1 == 9839 || 9886 <= D$1 && D$1 <= 9887 || 9918 <= D$1 && D$1 <= 9919 || 9924 <= D$1 && D$1 <= 9933 || 9935 <= D$1 && D$1 <= 9953 || D$1 == 9955 || 9960 <= D$1 && D$1 <= 9983 || D$1 == 10045 || D$1 == 10071 || 10102 <= D$1 && D$1 <= 10111 || 11093 <= D$1 && D$1 <= 11097 || 12872 <= D$1 && D$1 <= 12879 || 57344 <= D$1 && D$1 <= 63743 || 65024 <= D$1 && D$1 <= 65039 || D$1 == 65533 || 127232 <= D$1 && D$1 <= 127242 || 127248 <= D$1 && D$1 <= 127277 || 127280 <= D$1 && D$1 <= 127337 || 127344 <= D$1 && D$1 <= 127386 || 917760 <= D$1 && D$1 <= 917999 || 983040 <= D$1 && D$1 <= 1048573 || 1048576 <= D$1 && D$1 <= 1114109 ? "A" : "N";
185
+ }, u$1.characterLength = function(F$1) {
186
+ var s = this.eastAsianWidth(F$1);
187
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
188
+ };
189
+ function t(F$1) {
190
+ return F$1.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
191
+ }
192
+ u$1.length = function(F$1) {
193
+ for (var s = t(F$1), i = 0, D$1 = 0; D$1 < s.length; D$1++) i = i + this.characterLength(s[D$1]);
194
+ return i;
195
+ }, u$1.slice = function(F$1, s, i) {
196
+ textLen = u$1.length(F$1), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
197
+ for (var D$1 = "", C$1 = 0, n = t(F$1), E = 0; E < n.length; E++) {
198
+ var a = n[E], o$1 = u$1.length(a);
199
+ if (C$1 >= s - (o$1 == 2 ? 1 : 0)) if (C$1 + o$1 <= i) D$1 += a;
200
+ else break;
201
+ C$1 += o$1;
202
+ }
203
+ return D$1;
204
+ };
205
+ })(W$1);
206
+ var tD = W$1.exports;
207
+ const eD = L$1(tD);
208
+ var FD = function() {
209
+ 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;
210
+ };
211
+ const sD = L$1(FD);
212
+ function p(e$1, u$1 = {}) {
213
+ if (typeof e$1 != "string" || e$1.length === 0 || (u$1 = {
214
+ ambiguousIsNarrow: !0,
215
+ ...u$1
216
+ }, e$1 = P$1(e$1), e$1.length === 0)) return 0;
217
+ e$1 = e$1.replace(sD(), " ");
218
+ const t = u$1.ambiguousIsNarrow ? 1 : 2;
219
+ let F$1 = 0;
220
+ for (const s of e$1) {
221
+ const i = s.codePointAt(0);
222
+ if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
223
+ switch (eD.eastAsianWidth(s)) {
224
+ case "F":
225
+ case "W":
226
+ F$1 += 2;
227
+ break;
228
+ case "A":
229
+ F$1 += t;
230
+ break;
231
+ default: F$1 += 1;
232
+ }
233
+ }
234
+ return F$1;
235
+ }
236
+ const w = 10, N = (e$1 = 0) => (u$1) => `\x1B[${u$1 + e$1}m`, I = (e$1 = 0) => (u$1) => `\x1B[${38 + e$1};5;${u$1}m`, R = (e$1 = 0) => (u$1, t, F$1) => `\x1B[${38 + e$1};2;${u$1};${t};${F$1}m`, r = {
237
+ modifier: {
238
+ reset: [0, 0],
239
+ bold: [1, 22],
240
+ dim: [2, 22],
241
+ italic: [3, 23],
242
+ underline: [4, 24],
243
+ overline: [53, 55],
244
+ inverse: [7, 27],
245
+ hidden: [8, 28],
246
+ strikethrough: [9, 29]
247
+ },
248
+ color: {
249
+ black: [30, 39],
250
+ red: [31, 39],
251
+ green: [32, 39],
252
+ yellow: [33, 39],
253
+ blue: [34, 39],
254
+ magenta: [35, 39],
255
+ cyan: [36, 39],
256
+ white: [37, 39],
257
+ blackBright: [90, 39],
258
+ gray: [90, 39],
259
+ grey: [90, 39],
260
+ redBright: [91, 39],
261
+ greenBright: [92, 39],
262
+ yellowBright: [93, 39],
263
+ blueBright: [94, 39],
264
+ magentaBright: [95, 39],
265
+ cyanBright: [96, 39],
266
+ whiteBright: [97, 39]
267
+ },
268
+ bgColor: {
269
+ bgBlack: [40, 49],
270
+ bgRed: [41, 49],
271
+ bgGreen: [42, 49],
272
+ bgYellow: [43, 49],
273
+ bgBlue: [44, 49],
274
+ bgMagenta: [45, 49],
275
+ bgCyan: [46, 49],
276
+ bgWhite: [47, 49],
277
+ bgBlackBright: [100, 49],
278
+ bgGray: [100, 49],
279
+ bgGrey: [100, 49],
280
+ bgRedBright: [101, 49],
281
+ bgGreenBright: [102, 49],
282
+ bgYellowBright: [103, 49],
283
+ bgBlueBright: [104, 49],
284
+ bgMagentaBright: [105, 49],
285
+ bgCyanBright: [106, 49],
286
+ bgWhiteBright: [107, 49]
287
+ }
288
+ };
289
+ Object.keys(r.modifier);
290
+ const iD = Object.keys(r.color), CD = Object.keys(r.bgColor);
291
+ [...iD, ...CD];
292
+ function rD() {
293
+ const e$1 = /* @__PURE__ */ new Map();
294
+ for (const [u$1, t] of Object.entries(r)) {
295
+ for (const [F$1, s] of Object.entries(t)) r[F$1] = {
296
+ open: `\x1B[${s[0]}m`,
297
+ close: `\x1B[${s[1]}m`
298
+ }, t[F$1] = r[F$1], e$1.set(s[0], s[1]);
299
+ Object.defineProperty(r, u$1, {
300
+ value: t,
301
+ enumerable: !1
302
+ });
303
+ }
304
+ return Object.defineProperty(r, "codes", {
305
+ value: e$1,
306
+ enumerable: !1
307
+ }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = N(), r.color.ansi256 = I(), r.color.ansi16m = R(), r.bgColor.ansi = N(w), r.bgColor.ansi256 = I(w), r.bgColor.ansi16m = R(w), Object.defineProperties(r, {
308
+ rgbToAnsi256: {
309
+ value: (u$1, t, F$1) => u$1 === t && t === F$1 ? u$1 < 8 ? 16 : u$1 > 248 ? 231 : Math.round((u$1 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u$1 / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F$1 / 255 * 5),
310
+ enumerable: !1
311
+ },
312
+ hexToRgb: {
313
+ value: (u$1) => {
314
+ const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u$1.toString(16));
315
+ if (!t) return [
316
+ 0,
317
+ 0,
318
+ 0
319
+ ];
320
+ let [F$1] = t;
321
+ F$1.length === 3 && (F$1 = [...F$1].map((i) => i + i).join(""));
322
+ const s = Number.parseInt(F$1, 16);
323
+ return [
324
+ s >> 16 & 255,
325
+ s >> 8 & 255,
326
+ s & 255
327
+ ];
328
+ },
329
+ enumerable: !1
330
+ },
331
+ hexToAnsi256: {
332
+ value: (u$1) => r.rgbToAnsi256(...r.hexToRgb(u$1)),
333
+ enumerable: !1
334
+ },
335
+ ansi256ToAnsi: {
336
+ value: (u$1) => {
337
+ if (u$1 < 8) return 30 + u$1;
338
+ if (u$1 < 16) return 90 + (u$1 - 8);
339
+ let t, F$1, s;
340
+ if (u$1 >= 232) t = ((u$1 - 232) * 10 + 8) / 255, F$1 = t, s = t;
341
+ else {
342
+ u$1 -= 16;
343
+ const C$1 = u$1 % 36;
344
+ t = Math.floor(u$1 / 36) / 5, F$1 = Math.floor(C$1 / 6) / 5, s = C$1 % 6 / 5;
345
+ }
346
+ const i = Math.max(t, F$1, s) * 2;
347
+ if (i === 0) return 30;
348
+ let D$1 = 30 + (Math.round(s) << 2 | Math.round(F$1) << 1 | Math.round(t));
349
+ return i === 2 && (D$1 += 60), D$1;
350
+ },
351
+ enumerable: !1
352
+ },
353
+ rgbToAnsi: {
354
+ value: (u$1, t, F$1) => r.ansi256ToAnsi(r.rgbToAnsi256(u$1, t, F$1)),
355
+ enumerable: !1
356
+ },
357
+ hexToAnsi: {
358
+ value: (u$1) => r.ansi256ToAnsi(r.hexToAnsi256(u$1)),
359
+ enumerable: !1
360
+ }
361
+ }), r;
362
+ }
363
+ const ED = rD(), d$1 = new Set(["\x1B", "›"]), oD = 39, y$1 = "\x07", V$1 = "[", nD = "]", G$1 = "m", _$1 = `${nD}8;;`, z = (e$1) => `${d$1.values().next().value}${V$1}${e$1}${G$1}`, K$1 = (e$1) => `${d$1.values().next().value}${_$1}${e$1}${y$1}`, aD = (e$1) => e$1.split(" ").map((u$1) => p(u$1)), k$1 = (e$1, u$1, t) => {
364
+ const F$1 = [...u$1];
365
+ let s = !1, i = !1, D$1 = p(P$1(e$1[e$1.length - 1]));
366
+ for (const [C$1, n] of F$1.entries()) {
367
+ const E = p(n);
368
+ if (D$1 + E <= t ? e$1[e$1.length - 1] += n : (e$1.push(n), D$1 = 0), d$1.has(n) && (s = !0, i = F$1.slice(C$1 + 1).join("").startsWith(_$1)), s) {
369
+ i ? n === y$1 && (s = !1, i = !1) : n === G$1 && (s = !1);
370
+ continue;
371
+ }
372
+ D$1 += E, D$1 === t && C$1 < F$1.length - 1 && (e$1.push(""), D$1 = 0);
373
+ }
374
+ !D$1 && e$1[e$1.length - 1].length > 0 && e$1.length > 1 && (e$1[e$1.length - 2] += e$1.pop());
375
+ }, hD = (e$1) => {
376
+ const u$1 = e$1.split(" ");
377
+ let t = u$1.length;
378
+ for (; t > 0 && !(p(u$1[t - 1]) > 0);) t--;
379
+ return t === u$1.length ? e$1 : u$1.slice(0, t).join(" ") + u$1.slice(t).join("");
380
+ }, lD = (e$1, u$1, t = {}) => {
381
+ if (t.trim !== !1 && e$1.trim() === "") return "";
382
+ let F$1 = "", s, i;
383
+ const D$1 = aD(e$1);
384
+ let C$1 = [""];
385
+ for (const [E, a] of e$1.split(" ").entries()) {
386
+ t.trim !== !1 && (C$1[C$1.length - 1] = C$1[C$1.length - 1].trimStart());
387
+ let o$1 = p(C$1[C$1.length - 1]);
388
+ if (E !== 0 && (o$1 >= u$1 && (t.wordWrap === !1 || t.trim === !1) && (C$1.push(""), o$1 = 0), (o$1 > 0 || t.trim === !1) && (C$1[C$1.length - 1] += " ", o$1++)), t.hard && D$1[E] > u$1) {
389
+ const c = u$1 - o$1, f = 1 + Math.floor((D$1[E] - c - 1) / u$1);
390
+ Math.floor((D$1[E] - 1) / u$1) < f && C$1.push(""), k$1(C$1, a, u$1);
391
+ continue;
392
+ }
393
+ if (o$1 + D$1[E] > u$1 && o$1 > 0 && D$1[E] > 0) {
394
+ if (t.wordWrap === !1 && o$1 < u$1) {
395
+ k$1(C$1, a, u$1);
396
+ continue;
397
+ }
398
+ C$1.push("");
399
+ }
400
+ if (o$1 + D$1[E] > u$1 && t.wordWrap === !1) {
401
+ k$1(C$1, a, u$1);
402
+ continue;
403
+ }
404
+ C$1[C$1.length - 1] += a;
405
+ }
406
+ t.trim !== !1 && (C$1 = C$1.map((E) => hD(E)));
407
+ const n = [...C$1.join(`
408
+ `)];
409
+ for (const [E, a] of n.entries()) {
410
+ if (F$1 += a, d$1.has(a)) {
411
+ const { groups: c } = (/* @__PURE__ */ new RegExp(`(?:\\${V$1}(?<code>\\d+)m|\\${_$1}(?<uri>.*)${y$1})`)).exec(n.slice(E).join("")) || { groups: {} };
412
+ if (c.code !== void 0) {
413
+ const f = Number.parseFloat(c.code);
414
+ s = f === oD ? void 0 : f;
415
+ } else c.uri !== void 0 && (i = c.uri.length === 0 ? void 0 : c.uri);
416
+ }
417
+ const o$1 = ED.codes.get(Number(s));
418
+ n[E + 1] === `
419
+ ` ? (i && (F$1 += K$1("")), s && o$1 && (F$1 += z(o$1))) : a === `
420
+ ` && (s && o$1 && (F$1 += z(s)), i && (F$1 += K$1(i)));
421
+ }
422
+ return F$1;
423
+ };
424
+ function Y$1(e$1, u$1, t) {
425
+ return String(e$1).normalize().replace(/\r\n/g, `
426
+ `).split(`
427
+ `).map((F$1) => lD(F$1, u$1, t)).join(`
428
+ `);
429
+ }
430
+ const B = {
431
+ actions: new Set([
432
+ "up",
433
+ "down",
434
+ "left",
435
+ "right",
436
+ "space",
437
+ "enter",
438
+ "cancel"
439
+ ]),
440
+ aliases: new Map([
441
+ ["k", "up"],
442
+ ["j", "down"],
443
+ ["h", "left"],
444
+ ["l", "right"],
445
+ ["", "cancel"],
446
+ ["escape", "cancel"]
447
+ ])
448
+ };
449
+ function $(e$1, u$1) {
450
+ if (typeof e$1 == "string") return B.aliases.get(e$1) === u$1;
451
+ for (const t of e$1) if (t !== void 0 && $(t, u$1)) return !0;
452
+ return !1;
453
+ }
454
+ function BD(e$1, u$1) {
455
+ if (e$1 === u$1) return;
456
+ const t = e$1.split(`
457
+ `), F$1 = u$1.split(`
458
+ `), s = [];
459
+ for (let i = 0; i < Math.max(t.length, F$1.length); i++) t[i] !== F$1[i] && s.push(i);
460
+ return s;
461
+ }
462
+ const AD = globalThis.process.platform.startsWith("win"), S = Symbol("clack:cancel");
463
+ function pD(e$1) {
464
+ return e$1 === S;
465
+ }
466
+ function m(e$1, u$1) {
467
+ const t = e$1;
468
+ t.isTTY && t.setRawMode(u$1);
469
+ }
470
+ function fD({ input: e$1 = stdin, output: u$1 = stdout, overwrite: t = !0, hideCursor: F$1 = !0 } = {}) {
471
+ const s = g.createInterface({
472
+ input: e$1,
473
+ output: u$1,
474
+ prompt: "",
475
+ tabSize: 1
476
+ });
477
+ g.emitKeypressEvents(e$1, s), e$1.isTTY && e$1.setRawMode(!0);
478
+ const i = (D$1, { name: C$1, sequence: n }) => {
479
+ if ($([
480
+ String(D$1),
481
+ C$1,
482
+ n
483
+ ], "cancel")) {
484
+ F$1 && u$1.write(import_src.cursor.show), process.exit(0);
485
+ return;
486
+ }
487
+ if (!t) return;
488
+ const a = C$1 === "return" ? 0 : -1, o$1 = C$1 === "return" ? -1 : 0;
489
+ g.moveCursor(u$1, a, o$1, () => {
490
+ g.clearLine(u$1, 1, () => {
491
+ e$1.once("keypress", i);
492
+ });
493
+ });
494
+ };
495
+ return F$1 && u$1.write(import_src.cursor.hide), e$1.once("keypress", i), () => {
496
+ e$1.off("keypress", i), F$1 && u$1.write(import_src.cursor.show), e$1.isTTY && !AD && e$1.setRawMode(!1), s.terminal = !1, s.close();
497
+ };
498
+ }
499
+ var gD = Object.defineProperty, vD = (e$1, u$1, t) => u$1 in e$1 ? gD(e$1, u$1, {
500
+ enumerable: !0,
501
+ configurable: !0,
502
+ writable: !0,
503
+ value: t
504
+ }) : e$1[u$1] = t, h = (e$1, u$1, t) => (vD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
505
+ var x$1 = class {
506
+ constructor(u$1, t = !0) {
507
+ h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", !1), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
508
+ const { input: F$1 = stdin, output: s = stdout, render: i, signal: D$1, ...C$1 } = u$1;
509
+ this.opts = C$1, 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 = t, this._abortSignal = D$1, this.input = F$1, this.output = s;
510
+ }
511
+ unsubscribe() {
512
+ this._subscribers.clear();
513
+ }
514
+ setSubscriber(u$1, t) {
515
+ const F$1 = this._subscribers.get(u$1) ?? [];
516
+ F$1.push(t), this._subscribers.set(u$1, F$1);
517
+ }
518
+ on(u$1, t) {
519
+ this.setSubscriber(u$1, { cb: t });
520
+ }
521
+ once(u$1, t) {
522
+ this.setSubscriber(u$1, {
523
+ cb: t,
524
+ once: !0
525
+ });
526
+ }
527
+ emit(u$1, ...t) {
528
+ const F$1 = this._subscribers.get(u$1) ?? [], s = [];
529
+ for (const i of F$1) i.cb(...t), i.once && s.push(() => F$1.splice(F$1.indexOf(i), 1));
530
+ for (const i of s) i();
531
+ }
532
+ prompt() {
533
+ return new Promise((u$1, t) => {
534
+ if (this._abortSignal) {
535
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u$1(S);
536
+ this._abortSignal.addEventListener("abort", () => {
537
+ this.state = "cancel", this.close();
538
+ }, { once: !0 });
539
+ }
540
+ const F$1 = new Writable();
541
+ F$1._write = (s, i, D$1) => {
542
+ this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D$1();
543
+ }, this.input.pipe(F$1), this.rl = O.createInterface({
544
+ input: this.input,
545
+ output: F$1,
546
+ tabSize: 2,
547
+ prompt: "",
548
+ escapeCodeTimeout: 50,
549
+ terminal: !0
550
+ }), O.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), m(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
551
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), m(this.input, !1), u$1(this.value);
552
+ }), this.once("cancel", () => {
553
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), m(this.input, !1), u$1(S);
554
+ });
555
+ });
556
+ }
557
+ onKeypress(u$1, t) {
558
+ if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.name)), u$1 && (u$1.toLowerCase() === "y" || u$1.toLowerCase() === "n") && this.emit("confirm", u$1.toLowerCase() === "y"), u$1 === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u$1 && this.emit("key", u$1.toLowerCase()), t?.name === "return") {
559
+ if (this.opts.validate) {
560
+ const F$1 = this.opts.validate(this.value);
561
+ F$1 && (this.error = F$1 instanceof Error ? F$1.message : F$1, this.state = "error", this.rl?.write(this.value));
562
+ }
563
+ this.state !== "error" && (this.state = "submit");
564
+ }
565
+ $([
566
+ u$1,
567
+ t?.name,
568
+ t?.sequence
569
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
570
+ }
571
+ close() {
572
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
573
+ `), m(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
574
+ }
575
+ restoreCursor() {
576
+ const u$1 = Y$1(this._prevFrame, process.stdout.columns, { hard: !0 }).split(`
577
+ `).length - 1;
578
+ this.output.write(import_src.cursor.move(-999, u$1 * -1));
579
+ }
580
+ render() {
581
+ const u$1 = Y$1(this._render(this) ?? "", process.stdout.columns, { hard: !0 });
582
+ if (u$1 !== this._prevFrame) {
583
+ if (this.state === "initial") this.output.write(import_src.cursor.hide);
584
+ else {
585
+ const t = BD(this._prevFrame, u$1);
586
+ if (this.restoreCursor(), t && t?.length === 1) {
587
+ const F$1 = t[0];
588
+ this.output.write(import_src.cursor.move(0, F$1)), this.output.write(import_src.erase.lines(1));
589
+ const s = u$1.split(`
590
+ `);
591
+ this.output.write(s[F$1]), this._prevFrame = u$1, this.output.write(import_src.cursor.move(0, s.length - F$1 - 1));
592
+ return;
593
+ }
594
+ if (t && t?.length > 1) {
595
+ const F$1 = t[0];
596
+ this.output.write(import_src.cursor.move(0, F$1)), this.output.write(import_src.erase.down());
597
+ const s = u$1.split(`
598
+ `).slice(F$1);
599
+ this.output.write(s.join(`
600
+ `)), this._prevFrame = u$1;
601
+ return;
602
+ }
603
+ this.output.write(import_src.erase.down());
604
+ }
605
+ this.output.write(u$1), this.state === "initial" && (this.state = "active"), this._prevFrame = u$1;
606
+ }
607
+ }
608
+ };
609
+ var dD = class extends x$1 {
610
+ get cursor() {
611
+ return this.value ? 0 : 1;
612
+ }
613
+ get _value() {
614
+ return this.cursor === 0;
615
+ }
616
+ constructor(u$1) {
617
+ super(u$1, !1), this.value = !!u$1.initialValue, this.on("value", () => {
618
+ this.value = this._value;
619
+ }), this.on("confirm", (t) => {
620
+ this.output.write(import_src.cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
621
+ }), this.on("cursor", () => {
622
+ this.value = !this.value;
623
+ });
624
+ }
625
+ };
626
+ var mD = Object.defineProperty, bD = (e$1, u$1, t) => u$1 in e$1 ? mD(e$1, u$1, {
627
+ enumerable: !0,
628
+ configurable: !0,
629
+ writable: !0,
630
+ value: t
631
+ }) : e$1[u$1] = t, Z = (e$1, u$1, t) => (bD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t), q$1 = (e$1, u$1, t) => {
632
+ if (!u$1.has(e$1)) throw TypeError("Cannot " + t);
633
+ }, T$1 = (e$1, u$1, t) => (q$1(e$1, u$1, "read from private field"), t ? t.call(e$1) : u$1.get(e$1)), wD = (e$1, u$1, t) => {
634
+ if (u$1.has(e$1)) throw TypeError("Cannot add the same private member more than once");
635
+ u$1 instanceof WeakSet ? u$1.add(e$1) : u$1.set(e$1, t);
636
+ }, yD = (e$1, u$1, t, F$1) => (q$1(e$1, u$1, "write to private field"), F$1 ? F$1.call(e$1, t) : u$1.set(e$1, t), t), A$1;
637
+ let _D = class extends x$1 {
638
+ constructor(u$1) {
639
+ super(u$1, !1), Z(this, "options"), Z(this, "cursor", 0), wD(this, A$1, void 0);
640
+ const { options: t } = u$1;
641
+ yD(this, A$1, u$1.selectableGroups !== !1), this.options = Object.entries(t).flatMap(([F$1, s]) => [{
642
+ value: F$1,
643
+ group: !0,
644
+ label: F$1
645
+ }, ...s.map((i) => ({
646
+ ...i,
647
+ group: F$1
648
+ }))]), this.value = [...u$1.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F$1 }) => F$1 === u$1.cursorAt), T$1(this, A$1) ? 0 : 1), this.on("cursor", (F$1) => {
649
+ switch (F$1) {
650
+ case "left":
651
+ case "up": {
652
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
653
+ const s = this.options[this.cursor]?.group === !0;
654
+ !T$1(this, A$1) && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
655
+ break;
656
+ }
657
+ case "down":
658
+ case "right": {
659
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
660
+ const s = this.options[this.cursor]?.group === !0;
661
+ !T$1(this, A$1) && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
662
+ break;
663
+ }
664
+ case "space":
665
+ this.toggleValue();
666
+ break;
667
+ }
668
+ });
669
+ }
670
+ getGroupItems(u$1) {
671
+ return this.options.filter((t) => t.group === u$1);
672
+ }
673
+ isGroupSelected(u$1) {
674
+ return this.getGroupItems(u$1).every((t) => this.value.includes(t.value));
675
+ }
676
+ toggleValue() {
677
+ const u$1 = this.options[this.cursor];
678
+ if (u$1.group === !0) {
679
+ const t = u$1.value, F$1 = this.getGroupItems(t);
680
+ this.isGroupSelected(t) ? this.value = this.value.filter((s) => F$1.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...F$1.map((s) => s.value)], this.value = Array.from(new Set(this.value));
681
+ } else this.value = this.value.includes(u$1.value) ? this.value.filter((F$1) => F$1 !== u$1.value) : [...this.value, u$1.value];
682
+ }
683
+ };
684
+ A$1 = /* @__PURE__ */ new WeakMap();
685
+ var kD = Object.defineProperty, $D = (e$1, u$1, t) => u$1 in e$1 ? kD(e$1, u$1, {
686
+ enumerable: !0,
687
+ configurable: !0,
688
+ writable: !0,
689
+ value: t
690
+ }) : e$1[u$1] = t, H = (e$1, u$1, t) => ($D(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
691
+ let SD = class extends x$1 {
692
+ constructor(u$1) {
693
+ super(u$1, !1), H(this, "options"), H(this, "cursor", 0), this.options = u$1.options, this.value = [...u$1.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u$1.cursorAt), 0), this.on("key", (t) => {
694
+ t === "a" && this.toggleAll();
695
+ }), this.on("cursor", (t) => {
696
+ switch (t) {
697
+ case "left":
698
+ case "up":
699
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
700
+ break;
701
+ case "down":
702
+ case "right":
703
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
704
+ break;
705
+ case "space":
706
+ this.toggleValue();
707
+ break;
708
+ }
709
+ });
710
+ }
711
+ get _value() {
712
+ return this.options[this.cursor].value;
713
+ }
714
+ toggleAll() {
715
+ this.value = this.value.length === this.options.length ? [] : this.options.map((t) => t.value);
716
+ }
717
+ toggleValue() {
718
+ this.value = this.value.includes(this._value) ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
719
+ }
720
+ };
721
+ var TD = Object.defineProperty, jD = (e$1, u$1, t) => u$1 in e$1 ? TD(e$1, u$1, {
722
+ enumerable: !0,
723
+ configurable: !0,
724
+ writable: !0,
725
+ value: t
726
+ }) : e$1[u$1] = t, U$1 = (e$1, u$1, t) => (jD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
727
+ var MD = class extends x$1 {
728
+ constructor({ mask: u$1, ...t }) {
729
+ super(t), U$1(this, "valueWithCursor", ""), U$1(this, "_mask", "•"), this._mask = u$1 ?? "•", this.on("finalize", () => {
730
+ this.valueWithCursor = this.masked;
731
+ }), this.on("value", () => {
732
+ if (this.cursor >= this.value.length) this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
733
+ else {
734
+ const F$1 = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
735
+ this.valueWithCursor = `${F$1}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
736
+ }
737
+ });
738
+ }
739
+ get cursor() {
740
+ return this._cursor;
741
+ }
742
+ get masked() {
743
+ return this.value.replaceAll(/./g, this._mask);
744
+ }
745
+ };
746
+ var OD = Object.defineProperty, PD = (e$1, u$1, t) => u$1 in e$1 ? OD(e$1, u$1, {
747
+ enumerable: !0,
748
+ configurable: !0,
749
+ writable: !0,
750
+ value: t
751
+ }) : e$1[u$1] = t, J$1 = (e$1, u$1, t) => (PD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
752
+ var LD = class extends x$1 {
753
+ constructor(u$1) {
754
+ super(u$1, !1), J$1(this, "options"), J$1(this, "cursor", 0), this.options = u$1.options, this.cursor = this.options.findIndex(({ value: t }) => t === u$1.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
755
+ switch (t) {
756
+ case "left":
757
+ case "up":
758
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
759
+ break;
760
+ case "down":
761
+ case "right":
762
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
763
+ break;
764
+ }
765
+ this.changeValue();
766
+ });
767
+ }
768
+ get _value() {
769
+ return this.options[this.cursor];
770
+ }
771
+ changeValue() {
772
+ this.value = this._value.value;
773
+ }
774
+ };
775
+ var WD = Object.defineProperty, ND = (e$1, u$1, t) => u$1 in e$1 ? WD(e$1, u$1, {
776
+ enumerable: !0,
777
+ configurable: !0,
778
+ writable: !0,
779
+ value: t
780
+ }) : e$1[u$1] = t, Q = (e$1, u$1, t) => (ND(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
781
+ var ID = class extends x$1 {
782
+ constructor(u$1) {
783
+ super(u$1, !1), Q(this, "options"), Q(this, "cursor", 0), this.options = u$1.options;
784
+ const t = this.options.map(({ value: [F$1] }) => F$1?.toLowerCase());
785
+ this.cursor = Math.max(t.indexOf(u$1.initialValue), 0), this.on("key", (F$1) => {
786
+ if (!t.includes(F$1)) return;
787
+ const s = this.options.find(({ value: [i] }) => i?.toLowerCase() === F$1);
788
+ s && (this.value = s.value, this.state = "submit", this.emit("submit"));
789
+ });
790
+ }
791
+ };
792
+ var RD = class extends x$1 {
793
+ get valueWithCursor() {
794
+ if (this.state === "submit") return this.value;
795
+ if (this.cursor >= this.value.length) return `${this.value}\u2588`;
796
+ const u$1 = this.value.slice(0, this.cursor), [t, ...F$1] = this.value.slice(this.cursor);
797
+ return `${u$1}${import_picocolors.default.inverse(t)}${F$1.join("")}`;
798
+ }
799
+ get cursor() {
800
+ return this._cursor;
801
+ }
802
+ constructor(u$1) {
803
+ super(u$1), this.on("finalize", () => {
804
+ this.value || (this.value = u$1.defaultValue);
805
+ });
806
+ }
807
+ };
808
+
809
+ //#endregion
810
+ //#region node_modules/@clack/prompts/dist/index.mjs
811
+ function ce() {
812
+ return y.platform !== "win32" ? y.env.TERM !== "linux" : !!y.env.CI || !!y.env.WT_SESSION || !!y.env.TERMINUS_SUBLIME || y.env.ConEmuTask === "{cmd::Cmder}" || y.env.TERM_PROGRAM === "Terminus-Sublime" || y.env.TERM_PROGRAM === "vscode" || y.env.TERM === "xterm-256color" || y.env.TERM === "alacritty" || y.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
813
+ }
814
+ const V = ce(), u = (t, n) => V ? t : n, le = u("◆", "*"), L = u("■", "x"), W = u("▲", "x"), C = u("◇", "o"), ue = u("┌", "T"), o = u("│", "|"), d = u("└", "—"), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]"), $e = u("▪", "•"), _ = u("─", "-"), me = u("╮", "+"), de = u("├", "+"), pe = u("╯", "+"), q = u("●", "•"), D = u("◆", "*"), U = u("▲", "!"), K = u("■", "x"), b = (t) => {
815
+ switch (t) {
816
+ case "initial":
817
+ case "active": return import_picocolors.default.cyan(le);
818
+ case "cancel": return import_picocolors.default.red(L);
819
+ case "error": return import_picocolors.default.yellow(W);
820
+ case "submit": return import_picocolors.default.green(C);
821
+ }
822
+ }, G = (t) => {
823
+ const { cursor: n, options: r$1, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
824
+ let l$1 = 0;
825
+ n >= l$1 + a - 3 ? l$1 = Math.max(Math.min(n - a + 3, r$1.length - a), 0) : n < l$1 + 2 && (l$1 = Math.max(n - 2, 0));
826
+ const $$1 = a < r$1.length && l$1 > 0, g$1 = a < r$1.length && l$1 + a < r$1.length;
827
+ return r$1.slice(l$1, l$1 + a).map((p$1, v$1, f) => {
828
+ const j = v$1 === 0 && $$1, E = v$1 === f.length - 1 && g$1;
829
+ return j || E ? import_picocolors.default.dim("...") : i(p$1, v$1 + l$1 === n);
830
+ });
831
+ }, he = (t) => new RD({
832
+ validate: t.validate,
833
+ placeholder: t.placeholder,
834
+ defaultValue: t.defaultValue,
835
+ initialValue: t.initialValue,
836
+ render() {
837
+ const n = `${import_picocolors.default.gray(o)}
838
+ ${b(this.state)} ${t.message}
839
+ `, r$1 = t.placeholder ? import_picocolors.default.inverse(t.placeholder[0]) + import_picocolors.default.dim(t.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), i = this.value ? this.valueWithCursor : r$1;
840
+ switch (this.state) {
841
+ case "error": return `${n.trim()}
842
+ ${import_picocolors.default.yellow(o)} ${i}
843
+ ${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
844
+ `;
845
+ case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(this.value || t.placeholder)}`;
846
+ case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(this.value ?? ""))}${this.value?.trim() ? `
847
+ ${import_picocolors.default.gray(o)}` : ""}`;
848
+ default: return `${n}${import_picocolors.default.cyan(o)} ${i}
849
+ ${import_picocolors.default.cyan(d)}
850
+ `;
851
+ }
852
+ }
853
+ }).prompt(), ge = (t) => new MD({
854
+ validate: t.validate,
855
+ mask: t.mask ?? $e,
856
+ render() {
857
+ const n = `${import_picocolors.default.gray(o)}
858
+ ${b(this.state)} ${t.message}
859
+ `, r$1 = this.valueWithCursor, i = this.masked;
860
+ switch (this.state) {
861
+ case "error": return `${n.trim()}
862
+ ${import_picocolors.default.yellow(o)} ${i}
863
+ ${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
864
+ `;
865
+ case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(i)}`;
866
+ case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i ?? ""))}${i ? `
867
+ ${import_picocolors.default.gray(o)}` : ""}`;
868
+ default: return `${n}${import_picocolors.default.cyan(o)} ${r$1}
869
+ ${import_picocolors.default.cyan(d)}
870
+ `;
871
+ }
872
+ }
873
+ }).prompt(), ye = (t) => {
874
+ const n = t.active ?? "Yes", r$1 = t.inactive ?? "No";
875
+ return new dD({
876
+ active: n,
877
+ inactive: r$1,
878
+ initialValue: t.initialValue ?? !0,
879
+ render() {
880
+ const i = `${import_picocolors.default.gray(o)}
881
+ ${b(this.state)} ${t.message}
882
+ `, s = this.value ? n : r$1;
883
+ switch (this.state) {
884
+ case "submit": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(s)}`;
885
+ case "cancel": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}
886
+ ${import_picocolors.default.gray(o)}`;
887
+ default: return `${i}${import_picocolors.default.cyan(o)} ${this.value ? `${import_picocolors.default.green(k)} ${n}` : `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(n)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(r$1)}` : `${import_picocolors.default.green(k)} ${r$1}`}
888
+ ${import_picocolors.default.cyan(d)}
889
+ `;
890
+ }
891
+ }
892
+ }).prompt();
893
+ }, ve = (t) => {
894
+ const n = (r$1, i) => {
895
+ const s = r$1.label ?? String(r$1.value);
896
+ switch (i) {
897
+ case "selected": return `${import_picocolors.default.dim(s)}`;
898
+ case "active": return `${import_picocolors.default.green(k)} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}`;
899
+ case "cancelled": return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
900
+ default: return `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(s)}`;
901
+ }
902
+ };
903
+ return new LD({
904
+ options: t.options,
905
+ initialValue: t.initialValue,
906
+ render() {
907
+ const r$1 = `${import_picocolors.default.gray(o)}
908
+ ${b(this.state)} ${t.message}
909
+ `;
910
+ switch (this.state) {
911
+ case "submit": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
912
+ case "cancel": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
913
+ ${import_picocolors.default.gray(o)}`;
914
+ default: return `${r$1}${import_picocolors.default.cyan(o)} ${G({
915
+ cursor: this.cursor,
916
+ options: this.options,
917
+ maxItems: t.maxItems,
918
+ style: (i, s) => n(i, s ? "active" : "inactive")
919
+ }).join(`
920
+ ${import_picocolors.default.cyan(o)} `)}
921
+ ${import_picocolors.default.cyan(d)}
922
+ `;
923
+ }
924
+ }
925
+ }).prompt();
926
+ }, we = (t) => {
927
+ const n = (r$1, i = "inactive") => {
928
+ const s = r$1.label ?? String(r$1.value);
929
+ return i === "selected" ? `${import_picocolors.default.dim(s)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active" ? `${import_picocolors.default.bgCyan(import_picocolors.default.gray(` ${r$1.value} `))} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : `${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(` ${r$1.value} `)))} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}`;
930
+ };
931
+ return new ID({
932
+ options: t.options,
933
+ initialValue: t.initialValue,
934
+ render() {
935
+ const r$1 = `${import_picocolors.default.gray(o)}
936
+ ${b(this.state)} ${t.message}
937
+ `;
938
+ switch (this.state) {
939
+ case "submit": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options.find((i) => i.value === this.value) ?? t.options[0], "selected")}`;
940
+ case "cancel": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options[0], "cancelled")}
941
+ ${import_picocolors.default.gray(o)}`;
942
+ default: return `${r$1}${import_picocolors.default.cyan(o)} ${this.options.map((i, s) => n(i, s === this.cursor ? "active" : "inactive")).join(`
943
+ ${import_picocolors.default.cyan(o)} `)}
944
+ ${import_picocolors.default.cyan(d)}
945
+ `;
946
+ }
947
+ }
948
+ }).prompt();
949
+ }, fe = (t) => {
950
+ const n = (r$1, i) => {
951
+ const s = r$1.label ?? String(r$1.value);
952
+ return i === "active" ? `${import_picocolors.default.cyan(A)} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : i === "selected" ? `${import_picocolors.default.green(T)} ${import_picocolors.default.dim(s)} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active-selected" ? `${import_picocolors.default.green(T)} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : i === "submitted" ? `${import_picocolors.default.dim(s)}` : `${import_picocolors.default.dim(F)} ${import_picocolors.default.dim(s)}`;
953
+ };
954
+ return new SD({
955
+ options: t.options,
956
+ initialValues: t.initialValues,
957
+ required: t.required ?? !0,
958
+ cursorAt: t.cursorAt,
959
+ validate(r$1) {
960
+ if (this.required && r$1.length === 0) return `Please select at least one option.
961
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
962
+ },
963
+ render() {
964
+ const r$1 = `${import_picocolors.default.gray(o)}
965
+ ${b(this.state)} ${t.message}
966
+ `, i = (s, c) => {
967
+ const a = this.value.includes(s.value);
968
+ return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
969
+ };
970
+ switch (this.state) {
971
+ case "submit": return `${r$1}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none")}`;
972
+ case "cancel": {
973
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors.default.dim(", "));
974
+ return `${r$1}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
975
+ ${import_picocolors.default.gray(o)}` : ""}`;
976
+ }
977
+ case "error": {
978
+ const s = this.error.split(`
979
+ `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
980
+ `);
981
+ return `${r$1 + import_picocolors.default.yellow(o)} ${G({
982
+ options: this.options,
983
+ cursor: this.cursor,
984
+ maxItems: t.maxItems,
985
+ style: i
986
+ }).join(`
987
+ ${import_picocolors.default.yellow(o)} `)}
988
+ ${s}
989
+ `;
990
+ }
991
+ default: return `${r$1}${import_picocolors.default.cyan(o)} ${G({
992
+ options: this.options,
993
+ cursor: this.cursor,
994
+ maxItems: t.maxItems,
995
+ style: i
996
+ }).join(`
997
+ ${import_picocolors.default.cyan(o)} `)}
998
+ ${import_picocolors.default.cyan(d)}
999
+ `;
1000
+ }
1001
+ }
1002
+ }).prompt();
1003
+ }, be = (t) => {
1004
+ const { selectableGroups: n = !0 } = t, r$1 = (i, s, c = []) => {
1005
+ const a = i.label ?? String(i.value), l$1 = typeof i.group == "string", $$1 = l$1 && (c[c.indexOf(i) + 1] ?? { group: !0 }), g$1 = l$1 && $$1.group === !0, p$1 = l$1 ? n ? `${g$1 ? d : o} ` : " " : "";
1006
+ if (s === "active") return `${import_picocolors.default.dim(p$1)}${import_picocolors.default.cyan(A)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
1007
+ if (s === "group-active") return `${p$1}${import_picocolors.default.cyan(A)} ${import_picocolors.default.dim(a)}`;
1008
+ if (s === "group-active-selected") return `${p$1}${import_picocolors.default.green(T)} ${import_picocolors.default.dim(a)}`;
1009
+ if (s === "selected") {
1010
+ const f = l$1 || n ? import_picocolors.default.green(T) : "";
1011
+ return `${import_picocolors.default.dim(p$1)}${f} ${import_picocolors.default.dim(a)} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
1012
+ }
1013
+ if (s === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
1014
+ if (s === "active-selected") return `${import_picocolors.default.dim(p$1)}${import_picocolors.default.green(T)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
1015
+ if (s === "submitted") return `${import_picocolors.default.dim(a)}`;
1016
+ const v$1 = l$1 || n ? import_picocolors.default.dim(F) : "";
1017
+ return `${import_picocolors.default.dim(p$1)}${v$1} ${import_picocolors.default.dim(a)}`;
1018
+ };
1019
+ return new _D({
1020
+ options: t.options,
1021
+ initialValues: t.initialValues,
1022
+ required: t.required ?? !0,
1023
+ cursorAt: t.cursorAt,
1024
+ selectableGroups: n,
1025
+ validate(i) {
1026
+ if (this.required && i.length === 0) return `Please select at least one option.
1027
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
1028
+ },
1029
+ render() {
1030
+ const i = `${import_picocolors.default.gray(o)}
1031
+ ${b(this.state)} ${t.message}
1032
+ `;
1033
+ switch (this.state) {
1034
+ case "submit": return `${i}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r$1(s, "submitted")).join(import_picocolors.default.dim(", "))}`;
1035
+ case "cancel": {
1036
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r$1(c, "cancelled")).join(import_picocolors.default.dim(", "));
1037
+ return `${i}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
1038
+ ${import_picocolors.default.gray(o)}` : ""}`;
1039
+ }
1040
+ case "error": {
1041
+ const s = this.error.split(`
1042
+ `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
1043
+ `);
1044
+ return `${i}${import_picocolors.default.yellow(o)} ${this.options.map((c, a, l$1) => {
1045
+ const $$1 = this.value.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), g$1 = a === this.cursor;
1046
+ return !g$1 && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r$1(c, $$1 ? "group-active-selected" : "group-active", l$1) : g$1 && $$1 ? r$1(c, "active-selected", l$1) : $$1 ? r$1(c, "selected", l$1) : r$1(c, g$1 ? "active" : "inactive", l$1);
1047
+ }).join(`
1048
+ ${import_picocolors.default.yellow(o)} `)}
1049
+ ${s}
1050
+ `;
1051
+ }
1052
+ default: return `${i}${import_picocolors.default.cyan(o)} ${this.options.map((s, c, a) => {
1053
+ const l$1 = this.value.includes(s.value) || s.group === !0 && this.isGroupSelected(`${s.value}`), $$1 = c === this.cursor;
1054
+ return !$$1 && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r$1(s, l$1 ? "group-active-selected" : "group-active", a) : $$1 && l$1 ? r$1(s, "active-selected", a) : l$1 ? r$1(s, "selected", a) : r$1(s, $$1 ? "active" : "inactive", a);
1055
+ }).join(`
1056
+ ${import_picocolors.default.cyan(o)} `)}
1057
+ ${import_picocolors.default.cyan(d)}
1058
+ `;
1059
+ }
1060
+ }
1061
+ }).prompt();
1062
+ }, Me = (t = "", n = "") => {
1063
+ const r$1 = `
1064
+ ${t}
1065
+ `.split(`
1066
+ `), i = stripVTControlCharacters(n).length, s = Math.max(r$1.reduce((a, l$1) => {
1067
+ const $$1 = stripVTControlCharacters(l$1);
1068
+ return $$1.length > a ? $$1.length : a;
1069
+ }, 0), i) + 2, c = r$1.map((a) => `${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(a)}${" ".repeat(s - stripVTControlCharacters(a).length)}${import_picocolors.default.gray(o)}`).join(`
1070
+ `);
1071
+ process.stdout.write(`${import_picocolors.default.gray(o)}
1072
+ ${import_picocolors.default.green(C)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(_.repeat(Math.max(s - i - 1, 1)) + me)}
1073
+ ${c}
1074
+ ${import_picocolors.default.gray(de + _.repeat(s + 2) + pe)}
1075
+ `);
1076
+ }, xe = (t = "") => {
1077
+ process.stdout.write(`${import_picocolors.default.gray(d)} ${import_picocolors.default.red(t)}
1078
+
1079
+ `);
1080
+ }, Ie = (t = "") => {
1081
+ process.stdout.write(`${import_picocolors.default.gray(ue)} ${t}
1082
+ `);
1083
+ }, Se = (t = "") => {
1084
+ process.stdout.write(`${import_picocolors.default.gray(o)}
1085
+ ${import_picocolors.default.gray(d)} ${t}
1086
+
1087
+ `);
1088
+ }, M = {
1089
+ message: (t = "", { symbol: n = import_picocolors.default.gray(o) } = {}) => {
1090
+ const r$1 = [`${import_picocolors.default.gray(o)}`];
1091
+ if (t) {
1092
+ const [i, ...s] = t.split(`
1093
+ `);
1094
+ r$1.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors.default.gray(o)} ${c}`));
1095
+ }
1096
+ process.stdout.write(`${r$1.join(`
1097
+ `)}
1098
+ `);
1099
+ },
1100
+ info: (t) => {
1101
+ M.message(t, { symbol: import_picocolors.default.blue(q) });
1102
+ },
1103
+ success: (t) => {
1104
+ M.message(t, { symbol: import_picocolors.default.green(D) });
1105
+ },
1106
+ step: (t) => {
1107
+ M.message(t, { symbol: import_picocolors.default.green(C) });
1108
+ },
1109
+ warn: (t) => {
1110
+ M.message(t, { symbol: import_picocolors.default.yellow(U) });
1111
+ },
1112
+ warning: (t) => {
1113
+ M.warn(t);
1114
+ },
1115
+ error: (t) => {
1116
+ M.message(t, { symbol: import_picocolors.default.red(K) });
1117
+ }
1118
+ }, J = `${import_picocolors.default.gray(o)} `, x = {
1119
+ message: async (t, { symbol: n = import_picocolors.default.gray(o) } = {}) => {
1120
+ process.stdout.write(`${import_picocolors.default.gray(o)}
1121
+ ${n} `);
1122
+ let r$1 = 3;
1123
+ for await (let i of t) {
1124
+ i = i.replace(/\n/g, `
1125
+ ${J}`), i.includes(`
1126
+ `) && (r$1 = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
1127
+ `))).length);
1128
+ const s = stripVTControlCharacters(i).length;
1129
+ r$1 + s < process.stdout.columns ? (r$1 += s, process.stdout.write(i)) : (process.stdout.write(`
1130
+ ${J}${i.trimStart()}`), r$1 = 3 + stripVTControlCharacters(i.trimStart()).length);
1131
+ }
1132
+ process.stdout.write(`
1133
+ `);
1134
+ },
1135
+ info: (t) => x.message(t, { symbol: import_picocolors.default.blue(q) }),
1136
+ success: (t) => x.message(t, { symbol: import_picocolors.default.green(D) }),
1137
+ step: (t) => x.message(t, { symbol: import_picocolors.default.green(C) }),
1138
+ warn: (t) => x.message(t, { symbol: import_picocolors.default.yellow(U) }),
1139
+ warning: (t) => x.warn(t),
1140
+ error: (t) => x.message(t, { symbol: import_picocolors.default.red(K) })
1141
+ }, Y = ({ indicator: t = "dots" } = {}) => {
1142
+ const n = V ? [
1143
+ "◒",
1144
+ "◐",
1145
+ "◓",
1146
+ "◑"
1147
+ ] : [
1148
+ "•",
1149
+ "o",
1150
+ "O",
1151
+ "0"
1152
+ ], r$1 = V ? 80 : 120, i = process.env.CI === "true";
1153
+ let s, c, a = !1, l$1 = "", $$1, g$1 = performance.now();
1154
+ const p$1 = (m$1) => {
1155
+ a && N$1(m$1 > 1 ? "Something went wrong" : "Canceled", m$1);
1156
+ }, v$1 = () => p$1(2), f = () => p$1(1), j = () => {
1157
+ process.on("uncaughtExceptionMonitor", v$1), process.on("unhandledRejection", v$1), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p$1);
1158
+ }, E = () => {
1159
+ process.removeListener("uncaughtExceptionMonitor", v$1), process.removeListener("unhandledRejection", v$1), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p$1);
1160
+ }, B$1 = () => {
1161
+ if ($$1 === void 0) return;
1162
+ i && process.stdout.write(`
1163
+ `);
1164
+ const m$1 = $$1.split(`
1165
+ `);
1166
+ process.stdout.write(import_src.cursor.move(-999, m$1.length - 1)), process.stdout.write(import_src.erase.down(m$1.length));
1167
+ }, R$1 = (m$1) => m$1.replace(/\.+$/, ""), O$1 = (m$1) => {
1168
+ const h$1 = (performance.now() - m$1) / 1e3, w$1 = Math.floor(h$1 / 60), I$1 = Math.floor(h$1 % 60);
1169
+ return w$1 > 0 ? `[${w$1}m ${I$1}s]` : `[${I$1}s]`;
1170
+ }, H$1 = (m$1 = "") => {
1171
+ a = !0, s = fD(), l$1 = R$1(m$1), g$1 = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
1172
+ `);
1173
+ let h$1 = 0, w$1 = 0;
1174
+ j(), c = setInterval(() => {
1175
+ if (i && l$1 === $$1) return;
1176
+ B$1(), $$1 = l$1;
1177
+ const I$1 = import_picocolors.default.magenta(n[h$1]);
1178
+ if (i) process.stdout.write(`${I$1} ${l$1}...`);
1179
+ else if (t === "timer") process.stdout.write(`${I$1} ${l$1} ${O$1(g$1)}`);
1180
+ else {
1181
+ const z$1 = ".".repeat(Math.floor(w$1)).slice(0, 3);
1182
+ process.stdout.write(`${I$1} ${l$1}${z$1}`);
1183
+ }
1184
+ h$1 = h$1 + 1 < n.length ? h$1 + 1 : 0, w$1 = w$1 < n.length ? w$1 + .125 : 0;
1185
+ }, r$1);
1186
+ }, N$1 = (m$1 = "", h$1 = 0) => {
1187
+ a = !1, clearInterval(c), B$1();
1188
+ const w$1 = h$1 === 0 ? import_picocolors.default.green(C) : h$1 === 1 ? import_picocolors.default.red(L) : import_picocolors.default.red(W);
1189
+ l$1 = R$1(m$1 ?? l$1), t === "timer" ? process.stdout.write(`${w$1} ${l$1} ${O$1(g$1)}
1190
+ `) : process.stdout.write(`${w$1} ${l$1}
1191
+ `), E(), s();
1192
+ };
1193
+ return {
1194
+ start: H$1,
1195
+ stop: N$1,
1196
+ message: (m$1 = "") => {
1197
+ l$1 = R$1(m$1 ?? l$1);
1198
+ }
1199
+ };
1200
+ }, Ce = async (t, n) => {
1201
+ const r$1 = {}, i = Object.keys(t);
1202
+ for (const s of i) {
1203
+ const c = t[s], a = await c({ results: r$1 })?.catch((l$1) => {
1204
+ throw l$1;
1205
+ });
1206
+ if (typeof n?.onCancel == "function" && pD(a)) {
1207
+ r$1[s] = "canceled", n.onCancel({ results: r$1 });
1208
+ continue;
1209
+ }
1210
+ r$1[s] = a;
1211
+ }
1212
+ return r$1;
1213
+ }, Te = async (t) => {
1214
+ for (const n of t) {
1215
+ if (n.enabled === !1) continue;
1216
+ const r$1 = Y();
1217
+ r$1.start(n.title);
1218
+ const i = await n.task(r$1.message);
1219
+ r$1.stop(i || n.title);
1220
+ }
1221
+ };
1222
+
1223
+ //#endregion
1224
+ //#region node_modules/args-tokens/lib/utils-1LQrGCWG.js
1225
+ /**
1226
+ * Entry point of utils.
1227
+ *
1228
+ * Note that this entry point is used by gunshi to import utility functions.
1229
+ *
1230
+ * @module
1231
+ */
1232
+ /**
1233
+ * @author kazuya kawaguchi (a.k.a. kazupon)
1234
+ * @license MIT
1235
+ */
1236
+ /**
1237
+ * Convert a string to kebab-case.
1238
+ *
1239
+ * @param str - A string to convert
1240
+ * @returns Converted string into kebab-case.
1241
+ */
1242
+ function kebabnize(str) {
1243
+ return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
1244
+ }
1245
+
1246
+ //#endregion
1247
+ //#region node_modules/gunshi/lib/utils-DA31tfdY.js
1248
+ /**
1249
+ * Check if the given command is a {@link LazyCommand}.
1250
+ *
1251
+ * @param cmd - A command to check
1252
+ * @returns `true` if the command is a {@link LazyCommand}, otherwise `false
1253
+ */
1254
+ function isLazyCommand(cmd) {
1255
+ return typeof cmd === "function" && "commandName" in cmd && !!cmd.commandName;
1256
+ }
1257
+ /**
1258
+ * Resolve a lazy command to a {@link Command}.
1259
+ *
1260
+ * @param cmd - A {@link Commandable} or {@link LazyCommand} to resolve
1261
+ * @param name - Optional name of the command, if not provided, it will use the name from the command itself.
1262
+ * @param needRunResolving - Whether to run the resolving function of the lazy command.
1263
+ * @returns A resolved {@link Command}
1264
+ */
1265
+ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
1266
+ let command$1;
1267
+ if (isLazyCommand(cmd)) {
1268
+ const baseCommand = {
1269
+ name: cmd.commandName,
1270
+ description: cmd.description,
1271
+ args: cmd.args,
1272
+ examples: cmd.examples,
1273
+ internal: cmd.internal,
1274
+ entry: cmd.entry
1275
+ };
1276
+ if ("resource" in cmd && cmd.resource) baseCommand.resource = cmd.resource;
1277
+ command$1 = Object.assign(create(), baseCommand);
1278
+ if (needRunResolving) {
1279
+ const loaded = await cmd();
1280
+ if (typeof loaded === "function") command$1.run = loaded;
1281
+ else if (typeof loaded === "object") {
1282
+ if (loaded.run == null) throw new TypeError(`'run' is required in command: ${cmd.name || name}`);
1283
+ command$1.run = loaded.run;
1284
+ command$1.name = loaded.name;
1285
+ command$1.description = loaded.description;
1286
+ command$1.args = loaded.args;
1287
+ command$1.examples = loaded.examples;
1288
+ command$1.internal = loaded.internal;
1289
+ command$1.entry = loaded.entry;
1290
+ if ("resource" in loaded && loaded.resource) command$1.resource = loaded.resource;
1291
+ } else throw new TypeError(`Cannot resolve command: ${cmd.name || name}`);
1292
+ }
1293
+ } else command$1 = Object.assign(create(), cmd);
1294
+ if (command$1.name == null && name) command$1.name = name;
1295
+ return deepFreeze(command$1);
1296
+ }
1297
+ /**
1298
+ * Create an object with the specified prototype. A shorthand for `Object.create`.
1299
+ *
1300
+ * @param obj - An object to use as the prototype for the new object. If `null`, it will create an object with no prototype.
1301
+ * @returns A new object with the specified prototype
1302
+ */
1303
+ function create(obj = null) {
1304
+ return Object.create(obj);
1305
+ }
1306
+ /**
1307
+ * Log a message to the console.
1308
+ *
1309
+ * @param args - Arguments to log
1310
+ */
1311
+ function log(...args) {
1312
+ console.log(...args);
1313
+ }
1314
+ /**
1315
+ * Deep freeze an object, making it immutable.
1316
+ *
1317
+ * @param obj - The object to freeze
1318
+ * @param ignores - Properties to ignore during freezing
1319
+ * @returns A frozen object
1320
+ */
1321
+ function deepFreeze(obj, ignores = []) {
1322
+ if (obj === null || typeof obj !== "object") return obj;
1323
+ for (const key of Object.keys(obj)) {
1324
+ const value = obj[key];
1325
+ if (ignores.includes(key)) continue;
1326
+ if (typeof value === "object" && value !== null) deepFreeze(value, ignores);
1327
+ }
1328
+ return Object.freeze(obj);
1329
+ }
1330
+
1331
+ //#endregion
1332
+ //#region node_modules/gunshi/lib/context-DRQZ3doU.js
1333
+ const ANONYMOUS_COMMAND_NAME = "(anonymous)";
1334
+ /**
1335
+ * A no-operation function.
1336
+ */
1337
+ const NOOP = () => {};
1338
+ const CLI_OPTIONS_DEFAULT = {
1339
+ name: void 0,
1340
+ description: void 0,
1341
+ version: void 0,
1342
+ cwd: void 0,
1343
+ usageSilent: false,
1344
+ subCommands: void 0,
1345
+ leftMargin: 2,
1346
+ middleMargin: 10,
1347
+ usageOptionType: false,
1348
+ usageOptionValue: true,
1349
+ renderHeader: void 0,
1350
+ renderUsage: void 0,
1351
+ renderValidationErrors: void 0,
1352
+ plugins: void 0,
1353
+ fallbackToEntry: false
1354
+ };
1355
+ /**
1356
+ * The entry for gunshi context.
1357
+ * This module is exported for the purpose of testing the command.
1358
+ *
1359
+ * @example
1360
+ * ```js
1361
+ * import { createCommandContext } from 'gunshi/context'
1362
+ * ```
1363
+ *
1364
+ * @module
1365
+ */
1366
+ /**
1367
+ * @author kazuya kawaguchi (a.k.a. kazupon)
1368
+ * @license MIT
1369
+ */
1370
+ /**
1371
+ * Create a command context.
1372
+ *
1373
+ * @param param - A {@link CommandContextParams | parameters} to create a command context.
1374
+ * @returns A {@link CommandContext | command context}, which is readonly.
1375
+ */
1376
+ async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command: command$1 = {}, extensions = {}, cliOptions = {}, callMode = "entry", omitted = false, validationError = void 0 }) {
1377
+ /**
1378
+ * normailize the options schema and values, to avoid prototype pollution
1379
+ */
1380
+ const _args = Object.entries(args).reduce((acc, [key, value]) => {
1381
+ acc[key] = Object.assign(create(), value);
1382
+ return acc;
1383
+ }, create());
1384
+ /**
1385
+ * setup the environment
1386
+ */
1387
+ const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
1388
+ /**
1389
+ * apply Command definition's rendering option with highest priority
1390
+ */
1391
+ if (command$1.rendering) {
1392
+ const { header, usage, validationErrors } = command$1.rendering;
1393
+ if (header !== void 0) env.renderHeader = header;
1394
+ if (usage !== void 0) env.renderUsage = usage;
1395
+ if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
1396
+ }
1397
+ /**
1398
+ * create the command context
1399
+ */
1400
+ const core = Object.assign(create(), {
1401
+ name: getCommandName(command$1),
1402
+ description: command$1.description,
1403
+ omitted,
1404
+ callMode,
1405
+ env,
1406
+ args: _args,
1407
+ explicit,
1408
+ values,
1409
+ positionals,
1410
+ rest,
1411
+ _: argv,
1412
+ tokens,
1413
+ toKebab: command$1.toKebab,
1414
+ log: cliOptions.usageSilent ? NOOP : log,
1415
+ validationError
1416
+ });
1417
+ /**
1418
+ * extend the command context with extensions
1419
+ */
1420
+ if (Object.keys(extensions).length > 0) {
1421
+ const ext = create(null);
1422
+ Object.defineProperty(core, "extensions", {
1423
+ value: ext,
1424
+ writable: false,
1425
+ enumerable: true,
1426
+ configurable: true
1427
+ });
1428
+ for (const [key, extension$1] of Object.entries(extensions)) {
1429
+ ext[key] = await extension$1.factory(core, command$1);
1430
+ if (extension$1.onFactory) await extension$1.onFactory(core, command$1);
1431
+ }
1432
+ }
1433
+ return deepFreeze(core, ["extensions"]);
1434
+ }
1435
+ function getCommandName(cmd) {
1436
+ if (isLazyCommand(cmd)) return cmd.commandName || cmd.name || ANONYMOUS_COMMAND_NAME;
1437
+ else if (typeof cmd === "object") return cmd.name || ANONYMOUS_COMMAND_NAME;
1438
+ else return ANONYMOUS_COMMAND_NAME;
1439
+ }
1440
+
1441
+ //#endregion
1442
+ //#region node_modules/args-tokens/lib/parser-M-ayhS1h.js
1443
+ const HYPHEN_CHAR = "-";
1444
+ const HYPHEN_CODE = HYPHEN_CHAR.codePointAt(0);
1445
+ const EQUAL_CHAR = "=";
1446
+ const EQUAL_CODE = EQUAL_CHAR.codePointAt(0);
1447
+ const TERMINATOR = "--";
1448
+ const SHORT_OPTION_PREFIX = HYPHEN_CHAR;
1449
+ const LONG_OPTION_PREFIX = "--";
1450
+ /**
1451
+ * Parse command line arguments.
1452
+ *
1453
+ * @param args - command line arguments
1454
+ * @param options - parse options, about details see {@link ParserOptions}
1455
+ * @returns Argument tokens.
1456
+ *
1457
+ * @example
1458
+ * ```js
1459
+ * import { parseArgs } from 'args-tokens' // for Node.js and Bun
1460
+ * // import { parseArgs } from 'jsr:@kazupon/args-tokens' // for Deno
1461
+ *
1462
+ * const tokens = parseArgs(['--foo', 'bar', '-x', '--bar=baz'])
1463
+ * // do something with using tokens
1464
+ * // ...
1465
+ * console.log('tokens:', tokens)
1466
+ * ```
1467
+ */
1468
+ function parseArgs(args, options = {}) {
1469
+ const { allowCompatible = false } = options;
1470
+ const tokens = [];
1471
+ const remainings = [...args];
1472
+ let index = -1;
1473
+ let groupCount = 0;
1474
+ let hasShortValueSeparator = false;
1475
+ while (remainings.length > 0) {
1476
+ const arg = remainings.shift();
1477
+ if (arg == void 0) break;
1478
+ const nextArg = remainings[0];
1479
+ if (groupCount > 0) groupCount--;
1480
+ else index++;
1481
+ if (arg === TERMINATOR) {
1482
+ tokens.push({
1483
+ kind: "option-terminator",
1484
+ index
1485
+ });
1486
+ const mapped = remainings.map((arg$1) => {
1487
+ return {
1488
+ kind: "positional",
1489
+ index: ++index,
1490
+ value: arg$1
1491
+ };
1492
+ });
1493
+ tokens.push(...mapped);
1494
+ break;
1495
+ }
1496
+ if (isShortOption(arg)) {
1497
+ const shortOption = arg.charAt(1);
1498
+ let value;
1499
+ let inlineValue;
1500
+ if (groupCount) {
1501
+ tokens.push({
1502
+ kind: "option",
1503
+ name: shortOption,
1504
+ rawName: arg,
1505
+ index,
1506
+ value,
1507
+ inlineValue
1508
+ });
1509
+ if (groupCount === 1 && hasOptionValue(nextArg)) {
1510
+ value = remainings.shift();
1511
+ if (hasShortValueSeparator) {
1512
+ inlineValue = true;
1513
+ hasShortValueSeparator = false;
1514
+ }
1515
+ tokens.push({
1516
+ kind: "option",
1517
+ index,
1518
+ value,
1519
+ inlineValue
1520
+ });
1521
+ }
1522
+ } else tokens.push({
1523
+ kind: "option",
1524
+ name: shortOption,
1525
+ rawName: arg,
1526
+ index,
1527
+ value,
1528
+ inlineValue
1529
+ });
1530
+ if (value != null) ++index;
1531
+ continue;
1532
+ }
1533
+ if (isShortOptionGroup(arg)) {
1534
+ const expanded = [];
1535
+ let shortValue = "";
1536
+ for (let i = 1; i < arg.length; i++) {
1537
+ const shortableOption = arg.charAt(i);
1538
+ if (hasShortValueSeparator) shortValue += shortableOption;
1539
+ else if (!allowCompatible && shortableOption.codePointAt(0) === EQUAL_CODE) hasShortValueSeparator = true;
1540
+ else expanded.push(`${SHORT_OPTION_PREFIX}${shortableOption}`);
1541
+ }
1542
+ if (shortValue) expanded.push(shortValue);
1543
+ remainings.unshift(...expanded);
1544
+ groupCount = expanded.length;
1545
+ continue;
1546
+ }
1547
+ if (isLongOption(arg)) {
1548
+ const longOption = arg.slice(2);
1549
+ tokens.push({
1550
+ kind: "option",
1551
+ name: longOption,
1552
+ rawName: arg,
1553
+ index,
1554
+ value: void 0,
1555
+ inlineValue: void 0
1556
+ });
1557
+ continue;
1558
+ }
1559
+ if (isLongOptionAndValue(arg)) {
1560
+ const equalIndex = arg.indexOf(EQUAL_CHAR);
1561
+ const longOption = arg.slice(2, equalIndex);
1562
+ const value = arg.slice(equalIndex + 1);
1563
+ tokens.push({
1564
+ kind: "option",
1565
+ name: longOption,
1566
+ rawName: `${LONG_OPTION_PREFIX}${longOption}`,
1567
+ index,
1568
+ value,
1569
+ inlineValue: true
1570
+ });
1571
+ continue;
1572
+ }
1573
+ tokens.push({
1574
+ kind: "positional",
1575
+ index,
1576
+ value: arg
1577
+ });
1578
+ }
1579
+ return tokens;
1580
+ }
1581
+ /**
1582
+ * Check if `arg` is a short option (e.g. `-f`).
1583
+ *
1584
+ * @param arg - An argument to check
1585
+ * @returns Whether `arg` is a short option.
1586
+ */
1587
+ function isShortOption(arg) {
1588
+ return arg.length === 2 && arg.codePointAt(0) === HYPHEN_CODE && arg.codePointAt(1) !== HYPHEN_CODE;
1589
+ }
1590
+ /**
1591
+ * Check if `arg` is a short option group (e.g. `-abc`).
1592
+ *
1593
+ * @param arg - An argument to check
1594
+ * @returns Whether `arg` is a short option group.
1595
+ */
1596
+ function isShortOptionGroup(arg) {
1597
+ if (arg.length <= 2) return false;
1598
+ if (arg.codePointAt(0) !== HYPHEN_CODE) return false;
1599
+ if (arg.codePointAt(1) === HYPHEN_CODE) return false;
1600
+ return true;
1601
+ }
1602
+ /**
1603
+ * Check if `arg` is a long option (e.g. `--foo`).
1604
+ *
1605
+ * @param arg - An argument to check
1606
+ * @returns Whether `arg` is a long option.
1607
+ */
1608
+ function isLongOption(arg) {
1609
+ return hasLongOptionPrefix(arg) && !arg.includes(EQUAL_CHAR, 3);
1610
+ }
1611
+ /**
1612
+ * Check if `arg` is a long option with value (e.g. `--foo=bar`).
1613
+ *
1614
+ * @param arg - An argument to check
1615
+ * @returns Whether `arg` is a long option.
1616
+ */
1617
+ function isLongOptionAndValue(arg) {
1618
+ return hasLongOptionPrefix(arg) && arg.includes(EQUAL_CHAR, 3);
1619
+ }
1620
+ /**
1621
+ * Check if `arg` is a long option prefix (e.g. `--`).
1622
+ *
1623
+ * @param arg - An argument to check
1624
+ * @returns Whether `arg` is a long option prefix.
1625
+ */
1626
+ function hasLongOptionPrefix(arg) {
1627
+ return arg.length > 2 && ~arg.indexOf(LONG_OPTION_PREFIX);
1628
+ }
1629
+ /**
1630
+ * Check if a `value` is an option value.
1631
+ *
1632
+ * @param value - A value to check
1633
+ * @returns Whether a `value` is an option value.
1634
+ */
1635
+ function hasOptionValue(value) {
1636
+ return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
1637
+ }
1638
+
1639
+ //#endregion
1640
+ //#region node_modules/args-tokens/lib/resolver-D0hj6HpX.js
1641
+ const SKIP_POSITIONAL_DEFAULT = -1;
1642
+ /**
1643
+ * Resolve command line arguments.
1644
+ *
1645
+ * @typeParam A - {@link Args | Arguments}, which is an object that defines the command line arguments.
1646
+ *
1647
+ * @param args - An arguments that contains {@link ArgSchema | arguments schema}.
1648
+ * @param tokens - An array of {@link ArgToken | tokens}.
1649
+ * @param resolveArgs - An arguments that contains {@link ResolveArgs | resolve arguments}.
1650
+ * @returns An object that contains the values of the arguments, positional arguments, rest arguments, {@link AggregateError | validation errors}, and explicit provision status.
1651
+ *
1652
+ * @example
1653
+ * ```typescript
1654
+ * // passed tokens: --port 3000
1655
+ *
1656
+ * const { values, explicit } = resolveArgs({
1657
+ * port: {
1658
+ * type: 'number',
1659
+ * default: 8080
1660
+ * },
1661
+ * host: {
1662
+ * type: 'string',
1663
+ * default: 'localhost'
1664
+ * }
1665
+ * }, parsedTokens)
1666
+ *
1667
+ * values.port // 3000
1668
+ * values.host // 'localhost'
1669
+ *
1670
+ * explicit.port // true (explicitly provided)
1671
+ * explicit.host // false (not provided, fallback to default)
1672
+ * ```
1673
+ */
1674
+ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKIP_POSITIONAL_DEFAULT, toKebab = false } = {}) {
1675
+ const skipPositionalIndex = typeof skipPositional === "number" ? Math.max(skipPositional, SKIP_POSITIONAL_DEFAULT) : SKIP_POSITIONAL_DEFAULT;
1676
+ const rest = [];
1677
+ const optionTokens = [];
1678
+ const positionalTokens = [];
1679
+ let currentLongOption;
1680
+ let currentShortOption;
1681
+ const expandableShortOptions = [];
1682
+ function toShortValue() {
1683
+ if (expandableShortOptions.length === 0) return void 0;
1684
+ else {
1685
+ const value = expandableShortOptions.map((token) => token.name).join("");
1686
+ expandableShortOptions.length = 0;
1687
+ return value;
1688
+ }
1689
+ }
1690
+ function applyLongOptionValue(value = void 0) {
1691
+ if (currentLongOption) {
1692
+ currentLongOption.value = value;
1693
+ optionTokens.push({ ...currentLongOption });
1694
+ currentLongOption = void 0;
1695
+ }
1696
+ }
1697
+ function applyShortOptionValue(value = void 0) {
1698
+ if (currentShortOption) {
1699
+ currentShortOption.value = value || toShortValue();
1700
+ optionTokens.push({ ...currentShortOption });
1701
+ currentShortOption = void 0;
1702
+ }
1703
+ }
1704
+ /**
1705
+ * analyze phase to resolve value
1706
+ * separate tokens into positionals, long and short options, after that resolve values
1707
+ */
1708
+ const schemas = Object.values(args);
1709
+ let terminated = false;
1710
+ for (let i = 0; i < tokens.length; i++) {
1711
+ const token = tokens[i];
1712
+ if (token.kind === "positional") {
1713
+ if (terminated && token.value) {
1714
+ rest.push(token.value);
1715
+ continue;
1716
+ }
1717
+ if (currentShortOption) {
1718
+ if (schemas.find((schema) => schema.short === currentShortOption.name && schema.type === "boolean")) positionalTokens.push({ ...token });
1719
+ } else if (currentLongOption) {
1720
+ if (args[currentLongOption.name]?.type === "boolean") positionalTokens.push({ ...token });
1721
+ } else positionalTokens.push({ ...token });
1722
+ applyLongOptionValue(token.value);
1723
+ applyShortOptionValue(token.value);
1724
+ } else if (token.kind === "option") if (token.rawName) {
1725
+ if (hasLongOptionPrefix(token.rawName)) {
1726
+ applyLongOptionValue();
1727
+ if (token.inlineValue) optionTokens.push({ ...token });
1728
+ else currentLongOption = { ...token };
1729
+ applyShortOptionValue();
1730
+ } else if (isShortOption(token.rawName)) if (currentShortOption) {
1731
+ if (currentShortOption.index === token.index) if (shortGrouping) {
1732
+ currentShortOption.value = token.value;
1733
+ optionTokens.push({ ...currentShortOption });
1734
+ currentShortOption = { ...token };
1735
+ } else expandableShortOptions.push({ ...token });
1736
+ else {
1737
+ currentShortOption.value = toShortValue();
1738
+ optionTokens.push({ ...currentShortOption });
1739
+ currentShortOption = { ...token };
1740
+ }
1741
+ applyLongOptionValue();
1742
+ } else {
1743
+ currentShortOption = { ...token };
1744
+ applyLongOptionValue();
1745
+ }
1746
+ } else {
1747
+ if (currentShortOption && currentShortOption.index == token.index && token.inlineValue) {
1748
+ currentShortOption.value = token.value;
1749
+ optionTokens.push({ ...currentShortOption });
1750
+ currentShortOption = void 0;
1751
+ }
1752
+ applyLongOptionValue();
1753
+ }
1754
+ else {
1755
+ if (token.kind === "option-terminator") terminated = true;
1756
+ applyLongOptionValue();
1757
+ applyShortOptionValue();
1758
+ }
1759
+ }
1760
+ /**
1761
+ * check if the last long or short option is not resolved
1762
+ */
1763
+ applyLongOptionValue();
1764
+ applyShortOptionValue();
1765
+ /**
1766
+ * resolve values
1767
+ */
1768
+ const values = Object.create(null);
1769
+ const errors = [];
1770
+ const explicit = Object.create(null);
1771
+ const actualInputNames = /* @__PURE__ */ new Map();
1772
+ function checkTokenName(option, schema, token) {
1773
+ return token.name === (schema.type === "boolean" ? schema.negatable && token.name?.startsWith("no-") ? `no-${option}` : option : option);
1774
+ }
1775
+ const positionalItemCount = tokens.filter((token) => token.kind === "positional").length;
1776
+ function getPositionalSkipIndex() {
1777
+ return Math.min(skipPositionalIndex, positionalItemCount);
1778
+ }
1779
+ let positionalsCount = 0;
1780
+ for (const [rawArg, schema] of Object.entries(args)) {
1781
+ const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
1782
+ explicit[rawArg] = false;
1783
+ if (schema.type === "positional") {
1784
+ if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
1785
+ if (schema.multiple) {
1786
+ const remainingPositionals = positionalTokens.slice(positionalsCount);
1787
+ if (remainingPositionals.length > 0) {
1788
+ values[rawArg] = remainingPositionals.map((p$1) => p$1.value);
1789
+ positionalsCount += remainingPositionals.length;
1790
+ } else if (schema.required) errors.push(createRequireError(arg, schema));
1791
+ } else {
1792
+ const positional = positionalTokens[positionalsCount];
1793
+ if (positional != null) values[rawArg] = positional.value;
1794
+ else errors.push(createRequireError(arg, schema));
1795
+ positionalsCount++;
1796
+ }
1797
+ continue;
1798
+ }
1799
+ if (schema.required) {
1800
+ if (!optionTokens.find((token) => {
1801
+ return schema.short && token.name === schema.short || token.rawName && hasLongOptionPrefix(token.rawName) && token.name === arg;
1802
+ })) {
1803
+ errors.push(createRequireError(arg, schema));
1804
+ continue;
1805
+ }
1806
+ }
1807
+ for (let i = 0; i < optionTokens.length; i++) {
1808
+ const token = optionTokens[i];
1809
+ if (checkTokenName(arg, schema, token) && token.rawName != void 0 && hasLongOptionPrefix(token.rawName) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
1810
+ const invalid = validateRequire(token, arg, schema);
1811
+ if (invalid) {
1812
+ errors.push(invalid);
1813
+ continue;
1814
+ }
1815
+ explicit[rawArg] = true;
1816
+ const actualInputName = isShortOption(token.rawName) ? `-${token.name}` : `--${arg}`;
1817
+ actualInputNames.set(rawArg, actualInputName);
1818
+ if (schema.type === "boolean") token.value = void 0;
1819
+ const [parsedValue, error] = parse(token, arg, schema);
1820
+ if (error) errors.push(error);
1821
+ else if (schema.multiple) {
1822
+ values[rawArg] ||= [];
1823
+ values[rawArg].push(parsedValue);
1824
+ } else values[rawArg] = parsedValue;
1825
+ }
1826
+ }
1827
+ if (values[rawArg] == null && schema.default != null) values[rawArg] = schema.default;
1828
+ }
1829
+ const conflictErrors = checkConflicts(args, explicit, toKebab, actualInputNames);
1830
+ errors.push(...conflictErrors);
1831
+ return {
1832
+ values,
1833
+ positionals: positionalTokens.map((token) => token.value),
1834
+ rest,
1835
+ error: errors.length > 0 ? new AggregateError(errors) : void 0,
1836
+ explicit
1837
+ };
1838
+ }
1839
+ function parse(token, option, schema) {
1840
+ switch (schema.type) {
1841
+ case "string": return typeof token.value === "string" ? [token.value || schema.default, void 0] : [void 0, createTypeError(option, schema)];
1842
+ case "boolean": return token.value ? [token.value || schema.default, void 0] : [!(schema.negatable && token.name.startsWith("no-")), void 0];
1843
+ case "number":
1844
+ if (!isNumeric(token.value)) return [void 0, createTypeError(option, schema)];
1845
+ return token.value ? [+token.value, void 0] : [+(schema.default || ""), void 0];
1846
+ case "enum":
1847
+ if (schema.choices && !schema.choices.includes(token.value)) return [void 0, new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be chosen from '${schema.type}' [${schema.choices.map((c) => JSON.stringify(c)).join(", ")}] values`, option, "type", schema)];
1848
+ return [token.value || schema.default, void 0];
1849
+ case "custom":
1850
+ if (typeof schema.parse !== "function") throw new TypeError(`argument '${option}' should have a 'parse' function`);
1851
+ try {
1852
+ return [schema.parse(token.value || String(schema.default || "")), void 0];
1853
+ } catch (error) {
1854
+ return [void 0, error];
1855
+ }
1856
+ default: throw new Error(`Unsupported argument type '${schema.type}' for option '${option}'`);
1857
+ }
1858
+ }
1859
+ function createRequireError(option, schema) {
1860
+ return new ArgResolveError(schema.type === "positional" ? `Positional argument '${option}' is required` : `Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}is required`, option, "required", schema);
1861
+ }
1862
+ /**
1863
+ * An error that occurs when resolving arguments.
1864
+ * This error is thrown when the argument is not valid.
1865
+ */
1866
+ var ArgResolveError = class extends Error {
1867
+ name;
1868
+ schema;
1869
+ type;
1870
+ /**
1871
+ * Create an `ArgResolveError` instance.
1872
+ *
1873
+ * @param message - the error message
1874
+ * @param name - the name of the argument
1875
+ * @param type - the type of the error, either 'type' or 'required'
1876
+ * @param schema - the argument schema that caused the error
1877
+ */
1878
+ constructor(message, name, type, schema) {
1879
+ super(message);
1880
+ this.name = name;
1881
+ this.type = type;
1882
+ this.schema = schema;
1883
+ }
1884
+ };
1885
+ function validateRequire(token, option, schema) {
1886
+ if (schema.required && schema.type !== "boolean" && !token.value) return createRequireError(option, schema);
1887
+ }
1888
+ function isNumeric(str) {
1889
+ return str.trim() !== "" && !isNaN(str);
1890
+ }
1891
+ function createTypeError(option, schema) {
1892
+ return new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be '${schema.type}'`, option, "type", schema);
1893
+ }
1894
+ function checkConflicts(args, explicit, toKebab, actualInputNames) {
1895
+ for (const rawArg in args) {
1896
+ const schema = args[rawArg];
1897
+ if (!explicit[rawArg]) continue;
1898
+ if (!schema.conflicts) continue;
1899
+ const conflicts = Array.isArray(schema.conflicts) ? schema.conflicts : [schema.conflicts];
1900
+ for (let i = 0; i < conflicts.length; i++) {
1901
+ const conflictingArg = conflicts[i];
1902
+ if (!explicit[conflictingArg]) continue;
1903
+ const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
1904
+ const conflictingArgKebab = toKebab || args[conflictingArg]?.toKebab ? kebabnize(conflictingArg) : conflictingArg;
1905
+ return [new ArgResolveError(`Optional argument '${actualInputNames.get(rawArg) || `--${arg}`}' conflicts with '${actualInputNames.get(conflictingArg) || `--${conflictingArgKebab}`}'`, rawArg, "conflict", schema)];
1906
+ }
1907
+ }
1908
+ return [];
1909
+ }
1910
+
1911
+ //#endregion
1912
+ //#region node_modules/gunshi/lib/core-D15eimMG.js
1913
+ const EMPTY_RENDERER = () => Promise.resolve("");
1914
+ /**
1915
+ * Factory function for creating a decorators manager.
1916
+ *
1917
+ * @returns A new decorators manager instance
1918
+ */
1919
+ function createDecorators() {
1920
+ /**
1921
+ * private states
1922
+ */
1923
+ const headerDecorators = [];
1924
+ const usageDecorators = [];
1925
+ const validationDecorators = [];
1926
+ const commandDecorators = [];
1927
+ /**
1928
+ * helper function for building renderers
1929
+ */
1930
+ function buildRenderer(decorators, defaultRenderer) {
1931
+ if (decorators.length === 0) return defaultRenderer;
1932
+ let renderer$1 = defaultRenderer;
1933
+ for (const decorator$1 of decorators) {
1934
+ const previousRenderer = renderer$1;
1935
+ renderer$1 = (ctx) => decorator$1(previousRenderer, ctx);
1936
+ }
1937
+ return renderer$1;
1938
+ }
1939
+ /**
1940
+ * public interfaces
1941
+ */
1942
+ return Object.freeze({
1943
+ addHeaderDecorator(decorator$1) {
1944
+ headerDecorators.push(decorator$1);
1945
+ },
1946
+ addUsageDecorator(decorator$1) {
1947
+ usageDecorators.push(decorator$1);
1948
+ },
1949
+ addValidationErrorsDecorator(decorator$1) {
1950
+ validationDecorators.push(decorator$1);
1951
+ },
1952
+ addCommandDecorator(decorator$1) {
1953
+ commandDecorators.push(decorator$1);
1954
+ },
1955
+ get commandDecorators() {
1956
+ return [...commandDecorators];
1957
+ },
1958
+ getHeaderRenderer() {
1959
+ return buildRenderer(headerDecorators, EMPTY_RENDERER);
1960
+ },
1961
+ getUsageRenderer() {
1962
+ return buildRenderer(usageDecorators, EMPTY_RENDERER);
1963
+ },
1964
+ getValidationErrorsRenderer() {
1965
+ if (validationDecorators.length === 0) return EMPTY_RENDERER;
1966
+ let renderer$1 = EMPTY_RENDERER;
1967
+ for (const decorator$1 of validationDecorators) {
1968
+ const previousRenderer = renderer$1;
1969
+ renderer$1 = (ctx, error) => decorator$1(previousRenderer, ctx, error);
1970
+ }
1971
+ return renderer$1;
1972
+ }
1973
+ });
1974
+ }
1975
+ /**
1976
+ * Factory function for creating a plugin context.
1977
+ *
1978
+ * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command parameters.
1979
+ *
1980
+ * @param decorators - A {@linkcode Decorators} instance.
1981
+ * @param initialSubCommands - Initial sub commands map.
1982
+ * @returns A new {@linkcode PluginContext} instance.
1983
+ */
1984
+ function createPluginContext(decorators, initialSubCommands) {
1985
+ /**
1986
+ * private states
1987
+ */
1988
+ const globalOptions = /* @__PURE__ */ new Map();
1989
+ const subCommands = new Map(initialSubCommands || []);
1990
+ /**
1991
+ * public interfaces
1992
+ */
1993
+ return Object.freeze({
1994
+ get globalOptions() {
1995
+ return new Map(globalOptions);
1996
+ },
1997
+ addGlobalOption(name, schema) {
1998
+ if (!name) throw new Error("Option name must be a non-empty string");
1999
+ if (globalOptions.has(name)) throw new Error(`Global option '${name}' is already registered`);
2000
+ globalOptions.set(name, schema);
2001
+ },
2002
+ get subCommands() {
2003
+ return new Map(subCommands);
2004
+ },
2005
+ addCommand(name, command$1) {
2006
+ if (!name) throw new Error("Command name must be a non-empty string");
2007
+ if (subCommands.has(name)) throw new Error(`Command '${name}' is already registered`);
2008
+ subCommands.set(name, command$1);
2009
+ },
2010
+ hasCommand(name) {
2011
+ return subCommands.has(name);
2012
+ },
2013
+ decorateHeaderRenderer(decorator$1) {
2014
+ decorators.addHeaderDecorator(decorator$1);
2015
+ },
2016
+ decorateUsageRenderer(decorator$1) {
2017
+ decorators.addUsageDecorator(decorator$1);
2018
+ },
2019
+ decorateValidationErrorsRenderer(decorator$1) {
2020
+ decorators.addValidationErrorsDecorator(decorator$1);
2021
+ },
2022
+ decorateCommand(decorator$1) {
2023
+ decorators.addCommandDecorator(decorator$1);
2024
+ }
2025
+ });
2026
+ }
2027
+ /**
2028
+ * Resolve plugin dependencies using topological sort
2029
+ *
2030
+ * @param plugins - Array of plugins to resolve
2031
+ * @returns Array of plugins sorted by dependencies
2032
+ */
2033
+ function resolveDependencies(plugins) {
2034
+ const sorted = [];
2035
+ const visited = /* @__PURE__ */ new Set();
2036
+ const visiting = /* @__PURE__ */ new Set();
2037
+ const pluginMap = /* @__PURE__ */ new Map();
2038
+ for (const plugin$1 of plugins) if (plugin$1.id) {
2039
+ if (pluginMap.has(plugin$1.id)) console.warn(`Duplicate plugin id detected: \`${plugin$1.id}\``);
2040
+ pluginMap.set(plugin$1.id, plugin$1);
2041
+ }
2042
+ function visit(plugin$1) {
2043
+ if (!plugin$1.id) return;
2044
+ if (visited.has(plugin$1.id)) return;
2045
+ if (visiting.has(plugin$1.id)) throw new Error(`Circular dependency detected: \`${[...visiting].join(` -> `) + " -> " + plugin$1.id}\``);
2046
+ visiting.add(plugin$1.id);
2047
+ const deps = plugin$1.dependencies || [];
2048
+ for (const dep of deps) {
2049
+ const depId = typeof dep === "string" ? dep : dep.id;
2050
+ const isOptional = typeof dep === "string" ? false : dep.optional || false;
2051
+ const depPlugin = pluginMap.get(depId);
2052
+ if (!depPlugin && !isOptional) throw new Error(`Missing required dependency: \`${depId}\` on \`${plugin$1.id}\``);
2053
+ if (depPlugin) visit(depPlugin);
2054
+ }
2055
+ visiting.delete(plugin$1.id);
2056
+ visited.add(plugin$1.id);
2057
+ sorted.push(plugin$1);
2058
+ }
2059
+ for (const plugin$1 of plugins) visit(plugin$1);
2060
+ return sorted;
2061
+ }
2062
+ /**
2063
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2064
+ * @license MIT
2065
+ */
2066
+ /**
2067
+ * Run the command.
2068
+ *
2069
+ * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
2070
+ *
2071
+ * @param argv - Command line arguments
2072
+ * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
2073
+ * @param options - A {@link CliOptions | CLI options}
2074
+ * @param plugins - An array of {@link Plugin | plugins} to be applied
2075
+ * @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
2076
+ */
2077
+ async function cliCore(argv, entry, options, plugins) {
2078
+ const decorators = createDecorators();
2079
+ const pluginContext = createPluginContext(decorators, createInitialSubCommands(options, entry));
2080
+ const resolvedPlugins = await applyPlugins(pluginContext, [...plugins, ...options.plugins || []]);
2081
+ const cliOptions = normalizeCliOptions(options, decorators, pluginContext);
2082
+ const tokens = parseArgs(argv);
2083
+ const subCommand = getSubCommand(tokens);
2084
+ const { commandName: name, command: command$1, callMode } = resolveCommand(subCommand, entry, cliOptions);
2085
+ if (!command$1) throw new Error(`Command not found: ${name || ""}`);
2086
+ const args = resolveArguments(pluginContext, getCommandArgs(command$1));
2087
+ const { explicit, values, positionals, rest, error } = resolveArgs(args, tokens, {
2088
+ shortGrouping: true,
2089
+ toKebab: command$1.toKebab,
2090
+ skipPositional: callMode === "subCommand" && cliOptions.subCommands.size > 0 ? 0 : -1
2091
+ });
2092
+ const omitted = !subCommand;
2093
+ const resolvedCommand = isLazyCommand(command$1) ? await resolveLazyCommand(command$1, name, true) : command$1;
2094
+ return await executeCommand(resolvedCommand, await createCommandContext({
2095
+ args,
2096
+ explicit,
2097
+ values,
2098
+ positionals,
2099
+ rest,
2100
+ argv,
2101
+ tokens,
2102
+ omitted,
2103
+ callMode,
2104
+ command: resolvedCommand,
2105
+ extensions: getPluginExtensions(resolvedPlugins),
2106
+ validationError: error,
2107
+ cliOptions
2108
+ }), decorators.commandDecorators);
2109
+ }
2110
+ async function applyPlugins(pluginContext, plugins) {
2111
+ const sortedPlugins = resolveDependencies(plugins);
2112
+ try {
2113
+ for (const plugin$1 of sortedPlugins)
2114
+ /**
2115
+ * NOTE(kazupon):
2116
+ * strictly `Args` are not required for plugin installation.
2117
+ * because the strictly `Args` required by each plugin are unknown,
2118
+ * and the plugin side can not know what the user will specify.
2119
+ */
2120
+ await plugin$1(pluginContext);
2121
+ } catch (error) {
2122
+ console.error("Error loading plugin:", error.message);
2123
+ }
2124
+ return sortedPlugins;
2125
+ }
2126
+ function getCommandArgs(cmd) {
2127
+ if (isLazyCommand(cmd)) return cmd.args || create();
2128
+ else if (typeof cmd === "object") return cmd.args || create();
2129
+ else return create();
2130
+ }
2131
+ function resolveArguments(pluginContext, args) {
2132
+ return Object.assign(create(), Object.fromEntries(pluginContext.globalOptions), args);
2133
+ }
2134
+ const isObject = (val) => val !== null && typeof val === "object";
2135
+ function createInitialSubCommands(options, entryCmd) {
2136
+ const hasSubCommands = options.subCommands ? options.subCommands instanceof Map ? options.subCommands.size > 0 : isObject(options.subCommands) && Object.keys(options.subCommands).length > 0 : false;
2137
+ const subCommands = new Map(options.subCommands instanceof Map ? options.subCommands : []);
2138
+ if (!(options.subCommands instanceof Map) && isObject(options.subCommands)) for (const [name, cmd] of Object.entries(options.subCommands)) subCommands.set(name, cmd);
2139
+ if (hasSubCommands) {
2140
+ if (isLazyCommand(entryCmd) || typeof entryCmd === "object") {
2141
+ entryCmd.entry = true;
2142
+ subCommands.set(resolveEntryName(entryCmd), entryCmd);
2143
+ } else if (typeof entryCmd === "function") {
2144
+ const name = entryCmd.name || ANONYMOUS_COMMAND_NAME;
2145
+ subCommands.set(name, {
2146
+ run: entryCmd,
2147
+ name,
2148
+ entry: true
2149
+ });
2150
+ }
2151
+ }
2152
+ return subCommands;
2153
+ }
2154
+ function normalizeCliOptions(options, decorators, pluginContext) {
2155
+ const subCommands = new Map(pluginContext.subCommands);
2156
+ const resolvedOptions = Object.assign(create(), CLI_OPTIONS_DEFAULT, options, { subCommands });
2157
+ if (resolvedOptions.renderHeader === void 0) resolvedOptions.renderHeader = decorators.getHeaderRenderer();
2158
+ if (resolvedOptions.renderUsage === void 0) resolvedOptions.renderUsage = decorators.getUsageRenderer();
2159
+ if (resolvedOptions.renderValidationErrors === void 0) resolvedOptions.renderValidationErrors = decorators.getValidationErrorsRenderer();
2160
+ return resolvedOptions;
2161
+ }
2162
+ function getSubCommand(tokens) {
2163
+ const firstToken = tokens[0];
2164
+ return firstToken && firstToken.kind === "positional" && firstToken.index === 0 && firstToken.value ? firstToken.value : "";
2165
+ }
2166
+ const CANNOT_RESOLVE_COMMAND = { callMode: "unexpected" };
2167
+ function resolveCommand(sub, entry, options) {
2168
+ const omitted = !sub;
2169
+ function doResolveCommand() {
2170
+ if (typeof entry === "function") if ("commandName" in entry && entry.commandName) return {
2171
+ commandName: entry.commandName,
2172
+ command: entry,
2173
+ callMode: "entry"
2174
+ };
2175
+ else return {
2176
+ command: {
2177
+ run: entry,
2178
+ entry: true
2179
+ },
2180
+ callMode: "entry"
2181
+ };
2182
+ else if (typeof entry === "object") return {
2183
+ commandName: resolveEntryName(entry),
2184
+ command: entry,
2185
+ callMode: "entry"
2186
+ };
2187
+ else return CANNOT_RESOLVE_COMMAND;
2188
+ }
2189
+ if (omitted || options.subCommands?.size === 0) return doResolveCommand();
2190
+ const cmd = options.subCommands?.get(sub);
2191
+ if (cmd == null) {
2192
+ if (options.fallbackToEntry) return doResolveCommand();
2193
+ return {
2194
+ commandName: sub,
2195
+ callMode: "unexpected"
2196
+ };
2197
+ }
2198
+ if (isLazyCommand(cmd) && cmd.commandName == null) cmd.commandName = sub;
2199
+ else if (typeof cmd === "object" && cmd.name == null) cmd.name = sub;
2200
+ return {
2201
+ commandName: sub,
2202
+ command: cmd,
2203
+ callMode: "subCommand"
2204
+ };
2205
+ }
2206
+ function resolveEntryName(entry) {
2207
+ return isLazyCommand(entry) ? entry.commandName || ANONYMOUS_COMMAND_NAME : entry.name || ANONYMOUS_COMMAND_NAME;
2208
+ }
2209
+ function getPluginExtensions(plugins) {
2210
+ const extensions = create();
2211
+ for (const plugin$1 of plugins) if (plugin$1.extension) {
2212
+ const key = plugin$1.id;
2213
+ if (extensions[key]) console.warn(`Plugin "${key}" is already installed. Ignore it for command context extending.`);
2214
+ else extensions[key] = plugin$1.extension;
2215
+ }
2216
+ return extensions;
2217
+ }
2218
+ async function executeCommand(cmd, ctx, decorators) {
2219
+ const baseRunner = cmd.run || NOOP;
2220
+ const decoratedRunner = decorators.reduceRight((runner, decorator$1) => decorator$1(runner), baseRunner);
2221
+ try {
2222
+ if (ctx.env.onBeforeCommand) await ctx.env.onBeforeCommand(ctx);
2223
+ const result = await decoratedRunner(ctx);
2224
+ if (ctx.env.onAfterCommand) await ctx.env.onAfterCommand(ctx, result);
2225
+ return typeof result === "string" ? result : void 0;
2226
+ } catch (error) {
2227
+ if (ctx.env.onErrorCommand) try {
2228
+ await ctx.env.onErrorCommand(ctx, error);
2229
+ } catch (hookError) {
2230
+ console.error("Error in onErrorCommand hook:", hookError);
2231
+ }
2232
+ throw error;
2233
+ }
2234
+ }
2235
+
2236
+ //#endregion
2237
+ //#region node_modules/gunshi/lib/definition.js
2238
+ /**
2239
+ * Define a {@link Command | command}.
2240
+ *
2241
+ * @typeParam G - A {@link GunshiParamsConstraint} type
2242
+ *
2243
+ * @param definition - A {@link Command | command} definition
2244
+ * @returns A defined {@link Command | command}
2245
+ */
2246
+ function define(definition) {
2247
+ return definition;
2248
+ }
2249
+
2250
+ //#endregion
2251
+ //#region node_modules/gunshi/lib/plugin-vBhmK2n3.js
2252
+ const NOOP_EXTENSION = () => {
2253
+ return Object.create(null);
2254
+ };
2255
+ /**
2256
+ * Define a plugin
2257
+ *
2258
+ * @param options - {@linkcode PluginOptions | plugin options}
2259
+ * @returns A defined plugin
2260
+ *
2261
+ * @since v0.27.0
2262
+ */
2263
+ function plugin(options = {}) {
2264
+ const { id, name, setup, onExtension, dependencies: dependencies$1 } = options;
2265
+ const extension$1 = options.extension || NOOP_EXTENSION;
2266
+ const pluginFn = async (ctx) => {
2267
+ if (setup) await setup(ctx);
2268
+ };
2269
+ const props = {
2270
+ writable: false,
2271
+ enumerable: true,
2272
+ configurable: true
2273
+ };
2274
+ return Object.defineProperties(pluginFn, {
2275
+ id: {
2276
+ value: id,
2277
+ ...props
2278
+ },
2279
+ ...name && { name: {
2280
+ value: name,
2281
+ ...props
2282
+ } },
2283
+ ...dependencies$1 && { dependencies: {
2284
+ value: dependencies$1,
2285
+ ...props
2286
+ } },
2287
+ ...extension$1 && { extension: {
2288
+ value: {
2289
+ key: Symbol(id),
2290
+ factory: extension$1,
2291
+ onFactory: onExtension
2292
+ },
2293
+ ...props
2294
+ } }
2295
+ });
2296
+ }
2297
+
2298
+ //#endregion
2299
+ //#region node_modules/gunshi/lib/src-BXKp6yTi.js
2300
+ /**
2301
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2302
+ * @license MIT
2303
+ */
2304
+ const BUILT_IN_PREFIX = "_";
2305
+ const PLUGIN_PREFIX = "g";
2306
+ const ARG_PREFIX = "arg";
2307
+ const BUILT_IN_KEY_SEPARATOR = ":";
2308
+ const BUILD_IN_PREFIX_AND_KEY_SEPARATOR = `${BUILT_IN_PREFIX}${BUILT_IN_KEY_SEPARATOR}`;
2309
+ const ARG_PREFIX_AND_KEY_SEPARATOR = `${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}`;
2310
+ const ARG_NEGATABLE_PREFIX = "no-";
2311
+ const COMMON_ARGS = {
2312
+ help: {
2313
+ type: "boolean",
2314
+ short: "h",
2315
+ description: "Display this help message"
2316
+ },
2317
+ version: {
2318
+ type: "boolean",
2319
+ short: "v",
2320
+ description: "Display this version"
2321
+ }
2322
+ };
2323
+ var NEGATABLE = "Negatable of";
2324
+ var en_US_default = {
2325
+ COMMAND: "COMMAND",
2326
+ COMMANDS: "COMMANDS",
2327
+ SUBCOMMAND: "SUBCOMMAND",
2328
+ USAGE: "USAGE",
2329
+ ARGUMENTS: "ARGUMENTS",
2330
+ OPTIONS: "OPTIONS",
2331
+ EXAMPLES: "EXAMPLES",
2332
+ FORMORE: "For more info, run any command with the `--help` flag",
2333
+ NEGATABLE,
2334
+ DEFAULT: "default",
2335
+ CHOICES: "choices",
2336
+ help: "Display this help message",
2337
+ version: "Display this version"
2338
+ };
2339
+ /**
2340
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2341
+ * @license MIT
2342
+ */
2343
+ /**
2344
+ * Resolve a namespaced key for built-in resources.
2345
+ *
2346
+ * Built-in keys are prefixed with "_:".
2347
+ *
2348
+ * @typeParam K - The type of the built-in key to resolve. Defaults to command built-in argument and resource keys.
2349
+ *
2350
+ * @param key - The built-in key to resolve.
2351
+ * @returns Prefixed built-in key.
2352
+ */
2353
+ function resolveBuiltInKey(key) {
2354
+ return `${BUILT_IN_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
2355
+ }
2356
+ /**
2357
+ * Resolve a namespaced key for argument resources.
2358
+ *
2359
+ * Argument keys are prefixed with "arg:".
2360
+ * If the command name is provided, it will be prefixed with the command name (e.g. "cmd1:arg:foo").
2361
+ *
2362
+ * @typeParam A - The {@linkcode Args} type extracted from G
2363
+ *
2364
+ * @param key - The argument key to resolve.
2365
+ * @param name - The command name.
2366
+ * @returns Prefixed argument key.
2367
+ */
2368
+ function resolveArgKey(key, name) {
2369
+ return `${name ? `${name}${BUILT_IN_KEY_SEPARATOR}` : ""}${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
2370
+ }
2371
+ /**
2372
+ * Resolve a namespaced key for non-built-in resources.
2373
+ *
2374
+ * Non-built-in keys are not prefixed with any special characters. If the command name is provided, it will be prefixed with the command name (e.g. "cmd1:foo").
2375
+ *
2376
+ * @typeParam T - The type of the non-built-in key to resolve. Defaults to string.
2377
+ *
2378
+ * @param key - The non-built-in key to resolve.
2379
+ * @param name - The command name.
2380
+ * @returns Prefixed non-built-in key.
2381
+ */
2382
+ function resolveKey(key, name) {
2383
+ return `${name ? `${name}${BUILT_IN_KEY_SEPARATOR}` : ""}${key}`;
2384
+ }
2385
+ /**
2386
+ * Resolve command examples.
2387
+ *
2388
+ * @typeParam G - Type parameter extending {@linkcode GunshiParams}
2389
+ *
2390
+ * @param ctx - A {@linkcode CommandContext | command context}.
2391
+ * @param examples - The examples to resolve, which can be a string or a {@linkcode CommandExamplesFetcher | function} that returns a string.
2392
+ * @returns A resolved string of examples.
2393
+ */
2394
+ async function resolveExamples(ctx, examples) {
2395
+ return typeof examples === "string" ? examples : typeof examples === "function" ? await examples(ctx) : "";
2396
+ }
2397
+ /**
2398
+ * Generate a namespaced key for a plugin.
2399
+ *
2400
+ * @typeParam K - The type of the plugin id to generate a namespaced key for.
2401
+ *
2402
+ * @param id - A plugin id to generate a namespaced key.
2403
+ * @returns A namespaced key for the plugin.
2404
+ */
2405
+ function namespacedId(id) {
2406
+ return `${PLUGIN_PREFIX}${BUILT_IN_KEY_SEPARATOR}${id}`;
2407
+ }
2408
+ /**
2409
+ * Generate a short and long option pair for command arguments.
2410
+ *
2411
+ * @param schema - The {@linkcode ArgSchema | argument schema} to generate the option pair.
2412
+ * @param name - The name of the argument.
2413
+ * @param toKebab - Whether to convert the name to kebab-case for display in help text.
2414
+ * @returns A string representing the short and long option pair.
2415
+ */
2416
+ function makeShortLongOptionPair(schema, name, toKebab) {
2417
+ let key = `--${toKebab || schema.toKebab ? kebabnize(name) : name}`;
2418
+ if (schema.short) key = `-${schema.short}, ${key}`;
2419
+ return key;
2420
+ }
2421
+ /**
2422
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2423
+ * @license MIT
2424
+ */
2425
+ /**
2426
+ * Create a localizable function for a command.
2427
+ *
2428
+ * This function will resolve the translation key based on the command context and the provided translation function.
2429
+ *
2430
+ * @typeParam A - The {@linkcode Args} type extracted from Gunshi command.
2431
+ * @typeParam C - Additional context type for command localization.
2432
+ * @typeParam E - Extended resource keys type.
2433
+ *
2434
+ * @param ctx - Command context
2435
+ * @param cmd - Command
2436
+ * @param translate - Translation function
2437
+ * @returns Localizable function
2438
+ */
2439
+ function localizable(ctx, cmd, translate) {
2440
+ async function localize(key, values) {
2441
+ if (translate) return translate(key, values);
2442
+ if (key.startsWith(BUILD_IN_PREFIX_AND_KEY_SEPARATOR)) return en_US_default[key.slice(BUILD_IN_PREFIX_AND_KEY_SEPARATOR.length)] || key;
2443
+ const namaspacedArgKey = resolveKey(ARG_PREFIX_AND_KEY_SEPARATOR, ctx.name);
2444
+ if (key.startsWith(namaspacedArgKey)) {
2445
+ let argKey = key.slice(namaspacedArgKey.length);
2446
+ let negatable = false;
2447
+ if (argKey.startsWith(ARG_NEGATABLE_PREFIX)) {
2448
+ argKey = argKey.slice(3);
2449
+ negatable = true;
2450
+ }
2451
+ const schema = ctx.args[argKey];
2452
+ if (!schema) return argKey;
2453
+ return negatable && schema.type === "boolean" && schema.negatable ? `${NEGATABLE} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
2454
+ }
2455
+ if (key === resolveKey("description", ctx.name)) return "";
2456
+ else if (key === resolveKey("examples", ctx.name)) return await resolveExamples(ctx, cmd.examples);
2457
+ else return key;
2458
+ }
2459
+ return localize;
2460
+ }
2461
+ /**
2462
+ * Render the header.
2463
+ *
2464
+ * @param ctx - A {@link CommandContext | command context}
2465
+ * @returns A rendered header.
2466
+ */
2467
+ function renderHeader(ctx) {
2468
+ const title = ctx.env.description || ctx.env.name || "";
2469
+ return Promise.resolve(title ? `${title} (${ctx.env.name || ""}${ctx.env.version ? ` v${ctx.env.version}` : ""})` : title);
2470
+ }
2471
+ /**
2472
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2473
+ * @license MIT
2474
+ */
2475
+ /**
2476
+ * The unique identifier for usage renderer plugin.
2477
+ */
2478
+ const pluginId$1 = namespacedId("renderer");
2479
+ /**
2480
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2481
+ * @license MIT
2482
+ */
2483
+ const COMMON_ARGS_KEYS = Object.keys(COMMON_ARGS);
2484
+ /**
2485
+ * Render the usage.
2486
+ *
2487
+ * @param ctx - A {@link CommandContext | command context}
2488
+ * @returns A rendered usage.
2489
+ */
2490
+ async function renderUsage(ctx) {
2491
+ const messages = [];
2492
+ if (!ctx.omitted) {
2493
+ const description = await resolveDescription(ctx);
2494
+ if (description) messages.push(description, "");
2495
+ }
2496
+ messages.push(...await renderUsageSection(ctx), "");
2497
+ if (ctx.omitted && await hasCommands(ctx)) messages.push(...await renderCommandsSection(ctx), "");
2498
+ if (hasPositionalArgs(ctx.args)) messages.push(...await renderPositionalArgsSection(ctx), "");
2499
+ if (hasOptionalArgs(ctx.args)) messages.push(...await renderOptionalArgsSection(ctx), "");
2500
+ const examples = await renderExamplesSection(ctx);
2501
+ if (examples.length > 0) messages.push(...examples, "");
2502
+ return messages.join("\n");
2503
+ }
2504
+ /**
2505
+ * Render the positional arguments section
2506
+ *
2507
+ * @param ctx - A {@link CommandContext | command context}
2508
+ * @returns A rendered arguments section
2509
+ */
2510
+ async function renderPositionalArgsSection(ctx) {
2511
+ const messages = [];
2512
+ messages.push(`${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("ARGUMENTS"))}:`);
2513
+ messages.push(await generatePositionalArgsUsage(ctx));
2514
+ return messages;
2515
+ }
2516
+ /**
2517
+ * Render the optional arguments section
2518
+ *
2519
+ * @param ctx - A {@link CommandContext | command context}
2520
+ * @returns A rendered options section
2521
+ */
2522
+ async function renderOptionalArgsSection(ctx) {
2523
+ const messages = [];
2524
+ messages.push(`${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("OPTIONS"))}:`);
2525
+ messages.push(await generateOptionalArgsUsage(ctx, getOptionalArgsPairs(ctx)));
2526
+ return messages;
2527
+ }
2528
+ /**
2529
+ * Render the examples section
2530
+ *
2531
+ * @param ctx - A {@link CommandContext | command context}
2532
+ * @returns A rendered examples section
2533
+ */
2534
+ async function renderExamplesSection(ctx) {
2535
+ const messages = [];
2536
+ const resolvedExamples = await resolveExamples$1(ctx);
2537
+ if (resolvedExamples) {
2538
+ const examples = resolvedExamples.split("\n").map((example) => example.padStart(ctx.env.leftMargin + example.length));
2539
+ messages.push(`${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("EXAMPLES"))}:`, ...examples);
2540
+ }
2541
+ return messages;
2542
+ }
2543
+ /**
2544
+ * Render the usage section
2545
+ *
2546
+ * @param ctx - A {@link CommandContext | command context}
2547
+ * @returns A rendered usage section
2548
+ */
2549
+ async function renderUsageSection(ctx) {
2550
+ const messages = [`${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("USAGE"))}:`];
2551
+ const usageStr = await makeUsageSymbols(ctx);
2552
+ messages.push(usageStr.padStart(ctx.env.leftMargin + usageStr.length));
2553
+ return messages;
2554
+ }
2555
+ async function makeUsageSymbols(ctx) {
2556
+ const messages = [await resolveEntry(ctx)];
2557
+ if (ctx.omitted) if (await hasCommands(ctx)) messages.push(` [${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("COMMANDS"))}]`);
2558
+ else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
2559
+ else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
2560
+ const optionsSymbols = await generateOptionsSymbols(ctx, ctx.args);
2561
+ if (optionsSymbols) messages.push(" ", optionsSymbols);
2562
+ const positionalSymbols = generatePositionalSymbols(ctx.args);
2563
+ if (positionalSymbols) messages.push(" ", positionalSymbols);
2564
+ return messages.join("");
2565
+ }
2566
+ /**
2567
+ * Render the commands section
2568
+ *
2569
+ * @param ctx - A {@link CommandContext | command context}
2570
+ * @returns A rendered commands section
2571
+ */
2572
+ async function renderCommandsSection(ctx) {
2573
+ const messages = [`${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("COMMANDS"))}:`];
2574
+ const loadedCommands = await ctx.extensions?.[pluginId$1].loadCommands() || [];
2575
+ const commandMaxLength = Math.max(...loadedCommands.map((cmd) => (cmd.name || "").length));
2576
+ const commandsStr = await Promise.all(loadedCommands.map(async (cmd) => {
2577
+ const desc = cmd.description || "";
2578
+ const optionSymbol = await generateOptionsSymbols(ctx, ctx.args);
2579
+ const positionalSymbol = generatePositionalSymbols(ctx.args);
2580
+ const commandStr = await makeCommandSymbol(ctx, cmd);
2581
+ const symbolLength = desc.length > 0 ? commandMaxLength + optionSymbol.length + positionalSymbol.length : 0;
2582
+ const command$1 = `${commandStr.padEnd(symbolLength + ctx.env.middleMargin)}${desc}`;
2583
+ return `${command$1.padStart(ctx.env.leftMargin + command$1.length)}`;
2584
+ }));
2585
+ messages.push(...commandsStr, "", `${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("FORMORE"))}:`);
2586
+ messages.push(...loadedCommands.map((cmd) => {
2587
+ let commandStr = cmd.entry ? "" : cmd.name || "";
2588
+ if (commandStr) commandStr += " ";
2589
+ const commandHelp = `${ctx.env.name} ${commandStr}--help`;
2590
+ return `${commandHelp.padStart(ctx.env.leftMargin + commandHelp.length)}`;
2591
+ }));
2592
+ return messages;
2593
+ }
2594
+ async function makeCommandSymbol(ctx, cmd) {
2595
+ const optionSymbol = await generateOptionsSymbols(ctx, ctx.args);
2596
+ const positionalSymbol = generatePositionalSymbols(ctx.args);
2597
+ let commandStr = cmd.entry ? cmd.name === void 0 || cmd.name === ANONYMOUS_COMMAND_NAME ? "" : `[${cmd.name}]` : cmd.name || "";
2598
+ if (optionSymbol) {
2599
+ if (commandStr) commandStr += " ";
2600
+ commandStr += `${optionSymbol}`;
2601
+ }
2602
+ if (positionalSymbol) {
2603
+ if (commandStr) commandStr += " ";
2604
+ commandStr += `${positionalSymbol}`;
2605
+ }
2606
+ return commandStr;
2607
+ }
2608
+ /**
2609
+ * Resolve the entry command name
2610
+ *
2611
+ * @param ctx - A {@link CommandContext | command context}
2612
+ * @returns The entry command name
2613
+ */
2614
+ async function resolveEntry(ctx) {
2615
+ return ctx.env.name || await ctx.extensions[pluginId$1].text(resolveBuiltInKey("COMMAND"));
2616
+ }
2617
+ /**
2618
+ * Resolve the sub command name
2619
+ *
2620
+ * @param ctx - A {@link CommandContext | command context}
2621
+ * @returns The sub command name
2622
+ */
2623
+ async function resolveSubCommand(ctx) {
2624
+ return ctx.name || await ctx.extensions[pluginId$1].text(resolveBuiltInKey("SUBCOMMAND"));
2625
+ }
2626
+ /**
2627
+ * Resolve the command description
2628
+ *
2629
+ * @param ctx - A {@link CommandContext | command context}
2630
+ * @returns resolved command description
2631
+ */
2632
+ async function resolveDescription(ctx) {
2633
+ return await ctx.extensions[pluginId$1].text(resolveKey("description", ctx.name)) || ctx.description || "";
2634
+ }
2635
+ /**
2636
+ * Resolve the command examples
2637
+ *
2638
+ * @param ctx - A {@link CommandContext | command context}
2639
+ * @returns resolved command examples, if not resolved, return empty string
2640
+ */
2641
+ async function resolveExamples$1(ctx) {
2642
+ const ret = await ctx.extensions[pluginId$1].text(resolveKey("examples", ctx.name));
2643
+ if (ret) return ret;
2644
+ const command$1 = ctx.env.subCommands?.get(ctx.name || "");
2645
+ return await resolveExamples(ctx, command$1?.examples);
2646
+ }
2647
+ /**
2648
+ * Check if the command has sub commands
2649
+ *
2650
+ * @param ctx - A {@link CommandContext | command context}
2651
+ * @returns True if the command has sub commands
2652
+ */
2653
+ async function hasCommands(ctx) {
2654
+ return (await ctx.extensions?.[pluginId$1].loadCommands() || []).length > 1;
2655
+ }
2656
+ /**
2657
+ * Check if the command has optional arguments
2658
+ *
2659
+ * @param args - A {@link Args | command optional arguments}
2660
+ * @returns True if the command has options
2661
+ */
2662
+ function hasOptionalArgs(args) {
2663
+ return Object.values(args).some((arg) => arg.type !== "positional");
2664
+ }
2665
+ /**
2666
+ * Check if the command has positional arguments
2667
+ *
2668
+ * @param args - A {@link Args | command positional arguments}
2669
+ * @returns True if the command has options
2670
+ */
2671
+ function hasPositionalArgs(args) {
2672
+ return Object.values(args).some((arg) => arg.type === "positional");
2673
+ }
2674
+ /**
2675
+ * Check if all options have default values
2676
+ *
2677
+ * @param args - An {@link Args | command argument}
2678
+ * @returns True if all options have default values
2679
+ */
2680
+ function hasAllDefaultOptions(args) {
2681
+ return !!(args && Object.values(args).every((arg) => arg.default));
2682
+ }
2683
+ /**
2684
+ * Generate options symbols for usage
2685
+ *
2686
+ * @param ctx - A {@link CommandContext | command context}
2687
+ * @param args - {@link Args | command arguments}
2688
+ * @returns Options symbols for usage
2689
+ */
2690
+ async function generateOptionsSymbols(ctx, args) {
2691
+ return hasOptionalArgs(args) ? hasAllDefaultOptions(args) ? `[${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("OPTIONS"))}]` : `<${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("OPTIONS"))}>` : "";
2692
+ }
2693
+ /**
2694
+ * Get optional arguments pairs for usage
2695
+ *
2696
+ * @param ctx - A {@link CommandContext | command context}
2697
+ * @returns Options pairs for usage
2698
+ */
2699
+ function getOptionalArgsPairs(ctx) {
2700
+ return Object.entries(ctx.args).reduce((acc, [name, schema]) => {
2701
+ if (schema.type === "positional") return acc;
2702
+ let key = makeShortLongOptionPair(schema, name, ctx.toKebab);
2703
+ if (schema.type !== "boolean") {
2704
+ const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
2705
+ key = schema.default ? `${key} [${displayName}]` : `${key} <${displayName}>`;
2706
+ }
2707
+ acc[name] = key;
2708
+ if (schema.type === "boolean" && schema.negatable && !COMMON_ARGS_KEYS.includes(name)) {
2709
+ const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
2710
+ acc[`${ARG_NEGATABLE_PREFIX}${name}`] = `--${ARG_NEGATABLE_PREFIX}${displayName}`;
2711
+ }
2712
+ return acc;
2713
+ }, Object.create(null));
2714
+ }
2715
+ const resolveNegatableKey = (key) => key.split(ARG_NEGATABLE_PREFIX)[1];
2716
+ function resolveNegatableType(key, ctx) {
2717
+ return ctx.args[key.startsWith(ARG_NEGATABLE_PREFIX) ? resolveNegatableKey(key) : key].type;
2718
+ }
2719
+ async function generateDefaultDisplayValue(ctx, schema) {
2720
+ return `${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("DEFAULT"))}: ${schema.default}`;
2721
+ }
2722
+ async function resolveDisplayValue(ctx, key) {
2723
+ if (COMMON_ARGS_KEYS.includes(key)) return "";
2724
+ const schema = ctx.args[key];
2725
+ if ((schema.type === "boolean" || schema.type === "number" || schema.type === "string" || schema.type === "custom") && schema.default !== void 0) return `(${await generateDefaultDisplayValue(ctx, schema)})`;
2726
+ if (schema.type === "enum") {
2727
+ const _default = schema.default === void 0 ? "" : await generateDefaultDisplayValue(ctx, schema);
2728
+ const choices = `${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("CHOICES"))}: ${schema.choices.join(" | ")}`;
2729
+ return `(${_default ? `${_default}, ${choices}` : choices})`;
2730
+ }
2731
+ return "";
2732
+ }
2733
+ /**
2734
+ * Generate optional arguments usage
2735
+ *
2736
+ * @param ctx - A {@link CommandContext | command context}
2737
+ * @param optionsPairs - Options pairs for usage
2738
+ * @returns Generated options usage
2739
+ */
2740
+ async function generateOptionalArgsUsage(ctx, optionsPairs) {
2741
+ const optionsMaxLength = Math.max(...Object.entries(optionsPairs).map(([_$2, value]) => value.length));
2742
+ const optionSchemaMaxLength = ctx.env.usageOptionType ? Math.max(...Object.entries(optionsPairs).map(([key]) => resolveNegatableType(key, ctx).length)) : 0;
2743
+ return (await Promise.all(Object.entries(optionsPairs).map(async ([key, value]) => {
2744
+ let rawDesc = await ctx.extensions[pluginId$1].text(resolveArgKey(key, ctx.name));
2745
+ if (!rawDesc && key.startsWith(ARG_NEGATABLE_PREFIX)) {
2746
+ const name = resolveNegatableKey(key);
2747
+ const schema = ctx.args[name];
2748
+ const optionKey = makeShortLongOptionPair(schema, name, ctx.toKebab);
2749
+ rawDesc = `${await ctx.extensions[pluginId$1].text(resolveBuiltInKey("NEGATABLE"))} ${optionKey}`;
2750
+ }
2751
+ const optionsSchema = ctx.env.usageOptionType ? `[${resolveNegatableType(key, ctx)}] ` : "";
2752
+ const valueDesc = key.startsWith(ARG_NEGATABLE_PREFIX) ? "" : await resolveDisplayValue(ctx, key);
2753
+ const desc = `${optionsSchema ? optionsSchema.padEnd(optionSchemaMaxLength + 3) : ""}${rawDesc}`;
2754
+ const descLength = desc.length + valueDesc.length;
2755
+ const option = `${value.padEnd((descLength > 0 ? optionsMaxLength : 0) + ctx.env.middleMargin)}${desc}${valueDesc ? ` ${valueDesc}` : ""}`;
2756
+ return `${option.padStart(ctx.env.leftMargin + option.length)}`;
2757
+ }))).join("\n");
2758
+ }
2759
+ function getPositionalArgs(args) {
2760
+ return Object.entries(args).filter(([_$2, schema]) => schema.type === "positional");
2761
+ }
2762
+ async function generatePositionalArgsUsage(ctx) {
2763
+ const positionals = getPositionalArgs(ctx.args);
2764
+ const argsMaxLength = Math.max(...positionals.map(([name]) => name.length));
2765
+ return (await Promise.all(positionals.map(async ([name]) => {
2766
+ const desc = await ctx.extensions[pluginId$1].text(resolveArgKey(name, ctx.name)) || ctx.args[name].description || "";
2767
+ const arg = `${name.padEnd(argsMaxLength + ctx.env.middleMargin)} ${desc}`;
2768
+ return `${arg.padStart(ctx.env.leftMargin + arg.length)}`;
2769
+ }))).join("\n");
2770
+ }
2771
+ function generatePositionalSymbols(args) {
2772
+ return hasPositionalArgs(args) ? getPositionalArgs(args).map(([name, arg]) => {
2773
+ const elements = [];
2774
+ if (!arg.multiple || arg.required) elements.push(`<${name}>`);
2775
+ if (arg.multiple) elements.push(`[<${name}> ...]`);
2776
+ return elements.join(" ");
2777
+ }).join(" ") : "";
2778
+ }
2779
+ /**
2780
+ * Render the validation errors.
2781
+ *
2782
+ * @param _ctx - A {@link CommandContext | command context}
2783
+ * @param error - An {@link AggregateError} of option in `args-token` validation
2784
+ * @returns A rendered validation error.
2785
+ */
2786
+ function renderValidationErrors(_ctx, error) {
2787
+ const messages = [];
2788
+ for (const err of error.errors) messages.push(err.message);
2789
+ return Promise.resolve(messages.join("\n"));
2790
+ }
2791
+ /**
2792
+ * The entry point of usage renderer plugin
2793
+ *
2794
+ * @example
2795
+ * ```js
2796
+ * import renderer from '@gunshi/plugin-renderer'
2797
+ * import { cli } from 'gunshi'
2798
+ *
2799
+ * const entry = (ctx) => {
2800
+ * // ...
2801
+ * }
2802
+ *
2803
+ * await cli(process.argv.slice(2), entry, {
2804
+ * // ...
2805
+ *
2806
+ * plugins: [
2807
+ * renderer()
2808
+ * ],
2809
+ *
2810
+ * // ...
2811
+ * })
2812
+ * ```
2813
+ *
2814
+ * @module
2815
+ */
2816
+ /**
2817
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2818
+ * @license MIT
2819
+ */
2820
+ const i18nPluginId = namespacedId("i18n");
2821
+ const dependencies = [{
2822
+ id: i18nPluginId,
2823
+ optional: true
2824
+ }];
2825
+ /**
2826
+ * usage renderer plugin
2827
+ *
2828
+ * @returns A defined plugin as usage renderer
2829
+ */
2830
+ function renderer() {
2831
+ return plugin({
2832
+ id: pluginId$1,
2833
+ name: "usage renderer",
2834
+ dependencies,
2835
+ extension: (ctx, cmd) => {
2836
+ const i18n = ctx.extensions[i18nPluginId];
2837
+ let cachedCommands;
2838
+ async function loadCommands() {
2839
+ if (cachedCommands) return cachedCommands;
2840
+ const subCommands = [...ctx.env.subCommands || []];
2841
+ cachedCommands = (await Promise.all(subCommands.map(async ([name, cmd$1]) => await resolveLazyCommand(cmd$1, name)))).filter((cmd$1) => !cmd$1.internal).filter(Boolean);
2842
+ cachedCommands.sort((a, b$2) => {
2843
+ if (a.entry && !b$2.entry) return -1;
2844
+ if (!a.entry && b$2.entry) return 1;
2845
+ if (a.name && b$2.name) return a.name.localeCompare(b$2.name);
2846
+ if (a.name && !b$2.name) return -1;
2847
+ if (!a.name && b$2.name) return 1;
2848
+ return 0;
2849
+ });
2850
+ return cachedCommands;
2851
+ }
2852
+ return {
2853
+ text: localizable(ctx, cmd, i18n?.translate),
2854
+ loadCommands
2855
+ };
2856
+ },
2857
+ setup: (ctx) => {
2858
+ ctx.decorateHeaderRenderer(async (_baseRenderer, cmdCtx) => await renderHeader(cmdCtx));
2859
+ ctx.decorateUsageRenderer(async (_baseRenderer, cmdCtx) => await renderUsage(cmdCtx));
2860
+ ctx.decorateValidationErrorsRenderer(async (_baseRenderer, cmdCtx, error) => await renderValidationErrors(cmdCtx, error));
2861
+ }
2862
+ });
2863
+ }
2864
+
2865
+ //#endregion
2866
+ //#region node_modules/gunshi/lib/cli-BtnhCdFu.js
2867
+ /**
2868
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2869
+ * @license MIT
2870
+ */
2871
+ /**
2872
+ * The unique identifier for the global options plugin.
2873
+ */
2874
+ const pluginId = namespacedId("global");
2875
+ /**
2876
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2877
+ * @license MIT
2878
+ */
2879
+ /**
2880
+ * Decorator function to extend the command with global options.
2881
+ *
2882
+ * @param baseRunner - The base command runner
2883
+ * @returns A command decorator that adds global options handling
2884
+ */
2885
+ const decorator = (baseRunner) => async (ctx) => {
2886
+ const { values, validationError, extensions: { [pluginId]: { showVersion, showHeader, showUsage, showValidationErrors } } } = ctx;
2887
+ if (values.version) return showVersion();
2888
+ const buf = [];
2889
+ const header = await showHeader();
2890
+ if (header) buf.push(header);
2891
+ if (values.help) {
2892
+ const usage = await showUsage();
2893
+ if (usage) {
2894
+ buf.push(usage);
2895
+ return buf.join("\n");
2896
+ }
2897
+ return;
2898
+ }
2899
+ if (validationError) return await showValidationErrors(validationError);
2900
+ return baseRunner(ctx);
2901
+ };
2902
+ var decorator_default = decorator;
2903
+ /**
2904
+ * Extends the command context for global options plugin.
2905
+ *
2906
+ * @param ctx - The {@linkcode CommandContextCore | command context} core
2907
+ * @returns An {@linkcode GlobalExtension} of global options plugin
2908
+ */
2909
+ function extension(ctx) {
2910
+ return {
2911
+ showVersion: () => {
2912
+ const version$1 = ctx.env.version || "unknown";
2913
+ if (!ctx.env.usageSilent) ctx.log(version$1);
2914
+ return version$1;
2915
+ },
2916
+ showHeader: async () => {
2917
+ let header;
2918
+ if (ctx.env.renderHeader != null) {
2919
+ header = await ctx.env.renderHeader(ctx);
2920
+ if (header) {
2921
+ ctx.log(header);
2922
+ ctx.log();
2923
+ }
2924
+ }
2925
+ return header;
2926
+ },
2927
+ showUsage: async () => {
2928
+ if (ctx.env.renderUsage != null) {
2929
+ const usage = await ctx.env.renderUsage(ctx);
2930
+ if (usage) {
2931
+ ctx.log(usage);
2932
+ return usage;
2933
+ }
2934
+ }
2935
+ },
2936
+ showValidationErrors: async (error) => {
2937
+ if (ctx.env.renderValidationErrors === null) return;
2938
+ if (ctx.env.renderValidationErrors !== void 0) {
2939
+ const message = await ctx.env.renderValidationErrors(ctx, error);
2940
+ ctx.log(message);
2941
+ return message;
2942
+ }
2943
+ }
2944
+ };
2945
+ }
2946
+ /**
2947
+ * The entry point of global options plugin
2948
+ *
2949
+ * @example
2950
+ * ```js
2951
+ * import global from '@gunshi/plugin-global'
2952
+ * import { cli } from 'gunshi'
2953
+ *
2954
+ * const entry = (ctx) => {
2955
+ * // ...
2956
+ * }
2957
+ *
2958
+ * await cli(process.argv.slice(2), entry, {
2959
+ * // ...
2960
+ *
2961
+ * plugins: [
2962
+ * global()
2963
+ * ],
2964
+ *
2965
+ * // ...
2966
+ * })
2967
+ * ```
2968
+ *
2969
+ * @module
2970
+ */
2971
+ /**
2972
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2973
+ * @license MIT
2974
+ */
2975
+ /**
2976
+ * global options plugin
2977
+ *
2978
+ * @returns A defined plugin as global options
2979
+ */
2980
+ function global() {
2981
+ return plugin({
2982
+ id: pluginId,
2983
+ name: "global options",
2984
+ extension,
2985
+ setup(ctx) {
2986
+ for (const [name, schema] of Object.entries(COMMON_ARGS)) ctx.addGlobalOption(name, schema);
2987
+ ctx.decorateCommand(decorator_default);
2988
+ }
2989
+ });
2990
+ }
2991
+ /**
2992
+ * @author kazuya kawaguchi (a.k.a. kazupon)
2993
+ * @license MIT
2994
+ */
2995
+ /**
2996
+ * Run the command.
2997
+ *
2998
+ * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
2999
+ *
3000
+ * @param args - Command line arguments
3001
+ * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
3002
+ * @param options - A {@link CliOptions | CLI options}
3003
+ * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
3004
+ */
3005
+ async function cli(args, entry, options = {}) {
3006
+ return cliCore(args, entry, options, [global(), renderer()]);
3007
+ }
3008
+
3009
+ //#endregion
3010
+ //#region node_modules/gunshi/lib/index.js
3011
+ namespacedId("i18n");
3012
+ BUILT_IN_PREFIX.codePointAt(0);
3013
+
3014
+ //#endregion
3015
+ //#region package.json
3016
+ var version = "0.2.1";
3017
+
3018
+ //#endregion
3019
+ //#region src/lib.ts
3020
+ function toKebabCase(str) {
3021
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
3022
+ }
3023
+ /**
3024
+ * Validates that all provided flags are known options.
3025
+ * @returns Error message if an unknown flag is found, null otherwise
3026
+ */
3027
+ function validateUnknownFlags(tokens, args) {
3028
+ const knownOptions = /* @__PURE__ */ new Set();
3029
+ knownOptions.add("help");
3030
+ knownOptions.add("h");
3031
+ knownOptions.add("version");
3032
+ knownOptions.add("v");
3033
+ for (const [key, schema] of Object.entries(args)) {
3034
+ knownOptions.add(key);
3035
+ knownOptions.add(toKebabCase(key));
3036
+ if (schema.short) knownOptions.add(schema.short);
3037
+ }
3038
+ for (const token of tokens) if (token.kind === "option" && token.name) {
3039
+ const name = token.name.startsWith("no-") ? token.name.slice(3) : token.name;
3040
+ if (!knownOptions.has(name)) return `Unknown option: --${token.name}`;
3041
+ }
3042
+ return null;
3043
+ }
3044
+ function parseEnvContent(content) {
3045
+ const result = {};
3046
+ for (const line of content.split("\n")) {
3047
+ const trimmed = line.trim();
3048
+ if (trimmed === "" || trimmed.startsWith("#")) continue;
3049
+ const equalIndex = trimmed.indexOf("=");
3050
+ if (equalIndex === -1) continue;
3051
+ const key = trimmed.slice(0, equalIndex).trim();
3052
+ let value = trimmed.slice(equalIndex + 1).trim();
3053
+ if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
3054
+ else {
3055
+ const commentIndex = value.indexOf("#");
3056
+ if (commentIndex !== -1) value = value.slice(0, commentIndex).trim();
3057
+ }
3058
+ if (key) result[key] = value;
3059
+ }
3060
+ return result;
3061
+ }
3062
+
3063
+ //#endregion
3064
+ //#region src/index.ts
3065
+ function isCancel(value) {
3066
+ return pD(value);
3067
+ }
3068
+ function exec(command, args) {
3069
+ return new Promise((resolve) => {
3070
+ const proc = spawn(command, args, {
3071
+ shell: false,
3072
+ stdio: [
3073
+ "pipe",
3074
+ "pipe",
3075
+ "pipe"
3076
+ ]
3077
+ });
3078
+ let stdout$1 = "";
3079
+ let stderr = "";
3080
+ proc.stdout.on("data", (data) => {
3081
+ stdout$1 += data.toString();
3082
+ });
3083
+ proc.stderr.on("data", (data) => {
3084
+ stderr += data.toString();
3085
+ });
3086
+ proc.on("close", (code) => {
3087
+ resolve({
3088
+ exitCode: code ?? 1,
3089
+ stdout: stdout$1,
3090
+ stderr
3091
+ });
3092
+ });
3093
+ });
3094
+ }
3095
+ const command = define({
3096
+ name: "e2sm",
3097
+ description: "Upload .env file to AWS Secrets Manager",
3098
+ args: {
3099
+ dryRun: {
3100
+ type: "boolean",
3101
+ short: "d",
3102
+ toKebab: true,
3103
+ description: "Preview JSON output without uploading"
3104
+ },
3105
+ profile: {
3106
+ type: "string",
3107
+ short: "p",
3108
+ description: "AWS profile to use"
3109
+ },
3110
+ input: {
3111
+ type: "string",
3112
+ short: "i",
3113
+ description: "Path to the .env file (skip interactive prompt)"
3114
+ },
3115
+ name: {
3116
+ type: "string",
3117
+ short: "n",
3118
+ description: "Secret name for AWS Secrets Manager (skip interactive prompt)"
3119
+ },
3120
+ region: {
3121
+ type: "string",
3122
+ short: "r",
3123
+ description: "AWS region to use (e.g., ap-northeast-1)"
3124
+ }
3125
+ },
3126
+ run: async (ctx) => {
3127
+ const unknownFlagError = validateUnknownFlags(ctx.tokens, ctx.args);
3128
+ if (unknownFlagError) {
3129
+ console.error(unknownFlagError);
3130
+ process.exit(1);
3131
+ }
3132
+ const isDryRun = ctx.values.dryRun;
3133
+ const profile = ctx.values.profile;
3134
+ const inputFlag = ctx.values.input;
3135
+ const nameFlag = ctx.values.name;
3136
+ const region = ctx.values.region;
3137
+ Ie(`e2sm v${version} - env to AWS Secrets Manager`);
3138
+ let envFilePath;
3139
+ if (inputFlag) envFilePath = inputFlag;
3140
+ else {
3141
+ const result = await he({
3142
+ message: "Enter the path to your .env file:",
3143
+ placeholder: ".env.local",
3144
+ defaultValue: ".env.local"
3145
+ });
3146
+ if (isCancel(result)) {
3147
+ xe("Operation cancelled");
3148
+ process.exit(0);
3149
+ }
3150
+ envFilePath = result;
3151
+ }
3152
+ if (!await access(envFilePath).then(() => true).catch(() => false)) {
3153
+ xe(`File not found: ${envFilePath}`);
3154
+ process.exit(1);
3155
+ }
3156
+ const envData = parseEnvContent(await readFile(envFilePath, "utf-8"));
3157
+ if (Object.keys(envData).length === 0) {
3158
+ xe("No valid environment variables found in the file");
3159
+ process.exit(1);
3160
+ }
3161
+ const jsonString = JSON.stringify(envData);
3162
+ if (isDryRun) {
3163
+ M.info("Dry-run mode: Previewing JSON output");
3164
+ console.log(inspect(envData, {
3165
+ colors: true,
3166
+ depth: null
3167
+ }));
3168
+ Se("Dry-run complete");
3169
+ return;
3170
+ }
3171
+ let secretName;
3172
+ if (nameFlag) secretName = nameFlag;
3173
+ else {
3174
+ const result = await he({
3175
+ message: "Enter the secret name for AWS Secrets Manager:",
3176
+ placeholder: "my-app/default",
3177
+ defaultValue: "my-app/default"
3178
+ });
3179
+ if (isCancel(result)) {
3180
+ xe("Operation cancelled");
3181
+ process.exit(0);
3182
+ }
3183
+ secretName = result;
3184
+ }
3185
+ const spinner = Y();
3186
+ spinner.start("Uploading to AWS Secrets Manager...");
3187
+ const profileArgs = profile ? ["--profile", profile] : [];
3188
+ const regionArgs = region ? ["--region", region] : [];
3189
+ if ((await exec("aws", [
3190
+ "secretsmanager",
3191
+ "describe-secret",
3192
+ "--secret-id",
3193
+ secretName,
3194
+ ...profileArgs,
3195
+ ...regionArgs
3196
+ ])).exitCode === 0) {
3197
+ const updateResult = await exec("aws", [
3198
+ "secretsmanager",
3199
+ "put-secret-value",
3200
+ "--secret-id",
3201
+ secretName,
3202
+ "--secret-string",
3203
+ jsonString,
3204
+ ...profileArgs,
3205
+ ...regionArgs
3206
+ ]);
3207
+ if (updateResult.exitCode !== 0) {
3208
+ spinner.stop("Failed to update secret");
3209
+ xe(`Error: ${updateResult.stderr}`);
3210
+ process.exit(1);
3211
+ }
3212
+ spinner.stop("Secret updated successfully");
3213
+ } else {
3214
+ const createResult = await exec("aws", [
3215
+ "secretsmanager",
3216
+ "create-secret",
3217
+ "--name",
3218
+ secretName,
3219
+ "--secret-string",
3220
+ jsonString,
3221
+ ...profileArgs,
3222
+ ...regionArgs
3223
+ ]);
3224
+ if (createResult.exitCode !== 0) {
3225
+ spinner.stop("Failed to create secret");
3226
+ xe(`Error: ${createResult.stderr}`);
3227
+ process.exit(1);
3228
+ }
3229
+ spinner.stop("Secret created successfully");
3230
+ }
3231
+ Se(`Secret '${secretName}' has been saved to AWS Secrets Manager`);
3232
+ }
3233
+ });
3234
+ await cli(process.argv.slice(2), command, { version });
3235
+
3236
+ //#endregion
3237
+ export { };