domflax 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +214 -0
  2. package/dist/chunk-4HHISSMR.js +2227 -0
  3. package/dist/chunk-4HHISSMR.js.map +1 -0
  4. package/dist/chunk-6WVVF6AD.js +55 -0
  5. package/dist/chunk-6WVVF6AD.js.map +1 -0
  6. package/dist/chunk-77SLHRN6.js +2047 -0
  7. package/dist/chunk-77SLHRN6.js.map +1 -0
  8. package/dist/chunk-ZJ2S36GY.js +175 -0
  9. package/dist/chunk-ZJ2S36GY.js.map +1 -0
  10. package/dist/cli.cjs +5207 -0
  11. package/dist/cli.cjs.map +1 -0
  12. package/dist/cli.d.cts +1 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +1310 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/index.cjs +4383 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.cts +539 -0
  19. package/dist/index.d.ts +539 -0
  20. package/dist/index.js +110 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/pattern-CX6iBzTD.d.ts +237 -0
  23. package/dist/pattern-P4FIKAUB.d.cts +237 -0
  24. package/dist/pattern-kit.cjs +630 -0
  25. package/dist/pattern-kit.cjs.map +1 -0
  26. package/dist/pattern-kit.d.cts +80 -0
  27. package/dist/pattern-kit.d.ts +80 -0
  28. package/dist/pattern-kit.js +55 -0
  29. package/dist/pattern-kit.js.map +1 -0
  30. package/dist/types-BQ7l6dVe.d.cts +749 -0
  31. package/dist/types-BQ7l6dVe.d.ts +749 -0
  32. package/dist/verify.cjs +2747 -0
  33. package/dist/verify.cjs.map +1 -0
  34. package/dist/verify.d.cts +245 -0
  35. package/dist/verify.d.ts +245 -0
  36. package/dist/verify.js +2700 -0
  37. package/dist/verify.js.map +1 -0
  38. package/dist/webpack-loader.cjs +4149 -0
  39. package/dist/webpack-loader.cjs.map +1 -0
  40. package/dist/webpack-loader.d.cts +21 -0
  41. package/dist/webpack-loader.d.ts +21 -0
  42. package/dist/webpack-loader.js +30 -0
  43. package/dist/webpack-loader.js.map +1 -0
  44. package/package.json +99 -0
