@cubocompany/opengem 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.
Files changed (3) hide show
  1. package/README.md +97 -97
  2. package/dist/cli.js +1511 -0
  3. package/package.json +12 -2
package/dist/cli.js ADDED
@@ -0,0 +1,1511 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+
34
+ // node_modules/sisteransi/src/index.js
35
+ var require_src = __commonJS((exports, module) => {
36
+ var ESC2 = "\x1B";
37
+ var CSI2 = `${ESC2}[`;
38
+ var beep = "\x07";
39
+ var cursor = {
40
+ to(x, y) {
41
+ if (!y)
42
+ return `${CSI2}${x + 1}G`;
43
+ return `${CSI2}${y + 1};${x + 1}H`;
44
+ },
45
+ move(x, y) {
46
+ let ret = "";
47
+ if (x < 0)
48
+ ret += `${CSI2}${-x}D`;
49
+ else if (x > 0)
50
+ ret += `${CSI2}${x}C`;
51
+ if (y < 0)
52
+ ret += `${CSI2}${-y}A`;
53
+ else if (y > 0)
54
+ ret += `${CSI2}${y}B`;
55
+ return ret;
56
+ },
57
+ up: (count = 1) => `${CSI2}${count}A`,
58
+ down: (count = 1) => `${CSI2}${count}B`,
59
+ forward: (count = 1) => `${CSI2}${count}C`,
60
+ backward: (count = 1) => `${CSI2}${count}D`,
61
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
62
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
63
+ left: `${CSI2}G`,
64
+ hide: `${CSI2}?25l`,
65
+ show: `${CSI2}?25h`,
66
+ save: `${ESC2}7`,
67
+ restore: `${ESC2}8`
68
+ };
69
+ var scroll = {
70
+ up: (count = 1) => `${CSI2}S`.repeat(count),
71
+ down: (count = 1) => `${CSI2}T`.repeat(count)
72
+ };
73
+ var erase = {
74
+ screen: `${CSI2}2J`,
75
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
76
+ down: (count = 1) => `${CSI2}J`.repeat(count),
77
+ line: `${CSI2}2K`,
78
+ lineEnd: `${CSI2}K`,
79
+ lineStart: `${CSI2}1K`,
80
+ lines(count) {
81
+ let clear = "";
82
+ for (let i = 0;i < count; i++)
83
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
84
+ if (count)
85
+ clear += cursor.left;
86
+ return clear;
87
+ }
88
+ };
89
+ module.exports = { cursor, scroll, erase, beep };
90
+ });
91
+
92
+ // node_modules/@clack/core/dist/index.mjs
93
+ import { styleText as y } from "node:util";
94
+ import { stdout as S, stdin as $ } from "node:process";
95
+ import * as _ from "node:readline";
96
+ import P from "node:readline";
97
+
98
+ // node_modules/fast-string-truncated-width/dist/utils.js
99
+ var isAmbiguous = (x) => {
100
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
101
+ };
102
+ var isFullWidth = (x) => {
103
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
104
+ };
105
+ var isWide = (x) => {
106
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
107
+ };
108
+
109
+ // node_modules/fast-string-truncated-width/dist/index.js
110
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
111
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
112
+ var TAB_RE = /\t{1,1000}/y;
113
+ var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
114
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
115
+ var MODIFIER_RE = /\p{M}+/gu;
116
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
117
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
118
+ const LIMIT = truncationOptions.limit ?? Infinity;
119
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
120
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
121
+ const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
122
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
123
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
124
+ const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
125
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
126
+ const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
127
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
128
+ const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
129
+ let indexPrev = 0;
130
+ let index = 0;
131
+ let length = input.length;
132
+ let lengthExtra = 0;
133
+ let truncationEnabled = false;
134
+ let truncationIndex = length;
135
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
136
+ let unmatchedStart = 0;
137
+ let unmatchedEnd = 0;
138
+ let width = 0;
139
+ let widthExtra = 0;
140
+ outer:
141
+ while (true) {
142
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
143
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
144
+ lengthExtra = 0;
145
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
146
+ const codePoint = char.codePointAt(0) || 0;
147
+ if (isFullWidth(codePoint)) {
148
+ widthExtra = FULL_WIDTH_WIDTH;
149
+ } else if (isWide(codePoint)) {
150
+ widthExtra = WIDE_WIDTH;
151
+ } else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
152
+ widthExtra = AMBIGUOUS_WIDTH;
153
+ } else {
154
+ widthExtra = REGULAR_WIDTH;
155
+ }
156
+ if (width + widthExtra > truncationLimit) {
157
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
158
+ }
159
+ if (width + widthExtra > LIMIT) {
160
+ truncationEnabled = true;
161
+ break outer;
162
+ }
163
+ lengthExtra += char.length;
164
+ width += widthExtra;
165
+ }
166
+ unmatchedStart = unmatchedEnd = 0;
167
+ }
168
+ if (index >= length)
169
+ break;
170
+ LATIN_RE.lastIndex = index;
171
+ if (LATIN_RE.test(input)) {
172
+ lengthExtra = LATIN_RE.lastIndex - index;
173
+ widthExtra = lengthExtra * REGULAR_WIDTH;
174
+ if (width + widthExtra > truncationLimit) {
175
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
176
+ }
177
+ if (width + widthExtra > LIMIT) {
178
+ truncationEnabled = true;
179
+ break;
180
+ }
181
+ width += widthExtra;
182
+ unmatchedStart = indexPrev;
183
+ unmatchedEnd = index;
184
+ index = indexPrev = LATIN_RE.lastIndex;
185
+ continue;
186
+ }
187
+ ANSI_RE.lastIndex = index;
188
+ if (ANSI_RE.test(input)) {
189
+ if (width + ANSI_WIDTH > truncationLimit) {
190
+ truncationIndex = Math.min(truncationIndex, index);
191
+ }
192
+ if (width + ANSI_WIDTH > LIMIT) {
193
+ truncationEnabled = true;
194
+ break;
195
+ }
196
+ width += ANSI_WIDTH;
197
+ unmatchedStart = indexPrev;
198
+ unmatchedEnd = index;
199
+ index = indexPrev = ANSI_RE.lastIndex;
200
+ continue;
201
+ }
202
+ CONTROL_RE.lastIndex = index;
203
+ if (CONTROL_RE.test(input)) {
204
+ lengthExtra = CONTROL_RE.lastIndex - index;
205
+ widthExtra = lengthExtra * CONTROL_WIDTH;
206
+ if (width + widthExtra > truncationLimit) {
207
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
208
+ }
209
+ if (width + widthExtra > LIMIT) {
210
+ truncationEnabled = true;
211
+ break;
212
+ }
213
+ width += widthExtra;
214
+ unmatchedStart = indexPrev;
215
+ unmatchedEnd = index;
216
+ index = indexPrev = CONTROL_RE.lastIndex;
217
+ continue;
218
+ }
219
+ TAB_RE.lastIndex = index;
220
+ if (TAB_RE.test(input)) {
221
+ lengthExtra = TAB_RE.lastIndex - index;
222
+ widthExtra = lengthExtra * TAB_WIDTH;
223
+ if (width + widthExtra > truncationLimit) {
224
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
225
+ }
226
+ if (width + widthExtra > LIMIT) {
227
+ truncationEnabled = true;
228
+ break;
229
+ }
230
+ width += widthExtra;
231
+ unmatchedStart = indexPrev;
232
+ unmatchedEnd = index;
233
+ index = indexPrev = TAB_RE.lastIndex;
234
+ continue;
235
+ }
236
+ EMOJI_RE.lastIndex = index;
237
+ if (EMOJI_RE.test(input)) {
238
+ if (width + EMOJI_WIDTH > truncationLimit) {
239
+ truncationIndex = Math.min(truncationIndex, index);
240
+ }
241
+ if (width + EMOJI_WIDTH > LIMIT) {
242
+ truncationEnabled = true;
243
+ break;
244
+ }
245
+ width += EMOJI_WIDTH;
246
+ unmatchedStart = indexPrev;
247
+ unmatchedEnd = index;
248
+ index = indexPrev = EMOJI_RE.lastIndex;
249
+ continue;
250
+ }
251
+ index += 1;
252
+ }
253
+ return {
254
+ width: truncationEnabled ? truncationLimit : width,
255
+ index: truncationEnabled ? truncationIndex : length,
256
+ truncated: truncationEnabled,
257
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
258
+ };
259
+ };
260
+ var dist_default = getStringTruncatedWidth;
261
+
262
+ // node_modules/fast-string-width/dist/index.js
263
+ var NO_TRUNCATION2 = {
264
+ limit: Infinity,
265
+ ellipsis: "",
266
+ ellipsisWidth: 0
267
+ };
268
+ var fastStringWidth = (input, options = {}) => {
269
+ return dist_default(input, NO_TRUNCATION2, options).width;
270
+ };
271
+ var dist_default2 = fastStringWidth;
272
+
273
+ // node_modules/fast-wrap-ansi/lib/main.js
274
+ var ESC = "\x1B";
275
+ var CSI = "›";
276
+ var END_CODE = 39;
277
+ var ANSI_ESCAPE_BELL = "\x07";
278
+ var ANSI_CSI = "[";
279
+ var ANSI_OSC = "]";
280
+ var ANSI_SGR_TERMINATOR = "m";
281
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
282
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
283
+ var getClosingCode = (openingCode) => {
284
+ if (openingCode >= 30 && openingCode <= 37)
285
+ return 39;
286
+ if (openingCode >= 90 && openingCode <= 97)
287
+ return 39;
288
+ if (openingCode >= 40 && openingCode <= 47)
289
+ return 49;
290
+ if (openingCode >= 100 && openingCode <= 107)
291
+ return 49;
292
+ if (openingCode === 1 || openingCode === 2)
293
+ return 22;
294
+ if (openingCode === 3)
295
+ return 23;
296
+ if (openingCode === 4)
297
+ return 24;
298
+ if (openingCode === 7)
299
+ return 27;
300
+ if (openingCode === 8)
301
+ return 28;
302
+ if (openingCode === 9)
303
+ return 29;
304
+ if (openingCode === 0)
305
+ return 0;
306
+ return;
307
+ };
308
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
309
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
310
+ var wrapWord = (rows, word, columns) => {
311
+ const characters = word[Symbol.iterator]();
312
+ let isInsideEscape = false;
313
+ let isInsideLinkEscape = false;
314
+ let lastRow = rows.at(-1);
315
+ let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
316
+ let currentCharacter = characters.next();
317
+ let nextCharacter = characters.next();
318
+ let rawCharacterIndex = 0;
319
+ while (!currentCharacter.done) {
320
+ const character = currentCharacter.value;
321
+ const characterLength = dist_default2(character);
322
+ if (visible + characterLength <= columns) {
323
+ rows[rows.length - 1] += character;
324
+ } else {
325
+ rows.push(character);
326
+ visible = 0;
327
+ }
328
+ if (character === ESC || character === CSI) {
329
+ isInsideEscape = true;
330
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
331
+ }
332
+ if (isInsideEscape) {
333
+ if (isInsideLinkEscape) {
334
+ if (character === ANSI_ESCAPE_BELL) {
335
+ isInsideEscape = false;
336
+ isInsideLinkEscape = false;
337
+ }
338
+ } else if (character === ANSI_SGR_TERMINATOR) {
339
+ isInsideEscape = false;
340
+ }
341
+ } else {
342
+ visible += characterLength;
343
+ if (visible === columns && !nextCharacter.done) {
344
+ rows.push("");
345
+ visible = 0;
346
+ }
347
+ }
348
+ currentCharacter = nextCharacter;
349
+ nextCharacter = characters.next();
350
+ rawCharacterIndex += character.length;
351
+ }
352
+ lastRow = rows.at(-1);
353
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
354
+ rows[rows.length - 2] += rows.pop();
355
+ }
356
+ };
357
+ var stringVisibleTrimSpacesRight = (string) => {
358
+ const words = string.split(" ");
359
+ let last = words.length;
360
+ while (last) {
361
+ if (dist_default2(words[last - 1])) {
362
+ break;
363
+ }
364
+ last--;
365
+ }
366
+ if (last === words.length) {
367
+ return string;
368
+ }
369
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
370
+ };
371
+ var exec = (string, columns, options = {}) => {
372
+ if (options.trim !== false && string.trim() === "") {
373
+ return "";
374
+ }
375
+ let returnValue = "";
376
+ let escapeCode;
377
+ let escapeUrl;
378
+ const words = string.split(" ");
379
+ let rows = [""];
380
+ let rowLength = 0;
381
+ for (let index = 0;index < words.length; index++) {
382
+ const word = words[index];
383
+ if (options.trim !== false) {
384
+ const row = rows.at(-1) ?? "";
385
+ const trimmed = row.trimStart();
386
+ if (row.length !== trimmed.length) {
387
+ rows[rows.length - 1] = trimmed;
388
+ rowLength = dist_default2(trimmed);
389
+ }
390
+ }
391
+ if (index !== 0) {
392
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
393
+ rows.push("");
394
+ rowLength = 0;
395
+ }
396
+ if (rowLength || options.trim === false) {
397
+ rows[rows.length - 1] += " ";
398
+ rowLength++;
399
+ }
400
+ }
401
+ const wordLength = dist_default2(word);
402
+ if (options.hard && wordLength > columns) {
403
+ const remainingColumns = columns - rowLength;
404
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
405
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
406
+ if (breaksStartingNextLine < breaksStartingThisLine) {
407
+ rows.push("");
408
+ }
409
+ wrapWord(rows, word, columns);
410
+ rowLength = dist_default2(rows.at(-1) ?? "");
411
+ continue;
412
+ }
413
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
414
+ if (options.wordWrap === false && rowLength < columns) {
415
+ wrapWord(rows, word, columns);
416
+ rowLength = dist_default2(rows.at(-1) ?? "");
417
+ continue;
418
+ }
419
+ rows.push("");
420
+ rowLength = 0;
421
+ }
422
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
423
+ wrapWord(rows, word, columns);
424
+ rowLength = dist_default2(rows.at(-1) ?? "");
425
+ continue;
426
+ }
427
+ rows[rows.length - 1] += word;
428
+ rowLength += wordLength;
429
+ }
430
+ if (options.trim !== false) {
431
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
432
+ }
433
+ const preString = rows.join(`
434
+ `);
435
+ let inSurrogate = false;
436
+ for (let i = 0;i < preString.length; i++) {
437
+ const character = preString[i];
438
+ returnValue += character;
439
+ if (!inSurrogate) {
440
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
441
+ } else {
442
+ continue;
443
+ }
444
+ if (character === ESC || character === CSI) {
445
+ GROUP_REGEX.lastIndex = i + 1;
446
+ const groupsResult = GROUP_REGEX.exec(preString);
447
+ const groups = groupsResult?.groups;
448
+ if (groups?.code !== undefined) {
449
+ const code = Number.parseFloat(groups.code);
450
+ escapeCode = code === END_CODE ? undefined : code;
451
+ } else if (groups?.uri !== undefined) {
452
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
453
+ }
454
+ }
455
+ if (preString[i + 1] === `
456
+ `) {
457
+ if (escapeUrl) {
458
+ returnValue += wrapAnsiHyperlink("");
459
+ }
460
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
461
+ if (escapeCode && closingCode) {
462
+ returnValue += wrapAnsiCode(closingCode);
463
+ }
464
+ } else if (character === `
465
+ `) {
466
+ if (escapeCode && getClosingCode(escapeCode)) {
467
+ returnValue += wrapAnsiCode(escapeCode);
468
+ }
469
+ if (escapeUrl) {
470
+ returnValue += wrapAnsiHyperlink(escapeUrl);
471
+ }
472
+ }
473
+ }
474
+ return returnValue;
475
+ };
476
+ var CRLF_OR_LF = /\r?\n/;
477
+ function wrapAnsi(string, columns, options) {
478
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
479
+ `);
480
+ }
481
+
482
+ // node_modules/@clack/core/dist/index.mjs
483
+ var import_sisteransi = __toESM(require_src(), 1);
484
+ import { ReadStream as D } from "node:tty";
485
+ function d(r, t, e) {
486
+ if (!e.some((o) => !o.disabled))
487
+ return r;
488
+ const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
489
+ return e[n].disabled ? d(n, t < 0 ? -1 : 1, e) : n;
490
+ }
491
+ var E = ["up", "down", "left", "right", "space", "enter", "cancel"];
492
+ var G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
493
+ var u = { actions: new Set(E), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...G], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
494
+ function V(r, t) {
495
+ if (typeof r == "string")
496
+ return u.aliases.get(r) === t;
497
+ for (const e of r)
498
+ if (e !== undefined && V(e, t))
499
+ return true;
500
+ return false;
501
+ }
502
+ function j(r, t) {
503
+ if (r === t)
504
+ return;
505
+ const e = r.split(`
506
+ `), s = t.split(`
507
+ `), i = Math.max(e.length, s.length), n = [];
508
+ for (let o = 0;o < i; o++)
509
+ e[o] !== s[o] && n.push(o);
510
+ return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
511
+ }
512
+ var Y = globalThis.process.platform.startsWith("win");
513
+ var C = Symbol("clack:cancel");
514
+ function q(r) {
515
+ return r === C;
516
+ }
517
+ function w(r, t) {
518
+ const e = r;
519
+ e.isTTY && e.setRawMode(t);
520
+ }
521
+ function z({ input: r = $, output: t = S, overwrite: e = true, hideCursor: s = true } = {}) {
522
+ const i = _.createInterface({ input: r, output: t, prompt: "", tabSize: 1 });
523
+ _.emitKeypressEvents(r, i), r instanceof D && r.isTTY && r.setRawMode(true);
524
+ const n = (o, { name: a, sequence: h }) => {
525
+ const l = String(o);
526
+ if (V([l, a, h], "cancel")) {
527
+ s && t.write(import_sisteransi.cursor.show), process.exit(0);
528
+ return;
529
+ }
530
+ if (!e)
531
+ return;
532
+ const f = a === "return" ? 0 : -1, v = a === "return" ? -1 : 0;
533
+ _.moveCursor(t, f, v, () => {
534
+ _.clearLine(t, 1, () => {
535
+ r.once("keypress", n);
536
+ });
537
+ });
538
+ };
539
+ return s && t.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
540
+ r.off("keypress", n), s && t.write(import_sisteransi.cursor.show), r instanceof D && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
541
+ };
542
+ }
543
+ var O = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80;
544
+ var A = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20;
545
+ function R(r, t, e, s = e) {
546
+ const i = O(r ?? S);
547
+ return wrapAnsi(t, i - e.length, { hard: true, trim: false }).split(`
548
+ `).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
549
+ `);
550
+ }
551
+ var p = class {
552
+ input;
553
+ output;
554
+ _abortSignal;
555
+ rl;
556
+ opts;
557
+ _render;
558
+ _track = false;
559
+ _prevFrame = "";
560
+ _subscribers = new Map;
561
+ _cursor = 0;
562
+ state = "initial";
563
+ error = "";
564
+ value;
565
+ userInput = "";
566
+ constructor(t, e = true) {
567
+ const { input: s = $, output: i = S, render: n, signal: o, ...a } = t;
568
+ this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = e, this._abortSignal = o, this.input = s, this.output = i;
569
+ }
570
+ unsubscribe() {
571
+ this._subscribers.clear();
572
+ }
573
+ setSubscriber(t, e) {
574
+ const s = this._subscribers.get(t) ?? [];
575
+ s.push(e), this._subscribers.set(t, s);
576
+ }
577
+ on(t, e) {
578
+ this.setSubscriber(t, { cb: e });
579
+ }
580
+ once(t, e) {
581
+ this.setSubscriber(t, { cb: e, once: true });
582
+ }
583
+ emit(t, ...e) {
584
+ const s = this._subscribers.get(t) ?? [], i = [];
585
+ for (const n of s)
586
+ n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
587
+ for (const n of i)
588
+ n();
589
+ }
590
+ prompt() {
591
+ return new Promise((t) => {
592
+ if (this._abortSignal) {
593
+ if (this._abortSignal.aborted)
594
+ return this.state = "cancel", this.close(), t(C);
595
+ this._abortSignal.addEventListener("abort", () => {
596
+ this.state = "cancel", this.close();
597
+ }, { once: true });
598
+ }
599
+ this.rl = P.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
600
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
601
+ }), this.once("cancel", () => {
602
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(C);
603
+ });
604
+ });
605
+ }
606
+ _isActionKey(t, e) {
607
+ return t === "\t";
608
+ }
609
+ _setValue(t) {
610
+ this.value = t, this.emit("value", this.value);
611
+ }
612
+ _setUserInput(t, e) {
613
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
614
+ }
615
+ _clearUserInput() {
616
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
617
+ }
618
+ onKeypress(t, e) {
619
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
620
+ if (this.opts.validate) {
621
+ const s = this.opts.validate(this.value);
622
+ s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
623
+ }
624
+ this.state !== "error" && (this.state = "submit");
625
+ }
626
+ V([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
627
+ }
628
+ close() {
629
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
630
+ `), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
631
+ }
632
+ restoreCursor() {
633
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
634
+ `).length - 1;
635
+ this.output.write(import_sisteransi.cursor.move(-999, t * -1));
636
+ }
637
+ render() {
638
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
639
+ if (t !== this._prevFrame) {
640
+ if (this.state === "initial")
641
+ this.output.write(import_sisteransi.cursor.hide);
642
+ else {
643
+ const e = j(this._prevFrame, t), s = A(this.output);
644
+ if (this.restoreCursor(), e) {
645
+ const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
646
+ let o = e.lines.find((a) => a >= i);
647
+ if (o === undefined) {
648
+ this._prevFrame = t;
649
+ return;
650
+ }
651
+ if (e.lines.length === 1) {
652
+ this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
653
+ const a = t.split(`
654
+ `);
655
+ this.output.write(a[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
656
+ return;
657
+ } else if (e.lines.length > 1) {
658
+ if (i < n)
659
+ o = i;
660
+ else {
661
+ const h = o - n;
662
+ h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
663
+ }
664
+ this.output.write(import_sisteransi.erase.down());
665
+ const a = t.split(`
666
+ `).slice(o);
667
+ this.output.write(a.join(`
668
+ `)), this._prevFrame = t;
669
+ return;
670
+ }
671
+ }
672
+ this.output.write(import_sisteransi.erase.down());
673
+ }
674
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
675
+ }
676
+ }
677
+ };
678
+ function W(r, t) {
679
+ if (r === undefined || t.length === 0)
680
+ return 0;
681
+ const e = t.findIndex((s) => s.value === r);
682
+ return e !== -1 ? e : 0;
683
+ }
684
+ function B(r, t) {
685
+ return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
686
+ }
687
+ function J(r, t) {
688
+ if (t)
689
+ return r ? t : t[0];
690
+ }
691
+ var H = class extends p {
692
+ filteredOptions;
693
+ multiple;
694
+ isNavigating = false;
695
+ selectedValues = [];
696
+ focusedValue;
697
+ #e = 0;
698
+ #o = "";
699
+ #t;
700
+ #n;
701
+ #a;
702
+ get cursor() {
703
+ return this.#e;
704
+ }
705
+ get userInputWithCursor() {
706
+ if (!this.userInput)
707
+ return y(["inverse", "hidden"], "_");
708
+ if (this._cursor >= this.userInput.length)
709
+ return `${this.userInput}█`;
710
+ const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
711
+ return `${t}${y("inverse", e)}${s.join("")}`;
712
+ }
713
+ get options() {
714
+ return typeof this.#n == "function" ? this.#n() : this.#n;
715
+ }
716
+ constructor(t) {
717
+ super(t), this.#n = t.options, this.#a = t.placeholder;
718
+ const e = this.options;
719
+ this.filteredOptions = [...e], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
720
+ let s;
721
+ if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s)
722
+ for (const i of s) {
723
+ const n = e.findIndex((o) => o.value === i);
724
+ n !== -1 && (this.toggleSelected(i), this.#e = n);
725
+ }
726
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
727
+ }
728
+ _isActionKey(t, e) {
729
+ return t === "\t" || this.multiple && this.isNavigating && e.name === "space" && t !== undefined && t !== "";
730
+ }
731
+ #s(t, e) {
732
+ const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === "\t", a = this.#a, h = this.options, l = a !== undefined && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : true));
733
+ if (e.name === "tab" && o && l) {
734
+ this.userInput === "\t" && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
735
+ return;
736
+ }
737
+ s || i ? (this.#e = d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
738
+ }
739
+ deselectAll() {
740
+ this.selectedValues = [];
741
+ }
742
+ toggleSelected(t) {
743
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e) => e !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
744
+ }
745
+ #i(t) {
746
+ if (t !== this.#o) {
747
+ this.#o = t;
748
+ const e = this.options;
749
+ t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
750
+ const s = W(this.focusedValue, this.filteredOptions);
751
+ this.#e = d(s, 0, this.filteredOptions);
752
+ const i = this.filteredOptions[this.#e];
753
+ i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
754
+ }
755
+ }
756
+ };
757
+ var X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
758
+ function L(r) {
759
+ return [...r].map((t) => X[t]);
760
+ }
761
+ function Z(r) {
762
+ const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
763
+ let s = "/";
764
+ for (const i of t)
765
+ i.type === "literal" ? s = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && e.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
766
+ return { segments: e, separator: s };
767
+ }
768
+ function k(r) {
769
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
770
+ }
771
+ function I(r) {
772
+ return { year: k(r.year), month: k(r.month), day: k(r.day) };
773
+ }
774
+ function T(r, t) {
775
+ return new Date(r || 2001, t || 1, 0).getDate();
776
+ }
777
+ function F(r) {
778
+ const { year: t, month: e, day: s } = I(r);
779
+ if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
780
+ return;
781
+ const i = new Date(Date.UTC(t, e - 1, s));
782
+ if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s))
783
+ return { year: t, month: e, day: s };
784
+ }
785
+ function N(r) {
786
+ const t = F(r);
787
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
788
+ }
789
+ function tt(r, t, e, s) {
790
+ const i = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null, n = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null;
791
+ return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : T(t.year, t.month) };
792
+ }
793
+
794
+ class et extends p {
795
+ #e;
796
+ #o;
797
+ #t;
798
+ #n;
799
+ #a;
800
+ #s = { segmentIndex: 0, positionInSegment: 0 };
801
+ #i = true;
802
+ #r = null;
803
+ inlineError = "";
804
+ get segmentCursor() {
805
+ return { ...this.#s };
806
+ }
807
+ get segmentValues() {
808
+ return { ...this.#t };
809
+ }
810
+ get segments() {
811
+ return this.#e;
812
+ }
813
+ get separator() {
814
+ return this.#o;
815
+ }
816
+ get formattedValue() {
817
+ return this.#c(this.#t);
818
+ }
819
+ #c(t) {
820
+ return this.#e.map((e) => t[e.type]).join(this.#o);
821
+ }
822
+ #h() {
823
+ this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
824
+ }
825
+ constructor(t) {
826
+ const e = t.format ? { segments: L(t.format), separator: t.separator ?? "/" } : Z(t.locale), s = t.separator ?? e.separator, i = t.format ? L(t.format) : e.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, a = i.map((h) => o[h.type]).join(s);
827
+ super({ ...t, initialUserInput: a }, false), this.#e = i, this.#o = s, this.#t = o, this.#n = t.minDate, this.#a = t.maxDate, this.#h(), this.on("cursor", (h) => this.#d(h)), this.on("key", (h, l) => this.#f(h, l)), this.on("finalize", () => this.#g(t));
828
+ }
829
+ #u() {
830
+ const t = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t];
831
+ if (e)
832
+ return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t };
833
+ }
834
+ #l(t) {
835
+ this.inlineError = "", this.#r = null;
836
+ const e = this.#u();
837
+ e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t)), this.#s.positionInSegment = 0, this.#i = true);
838
+ }
839
+ #p(t) {
840
+ const e = this.#u();
841
+ if (!e)
842
+ return;
843
+ const { segment: s } = e, i = this.#t[s.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, a = tt(s.type, I(this.#t), this.#n, this.#a);
844
+ let h;
845
+ n ? h = t === 1 ? a.min : a.max : h = Math.max(Math.min(a.max, o + t), a.min), this.#t = { ...this.#t, [s.type]: h.toString().padStart(s.len, "0") }, this.#i = true, this.#r = null, this.#h();
846
+ }
847
+ #d(t) {
848
+ if (t)
849
+ switch (t) {
850
+ case "right":
851
+ return this.#l(1);
852
+ case "left":
853
+ return this.#l(-1);
854
+ case "up":
855
+ return this.#p(1);
856
+ case "down":
857
+ return this.#p(-1);
858
+ }
859
+ }
860
+ #f(t, e) {
861
+ if (e?.name === "backspace" || e?.sequence === "" || e?.sequence === "\b" || t === "" || t === "\b") {
862
+ this.inlineError = "";
863
+ const s = this.#u();
864
+ if (!s)
865
+ return;
866
+ if (!this.#t[s.segment.type].replace(/_/g, "")) {
867
+ this.#l(-1);
868
+ return;
869
+ }
870
+ this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
871
+ return;
872
+ }
873
+ if (e?.name === "tab") {
874
+ this.inlineError = "";
875
+ const s = this.#u();
876
+ if (!s)
877
+ return;
878
+ const i = e.shift ? -1 : 1, n = s.index + i;
879
+ n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
880
+ return;
881
+ }
882
+ if (t && /^[0-9]$/.test(t)) {
883
+ const s = this.#u();
884
+ if (!s)
885
+ return;
886
+ const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
887
+ if (this.#i && this.#r !== null && !n) {
888
+ const m = this.#r + t, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
889
+ if (b) {
890
+ this.inlineError = b, this.#r = null, this.#i = false;
891
+ return;
892
+ }
893
+ this.inlineError = "", this.#t[i.type] = m, this.#r = null, this.#i = false, this.#h(), s.index < this.#e.length - 1 && (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true);
894
+ return;
895
+ }
896
+ this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
897
+ const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
898
+ if (h < 0 || h >= i.len)
899
+ return;
900
+ let l = o.slice(0, h) + t + o.slice(h + 1), f = false;
901
+ if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
902
+ const m = Number.parseInt(t, 10);
903
+ l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
904
+ }
905
+ if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
906
+ const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
907
+ if (g) {
908
+ this.inlineError = g;
909
+ return;
910
+ }
911
+ }
912
+ this.inlineError = "", this.#t[i.type] = l;
913
+ const v = l.includes("_") ? undefined : F(this.#t);
914
+ if (v) {
915
+ const { year: m, month: g } = v, b = T(m, g);
916
+ this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(b, v.day))).padStart(2, "0") };
917
+ }
918
+ this.#h();
919
+ const U = l.indexOf("_");
920
+ f ? (this.#i = true, this.#r = t) : U >= 0 ? this.#s.positionInSegment = U : a >= 0 && s.index < this.#e.length - 1 ? (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true) : this.#s.positionInSegment = Math.min(h + 1, i.len - 1);
921
+ }
922
+ }
923
+ #m(t, e) {
924
+ const { month: s, day: i } = I(t);
925
+ if (e.type === "month" && (s < 0 || s > 12))
926
+ return u.date.messages.invalidMonth;
927
+ if (e.type === "day" && (i < 0 || i > 31))
928
+ return u.date.messages.invalidDay(31, "any month");
929
+ }
930
+ #g(t) {
931
+ const { year: e, month: s, day: i } = I(this.#t);
932
+ if (e && s && i) {
933
+ const n = T(e, s);
934
+ this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
935
+ }
936
+ this.value = N(this.#t) ?? t.defaultValue ?? undefined;
937
+ }
938
+ }
939
+
940
+ class st extends p {
941
+ options;
942
+ cursor = 0;
943
+ #e;
944
+ getGroupItems(t) {
945
+ return this.options.filter((e) => e.group === t);
946
+ }
947
+ isGroupSelected(t) {
948
+ const e = this.getGroupItems(t), s = this.value;
949
+ return s === undefined ? false : e.every((i) => s.includes(i.value));
950
+ }
951
+ toggleValue() {
952
+ const t = this.options[this.cursor];
953
+ if (this.value === undefined && (this.value = []), t.group === true) {
954
+ const e = t.value, s = this.getGroupItems(e);
955
+ this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
956
+ } else {
957
+ const e = this.value.includes(t.value);
958
+ this.value = e ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
959
+ }
960
+ }
961
+ constructor(t) {
962
+ super(t, false);
963
+ const { options: e } = t;
964
+ this.#e = t.selectableGroups !== false, this.options = Object.entries(e).flatMap(([s, i]) => [{ value: s, group: true, label: s }, ...i.map((n) => ({ ...n, group: s }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
965
+ switch (s) {
966
+ case "left":
967
+ case "up": {
968
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
969
+ const i = this.options[this.cursor]?.group === true;
970
+ !this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
971
+ break;
972
+ }
973
+ case "down":
974
+ case "right": {
975
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
976
+ const i = this.options[this.cursor]?.group === true;
977
+ !this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
978
+ break;
979
+ }
980
+ case "space":
981
+ this.toggleValue();
982
+ break;
983
+ }
984
+ });
985
+ }
986
+ }
987
+ class nt extends p {
988
+ options;
989
+ cursor = 0;
990
+ get _selectedValue() {
991
+ return this.options[this.cursor];
992
+ }
993
+ changeValue() {
994
+ this.value = this._selectedValue.value;
995
+ }
996
+ constructor(t) {
997
+ super(t, false), this.options = t.options;
998
+ const e = this.options.findIndex(({ value: i }) => i === t.initialValue), s = e === -1 ? 0 : e;
999
+ this.cursor = this.options[s].disabled ? d(s, 1, this.options) : s, this.changeValue(), this.on("cursor", (i) => {
1000
+ switch (i) {
1001
+ case "left":
1002
+ case "up":
1003
+ this.cursor = d(this.cursor, -1, this.options);
1004
+ break;
1005
+ case "down":
1006
+ case "right":
1007
+ this.cursor = d(this.cursor, 1, this.options);
1008
+ break;
1009
+ }
1010
+ this.changeValue();
1011
+ });
1012
+ }
1013
+ }
1014
+ class at extends p {
1015
+ get userInputWithCursor() {
1016
+ if (this.state === "submit")
1017
+ return this.userInput;
1018
+ const t = this.userInput;
1019
+ if (this.cursor >= t.length)
1020
+ return `${this.userInput}█`;
1021
+ const e = t.slice(0, this.cursor), [s, ...i] = t.slice(this.cursor);
1022
+ return `${e}${y("inverse", s)}${i.join("")}`;
1023
+ }
1024
+ get cursor() {
1025
+ return this._cursor;
1026
+ }
1027
+ constructor(t) {
1028
+ super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (e) => {
1029
+ this._setValue(e);
1030
+ }), this.on("finalize", () => {
1031
+ this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
1032
+ });
1033
+ }
1034
+ }
1035
+
1036
+ // node_modules/@clack/prompts/dist/index.mjs
1037
+ import { styleText as t, stripVTControlCharacters as ne } from "node:util";
1038
+ import P2 from "node:process";
1039
+ var import_sisteransi2 = __toESM(require_src(), 1);
1040
+ function Ze() {
1041
+ return P2.platform !== "win32" ? P2.env.TERM !== "linux" : !!P2.env.CI || !!P2.env.WT_SESSION || !!P2.env.TERMINUS_SUBLIME || P2.env.ConEmuTask === "{cmd::Cmder}" || P2.env.TERM_PROGRAM === "Terminus-Sublime" || P2.env.TERM_PROGRAM === "vscode" || P2.env.TERM === "xterm-256color" || P2.env.TERM === "alacritty" || P2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1042
+ }
1043
+ var ee = Ze();
1044
+ var ae = () => process.env.CI === "true";
1045
+ var w2 = (e, i) => ee ? e : i;
1046
+ var _e = w2("◆", "*");
1047
+ var oe = w2("■", "x");
1048
+ var ue = w2("▲", "x");
1049
+ var F2 = w2("◇", "o");
1050
+ var le = w2("┌", "T");
1051
+ var d2 = w2("│", "|");
1052
+ var E2 = w2("└", "—");
1053
+ var Ie = w2("┐", "T");
1054
+ var Ee = w2("┘", "—");
1055
+ var z2 = w2("●", ">");
1056
+ var H2 = w2("○", " ");
1057
+ var te = w2("◻", "[•]");
1058
+ var U = w2("◼", "[+]");
1059
+ var J2 = w2("◻", "[ ]");
1060
+ var xe = w2("▪", "•");
1061
+ var se = w2("─", "-");
1062
+ var ce = w2("╮", "+");
1063
+ var Ge = w2("├", "+");
1064
+ var $e = w2("╯", "+");
1065
+ var de = w2("╰", "+");
1066
+ var Oe = w2("╭", "+");
1067
+ var he = w2("●", "•");
1068
+ var pe = w2("◆", "*");
1069
+ var me = w2("▲", "!");
1070
+ var ge = w2("■", "x");
1071
+ var V2 = (e) => {
1072
+ switch (e) {
1073
+ case "initial":
1074
+ case "active":
1075
+ return t("cyan", _e);
1076
+ case "cancel":
1077
+ return t("red", oe);
1078
+ case "error":
1079
+ return t("yellow", ue);
1080
+ case "submit":
1081
+ return t("green", F2);
1082
+ }
1083
+ };
1084
+ var ye = (e) => {
1085
+ switch (e) {
1086
+ case "initial":
1087
+ case "active":
1088
+ return t("cyan", d2);
1089
+ case "cancel":
1090
+ return t("red", d2);
1091
+ case "error":
1092
+ return t("yellow", d2);
1093
+ case "submit":
1094
+ return t("green", d2);
1095
+ }
1096
+ };
1097
+ var et2 = (e, i, s, r, u2) => {
1098
+ let n = i, o = 0;
1099
+ for (let c2 = s;c2 < r; c2++) {
1100
+ const a = e[c2];
1101
+ if (n = n - a.length, o++, n <= u2)
1102
+ break;
1103
+ }
1104
+ return { lineCount: n, removals: o };
1105
+ };
1106
+ var Y2 = ({ cursor: e, options: i, style: s, output: r = process.stdout, maxItems: u2 = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
1107
+ const c2 = O(r) - n, a = A(r), l = t("dim", "..."), $2 = Math.max(a - o, 0), y2 = Math.max(Math.min(u2, $2), 5);
1108
+ let p2 = 0;
1109
+ e >= y2 - 3 && (p2 = Math.max(Math.min(e - y2 + 3, i.length - y2), 0));
1110
+ let m = y2 < i.length && p2 > 0, g = y2 < i.length && p2 + y2 < i.length;
1111
+ const S2 = Math.min(p2 + y2, i.length), h = [];
1112
+ let f = 0;
1113
+ m && f++, g && f++;
1114
+ const v = p2 + (m ? 1 : 0), T2 = S2 - (g ? 1 : 0);
1115
+ for (let b = v;b < T2; b++) {
1116
+ const x = wrapAnsi(s(i[b], b === e), c2, { hard: true, trim: false }).split(`
1117
+ `);
1118
+ h.push(x), f += x.length;
1119
+ }
1120
+ if (f > $2) {
1121
+ let b = 0, x = 0, G2 = f;
1122
+ const M2 = e - v, R2 = (j2, D2) => et2(h, G2, j2, D2, $2);
1123
+ m ? ({ lineCount: G2, removals: b } = R2(0, M2), G2 > $2 && ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length))) : ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length), G2 > $2 && ({ lineCount: G2, removals: b } = R2(0, M2))), b > 0 && (m = true, h.splice(0, b)), x > 0 && (g = true, h.splice(h.length - x, x));
1124
+ }
1125
+ const C2 = [];
1126
+ m && C2.push(l);
1127
+ for (const b of h)
1128
+ for (const x of b)
1129
+ C2.push(x);
1130
+ return g && C2.push(l), C2;
1131
+ };
1132
+ var pt = (e = "", i) => {
1133
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", E2)} ` : "";
1134
+ s.write(`${r}${t("red", e)}
1135
+
1136
+ `);
1137
+ };
1138
+ var mt = (e = "", i) => {
1139
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", le)} ` : "";
1140
+ s.write(`${r}${e}
1141
+ `);
1142
+ };
1143
+ var gt = (e = "", i) => {
1144
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", d2)}
1145
+ ${t("gray", E2)} ` : "";
1146
+ s.write(`${r}${e}
1147
+
1148
+ `);
1149
+ };
1150
+ var ft = (e) => t("dim", e);
1151
+ var vt = (e, i, s) => {
1152
+ const r = { hard: true, trim: false }, u2 = wrapAnsi(e, i, r).split(`
1153
+ `), n = u2.reduce((a, l) => Math.max(dist_default2(l), a), 0), o = u2.map(s).reduce((a, l) => Math.max(dist_default2(l), a), 0), c2 = i - (o - n);
1154
+ return wrapAnsi(e, c2, r);
1155
+ };
1156
+ var wt = (e = "", i = "", s) => {
1157
+ const r = s?.output ?? P2.stdout, u2 = s?.withGuide ?? u.withGuide, n = s?.format ?? ft, o = ["", ...vt(e, O(r) - 6, n).split(`
1158
+ `).map(n), ""], c2 = dist_default2(i), a = Math.max(o.reduce((p2, m) => {
1159
+ const g = dist_default2(m);
1160
+ return g > p2 ? g : p2;
1161
+ }, 0), c2) + 2, l = o.map((p2) => `${t("gray", d2)} ${p2}${" ".repeat(a - dist_default2(p2))}${t("gray", d2)}`).join(`
1162
+ `), $2 = u2 ? `${t("gray", d2)}
1163
+ ` : "", y2 = u2 ? Ge : de;
1164
+ r.write(`${$2}${t("green", F2)} ${t("reset", i)} ${t("gray", se.repeat(Math.max(a - c2 - 1, 1)) + ce)}
1165
+ ${l}
1166
+ ${t("gray", y2 + se.repeat(a + 2) + $e)}
1167
+ `);
1168
+ };
1169
+ var Ct = (e) => t("magenta", e);
1170
+ var fe = ({ indicator: e = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u2, frames: n = ee ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], delay: o = ee ? 80 : 120, signal: c2, ...a } = {}) => {
1171
+ const l = ae();
1172
+ let $2, y2, p2 = false, m = false, g = "", S2, h = performance.now();
1173
+ const f = O(s), v = a?.styleFrame ?? Ct, T2 = (_2) => {
1174
+ const A2 = _2 > 1 ? u2 ?? u.messages.error : r ?? u.messages.cancel;
1175
+ m = _2 === 1, p2 && (W2(A2, _2), m && typeof i == "function" && i());
1176
+ }, C2 = () => T2(2), b = () => T2(1), x = () => {
1177
+ process.on("uncaughtExceptionMonitor", C2), process.on("unhandledRejection", C2), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", T2), c2 && c2.addEventListener("abort", b);
1178
+ }, G2 = () => {
1179
+ process.removeListener("uncaughtExceptionMonitor", C2), process.removeListener("unhandledRejection", C2), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", T2), c2 && c2.removeEventListener("abort", b);
1180
+ }, M2 = () => {
1181
+ if (S2 === undefined)
1182
+ return;
1183
+ l && s.write(`
1184
+ `);
1185
+ const _2 = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
1186
+ `);
1187
+ _2.length > 1 && s.write(import_sisteransi2.cursor.up(_2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
1188
+ }, R2 = (_2) => _2.replace(/\.+$/, ""), j2 = (_2) => {
1189
+ const A2 = (performance.now() - _2) / 1000, k2 = Math.floor(A2 / 60), L2 = Math.floor(A2 % 60);
1190
+ return k2 > 0 ? `[${k2}m ${L2}s]` : `[${L2}s]`;
1191
+ }, D2 = a.withGuide ?? u.withGuide, ie = (_2 = "") => {
1192
+ p2 = true, $2 = z({ output: s }), g = R2(_2), h = performance.now(), D2 && s.write(`${t("gray", d2)}
1193
+ `);
1194
+ let A2 = 0, k2 = 0;
1195
+ x(), y2 = setInterval(() => {
1196
+ if (l && g === S2)
1197
+ return;
1198
+ M2(), S2 = g;
1199
+ const L2 = v(n[A2]);
1200
+ let Z2;
1201
+ if (l)
1202
+ Z2 = `${L2} ${g}...`;
1203
+ else if (e === "timer")
1204
+ Z2 = `${L2} ${g} ${j2(h)}`;
1205
+ else {
1206
+ const Be = ".".repeat(Math.floor(k2)).slice(0, 3);
1207
+ Z2 = `${L2} ${g}${Be}`;
1208
+ }
1209
+ const Ne = wrapAnsi(Z2, f, { hard: true, trim: false });
1210
+ s.write(Ne), A2 = A2 + 1 < n.length ? A2 + 1 : 0, k2 = k2 < 4 ? k2 + 0.125 : 0;
1211
+ }, o);
1212
+ }, W2 = (_2 = "", A2 = 0, k2 = false) => {
1213
+ if (!p2)
1214
+ return;
1215
+ p2 = false, clearInterval(y2), M2();
1216
+ const L2 = A2 === 0 ? t("green", F2) : A2 === 1 ? t("red", oe) : t("red", ue);
1217
+ g = _2 ?? g, k2 || (e === "timer" ? s.write(`${L2} ${g} ${j2(h)}
1218
+ `) : s.write(`${L2} ${g}
1219
+ `)), G2(), $2();
1220
+ };
1221
+ return { start: ie, stop: (_2 = "") => W2(_2, 0), message: (_2 = "") => {
1222
+ g = R2(_2 ?? g);
1223
+ }, cancel: (_2 = "") => W2(_2, 1), error: (_2 = "") => W2(_2, 2), clear: () => W2("", 0, true), get isCancelled() {
1224
+ return m;
1225
+ } };
1226
+ };
1227
+ var Ve = { light: w2("─", "-"), heavy: w2("━", "="), block: w2("█", "#") };
1228
+ var re = (e, i) => e.includes(`
1229
+ `) ? e.split(`
1230
+ `).map((s) => i(s)).join(`
1231
+ `) : i(e);
1232
+ var _t = (e) => {
1233
+ const i = (s, r) => {
1234
+ const u2 = s.label ?? String(s.value);
1235
+ switch (r) {
1236
+ case "disabled":
1237
+ return `${t("gray", H2)} ${re(u2, (n) => t("gray", n))}${s.hint ? ` ${t("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
1238
+ case "selected":
1239
+ return `${re(u2, (n) => t("dim", n))}`;
1240
+ case "active":
1241
+ return `${t("green", z2)} ${u2}${s.hint ? ` ${t("dim", `(${s.hint})`)}` : ""}`;
1242
+ case "cancelled":
1243
+ return `${re(u2, (n) => t(["strikethrough", "dim"], n))}`;
1244
+ default:
1245
+ return `${t("dim", H2)} ${re(u2, (n) => t("dim", n))}`;
1246
+ }
1247
+ };
1248
+ return new nt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
1249
+ const s = e.withGuide ?? u.withGuide, r = `${V2(this.state)} `, u2 = `${ye(this.state)} `, n = R(e.output, e.message, u2, r), o = `${s ? `${t("gray", d2)}
1250
+ ` : ""}${n}
1251
+ `;
1252
+ switch (this.state) {
1253
+ case "submit": {
1254
+ const c2 = s ? `${t("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "selected"), c2);
1255
+ return `${o}${a}`;
1256
+ }
1257
+ case "cancel": {
1258
+ const c2 = s ? `${t("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "cancelled"), c2);
1259
+ return `${o}${a}${s ? `
1260
+ ${t("gray", d2)}` : ""}`;
1261
+ }
1262
+ default: {
1263
+ const c2 = s ? `${t("cyan", d2)} ` : "", a = s ? t("cyan", E2) : "", l = o.split(`
1264
+ `).length, $2 = s ? 2 : 1;
1265
+ return `${o}${c2}${Y2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: c2.length, rowPadding: l + $2, style: (y2, p2) => i(y2, y2.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
1266
+ ${c2}`)}
1267
+ ${a}
1268
+ `;
1269
+ }
1270
+ }
1271
+ } }).prompt();
1272
+ };
1273
+ var je = `${t("gray", d2)} `;
1274
+ var Ot = (e) => new at({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
1275
+ const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${t("gray", d2)}
1276
+ ` : ""}${V2(this.state)} `}${e.message}
1277
+ `, r = e.placeholder ? t("inverse", e.placeholder[0]) + t("dim", e.placeholder.slice(1)) : t(["inverse", "hidden"], "_"), u2 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
1278
+ switch (this.state) {
1279
+ case "error": {
1280
+ const o = this.error ? ` ${t("yellow", this.error)}` : "", c2 = i ? `${t("yellow", d2)} ` : "", a = i ? t("yellow", E2) : "";
1281
+ return `${s.trim()}
1282
+ ${c2}${u2}
1283
+ ${a}${o}
1284
+ `;
1285
+ }
1286
+ case "submit": {
1287
+ const o = n ? ` ${t("dim", n)}` : "", c2 = i ? t("gray", d2) : "";
1288
+ return `${s}${c2}${o}`;
1289
+ }
1290
+ case "cancel": {
1291
+ const o = n ? ` ${t(["strikethrough", "dim"], n)}` : "", c2 = i ? t("gray", d2) : "";
1292
+ return `${s}${c2}${o}${n.trim() ? `
1293
+ ${c2}` : ""}`;
1294
+ }
1295
+ default: {
1296
+ const o = i ? `${t("cyan", d2)} ` : "", c2 = i ? t("cyan", E2) : "";
1297
+ return `${s}${o}${u2}
1298
+ ${c2}
1299
+ `;
1300
+ }
1301
+ }
1302
+ } }).prompt();
1303
+
1304
+ // src/cli.ts
1305
+ import { spawnSync } from "node:child_process";
1306
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
1307
+ import { homedir } from "node:os";
1308
+ import { dirname, join, resolve } from "node:path";
1309
+ function obsidian(args) {
1310
+ const r = spawnSync("obsidian", args, { encoding: "utf8" });
1311
+ return { exitCode: r.status ?? 1, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
1312
+ }
1313
+ function cliVersion() {
1314
+ const r = obsidian(["--version"]);
1315
+ if (r.exitCode !== 0)
1316
+ return null;
1317
+ return r.stdout.trim().split(`
1318
+ `)[0]?.trim() ?? null;
1319
+ }
1320
+ function appRunning() {
1321
+ return obsidian(["vault"]).exitCode === 0;
1322
+ }
1323
+ function activeVault() {
1324
+ const r = obsidian(["vault"]);
1325
+ if (r.exitCode !== 0)
1326
+ return null;
1327
+ const line = r.stdout.trim().split(`
1328
+ `).find((l) => l.startsWith("name"));
1329
+ return line ? line.split(/\s+/).slice(1).join(" ").trim() : null;
1330
+ }
1331
+ function listVaults() {
1332
+ const r = obsidian(["vaults"]);
1333
+ if (r.exitCode !== 0)
1334
+ return [];
1335
+ return r.stdout.trim().split(`
1336
+ `).filter(Boolean).map((line) => line.split("\t")[0].trim()).filter(Boolean);
1337
+ }
1338
+ var SCHEMA_MD = `# Wiki Schema
1339
+
1340
+ ## Page conventions
1341
+
1342
+ Every wiki page should follow this structure:
1343
+
1344
+ \`\`\`
1345
+ ---
1346
+ tags: [topic, subtopic]
1347
+ source: [[raw/original-source]]
1348
+ updated: YYYY-MM-DD
1349
+ ---
1350
+
1351
+ # Title
1352
+
1353
+ One paragraph summary.
1354
+
1355
+ ## Key points
1356
+ - ...
1357
+
1358
+ ## Details
1359
+ ...
1360
+
1361
+ ## See also
1362
+ - [[related-page]]
1363
+ \`\`\`
1364
+
1365
+ ## Folder structure
1366
+
1367
+ - \`raw/\` — original sources, never edited
1368
+ - \`wiki/\` — curated pages, one concept per file
1369
+ - \`schema/\` — this file and other conventions
1370
+ `;
1371
+ var INDEX_MD = `# Wiki Index
1372
+
1373
+ > generated by OpenGem — update with obsidian_wiki_refresh_index
1374
+
1375
+ `;
1376
+ function buildLogEntry() {
1377
+ const now = new Date().toISOString().replace("T", " ").slice(0, 16);
1378
+ return `# Wiki Log
1379
+
1380
+ ## ${now} — init
1381
+ - Wiki structure initialized by OpenGem
1382
+ `;
1383
+ }
1384
+ function escapeContent(content) {
1385
+ return content.replace(/\n/g, "\\n").replace(/\t/g, "\\t");
1386
+ }
1387
+ function createWikiFile(name, content, vault) {
1388
+ const r = obsidian(["create", `name=${name}`, `content=${escapeContent(content)}`, `vault=${vault}`]);
1389
+ return r.exitCode === 0;
1390
+ }
1391
+ function readConfig(configPath) {
1392
+ if (!existsSync(configPath))
1393
+ return {};
1394
+ try {
1395
+ return JSON.parse(readFileSync(configPath, "utf8"));
1396
+ } catch {
1397
+ return {};
1398
+ }
1399
+ }
1400
+ function saveConfig(configPath, vault) {
1401
+ const config = readConfig(configPath);
1402
+ const plugins = config.plugin ?? [];
1403
+ const filtered = plugins.filter((entry) => {
1404
+ const name = Array.isArray(entry) ? entry[0] : entry;
1405
+ return name !== "@cubocompany/opengem";
1406
+ });
1407
+ filtered.push(["@cubocompany/opengem", { defaultVault: vault }]);
1408
+ config.plugin = filtered;
1409
+ const dir = dirname(configPath);
1410
+ if (!existsSync(dir))
1411
+ mkdirSync(dir, { recursive: true });
1412
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + `
1413
+ `, "utf8");
1414
+ }
1415
+ async function main() {
1416
+ console.log();
1417
+ mt("OpenGem Setup");
1418
+ const s = fe();
1419
+ s.start("Checking Obsidian CLI...");
1420
+ const version = cliVersion();
1421
+ if (!version) {
1422
+ s.stop("Obsidian CLI not found");
1423
+ wt("Download and install the Obsidian CLI from https://obsidian.md/cli\nThen make sure `obsidian --version` works in your terminal.", "Missing requirement");
1424
+ gt("Setup incomplete. Run `npx @cubocompany/opengem init` again after installing the CLI.");
1425
+ process.exit(1);
1426
+ }
1427
+ s.stop(`Obsidian CLI found (${version})`);
1428
+ s.start("Checking Obsidian app...");
1429
+ if (!appRunning()) {
1430
+ s.stop("Obsidian app is not running");
1431
+ wt("Open Obsidian and make sure at least one vault is loaded.", "Missing requirement");
1432
+ gt("Setup incomplete. Run `npx @cubocompany/opengem init` again after opening Obsidian.");
1433
+ process.exit(1);
1434
+ }
1435
+ s.stop("Obsidian app is running");
1436
+ const active = activeVault();
1437
+ const all = listVaults();
1438
+ if (all.length === 0 && !active) {
1439
+ gt("No vaults found. Open a vault in Obsidian and run init again.");
1440
+ process.exit(1);
1441
+ }
1442
+ const vaultOptions = [
1443
+ ...all.map((v) => ({
1444
+ value: v,
1445
+ label: v === active ? `${v} (active)` : v
1446
+ })),
1447
+ { value: "__manual__", label: "Enter manually" }
1448
+ ];
1449
+ const vaultChoice = await _t({
1450
+ message: "Which vault do you want to use?",
1451
+ options: vaultOptions,
1452
+ initialValue: active ?? all[0]
1453
+ });
1454
+ if (q(vaultChoice)) {
1455
+ pt("Setup cancelled.");
1456
+ process.exit(0);
1457
+ }
1458
+ let vault;
1459
+ if (vaultChoice === "__manual__") {
1460
+ const manual = await Ot({ message: "Vault name:", placeholder: "My Vault" });
1461
+ if (q(manual)) {
1462
+ pt("Setup cancelled.");
1463
+ process.exit(0);
1464
+ }
1465
+ vault = manual;
1466
+ } else {
1467
+ vault = vaultChoice;
1468
+ }
1469
+ const globalPath = join(homedir(), ".opencode", "opencode.json");
1470
+ const localPath = resolve("opencode.json");
1471
+ const configChoice = await _t({
1472
+ message: "Save config to:",
1473
+ options: [
1474
+ { value: "global", label: "Global", hint: `~/.opencode/opencode.json — works in any project` },
1475
+ { value: "local", label: "This project", hint: `${localPath}` }
1476
+ ]
1477
+ });
1478
+ if (q(configChoice)) {
1479
+ pt("Setup cancelled.");
1480
+ process.exit(0);
1481
+ }
1482
+ const configPath = configChoice === "global" ? globalPath : localPath;
1483
+ s.start("Saving config...");
1484
+ try {
1485
+ saveConfig(configPath, vault);
1486
+ s.stop(`Config saved`);
1487
+ } catch (err) {
1488
+ s.stop("Failed to save config");
1489
+ console.error(err);
1490
+ process.exit(1);
1491
+ }
1492
+ s.start("Initializing wiki structure...");
1493
+ const results = [
1494
+ createWikiFile("schema/SCHEMA.md", SCHEMA_MD, vault),
1495
+ createWikiFile("wiki/INDEX.md", INDEX_MD, vault),
1496
+ createWikiFile("wiki/LOG.md", buildLogEntry(), vault),
1497
+ createWikiFile("raw/.keep", "", vault)
1498
+ ];
1499
+ const allOk = results.every(Boolean);
1500
+ if (allOk) {
1501
+ s.stop("Wiki structure initialized");
1502
+ } else {
1503
+ s.stop("Wiki structure partially created — run `obsidian_wiki_init` inside OpenCode to complete");
1504
+ }
1505
+ gt(`You're ready! Open OpenCode in any project and say:
1506
+ "Add this article to my wiki: https://..."`);
1507
+ }
1508
+ main().catch((err) => {
1509
+ console.error(err);
1510
+ process.exit(1);
1511
+ });