@hypersocial/cli-games 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.
@@ -0,0 +1,697 @@
1
+ // src/themes/index.ts
2
+ var themes = {
3
+ cyan: {
4
+ name: "Cyberpunk",
5
+ icon: "\u{1F535}",
6
+ primary: "#00D9FF",
7
+ secondary: "#FF006E",
8
+ glow: "rgba(0, 217, 255, 0.5)",
9
+ glowIntense: "rgba(0, 217, 255, 0.8)",
10
+ bg: "#0A1628",
11
+ statusBarBg: "#0D1E38"
12
+ },
13
+ cyanLight: {
14
+ name: "Cyberpunk Light",
15
+ icon: "\u{1F4A0}",
16
+ primary: "#0099CC",
17
+ secondary: "#CC0066",
18
+ glow: "rgba(0, 153, 204, 0.15)",
19
+ glowIntense: "rgba(0, 153, 204, 0.3)",
20
+ bg: "#F8FAFF",
21
+ statusBarBg: "#EEF2FA",
22
+ foreground: "#2d3640"
23
+ // Dark text for terminal readability
24
+ },
25
+ amber: {
26
+ name: "Fallout",
27
+ icon: "\u{1F7E0}",
28
+ primary: "#FFB000",
29
+ secondary: "#FF6600",
30
+ glow: "rgba(255, 176, 0, 0.5)",
31
+ glowIntense: "rgba(255, 176, 0, 0.8)",
32
+ bg: "#1C1408",
33
+ statusBarBg: "#2A1E0C"
34
+ },
35
+ green: {
36
+ name: "Matrix",
37
+ icon: "\u{1F7E2}",
38
+ primary: "#39FF14",
39
+ secondary: "#00FF00",
40
+ glow: "rgba(57, 255, 20, 0.5)",
41
+ glowIntense: "rgba(57, 255, 20, 0.8)",
42
+ bg: "#001A00",
43
+ statusBarBg: "#002800"
44
+ },
45
+ white: {
46
+ name: "Ghost",
47
+ icon: "\u26AA",
48
+ primary: "#FFFFFF",
49
+ secondary: "#88CCFF",
50
+ glow: "rgba(255, 255, 255, 0.3)",
51
+ glowIntense: "rgba(255, 255, 255, 0.5)",
52
+ bg: "#0C0C0C",
53
+ statusBarBg: "#1A1A1A"
54
+ },
55
+ hotpink: {
56
+ name: "Synthwave",
57
+ icon: "\u{1FA77}",
58
+ primary: "#FF6AC1",
59
+ secondary: "#00D9FF",
60
+ glow: "rgba(255, 106, 193, 0.5)",
61
+ glowIntense: "rgba(255, 106, 193, 0.8)",
62
+ bg: "#0F0818",
63
+ statusBarBg: "#1A0F28"
64
+ },
65
+ hotpinkLight: {
66
+ name: "Synthwave Light",
67
+ icon: "\u{1F337}",
68
+ primary: "#D84A9C",
69
+ secondary: "#0099BB",
70
+ glow: "rgba(216, 74, 156, 0.15)",
71
+ glowIntense: "rgba(216, 74, 156, 0.3)",
72
+ bg: "#FFF8FC",
73
+ statusBarBg: "#F5EEF2",
74
+ foreground: "#2d3640"
75
+ // Dark text for terminal readability
76
+ },
77
+ blood: {
78
+ name: "Blood",
79
+ icon: "\u{1F534}",
80
+ primary: "#FF3333",
81
+ secondary: "#AA0000",
82
+ glow: "rgba(255, 51, 51, 0.5)",
83
+ glowIntense: "rgba(255, 51, 51, 0.8)",
84
+ bg: "#1A0505",
85
+ statusBarBg: "#280808"
86
+ },
87
+ ice: {
88
+ name: "Ice",
89
+ icon: "\u{1FA75}",
90
+ primary: "#88FFFF",
91
+ secondary: "#4488FF",
92
+ glow: "rgba(136, 255, 255, 0.4)",
93
+ glowIntense: "rgba(136, 255, 255, 0.7)",
94
+ bg: "#051520",
95
+ statusBarBg: "#082030"
96
+ },
97
+ iceLight: {
98
+ name: "Ice Light",
99
+ icon: "\u{1F9CA}",
100
+ primary: "#0077AA",
101
+ secondary: "#2255CC",
102
+ glow: "rgba(0, 119, 170, 0.12)",
103
+ glowIntense: "rgba(0, 119, 170, 0.25)",
104
+ bg: "#F0FAFF",
105
+ statusBarBg: "#E5F0F8",
106
+ foreground: "#2d3640"
107
+ // Dark text for terminal readability
108
+ },
109
+ bladerunner: {
110
+ name: "Blade Runner",
111
+ icon: "\u{1F7E7}",
112
+ primary: "#FF6B35",
113
+ secondary: "#00CED1",
114
+ glow: "rgba(255, 107, 53, 0.6)",
115
+ glowIntense: "rgba(255, 107, 53, 0.9)",
116
+ bg: "#1F0E08",
117
+ statusBarBg: "#2D150C"
118
+ },
119
+ bladerunnerLight: {
120
+ name: "Blade Runner Light",
121
+ icon: "\u{1F305}",
122
+ primary: "#CC4400",
123
+ secondary: "#008B8B",
124
+ glow: "rgba(204, 68, 0, 0.15)",
125
+ glowIntense: "rgba(204, 68, 0, 0.3)",
126
+ bg: "#FFFAF5",
127
+ statusBarBg: "#F5EFEA",
128
+ foreground: "#2d3640"
129
+ // Dark text for terminal readability
130
+ },
131
+ tron: {
132
+ name: "Tron",
133
+ icon: "\u{1F537}",
134
+ primary: "#6FFFE9",
135
+ secondary: "#FF6B00",
136
+ glow: "rgba(111, 255, 233, 0.5)",
137
+ glowIntense: "rgba(111, 255, 233, 0.8)",
138
+ bg: "#020815",
139
+ statusBarBg: "#051020"
140
+ },
141
+ tronLight: {
142
+ name: "Tron Light",
143
+ icon: "\u{1F48E}",
144
+ primary: "#008080",
145
+ secondary: "#CC5500",
146
+ glow: "rgba(0, 128, 128, 0.15)",
147
+ glowIntense: "rgba(0, 128, 128, 0.3)",
148
+ bg: "#F5FFFF",
149
+ statusBarBg: "#EAF5F5",
150
+ foreground: "#2d3640"
151
+ // Dark text for terminal readability
152
+ },
153
+ daylight: {
154
+ name: "Daylight",
155
+ icon: "\u2600\uFE0F",
156
+ primary: "#1a1a1a",
157
+ secondary: "#0066CC",
158
+ glow: "rgba(0, 102, 204, 0.1)",
159
+ glowIntense: "rgba(0, 102, 204, 0.2)",
160
+ bg: "#FAFAF8",
161
+ statusBarBg: "#EEEEEC",
162
+ foreground: "#1a1a1a"
163
+ // Matches primary for consistent dark text
164
+ },
165
+ kawaii: {
166
+ name: "Kawaii",
167
+ icon: "\u{1F338}",
168
+ primary: "#FF69B4",
169
+ secondary: "#87CEEB",
170
+ glow: "rgba(255, 105, 180, 0.6)",
171
+ glowIntense: "rgba(255, 105, 180, 0.9)",
172
+ bg: "#1E0818",
173
+ statusBarBg: "#2D0F25"
174
+ },
175
+ kawaiiLight: {
176
+ name: "Kawaii Light",
177
+ icon: "\u{1F380}",
178
+ primary: "#D4458B",
179
+ secondary: "#7B68EE",
180
+ glow: "rgba(255, 105, 180, 0.2)",
181
+ glowIntense: "rgba(255, 105, 180, 0.4)",
182
+ bg: "#FFF5F8",
183
+ statusBarBg: "#F5EAEE",
184
+ foreground: "#2d3640"
185
+ // Dark text for terminal readability
186
+ },
187
+ oled: {
188
+ name: "OLED Black",
189
+ icon: "\u26AB",
190
+ primary: "#FFFFFF",
191
+ secondary: "#00D9FF",
192
+ glow: "rgba(255, 255, 255, 0.3)",
193
+ glowIntense: "rgba(255, 255, 255, 0.5)",
194
+ bg: "#000000",
195
+ statusBarBg: "#0A0A0A"
196
+ },
197
+ solarized: {
198
+ name: "Solarized",
199
+ icon: "\u{1F30A}",
200
+ primary: "#2AA198",
201
+ secondary: "#859900",
202
+ glow: "rgba(42, 161, 152, 0.4)",
203
+ glowIntense: "rgba(42, 161, 152, 0.6)",
204
+ bg: "#002B36",
205
+ statusBarBg: "#073642",
206
+ foreground: "#D4D4D4"
207
+ // Light gray for better readability
208
+ },
209
+ solarizedLight: {
210
+ name: "Solarized Light",
211
+ icon: "\u{1F3D6}\uFE0F",
212
+ primary: "#657B83",
213
+ secondary: "#268BD2",
214
+ glow: "rgba(38, 139, 210, 0.15)",
215
+ glowIntense: "rgba(38, 139, 210, 0.25)",
216
+ bg: "#FDF6E3",
217
+ statusBarBg: "#EEE8D5",
218
+ foreground: "#586e75"
219
+ // Solarized base01 for terminal text
220
+ },
221
+ nord: {
222
+ name: "Nord",
223
+ icon: "\u2744\uFE0F",
224
+ primary: "#88C0D0",
225
+ secondary: "#81A1C1",
226
+ glow: "rgba(136, 192, 208, 0.3)",
227
+ glowIntense: "rgba(136, 192, 208, 0.5)",
228
+ bg: "#2E3440",
229
+ statusBarBg: "#3B4252"
230
+ },
231
+ nordLight: {
232
+ name: "Nord Light",
233
+ icon: "\u{1F3D4}\uFE0F",
234
+ primary: "#2E3440",
235
+ secondary: "#5E81AC",
236
+ glow: "rgba(94, 129, 172, 0.15)",
237
+ glowIntense: "rgba(94, 129, 172, 0.25)",
238
+ bg: "#ECEFF4",
239
+ statusBarBg: "#E5E9F0",
240
+ foreground: "#2E3440"
241
+ // Nord polar night for terminal text
242
+ },
243
+ highcontrast: {
244
+ name: "High Contrast",
245
+ icon: "\u25D0",
246
+ primary: "#FFFFFF",
247
+ secondary: "#FFFF00",
248
+ glow: "rgba(255, 255, 255, 0.1)",
249
+ glowIntense: "rgba(255, 255, 255, 0.2)",
250
+ bg: "#000000",
251
+ statusBarBg: "#111111"
252
+ },
253
+ highcontrastLight: {
254
+ name: "High Contrast Light",
255
+ icon: "\u25D1",
256
+ primary: "#000000",
257
+ secondary: "#0000CC",
258
+ glow: "rgba(0, 0, 0, 0.05)",
259
+ glowIntense: "rgba(0, 0, 0, 0.1)",
260
+ bg: "#FFFFFF",
261
+ statusBarBg: "#EEEEEE",
262
+ foreground: "#000000"
263
+ // Maximum contrast for terminal text
264
+ },
265
+ banana: {
266
+ name: "Banana",
267
+ icon: "\u{1F34C}",
268
+ primary: "#FFE135",
269
+ secondary: "#8B7500",
270
+ glow: "rgba(255, 225, 53, 0.5)",
271
+ glowIntense: "rgba(255, 225, 53, 0.8)",
272
+ bg: "#1A1800",
273
+ statusBarBg: "#282400"
274
+ },
275
+ cream: {
276
+ name: "Cream",
277
+ icon: "\u{1F366}",
278
+ primary: "#4A3C2A",
279
+ secondary: "#C17844",
280
+ glow: "rgba(193, 120, 68, 0.12)",
281
+ glowIntense: "rgba(193, 120, 68, 0.22)",
282
+ bg: "#EDE5D4",
283
+ statusBarBg: "#E3DBCA",
284
+ foreground: "#4A3C2A"
285
+ }
286
+ };
287
+ var ansiCodes = {
288
+ cyan: "\x1B[96m",
289
+ cyanLight: "\x1B[38;5;31m",
290
+ amber: "\x1B[93m",
291
+ green: "\x1B[92m",
292
+ white: "\x1B[97m",
293
+ hotpink: "\x1B[95m",
294
+ hotpinkLight: "\x1B[38;5;169m",
295
+ blood: "\x1B[91m",
296
+ ice: "\x1B[96m",
297
+ iceLight: "\x1B[38;5;31m",
298
+ bladerunner: "\x1B[38;5;208m",
299
+ bladerunnerLight: "\x1B[38;5;166m",
300
+ tron: "\x1B[96m",
301
+ tronLight: "\x1B[38;5;30m",
302
+ daylight: "\x1B[34m",
303
+ kawaii: "\x1B[95m",
304
+ kawaiiLight: "\x1B[35m",
305
+ oled: "\x1B[97m",
306
+ solarized: "\x1B[36m",
307
+ solarizedLight: "\x1B[38;5;66m",
308
+ nord: "\x1B[96m",
309
+ nordLight: "\x1B[38;5;59m",
310
+ highcontrast: "\x1B[97m",
311
+ highcontrastLight: "\x1B[30m",
312
+ banana: "\x1B[93m",
313
+ cream: "\x1B[38;5;130m"
314
+ };
315
+ var lightThemes = /* @__PURE__ */ new Set([
316
+ "cyanLight",
317
+ "hotpinkLight",
318
+ "iceLight",
319
+ "bladerunnerLight",
320
+ "tronLight",
321
+ "daylight",
322
+ "kawaiiLight",
323
+ "solarizedLight",
324
+ "nordLight",
325
+ "highcontrastLight",
326
+ "cream"
327
+ ]);
328
+ var subtleColors = {
329
+ cyanLight: "\x1B[38;5;153m",
330
+ hotpinkLight: "\x1B[38;5;225m",
331
+ iceLight: "\x1B[38;5;195m",
332
+ bladerunnerLight: "\x1B[38;5;223m",
333
+ tronLight: "\x1B[38;5;159m",
334
+ daylight: "\x1B[38;5;252m",
335
+ kawaiiLight: "\x1B[38;5;218m",
336
+ solarizedLight: "\x1B[38;5;187m",
337
+ nordLight: "\x1B[38;5;255m",
338
+ highcontrastLight: "\x1B[38;5;250m",
339
+ cream: "\x1B[38;5;223m",
340
+ oled: "\x1B[38;5;234m",
341
+ highcontrast: "\x1B[38;5;238m"
342
+ };
343
+ function getTheme(mode) {
344
+ return themes[mode];
345
+ }
346
+ function getAnsiColor(mode) {
347
+ return ansiCodes[mode] || "\x1B[92m";
348
+ }
349
+ function isLightTheme(mode) {
350
+ return lightThemes.has(mode);
351
+ }
352
+ function getSubtleColor(mode) {
353
+ return subtleColors[mode] || "\x1B[38;5;236m";
354
+ }
355
+ function getThemeModes() {
356
+ return Object.keys(themes);
357
+ }
358
+ var VALID_THEME_MODES = new Set(Object.keys(themes));
359
+ function isValidThemeMode(value) {
360
+ return VALID_THEME_MODES.has(value);
361
+ }
362
+ var ANSI_RESET = "\x1B[0m";
363
+ function getTerminalTheme(mode) {
364
+ const theme = themes[mode];
365
+ const isLight = lightThemes.has(mode);
366
+ const selectionBg = isLight ? "#3399FF" : theme.primary;
367
+ const selectionFg = isLight ? "#000000" : "#000000";
368
+ let black, white, brightBlack, brightWhite;
369
+ if (isLight) {
370
+ black = theme.bg;
371
+ white = "#1a1a1a";
372
+ brightBlack = "#e0e0e0";
373
+ brightWhite = "#2a2a2a";
374
+ } else {
375
+ black = theme.bg;
376
+ white = "#FFFFFF";
377
+ brightBlack = "#636B7C";
378
+ brightWhite = "#FFFFFF";
379
+ }
380
+ const cursorAccent = isLight ? theme.foreground ?? "#1a1a1a" : theme.bg;
381
+ return {
382
+ background: "rgba(0, 0, 0, 0)",
383
+ foreground: theme.foreground ?? theme.primary,
384
+ cursor: theme.secondary,
385
+ cursorAccent,
386
+ selectionBackground: selectionBg,
387
+ selectionForeground: selectionFg,
388
+ black,
389
+ red: isLight ? "#c41a16" : "#FF0040",
390
+ green: isLight ? "#007400" : "#39FF14",
391
+ yellow: isLight ? "#826b00" : "#E5C400",
392
+ blue: isLight ? "#0451a5" : "#7AA2F7",
393
+ magenta: isLight ? "#a626a4" : theme.secondary,
394
+ cyan: isLight ? "#0598bc" : theme.primary,
395
+ white,
396
+ brightBlack,
397
+ brightRed: isLight ? "#e45649" : "#FF006E",
398
+ brightGreen: isLight ? "#50a14f" : "#39FF14",
399
+ brightYellow: isLight ? "#c18401" : "#FFD400",
400
+ brightBlue: isLight ? "#4078f2" : "#89B4FA",
401
+ brightMagenta: isLight ? "#c678dd" : theme.secondary,
402
+ brightCyan: isLight ? "#0184bc" : theme.primary,
403
+ brightWhite,
404
+ scrollbarSliderBackground: isLight ? "rgba(0, 0, 0, 0.12)" : "rgba(255, 255, 255, 0.1)",
405
+ scrollbarSliderHoverBackground: isLight ? "rgba(0, 0, 0, 0.2)" : "rgba(255, 255, 255, 0.18)",
406
+ scrollbarSliderActiveBackground: isLight ? "rgba(0, 0, 0, 0.28)" : "rgba(255, 255, 255, 0.25)"
407
+ };
408
+ }
409
+ function srgbToLinear(channel) {
410
+ const normalized = channel / 255;
411
+ return normalized <= 0.04045 ? normalized / 12.92 : Math.pow((normalized + 0.055) / 1.055, 2.4);
412
+ }
413
+ function relativeLuminance(r, g, b) {
414
+ return 0.2126 * srgbToLinear(r) + 0.7152 * srgbToLinear(g) + 0.0722 * srgbToLinear(b);
415
+ }
416
+ function contrastRatio(fgR, fgG, fgB, bgR, bgG, bgB) {
417
+ const fgLum = relativeLuminance(fgR, fgG, fgB);
418
+ const bgLum = relativeLuminance(bgR, bgG, bgB);
419
+ const lighter = Math.max(fgLum, bgLum);
420
+ const darker = Math.min(fgLum, bgLum);
421
+ return (lighter + 0.05) / (darker + 0.05);
422
+ }
423
+ function ensureReadableForegroundOnLightTheme(red, green, blue, bgR, bgG, bgB, minContrast = 4.2) {
424
+ if (contrastRatio(red, green, blue, bgR, bgG, bgB) >= minContrast) {
425
+ return [red, green, blue];
426
+ }
427
+ for (let step = 1; step <= 20; step += 1) {
428
+ const factor = 1 - step / 20;
429
+ const nextR = Math.round(red * factor);
430
+ const nextG = Math.round(green * factor);
431
+ const nextB = Math.round(blue * factor);
432
+ if (contrastRatio(nextR, nextG, nextB, bgR, bgG, bgB) >= minContrast) {
433
+ return [nextR, nextG, nextB];
434
+ }
435
+ }
436
+ return [30, 30, 30];
437
+ }
438
+ function ansi256ToRgb(colorIndex) {
439
+ if (colorIndex < 0 || colorIndex > 255) return null;
440
+ const basePalette = [
441
+ [0, 0, 0],
442
+ [205, 49, 49],
443
+ [13, 188, 121],
444
+ [229, 229, 16],
445
+ [36, 114, 200],
446
+ [188, 63, 188],
447
+ [17, 168, 205],
448
+ [229, 229, 229],
449
+ [102, 102, 102],
450
+ [241, 76, 76],
451
+ [35, 209, 139],
452
+ [245, 245, 67],
453
+ [59, 142, 234],
454
+ [214, 112, 214],
455
+ [41, 184, 219],
456
+ [255, 255, 255]
457
+ ];
458
+ if (colorIndex <= 15) return basePalette[colorIndex];
459
+ if (colorIndex >= 16 && colorIndex <= 231) {
460
+ const idx = colorIndex - 16;
461
+ const red = Math.floor(idx / 36);
462
+ const green = Math.floor(idx % 36 / 6);
463
+ const blue = idx % 6;
464
+ const level = [0, 95, 135, 175, 215, 255];
465
+ return [level[red], level[green], level[blue]];
466
+ }
467
+ const gray = 8 + (colorIndex - 232) * 10;
468
+ return [gray, gray, gray];
469
+ }
470
+ function transformEscapeSequencesForLightTheme(data, themeBg) {
471
+ const bgR = parseInt(themeBg.slice(1, 3), 16);
472
+ const bgG = parseInt(themeBg.slice(3, 5), 16);
473
+ const bgB = parseInt(themeBg.slice(5, 7), 16);
474
+ const highlightDelta = 22;
475
+ const highlightR = Math.max(bgR - highlightDelta, 0);
476
+ const highlightG = Math.max(bgG - highlightDelta, 0);
477
+ const highlightB = Math.max(bgB - highlightDelta, 0);
478
+ const transformSgr = (sequence) => {
479
+ const body = sequence.slice(2, -1);
480
+ if (body.length === 0) return sequence;
481
+ const normalized = body.replace(/:/g, ";");
482
+ const rawParams = normalized.split(";");
483
+ const params = [];
484
+ for (const raw of rawParams) {
485
+ if (raw === "") {
486
+ params.push(0);
487
+ continue;
488
+ }
489
+ const value = Number(raw);
490
+ if (!Number.isFinite(value)) {
491
+ return sequence;
492
+ }
493
+ params.push(value);
494
+ }
495
+ let changed = false;
496
+ const out = [];
497
+ for (let i = 0; i < params.length; i += 1) {
498
+ const code = params[i];
499
+ if (code === 48 && params[i + 1] === 2 && i + 4 < params.length) {
500
+ const hasColorSpace = i + 5 < params.length && params[i + 2] === 0 && params[i + 3] <= 255 && params[i + 4] <= 255 && params[i + 5] <= 255;
501
+ const offset = hasColorSpace ? 3 : 2;
502
+ const red = params[i + offset];
503
+ const green = params[i + offset + 1];
504
+ const blue = params[i + offset + 2];
505
+ const sum = red + green + blue;
506
+ if (sum < 600) {
507
+ out.push(48, 2, bgR, bgG, bgB);
508
+ changed = true;
509
+ } else {
510
+ out.push(48, 2, highlightR, highlightG, highlightB);
511
+ changed = true;
512
+ }
513
+ i += hasColorSpace ? 5 : 4;
514
+ continue;
515
+ }
516
+ if (code === 48 && params[i + 1] === 5 && i + 2 < params.length) {
517
+ const colorIndex = params[i + 2];
518
+ if (colorIndex === 7 || colorIndex === 8 || colorIndex === 15 || colorIndex >= 247 && colorIndex <= 255) {
519
+ out.push(48, 2, highlightR, highlightG, highlightB);
520
+ changed = true;
521
+ } else if (colorIndex === 0 || colorIndex === 16 || colorIndex >= 232 && colorIndex <= 246) {
522
+ out.push(48, 2, bgR, bgG, bgB);
523
+ changed = true;
524
+ } else {
525
+ out.push(48, 5, colorIndex);
526
+ }
527
+ i += 2;
528
+ continue;
529
+ }
530
+ if (code === 38 && params[i + 1] === 2 && i + 4 < params.length) {
531
+ const hasColorSpace = i + 5 < params.length && params[i + 2] === 0 && params[i + 3] <= 255 && params[i + 4] <= 255 && params[i + 5] <= 255;
532
+ const offset = hasColorSpace ? 3 : 2;
533
+ const red = params[i + offset];
534
+ const green = params[i + offset + 1];
535
+ const blue = params[i + offset + 2];
536
+ const [nextR, nextG, nextB] = ensureReadableForegroundOnLightTheme(red, green, blue, bgR, bgG, bgB);
537
+ if (nextR !== red || nextG !== green || nextB !== blue) {
538
+ out.push(38, 2, nextR, nextG, nextB);
539
+ changed = true;
540
+ } else {
541
+ out.push(38, 2, red, green, blue);
542
+ }
543
+ i += hasColorSpace ? 5 : 4;
544
+ continue;
545
+ }
546
+ if (code === 38 && params[i + 1] === 5 && i + 2 < params.length) {
547
+ const colorIndex = params[i + 2];
548
+ const rgb = ansi256ToRgb(colorIndex);
549
+ if (!rgb) {
550
+ out.push(38, 5, colorIndex);
551
+ i += 2;
552
+ continue;
553
+ }
554
+ const [red, green, blue] = rgb;
555
+ const [nextR, nextG, nextB] = ensureReadableForegroundOnLightTheme(red, green, blue, bgR, bgG, bgB);
556
+ if (nextR !== red || nextG !== green || nextB !== blue) {
557
+ out.push(38, 2, nextR, nextG, nextB);
558
+ changed = true;
559
+ } else {
560
+ out.push(38, 5, colorIndex);
561
+ }
562
+ i += 2;
563
+ continue;
564
+ }
565
+ if (code === 2) {
566
+ changed = true;
567
+ continue;
568
+ }
569
+ if (code === 40) {
570
+ out.push(48, 2, bgR, bgG, bgB);
571
+ changed = true;
572
+ continue;
573
+ }
574
+ if (code === 47 || code === 107) {
575
+ out.push(48, 2, highlightR, highlightG, highlightB);
576
+ changed = true;
577
+ continue;
578
+ }
579
+ if (code === 100) {
580
+ out.push(48, 2, highlightR, highlightG, highlightB);
581
+ changed = true;
582
+ continue;
583
+ }
584
+ if (code === 30) {
585
+ out.push(38, 2, 60, 60, 60);
586
+ changed = true;
587
+ continue;
588
+ }
589
+ if (code === 90) {
590
+ out.push(38, 2, 100, 100, 100);
591
+ changed = true;
592
+ continue;
593
+ }
594
+ if (code === 37) {
595
+ out.push(38, 2, 40, 40, 40);
596
+ changed = true;
597
+ continue;
598
+ }
599
+ if (code === 97) {
600
+ out.push(38, 2, 30, 30, 30);
601
+ changed = true;
602
+ continue;
603
+ }
604
+ if (code === 7) {
605
+ out.push(48, 2, highlightR, highlightG, highlightB);
606
+ changed = true;
607
+ continue;
608
+ }
609
+ if (code === 27) {
610
+ out.push(49);
611
+ changed = true;
612
+ continue;
613
+ }
614
+ out.push(code);
615
+ }
616
+ if (!changed) return sequence;
617
+ return `\x1B[${out.join(";")}m`;
618
+ };
619
+ return data.replace(/\x1b\[[0-9:;]*m/g, transformSgr);
620
+ }
621
+ function transformEscapeSequencesForDarkTheme(data, themeBg) {
622
+ const bgR = parseInt(themeBg.slice(1, 3), 16);
623
+ const bgG = parseInt(themeBg.slice(3, 5), 16);
624
+ const bgB = parseInt(themeBg.slice(5, 7), 16);
625
+ const transformSgr = (sequence) => {
626
+ const body = sequence.slice(2, -1);
627
+ if (body.length === 0) return sequence;
628
+ const normalized = body.replace(/:/g, ";");
629
+ const rawParams = normalized.split(";");
630
+ const params = [];
631
+ for (const raw of rawParams) {
632
+ if (raw === "") {
633
+ params.push(0);
634
+ continue;
635
+ }
636
+ const value = Number(raw);
637
+ if (!Number.isFinite(value)) return sequence;
638
+ params.push(value);
639
+ }
640
+ let changed = false;
641
+ const out = [];
642
+ for (let i = 0; i < params.length; i += 1) {
643
+ const code = params[i];
644
+ if (code === 48 && params[i + 1] === 2 && i + 4 < params.length) {
645
+ const hasColorSpace = i + 5 < params.length && params[i + 2] === 0 && params[i + 3] <= 255 && params[i + 4] <= 255 && params[i + 5] <= 255;
646
+ const offset = hasColorSpace ? 3 : 2;
647
+ const red = params[i + offset];
648
+ const green = params[i + offset + 1];
649
+ const blue = params[i + offset + 2];
650
+ const sum = red + green + blue;
651
+ if (sum < 40 || sum > 700) {
652
+ out.push(48, 2, bgR, bgG, bgB);
653
+ changed = true;
654
+ } else {
655
+ out.push(48, 2, red, green, blue);
656
+ }
657
+ i += hasColorSpace ? 5 : 4;
658
+ continue;
659
+ }
660
+ if (code === 48 && params[i + 1] === 5 && i + 2 < params.length) {
661
+ const colorIndex = params[i + 2];
662
+ if (colorIndex === 0 || colorIndex === 7 || colorIndex === 8 || colorIndex === 15 || colorIndex === 16 || colorIndex === 231 || colorIndex >= 232 && colorIndex <= 234 || colorIndex >= 250 && colorIndex <= 255) {
663
+ out.push(48, 2, bgR, bgG, bgB);
664
+ changed = true;
665
+ } else {
666
+ out.push(48, 5, colorIndex);
667
+ }
668
+ i += 2;
669
+ continue;
670
+ }
671
+ if (code === 47 || code === 107) {
672
+ out.push(48, 2, bgR, bgG, bgB);
673
+ changed = true;
674
+ continue;
675
+ }
676
+ out.push(code);
677
+ }
678
+ if (!changed) return sequence;
679
+ return `\x1B[${out.join(";")}m`;
680
+ };
681
+ return data.replace(/\x1b\[[0-9:;]*m/g, transformSgr);
682
+ }
683
+
684
+ export {
685
+ themes,
686
+ getTheme,
687
+ getAnsiColor,
688
+ isLightTheme,
689
+ getSubtleColor,
690
+ getThemeModes,
691
+ isValidThemeMode,
692
+ ANSI_RESET,
693
+ getTerminalTheme,
694
+ transformEscapeSequencesForLightTheme,
695
+ transformEscapeSequencesForDarkTheme
696
+ };
697
+ //# sourceMappingURL=chunk-AVGB32MC.js.map