package/dist/cli.js ADDED
@@ -0,0 +1,1310 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ builtinPatterns,
4
+ createCssResolver,
5
+ createJsxBackend,
6
+ createJsxFrontend,
7
+ createTailwindResolver
8
+ } from "./chunk-4HHISSMR.js";
9
+ import {
10
+ buildSelectorIndex,
11
+ createSyntheticSink,
12
+ normalizer,
13
+ runPasses,
14
+ syncClassesFromComputed
15
+ } from "./chunk-77SLHRN6.js";
16
+ import {
17
+ __commonJS,
18
+ __toESM,
19
+ init_esm_shims
20
+ } from "./chunk-6WVVF6AD.js";
21
+
22
+ // ../../node_modules/sisteransi/src/index.js
23
+ var require_src = __commonJS({
24
+ "../../node_modules/sisteransi/src/index.js"(exports, module) {
25
+ "use strict";
26
+ init_esm_shims();
27
+ var ESC = "\x1B";
28
+ var CSI = `${ESC}[`;
29
+ var beep = "\x07";
30
+ var cursor = {
31
+ to(x2, y3) {
32
+ if (!y3) return `${CSI}${x2 + 1}G`;
33
+ return `${CSI}${y3 + 1};${x2 + 1}H`;
34
+ },
35
+ move(x2, y3) {
36
+ let ret = "";
37
+ if (x2 < 0) ret += `${CSI}${-x2}D`;
38
+ else if (x2 > 0) ret += `${CSI}${x2}C`;
39
+ if (y3 < 0) ret += `${CSI}${-y3}A`;
40
+ else if (y3 > 0) ret += `${CSI}${y3}B`;
41
+ return ret;
42
+ },
43
+ up: (count = 1) => `${CSI}${count}A`,
44
+ down: (count = 1) => `${CSI}${count}B`,
45
+ forward: (count = 1) => `${CSI}${count}C`,
46
+ backward: (count = 1) => `${CSI}${count}D`,
47
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
48
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
49
+ left: `${CSI}G`,
50
+ hide: `${CSI}?25l`,
51
+ show: `${CSI}?25h`,
52
+ save: `${ESC}7`,
53
+ restore: `${ESC}8`
54
+ };
55
+ var scroll = {
56
+ up: (count = 1) => `${CSI}S`.repeat(count),
57
+ down: (count = 1) => `${CSI}T`.repeat(count)
58
+ };
59
+ var erase = {
60
+ screen: `${CSI}2J`,
61
+ up: (count = 1) => `${CSI}1J`.repeat(count),
62
+ down: (count = 1) => `${CSI}J`.repeat(count),
63
+ line: `${CSI}2K`,
64
+ lineEnd: `${CSI}K`,
65
+ lineStart: `${CSI}1K`,
66
+ lines(count) {
67
+ let clear = "";
68
+ for (let i = 0; i < count; i++)
69
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
70
+ if (count)
71
+ clear += cursor.left;
72
+ return clear;
73
+ }
74
+ };
75
+ module.exports = { cursor, scroll, erase, beep };
76
+ }
77
+ });
78
+
79
+ // ../../node_modules/picocolors/picocolors.js
80
+ var require_picocolors = __commonJS({
81
+ "../../node_modules/picocolors/picocolors.js"(exports, module) {
82
+ "use strict";
83
+ init_esm_shims();
84
+ var p2 = process || {};
85
+ var argv = p2.argv || [];
86
+ var env = p2.env || {};
87
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
88
+ var formatter = (open, close, replace = open) => (input) => {
89
+ let string = "" + input, index = string.indexOf(close, open.length);
90
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
91
+ };
92
+ var replaceClose = (string, close, replace, index) => {
93
+ let result = "", cursor = 0;
94
+ do {
95
+ result += string.substring(cursor, index) + replace;
96
+ cursor = index + close.length;
97
+ index = string.indexOf(close, cursor);
98
+ } while (~index);
99
+ return result + string.substring(cursor);
100
+ };
101
+ var createColors = (enabled = isColorSupported) => {
102
+ let f = enabled ? formatter : () => String;
103
+ return {
104
+ isColorSupported: enabled,
105
+ reset: f("\x1B[0m", "\x1B[0m"),
106
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
107
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
108
+ italic: f("\x1B[3m", "\x1B[23m"),
109
+ underline: f("\x1B[4m", "\x1B[24m"),
110
+ inverse: f("\x1B[7m", "\x1B[27m"),
111
+ hidden: f("\x1B[8m", "\x1B[28m"),
112
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
113
+ black: f("\x1B[30m", "\x1B[39m"),
114
+ red: f("\x1B[31m", "\x1B[39m"),
115
+ green: f("\x1B[32m", "\x1B[39m"),
116
+ yellow: f("\x1B[33m", "\x1B[39m"),
117
+ blue: f("\x1B[34m", "\x1B[39m"),
118
+ magenta: f("\x1B[35m", "\x1B[39m"),
119
+ cyan: f("\x1B[36m", "\x1B[39m"),
120
+ white: f("\x1B[37m", "\x1B[39m"),
121
+ gray: f("\x1B[90m", "\x1B[39m"),
122
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
123
+ bgRed: f("\x1B[41m", "\x1B[49m"),
124
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
125
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
126
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
127
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
128
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
129
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
130
+ blackBright: f("\x1B[90m", "\x1B[39m"),
131
+ redBright: f("\x1B[91m", "\x1B[39m"),
132
+ greenBright: f("\x1B[92m", "\x1B[39m"),
133
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
134
+ blueBright: f("\x1B[94m", "\x1B[39m"),
135
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
136
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
137
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
138
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
139
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
140
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
141
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
142
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
143
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
144
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
145
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
146
+ };
147
+ };
148
+ module.exports = createColors();
149
+ module.exports.createColors = createColors;
150
+ }
151
+ });
152
+
153
+ // src/cli.ts
154
+ init_esm_shims();
155
+
156
+ // ../cli/src/index.ts
157
+ init_esm_shims();
158
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
159
+ import * as path3 from "path";
160
+ import { fileURLToPath } from "url";
161
+
162
+ // ../cli/src/options.ts
163
+ init_esm_shims();
164
+ import { parseArgs } from "util";
165
+ var DEFAULT_SAFETY = 2;
166
+ var DEFAULT_PROVIDER = "auto";
167
+ function isProvider(value) {
168
+ return value === "auto" || value === "tailwind" || value === "custom";
169
+ }
170
+ function toSafety(raw) {
171
+ if (raw === void 0) return DEFAULT_SAFETY;
172
+ const n = Number(raw);
173
+ if (n === 0 || n === 1 || n === 2 || n === 3) return n;
174
+ throw new Error(`domflax: invalid --safety "${raw}" (expected 0, 1, 2 or 3)`);
175
+ }
176
+ function parseInvocation(argv) {
177
+ const { values, positionals } = parseArgs({
178
+ args: argv,
179
+ allowPositionals: true,
180
+ options: {
181
+ out: { type: "string" },
182
+ provider: { type: "string" },
183
+ css: { type: "string", multiple: true },
184
+ "dry-run": { type: "boolean", default: false },
185
+ report: { type: "boolean", default: false },
186
+ "dangerously-overwrite-source": { type: "boolean", default: false },
187
+ "no-git-check": { type: "boolean", default: false },
188
+ "no-interactive": { type: "boolean", default: false },
189
+ yes: { type: "boolean", short: "y", default: false },
190
+ safety: { type: "string" },
191
+ "project-root": { type: "string" }
192
+ }
193
+ });
194
+ const provider = values.provider ?? DEFAULT_PROVIDER;
195
+ if (!isProvider(provider)) {
196
+ throw new Error(`domflax: unknown --provider "${provider}" (expected auto|tailwind|custom)`);
197
+ }
198
+ return {
199
+ paths: positionals,
200
+ out: values.out ?? null,
201
+ provider,
202
+ css: values.css ?? [],
203
+ dryRun: values["dry-run"] === true,
204
+ report: values.report === true,
205
+ dangerouslyOverwriteSource: values["dangerously-overwrite-source"] === true,
206
+ noGitCheck: values["no-git-check"] === true,
207
+ interactive: values["no-interactive"] !== true && values.yes !== true,
208
+ passes: null,
209
+ safety: toSafety(values.safety),
210
+ projectRoot: values["project-root"] ?? null
211
+ };
212
+ }
213
+ function shouldPrompt(options, isTty) {
214
+ return isTty && options.interactive && options.paths.length === 0;
215
+ }
216
+ var USAGE = [
217
+ "Usage: domflax [paths...] [options]",
218
+ "",
219
+ "Optimizes .jsx/.tsx files (flatten redundant wrappers + compress class sets).",
220
+ "Source is READ-ONLY by default \u2014 output goes to --out or ./domflax-out.",
221
+ "",
222
+ "Arguments:",
223
+ " paths folders (recursive), globs, or files",
224
+ "",
225
+ "Options:",
226
+ " --out <dir> write optimized files here, mirroring structure",
227
+ " --provider <auto|tailwind|custom> style resolver (default: auto)",
228
+ " --css <file...> stylesheets feeding the custom-CSS provider",
229
+ " --dry-run print per-file diffs; write nothing",
230
+ " --report print a summary of what changed",
231
+ " --dangerously-overwrite-source overwrite source in place (needs a clean git tree)",
232
+ " --no-git-check skip the clean-git-tree gate",
233
+ " --safety <0|1|2|3> optimization aggressiveness (default: 2)",
234
+ " --yes, --no-interactive never launch the wizard (CI-safe)",
235
+ "",
236
+ "With no paths in an interactive terminal, a guided wizard launches."
237
+ ].join("\n");
238
+
239
+ // ../cli/src/safety.ts
240
+ init_esm_shims();
241
+ import { execFileSync } from "child_process";
242
+ import * as path from "path";
243
+ var DISPOSABLE_DIRS = /* @__PURE__ */ new Set(["dist", "build", "out", ".next"]);
244
+ function isDisposablePath(file) {
245
+ return path.resolve(file).split(path.sep).some((seg) => DISPOSABLE_DIRS.has(seg));
246
+ }
247
+ function isGitClean(cwd) {
248
+ try {
249
+ const out = execFileSync("git", ["status", "--porcelain"], {
250
+ cwd,
251
+ encoding: "utf8",
252
+ stdio: ["ignore", "pipe", "ignore"]
253
+ });
254
+ return out.trim().length === 0;
255
+ } catch {
256
+ return false;
257
+ }
258
+ }
259
+ function planWrites(options, gitClean) {
260
+ if (options.dangerouslyOverwriteSource) {
261
+ if (!options.noGitCheck && !gitClean) {
262
+ return {
263
+ ok: false,
264
+ error: "refusing --dangerously-overwrite-source: git working tree is not clean. Commit or stash first, or pass --no-git-check to override."
265
+ };
266
+ }
267
+ return { ok: true, value: { mode: "overwrite-source", outDir: null } };
268
+ }
269
+ const outDir = path.resolve(options.out ?? "domflax-out");
270
+ return { ok: true, value: { mode: "out-dir", outDir } };
271
+ }
272
+ function destinationFor(file, inputRoot, plan) {
273
+ const absFile = path.resolve(file);
274
+ if (plan.mode === "overwrite-source") {
275
+ return { ok: true, value: absFile };
276
+ }
277
+ const outDir = plan.outDir;
278
+ const rel = path.relative(inputRoot, absFile);
279
+ const safeRel = rel === "" || rel.startsWith("..") || path.isAbsolute(rel) ? path.basename(absFile) : rel;
280
+ const dest = path.join(outDir, safeRel);
281
+ if (path.resolve(dest) === absFile && !isDisposablePath(absFile)) {
282
+ return {
283
+ ok: false,
284
+ error: `refusing to overwrite source file ${absFile}: the output path resolves onto the source. Choose a different --out, or pass --dangerously-overwrite-source (with a clean git tree).`
285
+ };
286
+ }
287
+ return { ok: true, value: dest };
288
+ }
289
+
290
+ // ../cli/src/transform.ts
291
+ init_esm_shims();
292
+ function buildResolver(provider, css, projectRoot) {
293
+ if (provider === "custom") {
294
+ return createCssResolver([], { files: css, projectRoot });
295
+ }
296
+ return createTailwindResolver({ projectRoot });
297
+ }
298
+ function buildPasses(patterns) {
299
+ const byPhase = /* @__PURE__ */ new Map();
300
+ for (const p2 of patterns) {
301
+ const phase = p2.category.split("/", 1)[0] ?? "flatten";
302
+ let bucket = byPhase.get(phase);
303
+ if (!bucket) {
304
+ bucket = [];
305
+ byPhase.set(phase, bucket);
306
+ }
307
+ bucket.push(p2);
308
+ }
309
+ const passes = [];
310
+ for (const [phase, pats] of byPhase) {
311
+ passes.push({ phase, category: `${phase}/builtin`, patterns: pats });
312
+ }
313
+ return passes;
314
+ }
315
+ function selectPatterns(names) {
316
+ if (names === null) return builtinPatterns;
317
+ const set = new Set(names);
318
+ return builtinPatterns.filter((p2) => set.has(p2.name));
319
+ }
320
+ function jsxKindOf(id) {
321
+ const clean = id.split("?", 1)[0] ?? id;
322
+ const lower = clean.toLowerCase();
323
+ if (lower.endsWith(".tsx")) return "tsx";
324
+ if (lower.endsWith(".jsx")) return "jsx";
325
+ return null;
326
+ }
327
+ function countClassTokens(code) {
328
+ let total = 0;
329
+ const re = /\b(?:className|class)\s*=\s*"([^"]*)"/g;
330
+ let m2;
331
+ while ((m2 = re.exec(code)) !== null) {
332
+ total += m2[1].split(/\s+/).filter((t) => t.length > 0).length;
333
+ }
334
+ return total;
335
+ }
336
+ function bytes(s) {
337
+ return Buffer.byteLength(s, "utf8");
338
+ }
339
+ function passthroughResult(code) {
340
+ return {
341
+ code,
342
+ changed: false,
343
+ passthrough: true,
344
+ stats: {
345
+ nodesIn: 0,
346
+ nodesOut: 0,
347
+ nodesRemoved: 0,
348
+ classesBefore: 0,
349
+ classesAfter: 0,
350
+ classesSaved: 0,
351
+ bytesBefore: bytes(code),
352
+ bytesAfter: bytes(code),
353
+ bytesSaved: 0
354
+ }
355
+ };
356
+ }
357
+ function createTransform(options) {
358
+ const projectRoot = options.projectRoot ?? process.cwd();
359
+ const resolver = buildResolver(options.provider, options.css, projectRoot);
360
+ const patterns = selectPatterns(options.passes);
361
+ return {
362
+ resolver,
363
+ transformFile(code, id) {
364
+ const kind = jsxKindOf(id);
365
+ if (kind === null) return passthroughResult(code);
366
+ const parsed = createJsxFrontend().parse(code, {
367
+ id,
368
+ kind,
369
+ resolver,
370
+ normalizer,
371
+ config: {},
372
+ onDiagnostic: () => {
373
+ }
374
+ });
375
+ const doc = parsed.doc;
376
+ const nodesIn = doc.nodes.size;
377
+ for (const node of doc.nodes.values()) node.meta.safetyFloor = 3;
378
+ const ctx = {
379
+ doc,
380
+ safetyCeiling: options.safety,
381
+ normalizer,
382
+ // Real CSS-selector-safety index from the active resolver (custom-CSS reports combinator /
383
+ // structural-pseudo coupling; Tailwind has none → null index, behaviour unchanged).
384
+ selectors: buildSelectorIndex(doc, resolver),
385
+ resolver
386
+ };
387
+ const { doc: optimized } = runPasses(doc, buildPasses(patterns), ctx);
388
+ syncClassesFromComputed(optimized, resolver, normalizer);
389
+ const printed = createJsxBackend().print(
390
+ optimized,
391
+ { moduleId: id, ops: [], provenance: /* @__PURE__ */ new Map() },
392
+ {
393
+ normalizer,
394
+ resolver,
395
+ sink: createSyntheticSink(),
396
+ eol: "\n",
397
+ onDiagnostic: () => {
398
+ }
399
+ }
400
+ );
401
+ const out = printed.code;
402
+ const nodesOut = optimized.nodes.size;
403
+ const classesBefore = countClassTokens(code);
404
+ const classesAfter = countClassTokens(out);
405
+ return {
406
+ code: out,
407
+ changed: out !== code,
408
+ passthrough: false,
409
+ stats: {
410
+ nodesIn,
411
+ nodesOut,
412
+ nodesRemoved: Math.max(0, nodesIn - nodesOut),
413
+ classesBefore,
414
+ classesAfter,
415
+ classesSaved: Math.max(0, classesBefore - classesAfter),
416
+ bytesBefore: bytes(code),
417
+ bytesAfter: bytes(out),
418
+ bytesSaved: bytes(code) - bytes(out)
419
+ }
420
+ };
421
+ }
422
+ };
423
+ }
424
+ function builtinPatternNames() {
425
+ return builtinPatterns.map((p2) => p2.name);
426
+ }
427
+
428
+ // ../cli/src/walk.ts
429
+ init_esm_shims();
430
+ import * as fs from "fs";
431
+ import * as path2 from "path";
432
+ var SUPPORTED_EXTS = [".jsx", ".tsx", ".html", ".htm"];
433
+ var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "domflax-out"]);
434
+ function isSupported(file) {
435
+ const lower = file.toLowerCase();
436
+ return SUPPORTED_EXTS.some((ext) => lower.endsWith(ext));
437
+ }
438
+ function hasGlobMagic(p2) {
439
+ return /[*?[\]{}]/.test(p2);
440
+ }
441
+ function walkDir(dir, out) {
442
+ let entries;
443
+ try {
444
+ entries = fs.readdirSync(dir, { withFileTypes: true });
445
+ } catch {
446
+ return;
447
+ }
448
+ for (const entry of entries) {
449
+ const full = path2.join(dir, entry.name);
450
+ if (entry.isDirectory()) {
451
+ if (SKIP_DIRS.has(entry.name)) continue;
452
+ walkDir(full, out);
453
+ } else if (entry.isFile() && isSupported(entry.name)) {
454
+ out.push(full);
455
+ }
456
+ }
457
+ }
458
+ function globSyncMaybe() {
459
+ const g2 = fs.globSync;
460
+ return typeof g2 === "function" ? g2 : null;
461
+ }
462
+ function discoverInputs(paths) {
463
+ const files = [];
464
+ const warnings = [];
465
+ const seen = /* @__PURE__ */ new Set();
466
+ const push = (f) => {
467
+ const abs = path2.resolve(f);
468
+ if (!seen.has(abs)) {
469
+ seen.add(abs);
470
+ files.push(abs);
471
+ }
472
+ };
473
+ let inputRoot = process.cwd();
474
+ if (paths.length === 1) {
475
+ try {
476
+ if (fs.statSync(paths[0]).isDirectory()) inputRoot = path2.resolve(paths[0]);
477
+ } catch {
478
+ }
479
+ }
480
+ for (const p2 of paths) {
481
+ let stat = null;
482
+ try {
483
+ stat = fs.statSync(p2);
484
+ } catch {
485
+ stat = null;
486
+ }
487
+ if (stat?.isDirectory()) {
488
+ walkDir(path2.resolve(p2), files);
489
+ continue;
490
+ }
491
+ if (stat?.isFile()) {
492
+ push(p2);
493
+ continue;
494
+ }
495
+ if (hasGlobMagic(p2)) {
496
+ const glob = globSyncMaybe();
497
+ if (!glob) {
498
+ warnings.push(`glob not supported on this Node version, skipped: ${p2}`);
499
+ continue;
500
+ }
501
+ const matches = glob(p2).filter(isSupported);
502
+ if (matches.length === 0) warnings.push(`no files matched: ${p2}`);
503
+ for (const m2 of matches) push(m2);
504
+ continue;
505
+ }
506
+ warnings.push(`no such file or directory: ${p2}`);
507
+ }
508
+ const deduped = [];
509
+ const finalSeen = /* @__PURE__ */ new Set();
510
+ for (const f of files) {
511
+ const abs = path2.resolve(f);
512
+ if (!finalSeen.has(abs)) {
513
+ finalSeen.add(abs);
514
+ deduped.push(abs);
515
+ }
516
+ }
517
+ return { files: deduped, inputRoot, warnings };
518
+ }
519
+
520
+ // ../cli/src/diff.ts
521
+ init_esm_shims();
522
+ function unifiedDiff(before, after, label) {
523
+ if (before === after) return ` (unchanged) ${label}`;
524
+ const a = before.split("\n");
525
+ const b3 = after.split("\n");
526
+ let prefix = 0;
527
+ while (prefix < a.length && prefix < b3.length && a[prefix] === b3[prefix]) prefix += 1;
528
+ let suffix = 0;
529
+ while (suffix < a.length - prefix && suffix < b3.length - prefix && a[a.length - 1 - suffix] === b3[b3.length - 1 - suffix]) {
530
+ suffix += 1;
531
+ }
532
+ const removed = a.slice(prefix, a.length - suffix);
533
+ const added = b3.slice(prefix, b3.length - suffix);
534
+ const lines = [`--- a/${label}`, `+++ b/${label}`];
535
+ if (prefix > 0) lines.push(`@@ -${prefix + 1} +${prefix + 1} @@`);
536
+ for (const r2 of removed) lines.push(`-${r2}`);
537
+ for (const ad of added) lines.push(`+${ad}`);
538
+ return lines.join("\n");
539
+ }
540
+
541
+ // ../cli/src/wizard.ts
542
+ init_esm_shims();
543
+
544
+ // ../../node_modules/@clack/prompts/dist/index.mjs
545
+ init_esm_shims();
546
+ import { stripVTControlCharacters as S2 } from "util";
547
+
548
+ // ../../node_modules/@clack/core/dist/index.mjs
549
+ init_esm_shims();
550
+ var import_sisteransi = __toESM(require_src(), 1);
551
+ var import_picocolors = __toESM(require_picocolors(), 1);
552
+ import { stdin as j, stdout as M } from "process";
553
+ import * as g from "readline";
554
+ import O from "readline";
555
+ import { Writable as X } from "stream";
556
+ function DD({ onlyFirst: e2 = false } = {}) {
557
+ 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("|");
558
+ return new RegExp(t, e2 ? void 0 : "g");
559
+ }
560
+ var uD = DD();
561
+ function P(e2) {
562
+ if (typeof e2 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e2}\``);
563
+ return e2.replace(uD, "");
564
+ }
565
+ function L(e2) {
566
+ return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
567
+ }
568
+ var W = { exports: {} };
569
+ (function(e2) {
570
+ var u2 = {};
571
+ e2.exports = u2, u2.eastAsianWidth = function(F2) {
572
+ var s = F2.charCodeAt(0), i = F2.length == 2 ? F2.charCodeAt(1) : 0, D2 = s;
573
+ return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D2 = s << 10 | i, D2 += 65536), D2 == 12288 || 65281 <= D2 && D2 <= 65376 || 65504 <= D2 && D2 <= 65510 ? "F" : D2 == 8361 || 65377 <= D2 && D2 <= 65470 || 65474 <= D2 && D2 <= 65479 || 65482 <= D2 && D2 <= 65487 || 65490 <= D2 && D2 <= 65495 || 65498 <= D2 && D2 <= 65500 || 65512 <= D2 && D2 <= 65518 ? "H" : 4352 <= D2 && D2 <= 4447 || 4515 <= D2 && D2 <= 4519 || 4602 <= D2 && D2 <= 4607 || 9001 <= D2 && D2 <= 9002 || 11904 <= D2 && D2 <= 11929 || 11931 <= D2 && D2 <= 12019 || 12032 <= D2 && D2 <= 12245 || 12272 <= D2 && D2 <= 12283 || 12289 <= D2 && D2 <= 12350 || 12353 <= D2 && D2 <= 12438 || 12441 <= D2 && D2 <= 12543 || 12549 <= D2 && D2 <= 12589 || 12593 <= D2 && D2 <= 12686 || 12688 <= D2 && D2 <= 12730 || 12736 <= D2 && D2 <= 12771 || 12784 <= D2 && D2 <= 12830 || 12832 <= D2 && D2 <= 12871 || 12880 <= D2 && D2 <= 13054 || 13056 <= D2 && D2 <= 19903 || 19968 <= D2 && D2 <= 42124 || 42128 <= D2 && D2 <= 42182 || 43360 <= D2 && D2 <= 43388 || 44032 <= D2 && D2 <= 55203 || 55216 <= D2 && D2 <= 55238 || 55243 <= D2 && D2 <= 55291 || 63744 <= D2 && D2 <= 64255 || 65040 <= D2 && D2 <= 65049 || 65072 <= D2 && D2 <= 65106 || 65108 <= D2 && D2 <= 65126 || 65128 <= D2 && D2 <= 65131 || 110592 <= D2 && D2 <= 110593 || 127488 <= D2 && D2 <= 127490 || 127504 <= D2 && D2 <= 127546 || 127552 <= D2 && D2 <= 127560 || 127568 <= D2 && D2 <= 127569 || 131072 <= D2 && D2 <= 194367 || 177984 <= D2 && D2 <= 196605 || 196608 <= D2 && D2 <= 262141 ? "W" : 32 <= D2 && D2 <= 126 || 162 <= D2 && D2 <= 163 || 165 <= D2 && D2 <= 166 || D2 == 172 || D2 == 175 || 10214 <= D2 && D2 <= 10221 || 10629 <= D2 && D2 <= 10630 ? "Na" : D2 == 161 || D2 == 164 || 167 <= D2 && D2 <= 168 || D2 == 170 || 173 <= D2 && D2 <= 174 || 176 <= D2 && D2 <= 180 || 182 <= D2 && D2 <= 186 || 188 <= D2 && D2 <= 191 || D2 == 198 || D2 == 208 || 215 <= D2 && D2 <= 216 || 222 <= D2 && D2 <= 225 || D2 == 230 || 232 <= D2 && D2 <= 234 || 236 <= D2 && D2 <= 237 || D2 == 240 || 242 <= D2 && D2 <= 243 || 247 <= D2 && D2 <= 250 || D2 == 252 || D2 == 254 || D2 == 257 || D2 == 273 || D2 == 275 || D2 == 283 || 294 <= D2 && D2 <= 295 || D2 == 299 || 305 <= D2 && D2 <= 307 || D2 == 312 || 319 <= D2 && D2 <= 322 || D2 == 324 || 328 <= D2 && D2 <= 331 || D2 == 333 || 338 <= D2 && D2 <= 339 || 358 <= D2 && D2 <= 359 || D2 == 363 || D2 == 462 || D2 == 464 || D2 == 466 || D2 == 468 || D2 == 470 || D2 == 472 || D2 == 474 || D2 == 476 || D2 == 593 || D2 == 609 || D2 == 708 || D2 == 711 || 713 <= D2 && D2 <= 715 || D2 == 717 || D2 == 720 || 728 <= D2 && D2 <= 731 || D2 == 733 || D2 == 735 || 768 <= D2 && D2 <= 879 || 913 <= D2 && D2 <= 929 || 931 <= D2 && D2 <= 937 || 945 <= D2 && D2 <= 961 || 963 <= D2 && D2 <= 969 || D2 == 1025 || 1040 <= D2 && D2 <= 1103 || D2 == 1105 || D2 == 8208 || 8211 <= D2 && D2 <= 8214 || 8216 <= D2 && D2 <= 8217 || 8220 <= D2 && D2 <= 8221 || 8224 <= D2 && D2 <= 8226 || 8228 <= D2 && D2 <= 8231 || D2 == 8240 || 8242 <= D2 && D2 <= 8243 || D2 == 8245 || D2 == 8251 || D2 == 8254 || D2 == 8308 || D2 == 8319 || 8321 <= D2 && D2 <= 8324 || D2 == 8364 || D2 == 8451 || D2 == 8453 || D2 == 8457 || D2 == 8467 || D2 == 8470 || 8481 <= D2 && D2 <= 8482 || D2 == 8486 || D2 == 8491 || 8531 <= D2 && D2 <= 8532 || 8539 <= D2 && D2 <= 8542 || 8544 <= D2 && D2 <= 8555 || 8560 <= D2 && D2 <= 8569 || D2 == 8585 || 8592 <= D2 && D2 <= 8601 || 8632 <= D2 && D2 <= 8633 || D2 == 8658 || D2 == 8660 || D2 == 8679 || D2 == 8704 || 8706 <= D2 && D2 <= 8707 || 8711 <= D2 && D2 <= 8712 || D2 == 8715 || D2 == 8719 || D2 == 8721 || D2 == 8725 || D2 == 8730 || 8733 <= D2 && D2 <= 8736 || D2 == 8739 || D2 == 8741 || 8743 <= D2 && D2 <= 8748 || D2 == 8750 || 8756 <= D2 && D2 <= 8759 || 8764 <= D2 && D2 <= 8765 || D2 == 8776 || D2 == 8780 || D2 == 8786 || 8800 <= D2 && D2 <= 8801 || 8804 <= D2 && D2 <= 8807 || 8810 <= D2 && D2 <= 8811 || 8814 <= D2 && D2 <= 8815 || 8834 <= D2 && D2 <= 8835 || 8838 <= D2 && D2 <= 8839 || D2 == 8853 || D2 == 8857 || D2 == 8869 || D2 == 8895 || D2 == 8978 || 9312 <= D2 && D2 <= 9449 || 9451 <= D2 && D2 <= 9547 || 9552 <= D2 && D2 <= 9587 || 9600 <= D2 && D2 <= 9615 || 9618 <= D2 && D2 <= 9621 || 9632 <= D2 && D2 <= 9633 || 9635 <= D2 && D2 <= 9641 || 9650 <= D2 && D2 <= 9651 || 9654 <= D2 && D2 <= 9655 || 9660 <= D2 && D2 <= 9661 || 9664 <= D2 && D2 <= 9665 || 9670 <= D2 && D2 <= 9672 || D2 == 9675 || 9678 <= D2 && D2 <= 9681 || 9698 <= D2 && D2 <= 9701 || D2 == 9711 || 9733 <= D2 && D2 <= 9734 || D2 == 9737 || 9742 <= D2 && D2 <= 9743 || 9748 <= D2 && D2 <= 9749 || D2 == 9756 || D2 == 9758 || D2 == 9792 || D2 == 9794 || 9824 <= D2 && D2 <= 9825 || 9827 <= D2 && D2 <= 9829 || 9831 <= D2 && D2 <= 9834 || 9836 <= D2 && D2 <= 9837 || D2 == 9839 || 9886 <= D2 && D2 <= 9887 || 9918 <= D2 && D2 <= 9919 || 9924 <= D2 && D2 <= 9933 || 9935 <= D2 && D2 <= 9953 || D2 == 9955 || 9960 <= D2 && D2 <= 9983 || D2 == 10045 || D2 == 10071 || 10102 <= D2 && D2 <= 10111 || 11093 <= D2 && D2 <= 11097 || 12872 <= D2 && D2 <= 12879 || 57344 <= D2 && D2 <= 63743 || 65024 <= D2 && D2 <= 65039 || D2 == 65533 || 127232 <= D2 && D2 <= 127242 || 127248 <= D2 && D2 <= 127277 || 127280 <= D2 && D2 <= 127337 || 127344 <= D2 && D2 <= 127386 || 917760 <= D2 && D2 <= 917999 || 983040 <= D2 && D2 <= 1048573 || 1048576 <= D2 && D2 <= 1114109 ? "A" : "N";
574
+ }, u2.characterLength = function(F2) {
575
+ var s = this.eastAsianWidth(F2);
576
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
577
+ };
578
+ function t(F2) {
579
+ return F2.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
580
+ }
581
+ u2.length = function(F2) {
582
+ for (var s = t(F2), i = 0, D2 = 0; D2 < s.length; D2++) i = i + this.characterLength(s[D2]);
583
+ return i;
584
+ }, u2.slice = function(F2, s, i) {
585
+ textLen = u2.length(F2), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
586
+ for (var D2 = "", C2 = 0, n = t(F2), E = 0; E < n.length; E++) {
587
+ var a = n[E], o2 = u2.length(a);
588
+ if (C2 >= s - (o2 == 2 ? 1 : 0)) if (C2 + o2 <= i) D2 += a;
589
+ else break;
590
+ C2 += o2;
591
+ }
592
+ return D2;
593
+ };
594
+ })(W);
595
+ var tD = W.exports;
596
+ var eD = L(tD);
597
+ var FD = function() {
598
+ 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;
599
+ };
600
+ var sD = L(FD);
601
+ function p(e2, u2 = {}) {
602
+ if (typeof e2 != "string" || e2.length === 0 || (u2 = { ambiguousIsNarrow: true, ...u2 }, e2 = P(e2), e2.length === 0)) return 0;
603
+ e2 = e2.replace(sD(), " ");
604
+ const t = u2.ambiguousIsNarrow ? 1 : 2;
605
+ let F2 = 0;
606
+ for (const s of e2) {
607
+ const i = s.codePointAt(0);
608
+ if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
609
+ switch (eD.eastAsianWidth(s)) {
610
+ case "F":
611
+ case "W":
612
+ F2 += 2;
613
+ break;
614
+ case "A":
615
+ F2 += t;
616
+ break;
617
+ default:
618
+ F2 += 1;
619
+ }
620
+ }
621
+ return F2;
622
+ }
623
+ var w = 10;
624
+ var N = (e2 = 0) => (u2) => `\x1B[${u2 + e2}m`;
625
+ var I = (e2 = 0) => (u2) => `\x1B[${38 + e2};5;${u2}m`;
626
+ var R = (e2 = 0) => (u2, t, F2) => `\x1B[${38 + e2};2;${u2};${t};${F2}m`;
627
+ var r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
628
+ Object.keys(r.modifier);
629
+ var iD = Object.keys(r.color);
630
+ var CD = Object.keys(r.bgColor);
631
+ [...iD, ...CD];
632
+ function rD() {
633
+ const e2 = /* @__PURE__ */ new Map();
634
+ for (const [u2, t] of Object.entries(r)) {
635
+ for (const [F2, s] of Object.entries(t)) r[F2] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, t[F2] = r[F2], e2.set(s[0], s[1]);
636
+ Object.defineProperty(r, u2, { value: t, enumerable: false });
637
+ }
638
+ return Object.defineProperty(r, "codes", { value: e2, enumerable: false }), 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, { rgbToAnsi256: { value: (u2, t, F2) => u2 === t && t === F2 ? u2 < 8 ? 16 : u2 > 248 ? 231 : Math.round((u2 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u2 / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F2 / 255 * 5), enumerable: false }, hexToRgb: { value: (u2) => {
639
+ const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u2.toString(16));
640
+ if (!t) return [0, 0, 0];
641
+ let [F2] = t;
642
+ F2.length === 3 && (F2 = [...F2].map((i) => i + i).join(""));
643
+ const s = Number.parseInt(F2, 16);
644
+ return [s >> 16 & 255, s >> 8 & 255, s & 255];
645
+ }, enumerable: false }, hexToAnsi256: { value: (u2) => r.rgbToAnsi256(...r.hexToRgb(u2)), enumerable: false }, ansi256ToAnsi: { value: (u2) => {
646
+ if (u2 < 8) return 30 + u2;
647
+ if (u2 < 16) return 90 + (u2 - 8);
648
+ let t, F2, s;
649
+ if (u2 >= 232) t = ((u2 - 232) * 10 + 8) / 255, F2 = t, s = t;
650
+ else {
651
+ u2 -= 16;
652
+ const C2 = u2 % 36;
653
+ t = Math.floor(u2 / 36) / 5, F2 = Math.floor(C2 / 6) / 5, s = C2 % 6 / 5;
654
+ }
655
+ const i = Math.max(t, F2, s) * 2;
656
+ if (i === 0) return 30;
657
+ let D2 = 30 + (Math.round(s) << 2 | Math.round(F2) << 1 | Math.round(t));
658
+ return i === 2 && (D2 += 60), D2;
659
+ }, enumerable: false }, rgbToAnsi: { value: (u2, t, F2) => r.ansi256ToAnsi(r.rgbToAnsi256(u2, t, F2)), enumerable: false }, hexToAnsi: { value: (u2) => r.ansi256ToAnsi(r.hexToAnsi256(u2)), enumerable: false } }), r;
660
+ }
661
+ var ED = rD();
662
+ var d = /* @__PURE__ */ new Set(["\x1B", "\x9B"]);
663
+ var oD = 39;
664
+ var y = "\x07";
665
+ var V = "[";
666
+ var nD = "]";
667
+ var G = "m";
668
+ var _ = `${nD}8;;`;
669
+ var z = (e2) => `${d.values().next().value}${V}${e2}${G}`;
670
+ var K = (e2) => `${d.values().next().value}${_}${e2}${y}`;
671
+ var aD = (e2) => e2.split(" ").map((u2) => p(u2));
672
+ var k = (e2, u2, t) => {
673
+ const F2 = [...u2];
674
+ let s = false, i = false, D2 = p(P(e2[e2.length - 1]));
675
+ for (const [C2, n] of F2.entries()) {
676
+ const E = p(n);
677
+ if (D2 + E <= t ? e2[e2.length - 1] += n : (e2.push(n), D2 = 0), d.has(n) && (s = true, i = F2.slice(C2 + 1).join("").startsWith(_)), s) {
678
+ i ? n === y && (s = false, i = false) : n === G && (s = false);
679
+ continue;
680
+ }
681
+ D2 += E, D2 === t && C2 < F2.length - 1 && (e2.push(""), D2 = 0);
682
+ }
683
+ !D2 && e2[e2.length - 1].length > 0 && e2.length > 1 && (e2[e2.length - 2] += e2.pop());
684
+ };
685
+ var hD = (e2) => {
686
+ const u2 = e2.split(" ");
687
+ let t = u2.length;
688
+ for (; t > 0 && !(p(u2[t - 1]) > 0); ) t--;
689
+ return t === u2.length ? e2 : u2.slice(0, t).join(" ") + u2.slice(t).join("");
690
+ };
691
+ var lD = (e2, u2, t = {}) => {
692
+ if (t.trim !== false && e2.trim() === "") return "";
693
+ let F2 = "", s, i;
694
+ const D2 = aD(e2);
695
+ let C2 = [""];
696
+ for (const [E, a] of e2.split(" ").entries()) {
697
+ t.trim !== false && (C2[C2.length - 1] = C2[C2.length - 1].trimStart());
698
+ let o2 = p(C2[C2.length - 1]);
699
+ if (E !== 0 && (o2 >= u2 && (t.wordWrap === false || t.trim === false) && (C2.push(""), o2 = 0), (o2 > 0 || t.trim === false) && (C2[C2.length - 1] += " ", o2++)), t.hard && D2[E] > u2) {
700
+ const c = u2 - o2, f = 1 + Math.floor((D2[E] - c - 1) / u2);
701
+ Math.floor((D2[E] - 1) / u2) < f && C2.push(""), k(C2, a, u2);
702
+ continue;
703
+ }
704
+ if (o2 + D2[E] > u2 && o2 > 0 && D2[E] > 0) {
705
+ if (t.wordWrap === false && o2 < u2) {
706
+ k(C2, a, u2);
707
+ continue;
708
+ }
709
+ C2.push("");
710
+ }
711
+ if (o2 + D2[E] > u2 && t.wordWrap === false) {
712
+ k(C2, a, u2);
713
+ continue;
714
+ }
715
+ C2[C2.length - 1] += a;
716
+ }
717
+ t.trim !== false && (C2 = C2.map((E) => hD(E)));
718
+ const n = [...C2.join(`
719
+ `)];
720
+ for (const [E, a] of n.entries()) {
721
+ if (F2 += a, d.has(a)) {
722
+ const { groups: c } = new RegExp(`(?:\\${V}(?<code>\\d+)m|\\${_}(?<uri>.*)${y})`).exec(n.slice(E).join("")) || { groups: {} };
723
+ if (c.code !== void 0) {
724
+ const f = Number.parseFloat(c.code);
725
+ s = f === oD ? void 0 : f;
726
+ } else c.uri !== void 0 && (i = c.uri.length === 0 ? void 0 : c.uri);
727
+ }
728
+ const o2 = ED.codes.get(Number(s));
729
+ n[E + 1] === `
730
+ ` ? (i && (F2 += K("")), s && o2 && (F2 += z(o2))) : a === `
731
+ ` && (s && o2 && (F2 += z(s)), i && (F2 += K(i)));
732
+ }
733
+ return F2;
734
+ };
735
+ function Y(e2, u2, t) {
736
+ return String(e2).normalize().replace(/\r\n/g, `
737
+ `).split(`
738
+ `).map((F2) => lD(F2, u2, t)).join(`
739
+ `);
740
+ }
741
+ var xD = ["up", "down", "left", "right", "space", "enter", "cancel"];
742
+ var B = { actions: new Set(xD), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]) };
743
+ function $(e2, u2) {
744
+ if (typeof e2 == "string") return B.aliases.get(e2) === u2;
745
+ for (const t of e2) if (t !== void 0 && $(t, u2)) return true;
746
+ return false;
747
+ }
748
+ function BD(e2, u2) {
749
+ if (e2 === u2) return;
750
+ const t = e2.split(`
751
+ `), F2 = u2.split(`
752
+ `), s = [];
753
+ for (let i = 0; i < Math.max(t.length, F2.length); i++) t[i] !== F2[i] && s.push(i);
754
+ return s;
755
+ }
756
+ var AD = globalThis.process.platform.startsWith("win");
757
+ var S = /* @__PURE__ */ Symbol("clack:cancel");
758
+ function pD(e2) {
759
+ return e2 === S;
760
+ }
761
+ function m(e2, u2) {
762
+ const t = e2;
763
+ t.isTTY && t.setRawMode(u2);
764
+ }
765
+ var gD = Object.defineProperty;
766
+ var vD = (e2, u2, t) => u2 in e2 ? gD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
767
+ var h = (e2, u2, t) => (vD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
768
+ var x = class {
769
+ constructor(u2, t = true) {
770
+ h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
771
+ const { input: F2 = j, output: s = M, render: i, signal: D2, ...C2 } = u2;
772
+ this.opts = C2, 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 = D2, this.input = F2, this.output = s;
773
+ }
774
+ unsubscribe() {
775
+ this._subscribers.clear();
776
+ }
777
+ setSubscriber(u2, t) {
778
+ const F2 = this._subscribers.get(u2) ?? [];
779
+ F2.push(t), this._subscribers.set(u2, F2);
780
+ }
781
+ on(u2, t) {
782
+ this.setSubscriber(u2, { cb: t });
783
+ }
784
+ once(u2, t) {
785
+ this.setSubscriber(u2, { cb: t, once: true });
786
+ }
787
+ emit(u2, ...t) {
788
+ const F2 = this._subscribers.get(u2) ?? [], s = [];
789
+ for (const i of F2) i.cb(...t), i.once && s.push(() => F2.splice(F2.indexOf(i), 1));
790
+ for (const i of s) i();
791
+ }
792
+ prompt() {
793
+ return new Promise((u2, t) => {
794
+ if (this._abortSignal) {
795
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u2(S);
796
+ this._abortSignal.addEventListener("abort", () => {
797
+ this.state = "cancel", this.close();
798
+ }, { once: true });
799
+ }
800
+ const F2 = new X();
801
+ F2._write = (s, i, D2) => {
802
+ this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D2();
803
+ }, this.input.pipe(F2), this.rl = O.createInterface({ input: this.input, output: F2, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), 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, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
804
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u2(this.value);
805
+ }), this.once("cancel", () => {
806
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u2(S);
807
+ });
808
+ });
809
+ }
810
+ onKeypress(u2, t) {
811
+ 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)), u2 && (u2.toLowerCase() === "y" || u2.toLowerCase() === "n") && this.emit("confirm", u2.toLowerCase() === "y"), u2 === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u2 && this.emit("key", u2.toLowerCase()), t?.name === "return") {
812
+ if (this.opts.validate) {
813
+ const F2 = this.opts.validate(this.value);
814
+ F2 && (this.error = F2 instanceof Error ? F2.message : F2, this.state = "error", this.rl?.write(this.value));
815
+ }
816
+ this.state !== "error" && (this.state = "submit");
817
+ }
818
+ $([u2, t?.name, t?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
819
+ }
820
+ close() {
821
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
822
+ `), m(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
823
+ }
824
+ restoreCursor() {
825
+ const u2 = Y(this._prevFrame, process.stdout.columns, { hard: true }).split(`
826
+ `).length - 1;
827
+ this.output.write(import_sisteransi.cursor.move(-999, u2 * -1));
828
+ }
829
+ render() {
830
+ const u2 = Y(this._render(this) ?? "", process.stdout.columns, { hard: true });
831
+ if (u2 !== this._prevFrame) {
832
+ if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
833
+ else {
834
+ const t = BD(this._prevFrame, u2);
835
+ if (this.restoreCursor(), t && t?.length === 1) {
836
+ const F2 = t[0];
837
+ this.output.write(import_sisteransi.cursor.move(0, F2)), this.output.write(import_sisteransi.erase.lines(1));
838
+ const s = u2.split(`
839
+ `);
840
+ this.output.write(s[F2]), this._prevFrame = u2, this.output.write(import_sisteransi.cursor.move(0, s.length - F2 - 1));
841
+ return;
842
+ }
843
+ if (t && t?.length > 1) {
844
+ const F2 = t[0];
845
+ this.output.write(import_sisteransi.cursor.move(0, F2)), this.output.write(import_sisteransi.erase.down());
846
+ const s = u2.split(`
847
+ `).slice(F2);
848
+ this.output.write(s.join(`
849
+ `)), this._prevFrame = u2;
850
+ return;
851
+ }
852
+ this.output.write(import_sisteransi.erase.down());
853
+ }
854
+ this.output.write(u2), this.state === "initial" && (this.state = "active"), this._prevFrame = u2;
855
+ }
856
+ }
857
+ };
858
+ var A;
859
+ A = /* @__PURE__ */ new WeakMap();
860
+ var kD = Object.defineProperty;
861
+ var $D = (e2, u2, t) => u2 in e2 ? kD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
862
+ var H = (e2, u2, t) => ($D(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
863
+ var SD = class extends x {
864
+ constructor(u2) {
865
+ super(u2, false), H(this, "options"), H(this, "cursor", 0), this.options = u2.options, this.value = [...u2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u2.cursorAt), 0), this.on("key", (t) => {
866
+ t === "a" && this.toggleAll();
867
+ }), this.on("cursor", (t) => {
868
+ switch (t) {
869
+ case "left":
870
+ case "up":
871
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
872
+ break;
873
+ case "down":
874
+ case "right":
875
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
876
+ break;
877
+ case "space":
878
+ this.toggleValue();
879
+ break;
880
+ }
881
+ });
882
+ }
883
+ get _value() {
884
+ return this.options[this.cursor].value;
885
+ }
886
+ toggleAll() {
887
+ const u2 = this.value.length === this.options.length;
888
+ this.value = u2 ? [] : this.options.map((t) => t.value);
889
+ }
890
+ toggleValue() {
891
+ const u2 = this.value.includes(this._value);
892
+ this.value = u2 ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
893
+ }
894
+ };
895
+ var OD = Object.defineProperty;
896
+ var PD = (e2, u2, t) => u2 in e2 ? OD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
897
+ var J = (e2, u2, t) => (PD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
898
+ var LD = class extends x {
899
+ constructor(u2) {
900
+ super(u2, false), J(this, "options"), J(this, "cursor", 0), this.options = u2.options, this.cursor = this.options.findIndex(({ value: t }) => t === u2.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
901
+ switch (t) {
902
+ case "left":
903
+ case "up":
904
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
905
+ break;
906
+ case "down":
907
+ case "right":
908
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
909
+ break;
910
+ }
911
+ this.changeValue();
912
+ });
913
+ }
914
+ get _value() {
915
+ return this.options[this.cursor];
916
+ }
917
+ changeValue() {
918
+ this.value = this._value.value;
919
+ }
920
+ };
921
+ var RD = class extends x {
922
+ get valueWithCursor() {
923
+ if (this.state === "submit") return this.value;
924
+ if (this.cursor >= this.value.length) return `${this.value}\u2588`;
925
+ const u2 = this.value.slice(0, this.cursor), [t, ...F2] = this.value.slice(this.cursor);
926
+ return `${u2}${import_picocolors.default.inverse(t)}${F2.join("")}`;
927
+ }
928
+ get cursor() {
929
+ return this._cursor;
930
+ }
931
+ constructor(u2) {
932
+ super(u2), this.on("finalize", () => {
933
+ this.value || (this.value = u2.defaultValue);
934
+ });
935
+ }
936
+ };
937
+
938
+ // ../../node_modules/@clack/prompts/dist/index.mjs
939
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
940
+ var import_sisteransi2 = __toESM(require_src(), 1);
941
+ import y2 from "process";
942
+ function ce() {
943
+ return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
944
+ }
945
+ var V2 = ce();
946
+ var u = (t, n) => V2 ? t : n;
947
+ var le = u("\u25C6", "*");
948
+ var L2 = u("\u25A0", "x");
949
+ var W2 = u("\u25B2", "x");
950
+ var C = u("\u25C7", "o");
951
+ var ue = u("\u250C", "T");
952
+ var o = u("\u2502", "|");
953
+ var d2 = u("\u2514", "\u2014");
954
+ var k2 = u("\u25CF", ">");
955
+ var P2 = u("\u25CB", " ");
956
+ var A2 = u("\u25FB", "[\u2022]");
957
+ var T = u("\u25FC", "[+]");
958
+ var F = u("\u25FB", "[ ]");
959
+ var $e = u("\u25AA", "\u2022");
960
+ var _2 = u("\u2500", "-");
961
+ var me = u("\u256E", "+");
962
+ var de = u("\u251C", "+");
963
+ var pe = u("\u256F", "+");
964
+ var q = u("\u25CF", "\u2022");
965
+ var D = u("\u25C6", "*");
966
+ var U = u("\u25B2", "!");
967
+ var K2 = u("\u25A0", "x");
968
+ var b2 = (t) => {
969
+ switch (t) {
970
+ case "initial":
971
+ case "active":
972
+ return import_picocolors2.default.cyan(le);
973
+ case "cancel":
974
+ return import_picocolors2.default.red(L2);
975
+ case "error":
976
+ return import_picocolors2.default.yellow(W2);
977
+ case "submit":
978
+ return import_picocolors2.default.green(C);
979
+ }
980
+ };
981
+ var G2 = (t) => {
982
+ const { cursor: n, options: r2, 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));
983
+ let l2 = 0;
984
+ n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
985
+ const $2 = a < r2.length && l2 > 0, g2 = a < r2.length && l2 + a < r2.length;
986
+ return r2.slice(l2, l2 + a).map((p2, v2, f) => {
987
+ const j2 = v2 === 0 && $2, E = v2 === f.length - 1 && g2;
988
+ return j2 || E ? import_picocolors2.default.dim("...") : i(p2, v2 + l2 === n);
989
+ });
990
+ };
991
+ var he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
992
+ const n = `${import_picocolors2.default.gray(o)}
993
+ ${b2(this.state)} ${t.message}
994
+ `, r2 = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : r2;
995
+ switch (this.state) {
996
+ case "error":
997
+ return `${n.trim()}
998
+ ${import_picocolors2.default.yellow(o)} ${i}
999
+ ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
1000
+ `;
1001
+ case "submit":
1002
+ return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(this.value || t.placeholder)}`;
1003
+ case "cancel":
1004
+ return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
1005
+ ${import_picocolors2.default.gray(o)}` : ""}`;
1006
+ default:
1007
+ return `${n}${import_picocolors2.default.cyan(o)} ${i}
1008
+ ${import_picocolors2.default.cyan(d2)}
1009
+ `;
1010
+ }
1011
+ } }).prompt();
1012
+ var ve = (t) => {
1013
+ const n = (r2, i) => {
1014
+ const s = r2.label ?? String(r2.value);
1015
+ switch (i) {
1016
+ case "selected":
1017
+ return `${import_picocolors2.default.dim(s)}`;
1018
+ case "active":
1019
+ return `${import_picocolors2.default.green(k2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}`;
1020
+ case "cancelled":
1021
+ return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
1022
+ default:
1023
+ return `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(s)}`;
1024
+ }
1025
+ };
1026
+ return new LD({ options: t.options, initialValue: t.initialValue, render() {
1027
+ const r2 = `${import_picocolors2.default.gray(o)}
1028
+ ${b2(this.state)} ${t.message}
1029
+ `;
1030
+ switch (this.state) {
1031
+ case "submit":
1032
+ return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
1033
+ case "cancel":
1034
+ return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
1035
+ ${import_picocolors2.default.gray(o)}`;
1036
+ default:
1037
+ return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
1038
+ ${import_picocolors2.default.cyan(o)} `)}
1039
+ ${import_picocolors2.default.cyan(d2)}
1040
+ `;
1041
+ }
1042
+ } }).prompt();
1043
+ };
1044
+ var fe = (t) => {
1045
+ const n = (r2, i) => {
1046
+ const s = r2.label ?? String(r2.value);
1047
+ return i === "active" ? `${import_picocolors2.default.cyan(A2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "selected" ? `${import_picocolors2.default.green(T)} ${import_picocolors2.default.dim(s)} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : i === "active-selected" ? `${import_picocolors2.default.green(T)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(F)} ${import_picocolors2.default.dim(s)}`;
1048
+ };
1049
+ return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r2) {
1050
+ if (this.required && r2.length === 0) return `Please select at least one option.
1051
+ ${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
1052
+ }, render() {
1053
+ const r2 = `${import_picocolors2.default.gray(o)}
1054
+ ${b2(this.state)} ${t.message}
1055
+ `, i = (s, c) => {
1056
+ const a = this.value.includes(s.value);
1057
+ return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
1058
+ };
1059
+ switch (this.state) {
1060
+ case "submit":
1061
+ return `${r2}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
1062
+ case "cancel": {
1063
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors2.default.dim(", "));
1064
+ return `${r2}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
1065
+ ${import_picocolors2.default.gray(o)}` : ""}`;
1066
+ }
1067
+ case "error": {
1068
+ const s = this.error.split(`
1069
+ `).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
1070
+ `);
1071
+ return `${r2 + import_picocolors2.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
1072
+ ${import_picocolors2.default.yellow(o)} `)}
1073
+ ${s}
1074
+ `;
1075
+ }
1076
+ default:
1077
+ return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
1078
+ ${import_picocolors2.default.cyan(o)} `)}
1079
+ ${import_picocolors2.default.cyan(d2)}
1080
+ `;
1081
+ }
1082
+ } }).prompt();
1083
+ };
1084
+ var xe = (t = "") => {
1085
+ process.stdout.write(`${import_picocolors2.default.gray(d2)} ${import_picocolors2.default.red(t)}
1086
+
1087
+ `);
1088
+ };
1089
+ var Ie = (t = "") => {
1090
+ process.stdout.write(`${import_picocolors2.default.gray(ue)} ${t}
1091
+ `);
1092
+ };
1093
+ var Se = (t = "") => {
1094
+ process.stdout.write(`${import_picocolors2.default.gray(o)}
1095
+ ${import_picocolors2.default.gray(d2)} ${t}
1096
+
1097
+ `);
1098
+ };
1099
+ var J2 = `${import_picocolors2.default.gray(o)} `;
1100
+
1101
+ // ../cli/src/wizard.ts
1102
+ var WIZARD_CANCELLED = /* @__PURE__ */ Symbol("domflax.wizard.cancelled");
1103
+ function cancelled(value) {
1104
+ return pD(value);
1105
+ }
1106
+ async function runWizard(base) {
1107
+ Ie("domflax \u2014 optimize your markup");
1108
+ const pathInput = await he({
1109
+ message: "Which folder, glob, or file should domflax optimize?",
1110
+ placeholder: "src",
1111
+ defaultValue: "src"
1112
+ });
1113
+ if (cancelled(pathInput)) return done();
1114
+ const outputMode = await ve({
1115
+ message: "Where should the optimized files go?",
1116
+ options: [
1117
+ { value: "out", label: "A new ./domflax-out folder", hint: "safe default" },
1118
+ { value: "out-custom", label: "A custom output folder" },
1119
+ { value: "dry-run", label: "Preview only (dry run)", hint: "writes nothing" },
1120
+ { value: "overwrite", label: "Overwrite the source in place", hint: "dangerous \u2014 needs clean git" }
1121
+ ],
1122
+ initialValue: "out"
1123
+ });
1124
+ if (cancelled(outputMode)) return done();
1125
+ let out = null;
1126
+ let dryRun = false;
1127
+ let dangerouslyOverwriteSource = false;
1128
+ if (outputMode === "out-custom") {
1129
+ const dir = await he({
1130
+ message: "Output folder:",
1131
+ placeholder: "domflax-out",
1132
+ defaultValue: "domflax-out"
1133
+ });
1134
+ if (cancelled(dir)) return done();
1135
+ out = String(dir);
1136
+ } else if (outputMode === "dry-run") {
1137
+ dryRun = true;
1138
+ } else if (outputMode === "overwrite") {
1139
+ dangerouslyOverwriteSource = true;
1140
+ }
1141
+ const allPasses = builtinPatternNames();
1142
+ const passSelection = await fe({
1143
+ message: "Which optimization passes should run?",
1144
+ options: allPasses.map((name) => ({ value: name, label: name })),
1145
+ initialValues: [...allPasses],
1146
+ required: true
1147
+ });
1148
+ if (cancelled(passSelection)) return done();
1149
+ const passes = passSelection;
1150
+ const provider = await ve({
1151
+ message: "How should class names resolve to styles?",
1152
+ options: [
1153
+ { value: "auto", label: "Auto (Tailwind)", hint: "default" },
1154
+ { value: "tailwind", label: "Tailwind" },
1155
+ { value: "custom", label: "Custom CSS files" }
1156
+ ],
1157
+ initialValue: "auto"
1158
+ });
1159
+ if (cancelled(provider)) return done();
1160
+ let css = base.css;
1161
+ if (provider === "custom") {
1162
+ const cssInput = await he({
1163
+ message: "CSS files (space-separated):",
1164
+ placeholder: "src/styles.css"
1165
+ });
1166
+ if (cancelled(cssInput)) return done();
1167
+ css = String(cssInput).split(/\s+/).filter((s) => s.length > 0);
1168
+ }
1169
+ Se("Ready \u2014 running domflax.");
1170
+ return {
1171
+ ...base,
1172
+ paths: [String(pathInput)],
1173
+ out,
1174
+ provider,
1175
+ css,
1176
+ dryRun,
1177
+ dangerouslyOverwriteSource,
1178
+ passes: passes.length === allPasses.length ? null : passes,
1179
+ safety: base.safety ?? DEFAULT_SAFETY
1180
+ };
1181
+ function done() {
1182
+ xe("Cancelled \u2014 nothing was written.");
1183
+ return WIZARD_CANCELLED;
1184
+ }
1185
+ }
1186
+
1187
+ // ../cli/src/index.ts
1188
+ function addStats(totals, stats, changed) {
1189
+ totals.files += 1;
1190
+ if (changed) totals.changed += 1;
1191
+ totals.nodesRemoved += stats.nodesRemoved;
1192
+ totals.classesSaved += stats.classesSaved;
1193
+ totals.bytesSaved += stats.bytesSaved;
1194
+ }
1195
+ function printReport(totals) {
1196
+ console.log("");
1197
+ console.log("domflax report");
1198
+ console.log(` files processed : ${totals.files}`);
1199
+ console.log(` files changed : ${totals.changed}`);
1200
+ console.log(` nodes removed : ${totals.nodesRemoved}`);
1201
+ console.log(` classes saved : ${totals.classesSaved}`);
1202
+ console.log(` bytes saved : ${totals.bytesSaved}`);
1203
+ }
1204
+ function execute(options) {
1205
+ const { files, inputRoot, warnings } = discoverInputs(options.paths);
1206
+ for (const w2 of warnings) console.error(`domflax: ${w2}`);
1207
+ if (files.length === 0) {
1208
+ console.error("domflax: no .jsx/.tsx/.html files found for the given paths");
1209
+ return { exitCode: 1 };
1210
+ }
1211
+ const projectRoot = options.projectRoot ?? process.cwd();
1212
+ const gitClean = options.dangerouslyOverwriteSource && !options.noGitCheck ? isGitClean(projectRoot) : true;
1213
+ const planned = planWrites(options, gitClean);
1214
+ if (!planned.ok) {
1215
+ console.error(`domflax: ${planned.error}`);
1216
+ return { exitCode: 1 };
1217
+ }
1218
+ const plan = planned.value;
1219
+ const transform = createTransform(options);
1220
+ const totals = { files: 0, changed: 0, nodesRemoved: 0, classesSaved: 0, bytesSaved: 0 };
1221
+ let failures = 0;
1222
+ for (const file of files) {
1223
+ let code;
1224
+ try {
1225
+ code = readFileSync(file, "utf8");
1226
+ } catch (err) {
1227
+ console.error(`domflax: cannot read ${file}: ${String(err?.message ?? err)}`);
1228
+ failures += 1;
1229
+ continue;
1230
+ }
1231
+ const result = transform.transformFile(code, file);
1232
+ addStats(totals, result.stats, result.changed);
1233
+ if (options.dryRun) {
1234
+ const rel = path3.relative(inputRoot, file) || path3.basename(file);
1235
+ if (result.changed) console.log(unifiedDiff(code, result.code, rel));
1236
+ else if (!options.report) console.log(` (unchanged) ${rel}`);
1237
+ continue;
1238
+ }
1239
+ if (!result.changed) continue;
1240
+ const target = destinationFor(file, inputRoot, plan);
1241
+ if (!target.ok) {
1242
+ console.error(`domflax: ${target.error}`);
1243
+ failures += 1;
1244
+ continue;
1245
+ }
1246
+ try {
1247
+ mkdirSync(path3.dirname(target.value), { recursive: true });
1248
+ writeFileSync(target.value, result.code, "utf8");
1249
+ console.log(`domflax: wrote ${path3.relative(process.cwd(), target.value) || target.value}`);
1250
+ } catch (err) {
1251
+ console.error(`domflax: cannot write ${target.value}: ${String(err?.message ?? err)}`);
1252
+ failures += 1;
1253
+ }
1254
+ }
1255
+ if (options.report) printReport(totals);
1256
+ if (options.dryRun) console.log("\ndomflax: dry run \u2014 no files were written.");
1257
+ return { exitCode: failures > 0 ? 1 : 0 };
1258
+ }
1259
+ async function main(argv = process.argv.slice(2)) {
1260
+ let options;
1261
+ try {
1262
+ options = parseInvocation(argv);
1263
+ } catch (err) {
1264
+ console.error(err instanceof Error ? err.message : String(err));
1265
+ console.error(USAGE);
1266
+ process.exitCode = 2;
1267
+ return;
1268
+ }
1269
+ const inCi = !!process.env.CI || !!process.env.CONTINUOUS_INTEGRATION || !!process.env.GITHUB_ACTIONS || !!process.env.GITLAB_CI || !!process.env.BUILDKITE || !!process.env.TF_BUILD;
1270
+ const isTty = process.stdout.isTTY === true && !inCi;
1271
+ if (shouldPrompt(options, isTty)) {
1272
+ const wizardResult = await runWizard(options);
1273
+ if (wizardResult === WIZARD_CANCELLED) {
1274
+ process.exitCode = 0;
1275
+ return;
1276
+ }
1277
+ options = wizardResult;
1278
+ }
1279
+ if (options.paths.length === 0) {
1280
+ console.error("domflax: no input paths given (and not an interactive terminal).");
1281
+ console.error(USAGE);
1282
+ process.exitCode = 2;
1283
+ return;
1284
+ }
1285
+ try {
1286
+ const result = execute(options);
1287
+ process.exitCode = result.exitCode;
1288
+ } catch (err) {
1289
+ console.error(`domflax: ${err instanceof Error ? err.message : String(err)}`);
1290
+ process.exitCode = 1;
1291
+ }
1292
+ }
1293
+ function isMainEntry() {
1294
+ const entry = process.argv[1];
1295
+ if (entry === void 0) return false;
1296
+ try {
1297
+ const self = path3.resolve(fileURLToPath(import.meta.url));
1298
+ const argv = path3.resolve(entry);
1299
+ return process.platform === "win32" ? self.toLowerCase() === argv.toLowerCase() : self === argv;
1300
+ } catch {
1301
+ return false;
1302
+ }
1303
+ }
1304
+ if (isMainEntry()) {
1305
+ void main();
1306
+ }
1307
+
1308
+ // src/cli.ts
1309
+ main(process.argv.slice(2));
1310
+ //# sourceMappingURL=cli.js.map