@naram/codex-switch 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.
package/dist/index.js ADDED
@@ -0,0 +1,1965 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // node_modules/sisteransi/src/index.js
29
+ var require_src = __commonJS({
30
+ "node_modules/sisteransi/src/index.js"(exports, module) {
31
+ "use strict";
32
+ var ESC = "\x1B";
33
+ var CSI = `${ESC}[`;
34
+ var beep = "\x07";
35
+ var cursor = {
36
+ to(x3, y3) {
37
+ if (!y3) return `${CSI}${x3 + 1}G`;
38
+ return `${CSI}${y3 + 1};${x3 + 1}H`;
39
+ },
40
+ move(x3, y3) {
41
+ let ret = "";
42
+ if (x3 < 0) ret += `${CSI}${-x3}D`;
43
+ else if (x3 > 0) ret += `${CSI}${x3}C`;
44
+ if (y3 < 0) ret += `${CSI}${-y3}A`;
45
+ else if (y3 > 0) ret += `${CSI}${y3}B`;
46
+ return ret;
47
+ },
48
+ up: (count = 1) => `${CSI}${count}A`,
49
+ down: (count = 1) => `${CSI}${count}B`,
50
+ forward: (count = 1) => `${CSI}${count}C`,
51
+ backward: (count = 1) => `${CSI}${count}D`,
52
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
53
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
54
+ left: `${CSI}G`,
55
+ hide: `${CSI}?25l`,
56
+ show: `${CSI}?25h`,
57
+ save: `${ESC}7`,
58
+ restore: `${ESC}8`
59
+ };
60
+ var scroll = {
61
+ up: (count = 1) => `${CSI}S`.repeat(count),
62
+ down: (count = 1) => `${CSI}T`.repeat(count)
63
+ };
64
+ var erase = {
65
+ screen: `${CSI}2J`,
66
+ up: (count = 1) => `${CSI}1J`.repeat(count),
67
+ down: (count = 1) => `${CSI}J`.repeat(count),
68
+ line: `${CSI}2K`,
69
+ lineEnd: `${CSI}K`,
70
+ lineStart: `${CSI}1K`,
71
+ lines(count) {
72
+ let clear = "";
73
+ for (let i = 0; i < count; i++)
74
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
75
+ if (count)
76
+ clear += cursor.left;
77
+ return clear;
78
+ }
79
+ };
80
+ module.exports = { cursor, scroll, erase, beep };
81
+ }
82
+ });
83
+
84
+ // node_modules/picocolors/picocolors.js
85
+ var require_picocolors = __commonJS({
86
+ "node_modules/picocolors/picocolors.js"(exports, module) {
87
+ "use strict";
88
+ var p = process || {};
89
+ var argv = p.argv || [];
90
+ var env = p.env || {};
91
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
92
+ var formatter = (open, close, replace = open) => (input) => {
93
+ let string = "" + input, index = string.indexOf(close, open.length);
94
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
95
+ };
96
+ var replaceClose = (string, close, replace, index) => {
97
+ let result = "", cursor = 0;
98
+ do {
99
+ result += string.substring(cursor, index) + replace;
100
+ cursor = index + close.length;
101
+ index = string.indexOf(close, cursor);
102
+ } while (~index);
103
+ return result + string.substring(cursor);
104
+ };
105
+ var createColors = (enabled = isColorSupported) => {
106
+ let f3 = enabled ? formatter : () => String;
107
+ return {
108
+ isColorSupported: enabled,
109
+ reset: f3("\x1B[0m", "\x1B[0m"),
110
+ bold: f3("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
111
+ dim: f3("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
112
+ italic: f3("\x1B[3m", "\x1B[23m"),
113
+ underline: f3("\x1B[4m", "\x1B[24m"),
114
+ inverse: f3("\x1B[7m", "\x1B[27m"),
115
+ hidden: f3("\x1B[8m", "\x1B[28m"),
116
+ strikethrough: f3("\x1B[9m", "\x1B[29m"),
117
+ black: f3("\x1B[30m", "\x1B[39m"),
118
+ red: f3("\x1B[31m", "\x1B[39m"),
119
+ green: f3("\x1B[32m", "\x1B[39m"),
120
+ yellow: f3("\x1B[33m", "\x1B[39m"),
121
+ blue: f3("\x1B[34m", "\x1B[39m"),
122
+ magenta: f3("\x1B[35m", "\x1B[39m"),
123
+ cyan: f3("\x1B[36m", "\x1B[39m"),
124
+ white: f3("\x1B[37m", "\x1B[39m"),
125
+ gray: f3("\x1B[90m", "\x1B[39m"),
126
+ bgBlack: f3("\x1B[40m", "\x1B[49m"),
127
+ bgRed: f3("\x1B[41m", "\x1B[49m"),
128
+ bgGreen: f3("\x1B[42m", "\x1B[49m"),
129
+ bgYellow: f3("\x1B[43m", "\x1B[49m"),
130
+ bgBlue: f3("\x1B[44m", "\x1B[49m"),
131
+ bgMagenta: f3("\x1B[45m", "\x1B[49m"),
132
+ bgCyan: f3("\x1B[46m", "\x1B[49m"),
133
+ bgWhite: f3("\x1B[47m", "\x1B[49m"),
134
+ blackBright: f3("\x1B[90m", "\x1B[39m"),
135
+ redBright: f3("\x1B[91m", "\x1B[39m"),
136
+ greenBright: f3("\x1B[92m", "\x1B[39m"),
137
+ yellowBright: f3("\x1B[93m", "\x1B[39m"),
138
+ blueBright: f3("\x1B[94m", "\x1B[39m"),
139
+ magentaBright: f3("\x1B[95m", "\x1B[39m"),
140
+ cyanBright: f3("\x1B[96m", "\x1B[39m"),
141
+ whiteBright: f3("\x1B[97m", "\x1B[39m"),
142
+ bgBlackBright: f3("\x1B[100m", "\x1B[49m"),
143
+ bgRedBright: f3("\x1B[101m", "\x1B[49m"),
144
+ bgGreenBright: f3("\x1B[102m", "\x1B[49m"),
145
+ bgYellowBright: f3("\x1B[103m", "\x1B[49m"),
146
+ bgBlueBright: f3("\x1B[104m", "\x1B[49m"),
147
+ bgMagentaBright: f3("\x1B[105m", "\x1B[49m"),
148
+ bgCyanBright: f3("\x1B[106m", "\x1B[49m"),
149
+ bgWhiteBright: f3("\x1B[107m", "\x1B[49m")
150
+ };
151
+ };
152
+ module.exports = createColors();
153
+ module.exports.createColors = createColors;
154
+ }
155
+ });
156
+
157
+ // node_modules/@clack/core/dist/index.mjs
158
+ var import_sisteransi = __toESM(require_src(), 1);
159
+ var import_picocolors = __toESM(require_picocolors(), 1);
160
+ import { stdin as $, stdout as k } from "process";
161
+ import * as f from "readline";
162
+ import _ from "readline";
163
+ import { WriteStream as U } from "tty";
164
+ function q({ onlyFirst: e2 = false } = {}) {
165
+ const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
166
+ return new RegExp(F, e2 ? void 0 : "g");
167
+ }
168
+ var J = q();
169
+ function S(e2) {
170
+ if (typeof e2 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e2}\``);
171
+ return e2.replace(J, "");
172
+ }
173
+ function T(e2) {
174
+ return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
175
+ }
176
+ var j = { exports: {} };
177
+ (function(e2) {
178
+ var u = {};
179
+ e2.exports = u, u.eastAsianWidth = function(t) {
180
+ var s = t.charCodeAt(0), C2 = t.length == 2 ? t.charCodeAt(1) : 0, D = s;
181
+ return 55296 <= s && s <= 56319 && 56320 <= C2 && C2 <= 57343 && (s &= 1023, C2 &= 1023, D = s << 10 | C2, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
182
+ }, u.characterLength = function(t) {
183
+ var s = this.eastAsianWidth(t);
184
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
185
+ };
186
+ function F(t) {
187
+ return t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
188
+ }
189
+ u.length = function(t) {
190
+ for (var s = F(t), C2 = 0, D = 0; D < s.length; D++) C2 = C2 + this.characterLength(s[D]);
191
+ return C2;
192
+ }, u.slice = function(t, s, C2) {
193
+ textLen = u.length(t), s = s || 0, C2 = C2 || 1, s < 0 && (s = textLen + s), C2 < 0 && (C2 = textLen + C2);
194
+ for (var D = "", i = 0, n = F(t), E2 = 0; E2 < n.length; E2++) {
195
+ var h2 = n[E2], o2 = u.length(h2);
196
+ if (i >= s - (o2 == 2 ? 1 : 0)) if (i + o2 <= C2) D += h2;
197
+ else break;
198
+ i += o2;
199
+ }
200
+ return D;
201
+ };
202
+ })(j);
203
+ var Q = j.exports;
204
+ var X = T(Q);
205
+ var DD = function() {
206
+ 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;
207
+ };
208
+ var uD = T(DD);
209
+ function A(e2, u = {}) {
210
+ if (typeof e2 != "string" || e2.length === 0 || (u = { ambiguousIsNarrow: true, ...u }, e2 = S(e2), e2.length === 0)) return 0;
211
+ e2 = e2.replace(uD(), " ");
212
+ const F = u.ambiguousIsNarrow ? 1 : 2;
213
+ let t = 0;
214
+ for (const s of e2) {
215
+ const C2 = s.codePointAt(0);
216
+ if (C2 <= 31 || C2 >= 127 && C2 <= 159 || C2 >= 768 && C2 <= 879) continue;
217
+ switch (X.eastAsianWidth(s)) {
218
+ case "F":
219
+ case "W":
220
+ t += 2;
221
+ break;
222
+ case "A":
223
+ t += F;
224
+ break;
225
+ default:
226
+ t += 1;
227
+ }
228
+ }
229
+ return t;
230
+ }
231
+ var d = 10;
232
+ var M = (e2 = 0) => (u) => `\x1B[${u + e2}m`;
233
+ var P = (e2 = 0) => (u) => `\x1B[${38 + e2};5;${u}m`;
234
+ var W = (e2 = 0) => (u, F, t) => `\x1B[${38 + e2};2;${u};${F};${t}m`;
235
+ 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] } };
236
+ Object.keys(r.modifier);
237
+ var FD = Object.keys(r.color);
238
+ var eD = Object.keys(r.bgColor);
239
+ [...FD, ...eD];
240
+ function tD() {
241
+ const e2 = /* @__PURE__ */ new Map();
242
+ for (const [u, F] of Object.entries(r)) {
243
+ for (const [t, s] of Object.entries(F)) r[t] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[t] = r[t], e2.set(s[0], s[1]);
244
+ Object.defineProperty(r, u, { value: F, enumerable: false });
245
+ }
246
+ return Object.defineProperty(r, "codes", { value: e2, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = M(), r.color.ansi256 = P(), r.color.ansi16m = W(), r.bgColor.ansi = M(d), r.bgColor.ansi256 = P(d), r.bgColor.ansi16m = W(d), Object.defineProperties(r, { rgbToAnsi256: { value: (u, F, t) => u === F && F === t ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(t / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
247
+ const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
248
+ if (!F) return [0, 0, 0];
249
+ let [t] = F;
250
+ t.length === 3 && (t = [...t].map((C2) => C2 + C2).join(""));
251
+ const s = Number.parseInt(t, 16);
252
+ return [s >> 16 & 255, s >> 8 & 255, s & 255];
253
+ }, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
254
+ if (u < 8) return 30 + u;
255
+ if (u < 16) return 90 + (u - 8);
256
+ let F, t, s;
257
+ if (u >= 232) F = ((u - 232) * 10 + 8) / 255, t = F, s = F;
258
+ else {
259
+ u -= 16;
260
+ const i = u % 36;
261
+ F = Math.floor(u / 36) / 5, t = Math.floor(i / 6) / 5, s = i % 6 / 5;
262
+ }
263
+ const C2 = Math.max(F, t, s) * 2;
264
+ if (C2 === 0) return 30;
265
+ let D = 30 + (Math.round(s) << 2 | Math.round(t) << 1 | Math.round(F));
266
+ return C2 === 2 && (D += 60), D;
267
+ }, enumerable: false }, rgbToAnsi: { value: (u, F, t) => r.ansi256ToAnsi(r.rgbToAnsi256(u, F, t)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
268
+ }
269
+ var sD = tD();
270
+ var g = /* @__PURE__ */ new Set(["\x1B", "\x9B"]);
271
+ var CD = 39;
272
+ var b = "\x07";
273
+ var O = "[";
274
+ var iD = "]";
275
+ var I = "m";
276
+ var w = `${iD}8;;`;
277
+ var N = (e2) => `${g.values().next().value}${O}${e2}${I}`;
278
+ var L = (e2) => `${g.values().next().value}${w}${e2}${b}`;
279
+ var rD = (e2) => e2.split(" ").map((u) => A(u));
280
+ var y = (e2, u, F) => {
281
+ const t = [...u];
282
+ let s = false, C2 = false, D = A(S(e2[e2.length - 1]));
283
+ for (const [i, n] of t.entries()) {
284
+ const E2 = A(n);
285
+ if (D + E2 <= F ? e2[e2.length - 1] += n : (e2.push(n), D = 0), g.has(n) && (s = true, C2 = t.slice(i + 1).join("").startsWith(w)), s) {
286
+ C2 ? n === b && (s = false, C2 = false) : n === I && (s = false);
287
+ continue;
288
+ }
289
+ D += E2, D === F && i < t.length - 1 && (e2.push(""), D = 0);
290
+ }
291
+ !D && e2[e2.length - 1].length > 0 && e2.length > 1 && (e2[e2.length - 2] += e2.pop());
292
+ };
293
+ var ED = (e2) => {
294
+ const u = e2.split(" ");
295
+ let F = u.length;
296
+ for (; F > 0 && !(A(u[F - 1]) > 0); ) F--;
297
+ return F === u.length ? e2 : u.slice(0, F).join(" ") + u.slice(F).join("");
298
+ };
299
+ var oD = (e2, u, F = {}) => {
300
+ if (F.trim !== false && e2.trim() === "") return "";
301
+ let t = "", s, C2;
302
+ const D = rD(e2);
303
+ let i = [""];
304
+ for (const [E2, h2] of e2.split(" ").entries()) {
305
+ F.trim !== false && (i[i.length - 1] = i[i.length - 1].trimStart());
306
+ let o2 = A(i[i.length - 1]);
307
+ if (E2 !== 0 && (o2 >= u && (F.wordWrap === false || F.trim === false) && (i.push(""), o2 = 0), (o2 > 0 || F.trim === false) && (i[i.length - 1] += " ", o2++)), F.hard && D[E2] > u) {
308
+ const B2 = u - o2, p = 1 + Math.floor((D[E2] - B2 - 1) / u);
309
+ Math.floor((D[E2] - 1) / u) < p && i.push(""), y(i, h2, u);
310
+ continue;
311
+ }
312
+ if (o2 + D[E2] > u && o2 > 0 && D[E2] > 0) {
313
+ if (F.wordWrap === false && o2 < u) {
314
+ y(i, h2, u);
315
+ continue;
316
+ }
317
+ i.push("");
318
+ }
319
+ if (o2 + D[E2] > u && F.wordWrap === false) {
320
+ y(i, h2, u);
321
+ continue;
322
+ }
323
+ i[i.length - 1] += h2;
324
+ }
325
+ F.trim !== false && (i = i.map((E2) => ED(E2)));
326
+ const n = [...i.join(`
327
+ `)];
328
+ for (const [E2, h2] of n.entries()) {
329
+ if (t += h2, g.has(h2)) {
330
+ const { groups: B2 } = new RegExp(`(?:\\${O}(?<code>\\d+)m|\\${w}(?<uri>.*)${b})`).exec(n.slice(E2).join("")) || { groups: {} };
331
+ if (B2.code !== void 0) {
332
+ const p = Number.parseFloat(B2.code);
333
+ s = p === CD ? void 0 : p;
334
+ } else B2.uri !== void 0 && (C2 = B2.uri.length === 0 ? void 0 : B2.uri);
335
+ }
336
+ const o2 = sD.codes.get(Number(s));
337
+ n[E2 + 1] === `
338
+ ` ? (C2 && (t += L("")), s && o2 && (t += N(o2))) : h2 === `
339
+ ` && (s && o2 && (t += N(s)), C2 && (t += L(C2)));
340
+ }
341
+ return t;
342
+ };
343
+ function R(e2, u, F) {
344
+ return String(e2).normalize().replace(/\r\n/g, `
345
+ `).split(`
346
+ `).map((t) => oD(t, u, F)).join(`
347
+ `);
348
+ }
349
+ var nD = Object.defineProperty;
350
+ var aD = (e2, u, F) => u in e2 ? nD(e2, u, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u] = F;
351
+ var a = (e2, u, F) => (aD(e2, typeof u != "symbol" ? u + "" : u, F), F);
352
+ function hD(e2, u) {
353
+ if (e2 === u) return;
354
+ const F = e2.split(`
355
+ `), t = u.split(`
356
+ `), s = [];
357
+ for (let C2 = 0; C2 < Math.max(F.length, t.length); C2++) F[C2] !== t[C2] && s.push(C2);
358
+ return s;
359
+ }
360
+ var V = /* @__PURE__ */ Symbol("clack:cancel");
361
+ function lD(e2) {
362
+ return e2 === V;
363
+ }
364
+ function v(e2, u) {
365
+ e2.isTTY && e2.setRawMode(u);
366
+ }
367
+ var z = /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"]]);
368
+ var xD = /* @__PURE__ */ new Set(["up", "down", "left", "right", "space", "enter"]);
369
+ var x = class {
370
+ constructor({ render: u, input: F = $, output: t = k, ...s }, C2 = true) {
371
+ a(this, "input"), a(this, "output"), a(this, "rl"), a(this, "opts"), a(this, "_track", false), a(this, "_render"), a(this, "_cursor", 0), a(this, "state", "initial"), a(this, "value"), a(this, "error", ""), a(this, "subscribers", /* @__PURE__ */ new Map()), a(this, "_prevFrame", ""), this.opts = s, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = u.bind(this), this._track = C2, this.input = F, this.output = t;
372
+ }
373
+ prompt() {
374
+ const u = new U(0);
375
+ return u._write = (F, t, s) => {
376
+ this._track && (this.value = this.rl.line.replace(/\t/g, ""), this._cursor = this.rl.cursor, this.emit("value", this.value)), s();
377
+ }, this.input.pipe(u), this.rl = _.createInterface({ input: this.input, output: u, tabSize: 2, prompt: "", escapeCodeTimeout: 50 }), _.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), v(this.input, true), this.output.on("resize", this.render), this.render(), new Promise((F, t) => {
378
+ this.once("submit", () => {
379
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), v(this.input, false), F(this.value);
380
+ }), this.once("cancel", () => {
381
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), v(this.input, false), F(V);
382
+ });
383
+ });
384
+ }
385
+ on(u, F) {
386
+ const t = this.subscribers.get(u) ?? [];
387
+ t.push({ cb: F }), this.subscribers.set(u, t);
388
+ }
389
+ once(u, F) {
390
+ const t = this.subscribers.get(u) ?? [];
391
+ t.push({ cb: F, once: true }), this.subscribers.set(u, t);
392
+ }
393
+ emit(u, ...F) {
394
+ const t = this.subscribers.get(u) ?? [], s = [];
395
+ for (const C2 of t) C2.cb(...F), C2.once && s.push(() => t.splice(t.indexOf(C2), 1));
396
+ for (const C2 of s) C2();
397
+ }
398
+ unsubscribe() {
399
+ this.subscribers.clear();
400
+ }
401
+ onKeypress(u, F) {
402
+ if (this.state === "error" && (this.state = "active"), F?.name && !this._track && z.has(F.name) && this.emit("cursor", z.get(F.name)), F?.name && xD.has(F.name) && this.emit("cursor", F.name), u && (u.toLowerCase() === "y" || u.toLowerCase() === "n") && this.emit("confirm", u.toLowerCase() === "y"), u === " " && this.opts.placeholder && (this.value || (this.rl.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u && this.emit("key", u.toLowerCase()), F?.name === "return") {
403
+ if (this.opts.validate) {
404
+ const t = this.opts.validate(this.value);
405
+ t && (this.error = t, this.state = "error", this.rl.write(this.value));
406
+ }
407
+ this.state !== "error" && (this.state = "submit");
408
+ }
409
+ u === "" && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
410
+ }
411
+ close() {
412
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
413
+ `), v(this.input, false), this.rl.close(), this.emit(`${this.state}`, this.value), this.unsubscribe();
414
+ }
415
+ restoreCursor() {
416
+ const u = R(this._prevFrame, process.stdout.columns, { hard: true }).split(`
417
+ `).length - 1;
418
+ this.output.write(import_sisteransi.cursor.move(-999, u * -1));
419
+ }
420
+ render() {
421
+ const u = R(this._render(this) ?? "", process.stdout.columns, { hard: true });
422
+ if (u !== this._prevFrame) {
423
+ if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
424
+ else {
425
+ const F = hD(this._prevFrame, u);
426
+ if (this.restoreCursor(), F && F?.length === 1) {
427
+ const t = F[0];
428
+ this.output.write(import_sisteransi.cursor.move(0, t)), this.output.write(import_sisteransi.erase.lines(1));
429
+ const s = u.split(`
430
+ `);
431
+ this.output.write(s[t]), this._prevFrame = u, this.output.write(import_sisteransi.cursor.move(0, s.length - t - 1));
432
+ return;
433
+ } else if (F && F?.length > 1) {
434
+ const t = F[0];
435
+ this.output.write(import_sisteransi.cursor.move(0, t)), this.output.write(import_sisteransi.erase.down());
436
+ const s = u.split(`
437
+ `).slice(t);
438
+ this.output.write(s.join(`
439
+ `)), this._prevFrame = u;
440
+ return;
441
+ }
442
+ this.output.write(import_sisteransi.erase.down());
443
+ }
444
+ this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
445
+ }
446
+ }
447
+ };
448
+ var BD = class extends x {
449
+ get cursor() {
450
+ return this.value ? 0 : 1;
451
+ }
452
+ get _value() {
453
+ return this.cursor === 0;
454
+ }
455
+ constructor(u) {
456
+ super(u, false), this.value = !!u.initialValue, this.on("value", () => {
457
+ this.value = this._value;
458
+ }), this.on("confirm", (F) => {
459
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = F, this.state = "submit", this.close();
460
+ }), this.on("cursor", () => {
461
+ this.value = !this.value;
462
+ });
463
+ }
464
+ };
465
+ var fD = Object.defineProperty;
466
+ var gD = (e2, u, F) => u in e2 ? fD(e2, u, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u] = F;
467
+ var K = (e2, u, F) => (gD(e2, typeof u != "symbol" ? u + "" : u, F), F);
468
+ var vD = class extends x {
469
+ constructor(u) {
470
+ super(u, false), K(this, "options"), K(this, "cursor", 0), this.options = u.options, this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F }) => F === u.cursorAt), 0), this.on("key", (F) => {
471
+ F === "a" && this.toggleAll();
472
+ }), this.on("cursor", (F) => {
473
+ switch (F) {
474
+ case "left":
475
+ case "up":
476
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
477
+ break;
478
+ case "down":
479
+ case "right":
480
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
481
+ break;
482
+ case "space":
483
+ this.toggleValue();
484
+ break;
485
+ }
486
+ });
487
+ }
488
+ get _value() {
489
+ return this.options[this.cursor].value;
490
+ }
491
+ toggleAll() {
492
+ const u = this.value.length === this.options.length;
493
+ this.value = u ? [] : this.options.map((F) => F.value);
494
+ }
495
+ toggleValue() {
496
+ const u = this.value.includes(this._value);
497
+ this.value = u ? this.value.filter((F) => F !== this._value) : [...this.value, this._value];
498
+ }
499
+ };
500
+ var mD = Object.defineProperty;
501
+ var dD = (e2, u, F) => u in e2 ? mD(e2, u, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u] = F;
502
+ var Y = (e2, u, F) => (dD(e2, typeof u != "symbol" ? u + "" : u, F), F);
503
+ var bD = class extends x {
504
+ constructor({ mask: u, ...F }) {
505
+ super(F), Y(this, "valueWithCursor", ""), Y(this, "_mask", "\u2022"), this._mask = u ?? "\u2022", this.on("finalize", () => {
506
+ this.valueWithCursor = this.masked;
507
+ }), this.on("value", () => {
508
+ if (this.cursor >= this.value.length) this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
509
+ else {
510
+ const t = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
511
+ this.valueWithCursor = `${t}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
512
+ }
513
+ });
514
+ }
515
+ get cursor() {
516
+ return this._cursor;
517
+ }
518
+ get masked() {
519
+ return this.value.replaceAll(/./g, this._mask);
520
+ }
521
+ };
522
+ var wD = Object.defineProperty;
523
+ var yD = (e2, u, F) => u in e2 ? wD(e2, u, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u] = F;
524
+ var Z = (e2, u, F) => (yD(e2, typeof u != "symbol" ? u + "" : u, F), F);
525
+ var $D = class extends x {
526
+ constructor(u) {
527
+ super(u, false), Z(this, "options"), Z(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: F }) => F === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F) => {
528
+ switch (F) {
529
+ case "left":
530
+ case "up":
531
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
532
+ break;
533
+ case "down":
534
+ case "right":
535
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
536
+ break;
537
+ }
538
+ this.changeValue();
539
+ });
540
+ }
541
+ get _value() {
542
+ return this.options[this.cursor];
543
+ }
544
+ changeValue() {
545
+ this.value = this._value.value;
546
+ }
547
+ };
548
+ var TD = Object.defineProperty;
549
+ var jD = (e2, u, F) => u in e2 ? TD(e2, u, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u] = F;
550
+ var MD = (e2, u, F) => (jD(e2, typeof u != "symbol" ? u + "" : u, F), F);
551
+ var PD = class extends x {
552
+ constructor(u) {
553
+ super(u), MD(this, "valueWithCursor", ""), this.on("finalize", () => {
554
+ this.value || (this.value = u.defaultValue), this.valueWithCursor = this.value;
555
+ }), this.on("value", () => {
556
+ if (this.cursor >= this.value.length) this.valueWithCursor = `${this.value}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
557
+ else {
558
+ const F = this.value.slice(0, this.cursor), t = this.value.slice(this.cursor);
559
+ this.valueWithCursor = `${F}${import_picocolors.default.inverse(t[0])}${t.slice(1)}`;
560
+ }
561
+ });
562
+ }
563
+ get cursor() {
564
+ return this._cursor;
565
+ }
566
+ };
567
+ var WD = globalThis.process.platform.startsWith("win");
568
+ function OD({ input: e2 = $, output: u = k, overwrite: F = true, hideCursor: t = true } = {}) {
569
+ const s = f.createInterface({ input: e2, output: u, prompt: "", tabSize: 1 });
570
+ f.emitKeypressEvents(e2, s), e2.isTTY && e2.setRawMode(true);
571
+ const C2 = (D, { name: i }) => {
572
+ if (String(D) === "") {
573
+ t && u.write(import_sisteransi.cursor.show), process.exit(0);
574
+ return;
575
+ }
576
+ if (!F) return;
577
+ let n = i === "return" ? 0 : -1, E2 = i === "return" ? -1 : 0;
578
+ f.moveCursor(u, n, E2, () => {
579
+ f.clearLine(u, 1, () => {
580
+ e2.once("keypress", C2);
581
+ });
582
+ });
583
+ };
584
+ return t && u.write(import_sisteransi.cursor.hide), e2.once("keypress", C2), () => {
585
+ e2.off("keypress", C2), t && u.write(import_sisteransi.cursor.show), e2.isTTY && !WD && e2.setRawMode(false), s.terminal = false, s.close();
586
+ };
587
+ }
588
+
589
+ // node_modules/@clack/prompts/dist/index.mjs
590
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
591
+ var import_sisteransi2 = __toESM(require_src(), 1);
592
+ import h from "process";
593
+ function q2() {
594
+ return h.platform !== "win32" ? h.env.TERM !== "linux" : Boolean(h.env.CI) || Boolean(h.env.WT_SESSION) || Boolean(h.env.TERMINUS_SUBLIME) || h.env.ConEmuTask === "{cmd::Cmder}" || h.env.TERM_PROGRAM === "Terminus-Sublime" || h.env.TERM_PROGRAM === "vscode" || h.env.TERM === "xterm-256color" || h.env.TERM === "alacritty" || h.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
595
+ }
596
+ var _2 = q2();
597
+ var o = (r2, n) => _2 ? r2 : n;
598
+ var H = o("\u25C6", "*");
599
+ var I2 = o("\u25A0", "x");
600
+ var x2 = o("\u25B2", "x");
601
+ var S2 = o("\u25C7", "o");
602
+ var K2 = o("\u250C", "T");
603
+ var a2 = o("\u2502", "|");
604
+ var d2 = o("\u2514", "\u2014");
605
+ var b2 = o("\u25CF", ">");
606
+ var E = o("\u25CB", " ");
607
+ var C = o("\u25FB", "[\u2022]");
608
+ var w2 = o("\u25FC", "[+]");
609
+ var M2 = o("\u25FB", "[ ]");
610
+ var U2 = o("\u25AA", "\u2022");
611
+ var B = o("\u2500", "-");
612
+ var Z2 = o("\u256E", "+");
613
+ var z2 = o("\u251C", "+");
614
+ var X2 = o("\u256F", "+");
615
+ var J2 = o("\u25CF", "\u2022");
616
+ var Y2 = o("\u25C6", "*");
617
+ var Q2 = o("\u25B2", "!");
618
+ var ee = o("\u25A0", "x");
619
+ var y2 = (r2) => {
620
+ switch (r2) {
621
+ case "initial":
622
+ case "active":
623
+ return import_picocolors2.default.cyan(H);
624
+ case "cancel":
625
+ return import_picocolors2.default.red(I2);
626
+ case "error":
627
+ return import_picocolors2.default.yellow(x2);
628
+ case "submit":
629
+ return import_picocolors2.default.green(S2);
630
+ }
631
+ };
632
+ var te = (r2) => new PD({ validate: r2.validate, placeholder: r2.placeholder, defaultValue: r2.defaultValue, initialValue: r2.initialValue, render() {
633
+ const n = `${import_picocolors2.default.gray(a2)}
634
+ ${y2(this.state)} ${r2.message}
635
+ `, i = r2.placeholder ? import_picocolors2.default.inverse(r2.placeholder[0]) + import_picocolors2.default.dim(r2.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), t = this.value ? this.valueWithCursor : i;
636
+ switch (this.state) {
637
+ case "error":
638
+ return `${n.trim()}
639
+ ${import_picocolors2.default.yellow(a2)} ${t}
640
+ ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
641
+ `;
642
+ case "submit":
643
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.dim(this.value || r2.placeholder)}`;
644
+ case "cancel":
645
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
646
+ ` + import_picocolors2.default.gray(a2) : ""}`;
647
+ default:
648
+ return `${n}${import_picocolors2.default.cyan(a2)} ${t}
649
+ ${import_picocolors2.default.cyan(d2)}
650
+ `;
651
+ }
652
+ } }).prompt();
653
+ var re = (r2) => new bD({ validate: r2.validate, mask: r2.mask ?? U2, render() {
654
+ const n = `${import_picocolors2.default.gray(a2)}
655
+ ${y2(this.state)} ${r2.message}
656
+ `, i = this.valueWithCursor, t = this.masked;
657
+ switch (this.state) {
658
+ case "error":
659
+ return `${n.trim()}
660
+ ${import_picocolors2.default.yellow(a2)} ${t}
661
+ ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
662
+ `;
663
+ case "submit":
664
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.dim(t)}`;
665
+ case "cancel":
666
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(t ?? ""))}${t ? `
667
+ ` + import_picocolors2.default.gray(a2) : ""}`;
668
+ default:
669
+ return `${n}${import_picocolors2.default.cyan(a2)} ${i}
670
+ ${import_picocolors2.default.cyan(d2)}
671
+ `;
672
+ }
673
+ } }).prompt();
674
+ var se = (r2) => {
675
+ const n = r2.active ?? "Yes", i = r2.inactive ?? "No";
676
+ return new BD({ active: n, inactive: i, initialValue: r2.initialValue ?? true, render() {
677
+ const t = `${import_picocolors2.default.gray(a2)}
678
+ ${y2(this.state)} ${r2.message}
679
+ `, s = this.value ? n : i;
680
+ switch (this.state) {
681
+ case "submit":
682
+ return `${t}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.dim(s)}`;
683
+ case "cancel":
684
+ return `${t}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
685
+ ${import_picocolors2.default.gray(a2)}`;
686
+ default:
687
+ return `${t}${import_picocolors2.default.cyan(a2)} ${this.value ? `${import_picocolors2.default.green(b2)} ${n}` : `${import_picocolors2.default.dim(E)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(E)} ${import_picocolors2.default.dim(i)}` : `${import_picocolors2.default.green(b2)} ${i}`}
688
+ ${import_picocolors2.default.cyan(d2)}
689
+ `;
690
+ }
691
+ } }).prompt();
692
+ };
693
+ var ie = (r2) => {
694
+ const n = (t, s) => {
695
+ const c2 = t.label ?? String(t.value);
696
+ return s === "active" ? `${import_picocolors2.default.green(b2)} ${c2} ${t.hint ? import_picocolors2.default.dim(`(${t.hint})`) : ""}` : s === "selected" ? `${import_picocolors2.default.dim(c2)}` : s === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(c2))}` : `${import_picocolors2.default.dim(E)} ${import_picocolors2.default.dim(c2)}`;
697
+ };
698
+ let i = 0;
699
+ return new $D({ options: r2.options, initialValue: r2.initialValue, render() {
700
+ const t = `${import_picocolors2.default.gray(a2)}
701
+ ${y2(this.state)} ${r2.message}
702
+ `;
703
+ switch (this.state) {
704
+ case "submit":
705
+ return `${t}${import_picocolors2.default.gray(a2)} ${n(this.options[this.cursor], "selected")}`;
706
+ case "cancel":
707
+ return `${t}${import_picocolors2.default.gray(a2)} ${n(this.options[this.cursor], "cancelled")}
708
+ ${import_picocolors2.default.gray(a2)}`;
709
+ default: {
710
+ const s = r2.maxItems === void 0 ? 1 / 0 : Math.max(r2.maxItems, 5);
711
+ this.cursor >= i + s - 3 ? i = Math.max(Math.min(this.cursor - s + 3, this.options.length - s), 0) : this.cursor < i + 2 && (i = Math.max(this.cursor - 2, 0));
712
+ const c2 = s < this.options.length && i > 0, l2 = s < this.options.length && i + s < this.options.length;
713
+ return `${t}${import_picocolors2.default.cyan(a2)} ${this.options.slice(i, i + s).map((u, m2, $2) => m2 === 0 && c2 ? import_picocolors2.default.dim("...") : m2 === $2.length - 1 && l2 ? import_picocolors2.default.dim("...") : n(u, m2 + i === this.cursor ? "active" : "inactive")).join(`
714
+ ${import_picocolors2.default.cyan(a2)} `)}
715
+ ${import_picocolors2.default.cyan(d2)}
716
+ `;
717
+ }
718
+ }
719
+ } }).prompt();
720
+ };
721
+ var ae = (r2) => {
722
+ const n = (i, t) => {
723
+ const s = i.label ?? String(i.value);
724
+ return t === "active" ? `${import_picocolors2.default.cyan(C)} ${s} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}` : t === "selected" ? `${import_picocolors2.default.green(w2)} ${import_picocolors2.default.dim(s)}` : t === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : t === "active-selected" ? `${import_picocolors2.default.green(w2)} ${s} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}` : t === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(M2)} ${import_picocolors2.default.dim(s)}`;
725
+ };
726
+ return new vD({ options: r2.options, initialValues: r2.initialValues, required: r2.required ?? true, cursorAt: r2.cursorAt, validate(i) {
727
+ if (this.required && i.length === 0) return `Please select at least one option.
728
+ ${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`))}`;
729
+ }, render() {
730
+ let i = `${import_picocolors2.default.gray(a2)}
731
+ ${y2(this.state)} ${r2.message}
732
+ `;
733
+ switch (this.state) {
734
+ case "submit":
735
+ return `${i}${import_picocolors2.default.gray(a2)} ${this.options.filter(({ value: t }) => this.value.includes(t)).map((t) => n(t, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
736
+ case "cancel": {
737
+ const t = this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "cancelled")).join(import_picocolors2.default.dim(", "));
738
+ return `${i}${import_picocolors2.default.gray(a2)} ${t.trim() ? `${t}
739
+ ${import_picocolors2.default.gray(a2)}` : ""}`;
740
+ }
741
+ case "error": {
742
+ const t = this.error.split(`
743
+ `).map((s, c2) => c2 === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(s)}` : ` ${s}`).join(`
744
+ `);
745
+ return i + import_picocolors2.default.yellow(a2) + " " + this.options.map((s, c2) => {
746
+ const l2 = this.value.includes(s.value), u = c2 === this.cursor;
747
+ return u && l2 ? n(s, "active-selected") : l2 ? n(s, "selected") : n(s, u ? "active" : "inactive");
748
+ }).join(`
749
+ ${import_picocolors2.default.yellow(a2)} `) + `
750
+ ` + t + `
751
+ `;
752
+ }
753
+ default:
754
+ return `${i}${import_picocolors2.default.cyan(a2)} ${this.options.map((t, s) => {
755
+ const c2 = this.value.includes(t.value), l2 = s === this.cursor;
756
+ return l2 && c2 ? n(t, "active-selected") : c2 ? n(t, "selected") : n(t, l2 ? "active" : "inactive");
757
+ }).join(`
758
+ ${import_picocolors2.default.cyan(a2)} `)}
759
+ ${import_picocolors2.default.cyan(d2)}
760
+ `;
761
+ }
762
+ } }).prompt();
763
+ };
764
+ var R2 = (r2) => r2.replace(me(), "");
765
+ var le = (r2 = "", n = "") => {
766
+ const i = `
767
+ ${r2}
768
+ `.split(`
769
+ `), t = R2(n).length, s = Math.max(i.reduce((l2, u) => (u = R2(u), u.length > l2 ? u.length : l2), 0), t) + 2, c2 = i.map((l2) => `${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.dim(l2)}${" ".repeat(s - R2(l2).length)}${import_picocolors2.default.gray(a2)}`).join(`
770
+ `);
771
+ process.stdout.write(`${import_picocolors2.default.gray(a2)}
772
+ ${import_picocolors2.default.green(S2)} ${import_picocolors2.default.reset(n)} ${import_picocolors2.default.gray(B.repeat(Math.max(s - t - 1, 1)) + Z2)}
773
+ ${c2}
774
+ ${import_picocolors2.default.gray(z2 + B.repeat(s + 2) + X2)}
775
+ `);
776
+ };
777
+ var ue = (r2 = "") => {
778
+ process.stdout.write(`${import_picocolors2.default.gray(d2)} ${import_picocolors2.default.red(r2)}
779
+
780
+ `);
781
+ };
782
+ var oe = (r2 = "") => {
783
+ process.stdout.write(`${import_picocolors2.default.gray(K2)} ${r2}
784
+ `);
785
+ };
786
+ var $e = (r2 = "") => {
787
+ process.stdout.write(`${import_picocolors2.default.gray(a2)}
788
+ ${import_picocolors2.default.gray(d2)} ${r2}
789
+
790
+ `);
791
+ };
792
+ var f2 = { message: (r2 = "", { symbol: n = import_picocolors2.default.gray(a2) } = {}) => {
793
+ const i = [`${import_picocolors2.default.gray(a2)}`];
794
+ if (r2) {
795
+ const [t, ...s] = r2.split(`
796
+ `);
797
+ i.push(`${n} ${t}`, ...s.map((c2) => `${import_picocolors2.default.gray(a2)} ${c2}`));
798
+ }
799
+ process.stdout.write(`${i.join(`
800
+ `)}
801
+ `);
802
+ }, info: (r2) => {
803
+ f2.message(r2, { symbol: import_picocolors2.default.blue(J2) });
804
+ }, success: (r2) => {
805
+ f2.message(r2, { symbol: import_picocolors2.default.green(Y2) });
806
+ }, step: (r2) => {
807
+ f2.message(r2, { symbol: import_picocolors2.default.green(S2) });
808
+ }, warn: (r2) => {
809
+ f2.message(r2, { symbol: import_picocolors2.default.yellow(Q2) });
810
+ }, warning: (r2) => {
811
+ f2.warn(r2);
812
+ }, error: (r2) => {
813
+ f2.message(r2, { symbol: import_picocolors2.default.red(ee) });
814
+ } };
815
+ var de = () => {
816
+ const r2 = _2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], n = _2 ? 80 : 120;
817
+ let i, t, s = false, c2 = "";
818
+ const l2 = (v2 = "") => {
819
+ s = true, i = OD(), c2 = v2.replace(/\.+$/, ""), process.stdout.write(`${import_picocolors2.default.gray(a2)}
820
+ `);
821
+ let g2 = 0, p = 0;
822
+ t = setInterval(() => {
823
+ const O2 = import_picocolors2.default.magenta(r2[g2]), P2 = ".".repeat(Math.floor(p)).slice(0, 3);
824
+ process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${O2} ${c2}${P2}`), g2 = g2 + 1 < r2.length ? g2 + 1 : 0, p = p < r2.length ? p + 0.125 : 0;
825
+ }, n);
826
+ }, u = (v2 = "", g2 = 0) => {
827
+ c2 = v2 ?? c2, s = false, clearInterval(t);
828
+ const p = g2 === 0 ? import_picocolors2.default.green(S2) : g2 === 1 ? import_picocolors2.default.red(I2) : import_picocolors2.default.red(x2);
829
+ process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${p} ${c2}
830
+ `), i();
831
+ }, m2 = (v2 = "") => {
832
+ c2 = v2 ?? c2;
833
+ }, $2 = (v2) => {
834
+ const g2 = v2 > 1 ? "Something went wrong" : "Canceled";
835
+ s && u(g2, v2);
836
+ };
837
+ return process.on("uncaughtExceptionMonitor", () => $2(2)), process.on("unhandledRejection", () => $2(2)), process.on("SIGINT", () => $2(1)), process.on("SIGTERM", () => $2(1)), process.on("exit", $2), { start: l2, stop: u, message: m2 };
838
+ };
839
+ function me() {
840
+ const r2 = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
841
+ return new RegExp(r2, "g");
842
+ }
843
+
844
+ // src/commands/create.ts
845
+ import path6 from "path";
846
+
847
+ // src/util/fs.ts
848
+ import fs from "fs";
849
+ import path from "path";
850
+ function ensureDir(dir, mode = 448) {
851
+ fs.mkdirSync(dir, { recursive: true, mode });
852
+ }
853
+ function fileExists(p) {
854
+ try {
855
+ fs.accessSync(p);
856
+ return true;
857
+ } catch {
858
+ return false;
859
+ }
860
+ }
861
+ function readText(p) {
862
+ return fs.readFileSync(p, "utf8");
863
+ }
864
+ function readJson(p, fallback) {
865
+ if (!fileExists(p)) return fallback;
866
+ try {
867
+ return JSON.parse(readText(p));
868
+ } catch {
869
+ throw new Error(`Failed to parse JSON at ${p} (file may be corrupted)`);
870
+ }
871
+ }
872
+ function writeFileAtomic(p, contents, mode = 384) {
873
+ const dir = path.dirname(p);
874
+ ensureDir(dir);
875
+ const tmp = path.join(dir, `.${path.basename(p)}.tmp-${process.pid}`);
876
+ fs.writeFileSync(tmp, contents, { mode });
877
+ fs.chmodSync(tmp, mode);
878
+ fs.renameSync(tmp, p);
879
+ }
880
+ function writeJson(p, value, mode = 384) {
881
+ writeFileAtomic(p, `${JSON.stringify(value, null, 2)}
882
+ `, mode);
883
+ }
884
+ function backupFile(p) {
885
+ if (!fileExists(p)) return null;
886
+ let i = 0;
887
+ let target = `${p}.codex-switch.bak`;
888
+ while (fileExists(target)) {
889
+ i += 1;
890
+ target = `${p}.codex-switch.bak.${i}`;
891
+ }
892
+ fs.copyFileSync(p, target);
893
+ return target;
894
+ }
895
+ function removeFile(p) {
896
+ try {
897
+ fs.unlinkSync(p);
898
+ } catch (err) {
899
+ if (err.code !== "ENOENT") throw err;
900
+ }
901
+ }
902
+ function removeDir(p) {
903
+ fs.rmSync(p, { recursive: true, force: true });
904
+ }
905
+
906
+ // src/installers/alias.ts
907
+ import fs2 from "fs";
908
+ import path3 from "path";
909
+
910
+ // src/core/paths.ts
911
+ import os from "os";
912
+ import path2 from "path";
913
+ function home() {
914
+ return process.env.CODEX_SWITCH_HOME && process.env.CODEX_SWITCH_HOME.trim().length > 0 ? path2.resolve(process.env.CODEX_SWITCH_HOME) : os.homedir();
915
+ }
916
+ function rootDir() {
917
+ return path2.join(home(), ".codex-switch");
918
+ }
919
+ function registryPath() {
920
+ return path2.join(rootDir(), "profiles.json");
921
+ }
922
+ function codexHomeFor(alias) {
923
+ return path2.join(rootDir(), alias);
924
+ }
925
+ function configPathFor(alias) {
926
+ return path2.join(codexHomeFor(alias), "config.toml");
927
+ }
928
+ function secretEnvPathFor(alias) {
929
+ return path2.join(codexHomeFor(alias), ".env");
930
+ }
931
+ function internalLauncherPathFor(alias) {
932
+ return path2.join(codexHomeFor(alias), "launcher");
933
+ }
934
+ function defaultBinDir() {
935
+ return path2.join(home(), ".local", "bin");
936
+ }
937
+ function expandHome(p) {
938
+ if (p === "~") return home();
939
+ if (p.startsWith("~/")) return path2.join(home(), p.slice(2));
940
+ return path2.resolve(p);
941
+ }
942
+ function tildify(p) {
943
+ const h2 = home();
944
+ return p.startsWith(h2) ? `~${p.slice(h2.length)}` : p;
945
+ }
946
+
947
+ // src/installers/alias.ts
948
+ function renderShellPath(p) {
949
+ const h2 = home();
950
+ if (p === h2) return '"$HOME"';
951
+ if (p.startsWith(h2 + path3.sep)) {
952
+ return `"$HOME/${p.slice(h2.length + 1)}"`;
953
+ }
954
+ return `"${p}"`;
955
+ }
956
+ function aliasLine(alias, launcherPath, shell) {
957
+ const launcher = renderShellPath(launcherPath);
958
+ if (shell === "fish") {
959
+ return `alias ${alias} ${launcher}`;
960
+ }
961
+ return `alias ${alias}='${launcher}'`;
962
+ }
963
+ function completionLine(alias, shell) {
964
+ switch (shell) {
965
+ case "zsh":
966
+ return `(( $+functions[compdef] )) && compdef ${alias}=codex 2>/dev/null`;
967
+ case "bash":
968
+ return `type _codex &>/dev/null && complete -F _codex ${alias}`;
969
+ case "fish":
970
+ return `complete -c ${alias} -w codex`;
971
+ default:
972
+ return null;
973
+ }
974
+ }
975
+ var markerStart = (alias) => `# >>> codex-switch: ${alias} >>>`;
976
+ var markerEnd = (alias) => `# <<< codex-switch: ${alias} <<<`;
977
+ function escapeRe(s) {
978
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
979
+ }
980
+ function blockRegex(alias) {
981
+ const start = escapeRe(markerStart(alias));
982
+ const end = escapeRe(markerEnd(alias));
983
+ return new RegExp(`${start}[\\s\\S]*?${end}\\n?`, "g");
984
+ }
985
+ function buildBlock(alias, launcherPath, shell) {
986
+ const completion = completionLine(alias, shell);
987
+ const lines = [markerStart(alias), aliasLine(alias, launcherPath, shell)];
988
+ if (completion) lines.push(completion);
989
+ lines.push(markerEnd(alias));
990
+ return `${lines.join("\n")}
991
+ `;
992
+ }
993
+ function rcMode(rcPath) {
994
+ try {
995
+ return fs2.statSync(rcPath).mode & 511;
996
+ } catch {
997
+ return 420;
998
+ }
999
+ }
1000
+ function writeRc(rcPath, contents) {
1001
+ const dir = path3.dirname(rcPath);
1002
+ fs2.mkdirSync(dir, { recursive: true });
1003
+ const mode = rcMode(rcPath);
1004
+ const tmp = path3.join(dir, `.${path3.basename(rcPath)}.tmp-${process.pid}`);
1005
+ fs2.writeFileSync(tmp, contents, { mode });
1006
+ fs2.chmodSync(tmp, mode);
1007
+ fs2.renameSync(tmp, rcPath);
1008
+ }
1009
+ function hasAlias(rcPath, alias) {
1010
+ if (!fileExists(rcPath)) return false;
1011
+ return blockRegex(alias).test(readText(rcPath));
1012
+ }
1013
+ function injectAlias(rcPath, alias, launcherPath, shell) {
1014
+ const block = buildBlock(alias, launcherPath, shell);
1015
+ const exists = fileExists(rcPath);
1016
+ const original = exists ? readText(rcPath) : "";
1017
+ const re2 = blockRegex(alias);
1018
+ const hadBlock = re2.test(original);
1019
+ let next;
1020
+ if (hadBlock) {
1021
+ next = original.replace(blockRegex(alias), block);
1022
+ } else {
1023
+ const sep = original.length === 0 || original.endsWith("\n") ? "" : "\n";
1024
+ const lead = original.length === 0 ? "" : "\n";
1025
+ next = `${original}${sep}${lead}${block}`;
1026
+ }
1027
+ if (next === original) {
1028
+ return { rcPath, backup: null, action: "unchanged" };
1029
+ }
1030
+ const backup = backupFile(rcPath);
1031
+ writeRc(rcPath, next);
1032
+ return { rcPath, backup, action: hadBlock ? "updated" : "created" };
1033
+ }
1034
+ function removeAlias(rcPath, alias) {
1035
+ if (!fileExists(rcPath)) return { removed: false, backup: null };
1036
+ const original = readText(rcPath);
1037
+ if (!blockRegex(alias).test(original)) return { removed: false, backup: null };
1038
+ let next = original.replace(blockRegex(alias), "");
1039
+ next = next.replace(/\n{3,}/g, "\n\n");
1040
+ const backup = backupFile(rcPath);
1041
+ writeRc(rcPath, next);
1042
+ return { removed: true, backup };
1043
+ }
1044
+
1045
+ // src/installers/script.ts
1046
+ import fs3 from "fs";
1047
+ import path4 from "path";
1048
+ var SCRIPT_MARKER = "# codex-switch launcher:";
1049
+ var INTERNAL_SCRIPT_MARKER = "# codex-switch internal launcher:";
1050
+ function buildInternalLauncher(alias, codexHome, secretEnvPath) {
1051
+ return [
1052
+ "#!/bin/sh",
1053
+ `${INTERNAL_SCRIPT_MARKER} ${alias}`,
1054
+ secretEnvPath ? `if [ -f ${renderShellPath(secretEnvPath)} ]; then` : "",
1055
+ secretEnvPath ? ` . ${renderShellPath(secretEnvPath)}` : "",
1056
+ secretEnvPath ? "fi" : "",
1057
+ `export CODEX_HOME=${renderShellPath(codexHome)}`,
1058
+ 'exec codex "$@"',
1059
+ ""
1060
+ ].filter((line2) => line2.length > 0).join("\n");
1061
+ }
1062
+ function buildScript(alias, launcherPath) {
1063
+ return [
1064
+ "#!/bin/sh",
1065
+ `${SCRIPT_MARKER} ${alias}`,
1066
+ `exec ${renderShellPath(launcherPath)} "$@"`,
1067
+ ""
1068
+ ].join("\n");
1069
+ }
1070
+ function isOurScript(scriptPath) {
1071
+ if (!fileExists(scriptPath)) return false;
1072
+ try {
1073
+ return readText(scriptPath).includes(SCRIPT_MARKER);
1074
+ } catch {
1075
+ return false;
1076
+ }
1077
+ }
1078
+ function writeInternalLauncher(launcherPath, alias, codexHome, secretEnvPath) {
1079
+ fs3.mkdirSync(path4.dirname(launcherPath), { recursive: true });
1080
+ const existed = fileExists(launcherPath);
1081
+ const tmp = path4.join(
1082
+ path4.dirname(launcherPath),
1083
+ `.${path4.basename(launcherPath)}.tmp-${process.pid}`
1084
+ );
1085
+ fs3.writeFileSync(tmp, buildInternalLauncher(alias, codexHome, secretEnvPath), { mode: 448 });
1086
+ fs3.chmodSync(tmp, 448);
1087
+ fs3.renameSync(tmp, launcherPath);
1088
+ return { scriptPath: launcherPath, action: existed ? "updated" : "created" };
1089
+ }
1090
+ function writeWrapperScript(scriptPath, alias, launcherPath) {
1091
+ const existed = fileExists(scriptPath);
1092
+ if (existed && !isOurScript(scriptPath)) {
1093
+ throw new Error(
1094
+ `Refusing to overwrite ${scriptPath}: it exists and is not a codex-switch script.`
1095
+ );
1096
+ }
1097
+ fs3.mkdirSync(path4.dirname(scriptPath), { recursive: true });
1098
+ const tmp = path4.join(
1099
+ path4.dirname(scriptPath),
1100
+ `.${path4.basename(scriptPath)}.tmp-${process.pid}`
1101
+ );
1102
+ fs3.writeFileSync(tmp, buildScript(alias, launcherPath), { mode: 493 });
1103
+ fs3.chmodSync(tmp, 493);
1104
+ fs3.renameSync(tmp, scriptPath);
1105
+ return { scriptPath, action: existed ? "updated" : "created" };
1106
+ }
1107
+ function removeWrapperScript(scriptPath) {
1108
+ if (!isOurScript(scriptPath)) return false;
1109
+ fs3.unlinkSync(scriptPath);
1110
+ return true;
1111
+ }
1112
+
1113
+ // src/core/profile.ts
1114
+ function emptyRegistry() {
1115
+ return { version: 1, profiles: [] };
1116
+ }
1117
+
1118
+ // src/core/registry.ts
1119
+ function loadRegistry() {
1120
+ const reg = readJson(registryPath(), emptyRegistry());
1121
+ if (!reg.profiles) reg.profiles = [];
1122
+ if (!reg.version) reg.version = 1;
1123
+ return reg;
1124
+ }
1125
+ function saveRegistry(reg) {
1126
+ writeJson(registryPath(), reg, 384);
1127
+ }
1128
+ function getProfile(alias) {
1129
+ return loadRegistry().profiles.find((p) => p.alias === alias);
1130
+ }
1131
+ function listProfiles() {
1132
+ return loadRegistry().profiles.slice().sort((a3, b3) => a3.alias.localeCompare(b3.alias));
1133
+ }
1134
+ function upsertProfile(profile) {
1135
+ const reg = loadRegistry();
1136
+ const idx = reg.profiles.findIndex((p) => p.alias === profile.alias);
1137
+ if (idx >= 0) reg.profiles[idx] = profile;
1138
+ else reg.profiles.push(profile);
1139
+ saveRegistry(reg);
1140
+ }
1141
+ function removeProfile(alias) {
1142
+ const reg = loadRegistry();
1143
+ const idx = reg.profiles.findIndex((p) => p.alias === alias);
1144
+ if (idx < 0) return void 0;
1145
+ const [removed] = reg.profiles.splice(idx, 1);
1146
+ saveRegistry(reg);
1147
+ return removed;
1148
+ }
1149
+
1150
+ // src/core/settings.ts
1151
+ function sanitizeId(value) {
1152
+ const id = value.replace(/[^A-Za-z0-9_]/g, "_").replace(/^_+|_+$/g, "");
1153
+ const fallback = id.length > 0 ? id : "profile";
1154
+ return /^[A-Za-z_]/.test(fallback) ? fallback : `profile_${fallback}`;
1155
+ }
1156
+ function providerIdForAlias(alias) {
1157
+ return sanitizeId(alias).toLowerCase();
1158
+ }
1159
+ function envVarForAlias(alias) {
1160
+ return `CODEX_SWITCH_${sanitizeId(alias).toUpperCase()}_API_KEY`;
1161
+ }
1162
+ function tomlString(value) {
1163
+ return JSON.stringify(value);
1164
+ }
1165
+ function tomlKeyPath(key) {
1166
+ return key.split(".").map((part) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(part) ? part : tomlString(part)).join(".");
1167
+ }
1168
+ function tomlInlineTable(value) {
1169
+ return `{ ${Object.entries(value).map(([key, v2]) => `${tomlString(key)} = ${tomlString(v2)}`).join(", ")} }`;
1170
+ }
1171
+ function shellSingleQuote(value) {
1172
+ return `'${value.replace(/'/g, `'\\''`)}'`;
1173
+ }
1174
+ function buildSecretEnv(spec) {
1175
+ const authMethod = spec.authMethod ?? "envKey";
1176
+ if (!spec.custom || authMethod === "none" || !spec.secret || !spec.envVar) return null;
1177
+ const value = authMethod === "bearerHeader" && !/^Bearer\s+/i.test(spec.secret) ? `Bearer ${spec.secret}` : spec.secret;
1178
+ return [
1179
+ `# Generated by codex-switch.`,
1180
+ `export ${spec.envVar}=${shellSingleQuote(value)}`,
1181
+ ""
1182
+ ].join("\n");
1183
+ }
1184
+ function buildConfigToml(spec) {
1185
+ const lines = [
1186
+ "# Generated by codex-switch.",
1187
+ "# This file is the CODEX_HOME-local configuration for this launcher profile.",
1188
+ 'cli_auth_credentials_store = "file"'
1189
+ ];
1190
+ if (spec.model) lines.push(`model = ${tomlString(spec.model)}`);
1191
+ if (spec.approvalPolicy) lines.push(`approval_policy = ${tomlString(spec.approvalPolicy)}`);
1192
+ if (spec.approvalsReviewer) {
1193
+ lines.push(`approvals_reviewer = ${tomlString(spec.approvalsReviewer)}`);
1194
+ }
1195
+ if (spec.sandboxMode) lines.push(`sandbox_mode = ${tomlString(spec.sandboxMode)}`);
1196
+ if (spec.custom) {
1197
+ if (!spec.baseUrl) throw new Error("Custom provider profiles require a base URL.");
1198
+ const authMethod = spec.authMethod ?? "envKey";
1199
+ const providerId = spec.providerId ?? providerIdForAlias("profile");
1200
+ lines.push(`model_provider = ${tomlString(providerId)}`);
1201
+ lines.push("");
1202
+ lines.push(`[model_providers.${tomlKeyPath(providerId)}]`);
1203
+ lines.push(`name = ${tomlString(providerId)}`);
1204
+ lines.push(`base_url = ${tomlString(spec.baseUrl)}`);
1205
+ lines.push(`wire_api = ${tomlString(spec.wireApi ?? "chat")}`);
1206
+ if (authMethod === "envKey") {
1207
+ if (!spec.envVar) throw new Error("env_key authentication requires an env var name.");
1208
+ lines.push(`env_key = ${tomlString(spec.envVar)}`);
1209
+ } else if (authMethod === "bearerHeader") {
1210
+ if (!spec.envVar) throw new Error("Bearer header authentication requires an env var name.");
1211
+ lines.push(`env_http_headers = ${tomlInlineTable({ Authorization: spec.envVar })}`);
1212
+ } else if (authMethod === "xApiKeyHeader") {
1213
+ if (!spec.envVar) throw new Error("X-Api-Key authentication requires an env var name.");
1214
+ lines.push(`env_http_headers = ${tomlInlineTable({ "X-Api-Key": spec.envVar })}`);
1215
+ }
1216
+ }
1217
+ return `${lines.join("\n")}
1218
+ `;
1219
+ }
1220
+ function writeProfileSettings(alias, spec) {
1221
+ const authMethod = spec.custom ? spec.authMethod ?? "envKey" : spec.authMethod;
1222
+ const providerId = spec.custom ? spec.providerId ?? providerIdForAlias(alias) : void 0;
1223
+ const envVar = spec.custom && authMethod !== "none" ? spec.envVar ?? envVarForAlias(alias) : void 0;
1224
+ const resolved = { ...spec, authMethod, providerId, envVar };
1225
+ const configPath = configPathFor(alias);
1226
+ writeFileAtomic(configPath, buildConfigToml(resolved), 384);
1227
+ const secretEnv = buildSecretEnv(resolved);
1228
+ const secretEnvPath = secretEnvPathFor(alias);
1229
+ if (secretEnv) {
1230
+ writeFileAtomic(secretEnvPath, secretEnv, 384);
1231
+ } else {
1232
+ removeFile(secretEnvPath);
1233
+ }
1234
+ return {
1235
+ configPath,
1236
+ secretEnvPath: secretEnv ? secretEnvPath : void 0,
1237
+ providerId,
1238
+ envVar
1239
+ };
1240
+ }
1241
+
1242
+ // src/core/apply.ts
1243
+ function applyProfile(spec) {
1244
+ const codexHome = codexHomeFor(spec.alias);
1245
+ ensureDir(codexHome, 448);
1246
+ const authMethod = spec.custom ? spec.authMethod ?? "envKey" : spec.authMethod;
1247
+ const wireApi = spec.custom ? spec.wireApi ?? "chat" : void 0;
1248
+ const profileFiles = writeProfileSettings(spec.alias, {
1249
+ custom: spec.custom,
1250
+ baseUrl: spec.baseUrl,
1251
+ authMethod,
1252
+ wireApi,
1253
+ secret: spec.secret,
1254
+ model: spec.model,
1255
+ approvalPolicy: spec.approvalPolicy,
1256
+ sandboxMode: spec.sandboxMode,
1257
+ approvalsReviewer: spec.approvalsReviewer
1258
+ });
1259
+ const launcherPath = internalLauncherPathFor(spec.alias);
1260
+ const internalLauncherResult = writeInternalLauncher(
1261
+ launcherPath,
1262
+ spec.alias,
1263
+ codexHome,
1264
+ profileFiles.secretEnvPath
1265
+ );
1266
+ let aliasResult;
1267
+ if (spec.launchers.includes("alias")) {
1268
+ aliasResult = injectAlias(spec.shell.rcPath, spec.alias, launcherPath, spec.shell.name);
1269
+ }
1270
+ let scriptResult;
1271
+ if (spec.launchers.includes("script") && spec.scriptPath) {
1272
+ scriptResult = writeWrapperScript(spec.scriptPath, spec.alias, launcherPath);
1273
+ }
1274
+ const profile = {
1275
+ alias: spec.alias,
1276
+ codexHome,
1277
+ configPath: profileFiles.configPath,
1278
+ launcherPath,
1279
+ secretEnvPath: profileFiles.secretEnvPath,
1280
+ custom: spec.custom,
1281
+ baseUrl: spec.custom ? spec.baseUrl : void 0,
1282
+ authMethod: spec.custom ? authMethod : void 0,
1283
+ wireApi,
1284
+ providerId: profileFiles.providerId,
1285
+ envVar: profileFiles.envVar,
1286
+ model: spec.model,
1287
+ approvalPolicy: spec.approvalPolicy,
1288
+ sandboxMode: spec.sandboxMode,
1289
+ approvalsReviewer: spec.approvalsReviewer,
1290
+ launchers: spec.launchers,
1291
+ scriptPath: spec.scriptPath,
1292
+ shellRc: spec.launchers.includes("alias") ? spec.shell.rcPath : void 0,
1293
+ createdAt: spec.createdAt
1294
+ };
1295
+ upsertProfile(profile);
1296
+ return {
1297
+ profile,
1298
+ configPath: profileFiles.configPath,
1299
+ secretEnvPath: profileFiles.secretEnvPath,
1300
+ internalLauncherResult,
1301
+ aliasResult,
1302
+ scriptResult
1303
+ };
1304
+ }
1305
+
1306
+ // src/installers/shell.ts
1307
+ import { execFileSync } from "child_process";
1308
+ import path5 from "path";
1309
+ function detectShell() {
1310
+ const shellPath = process.env.SHELL ?? "";
1311
+ const base = path5.basename(shellPath);
1312
+ const h2 = home();
1313
+ if (base === "zsh") {
1314
+ const zdot = process.env.ZDOTDIR && process.env.ZDOTDIR.trim() ? process.env.ZDOTDIR : h2;
1315
+ return { name: "zsh", rcPath: path5.join(zdot, ".zshrc") };
1316
+ }
1317
+ if (base === "bash") {
1318
+ const bashrc = path5.join(h2, ".bashrc");
1319
+ const bashProfile = path5.join(h2, ".bash_profile");
1320
+ if (!fileExists(bashrc) && fileExists(bashProfile)) {
1321
+ return { name: "bash", rcPath: bashProfile };
1322
+ }
1323
+ return { name: "bash", rcPath: bashrc };
1324
+ }
1325
+ if (base === "fish") {
1326
+ return { name: "fish", rcPath: path5.join(h2, ".config", "fish", "config.fish") };
1327
+ }
1328
+ return { name: "unknown", rcPath: path5.join(h2, ".profile") };
1329
+ }
1330
+ function codexInstalled() {
1331
+ return commandExists("codex");
1332
+ }
1333
+ function commandExists(name) {
1334
+ try {
1335
+ execFileSync("/bin/sh", ["-c", 'command -v "$0"', name], { stdio: "ignore" });
1336
+ return true;
1337
+ } catch {
1338
+ return false;
1339
+ }
1340
+ }
1341
+ function isOnPath(dir) {
1342
+ const resolved = path5.resolve(dir);
1343
+ return (process.env.PATH ?? "").split(path5.delimiter).some((entry) => entry && path5.resolve(entry) === resolved);
1344
+ }
1345
+
1346
+ // src/util/log.ts
1347
+ var useColor = process.stdout.isTTY && !process.env.NO_COLOR;
1348
+ var wrap = (code) => (s) => useColor ? `\x1B[${code}m${s}\x1B[0m` : s;
1349
+ var color = {
1350
+ dim: wrap("2"),
1351
+ bold: wrap("1"),
1352
+ red: wrap("31"),
1353
+ green: wrap("32"),
1354
+ yellow: wrap("33"),
1355
+ cyan: wrap("36")
1356
+ };
1357
+ function info(msg) {
1358
+ process.stdout.write(`${msg}
1359
+ `);
1360
+ }
1361
+ function error(msg) {
1362
+ process.stderr.write(`${color.red("\u2716")} ${msg}
1363
+ `);
1364
+ }
1365
+
1366
+ // src/util/validate.ts
1367
+ var ALIAS_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
1368
+ var RESERVED = /* @__PURE__ */ new Set([
1369
+ "cd",
1370
+ "ls",
1371
+ "rm",
1372
+ "mv",
1373
+ "cp",
1374
+ "echo",
1375
+ "export",
1376
+ "alias",
1377
+ "unalias",
1378
+ "source",
1379
+ "exec",
1380
+ "sudo",
1381
+ "kill",
1382
+ "codex"
1383
+ ]);
1384
+ function validateAlias(value) {
1385
+ const v2 = value.trim();
1386
+ if (!v2) return "Alias cannot be empty.";
1387
+ if (v2.length > 64) return "Alias is too long (max 64 characters).";
1388
+ if (!ALIAS_RE.test(v2)) {
1389
+ return 'Alias may contain only letters, digits, "-", "_", "." and must start with a letter or digit.';
1390
+ }
1391
+ if (RESERVED.has(v2)) return `"${v2}" is a reserved command name \u2014 choose another alias.`;
1392
+ return null;
1393
+ }
1394
+ function validateBaseUrl(value) {
1395
+ const v2 = value.trim();
1396
+ if (!v2) return "Base URL cannot be empty.";
1397
+ let url;
1398
+ try {
1399
+ url = new URL(v2);
1400
+ } catch {
1401
+ return "Base URL must be a valid URL (e.g. https://openrouter.ai/api/v1).";
1402
+ }
1403
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
1404
+ return "Base URL must use http or https.";
1405
+ }
1406
+ return null;
1407
+ }
1408
+ function validateRequired(label) {
1409
+ return (value) => value.trim().length === 0 ? `${label} cannot be empty.` : null;
1410
+ }
1411
+
1412
+ // src/commands/create.ts
1413
+ function ensure(value) {
1414
+ if (lD(value)) {
1415
+ ue("Cancelled. Nothing was changed.");
1416
+ process.exit(130);
1417
+ }
1418
+ return value;
1419
+ }
1420
+ var PERMISSION_SETTINGS = {
1421
+ codexDefault: {},
1422
+ readOnly: {
1423
+ approvalPolicy: "on-request",
1424
+ sandboxMode: "read-only",
1425
+ approvalsReviewer: "user"
1426
+ },
1427
+ auto: {
1428
+ approvalPolicy: "on-request",
1429
+ sandboxMode: "workspace-write",
1430
+ approvalsReviewer: "user"
1431
+ },
1432
+ autoReview: {
1433
+ approvalPolicy: "on-request",
1434
+ sandboxMode: "workspace-write",
1435
+ approvalsReviewer: "auto_review"
1436
+ },
1437
+ noPrompts: {
1438
+ approvalPolicy: "never",
1439
+ sandboxMode: "workspace-write"
1440
+ }
1441
+ };
1442
+ function permissionSummary(settings) {
1443
+ const parts = [
1444
+ settings.sandboxMode ? `sandbox=${settings.sandboxMode}` : void 0,
1445
+ settings.approvalPolicy ? `approval=${settings.approvalPolicy}` : void 0,
1446
+ settings.approvalsReviewer ? `reviewer=${settings.approvalsReviewer}` : void 0
1447
+ ].filter((part) => Boolean(part));
1448
+ return parts.length > 0 ? parts.join(", ") : "Codex default";
1449
+ }
1450
+ async function runCreate() {
1451
+ oe(color.bold("codex-switch \u2014 new Codex profile"));
1452
+ if (!codexInstalled()) {
1453
+ f2.warn(
1454
+ "The `codex` command was not found on PATH. The profile will still be created, but install Codex before launching it."
1455
+ );
1456
+ }
1457
+ const alias = ensure(
1458
+ await te({
1459
+ message: "Launch alias (the command you will type)",
1460
+ placeholder: "codex-o",
1461
+ validate: (v2) => validateAlias(v2 ?? "") ?? void 0
1462
+ })
1463
+ ).trim();
1464
+ const existing = getProfile(alias);
1465
+ if (existing) {
1466
+ const ov = ensure(
1467
+ await se({
1468
+ message: `Profile "${alias}" already exists. Update it?`,
1469
+ initialValue: true
1470
+ })
1471
+ );
1472
+ if (!ov) {
1473
+ ue("Aborted.");
1474
+ return 0;
1475
+ }
1476
+ } else if (commandExists(alias)) {
1477
+ f2.warn(
1478
+ `"${alias}" already resolves to an existing command. Your alias/script will shadow it in new shells.`
1479
+ );
1480
+ }
1481
+ const custom = ensure(
1482
+ await se({
1483
+ message: "Use a custom OpenAI-compatible provider? (No = standard Codex account/login)",
1484
+ initialValue: false
1485
+ })
1486
+ );
1487
+ let baseUrl;
1488
+ let authMethod;
1489
+ let wireApi;
1490
+ let secret;
1491
+ let model;
1492
+ if (custom) {
1493
+ authMethod = ensure(
1494
+ await ie({
1495
+ message: "Authentication method",
1496
+ initialValue: "envKey",
1497
+ options: [
1498
+ { value: "envKey", label: "env_key", hint: "provider API key env var (OpenRouter, \u2026)" },
1499
+ { value: "bearerHeader", label: "Authorization: Bearer", hint: "custom header" },
1500
+ { value: "xApiKeyHeader", label: "X-Api-Key", hint: "custom header" },
1501
+ { value: "none", label: "No auth", hint: "local or unauthenticated proxy" }
1502
+ ]
1503
+ })
1504
+ );
1505
+ baseUrl = ensure(
1506
+ await te({
1507
+ message: "Provider base URL",
1508
+ placeholder: "https://openrouter.ai/api/v1",
1509
+ initialValue: "https://openrouter.ai/api/v1",
1510
+ validate: (v2) => validateBaseUrl(v2 ?? "") ?? void 0
1511
+ })
1512
+ ).trim();
1513
+ wireApi = ensure(
1514
+ await ie({
1515
+ message: "Wire protocol",
1516
+ initialValue: "chat",
1517
+ options: [
1518
+ { value: "chat", label: "Chat Completions", hint: "OpenRouter, Groq, Together, \u2026" },
1519
+ { value: "responses", label: "Responses", hint: "OpenAI-native / Responses gateways" }
1520
+ ]
1521
+ })
1522
+ );
1523
+ if (authMethod !== "none") {
1524
+ secret = ensure(
1525
+ await re({
1526
+ message: authMethod === "bearerHeader" ? "Bearer token" : "API key / token",
1527
+ validate: (v2) => validateRequired("Value")(v2 ?? "") ?? void 0
1528
+ })
1529
+ );
1530
+ }
1531
+ const m2 = ensure(
1532
+ await te({
1533
+ message: "Default model (optional, Enter to skip)",
1534
+ placeholder: "anthropic/claude-sonnet-4.5"
1535
+ })
1536
+ ).trim();
1537
+ model = m2 || void 0;
1538
+ } else {
1539
+ const fixModel = ensure(
1540
+ await se({
1541
+ message: "Pin a default model for this profile?",
1542
+ initialValue: false
1543
+ })
1544
+ );
1545
+ if (fixModel) {
1546
+ const m2 = ensure(
1547
+ await te({
1548
+ message: "Default model",
1549
+ placeholder: "gpt-5.5"
1550
+ })
1551
+ ).trim();
1552
+ model = m2 || void 0;
1553
+ }
1554
+ }
1555
+ const permissionPreset = ensure(
1556
+ await ie({
1557
+ message: "Codex permissions / auto-review preset",
1558
+ initialValue: "codexDefault",
1559
+ options: [
1560
+ {
1561
+ value: "codexDefault",
1562
+ label: "Codex default",
1563
+ hint: "do not write sandbox or approval settings"
1564
+ },
1565
+ {
1566
+ value: "autoReview",
1567
+ label: "Auto-review",
1568
+ hint: "workspace-write + on-request + approvals_reviewer=auto_review"
1569
+ },
1570
+ {
1571
+ value: "auto",
1572
+ label: "Auto (manual approval)",
1573
+ hint: "workspace-write + on-request + approvals_reviewer=user"
1574
+ },
1575
+ {
1576
+ value: "readOnly",
1577
+ label: "Read-only",
1578
+ hint: "read-only + on-request approvals"
1579
+ },
1580
+ {
1581
+ value: "noPrompts",
1582
+ label: "No approval prompts",
1583
+ hint: "workspace-write + approval_policy=never"
1584
+ }
1585
+ ]
1586
+ })
1587
+ );
1588
+ const permissionSettings = PERMISSION_SETTINGS[permissionPreset];
1589
+ if (permissionPreset === "noPrompts") {
1590
+ f2.warn(
1591
+ "No approval prompts still keeps the workspace-write sandbox. It does not grant full filesystem or network access."
1592
+ );
1593
+ }
1594
+ const shell = detectShell();
1595
+ const launchers = ensure(
1596
+ await ae({
1597
+ message: "How do you want to launch this profile?",
1598
+ required: true,
1599
+ initialValues: ["alias"],
1600
+ options: [
1601
+ { value: "alias", label: `Shell alias`, hint: `${shell.name} -> ${tildify(shell.rcPath)}` },
1602
+ { value: "script", label: "Wrapper script", hint: "an executable on your PATH" }
1603
+ ]
1604
+ })
1605
+ );
1606
+ let scriptPath;
1607
+ if (launchers.includes("script")) {
1608
+ const binDir = ensure(
1609
+ await te({
1610
+ message: "Install the wrapper script into which directory?",
1611
+ placeholder: tildify(defaultBinDir()),
1612
+ initialValue: tildify(defaultBinDir()),
1613
+ validate: (v2) => validateRequired("Directory")(v2 ?? "") ?? void 0
1614
+ })
1615
+ ).trim();
1616
+ const resolvedBin = expandHome(binDir);
1617
+ scriptPath = path6.join(resolvedBin, alias);
1618
+ if (!isOnPath(resolvedBin)) {
1619
+ f2.warn(
1620
+ `${tildify(resolvedBin)} is not on your PATH. Add it (e.g. export PATH="${binDir}:$PATH") or the "${alias}" command won't be found.`
1621
+ );
1622
+ }
1623
+ }
1624
+ if (launchers.includes("alias") && shell.name === "unknown") {
1625
+ f2.warn(
1626
+ `Could not detect a supported shell (SHELL=${process.env.SHELL ?? "unset"}). The alias will be written to ${tildify(shell.rcPath)} using POSIX syntax.`
1627
+ );
1628
+ }
1629
+ const codexHome = codexHomeFor(alias);
1630
+ const summaryLines = [
1631
+ `${color.dim("alias")} ${alias}`,
1632
+ `${color.dim("type")} ${custom ? "custom provider" : "standard Codex account"}`,
1633
+ ...custom ? [
1634
+ `${color.dim("baseUrl")} ${baseUrl}`,
1635
+ `${color.dim("wireApi")} ${wireApi}`,
1636
+ `${color.dim("auth")} ${authMethod}`,
1637
+ ...authMethod !== "none" ? [`${color.dim("secret")} ${"\u2022".repeat(8)} (stored in .env, 0600)`] : []
1638
+ ] : [],
1639
+ ...model ? [`${color.dim("model")} ${model}`] : [],
1640
+ `${color.dim("permissions")} ${permissionSummary(permissionSettings)}`,
1641
+ `${color.dim("codexHome")} ${tildify(codexHome)}`,
1642
+ `${color.dim("launchers")} ${launchers.join(", ")}`,
1643
+ ...scriptPath ? [`${color.dim("script")} ${tildify(scriptPath)}`] : [],
1644
+ ...launchers.includes("alias") ? [`${color.dim("rc")} ${tildify(shell.rcPath)}`] : []
1645
+ ];
1646
+ le(summaryLines.join("\n"), "Summary");
1647
+ const go = ensure(await se({ message: "Apply this configuration?", initialValue: true }));
1648
+ if (!go) {
1649
+ ue("Aborted. Nothing was changed.");
1650
+ return 0;
1651
+ }
1652
+ const s = de();
1653
+ s.start("Writing profile");
1654
+ applyProfile({
1655
+ alias,
1656
+ custom,
1657
+ baseUrl,
1658
+ authMethod,
1659
+ wireApi,
1660
+ secret,
1661
+ model,
1662
+ approvalPolicy: permissionSettings.approvalPolicy,
1663
+ sandboxMode: permissionSettings.sandboxMode,
1664
+ approvalsReviewer: permissionSettings.approvalsReviewer,
1665
+ launchers,
1666
+ scriptPath,
1667
+ shell,
1668
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
1669
+ });
1670
+ s.stop("Profile written");
1671
+ const next = [];
1672
+ if (launchers.includes("alias")) {
1673
+ next.push(`Open a new shell, or run: ${color.cyan(`source ${tildify(shell.rcPath)}`)}`);
1674
+ }
1675
+ next.push(`Launch with: ${color.cyan(alias)}`);
1676
+ if (!custom) {
1677
+ next.push(`Run ${color.cyan(`${alias} login`)} if you want to sign in before opening Codex.`);
1678
+ }
1679
+ le(next.join("\n"), "Next steps");
1680
+ $e(color.green(`Profile "${alias}" is ready.`));
1681
+ return 0;
1682
+ }
1683
+
1684
+ // src/commands/doctor.ts
1685
+ import fs4 from "fs";
1686
+ import path7 from "path";
1687
+ var OK = color.green("\u2714");
1688
+ var BAD = color.red("\u2716");
1689
+ var WARN = color.yellow("!");
1690
+ function line(status, label, detail = "") {
1691
+ info(` ${status} ${label}${detail ? color.dim(` ${detail}`) : ""}`);
1692
+ }
1693
+ function modeOf(file) {
1694
+ try {
1695
+ return fs4.statSync(file).mode & 511;
1696
+ } catch {
1697
+ return null;
1698
+ }
1699
+ }
1700
+ function runDoctor() {
1701
+ let errors = 0;
1702
+ info(color.bold("Environment"));
1703
+ if (codexInstalled()) {
1704
+ line(OK, "codex is on PATH");
1705
+ } else {
1706
+ line(BAD, "codex not found on PATH", "install Codex first");
1707
+ errors += 1;
1708
+ }
1709
+ line(OK, "profiles root", tildify(rootDir()));
1710
+ const profiles = listProfiles();
1711
+ info("");
1712
+ info(color.bold(`Profiles (${profiles.length})`));
1713
+ if (profiles.length === 0) {
1714
+ info(color.dim(" none yet - run `codex-switch create`"));
1715
+ }
1716
+ for (const p of profiles) {
1717
+ info(color.bold(` ${p.alias}`));
1718
+ if (fs4.existsSync(p.codexHome)) line(OK, "CODEX_HOME", tildify(p.codexHome));
1719
+ else {
1720
+ line(BAD, "CODEX_HOME missing", tildify(p.codexHome));
1721
+ errors += 1;
1722
+ }
1723
+ if (fs4.existsSync(p.configPath)) {
1724
+ const mode = modeOf(p.configPath);
1725
+ if (mode === 384) line(OK, "config.toml", "0600");
1726
+ else line(WARN, "config.toml perms not 0600", mode === null ? "" : `0${mode.toString(8)}`);
1727
+ } else {
1728
+ line(BAD, "config.toml missing", tildify(p.configPath));
1729
+ errors += 1;
1730
+ }
1731
+ if (p.secretEnvPath) {
1732
+ const mode = modeOf(p.secretEnvPath);
1733
+ if (mode === 384) line(OK, ".env", "0600");
1734
+ else if (mode === null) {
1735
+ line(BAD, ".env missing", tildify(p.secretEnvPath));
1736
+ errors += 1;
1737
+ } else {
1738
+ line(WARN, ".env perms not 0600", `0${mode.toString(8)}`);
1739
+ }
1740
+ }
1741
+ const launcherMode = modeOf(p.launcherPath);
1742
+ if (launcherMode === 448) line(OK, "internal launcher", tildify(p.launcherPath));
1743
+ else if (launcherMode === null) {
1744
+ line(BAD, "internal launcher missing", tildify(p.launcherPath));
1745
+ errors += 1;
1746
+ } else {
1747
+ line(WARN, "internal launcher perms not 0700", `0${launcherMode.toString(8)}`);
1748
+ }
1749
+ if (p.launchers.includes("alias")) {
1750
+ if (p.shellRc && hasAlias(p.shellRc, p.alias)) {
1751
+ line(OK, "alias installed", tildify(p.shellRc));
1752
+ } else {
1753
+ line(BAD, "alias block missing from rc", p.shellRc ? tildify(p.shellRc) : "(unknown rc)");
1754
+ errors += 1;
1755
+ }
1756
+ }
1757
+ if (p.launchers.includes("script") && p.scriptPath) {
1758
+ if (isOurScript(p.scriptPath)) {
1759
+ line(OK, "wrapper script", tildify(p.scriptPath));
1760
+ const dir = path7.dirname(p.scriptPath);
1761
+ if (isOnPath(dir)) line(OK, "script dir on PATH", tildify(dir));
1762
+ else line(WARN, "script dir not on PATH", tildify(dir));
1763
+ } else {
1764
+ line(BAD, "wrapper script missing", tildify(p.scriptPath));
1765
+ errors += 1;
1766
+ }
1767
+ }
1768
+ }
1769
+ info("");
1770
+ if (errors === 0) info(color.green("No problems found."));
1771
+ else info(color.red(`${errors} problem(s) found.`));
1772
+ return errors === 0 ? 0 : 1;
1773
+ }
1774
+
1775
+ // src/commands/list.ts
1776
+ function pad(s, width) {
1777
+ return s.length >= width ? s : s + " ".repeat(width - s.length);
1778
+ }
1779
+ function permissionLabel(profile) {
1780
+ if (!profile.approvalPolicy && !profile.sandboxMode && !profile.approvalsReviewer) {
1781
+ return "default";
1782
+ }
1783
+ if (profile.approvalPolicy === "on-request" && profile.sandboxMode === "workspace-write" && profile.approvalsReviewer === "auto_review") {
1784
+ return "auto-review";
1785
+ }
1786
+ if (profile.approvalPolicy === "on-request" && profile.sandboxMode === "workspace-write" && profile.approvalsReviewer === "user") {
1787
+ return "auto";
1788
+ }
1789
+ if (profile.approvalPolicy === "on-request" && profile.sandboxMode === "read-only") {
1790
+ return "read-only";
1791
+ }
1792
+ if (profile.approvalPolicy === "never" && profile.sandboxMode === "workspace-write") {
1793
+ return "no-prompts";
1794
+ }
1795
+ return [
1796
+ profile.sandboxMode ?? "sandbox-default",
1797
+ profile.approvalPolicy ?? "approval-default",
1798
+ profile.approvalsReviewer ?? "reviewer-default"
1799
+ ].join("/");
1800
+ }
1801
+ function runList() {
1802
+ const profiles = listProfiles();
1803
+ if (profiles.length === 0) {
1804
+ info("No profiles yet. Run `codex-switch create` to add one.");
1805
+ return 0;
1806
+ }
1807
+ const rows = profiles.map((p) => ({
1808
+ alias: p.alias,
1809
+ model: p.model ?? (p.custom ? "(provider default)" : "(account default)"),
1810
+ type: p.custom ? "custom" : "standard",
1811
+ permissions: permissionLabel(p),
1812
+ launchers: p.launchers.join(", ") || "-",
1813
+ codexHome: tildify(p.codexHome)
1814
+ }));
1815
+ const headers = {
1816
+ alias: "ALIAS",
1817
+ model: "MODEL",
1818
+ type: "TYPE",
1819
+ permissions: "PERMISSIONS",
1820
+ launchers: "LAUNCHERS",
1821
+ codexHome: "CODEX HOME"
1822
+ };
1823
+ const widths = {
1824
+ alias: Math.max(headers.alias.length, ...rows.map((r2) => r2.alias.length)),
1825
+ model: Math.max(headers.model.length, ...rows.map((r2) => r2.model.length)),
1826
+ type: Math.max(headers.type.length, ...rows.map((r2) => r2.type.length)),
1827
+ permissions: Math.max(headers.permissions.length, ...rows.map((r2) => r2.permissions.length)),
1828
+ launchers: Math.max(headers.launchers.length, ...rows.map((r2) => r2.launchers.length))
1829
+ };
1830
+ info(
1831
+ color.bold(
1832
+ `${pad(headers.alias, widths.alias)} ${pad(headers.model, widths.model)} ${pad(headers.type, widths.type)} ${pad(headers.permissions, widths.permissions)} ${pad(headers.launchers, widths.launchers)} ${headers.codexHome}`
1833
+ )
1834
+ );
1835
+ for (const r2 of rows) {
1836
+ info(
1837
+ `${pad(r2.alias, widths.alias)} ${pad(r2.model, widths.model)} ${pad(r2.type, widths.type)} ${pad(r2.permissions, widths.permissions)} ${pad(r2.launchers, widths.launchers)} ${color.dim(r2.codexHome)}`
1838
+ );
1839
+ }
1840
+ return 0;
1841
+ }
1842
+
1843
+ // src/commands/remove.ts
1844
+ async function runRemove(aliasArg) {
1845
+ if (!aliasArg) {
1846
+ error("Usage: codex-switch remove <alias>");
1847
+ return 1;
1848
+ }
1849
+ const profile = getProfile(aliasArg);
1850
+ if (!profile) {
1851
+ error(`No profile named "${aliasArg}". Run \`codex-switch list\` to see profiles.`);
1852
+ return 1;
1853
+ }
1854
+ oe(color.bold(`Remove profile "${profile.alias}"`));
1855
+ const confirmed = await se({
1856
+ message: `Remove launchers and registry entry for "${profile.alias}"?`,
1857
+ initialValue: true
1858
+ });
1859
+ if (lD(confirmed) || !confirmed) {
1860
+ ue("Aborted. Nothing changed.");
1861
+ return 0;
1862
+ }
1863
+ const summary = [];
1864
+ if (profile.launchers.includes("alias") && profile.shellRc) {
1865
+ const { removed, backup } = removeAlias(profile.shellRc, profile.alias);
1866
+ if (removed) {
1867
+ summary.push(`Removed alias from ${tildify(profile.shellRc)}`);
1868
+ if (backup) summary.push(` backup: ${tildify(backup)}`);
1869
+ }
1870
+ }
1871
+ if (profile.scriptPath && fileExists(profile.scriptPath)) {
1872
+ if (removeWrapperScript(profile.scriptPath)) {
1873
+ summary.push(`Removed script ${tildify(profile.scriptPath)}`);
1874
+ } else {
1875
+ summary.push(`Left ${tildify(profile.scriptPath)} (not a codex-switch script)`);
1876
+ }
1877
+ }
1878
+ const codexHome = profile.codexHome || codexHomeFor(profile.alias);
1879
+ if (fileExists(codexHome)) {
1880
+ const delDir = await se({
1881
+ message: `Also delete ${tildify(codexHome)}? This erases its login + session history.`,
1882
+ initialValue: false
1883
+ });
1884
+ if (!lD(delDir) && delDir) {
1885
+ removeDir(codexHome);
1886
+ summary.push(`Deleted CODEX_HOME ${tildify(codexHome)}`);
1887
+ } else {
1888
+ summary.push(`Kept CODEX_HOME ${tildify(codexHome)}`);
1889
+ }
1890
+ }
1891
+ removeProfile(profile.alias);
1892
+ summary.push("Removed registry entry");
1893
+ $e(color.green("Done."));
1894
+ for (const line2 of summary) info(` ${line2}`);
1895
+ if (profile.launchers.includes("alias") && profile.shellRc) {
1896
+ info("");
1897
+ info(
1898
+ color.dim(`Open a new shell (or 'source ${tildify(profile.shellRc)}') to drop the alias.`)
1899
+ );
1900
+ }
1901
+ return 0;
1902
+ }
1903
+
1904
+ // src/index.ts
1905
+ var VERSION = "0.1.0";
1906
+ var HELP = `${color.bold("codex-switch")} \u2014 set up isolated Codex profiles
1907
+
1908
+ ${color.bold("USAGE")}
1909
+ codex-switch [command]
1910
+
1911
+ ${color.bold("COMMANDS")}
1912
+ create Create a new profile (interactive). Default when no command given.
1913
+ list List configured profiles.
1914
+ remove <alias> Remove a profile (cleans launchers; CODEX_HOME on confirm).
1915
+ doctor Check codex install, PATH, and profile health.
1916
+ help Show this help.
1917
+ version Show version.
1918
+
1919
+ ${color.bold("OPTIONS")}
1920
+ -h, --help Show this help.
1921
+ -v, --version Show version.
1922
+
1923
+ ${color.bold("EXAMPLES")}
1924
+ npx @naram/codex-switch # create a profile interactively
1925
+ codex-switch list
1926
+ codex-switch remove codex-gpt
1927
+
1928
+ Profiles are stored under ${color.dim("~/.codex-switch")}. Secrets live only in
1929
+ each profile's .env file (chmod 0600) \u2014 never in your shell rc.`;
1930
+ async function main(argv) {
1931
+ const [cmd, ...rest] = argv;
1932
+ switch (cmd) {
1933
+ case void 0:
1934
+ case "create":
1935
+ return runCreate();
1936
+ case "list":
1937
+ case "ls":
1938
+ return runList();
1939
+ case "remove":
1940
+ case "rm":
1941
+ return runRemove(rest[0]);
1942
+ case "doctor":
1943
+ return runDoctor();
1944
+ case "help":
1945
+ case "--help":
1946
+ case "-h":
1947
+ info(HELP);
1948
+ return 0;
1949
+ case "version":
1950
+ case "--version":
1951
+ case "-v":
1952
+ info(VERSION);
1953
+ return 0;
1954
+ default:
1955
+ error(`Unknown command: ${cmd}`);
1956
+ info(`Run ${color.cyan("codex-switch help")} for usage.`);
1957
+ return 1;
1958
+ }
1959
+ }
1960
+ main(process.argv.slice(2)).then((code) => {
1961
+ process.exitCode = code;
1962
+ }).catch((err) => {
1963
+ error(err instanceof Error ? err.message : String(err));
1964
+ process.exitCode = 1;
1965
+ });