@alcyone-labs/arg-parser 2.13.5 → 2.14.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/core/ArgParserBase.d.ts +55 -1
- package/dist/core/ArgParserBase.d.ts.map +1 -1
- package/dist/core/FlagManager.d.ts +160 -3
- package/dist/core/FlagManager.d.ts.map +1 -1
- package/dist/core/PromptManager.d.ts +102 -0
- package/dist/core/PromptManager.d.ts.map +1 -0
- package/dist/core/types.d.ts +224 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.cjs +2312 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.min.mjs +5140 -3558
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +1612 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var __copyProps$1 = (to, from, except, desc) => {
|
|
|
20
20
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$1(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
21
|
key = keys[i];
|
|
22
22
|
if (!__hasOwnProp$1.call(to, key) && key !== except) __defProp$1(to, key, {
|
|
23
|
-
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
get: ((k$1) => from[k$1]).bind(null, key),
|
|
24
24
|
enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -42,6 +42,11 @@ let get_tsconfig = require("get-tsconfig");
|
|
|
42
42
|
let node_os = require("node:os");
|
|
43
43
|
node_os = __toESM(node_os);
|
|
44
44
|
let zod = require("zod");
|
|
45
|
+
let node_process = require("node:process");
|
|
46
|
+
node_process = __toESM(node_process);
|
|
47
|
+
let node_readline = require("node:readline");
|
|
48
|
+
node_readline = __toESM(node_readline);
|
|
49
|
+
let node_tty = require("node:tty");
|
|
45
50
|
var RESET$1 = "\x1B[0m";
|
|
46
51
|
var BOLD$1 = "\x1B[1m";
|
|
47
52
|
var DIM$1 = "\x1B[2m";
|
|
@@ -773,18 +778,18 @@ ${codeblock}`, options);
|
|
|
773
778
|
});
|
|
774
779
|
else if (c === "#") ptr = skipComment$1(str, ptr);
|
|
775
780
|
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
776
|
-
let k;
|
|
777
|
-
let t = res;
|
|
781
|
+
let k$1;
|
|
782
|
+
let t$1 = res;
|
|
778
783
|
let hasOwn = false;
|
|
779
784
|
let [key, keyEndPtr] = parseKey$1(str, ptr - 1);
|
|
780
785
|
for (let i = 0; i < key.length; i++) {
|
|
781
|
-
if (i) t = hasOwn ? t[k] : t[k] = {};
|
|
782
|
-
k = key[i];
|
|
783
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError$1("trying to redefine an already defined value", {
|
|
786
|
+
if (i) t$1 = hasOwn ? t$1[k$1] : t$1[k$1] = {};
|
|
787
|
+
k$1 = key[i];
|
|
788
|
+
if ((hasOwn = Object.hasOwn(t$1, k$1)) && (typeof t$1[k$1] !== "object" || seen.has(t$1[k$1]))) throw new TomlError$1("trying to redefine an already defined value", {
|
|
784
789
|
toml: str,
|
|
785
790
|
ptr
|
|
786
791
|
});
|
|
787
|
-
if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
|
|
792
|
+
if (!hasOwn && k$1 === "__proto__") Object.defineProperty(t$1, k$1, {
|
|
788
793
|
enumerable: true,
|
|
789
794
|
configurable: true,
|
|
790
795
|
writable: true
|
|
@@ -796,7 +801,7 @@ ${codeblock}`, options);
|
|
|
796
801
|
});
|
|
797
802
|
let [value, valueEndPtr] = extractValue$1(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
798
803
|
seen.add(value);
|
|
799
|
-
t[k] = value;
|
|
804
|
+
t$1[k$1] = value;
|
|
800
805
|
ptr = valueEndPtr;
|
|
801
806
|
}
|
|
802
807
|
if (!c) throw new TomlError$1("unfinished table encountered", {
|
|
@@ -826,38 +831,38 @@ ${codeblock}`, options);
|
|
|
826
831
|
return [res, ptr];
|
|
827
832
|
}
|
|
828
833
|
function peekTable$1(key, table, meta, type) {
|
|
829
|
-
let t = table;
|
|
834
|
+
let t$1 = table;
|
|
830
835
|
let m = meta;
|
|
831
|
-
let k;
|
|
836
|
+
let k$1;
|
|
832
837
|
let hasOwn = false;
|
|
833
838
|
let state;
|
|
834
839
|
for (let i = 0; i < key.length; i++) {
|
|
835
840
|
if (i) {
|
|
836
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
837
|
-
m = (state = m[k]).c;
|
|
841
|
+
t$1 = hasOwn ? t$1[k$1] : t$1[k$1] = {};
|
|
842
|
+
m = (state = m[k$1]).c;
|
|
838
843
|
if (type === 0 && (state.t === 1 || state.t === 2)) return null;
|
|
839
844
|
if (state.t === 2) {
|
|
840
|
-
let l = t.length - 1;
|
|
841
|
-
t = t[l];
|
|
845
|
+
let l = t$1.length - 1;
|
|
846
|
+
t$1 = t$1[l];
|
|
842
847
|
m = m[l].c;
|
|
843
848
|
}
|
|
844
849
|
}
|
|
845
|
-
k = key[i];
|
|
846
|
-
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
|
|
850
|
+
k$1 = key[i];
|
|
851
|
+
if ((hasOwn = Object.hasOwn(t$1, k$1)) && m[k$1]?.t === 0 && m[k$1]?.d) return null;
|
|
847
852
|
if (!hasOwn) {
|
|
848
|
-
if (k === "__proto__") {
|
|
849
|
-
Object.defineProperty(t, k, {
|
|
853
|
+
if (k$1 === "__proto__") {
|
|
854
|
+
Object.defineProperty(t$1, k$1, {
|
|
850
855
|
enumerable: true,
|
|
851
856
|
configurable: true,
|
|
852
857
|
writable: true
|
|
853
858
|
});
|
|
854
|
-
Object.defineProperty(m, k, {
|
|
859
|
+
Object.defineProperty(m, k$1, {
|
|
855
860
|
enumerable: true,
|
|
856
861
|
configurable: true,
|
|
857
862
|
writable: true
|
|
858
863
|
});
|
|
859
864
|
}
|
|
860
|
-
m[k] = {
|
|
865
|
+
m[k$1] = {
|
|
861
866
|
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
862
867
|
d: false,
|
|
863
868
|
i: 0,
|
|
@@ -865,14 +870,14 @@ ${codeblock}`, options);
|
|
|
865
870
|
};
|
|
866
871
|
}
|
|
867
872
|
}
|
|
868
|
-
state = m[k];
|
|
873
|
+
state = m[k$1];
|
|
869
874
|
if (state.t !== type && !(type === 1 && state.t === 3)) return null;
|
|
870
875
|
if (type === 2) {
|
|
871
876
|
if (!state.d) {
|
|
872
877
|
state.d = true;
|
|
873
|
-
t[k] = [];
|
|
878
|
+
t$1[k$1] = [];
|
|
874
879
|
}
|
|
875
|
-
t[k].push(t = {});
|
|
880
|
+
t$1[k$1].push(t$1 = {});
|
|
876
881
|
state.c[state.i++] = state = {
|
|
877
882
|
t: 1,
|
|
878
883
|
d: false,
|
|
@@ -882,11 +887,11 @@ ${codeblock}`, options);
|
|
|
882
887
|
}
|
|
883
888
|
if (state.d) return null;
|
|
884
889
|
state.d = true;
|
|
885
|
-
if (type === 1) t = hasOwn ? t[k] : t[k] = {};
|
|
890
|
+
if (type === 1) t$1 = hasOwn ? t$1[k$1] : t$1[k$1] = {};
|
|
886
891
|
else if (type === 0 && hasOwn) return null;
|
|
887
892
|
return [
|
|
888
|
-
k,
|
|
889
|
-
t,
|
|
893
|
+
k$1,
|
|
894
|
+
t$1,
|
|
890
895
|
state.c
|
|
891
896
|
];
|
|
892
897
|
}
|
|
@@ -898,30 +903,30 @@ ${codeblock}`, options);
|
|
|
898
903
|
for (let ptr = skipVoid$1(toml, 0); ptr < toml.length;) {
|
|
899
904
|
if (toml[ptr] === "[") {
|
|
900
905
|
let isTableArray = toml[++ptr] === "[";
|
|
901
|
-
let k = parseKey$1(toml, ptr += +isTableArray, "]");
|
|
906
|
+
let k$1 = parseKey$1(toml, ptr += +isTableArray, "]");
|
|
902
907
|
if (isTableArray) {
|
|
903
|
-
if (toml[k[1] - 1] !== "]") throw new TomlError$1("expected end of table declaration", {
|
|
908
|
+
if (toml[k$1[1] - 1] !== "]") throw new TomlError$1("expected end of table declaration", {
|
|
904
909
|
toml,
|
|
905
|
-
ptr: k[1] - 1
|
|
910
|
+
ptr: k$1[1] - 1
|
|
906
911
|
});
|
|
907
|
-
k[1]++;
|
|
912
|
+
k$1[1]++;
|
|
908
913
|
}
|
|
909
|
-
let p = peekTable$1(k[0], res, meta, isTableArray ? 2 : 1);
|
|
914
|
+
let p = peekTable$1(k$1[0], res, meta, isTableArray ? 2 : 1);
|
|
910
915
|
if (!p) throw new TomlError$1("trying to redefine an already defined table or value", {
|
|
911
916
|
toml,
|
|
912
917
|
ptr
|
|
913
918
|
});
|
|
914
919
|
m = p[2];
|
|
915
920
|
tbl = p[1];
|
|
916
|
-
ptr = k[1];
|
|
921
|
+
ptr = k$1[1];
|
|
917
922
|
} else {
|
|
918
|
-
let k = parseKey$1(toml, ptr);
|
|
919
|
-
let p = peekTable$1(k[0], tbl, m, 0);
|
|
923
|
+
let k$1 = parseKey$1(toml, ptr);
|
|
924
|
+
let p = peekTable$1(k$1[0], tbl, m, 0);
|
|
920
925
|
if (!p) throw new TomlError$1("trying to redefine an already defined table or value", {
|
|
921
926
|
toml,
|
|
922
927
|
ptr
|
|
923
928
|
});
|
|
924
|
-
let v = extractValue$1(toml, k[1], void 0, maxDepth, integersAsBigInt);
|
|
929
|
+
let v = extractValue$1(toml, k$1[1], void 0, maxDepth, integersAsBigInt);
|
|
925
930
|
p[1][p[0]] = v[0];
|
|
926
931
|
ptr = v[1];
|
|
927
932
|
}
|
|
@@ -973,11 +978,11 @@ ${codeblock}`, options);
|
|
|
973
978
|
if (keys.length === 0) return "{}";
|
|
974
979
|
let res = "{ ";
|
|
975
980
|
for (let i = 0; i < keys.length; i++) {
|
|
976
|
-
let k = keys[i];
|
|
981
|
+
let k$1 = keys[i];
|
|
977
982
|
if (i) res += ", ";
|
|
978
|
-
res += BARE_KEY$1.test(k) ? k : formatString$1(k);
|
|
983
|
+
res += BARE_KEY$1.test(k$1) ? k$1 : formatString$1(k$1);
|
|
979
984
|
res += " = ";
|
|
980
|
-
res += stringifyValue$1(obj[k], extendedTypeOf$1(obj[k]), depth - 1, numberAsFloat);
|
|
985
|
+
res += stringifyValue$1(obj[k$1], extendedTypeOf$1(obj[k$1]), depth - 1, numberAsFloat);
|
|
981
986
|
}
|
|
982
987
|
return res + " }";
|
|
983
988
|
}
|
|
@@ -1007,19 +1012,19 @@ ${codeblock}`, options);
|
|
|
1007
1012
|
let tables = "";
|
|
1008
1013
|
let keys = Object.keys(obj);
|
|
1009
1014
|
for (let i = 0; i < keys.length; i++) {
|
|
1010
|
-
let k = keys[i];
|
|
1011
|
-
if (obj[k] !== null && obj[k] !== void 0) {
|
|
1012
|
-
let type = extendedTypeOf$1(obj[k]);
|
|
1015
|
+
let k$1 = keys[i];
|
|
1016
|
+
if (obj[k$1] !== null && obj[k$1] !== void 0) {
|
|
1017
|
+
let type = extendedTypeOf$1(obj[k$1]);
|
|
1013
1018
|
if (type === "symbol" || type === "function") throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
1014
|
-
let key = BARE_KEY$1.test(k) ? k : formatString$1(k);
|
|
1015
|
-
if (type === "array" && isArrayOfTables$1(obj[k])) tables += (tables && "\n") + stringifyArrayTable$1(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
1019
|
+
let key = BARE_KEY$1.test(k$1) ? k$1 : formatString$1(k$1);
|
|
1020
|
+
if (type === "array" && isArrayOfTables$1(obj[k$1])) tables += (tables && "\n") + stringifyArrayTable$1(obj[k$1], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
1016
1021
|
else if (type === "object") {
|
|
1017
1022
|
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
1018
|
-
tables += (tables && "\n") + stringifyTable$1(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
1023
|
+
tables += (tables && "\n") + stringifyTable$1(tblKey, obj[k$1], tblKey, depth - 1, numberAsFloat);
|
|
1019
1024
|
} else {
|
|
1020
1025
|
preamble += key;
|
|
1021
1026
|
preamble += " = ";
|
|
1022
|
-
preamble += stringifyValue$1(obj[k], type, depth, numberAsFloat);
|
|
1027
|
+
preamble += stringifyValue$1(obj[k$1], type, depth, numberAsFloat);
|
|
1023
1028
|
preamble += "\n";
|
|
1024
1029
|
}
|
|
1025
1030
|
}
|
|
@@ -1462,18 +1467,18 @@ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
|
|
|
1462
1467
|
});
|
|
1463
1468
|
else if (c === "#") ptr = skipComment(str, ptr);
|
|
1464
1469
|
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
1465
|
-
let k;
|
|
1466
|
-
let t = res;
|
|
1470
|
+
let k$1;
|
|
1471
|
+
let t$1 = res;
|
|
1467
1472
|
let hasOwn = false;
|
|
1468
1473
|
let [key, keyEndPtr] = parseKey(str, ptr - 1);
|
|
1469
1474
|
for (let i = 0; i < key.length; i++) {
|
|
1470
|
-
if (i) t = hasOwn ? t[k] : t[k] = {};
|
|
1471
|
-
k = key[i];
|
|
1472
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError("trying to redefine an already defined value", {
|
|
1475
|
+
if (i) t$1 = hasOwn ? t$1[k$1] : t$1[k$1] = {};
|
|
1476
|
+
k$1 = key[i];
|
|
1477
|
+
if ((hasOwn = Object.hasOwn(t$1, k$1)) && (typeof t$1[k$1] !== "object" || seen.has(t$1[k$1]))) throw new TomlError("trying to redefine an already defined value", {
|
|
1473
1478
|
toml: str,
|
|
1474
1479
|
ptr
|
|
1475
1480
|
});
|
|
1476
|
-
if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
|
|
1481
|
+
if (!hasOwn && k$1 === "__proto__") Object.defineProperty(t$1, k$1, {
|
|
1477
1482
|
enumerable: true,
|
|
1478
1483
|
configurable: true,
|
|
1479
1484
|
writable: true
|
|
@@ -1485,7 +1490,7 @@ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
|
|
|
1485
1490
|
});
|
|
1486
1491
|
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
1487
1492
|
seen.add(value);
|
|
1488
|
-
t[k] = value;
|
|
1493
|
+
t$1[k$1] = value;
|
|
1489
1494
|
ptr = valueEndPtr;
|
|
1490
1495
|
}
|
|
1491
1496
|
if (!c) throw new TomlError("unfinished table encountered", {
|
|
@@ -1523,38 +1528,38 @@ var init_struct = __esmMin((() => {
|
|
|
1523
1528
|
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
1524
1529
|
}));
|
|
1525
1530
|
function peekTable(key, table, meta, type) {
|
|
1526
|
-
let t = table;
|
|
1531
|
+
let t$1 = table;
|
|
1527
1532
|
let m = meta;
|
|
1528
|
-
let k;
|
|
1533
|
+
let k$1;
|
|
1529
1534
|
let hasOwn = false;
|
|
1530
1535
|
let state;
|
|
1531
1536
|
for (let i = 0; i < key.length; i++) {
|
|
1532
1537
|
if (i) {
|
|
1533
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
1534
|
-
m = (state = m[k]).c;
|
|
1538
|
+
t$1 = hasOwn ? t$1[k$1] : t$1[k$1] = {};
|
|
1539
|
+
m = (state = m[k$1]).c;
|
|
1535
1540
|
if (type === 0 && (state.t === 1 || state.t === 2)) return null;
|
|
1536
1541
|
if (state.t === 2) {
|
|
1537
|
-
let l = t.length - 1;
|
|
1538
|
-
t = t[l];
|
|
1542
|
+
let l = t$1.length - 1;
|
|
1543
|
+
t$1 = t$1[l];
|
|
1539
1544
|
m = m[l].c;
|
|
1540
1545
|
}
|
|
1541
1546
|
}
|
|
1542
|
-
k = key[i];
|
|
1543
|
-
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
|
|
1547
|
+
k$1 = key[i];
|
|
1548
|
+
if ((hasOwn = Object.hasOwn(t$1, k$1)) && m[k$1]?.t === 0 && m[k$1]?.d) return null;
|
|
1544
1549
|
if (!hasOwn) {
|
|
1545
|
-
if (k === "__proto__") {
|
|
1546
|
-
Object.defineProperty(t, k, {
|
|
1550
|
+
if (k$1 === "__proto__") {
|
|
1551
|
+
Object.defineProperty(t$1, k$1, {
|
|
1547
1552
|
enumerable: true,
|
|
1548
1553
|
configurable: true,
|
|
1549
1554
|
writable: true
|
|
1550
1555
|
});
|
|
1551
|
-
Object.defineProperty(m, k, {
|
|
1556
|
+
Object.defineProperty(m, k$1, {
|
|
1552
1557
|
enumerable: true,
|
|
1553
1558
|
configurable: true,
|
|
1554
1559
|
writable: true
|
|
1555
1560
|
});
|
|
1556
1561
|
}
|
|
1557
|
-
m[k] = {
|
|
1562
|
+
m[k$1] = {
|
|
1558
1563
|
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
1559
1564
|
d: false,
|
|
1560
1565
|
i: 0,
|
|
@@ -1562,14 +1567,14 @@ function peekTable(key, table, meta, type) {
|
|
|
1562
1567
|
};
|
|
1563
1568
|
}
|
|
1564
1569
|
}
|
|
1565
|
-
state = m[k];
|
|
1570
|
+
state = m[k$1];
|
|
1566
1571
|
if (state.t !== type && !(type === 1 && state.t === 3)) return null;
|
|
1567
1572
|
if (type === 2) {
|
|
1568
1573
|
if (!state.d) {
|
|
1569
1574
|
state.d = true;
|
|
1570
|
-
t[k] = [];
|
|
1575
|
+
t$1[k$1] = [];
|
|
1571
1576
|
}
|
|
1572
|
-
t[k].push(t = {});
|
|
1577
|
+
t$1[k$1].push(t$1 = {});
|
|
1573
1578
|
state.c[state.i++] = state = {
|
|
1574
1579
|
t: 1,
|
|
1575
1580
|
d: false,
|
|
@@ -1579,11 +1584,11 @@ function peekTable(key, table, meta, type) {
|
|
|
1579
1584
|
}
|
|
1580
1585
|
if (state.d) return null;
|
|
1581
1586
|
state.d = true;
|
|
1582
|
-
if (type === 1) t = hasOwn ? t[k] : t[k] = {};
|
|
1587
|
+
if (type === 1) t$1 = hasOwn ? t$1[k$1] : t$1[k$1] = {};
|
|
1583
1588
|
else if (type === 0 && hasOwn) return null;
|
|
1584
1589
|
return [
|
|
1585
|
-
k,
|
|
1586
|
-
t,
|
|
1590
|
+
k$1,
|
|
1591
|
+
t$1,
|
|
1587
1592
|
state.c
|
|
1588
1593
|
];
|
|
1589
1594
|
}
|
|
@@ -1595,30 +1600,30 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
1595
1600
|
for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
|
|
1596
1601
|
if (toml[ptr] === "[") {
|
|
1597
1602
|
let isTableArray = toml[++ptr] === "[";
|
|
1598
|
-
let k = parseKey(toml, ptr += +isTableArray, "]");
|
|
1603
|
+
let k$1 = parseKey(toml, ptr += +isTableArray, "]");
|
|
1599
1604
|
if (isTableArray) {
|
|
1600
|
-
if (toml[k[1] - 1] !== "]") throw new TomlError("expected end of table declaration", {
|
|
1605
|
+
if (toml[k$1[1] - 1] !== "]") throw new TomlError("expected end of table declaration", {
|
|
1601
1606
|
toml,
|
|
1602
|
-
ptr: k[1] - 1
|
|
1607
|
+
ptr: k$1[1] - 1
|
|
1603
1608
|
});
|
|
1604
|
-
k[1]++;
|
|
1609
|
+
k$1[1]++;
|
|
1605
1610
|
}
|
|
1606
|
-
let p = peekTable(k[0], res, meta, isTableArray ? 2 : 1);
|
|
1611
|
+
let p = peekTable(k$1[0], res, meta, isTableArray ? 2 : 1);
|
|
1607
1612
|
if (!p) throw new TomlError("trying to redefine an already defined table or value", {
|
|
1608
1613
|
toml,
|
|
1609
1614
|
ptr
|
|
1610
1615
|
});
|
|
1611
1616
|
m = p[2];
|
|
1612
1617
|
tbl = p[1];
|
|
1613
|
-
ptr = k[1];
|
|
1618
|
+
ptr = k$1[1];
|
|
1614
1619
|
} else {
|
|
1615
|
-
let k = parseKey(toml, ptr);
|
|
1616
|
-
let p = peekTable(k[0], tbl, m, 0);
|
|
1620
|
+
let k$1 = parseKey(toml, ptr);
|
|
1621
|
+
let p = peekTable(k$1[0], tbl, m, 0);
|
|
1617
1622
|
if (!p) throw new TomlError("trying to redefine an already defined table or value", {
|
|
1618
1623
|
toml,
|
|
1619
1624
|
ptr
|
|
1620
1625
|
});
|
|
1621
|
-
let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
|
|
1626
|
+
let v = extractValue(toml, k$1[1], void 0, maxDepth, integersAsBigInt);
|
|
1622
1627
|
p[1][p[0]] = v[0];
|
|
1623
1628
|
ptr = v[1];
|
|
1624
1629
|
}
|
|
@@ -1675,11 +1680,11 @@ function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
|
1675
1680
|
if (keys.length === 0) return "{}";
|
|
1676
1681
|
let res = "{ ";
|
|
1677
1682
|
for (let i = 0; i < keys.length; i++) {
|
|
1678
|
-
let k = keys[i];
|
|
1683
|
+
let k$1 = keys[i];
|
|
1679
1684
|
if (i) res += ", ";
|
|
1680
|
-
res += BARE_KEY.test(k) ? k : formatString(k);
|
|
1685
|
+
res += BARE_KEY.test(k$1) ? k$1 : formatString(k$1);
|
|
1681
1686
|
res += " = ";
|
|
1682
|
-
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
1687
|
+
res += stringifyValue(obj[k$1], extendedTypeOf(obj[k$1]), depth - 1, numberAsFloat);
|
|
1683
1688
|
}
|
|
1684
1689
|
return res + " }";
|
|
1685
1690
|
}
|
|
@@ -1708,19 +1713,19 @@ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
|
1708
1713
|
let tables = "";
|
|
1709
1714
|
let keys = Object.keys(obj);
|
|
1710
1715
|
for (let i = 0; i < keys.length; i++) {
|
|
1711
|
-
let k = keys[i];
|
|
1712
|
-
if (obj[k] !== null && obj[k] !== void 0) {
|
|
1713
|
-
let type = extendedTypeOf(obj[k]);
|
|
1716
|
+
let k$1 = keys[i];
|
|
1717
|
+
if (obj[k$1] !== null && obj[k$1] !== void 0) {
|
|
1718
|
+
let type = extendedTypeOf(obj[k$1]);
|
|
1714
1719
|
if (type === "symbol" || type === "function") throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
1715
|
-
let key = BARE_KEY.test(k) ? k : formatString(k);
|
|
1716
|
-
if (type === "array" && isArrayOfTables(obj[k])) tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
1720
|
+
let key = BARE_KEY.test(k$1) ? k$1 : formatString(k$1);
|
|
1721
|
+
if (type === "array" && isArrayOfTables(obj[k$1])) tables += (tables && "\n") + stringifyArrayTable(obj[k$1], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
1717
1722
|
else if (type === "object") {
|
|
1718
1723
|
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
1719
|
-
tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
1724
|
+
tables += (tables && "\n") + stringifyTable(tblKey, obj[k$1], tblKey, depth - 1, numberAsFloat);
|
|
1720
1725
|
} else {
|
|
1721
1726
|
preamble += key;
|
|
1722
1727
|
preamble += " = ";
|
|
1723
|
-
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
1728
|
+
preamble += stringifyValue(obj[k$1], type, depth, numberAsFloat);
|
|
1724
1729
|
preamble += "\n";
|
|
1725
1730
|
}
|
|
1726
1731
|
}
|
|
@@ -1738,7 +1743,7 @@ var BARE_KEY;
|
|
|
1738
1743
|
var init_stringify = __esmMin((() => {
|
|
1739
1744
|
BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
1740
1745
|
}));
|
|
1741
|
-
var dist_exports = /* @__PURE__ */ __export$1({
|
|
1746
|
+
var dist_exports$1 = /* @__PURE__ */ __export$1({
|
|
1742
1747
|
TomlDate: () => TomlDate,
|
|
1743
1748
|
TomlError: () => TomlError,
|
|
1744
1749
|
default: () => dist_default,
|
|
@@ -1776,7 +1781,7 @@ async function createTomlPluginAsync() {
|
|
|
1776
1781
|
if (typeof require !== "undefined") try {
|
|
1777
1782
|
return new TomlConfigPlugin(require_dist());
|
|
1778
1783
|
} catch (error) {}
|
|
1779
|
-
return new TomlConfigPlugin(await Promise.resolve().then(() => (init_dist(), dist_exports)));
|
|
1784
|
+
return new TomlConfigPlugin(await Promise.resolve().then(() => (init_dist(), dist_exports$1)));
|
|
1780
1785
|
} catch (error) {
|
|
1781
1786
|
console.warn("TOML plugin not available:", error instanceof Error ? error.message : String(error));
|
|
1782
1787
|
return null;
|
|
@@ -2679,7 +2684,9 @@ const zodFlagSchema = zod.z.object({
|
|
|
2679
2684
|
dxtOptions: zodDxtOptionsSchema.optional().describe("DXT-specific configuration options for enhanced DXT manifest generation"),
|
|
2680
2685
|
dynamicRegister: zod.z.custom((val) => typeof val === "function").optional().describe("Optional callback that can register additional flags dynamically when this flag is present."),
|
|
2681
2686
|
setWorkingDirectory: zod.z.boolean().optional().describe("If true, this flag's value becomes the effective working directory for file operations."),
|
|
2682
|
-
positional: zod.z.number().int().positive("Positional index must be a positive integer (1, 2, 3...)").optional().describe("If set, this flag captures the Nth trailing positional argument (1-indexed). Multiple flags can have different positional values to capture multiple trailing args in order.")
|
|
2687
|
+
positional: zod.z.number().int().positive("Positional index must be a positive integer (1, 2, 3...)").optional().describe("If set, this flag captures the Nth trailing positional argument (1-indexed). Multiple flags can have different positional values to capture multiple trailing args in order."),
|
|
2688
|
+
prompt: zod.z.custom((val) => typeof val === "function").optional().describe("Prompt configuration factory for interactive mode"),
|
|
2689
|
+
promptSequence: zod.z.number().int().positive("Prompt sequence must be a positive integer").optional().describe("Explicit sequence order for prompts (1 = first, 2 = second, etc.)")
|
|
2683
2690
|
}).transform((obj) => {
|
|
2684
2691
|
const newObj = { ...obj };
|
|
2685
2692
|
if ("default" in newObj && newObj["default"] !== void 0 && !("defaultValue" in newObj)) newObj["defaultValue"] = newObj["default"];
|
|
@@ -3799,6 +3806,9 @@ var McpPromptsManager = class {
|
|
|
3799
3806
|
}
|
|
3800
3807
|
}
|
|
3801
3808
|
};
|
|
3809
|
+
var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3810
|
+
module.exports = {};
|
|
3811
|
+
}));
|
|
3802
3812
|
var logger$4 = (0, __alcyone_labs_simple_mcp_logger.createMcpLogger)("MCP Resources");
|
|
3803
3813
|
var ResourceTemplateParser = class {
|
|
3804
3814
|
constructor(template) {
|
|
@@ -3935,9 +3945,14 @@ const debug = {
|
|
|
3935
3945
|
};
|
|
3936
3946
|
var FlagManager = class FlagManager {
|
|
3937
3947
|
#_flags = /* @__PURE__ */ new Map();
|
|
3948
|
+
#_optionToFlagName = /* @__PURE__ */ new Map();
|
|
3938
3949
|
#throwForDuplicateFlags;
|
|
3950
|
+
#detectOptionCollisions;
|
|
3951
|
+
#throwForOptionCollisions;
|
|
3939
3952
|
constructor(options = {}, initialFlags = []) {
|
|
3940
3953
|
this.#throwForDuplicateFlags = options.throwForDuplicateFlags ?? false;
|
|
3954
|
+
this.#detectOptionCollisions = options.detectOptionCollisions ?? true;
|
|
3955
|
+
this.#throwForOptionCollisions = options.throwForOptionCollisions ?? false;
|
|
3941
3956
|
this.addFlags(initialFlags);
|
|
3942
3957
|
}
|
|
3943
3958
|
static _safeFlag(flag) {
|
|
@@ -3971,9 +3986,26 @@ var FlagManager = class FlagManager {
|
|
|
3971
3986
|
enum: parsedFromZod["enum"],
|
|
3972
3987
|
mandatory: parsedFromZod["mandatory"],
|
|
3973
3988
|
env: parsedFromZod["env"],
|
|
3974
|
-
dxtOptions: parsedFromZod["dxtOptions"]
|
|
3989
|
+
dxtOptions: parsedFromZod["dxtOptions"],
|
|
3990
|
+
prompt: parsedFromZod["prompt"],
|
|
3991
|
+
promptSequence: parsedFromZod["promptSequence"]
|
|
3975
3992
|
};
|
|
3976
3993
|
}
|
|
3994
|
+
#findOptionCollisions(newFlag) {
|
|
3995
|
+
const collisions = [];
|
|
3996
|
+
for (const option of newFlag["options"]) {
|
|
3997
|
+
const existingFlagName = this.#_optionToFlagName.get(option);
|
|
3998
|
+
if (existingFlagName && existingFlagName !== newFlag["name"]) collisions.push({
|
|
3999
|
+
option,
|
|
4000
|
+
existingFlagName,
|
|
4001
|
+
newFlagName: newFlag["name"]
|
|
4002
|
+
});
|
|
4003
|
+
}
|
|
4004
|
+
return collisions;
|
|
4005
|
+
}
|
|
4006
|
+
#registerFlagOptions(flag) {
|
|
4007
|
+
for (const option of flag["options"]) this.#_optionToFlagName.set(option, flag["name"]);
|
|
4008
|
+
}
|
|
3977
4009
|
addFlag(flag) {
|
|
3978
4010
|
const safeFlag = FlagManager._safeFlag(flag);
|
|
3979
4011
|
if (this.#_flags.has(safeFlag["name"])) if (this.#throwForDuplicateFlags) throw new Error(`FlagManager: Flag '${safeFlag["name"]}' already exists.`);
|
|
@@ -3981,12 +4013,23 @@ var FlagManager = class FlagManager {
|
|
|
3981
4013
|
console.warn(`Warning: FlagManager: Flag '${safeFlag["name"]}' already exists. Duplicate not added.`);
|
|
3982
4014
|
return this;
|
|
3983
4015
|
}
|
|
4016
|
+
if (this.#detectOptionCollisions) {
|
|
4017
|
+
const collisions = this.#findOptionCollisions(safeFlag);
|
|
4018
|
+
if (collisions.length > 0) {
|
|
4019
|
+
const collisionMessages = collisions.map((c) => `'${c.option}' (conflicts with '${c.existingFlagName}')`);
|
|
4020
|
+
const message = `Flag '${safeFlag["name"]}' has option collision(s): ${collisionMessages.join(", ")}. Each option string can only be used by one flag.`;
|
|
4021
|
+
if (this.#throwForOptionCollisions) throw new Error(`FlagManager: ${message}`);
|
|
4022
|
+
else console.warn(`Warning: FlagManager: ${message}`);
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
3984
4025
|
this.#_flags.set(safeFlag["name"], safeFlag);
|
|
4026
|
+
this.#registerFlagOptions(safeFlag);
|
|
3985
4027
|
return this;
|
|
3986
4028
|
}
|
|
3987
4029
|
_setProcessedFlagForInheritance(processedFlag) {
|
|
3988
4030
|
if (this.#_flags.has(processedFlag["name"])) return this;
|
|
3989
4031
|
this.#_flags.set(processedFlag["name"], processedFlag);
|
|
4032
|
+
this.#registerFlagOptions(processedFlag);
|
|
3990
4033
|
return this;
|
|
3991
4034
|
}
|
|
3992
4035
|
addFlags(flags) {
|
|
@@ -3997,7 +4040,12 @@ var FlagManager = class FlagManager {
|
|
|
3997
4040
|
return this.#_flags.has(name);
|
|
3998
4041
|
}
|
|
3999
4042
|
removeFlag(name) {
|
|
4000
|
-
|
|
4043
|
+
const flag = this.#_flags.get(name);
|
|
4044
|
+
if (flag) {
|
|
4045
|
+
for (const option of flag["options"]) this.#_optionToFlagName.delete(option);
|
|
4046
|
+
return this.#_flags.delete(name);
|
|
4047
|
+
}
|
|
4048
|
+
return false;
|
|
4001
4049
|
}
|
|
4002
4050
|
getFlag(name) {
|
|
4003
4051
|
return this.#_flags.get(name);
|
|
@@ -4008,7 +4056,2089 @@ var FlagManager = class FlagManager {
|
|
|
4008
4056
|
get flagNames() {
|
|
4009
4057
|
return Array.from(this.#_flags.values()).map((flag) => flag["name"]);
|
|
4010
4058
|
}
|
|
4059
|
+
get optionMappings() {
|
|
4060
|
+
return new Map(this.#_optionToFlagName);
|
|
4061
|
+
}
|
|
4062
|
+
getCollisionsForFlag(flag) {
|
|
4063
|
+
const safeFlag = FlagManager._safeFlag(flag);
|
|
4064
|
+
return this.#findOptionCollisions(safeFlag);
|
|
4065
|
+
}
|
|
4066
|
+
};
|
|
4067
|
+
var require_picocolors_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4068
|
+
var x$2 = String;
|
|
4069
|
+
var create = function() {
|
|
4070
|
+
return {
|
|
4071
|
+
isColorSupported: false,
|
|
4072
|
+
reset: x$2,
|
|
4073
|
+
bold: x$2,
|
|
4074
|
+
dim: x$2,
|
|
4075
|
+
italic: x$2,
|
|
4076
|
+
underline: x$2,
|
|
4077
|
+
inverse: x$2,
|
|
4078
|
+
hidden: x$2,
|
|
4079
|
+
strikethrough: x$2,
|
|
4080
|
+
black: x$2,
|
|
4081
|
+
red: x$2,
|
|
4082
|
+
green: x$2,
|
|
4083
|
+
yellow: x$2,
|
|
4084
|
+
blue: x$2,
|
|
4085
|
+
magenta: x$2,
|
|
4086
|
+
cyan: x$2,
|
|
4087
|
+
white: x$2,
|
|
4088
|
+
gray: x$2,
|
|
4089
|
+
bgBlack: x$2,
|
|
4090
|
+
bgRed: x$2,
|
|
4091
|
+
bgGreen: x$2,
|
|
4092
|
+
bgYellow: x$2,
|
|
4093
|
+
bgBlue: x$2,
|
|
4094
|
+
bgMagenta: x$2,
|
|
4095
|
+
bgCyan: x$2,
|
|
4096
|
+
bgWhite: x$2,
|
|
4097
|
+
blackBright: x$2,
|
|
4098
|
+
redBright: x$2,
|
|
4099
|
+
greenBright: x$2,
|
|
4100
|
+
yellowBright: x$2,
|
|
4101
|
+
blueBright: x$2,
|
|
4102
|
+
magentaBright: x$2,
|
|
4103
|
+
cyanBright: x$2,
|
|
4104
|
+
whiteBright: x$2,
|
|
4105
|
+
bgBlackBright: x$2,
|
|
4106
|
+
bgRedBright: x$2,
|
|
4107
|
+
bgGreenBright: x$2,
|
|
4108
|
+
bgYellowBright: x$2,
|
|
4109
|
+
bgBlueBright: x$2,
|
|
4110
|
+
bgMagentaBright: x$2,
|
|
4111
|
+
bgCyanBright: x$2,
|
|
4112
|
+
bgWhiteBright: x$2
|
|
4113
|
+
};
|
|
4114
|
+
};
|
|
4115
|
+
module.exports = create();
|
|
4116
|
+
module.exports.createColors = create;
|
|
4117
|
+
}));
|
|
4118
|
+
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4119
|
+
var ESC = "\x1B";
|
|
4120
|
+
var CSI = `${ESC}[`;
|
|
4121
|
+
var beep = "\x07";
|
|
4122
|
+
var cursor = {
|
|
4123
|
+
to(x$3, y$1) {
|
|
4124
|
+
if (!y$1) return `${CSI}${x$3 + 1}G`;
|
|
4125
|
+
return `${CSI}${y$1 + 1};${x$3 + 1}H`;
|
|
4126
|
+
},
|
|
4127
|
+
move(x$3, y$1) {
|
|
4128
|
+
let ret = "";
|
|
4129
|
+
if (x$3 < 0) ret += `${CSI}${-x$3}D`;
|
|
4130
|
+
else if (x$3 > 0) ret += `${CSI}${x$3}C`;
|
|
4131
|
+
if (y$1 < 0) ret += `${CSI}${-y$1}A`;
|
|
4132
|
+
else if (y$1 > 0) ret += `${CSI}${y$1}B`;
|
|
4133
|
+
return ret;
|
|
4134
|
+
},
|
|
4135
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
4136
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
4137
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
4138
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
4139
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
4140
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
4141
|
+
left: `${CSI}G`,
|
|
4142
|
+
hide: `${CSI}?25l`,
|
|
4143
|
+
show: `${CSI}?25h`,
|
|
4144
|
+
save: `${ESC}7`,
|
|
4145
|
+
restore: `${ESC}8`
|
|
4146
|
+
};
|
|
4147
|
+
module.exports = {
|
|
4148
|
+
cursor,
|
|
4149
|
+
scroll: {
|
|
4150
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
4151
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
4152
|
+
},
|
|
4153
|
+
erase: {
|
|
4154
|
+
screen: `${CSI}2J`,
|
|
4155
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
4156
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
4157
|
+
line: `${CSI}2K`,
|
|
4158
|
+
lineEnd: `${CSI}K`,
|
|
4159
|
+
lineStart: `${CSI}1K`,
|
|
4160
|
+
lines(count) {
|
|
4161
|
+
let clear = "";
|
|
4162
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
4163
|
+
if (count) clear += cursor.left;
|
|
4164
|
+
return clear;
|
|
4165
|
+
}
|
|
4166
|
+
},
|
|
4167
|
+
beep
|
|
4168
|
+
};
|
|
4169
|
+
}));
|
|
4170
|
+
var import_picocolors_browser$1 = /* @__PURE__ */ __toESM(require_picocolors_browser(), 1);
|
|
4171
|
+
var import_src$1 = require_src();
|
|
4172
|
+
var at = (t$1) => t$1 === 161 || t$1 === 164 || t$1 === 167 || t$1 === 168 || t$1 === 170 || t$1 === 173 || t$1 === 174 || t$1 >= 176 && t$1 <= 180 || t$1 >= 182 && t$1 <= 186 || t$1 >= 188 && t$1 <= 191 || t$1 === 198 || t$1 === 208 || t$1 === 215 || t$1 === 216 || t$1 >= 222 && t$1 <= 225 || t$1 === 230 || t$1 >= 232 && t$1 <= 234 || t$1 === 236 || t$1 === 237 || t$1 === 240 || t$1 === 242 || t$1 === 243 || t$1 >= 247 && t$1 <= 250 || t$1 === 252 || t$1 === 254 || t$1 === 257 || t$1 === 273 || t$1 === 275 || t$1 === 283 || t$1 === 294 || t$1 === 295 || t$1 === 299 || t$1 >= 305 && t$1 <= 307 || t$1 === 312 || t$1 >= 319 && t$1 <= 322 || t$1 === 324 || t$1 >= 328 && t$1 <= 331 || t$1 === 333 || t$1 === 338 || t$1 === 339 || t$1 === 358 || t$1 === 359 || t$1 === 363 || t$1 === 462 || t$1 === 464 || t$1 === 466 || t$1 === 468 || t$1 === 470 || t$1 === 472 || t$1 === 474 || t$1 === 476 || t$1 === 593 || t$1 === 609 || t$1 === 708 || t$1 === 711 || t$1 >= 713 && t$1 <= 715 || t$1 === 717 || t$1 === 720 || t$1 >= 728 && t$1 <= 731 || t$1 === 733 || t$1 === 735 || t$1 >= 768 && t$1 <= 879 || t$1 >= 913 && t$1 <= 929 || t$1 >= 931 && t$1 <= 937 || t$1 >= 945 && t$1 <= 961 || t$1 >= 963 && t$1 <= 969 || t$1 === 1025 || t$1 >= 1040 && t$1 <= 1103 || t$1 === 1105 || t$1 === 8208 || t$1 >= 8211 && t$1 <= 8214 || t$1 === 8216 || t$1 === 8217 || t$1 === 8220 || t$1 === 8221 || t$1 >= 8224 && t$1 <= 8226 || t$1 >= 8228 && t$1 <= 8231 || t$1 === 8240 || t$1 === 8242 || t$1 === 8243 || t$1 === 8245 || t$1 === 8251 || t$1 === 8254 || t$1 === 8308 || t$1 === 8319 || t$1 >= 8321 && t$1 <= 8324 || t$1 === 8364 || t$1 === 8451 || t$1 === 8453 || t$1 === 8457 || t$1 === 8467 || t$1 === 8470 || t$1 === 8481 || t$1 === 8482 || t$1 === 8486 || t$1 === 8491 || t$1 === 8531 || t$1 === 8532 || t$1 >= 8539 && t$1 <= 8542 || t$1 >= 8544 && t$1 <= 8555 || t$1 >= 8560 && t$1 <= 8569 || t$1 === 8585 || t$1 >= 8592 && t$1 <= 8601 || t$1 === 8632 || t$1 === 8633 || t$1 === 8658 || t$1 === 8660 || t$1 === 8679 || t$1 === 8704 || t$1 === 8706 || t$1 === 8707 || t$1 === 8711 || t$1 === 8712 || t$1 === 8715 || t$1 === 8719 || t$1 === 8721 || t$1 === 8725 || t$1 === 8730 || t$1 >= 8733 && t$1 <= 8736 || t$1 === 8739 || t$1 === 8741 || t$1 >= 8743 && t$1 <= 8748 || t$1 === 8750 || t$1 >= 8756 && t$1 <= 8759 || t$1 === 8764 || t$1 === 8765 || t$1 === 8776 || t$1 === 8780 || t$1 === 8786 || t$1 === 8800 || t$1 === 8801 || t$1 >= 8804 && t$1 <= 8807 || t$1 === 8810 || t$1 === 8811 || t$1 === 8814 || t$1 === 8815 || t$1 === 8834 || t$1 === 8835 || t$1 === 8838 || t$1 === 8839 || t$1 === 8853 || t$1 === 8857 || t$1 === 8869 || t$1 === 8895 || t$1 === 8978 || t$1 >= 9312 && t$1 <= 9449 || t$1 >= 9451 && t$1 <= 9547 || t$1 >= 9552 && t$1 <= 9587 || t$1 >= 9600 && t$1 <= 9615 || t$1 >= 9618 && t$1 <= 9621 || t$1 === 9632 || t$1 === 9633 || t$1 >= 9635 && t$1 <= 9641 || t$1 === 9650 || t$1 === 9651 || t$1 === 9654 || t$1 === 9655 || t$1 === 9660 || t$1 === 9661 || t$1 === 9664 || t$1 === 9665 || t$1 >= 9670 && t$1 <= 9672 || t$1 === 9675 || t$1 >= 9678 && t$1 <= 9681 || t$1 >= 9698 && t$1 <= 9701 || t$1 === 9711 || t$1 === 9733 || t$1 === 9734 || t$1 === 9737 || t$1 === 9742 || t$1 === 9743 || t$1 === 9756 || t$1 === 9758 || t$1 === 9792 || t$1 === 9794 || t$1 === 9824 || t$1 === 9825 || t$1 >= 9827 && t$1 <= 9829 || t$1 >= 9831 && t$1 <= 9834 || t$1 === 9836 || t$1 === 9837 || t$1 === 9839 || t$1 === 9886 || t$1 === 9887 || t$1 === 9919 || t$1 >= 9926 && t$1 <= 9933 || t$1 >= 9935 && t$1 <= 9939 || t$1 >= 9941 && t$1 <= 9953 || t$1 === 9955 || t$1 === 9960 || t$1 === 9961 || t$1 >= 9963 && t$1 <= 9969 || t$1 === 9972 || t$1 >= 9974 && t$1 <= 9977 || t$1 === 9979 || t$1 === 9980 || t$1 === 9982 || t$1 === 9983 || t$1 === 10045 || t$1 >= 10102 && t$1 <= 10111 || t$1 >= 11094 && t$1 <= 11097 || t$1 >= 12872 && t$1 <= 12879 || t$1 >= 57344 && t$1 <= 63743 || t$1 >= 65024 && t$1 <= 65039 || t$1 === 65533 || t$1 >= 127232 && t$1 <= 127242 || t$1 >= 127248 && t$1 <= 127277 || t$1 >= 127280 && t$1 <= 127337 || t$1 >= 127344 && t$1 <= 127373 || t$1 === 127375 || t$1 === 127376 || t$1 >= 127387 && t$1 <= 127404 || t$1 >= 917760 && t$1 <= 917999 || t$1 >= 983040 && t$1 <= 1048573 || t$1 >= 1048576 && t$1 <= 1114109, lt = (t$1) => t$1 === 12288 || t$1 >= 65281 && t$1 <= 65376 || t$1 >= 65504 && t$1 <= 65510, ht$1 = (t$1) => t$1 >= 4352 && t$1 <= 4447 || t$1 === 8986 || t$1 === 8987 || t$1 === 9001 || t$1 === 9002 || t$1 >= 9193 && t$1 <= 9196 || t$1 === 9200 || t$1 === 9203 || t$1 === 9725 || t$1 === 9726 || t$1 === 9748 || t$1 === 9749 || t$1 >= 9800 && t$1 <= 9811 || t$1 === 9855 || t$1 === 9875 || t$1 === 9889 || t$1 === 9898 || t$1 === 9899 || t$1 === 9917 || t$1 === 9918 || t$1 === 9924 || t$1 === 9925 || t$1 === 9934 || t$1 === 9940 || t$1 === 9962 || t$1 === 9970 || t$1 === 9971 || t$1 === 9973 || t$1 === 9978 || t$1 === 9981 || t$1 === 9989 || t$1 === 9994 || t$1 === 9995 || t$1 === 10024 || t$1 === 10060 || t$1 === 10062 || t$1 >= 10067 && t$1 <= 10069 || t$1 === 10071 || t$1 >= 10133 && t$1 <= 10135 || t$1 === 10160 || t$1 === 10175 || t$1 === 11035 || t$1 === 11036 || t$1 === 11088 || t$1 === 11093 || t$1 >= 11904 && t$1 <= 11929 || t$1 >= 11931 && t$1 <= 12019 || t$1 >= 12032 && t$1 <= 12245 || t$1 >= 12272 && t$1 <= 12287 || t$1 >= 12289 && t$1 <= 12350 || t$1 >= 12353 && t$1 <= 12438 || t$1 >= 12441 && t$1 <= 12543 || t$1 >= 12549 && t$1 <= 12591 || t$1 >= 12593 && t$1 <= 12686 || t$1 >= 12688 && t$1 <= 12771 || t$1 >= 12783 && t$1 <= 12830 || t$1 >= 12832 && t$1 <= 12871 || t$1 >= 12880 && t$1 <= 19903 || t$1 >= 19968 && t$1 <= 42124 || t$1 >= 42128 && t$1 <= 42182 || t$1 >= 43360 && t$1 <= 43388 || t$1 >= 44032 && t$1 <= 55203 || t$1 >= 63744 && t$1 <= 64255 || t$1 >= 65040 && t$1 <= 65049 || t$1 >= 65072 && t$1 <= 65106 || t$1 >= 65108 && t$1 <= 65126 || t$1 >= 65128 && t$1 <= 65131 || t$1 >= 94176 && t$1 <= 94180 || t$1 === 94192 || t$1 === 94193 || t$1 >= 94208 && t$1 <= 100343 || t$1 >= 100352 && t$1 <= 101589 || t$1 >= 101632 && t$1 <= 101640 || t$1 >= 110576 && t$1 <= 110579 || t$1 >= 110581 && t$1 <= 110587 || t$1 === 110589 || t$1 === 110590 || t$1 >= 110592 && t$1 <= 110882 || t$1 === 110898 || t$1 >= 110928 && t$1 <= 110930 || t$1 === 110933 || t$1 >= 110948 && t$1 <= 110951 || t$1 >= 110960 && t$1 <= 111355 || t$1 === 126980 || t$1 === 127183 || t$1 === 127374 || t$1 >= 127377 && t$1 <= 127386 || t$1 >= 127488 && t$1 <= 127490 || t$1 >= 127504 && t$1 <= 127547 || t$1 >= 127552 && t$1 <= 127560 || t$1 === 127568 || t$1 === 127569 || t$1 >= 127584 && t$1 <= 127589 || t$1 >= 127744 && t$1 <= 127776 || t$1 >= 127789 && t$1 <= 127797 || t$1 >= 127799 && t$1 <= 127868 || t$1 >= 127870 && t$1 <= 127891 || t$1 >= 127904 && t$1 <= 127946 || t$1 >= 127951 && t$1 <= 127955 || t$1 >= 127968 && t$1 <= 127984 || t$1 === 127988 || t$1 >= 127992 && t$1 <= 128062 || t$1 === 128064 || t$1 >= 128066 && t$1 <= 128252 || t$1 >= 128255 && t$1 <= 128317 || t$1 >= 128331 && t$1 <= 128334 || t$1 >= 128336 && t$1 <= 128359 || t$1 === 128378 || t$1 === 128405 || t$1 === 128406 || t$1 === 128420 || t$1 >= 128507 && t$1 <= 128591 || t$1 >= 128640 && t$1 <= 128709 || t$1 === 128716 || t$1 >= 128720 && t$1 <= 128722 || t$1 >= 128725 && t$1 <= 128727 || t$1 >= 128732 && t$1 <= 128735 || t$1 === 128747 || t$1 === 128748 || t$1 >= 128756 && t$1 <= 128764 || t$1 >= 128992 && t$1 <= 129003 || t$1 === 129008 || t$1 >= 129292 && t$1 <= 129338 || t$1 >= 129340 && t$1 <= 129349 || t$1 >= 129351 && t$1 <= 129535 || t$1 >= 129648 && t$1 <= 129660 || t$1 >= 129664 && t$1 <= 129672 || t$1 >= 129680 && t$1 <= 129725 || t$1 >= 129727 && t$1 <= 129733 || t$1 >= 129742 && t$1 <= 129755 || t$1 >= 129760 && t$1 <= 129768 || t$1 >= 129776 && t$1 <= 129784 || t$1 >= 131072 && t$1 <= 196605 || t$1 >= 196608 && t$1 <= 262141, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, M$1 = /\t{1,1000}/y, P$1 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, L = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct$1 = /\p{M}+/gu, pt$1 = {
|
|
4173
|
+
limit: Infinity,
|
|
4174
|
+
ellipsis: ""
|
|
4175
|
+
}, X = (t$1, e = {}, s = {}) => {
|
|
4176
|
+
const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, pt$1, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
|
|
4177
|
+
let h$1 = 0, o = 0, f = t$1.length, v = 0, F = !1, d = f, b = Math.max(0, i - n), C = 0, B = 0, c = 0, p = 0;
|
|
4178
|
+
t: for (;;) {
|
|
4179
|
+
if (B > C || o >= f && o > h$1) {
|
|
4180
|
+
const ut = t$1.slice(C, B) || t$1.slice(h$1, o);
|
|
4181
|
+
v = 0;
|
|
4182
|
+
for (const Y$1 of ut.replaceAll(ct$1, "")) {
|
|
4183
|
+
const $ = Y$1.codePointAt(0) || 0;
|
|
4184
|
+
if (lt($) ? p = m : ht$1($) ? p = V : E !== A && at($) ? p = E : p = A, c + p > b && (d = Math.min(d, Math.max(C, h$1) + v)), c + p > i) {
|
|
4185
|
+
F = !0;
|
|
4186
|
+
break t;
|
|
4187
|
+
}
|
|
4188
|
+
v += Y$1.length, c += p;
|
|
4189
|
+
}
|
|
4190
|
+
C = B = 0;
|
|
4191
|
+
}
|
|
4192
|
+
if (o >= f) break;
|
|
4193
|
+
if (L.lastIndex = o, L.test(t$1)) {
|
|
4194
|
+
if (v = L.lastIndex - o, p = v * A, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + p > i) {
|
|
4195
|
+
F = !0;
|
|
4196
|
+
break;
|
|
4197
|
+
}
|
|
4198
|
+
c += p, C = h$1, B = o, o = h$1 = L.lastIndex;
|
|
4199
|
+
continue;
|
|
4200
|
+
}
|
|
4201
|
+
if (O.lastIndex = o, O.test(t$1)) {
|
|
4202
|
+
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
|
|
4203
|
+
F = !0;
|
|
4204
|
+
break;
|
|
4205
|
+
}
|
|
4206
|
+
c += u, C = h$1, B = o, o = h$1 = O.lastIndex;
|
|
4207
|
+
continue;
|
|
4208
|
+
}
|
|
4209
|
+
if (y.lastIndex = o, y.test(t$1)) {
|
|
4210
|
+
if (v = y.lastIndex - o, p = v * a, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + p > i) {
|
|
4211
|
+
F = !0;
|
|
4212
|
+
break;
|
|
4213
|
+
}
|
|
4214
|
+
c += p, C = h$1, B = o, o = h$1 = y.lastIndex;
|
|
4215
|
+
continue;
|
|
4216
|
+
}
|
|
4217
|
+
if (M$1.lastIndex = o, M$1.test(t$1)) {
|
|
4218
|
+
if (v = M$1.lastIndex - o, p = v * l, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + p > i) {
|
|
4219
|
+
F = !0;
|
|
4220
|
+
break;
|
|
4221
|
+
}
|
|
4222
|
+
c += p, C = h$1, B = o, o = h$1 = M$1.lastIndex;
|
|
4223
|
+
continue;
|
|
4224
|
+
}
|
|
4225
|
+
if (P$1.lastIndex = o, P$1.test(t$1)) {
|
|
4226
|
+
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
|
|
4227
|
+
F = !0;
|
|
4228
|
+
break;
|
|
4229
|
+
}
|
|
4230
|
+
c += g, C = h$1, B = o, o = h$1 = P$1.lastIndex;
|
|
4231
|
+
continue;
|
|
4232
|
+
}
|
|
4233
|
+
o += 1;
|
|
4234
|
+
}
|
|
4235
|
+
return {
|
|
4236
|
+
width: F ? b : c,
|
|
4237
|
+
index: F ? d : f,
|
|
4238
|
+
truncated: F,
|
|
4239
|
+
ellipsed: F && i >= n
|
|
4240
|
+
};
|
|
4241
|
+
}, ft$1 = {
|
|
4242
|
+
limit: Infinity,
|
|
4243
|
+
ellipsis: "",
|
|
4244
|
+
ellipsisWidth: 0
|
|
4245
|
+
}, S = (t$1, e = {}) => X(t$1, ft$1, e).width, W = "\x1B", Z = "", Ft$1 = 39, j = "\x07", Q$1 = "[", dt$1 = "]", tt = "m", U = `${dt$1}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y"), mt$1 = (t$1) => {
|
|
4246
|
+
if (t$1 >= 30 && t$1 <= 37 || t$1 >= 90 && t$1 <= 97) return 39;
|
|
4247
|
+
if (t$1 >= 40 && t$1 <= 47 || t$1 >= 100 && t$1 <= 107) return 49;
|
|
4248
|
+
if (t$1 === 1 || t$1 === 2) return 22;
|
|
4249
|
+
if (t$1 === 3) return 23;
|
|
4250
|
+
if (t$1 === 4) return 24;
|
|
4251
|
+
if (t$1 === 7) return 27;
|
|
4252
|
+
if (t$1 === 8) return 28;
|
|
4253
|
+
if (t$1 === 9) return 29;
|
|
4254
|
+
if (t$1 === 0) return 0;
|
|
4255
|
+
}, st = (t$1) => `${W}${Q$1}${t$1}${tt}`, it = (t$1) => `${W}${U}${t$1}${j}`, gt$1 = (t$1) => t$1.map((e) => S(e)), G$1 = (t$1, e, s) => {
|
|
4256
|
+
const i = e[Symbol.iterator]();
|
|
4257
|
+
let r = !1, n = !1, u = t$1.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
4258
|
+
for (; !l.done;) {
|
|
4259
|
+
const m = l.value, A = S(m);
|
|
4260
|
+
a + A <= s ? t$1[t$1.length - 1] += m : (t$1.push(m), a = 0), (m === W || m === Z) && (r = !0, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t$1.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
4261
|
+
}
|
|
4262
|
+
u = t$1.at(-1), !a && u !== void 0 && u.length > 0 && t$1.length > 1 && (t$1[t$1.length - 2] += t$1.pop());
|
|
4263
|
+
}, vt$1 = (t$1) => {
|
|
4264
|
+
const e = t$1.split(" ");
|
|
4265
|
+
let s = e.length;
|
|
4266
|
+
for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
|
|
4267
|
+
return s === e.length ? t$1 : e.slice(0, s).join(" ") + e.slice(s).join("");
|
|
4268
|
+
}, Et$1 = (t$1, e, s = {}) => {
|
|
4269
|
+
if (s.trim !== !1 && t$1.trim() === "") return "";
|
|
4270
|
+
let i = "", r, n;
|
|
4271
|
+
const u = t$1.split(" "), a = gt$1(u);
|
|
4272
|
+
let l = [""];
|
|
4273
|
+
for (const [h$1, o] of u.entries()) {
|
|
4274
|
+
s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
4275
|
+
let f = S(l.at(-1) ?? "");
|
|
4276
|
+
if (h$1 !== 0 && (f >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), f = 0), (f > 0 || s.trim === !1) && (l[l.length - 1] += " ", f++)), s.hard && a[h$1] > e) {
|
|
4277
|
+
const v = e - f, F = 1 + Math.floor((a[h$1] - v - 1) / e);
|
|
4278
|
+
Math.floor((a[h$1] - 1) / e) < F && l.push(""), G$1(l, o, e);
|
|
4279
|
+
continue;
|
|
4280
|
+
}
|
|
4281
|
+
if (f + a[h$1] > e && f > 0 && a[h$1] > 0) {
|
|
4282
|
+
if (s.wordWrap === !1 && f < e) {
|
|
4283
|
+
G$1(l, o, e);
|
|
4284
|
+
continue;
|
|
4285
|
+
}
|
|
4286
|
+
l.push("");
|
|
4287
|
+
}
|
|
4288
|
+
if (f + a[h$1] > e && s.wordWrap === !1) {
|
|
4289
|
+
G$1(l, o, e);
|
|
4290
|
+
continue;
|
|
4291
|
+
}
|
|
4292
|
+
l[l.length - 1] += o;
|
|
4293
|
+
}
|
|
4294
|
+
s.trim !== !1 && (l = l.map((h$1) => vt$1(h$1)));
|
|
4295
|
+
const E = l.join(`
|
|
4296
|
+
`), g = E[Symbol.iterator]();
|
|
4297
|
+
let m = g.next(), A = g.next(), V = 0;
|
|
4298
|
+
for (; !m.done;) {
|
|
4299
|
+
const h$1 = m.value, o = A.value;
|
|
4300
|
+
if (i += h$1, h$1 === W || h$1 === Z) {
|
|
4301
|
+
et.lastIndex = V + 1;
|
|
4302
|
+
const F = et.exec(E)?.groups;
|
|
4303
|
+
if (F?.code !== void 0) {
|
|
4304
|
+
const d = Number.parseFloat(F.code);
|
|
4305
|
+
r = d === Ft$1 ? void 0 : d;
|
|
4306
|
+
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
4307
|
+
}
|
|
4308
|
+
const f = r ? mt$1(r) : void 0;
|
|
4309
|
+
o === `
|
|
4310
|
+
` ? (n && (i += it("")), r && f && (i += st(f))) : h$1 === `
|
|
4311
|
+
` && (r && f && (i += st(r)), n && (i += it(n))), V += h$1.length, m = A, A = g.next();
|
|
4312
|
+
}
|
|
4313
|
+
return i;
|
|
4314
|
+
};
|
|
4315
|
+
function K$1(t$1, e, s) {
|
|
4316
|
+
return String(t$1).normalize().replaceAll(`\r
|
|
4317
|
+
`, `
|
|
4318
|
+
`).split(`
|
|
4319
|
+
`).map((i) => Et$1(i, e, s)).join(`
|
|
4320
|
+
`);
|
|
4321
|
+
}
|
|
4322
|
+
var _ = {
|
|
4323
|
+
actions: new Set([
|
|
4324
|
+
"up",
|
|
4325
|
+
"down",
|
|
4326
|
+
"left",
|
|
4327
|
+
"right",
|
|
4328
|
+
"space",
|
|
4329
|
+
"enter",
|
|
4330
|
+
"cancel"
|
|
4331
|
+
]),
|
|
4332
|
+
aliases: new Map([
|
|
4333
|
+
["k", "up"],
|
|
4334
|
+
["j", "down"],
|
|
4335
|
+
["h", "left"],
|
|
4336
|
+
["l", "right"],
|
|
4337
|
+
["", "cancel"],
|
|
4338
|
+
["escape", "cancel"]
|
|
4339
|
+
]),
|
|
4340
|
+
messages: {
|
|
4341
|
+
cancel: "Canceled",
|
|
4342
|
+
error: "Something went wrong"
|
|
4343
|
+
},
|
|
4344
|
+
withGuide: !0
|
|
4345
|
+
};
|
|
4346
|
+
function H$1(t$1, e) {
|
|
4347
|
+
if (typeof t$1 == "string") return _.aliases.get(t$1) === e;
|
|
4348
|
+
for (const s of t$1) if (s !== void 0 && H$1(s, e)) return !0;
|
|
4349
|
+
return !1;
|
|
4350
|
+
}
|
|
4351
|
+
function _t$1(t$1, e) {
|
|
4352
|
+
if (t$1 === e) return;
|
|
4353
|
+
const s = t$1.split(`
|
|
4354
|
+
`), i = e.split(`
|
|
4355
|
+
`), r = Math.max(s.length, i.length), n = [];
|
|
4356
|
+
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
|
|
4357
|
+
return {
|
|
4358
|
+
lines: n,
|
|
4359
|
+
numLinesBefore: s.length,
|
|
4360
|
+
numLinesAfter: i.length,
|
|
4361
|
+
numLines: r
|
|
4362
|
+
};
|
|
4363
|
+
}
|
|
4364
|
+
var bt$1 = globalThis.process.platform.startsWith("win"), z$4 = Symbol("clack:cancel");
|
|
4365
|
+
function Ct(t$1) {
|
|
4366
|
+
return t$1 === z$4;
|
|
4367
|
+
}
|
|
4368
|
+
function T(t$1, e) {
|
|
4369
|
+
const s = t$1;
|
|
4370
|
+
s.isTTY && s.setRawMode(e);
|
|
4371
|
+
}
|
|
4372
|
+
function xt({ input: t$1 = node_process.stdin, output: e = node_process.stdout, overwrite: s = !0, hideCursor: i = !0 } = {}) {
|
|
4373
|
+
const r = node_readline.createInterface({
|
|
4374
|
+
input: t$1,
|
|
4375
|
+
output: e,
|
|
4376
|
+
prompt: "",
|
|
4377
|
+
tabSize: 1
|
|
4378
|
+
});
|
|
4379
|
+
node_readline.emitKeypressEvents(t$1, r), t$1 instanceof node_tty.ReadStream && t$1.isTTY && t$1.setRawMode(!0);
|
|
4380
|
+
const n = (u, { name: a, sequence: l }) => {
|
|
4381
|
+
if (H$1([
|
|
4382
|
+
String(u),
|
|
4383
|
+
a,
|
|
4384
|
+
l
|
|
4385
|
+
], "cancel")) {
|
|
4386
|
+
i && e.write(import_src$1.cursor.show), process.exit(0);
|
|
4387
|
+
return;
|
|
4388
|
+
}
|
|
4389
|
+
if (!s) return;
|
|
4390
|
+
const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
4391
|
+
node_readline.moveCursor(e, g, m, () => {
|
|
4392
|
+
node_readline.clearLine(e, 1, () => {
|
|
4393
|
+
t$1.once("keypress", n);
|
|
4394
|
+
});
|
|
4395
|
+
});
|
|
4396
|
+
};
|
|
4397
|
+
return i && e.write(import_src$1.cursor.hide), t$1.once("keypress", n), () => {
|
|
4398
|
+
t$1.off("keypress", n), i && e.write(import_src$1.cursor.show), t$1 instanceof node_tty.ReadStream && t$1.isTTY && !bt$1 && t$1.setRawMode(!1), r.terminal = !1, r.close();
|
|
4399
|
+
};
|
|
4400
|
+
}
|
|
4401
|
+
var rt = (t$1) => "columns" in t$1 && typeof t$1.columns == "number" ? t$1.columns : 80, nt = (t$1) => "rows" in t$1 && typeof t$1.rows == "number" ? t$1.rows : 20;
|
|
4402
|
+
function Bt(t$1, e, s, i = s) {
|
|
4403
|
+
return K$1(e, rt(t$1 ?? node_process.stdout) - s.length, {
|
|
4404
|
+
hard: !0,
|
|
4405
|
+
trim: !1
|
|
4406
|
+
}).split(`
|
|
4407
|
+
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
|
|
4408
|
+
`);
|
|
4409
|
+
}
|
|
4410
|
+
var x$1 = class {
|
|
4411
|
+
input;
|
|
4412
|
+
output;
|
|
4413
|
+
_abortSignal;
|
|
4414
|
+
rl;
|
|
4415
|
+
opts;
|
|
4416
|
+
_render;
|
|
4417
|
+
_track = !1;
|
|
4418
|
+
_prevFrame = "";
|
|
4419
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
4420
|
+
_cursor = 0;
|
|
4421
|
+
state = "initial";
|
|
4422
|
+
error = "";
|
|
4423
|
+
value;
|
|
4424
|
+
userInput = "";
|
|
4425
|
+
constructor(e, s = !0) {
|
|
4426
|
+
const { input: i = node_process.stdin, output: r = node_process.stdout, render: n, signal: u, ...a } = e;
|
|
4427
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
|
|
4428
|
+
}
|
|
4429
|
+
unsubscribe() {
|
|
4430
|
+
this._subscribers.clear();
|
|
4431
|
+
}
|
|
4432
|
+
setSubscriber(e, s) {
|
|
4433
|
+
const i = this._subscribers.get(e) ?? [];
|
|
4434
|
+
i.push(s), this._subscribers.set(e, i);
|
|
4435
|
+
}
|
|
4436
|
+
on(e, s) {
|
|
4437
|
+
this.setSubscriber(e, { cb: s });
|
|
4438
|
+
}
|
|
4439
|
+
once(e, s) {
|
|
4440
|
+
this.setSubscriber(e, {
|
|
4441
|
+
cb: s,
|
|
4442
|
+
once: !0
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
4445
|
+
emit(e, ...s) {
|
|
4446
|
+
const i = this._subscribers.get(e) ?? [], r = [];
|
|
4447
|
+
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
4448
|
+
for (const n of r) n();
|
|
4449
|
+
}
|
|
4450
|
+
prompt() {
|
|
4451
|
+
return new Promise((e) => {
|
|
4452
|
+
if (this._abortSignal) {
|
|
4453
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$4);
|
|
4454
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
4455
|
+
this.state = "cancel", this.close();
|
|
4456
|
+
}, { once: !0 });
|
|
4457
|
+
}
|
|
4458
|
+
this.rl = node_readline.default.createInterface({
|
|
4459
|
+
input: this.input,
|
|
4460
|
+
tabSize: 2,
|
|
4461
|
+
prompt: "",
|
|
4462
|
+
escapeCodeTimeout: 50,
|
|
4463
|
+
terminal: !0
|
|
4464
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), T(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
4465
|
+
this.output.write(import_src$1.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(this.value);
|
|
4466
|
+
}), this.once("cancel", () => {
|
|
4467
|
+
this.output.write(import_src$1.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(z$4);
|
|
4468
|
+
});
|
|
4469
|
+
});
|
|
4470
|
+
}
|
|
4471
|
+
_isActionKey(e, s) {
|
|
4472
|
+
return e === " ";
|
|
4473
|
+
}
|
|
4474
|
+
_setValue(e) {
|
|
4475
|
+
this.value = e, this.emit("value", this.value);
|
|
4476
|
+
}
|
|
4477
|
+
_setUserInput(e, s) {
|
|
4478
|
+
this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
4479
|
+
}
|
|
4480
|
+
_clearUserInput() {
|
|
4481
|
+
this.rl?.write(null, {
|
|
4482
|
+
ctrl: !0,
|
|
4483
|
+
name: "u"
|
|
4484
|
+
}), this._setUserInput("");
|
|
4485
|
+
}
|
|
4486
|
+
onKeypress(e, s) {
|
|
4487
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
|
|
4488
|
+
ctrl: !0,
|
|
4489
|
+
name: "h"
|
|
4490
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
|
|
4491
|
+
if (this.opts.validate) {
|
|
4492
|
+
const i = this.opts.validate(this.value);
|
|
4493
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
4494
|
+
}
|
|
4495
|
+
this.state !== "error" && (this.state = "submit");
|
|
4496
|
+
}
|
|
4497
|
+
H$1([
|
|
4498
|
+
e,
|
|
4499
|
+
s?.name,
|
|
4500
|
+
s?.sequence
|
|
4501
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
4502
|
+
}
|
|
4503
|
+
close() {
|
|
4504
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
4505
|
+
`), T(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
4506
|
+
}
|
|
4507
|
+
restoreCursor() {
|
|
4508
|
+
const e = K$1(this._prevFrame, process.stdout.columns, {
|
|
4509
|
+
hard: !0,
|
|
4510
|
+
trim: !1
|
|
4511
|
+
}).split(`
|
|
4512
|
+
`).length - 1;
|
|
4513
|
+
this.output.write(import_src$1.cursor.move(-999, e * -1));
|
|
4514
|
+
}
|
|
4515
|
+
render() {
|
|
4516
|
+
const e = K$1(this._render(this) ?? "", process.stdout.columns, {
|
|
4517
|
+
hard: !0,
|
|
4518
|
+
trim: !1
|
|
4519
|
+
});
|
|
4520
|
+
if (e !== this._prevFrame) {
|
|
4521
|
+
if (this.state === "initial") this.output.write(import_src$1.cursor.hide);
|
|
4522
|
+
else {
|
|
4523
|
+
const s = _t$1(this._prevFrame, e), i = nt(this.output);
|
|
4524
|
+
if (this.restoreCursor(), s) {
|
|
4525
|
+
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
|
|
4526
|
+
let u = s.lines.find((a) => a >= r);
|
|
4527
|
+
if (u === void 0) {
|
|
4528
|
+
this._prevFrame = e;
|
|
4529
|
+
return;
|
|
4530
|
+
}
|
|
4531
|
+
if (s.lines.length === 1) {
|
|
4532
|
+
this.output.write(import_src$1.cursor.move(0, u - n)), this.output.write(import_src$1.erase.lines(1));
|
|
4533
|
+
const a = e.split(`
|
|
4534
|
+
`);
|
|
4535
|
+
this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src$1.cursor.move(0, a.length - u - 1));
|
|
4536
|
+
return;
|
|
4537
|
+
} else if (s.lines.length > 1) {
|
|
4538
|
+
if (r < n) u = r;
|
|
4539
|
+
else {
|
|
4540
|
+
const l = u - n;
|
|
4541
|
+
l > 0 && this.output.write(import_src$1.cursor.move(0, l));
|
|
4542
|
+
}
|
|
4543
|
+
this.output.write(import_src$1.erase.down());
|
|
4544
|
+
const a = e.split(`
|
|
4545
|
+
`).slice(u);
|
|
4546
|
+
this.output.write(a.join(`
|
|
4547
|
+
`)), this._prevFrame = e;
|
|
4548
|
+
return;
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
this.output.write(import_src$1.erase.down());
|
|
4552
|
+
}
|
|
4553
|
+
this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
};
|
|
4557
|
+
function wt$1(t$1, e) {
|
|
4558
|
+
if (t$1 === void 0 || e.length === 0) return 0;
|
|
4559
|
+
const s = e.findIndex((i) => i.value === t$1);
|
|
4560
|
+
return s !== -1 ? s : 0;
|
|
4561
|
+
}
|
|
4562
|
+
function Dt$1(t$1, e) {
|
|
4563
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(t$1.toLowerCase());
|
|
4564
|
+
}
|
|
4565
|
+
function St$1(t$1, e) {
|
|
4566
|
+
if (e) return t$1 ? e : e[0];
|
|
4567
|
+
}
|
|
4568
|
+
var Vt = class extends x$1 {
|
|
4569
|
+
filteredOptions;
|
|
4570
|
+
multiple;
|
|
4571
|
+
isNavigating = !1;
|
|
4572
|
+
selectedValues = [];
|
|
4573
|
+
focusedValue;
|
|
4574
|
+
#t = 0;
|
|
4575
|
+
#s = "";
|
|
4576
|
+
#i;
|
|
4577
|
+
#e;
|
|
4578
|
+
get cursor() {
|
|
4579
|
+
return this.#t;
|
|
4580
|
+
}
|
|
4581
|
+
get userInputWithCursor() {
|
|
4582
|
+
if (!this.userInput) return import_picocolors_browser$1.default.inverse(import_picocolors_browser$1.default.hidden("_"));
|
|
4583
|
+
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
4584
|
+
const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
|
|
4585
|
+
return `${e}${import_picocolors_browser$1.default.inverse(s)}${i.join("")}`;
|
|
4586
|
+
}
|
|
4587
|
+
get options() {
|
|
4588
|
+
return typeof this.#e == "function" ? this.#e() : this.#e;
|
|
4589
|
+
}
|
|
4590
|
+
constructor(e) {
|
|
4591
|
+
super(e), this.#e = e.options;
|
|
4592
|
+
const s = this.options;
|
|
4593
|
+
this.filteredOptions = [...s], this.multiple = e.multiple === !0, this.#i = e.filter ?? Dt$1;
|
|
4594
|
+
let i;
|
|
4595
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const r of i) {
|
|
4596
|
+
const n = s.findIndex((u) => u.value === r);
|
|
4597
|
+
n !== -1 && (this.toggleSelected(r), this.#t = n);
|
|
4598
|
+
}
|
|
4599
|
+
this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
|
|
4600
|
+
}
|
|
4601
|
+
_isActionKey(e, s) {
|
|
4602
|
+
return e === " " || this.multiple && this.isNavigating && s.name === "space" && e !== void 0 && e !== "";
|
|
4603
|
+
}
|
|
4604
|
+
#r(e, s) {
|
|
4605
|
+
const i = s.name === "up", r = s.name === "down", n = s.name === "return";
|
|
4606
|
+
i || r ? (this.#t = Math.max(0, Math.min(this.#t + (i ? -1 : 1), this.filteredOptions.length - 1)), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = St$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
|
|
4607
|
+
}
|
|
4608
|
+
deselectAll() {
|
|
4609
|
+
this.selectedValues = [];
|
|
4610
|
+
}
|
|
4611
|
+
toggleSelected(e) {
|
|
4612
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
4613
|
+
}
|
|
4614
|
+
#n(e) {
|
|
4615
|
+
if (e !== this.#s) {
|
|
4616
|
+
this.#s = e;
|
|
4617
|
+
const s = this.options;
|
|
4618
|
+
e ? this.filteredOptions = s.filter((i) => this.#i(e, i)) : this.filteredOptions = [...s], this.#t = wt$1(this.focusedValue, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
};
|
|
4622
|
+
var kt = class extends x$1 {
|
|
4623
|
+
get cursor() {
|
|
4624
|
+
return this.value ? 0 : 1;
|
|
4625
|
+
}
|
|
4626
|
+
get _value() {
|
|
4627
|
+
return this.cursor === 0;
|
|
4628
|
+
}
|
|
4629
|
+
constructor(e) {
|
|
4630
|
+
super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
|
|
4631
|
+
this.value = this._value;
|
|
4632
|
+
}), this.on("confirm", (s) => {
|
|
4633
|
+
this.output.write(import_src$1.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
4634
|
+
}), this.on("cursor", () => {
|
|
4635
|
+
this.value = !this.value;
|
|
4636
|
+
});
|
|
4637
|
+
}
|
|
4638
|
+
};
|
|
4639
|
+
var yt = class extends x$1 {
|
|
4640
|
+
options;
|
|
4641
|
+
cursor = 0;
|
|
4642
|
+
#t;
|
|
4643
|
+
getGroupItems(e) {
|
|
4644
|
+
return this.options.filter((s) => s.group === e);
|
|
4645
|
+
}
|
|
4646
|
+
isGroupSelected(e) {
|
|
4647
|
+
const s = this.getGroupItems(e), i = this.value;
|
|
4648
|
+
return i === void 0 ? !1 : s.every((r) => i.includes(r.value));
|
|
4649
|
+
}
|
|
4650
|
+
toggleValue() {
|
|
4651
|
+
const e = this.options[this.cursor];
|
|
4652
|
+
if (this.value === void 0 && (this.value = []), e.group === !0) {
|
|
4653
|
+
const s = e.value, i = this.getGroupItems(s);
|
|
4654
|
+
this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
|
|
4655
|
+
} else this.value = this.value.includes(e.value) ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
|
|
4656
|
+
}
|
|
4657
|
+
constructor(e) {
|
|
4658
|
+
super(e, !1);
|
|
4659
|
+
const { options: s } = e;
|
|
4660
|
+
this.#t = e.selectableGroups !== !1, this.options = Object.entries(s).flatMap(([i, r]) => [{
|
|
4661
|
+
value: i,
|
|
4662
|
+
group: !0,
|
|
4663
|
+
label: i
|
|
4664
|
+
}, ...r.map((n) => ({
|
|
4665
|
+
...n,
|
|
4666
|
+
group: i
|
|
4667
|
+
}))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
|
|
4668
|
+
switch (i) {
|
|
4669
|
+
case "left":
|
|
4670
|
+
case "up": {
|
|
4671
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
4672
|
+
const r = this.options[this.cursor]?.group === !0;
|
|
4673
|
+
!this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
4674
|
+
break;
|
|
4675
|
+
}
|
|
4676
|
+
case "down":
|
|
4677
|
+
case "right": {
|
|
4678
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
4679
|
+
const r = this.options[this.cursor]?.group === !0;
|
|
4680
|
+
!this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
4681
|
+
break;
|
|
4682
|
+
}
|
|
4683
|
+
case "space":
|
|
4684
|
+
this.toggleValue();
|
|
4685
|
+
break;
|
|
4686
|
+
}
|
|
4687
|
+
});
|
|
4688
|
+
}
|
|
4011
4689
|
};
|
|
4690
|
+
function D(t$1, e, s) {
|
|
4691
|
+
const i = t$1 + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
4692
|
+
return s[n].disabled ? D(n, e < 0 ? -1 : 1, s) : n;
|
|
4693
|
+
}
|
|
4694
|
+
var Mt = class extends x$1 {
|
|
4695
|
+
options;
|
|
4696
|
+
cursor = 0;
|
|
4697
|
+
get _value() {
|
|
4698
|
+
return this.options[this.cursor].value;
|
|
4699
|
+
}
|
|
4700
|
+
get _enabledOptions() {
|
|
4701
|
+
return this.options.filter((e) => e.disabled !== !0);
|
|
4702
|
+
}
|
|
4703
|
+
toggleAll() {
|
|
4704
|
+
const e = this._enabledOptions;
|
|
4705
|
+
this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
|
|
4706
|
+
}
|
|
4707
|
+
toggleInvert() {
|
|
4708
|
+
const e = this.value;
|
|
4709
|
+
if (!e) return;
|
|
4710
|
+
this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
|
|
4711
|
+
}
|
|
4712
|
+
toggleValue() {
|
|
4713
|
+
this.value === void 0 && (this.value = []);
|
|
4714
|
+
this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
4715
|
+
}
|
|
4716
|
+
constructor(e) {
|
|
4717
|
+
super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
4718
|
+
const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
|
|
4719
|
+
this.cursor = this.options[s].disabled ? D(s, 1, this.options) : s, this.on("key", (i) => {
|
|
4720
|
+
i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
|
|
4721
|
+
}), this.on("cursor", (i) => {
|
|
4722
|
+
switch (i) {
|
|
4723
|
+
case "left":
|
|
4724
|
+
case "up":
|
|
4725
|
+
this.cursor = D(this.cursor, -1, this.options);
|
|
4726
|
+
break;
|
|
4727
|
+
case "down":
|
|
4728
|
+
case "right":
|
|
4729
|
+
this.cursor = D(this.cursor, 1, this.options);
|
|
4730
|
+
break;
|
|
4731
|
+
case "space":
|
|
4732
|
+
this.toggleValue();
|
|
4733
|
+
break;
|
|
4734
|
+
}
|
|
4735
|
+
});
|
|
4736
|
+
}
|
|
4737
|
+
};
|
|
4738
|
+
var Lt = class extends x$1 {
|
|
4739
|
+
_mask = "•";
|
|
4740
|
+
get cursor() {
|
|
4741
|
+
return this._cursor;
|
|
4742
|
+
}
|
|
4743
|
+
get masked() {
|
|
4744
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
4745
|
+
}
|
|
4746
|
+
get userInputWithCursor() {
|
|
4747
|
+
if (this.state === "submit" || this.state === "cancel") return this.masked;
|
|
4748
|
+
const e = this.userInput;
|
|
4749
|
+
if (this.cursor >= e.length) return `${this.masked}${import_picocolors_browser$1.default.inverse(import_picocolors_browser$1.default.hidden("_"))}`;
|
|
4750
|
+
const s = this.masked, i = s.slice(0, this.cursor), r = s.slice(this.cursor);
|
|
4751
|
+
return `${i}${import_picocolors_browser$1.default.inverse(r[0])}${r.slice(1)}`;
|
|
4752
|
+
}
|
|
4753
|
+
clear() {
|
|
4754
|
+
this._clearUserInput();
|
|
4755
|
+
}
|
|
4756
|
+
constructor({ mask: e, ...s }) {
|
|
4757
|
+
super(s), this._mask = e ?? "•", this.on("userInput", (i) => {
|
|
4758
|
+
this._setValue(i);
|
|
4759
|
+
});
|
|
4760
|
+
}
|
|
4761
|
+
};
|
|
4762
|
+
var Wt = class extends x$1 {
|
|
4763
|
+
options;
|
|
4764
|
+
cursor = 0;
|
|
4765
|
+
get _selectedValue() {
|
|
4766
|
+
return this.options[this.cursor];
|
|
4767
|
+
}
|
|
4768
|
+
changeValue() {
|
|
4769
|
+
this.value = this._selectedValue.value;
|
|
4770
|
+
}
|
|
4771
|
+
constructor(e) {
|
|
4772
|
+
super(e, !1), this.options = e.options;
|
|
4773
|
+
const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
|
|
4774
|
+
this.cursor = this.options[i].disabled ? D(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
|
|
4775
|
+
switch (r) {
|
|
4776
|
+
case "left":
|
|
4777
|
+
case "up":
|
|
4778
|
+
this.cursor = D(this.cursor, -1, this.options);
|
|
4779
|
+
break;
|
|
4780
|
+
case "down":
|
|
4781
|
+
case "right":
|
|
4782
|
+
this.cursor = D(this.cursor, 1, this.options);
|
|
4783
|
+
break;
|
|
4784
|
+
}
|
|
4785
|
+
this.changeValue();
|
|
4786
|
+
});
|
|
4787
|
+
}
|
|
4788
|
+
};
|
|
4789
|
+
var Tt = class extends x$1 {
|
|
4790
|
+
options;
|
|
4791
|
+
cursor = 0;
|
|
4792
|
+
constructor(e) {
|
|
4793
|
+
super(e, !1), this.options = e.options;
|
|
4794
|
+
const s = e.caseSensitive === !0, i = this.options.map(({ value: [r] }) => s ? r : r?.toLowerCase());
|
|
4795
|
+
this.cursor = Math.max(i.indexOf(e.initialValue), 0), this.on("key", (r, n) => {
|
|
4796
|
+
if (!r) return;
|
|
4797
|
+
const u = s && n.shift ? r.toUpperCase() : r;
|
|
4798
|
+
if (!i.includes(u)) return;
|
|
4799
|
+
const a = this.options.find(({ value: [l] }) => s ? l === u : l?.toLowerCase() === r);
|
|
4800
|
+
a && (this.value = a.value, this.state = "submit", this.emit("submit"));
|
|
4801
|
+
});
|
|
4802
|
+
}
|
|
4803
|
+
};
|
|
4804
|
+
var $t = class extends x$1 {
|
|
4805
|
+
get userInputWithCursor() {
|
|
4806
|
+
if (this.state === "submit") return this.userInput;
|
|
4807
|
+
const e = this.userInput;
|
|
4808
|
+
if (this.cursor >= e.length) return `${this.userInput}\u2588`;
|
|
4809
|
+
const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
|
|
4810
|
+
return `${s}${import_picocolors_browser$1.default.inverse(i)}${r.join("")}`;
|
|
4811
|
+
}
|
|
4812
|
+
get cursor() {
|
|
4813
|
+
return this._cursor;
|
|
4814
|
+
}
|
|
4815
|
+
constructor(e) {
|
|
4816
|
+
super({
|
|
4817
|
+
...e,
|
|
4818
|
+
initialUserInput: e.initialUserInput ?? e.initialValue
|
|
4819
|
+
}), this.on("userInput", (s) => {
|
|
4820
|
+
this._setValue(s);
|
|
4821
|
+
}), this.on("finalize", () => {
|
|
4822
|
+
this.value || (this.value = e.defaultValue), this.value === void 0 && (this.value = "");
|
|
4823
|
+
});
|
|
4824
|
+
}
|
|
4825
|
+
};
|
|
4826
|
+
var import_picocolors_browser = /* @__PURE__ */ __toESM(require_picocolors_browser(), 1);
|
|
4827
|
+
var import_src = require_src();
|
|
4828
|
+
var import___vite_browser_external = require___vite_browser_external();
|
|
4829
|
+
function ht() {
|
|
4830
|
+
return node_process.default.platform !== "win32" ? node_process.default.env.TERM !== "linux" : !!node_process.default.env.CI || !!node_process.default.env.WT_SESSION || !!node_process.default.env.TERMINUS_SUBLIME || node_process.default.env.ConEmuTask === "{cmd::Cmder}" || node_process.default.env.TERM_PROGRAM === "Terminus-Sublime" || node_process.default.env.TERM_PROGRAM === "vscode" || node_process.default.env.TERM === "xterm-256color" || node_process.default.env.TERM === "alacritty" || node_process.default.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
4831
|
+
}
|
|
4832
|
+
var ee = ht(), ue = () => process.env.CI === "true", Te = (e) => e.isTTY === !0, w = (e, r) => ee ? e : r, Me = w("◆", "*"), ce = w("■", "x"), de = w("▲", "x"), k = w("◇", "o"), $e = w("┌", "T"), h = w("│", "|"), x = w("└", "—"), Re = w("┐", "T"), Oe = w("┘", "—"), Y = w("●", ">"), K = w("○", " "), te = w("◻", "[•]"), G = w("◼", "[+]"), z$3 = w("◻", "[ ]"), Pe = w("▪", "•"), se = w("─", "-"), he = w("╮", "+"), Ne = w("├", "+"), me = w("╯", "+"), pe = w("╰", "+"), We = w("╭", "+"), ge = w("●", "•"), fe = w("◆", "*"), Fe = w("▲", "!"), ye = w("■", "x"), N = (e) => {
|
|
4833
|
+
switch (e) {
|
|
4834
|
+
case "initial":
|
|
4835
|
+
case "active": return import_picocolors_browser.default.cyan(Me);
|
|
4836
|
+
case "cancel": return import_picocolors_browser.default.red(ce);
|
|
4837
|
+
case "error": return import_picocolors_browser.default.yellow(de);
|
|
4838
|
+
case "submit": return import_picocolors_browser.default.green(k);
|
|
4839
|
+
}
|
|
4840
|
+
}, Ee = (e) => {
|
|
4841
|
+
switch (e) {
|
|
4842
|
+
case "initial":
|
|
4843
|
+
case "active": return import_picocolors_browser.default.cyan(h);
|
|
4844
|
+
case "cancel": return import_picocolors_browser.default.red(h);
|
|
4845
|
+
case "error": return import_picocolors_browser.default.yellow(h);
|
|
4846
|
+
case "submit": return import_picocolors_browser.default.green(h);
|
|
4847
|
+
}
|
|
4848
|
+
}, mt = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, pt = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, gt = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, ve = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, ie = /\t{1,1000}/y, Ae = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ft = /\p{M}+/gu, Ft = {
|
|
4849
|
+
limit: Infinity,
|
|
4850
|
+
ellipsis: ""
|
|
4851
|
+
}, Le = (e, r = {}, s = {}) => {
|
|
4852
|
+
const i = r.limit ?? Infinity, n = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (n ? Le(n, Ft, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, a = s.tabWidth ?? 8, d = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, E = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, y$1 = s.wideWidth ?? 2;
|
|
4853
|
+
let $ = 0, c = 0, m = e.length, f = 0, F = !1, v = m, S$1 = Math.max(0, i - o), B = 0, b = 0, A = 0, C = 0;
|
|
4854
|
+
e: for (;;) {
|
|
4855
|
+
if (b > B || c >= m && c > $) {
|
|
4856
|
+
const _$1 = e.slice(B, b) || e.slice($, c);
|
|
4857
|
+
f = 0;
|
|
4858
|
+
for (const D$1 of _$1.replaceAll(ft, "")) {
|
|
4859
|
+
const T$1 = D$1.codePointAt(0) || 0;
|
|
4860
|
+
if (pt(T$1) ? C = E : gt(T$1) ? C = y$1 : d !== p && mt(T$1) ? C = d : C = p, A + C > S$1 && (v = Math.min(v, Math.max(B, $) + f)), A + C > i) {
|
|
4861
|
+
F = !0;
|
|
4862
|
+
break e;
|
|
4863
|
+
}
|
|
4864
|
+
f += D$1.length, A += C;
|
|
4865
|
+
}
|
|
4866
|
+
B = b = 0;
|
|
4867
|
+
}
|
|
4868
|
+
if (c >= m) break;
|
|
4869
|
+
if (ne.lastIndex = c, ne.test(e)) {
|
|
4870
|
+
if (f = ne.lastIndex - c, C = f * p, A + C > S$1 && (v = Math.min(v, c + Math.floor((S$1 - A) / p))), A + C > i) {
|
|
4871
|
+
F = !0;
|
|
4872
|
+
break;
|
|
4873
|
+
}
|
|
4874
|
+
A += C, B = $, b = c, c = $ = ne.lastIndex;
|
|
4875
|
+
continue;
|
|
4876
|
+
}
|
|
4877
|
+
if (ve.lastIndex = c, ve.test(e)) {
|
|
4878
|
+
if (A + u > S$1 && (v = Math.min(v, c)), A + u > i) {
|
|
4879
|
+
F = !0;
|
|
4880
|
+
break;
|
|
4881
|
+
}
|
|
4882
|
+
A += u, B = $, b = c, c = $ = ve.lastIndex;
|
|
4883
|
+
continue;
|
|
4884
|
+
}
|
|
4885
|
+
if (re.lastIndex = c, re.test(e)) {
|
|
4886
|
+
if (f = re.lastIndex - c, C = f * l, A + C > S$1 && (v = Math.min(v, c + Math.floor((S$1 - A) / l))), A + C > i) {
|
|
4887
|
+
F = !0;
|
|
4888
|
+
break;
|
|
4889
|
+
}
|
|
4890
|
+
A += C, B = $, b = c, c = $ = re.lastIndex;
|
|
4891
|
+
continue;
|
|
4892
|
+
}
|
|
4893
|
+
if (ie.lastIndex = c, ie.test(e)) {
|
|
4894
|
+
if (f = ie.lastIndex - c, C = f * a, A + C > S$1 && (v = Math.min(v, c + Math.floor((S$1 - A) / a))), A + C > i) {
|
|
4895
|
+
F = !0;
|
|
4896
|
+
break;
|
|
4897
|
+
}
|
|
4898
|
+
A += C, B = $, b = c, c = $ = ie.lastIndex;
|
|
4899
|
+
continue;
|
|
4900
|
+
}
|
|
4901
|
+
if (Ae.lastIndex = c, Ae.test(e)) {
|
|
4902
|
+
if (A + g > S$1 && (v = Math.min(v, c)), A + g > i) {
|
|
4903
|
+
F = !0;
|
|
4904
|
+
break;
|
|
4905
|
+
}
|
|
4906
|
+
A += g, B = $, b = c, c = $ = Ae.lastIndex;
|
|
4907
|
+
continue;
|
|
4908
|
+
}
|
|
4909
|
+
c += 1;
|
|
4910
|
+
}
|
|
4911
|
+
return {
|
|
4912
|
+
width: F ? S$1 : A,
|
|
4913
|
+
index: F ? v : m,
|
|
4914
|
+
truncated: F,
|
|
4915
|
+
ellipsed: F && i >= o
|
|
4916
|
+
};
|
|
4917
|
+
}, yt$1 = {
|
|
4918
|
+
limit: Infinity,
|
|
4919
|
+
ellipsis: "",
|
|
4920
|
+
ellipsisWidth: 0
|
|
4921
|
+
}, M = (e, r = {}) => Le(e, yt$1, r).width, ae = "\x1B", je = "", Et = 39, Ce = "\x07", Ve = "[", vt = "]", ke = "m", we = `${vt}8;;`, Ge = new RegExp(`(?:\\${Ve}(?<code>\\d+)m|\\${we}(?<uri>.*)${Ce})`, "y"), At = (e) => {
|
|
4922
|
+
if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
|
|
4923
|
+
if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
|
|
4924
|
+
if (e === 1 || e === 2) return 22;
|
|
4925
|
+
if (e === 3) return 23;
|
|
4926
|
+
if (e === 4) return 24;
|
|
4927
|
+
if (e === 7) return 27;
|
|
4928
|
+
if (e === 8) return 28;
|
|
4929
|
+
if (e === 9) return 29;
|
|
4930
|
+
if (e === 0) return 0;
|
|
4931
|
+
}, He = (e) => `${ae}${Ve}${e}${ke}`, Ue = (e) => `${ae}${we}${e}${Ce}`, Ct$1 = (e) => e.map((r) => M(r)), Se = (e, r, s) => {
|
|
4932
|
+
const i = r[Symbol.iterator]();
|
|
4933
|
+
let n = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : M(u), a = i.next(), d = i.next(), g = 0;
|
|
4934
|
+
for (; !a.done;) {
|
|
4935
|
+
const E = a.value, p = M(E);
|
|
4936
|
+
l + p <= s ? e[e.length - 1] += E : (e.push(E), l = 0), (E === ae || E === je) && (n = !0, o = r.startsWith(we, g + 1)), n ? o ? E === Ce && (n = !1, o = !1) : E === ke && (n = !1) : (l += p, l === s && !d.done && (e.push(""), l = 0)), a = d, d = i.next(), g += E.length;
|
|
4937
|
+
}
|
|
4938
|
+
u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
|
|
4939
|
+
}, wt = (e) => {
|
|
4940
|
+
const r = e.split(" ");
|
|
4941
|
+
let s = r.length;
|
|
4942
|
+
for (; s > 0 && !(M(r[s - 1]) > 0);) s--;
|
|
4943
|
+
return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
4944
|
+
}, St = (e, r, s = {}) => {
|
|
4945
|
+
if (s.trim !== !1 && e.trim() === "") return "";
|
|
4946
|
+
let i = "", n, o;
|
|
4947
|
+
const u = e.split(" "), l = Ct$1(u);
|
|
4948
|
+
let a = [""];
|
|
4949
|
+
for (const [$, c] of u.entries()) {
|
|
4950
|
+
s.trim !== !1 && (a[a.length - 1] = (a.at(-1) ?? "").trimStart());
|
|
4951
|
+
let m = M(a.at(-1) ?? "");
|
|
4952
|
+
if ($ !== 0 && (m >= r && (s.wordWrap === !1 || s.trim === !1) && (a.push(""), m = 0), (m > 0 || s.trim === !1) && (a[a.length - 1] += " ", m++)), s.hard && l[$] > r) {
|
|
4953
|
+
const f = r - m, F = 1 + Math.floor((l[$] - f - 1) / r);
|
|
4954
|
+
Math.floor((l[$] - 1) / r) < F && a.push(""), Se(a, c, r);
|
|
4955
|
+
continue;
|
|
4956
|
+
}
|
|
4957
|
+
if (m + l[$] > r && m > 0 && l[$] > 0) {
|
|
4958
|
+
if (s.wordWrap === !1 && m < r) {
|
|
4959
|
+
Se(a, c, r);
|
|
4960
|
+
continue;
|
|
4961
|
+
}
|
|
4962
|
+
a.push("");
|
|
4963
|
+
}
|
|
4964
|
+
if (m + l[$] > r && s.wordWrap === !1) {
|
|
4965
|
+
Se(a, c, r);
|
|
4966
|
+
continue;
|
|
4967
|
+
}
|
|
4968
|
+
a[a.length - 1] += c;
|
|
4969
|
+
}
|
|
4970
|
+
s.trim !== !1 && (a = a.map(($) => wt($)));
|
|
4971
|
+
const d = a.join(`
|
|
4972
|
+
`), g = d[Symbol.iterator]();
|
|
4973
|
+
let E = g.next(), p = g.next(), y$1 = 0;
|
|
4974
|
+
for (; !E.done;) {
|
|
4975
|
+
const $ = E.value, c = p.value;
|
|
4976
|
+
if (i += $, $ === ae || $ === je) {
|
|
4977
|
+
Ge.lastIndex = y$1 + 1;
|
|
4978
|
+
const F = Ge.exec(d)?.groups;
|
|
4979
|
+
if (F?.code !== void 0) {
|
|
4980
|
+
const v = Number.parseFloat(F.code);
|
|
4981
|
+
n = v === Et ? void 0 : v;
|
|
4982
|
+
} else F?.uri !== void 0 && (o = F.uri.length === 0 ? void 0 : F.uri);
|
|
4983
|
+
}
|
|
4984
|
+
const m = n ? At(n) : void 0;
|
|
4985
|
+
c === `
|
|
4986
|
+
` ? (o && (i += Ue("")), n && m && (i += He(m))) : $ === `
|
|
4987
|
+
` && (n && m && (i += He(n)), o && (i += Ue(o))), y$1 += $.length, E = p, p = g.next();
|
|
4988
|
+
}
|
|
4989
|
+
return i;
|
|
4990
|
+
};
|
|
4991
|
+
function q(e, r, s) {
|
|
4992
|
+
return String(e).normalize().replaceAll(`\r
|
|
4993
|
+
`, `
|
|
4994
|
+
`).split(`
|
|
4995
|
+
`).map((i) => St(i, r, s)).join(`
|
|
4996
|
+
`);
|
|
4997
|
+
}
|
|
4998
|
+
var It$1 = (e, r, s, i, n) => {
|
|
4999
|
+
let o = r, u = 0;
|
|
5000
|
+
for (let l = s; l < i; l++) {
|
|
5001
|
+
const a = e[l];
|
|
5002
|
+
if (o = o - a.length, u++, o <= n) break;
|
|
5003
|
+
}
|
|
5004
|
+
return {
|
|
5005
|
+
lineCount: o,
|
|
5006
|
+
removals: u
|
|
5007
|
+
};
|
|
5008
|
+
}, J = (e) => {
|
|
5009
|
+
const { cursor: r, options: s, style: i } = e, n = e.output ?? process.stdout, o = rt(n), u = e.columnPadding ?? 0, l = e.rowPadding ?? 4, a = o - u, d = nt(n), g = import_picocolors_browser.default.dim("..."), E = e.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(d - l, 0), y$1 = Math.max(Math.min(E, p), 5);
|
|
5010
|
+
let $ = 0;
|
|
5011
|
+
r >= y$1 - 3 && ($ = Math.max(Math.min(r - y$1 + 3, s.length - y$1), 0));
|
|
5012
|
+
let c = y$1 < s.length && $ > 0, m = y$1 < s.length && $ + y$1 < s.length;
|
|
5013
|
+
const f = Math.min($ + y$1, s.length), F = [];
|
|
5014
|
+
let v = 0;
|
|
5015
|
+
c && v++, m && v++;
|
|
5016
|
+
const S$1 = $ + (c ? 1 : 0), B = f - (m ? 1 : 0);
|
|
5017
|
+
for (let A = S$1; A < B; A++) {
|
|
5018
|
+
const C = q(i(s[A], A === r), a, {
|
|
5019
|
+
hard: !0,
|
|
5020
|
+
trim: !1
|
|
5021
|
+
}).split(`
|
|
5022
|
+
`);
|
|
5023
|
+
F.push(C), v += C.length;
|
|
5024
|
+
}
|
|
5025
|
+
if (v > p) {
|
|
5026
|
+
let A = 0, C = 0, _$1 = v;
|
|
5027
|
+
const D$1 = r - S$1, T$1 = (W$1, I$1) => It$1(F, _$1, W$1, I$1, p);
|
|
5028
|
+
c ? ({lineCount: _$1, removals: A} = T$1(0, D$1), _$1 > p && ({lineCount: _$1, removals: C} = T$1(D$1 + 1, F.length))) : ({lineCount: _$1, removals: C} = T$1(D$1 + 1, F.length), _$1 > p && ({lineCount: _$1, removals: A} = T$1(0, D$1))), A > 0 && (c = !0, F.splice(0, A)), C > 0 && (m = !0, F.splice(F.length - C, C));
|
|
5029
|
+
}
|
|
5030
|
+
const b = [];
|
|
5031
|
+
c && b.push(g);
|
|
5032
|
+
for (const A of F) for (const C of A) b.push(C);
|
|
5033
|
+
return m && b.push(g), b;
|
|
5034
|
+
};
|
|
5035
|
+
function Ke(e) {
|
|
5036
|
+
return e.label ?? String(e.value ?? "");
|
|
5037
|
+
}
|
|
5038
|
+
function qe(e, r) {
|
|
5039
|
+
if (!e) return !0;
|
|
5040
|
+
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), n = String(r.value).toLowerCase(), o = e.toLowerCase();
|
|
5041
|
+
return s.includes(o) || i.includes(o) || n.includes(o);
|
|
5042
|
+
}
|
|
5043
|
+
function Bt$1(e, r) {
|
|
5044
|
+
const s = [];
|
|
5045
|
+
for (const i of r) e.includes(i.value) && s.push(i);
|
|
5046
|
+
return s;
|
|
5047
|
+
}
|
|
5048
|
+
var Je = (e) => new Vt({
|
|
5049
|
+
options: e.options,
|
|
5050
|
+
initialValue: e.initialValue ? [e.initialValue] : void 0,
|
|
5051
|
+
initialUserInput: e.initialUserInput,
|
|
5052
|
+
filter: e.filter ?? ((r, s) => qe(r, s)),
|
|
5053
|
+
signal: e.signal,
|
|
5054
|
+
input: e.input,
|
|
5055
|
+
output: e.output,
|
|
5056
|
+
validate: e.validate,
|
|
5057
|
+
render() {
|
|
5058
|
+
const r = [`${import_picocolors_browser.default.gray(h)}`, `${N(this.state)} ${e.message}`], s = this.userInput, i = this.options, n = e.placeholder, o = s === "" && n !== void 0;
|
|
5059
|
+
switch (this.state) {
|
|
5060
|
+
case "submit": {
|
|
5061
|
+
const u = Bt$1(this.selectedValues, i), l = u.length > 0 ? ` ${import_picocolors_browser.default.dim(u.map(Ke).join(", "))}` : "";
|
|
5062
|
+
return `${r.join(`
|
|
5063
|
+
`)}
|
|
5064
|
+
${import_picocolors_browser.default.gray(h)}${l}`;
|
|
5065
|
+
}
|
|
5066
|
+
case "cancel": {
|
|
5067
|
+
const u = s ? ` ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(s))}` : "";
|
|
5068
|
+
return `${r.join(`
|
|
5069
|
+
`)}
|
|
5070
|
+
${import_picocolors_browser.default.gray(h)}${u}`;
|
|
5071
|
+
}
|
|
5072
|
+
default: {
|
|
5073
|
+
const u = `${(this.state === "error" ? import_picocolors_browser.default.yellow : import_picocolors_browser.default.cyan)(h)} `, l = (this.state === "error" ? import_picocolors_browser.default.yellow : import_picocolors_browser.default.cyan)(x);
|
|
5074
|
+
let a = "";
|
|
5075
|
+
if (this.isNavigating || o) {
|
|
5076
|
+
const c = o ? n : s;
|
|
5077
|
+
a = c !== "" ? ` ${import_picocolors_browser.default.dim(c)}` : "";
|
|
5078
|
+
} else a = ` ${this.userInputWithCursor}`;
|
|
5079
|
+
const d = this.filteredOptions.length !== i.length ? import_picocolors_browser.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", g = this.filteredOptions.length === 0 && s ? [`${u}${import_picocolors_browser.default.yellow("No matches found")}`] : [], E = this.state === "error" ? [`${u}${import_picocolors_browser.default.yellow(this.error)}`] : [];
|
|
5080
|
+
r.push(`${u.trimEnd()}`, `${u}${import_picocolors_browser.default.dim("Search:")}${a}${d}`, ...g, ...E);
|
|
5081
|
+
const p = [
|
|
5082
|
+
`${import_picocolors_browser.default.dim("↑/↓")} to select`,
|
|
5083
|
+
`${import_picocolors_browser.default.dim("Enter:")} confirm`,
|
|
5084
|
+
`${import_picocolors_browser.default.dim("Type:")} to search`
|
|
5085
|
+
], y$1 = [`${u}${import_picocolors_browser.default.dim(p.join(" • "))}`, `${l}`], $ = this.filteredOptions.length === 0 ? [] : J({
|
|
5086
|
+
cursor: this.cursor,
|
|
5087
|
+
options: this.filteredOptions,
|
|
5088
|
+
columnPadding: 3,
|
|
5089
|
+
rowPadding: r.length + y$1.length,
|
|
5090
|
+
style: (c, m) => {
|
|
5091
|
+
const f = Ke(c), F = c.hint && c.value === this.focusedValue ? import_picocolors_browser.default.dim(` (${c.hint})`) : "";
|
|
5092
|
+
return m ? `${import_picocolors_browser.default.green(Y)} ${f}${F}` : `${import_picocolors_browser.default.dim(K)} ${import_picocolors_browser.default.dim(f)}${F}`;
|
|
5093
|
+
},
|
|
5094
|
+
maxItems: e.maxItems,
|
|
5095
|
+
output: e.output
|
|
5096
|
+
});
|
|
5097
|
+
return [
|
|
5098
|
+
...r,
|
|
5099
|
+
...$.map((c) => `${u}${c}`),
|
|
5100
|
+
...y$1
|
|
5101
|
+
].join(`
|
|
5102
|
+
`);
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
}
|
|
5106
|
+
}).prompt(), bt = (e) => {
|
|
5107
|
+
const r = (i, n, o, u) => {
|
|
5108
|
+
const l = o.includes(i.value), a = i.label ?? String(i.value ?? ""), d = i.hint && u !== void 0 && i.value === u ? import_picocolors_browser.default.dim(` (${i.hint})`) : "", g = l ? import_picocolors_browser.default.green(G) : import_picocolors_browser.default.dim(z$3);
|
|
5109
|
+
return n ? `${g} ${a}${d}` : `${g} ${import_picocolors_browser.default.dim(a)}`;
|
|
5110
|
+
}, s = new Vt({
|
|
5111
|
+
options: e.options,
|
|
5112
|
+
multiple: !0,
|
|
5113
|
+
filter: e.filter ?? ((i, n) => qe(i, n)),
|
|
5114
|
+
validate: () => {
|
|
5115
|
+
if (e.required && s.selectedValues.length === 0) return "Please select at least one item";
|
|
5116
|
+
},
|
|
5117
|
+
initialValue: e.initialValues,
|
|
5118
|
+
signal: e.signal,
|
|
5119
|
+
input: e.input,
|
|
5120
|
+
output: e.output,
|
|
5121
|
+
render() {
|
|
5122
|
+
const i = `${import_picocolors_browser.default.gray(h)}
|
|
5123
|
+
${N(this.state)} ${e.message}
|
|
5124
|
+
`, n = this.userInput, o = e.placeholder, u = n === "" && o !== void 0, l = this.isNavigating || u ? import_picocolors_browser.default.dim(u ? o : n) : this.userInputWithCursor, a = this.options, d = this.filteredOptions.length !== a.length ? import_picocolors_browser.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
5125
|
+
switch (this.state) {
|
|
5126
|
+
case "submit": return `${i}${import_picocolors_browser.default.gray(h)} ${import_picocolors_browser.default.dim(`${this.selectedValues.length} items selected`)}`;
|
|
5127
|
+
case "cancel": return `${i}${import_picocolors_browser.default.gray(h)} ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(n))}`;
|
|
5128
|
+
default: {
|
|
5129
|
+
const g = this.state === "error" ? import_picocolors_browser.default.yellow : import_picocolors_browser.default.cyan, E = [
|
|
5130
|
+
`${import_picocolors_browser.default.dim("↑/↓")} to navigate`,
|
|
5131
|
+
`${import_picocolors_browser.default.dim(this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
5132
|
+
`${import_picocolors_browser.default.dim("Enter:")} confirm`,
|
|
5133
|
+
`${import_picocolors_browser.default.dim("Type:")} to search`
|
|
5134
|
+
], p = this.filteredOptions.length === 0 && n ? [`${g(h)} ${import_picocolors_browser.default.yellow("No matches found")}`] : [], y$1 = this.state === "error" ? [`${g(h)} ${import_picocolors_browser.default.yellow(this.error)}`] : [], $ = [
|
|
5135
|
+
...`${i}${g(h)}`.split(`
|
|
5136
|
+
`),
|
|
5137
|
+
`${g(h)} ${import_picocolors_browser.default.dim("Search:")} ${l}${d}`,
|
|
5138
|
+
...p,
|
|
5139
|
+
...y$1
|
|
5140
|
+
], c = [`${g(h)} ${import_picocolors_browser.default.dim(E.join(" • "))}`, `${g(x)}`], m = J({
|
|
5141
|
+
cursor: this.cursor,
|
|
5142
|
+
options: this.filteredOptions,
|
|
5143
|
+
style: (f, F) => r(f, F, this.selectedValues, this.focusedValue),
|
|
5144
|
+
maxItems: e.maxItems,
|
|
5145
|
+
output: e.output,
|
|
5146
|
+
rowPadding: $.length + c.length
|
|
5147
|
+
});
|
|
5148
|
+
return [
|
|
5149
|
+
...$,
|
|
5150
|
+
...m.map((f) => `${g(h)} ${f}`),
|
|
5151
|
+
...c
|
|
5152
|
+
].join(`
|
|
5153
|
+
`);
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
}
|
|
5157
|
+
});
|
|
5158
|
+
return s.prompt();
|
|
5159
|
+
}, xt$1 = [
|
|
5160
|
+
We,
|
|
5161
|
+
he,
|
|
5162
|
+
pe,
|
|
5163
|
+
me
|
|
5164
|
+
], _t = [
|
|
5165
|
+
$e,
|
|
5166
|
+
Re,
|
|
5167
|
+
x,
|
|
5168
|
+
Oe
|
|
5169
|
+
];
|
|
5170
|
+
function Xe(e, r, s, i) {
|
|
5171
|
+
let n = s, o = s;
|
|
5172
|
+
return i === "center" ? n = Math.floor((r - e) / 2) : i === "right" && (n = r - e - s), o = r - n - e, [n, o];
|
|
5173
|
+
}
|
|
5174
|
+
var Dt = (e) => e, Tt$1 = (e = "", r = "", s) => {
|
|
5175
|
+
const i = s?.output ?? process.stdout, n = rt(i), o = 2, u = s?.titlePadding ?? 1, l = s?.contentPadding ?? 2, a = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), d = (s?.withGuide ?? _.withGuide) !== !1 ? `${h} ` : "", g = s?.formatBorder ?? Dt, E = (s?.rounded ? xt$1 : _t).map(g), p = g(se), y$1 = g(h), $ = M(d), c = M(r), m = n - $;
|
|
5176
|
+
let f = Math.floor(n * a) - $;
|
|
5177
|
+
if (s?.width === "auto") {
|
|
5178
|
+
const _$1 = e.split(`
|
|
5179
|
+
`);
|
|
5180
|
+
let D$1 = c + u * 2;
|
|
5181
|
+
for (const W$1 of _$1) {
|
|
5182
|
+
const I$1 = M(W$1) + l * 2;
|
|
5183
|
+
I$1 > D$1 && (D$1 = I$1);
|
|
5184
|
+
}
|
|
5185
|
+
const T$1 = D$1 + o;
|
|
5186
|
+
T$1 < f && (f = T$1);
|
|
5187
|
+
}
|
|
5188
|
+
f % 2 !== 0 && (f < m ? f++ : f--);
|
|
5189
|
+
const F = f - o, v = F - u * 2, S$1 = c > v ? `${r.slice(0, v - 3)}...` : r, [B, b] = Xe(M(S$1), F, u, s?.titleAlign), A = q(e, F - l * 2, {
|
|
5190
|
+
hard: !0,
|
|
5191
|
+
trim: !1
|
|
5192
|
+
});
|
|
5193
|
+
i.write(`${d}${E[0]}${p.repeat(B)}${S$1}${p.repeat(b)}${E[1]}
|
|
5194
|
+
`);
|
|
5195
|
+
const C = A.split(`
|
|
5196
|
+
`);
|
|
5197
|
+
for (const _$1 of C) {
|
|
5198
|
+
const [D$1, T$1] = Xe(M(_$1), F, l, s?.contentAlign);
|
|
5199
|
+
i.write(`${d}${y$1}${" ".repeat(D$1)}${_$1}${" ".repeat(T$1)}${y$1}
|
|
5200
|
+
`);
|
|
5201
|
+
}
|
|
5202
|
+
i.write(`${d}${E[2]}${p.repeat(F)}${E[3]}
|
|
5203
|
+
`);
|
|
5204
|
+
}, Mt$1 = (e) => {
|
|
5205
|
+
const r = e.active ?? "Yes", s = e.inactive ?? "No";
|
|
5206
|
+
return new kt({
|
|
5207
|
+
active: r,
|
|
5208
|
+
inactive: s,
|
|
5209
|
+
signal: e.signal,
|
|
5210
|
+
input: e.input,
|
|
5211
|
+
output: e.output,
|
|
5212
|
+
initialValue: e.initialValue ?? !0,
|
|
5213
|
+
render() {
|
|
5214
|
+
const i = `${import_picocolors_browser.default.gray(h)}
|
|
5215
|
+
${N(this.state)} ${e.message}
|
|
5216
|
+
`, n = this.value ? r : s;
|
|
5217
|
+
switch (this.state) {
|
|
5218
|
+
case "submit": return `${i}${import_picocolors_browser.default.gray(h)} ${import_picocolors_browser.default.dim(n)}`;
|
|
5219
|
+
case "cancel": return `${i}${import_picocolors_browser.default.gray(h)} ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(n))}
|
|
5220
|
+
${import_picocolors_browser.default.gray(h)}`;
|
|
5221
|
+
default: return `${i}${import_picocolors_browser.default.cyan(h)} ${this.value ? `${import_picocolors_browser.default.green(Y)} ${r}` : `${import_picocolors_browser.default.dim(K)} ${import_picocolors_browser.default.dim(r)}`} ${import_picocolors_browser.default.dim("/")} ${this.value ? `${import_picocolors_browser.default.dim(K)} ${import_picocolors_browser.default.dim(s)}` : `${import_picocolors_browser.default.green(Y)} ${s}`}
|
|
5222
|
+
${import_picocolors_browser.default.cyan(x)}
|
|
5223
|
+
`;
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
}).prompt();
|
|
5227
|
+
}, Rt = async (e, r) => {
|
|
5228
|
+
const s = {}, i = Object.keys(e);
|
|
5229
|
+
for (const n of i) {
|
|
5230
|
+
const o = e[n], u = await o({ results: s })?.catch((l) => {
|
|
5231
|
+
throw l;
|
|
5232
|
+
});
|
|
5233
|
+
if (typeof r?.onCancel == "function" && Ct(u)) {
|
|
5234
|
+
s[n] = "canceled", r.onCancel({ results: s });
|
|
5235
|
+
continue;
|
|
5236
|
+
}
|
|
5237
|
+
s[n] = u;
|
|
5238
|
+
}
|
|
5239
|
+
return s;
|
|
5240
|
+
}, Ot = (e) => {
|
|
5241
|
+
const { selectableGroups: r = !0, groupSpacing: s = 0 } = e, i = (o, u, l = []) => {
|
|
5242
|
+
const a = o.label ?? String(o.value), d = typeof o.group == "string", g = d && (l[l.indexOf(o) + 1] ?? { group: !0 }), E = d && g && g.group === !0, p = d ? r ? `${E ? x : h} ` : " " : "";
|
|
5243
|
+
let y$1 = "";
|
|
5244
|
+
if (s > 0 && !d) {
|
|
5245
|
+
const c = `
|
|
5246
|
+
${import_picocolors_browser.default.cyan(h)}`;
|
|
5247
|
+
y$1 = `${c.repeat(s - 1)}${c} `;
|
|
5248
|
+
}
|
|
5249
|
+
if (u === "active") return `${y$1}${import_picocolors_browser.default.dim(p)}${import_picocolors_browser.default.cyan(te)} ${a}${o.hint ? ` ${import_picocolors_browser.default.dim(`(${o.hint})`)}` : ""}`;
|
|
5250
|
+
if (u === "group-active") return `${y$1}${p}${import_picocolors_browser.default.cyan(te)} ${import_picocolors_browser.default.dim(a)}`;
|
|
5251
|
+
if (u === "group-active-selected") return `${y$1}${p}${import_picocolors_browser.default.green(G)} ${import_picocolors_browser.default.dim(a)}`;
|
|
5252
|
+
if (u === "selected") {
|
|
5253
|
+
const c = d || r ? import_picocolors_browser.default.green(G) : "";
|
|
5254
|
+
return `${y$1}${import_picocolors_browser.default.dim(p)}${c} ${import_picocolors_browser.default.dim(a)}${o.hint ? ` ${import_picocolors_browser.default.dim(`(${o.hint})`)}` : ""}`;
|
|
5255
|
+
}
|
|
5256
|
+
if (u === "cancelled") return `${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(a))}`;
|
|
5257
|
+
if (u === "active-selected") return `${y$1}${import_picocolors_browser.default.dim(p)}${import_picocolors_browser.default.green(G)} ${a}${o.hint ? ` ${import_picocolors_browser.default.dim(`(${o.hint})`)}` : ""}`;
|
|
5258
|
+
if (u === "submitted") return `${import_picocolors_browser.default.dim(a)}`;
|
|
5259
|
+
const $ = d || r ? import_picocolors_browser.default.dim(z$3) : "";
|
|
5260
|
+
return `${y$1}${import_picocolors_browser.default.dim(p)}${$} ${import_picocolors_browser.default.dim(a)}`;
|
|
5261
|
+
}, n = e.required ?? !0;
|
|
5262
|
+
return new yt({
|
|
5263
|
+
options: e.options,
|
|
5264
|
+
signal: e.signal,
|
|
5265
|
+
input: e.input,
|
|
5266
|
+
output: e.output,
|
|
5267
|
+
initialValues: e.initialValues,
|
|
5268
|
+
required: n,
|
|
5269
|
+
cursorAt: e.cursorAt,
|
|
5270
|
+
selectableGroups: r,
|
|
5271
|
+
validate(o) {
|
|
5272
|
+
if (n && (o === void 0 || o.length === 0)) return `Please select at least one option.
|
|
5273
|
+
${import_picocolors_browser.default.reset(import_picocolors_browser.default.dim(`Press ${import_picocolors_browser.default.gray(import_picocolors_browser.default.bgWhite(import_picocolors_browser.default.inverse(" space ")))} to select, ${import_picocolors_browser.default.gray(import_picocolors_browser.default.bgWhite(import_picocolors_browser.default.inverse(" enter ")))} to submit`))}`;
|
|
5274
|
+
},
|
|
5275
|
+
render() {
|
|
5276
|
+
const o = `${import_picocolors_browser.default.gray(h)}
|
|
5277
|
+
${N(this.state)} ${e.message}
|
|
5278
|
+
`, u = this.value ?? [];
|
|
5279
|
+
switch (this.state) {
|
|
5280
|
+
case "submit": {
|
|
5281
|
+
const l = this.options.filter(({ value: d }) => u.includes(d)).map((d) => i(d, "submitted")), a = l.length === 0 ? "" : ` ${l.join(import_picocolors_browser.default.dim(", "))}`;
|
|
5282
|
+
return `${o}${import_picocolors_browser.default.gray(h)}${a}`;
|
|
5283
|
+
}
|
|
5284
|
+
case "cancel": {
|
|
5285
|
+
const l = this.options.filter(({ value: a }) => u.includes(a)).map((a) => i(a, "cancelled")).join(import_picocolors_browser.default.dim(", "));
|
|
5286
|
+
return `${o}${import_picocolors_browser.default.gray(h)} ${l.trim() ? `${l}
|
|
5287
|
+
${import_picocolors_browser.default.gray(h)}` : ""}`;
|
|
5288
|
+
}
|
|
5289
|
+
case "error": {
|
|
5290
|
+
const l = this.error.split(`
|
|
5291
|
+
`).map((a, d) => d === 0 ? `${import_picocolors_browser.default.yellow(x)} ${import_picocolors_browser.default.yellow(a)}` : ` ${a}`).join(`
|
|
5292
|
+
`);
|
|
5293
|
+
return `${o}${import_picocolors_browser.default.yellow(h)} ${this.options.map((a, d, g) => {
|
|
5294
|
+
const E = u.includes(a.value) || a.group === !0 && this.isGroupSelected(`${a.value}`), p = d === this.cursor;
|
|
5295
|
+
return !p && typeof a.group == "string" && this.options[this.cursor].value === a.group ? i(a, E ? "group-active-selected" : "group-active", g) : p && E ? i(a, "active-selected", g) : E ? i(a, "selected", g) : i(a, p ? "active" : "inactive", g);
|
|
5296
|
+
}).join(`
|
|
5297
|
+
${import_picocolors_browser.default.yellow(h)} `)}
|
|
5298
|
+
${l}
|
|
5299
|
+
`;
|
|
5300
|
+
}
|
|
5301
|
+
default: {
|
|
5302
|
+
const l = this.options.map((d, g, E) => {
|
|
5303
|
+
const p = u.includes(d.value) || d.group === !0 && this.isGroupSelected(`${d.value}`), y$1 = g === this.cursor, $ = !y$1 && typeof d.group == "string" && this.options[this.cursor].value === d.group;
|
|
5304
|
+
let c = "";
|
|
5305
|
+
return $ ? c = i(d, p ? "group-active-selected" : "group-active", E) : y$1 && p ? c = i(d, "active-selected", E) : p ? c = i(d, "selected", E) : c = i(d, y$1 ? "active" : "inactive", E), `${g !== 0 && !c.startsWith(`
|
|
5306
|
+
`) ? " " : ""}${c}`;
|
|
5307
|
+
}).join(`
|
|
5308
|
+
${import_picocolors_browser.default.cyan(h)}`), a = l.startsWith(`
|
|
5309
|
+
`) ? "" : " ";
|
|
5310
|
+
return `${o}${import_picocolors_browser.default.cyan(h)}${a}${l}
|
|
5311
|
+
${import_picocolors_browser.default.cyan(x)}
|
|
5312
|
+
`;
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
}).prompt();
|
|
5317
|
+
}, R = {
|
|
5318
|
+
message: (e = [], { symbol: r = import_picocolors_browser.default.gray(h), secondarySymbol: s = import_picocolors_browser.default.gray(h), output: i = process.stdout, spacing: n = 1, withGuide: o } = {}) => {
|
|
5319
|
+
const u = [], l = (o ?? _.withGuide) !== !1, a = l ? s : "", d = l ? `${r} ` : "", g = l ? `${s} ` : "";
|
|
5320
|
+
for (let p = 0; p < n; p++) u.push(a);
|
|
5321
|
+
const E = Array.isArray(e) ? e : e.split(`
|
|
5322
|
+
`);
|
|
5323
|
+
if (E.length > 0) {
|
|
5324
|
+
const [p, ...y$1] = E;
|
|
5325
|
+
p.length > 0 ? u.push(`${d}${p}`) : u.push(l ? r : "");
|
|
5326
|
+
for (const $ of y$1) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
|
|
5327
|
+
}
|
|
5328
|
+
i.write(`${u.join(`
|
|
5329
|
+
`)}
|
|
5330
|
+
`);
|
|
5331
|
+
},
|
|
5332
|
+
info: (e, r) => {
|
|
5333
|
+
R.message(e, {
|
|
5334
|
+
...r,
|
|
5335
|
+
symbol: import_picocolors_browser.default.blue(ge)
|
|
5336
|
+
});
|
|
5337
|
+
},
|
|
5338
|
+
success: (e, r) => {
|
|
5339
|
+
R.message(e, {
|
|
5340
|
+
...r,
|
|
5341
|
+
symbol: import_picocolors_browser.default.green(fe)
|
|
5342
|
+
});
|
|
5343
|
+
},
|
|
5344
|
+
step: (e, r) => {
|
|
5345
|
+
R.message(e, {
|
|
5346
|
+
...r,
|
|
5347
|
+
symbol: import_picocolors_browser.default.green(k)
|
|
5348
|
+
});
|
|
5349
|
+
},
|
|
5350
|
+
warn: (e, r) => {
|
|
5351
|
+
R.message(e, {
|
|
5352
|
+
...r,
|
|
5353
|
+
symbol: import_picocolors_browser.default.yellow(Fe)
|
|
5354
|
+
});
|
|
5355
|
+
},
|
|
5356
|
+
warning: (e, r) => {
|
|
5357
|
+
R.warn(e, r);
|
|
5358
|
+
},
|
|
5359
|
+
error: (e, r) => {
|
|
5360
|
+
R.message(e, {
|
|
5361
|
+
...r,
|
|
5362
|
+
symbol: import_picocolors_browser.default.red(ye)
|
|
5363
|
+
});
|
|
5364
|
+
}
|
|
5365
|
+
}, Pt = (e = "", r) => {
|
|
5366
|
+
(r?.output ?? process.stdout).write(`${import_picocolors_browser.default.gray(x)} ${import_picocolors_browser.default.red(e)}
|
|
5367
|
+
|
|
5368
|
+
`);
|
|
5369
|
+
}, Nt = (e = "", r) => {
|
|
5370
|
+
(r?.output ?? process.stdout).write(`${import_picocolors_browser.default.gray($e)} ${e}
|
|
5371
|
+
`);
|
|
5372
|
+
}, Wt$1 = (e = "", r) => {
|
|
5373
|
+
(r?.output ?? process.stdout).write(`${import_picocolors_browser.default.gray(h)}
|
|
5374
|
+
${import_picocolors_browser.default.gray(x)} ${e}
|
|
5375
|
+
|
|
5376
|
+
`);
|
|
5377
|
+
}, Q = (e, r) => e.split(`
|
|
5378
|
+
`).map((s) => r(s)).join(`
|
|
5379
|
+
`), Lt$1 = (e) => {
|
|
5380
|
+
const r = (i, n) => {
|
|
5381
|
+
const o = i.label ?? String(i.value);
|
|
5382
|
+
return n === "disabled" ? `${import_picocolors_browser.default.gray(z$3)} ${Q(o, (u) => import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.gray(u)))}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint ?? "disabled"})`)}` : ""}` : n === "active" ? `${import_picocolors_browser.default.cyan(te)} ${o}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint})`)}` : ""}` : n === "selected" ? `${import_picocolors_browser.default.green(G)} ${Q(o, import_picocolors_browser.default.dim)}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint})`)}` : ""}` : n === "cancelled" ? `${Q(o, (u) => import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(u)))}` : n === "active-selected" ? `${import_picocolors_browser.default.green(G)} ${o}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint})`)}` : ""}` : n === "submitted" ? `${Q(o, import_picocolors_browser.default.dim)}` : `${import_picocolors_browser.default.dim(z$3)} ${Q(o, import_picocolors_browser.default.dim)}`;
|
|
5383
|
+
}, s = e.required ?? !0;
|
|
5384
|
+
return new Mt({
|
|
5385
|
+
options: e.options,
|
|
5386
|
+
signal: e.signal,
|
|
5387
|
+
input: e.input,
|
|
5388
|
+
output: e.output,
|
|
5389
|
+
initialValues: e.initialValues,
|
|
5390
|
+
required: s,
|
|
5391
|
+
cursorAt: e.cursorAt,
|
|
5392
|
+
validate(i) {
|
|
5393
|
+
if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
|
|
5394
|
+
${import_picocolors_browser.default.reset(import_picocolors_browser.default.dim(`Press ${import_picocolors_browser.default.gray(import_picocolors_browser.default.bgWhite(import_picocolors_browser.default.inverse(" space ")))} to select, ${import_picocolors_browser.default.gray(import_picocolors_browser.default.bgWhite(import_picocolors_browser.default.inverse(" enter ")))} to submit`))}`;
|
|
5395
|
+
},
|
|
5396
|
+
render() {
|
|
5397
|
+
const i = Bt(e.output, e.message, `${Ee(this.state)} `, `${N(this.state)} `), n = `${import_picocolors_browser.default.gray(h)}
|
|
5398
|
+
${i}
|
|
5399
|
+
`, o = this.value ?? [], u = (l, a) => {
|
|
5400
|
+
if (l.disabled) return r(l, "disabled");
|
|
5401
|
+
const d = o.includes(l.value);
|
|
5402
|
+
return a && d ? r(l, "active-selected") : d ? r(l, "selected") : r(l, a ? "active" : "inactive");
|
|
5403
|
+
};
|
|
5404
|
+
switch (this.state) {
|
|
5405
|
+
case "submit": {
|
|
5406
|
+
const l = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "submitted")).join(import_picocolors_browser.default.dim(", ")) || import_picocolors_browser.default.dim("none");
|
|
5407
|
+
return `${n}${Bt(e.output, l, `${import_picocolors_browser.default.gray(h)} `)}`;
|
|
5408
|
+
}
|
|
5409
|
+
case "cancel": {
|
|
5410
|
+
const l = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "cancelled")).join(import_picocolors_browser.default.dim(", "));
|
|
5411
|
+
if (l.trim() === "") return `${n}${import_picocolors_browser.default.gray(h)}`;
|
|
5412
|
+
return `${n}${Bt(e.output, l, `${import_picocolors_browser.default.gray(h)} `)}
|
|
5413
|
+
${import_picocolors_browser.default.gray(h)}`;
|
|
5414
|
+
}
|
|
5415
|
+
case "error": {
|
|
5416
|
+
const l = `${import_picocolors_browser.default.yellow(h)} `, a = this.error.split(`
|
|
5417
|
+
`).map((E, p) => p === 0 ? `${import_picocolors_browser.default.yellow(x)} ${import_picocolors_browser.default.yellow(E)}` : ` ${E}`).join(`
|
|
5418
|
+
`), d = n.split(`
|
|
5419
|
+
`).length, g = a.split(`
|
|
5420
|
+
`).length + 1;
|
|
5421
|
+
return `${n}${l}${J({
|
|
5422
|
+
output: e.output,
|
|
5423
|
+
options: this.options,
|
|
5424
|
+
cursor: this.cursor,
|
|
5425
|
+
maxItems: e.maxItems,
|
|
5426
|
+
columnPadding: l.length,
|
|
5427
|
+
rowPadding: d + g,
|
|
5428
|
+
style: u
|
|
5429
|
+
}).join(`
|
|
5430
|
+
${l}`)}
|
|
5431
|
+
${a}
|
|
5432
|
+
`;
|
|
5433
|
+
}
|
|
5434
|
+
default: {
|
|
5435
|
+
const l = `${import_picocolors_browser.default.cyan(h)} `, a = n.split(`
|
|
5436
|
+
`).length;
|
|
5437
|
+
return `${n}${l}${J({
|
|
5438
|
+
output: e.output,
|
|
5439
|
+
options: this.options,
|
|
5440
|
+
cursor: this.cursor,
|
|
5441
|
+
maxItems: e.maxItems,
|
|
5442
|
+
columnPadding: l.length,
|
|
5443
|
+
rowPadding: a + 2,
|
|
5444
|
+
style: u
|
|
5445
|
+
}).join(`
|
|
5446
|
+
${l}`)}
|
|
5447
|
+
${import_picocolors_browser.default.cyan(x)}
|
|
5448
|
+
`;
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
}).prompt();
|
|
5453
|
+
}, jt = (e) => import_picocolors_browser.default.dim(e), Vt$1 = (e, r, s) => {
|
|
5454
|
+
const i = {
|
|
5455
|
+
hard: !0,
|
|
5456
|
+
trim: !1
|
|
5457
|
+
}, n = q(e, r, i).split(`
|
|
5458
|
+
`), o = n.reduce((a, d) => Math.max(M(d), a), 0);
|
|
5459
|
+
return q(e, r - (n.map(s).reduce((a, d) => Math.max(M(d), a), 0) - o), i);
|
|
5460
|
+
}, kt$1 = (e = "", r = "", s) => {
|
|
5461
|
+
const i = s?.output ?? node_process.default.stdout, n = (s?.withGuide ?? _.withGuide) !== !1, o = s?.format ?? jt, u = [
|
|
5462
|
+
"",
|
|
5463
|
+
...Vt$1(e, rt(i) - 6, o).split(`
|
|
5464
|
+
`).map(o),
|
|
5465
|
+
""
|
|
5466
|
+
], l = M(r), a = Math.max(u.reduce((p, y$1) => {
|
|
5467
|
+
const $ = M(y$1);
|
|
5468
|
+
return $ > p ? $ : p;
|
|
5469
|
+
}, 0), l) + 2, d = u.map((p) => `${import_picocolors_browser.default.gray(h)} ${p}${" ".repeat(a - M(p))}${import_picocolors_browser.default.gray(h)}`).join(`
|
|
5470
|
+
`), g = n ? `${import_picocolors_browser.default.gray(h)}
|
|
5471
|
+
` : "", E = n ? Ne : pe;
|
|
5472
|
+
i.write(`${g}${import_picocolors_browser.default.green(k)} ${import_picocolors_browser.default.reset(r)} ${import_picocolors_browser.default.gray(se.repeat(Math.max(a - l - 1, 1)) + he)}
|
|
5473
|
+
${d}
|
|
5474
|
+
${import_picocolors_browser.default.gray(E + se.repeat(a + 2) + me)}
|
|
5475
|
+
`);
|
|
5476
|
+
}, Gt = (e) => new Lt({
|
|
5477
|
+
validate: e.validate,
|
|
5478
|
+
mask: e.mask ?? Pe,
|
|
5479
|
+
signal: e.signal,
|
|
5480
|
+
input: e.input,
|
|
5481
|
+
output: e.output,
|
|
5482
|
+
render() {
|
|
5483
|
+
const r = `${import_picocolors_browser.default.gray(h)}
|
|
5484
|
+
${N(this.state)} ${e.message}
|
|
5485
|
+
`, s = this.userInputWithCursor, i = this.masked;
|
|
5486
|
+
switch (this.state) {
|
|
5487
|
+
case "error": {
|
|
5488
|
+
const n = i ? ` ${i}` : "";
|
|
5489
|
+
return e.clearOnError && this.clear(), `${r.trim()}
|
|
5490
|
+
${import_picocolors_browser.default.yellow(h)}${n}
|
|
5491
|
+
${import_picocolors_browser.default.yellow(x)} ${import_picocolors_browser.default.yellow(this.error)}
|
|
5492
|
+
`;
|
|
5493
|
+
}
|
|
5494
|
+
case "submit": {
|
|
5495
|
+
const n = i ? ` ${import_picocolors_browser.default.dim(i)}` : "";
|
|
5496
|
+
return `${r}${import_picocolors_browser.default.gray(h)}${n}`;
|
|
5497
|
+
}
|
|
5498
|
+
case "cancel": {
|
|
5499
|
+
const n = i ? ` ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(i))}` : "";
|
|
5500
|
+
return `${r}${import_picocolors_browser.default.gray(h)}${n}${i ? `
|
|
5501
|
+
${import_picocolors_browser.default.gray(h)}` : ""}`;
|
|
5502
|
+
}
|
|
5503
|
+
default: return `${r}${import_picocolors_browser.default.cyan(h)} ${s}
|
|
5504
|
+
${import_picocolors_browser.default.cyan(x)}
|
|
5505
|
+
`;
|
|
5506
|
+
}
|
|
5507
|
+
}
|
|
5508
|
+
}).prompt(), Ht = (e) => {
|
|
5509
|
+
const r = e.validate;
|
|
5510
|
+
return Je({
|
|
5511
|
+
...e,
|
|
5512
|
+
initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
|
|
5513
|
+
maxItems: 5,
|
|
5514
|
+
validate(s) {
|
|
5515
|
+
if (!Array.isArray(s)) {
|
|
5516
|
+
if (!s) return "Please select a path";
|
|
5517
|
+
if (r) return r(s);
|
|
5518
|
+
}
|
|
5519
|
+
},
|
|
5520
|
+
options() {
|
|
5521
|
+
const s = this.userInput;
|
|
5522
|
+
if (s === "") return [];
|
|
5523
|
+
try {
|
|
5524
|
+
let i;
|
|
5525
|
+
return (0, node_fs.existsSync)(s) ? (0, node_fs.lstatSync)(s).isDirectory() ? i = s : i = (0, node_path.dirname)(s) : i = (0, node_path.dirname)(s), (0, node_fs.readdirSync)(i).map((n) => {
|
|
5526
|
+
const o = (0, node_path.join)(i, n);
|
|
5527
|
+
return {
|
|
5528
|
+
name: n,
|
|
5529
|
+
path: o,
|
|
5530
|
+
isDirectory: (0, node_fs.lstatSync)(o).isDirectory()
|
|
5531
|
+
};
|
|
5532
|
+
}).filter(({ path: n, isDirectory: o }) => n.startsWith(s) && (e.directory || !o)).map((n) => ({ value: n.path }));
|
|
5533
|
+
} catch {
|
|
5534
|
+
return [];
|
|
5535
|
+
}
|
|
5536
|
+
}
|
|
5537
|
+
});
|
|
5538
|
+
}, Ut = import_picocolors_browser.default.magenta, Ie = ({ indicator: e = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: n, frames: o = ee ? [
|
|
5539
|
+
"◒",
|
|
5540
|
+
"◐",
|
|
5541
|
+
"◓",
|
|
5542
|
+
"◑"
|
|
5543
|
+
] : [
|
|
5544
|
+
"•",
|
|
5545
|
+
"o",
|
|
5546
|
+
"O",
|
|
5547
|
+
"0"
|
|
5548
|
+
], delay: u = ee ? 80 : 120, signal: l, ...a } = {}) => {
|
|
5549
|
+
const d = ue();
|
|
5550
|
+
let g, E, p = !1, y$1 = !1, $ = "", c, m = performance.now();
|
|
5551
|
+
const f = rt(s), F = a?.styleFrame ?? Ut, v = (I$1) => {
|
|
5552
|
+
const O$1 = I$1 > 1 ? n ?? _.messages.error : i ?? _.messages.cancel;
|
|
5553
|
+
y$1 = I$1 === 1, p && (W$1(O$1, I$1), y$1 && typeof r == "function" && r());
|
|
5554
|
+
}, S$1 = () => v(2), B = () => v(1), b = () => {
|
|
5555
|
+
process.on("uncaughtExceptionMonitor", S$1), process.on("unhandledRejection", S$1), process.on("SIGINT", B), process.on("SIGTERM", B), process.on("exit", v), l && l.addEventListener("abort", B);
|
|
5556
|
+
}, A = () => {
|
|
5557
|
+
process.removeListener("uncaughtExceptionMonitor", S$1), process.removeListener("unhandledRejection", S$1), process.removeListener("SIGINT", B), process.removeListener("SIGTERM", B), process.removeListener("exit", v), l && l.removeEventListener("abort", B);
|
|
5558
|
+
}, C = () => {
|
|
5559
|
+
if (c === void 0) return;
|
|
5560
|
+
d && s.write(`
|
|
5561
|
+
`);
|
|
5562
|
+
const I$1 = q(c, f, {
|
|
5563
|
+
hard: !0,
|
|
5564
|
+
trim: !1
|
|
5565
|
+
}).split(`
|
|
5566
|
+
`);
|
|
5567
|
+
I$1.length > 1 && s.write(import_src.cursor.up(I$1.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
|
|
5568
|
+
}, _$1 = (I$1) => I$1.replace(/\.+$/, ""), D$1 = (I$1) => {
|
|
5569
|
+
const O$1 = (performance.now() - I$1) / 1e3, L$1 = Math.floor(O$1 / 60), j$1 = Math.floor(O$1 % 60);
|
|
5570
|
+
return L$1 > 0 ? `[${L$1}m ${j$1}s]` : `[${j$1}s]`;
|
|
5571
|
+
}, T$1 = (I$1 = "") => {
|
|
5572
|
+
p = !0, g = xt({ output: s }), $ = _$1(I$1), m = performance.now(), s.write(`${import_picocolors_browser.default.gray(h)}
|
|
5573
|
+
`);
|
|
5574
|
+
let O$1 = 0, L$1 = 0;
|
|
5575
|
+
b(), E = setInterval(() => {
|
|
5576
|
+
if (d && $ === c) return;
|
|
5577
|
+
C(), c = $;
|
|
5578
|
+
const j$1 = F(o[O$1]);
|
|
5579
|
+
let Z$1;
|
|
5580
|
+
if (d) Z$1 = `${j$1} ${$}...`;
|
|
5581
|
+
else if (e === "timer") Z$1 = `${j$1} ${$} ${D$1(m)}`;
|
|
5582
|
+
else {
|
|
5583
|
+
const Ze = ".".repeat(Math.floor(L$1)).slice(0, 3);
|
|
5584
|
+
Z$1 = `${j$1} ${$}${Ze}`;
|
|
5585
|
+
}
|
|
5586
|
+
const Qe = q(Z$1, f, {
|
|
5587
|
+
hard: !0,
|
|
5588
|
+
trim: !1
|
|
5589
|
+
});
|
|
5590
|
+
s.write(Qe), O$1 = O$1 + 1 < o.length ? O$1 + 1 : 0, L$1 = L$1 < 4 ? L$1 + .125 : 0;
|
|
5591
|
+
}, u);
|
|
5592
|
+
}, W$1 = (I$1 = "", O$1 = 0, L$1 = !1) => {
|
|
5593
|
+
if (!p) return;
|
|
5594
|
+
p = !1, clearInterval(E), C();
|
|
5595
|
+
const j$1 = O$1 === 0 ? import_picocolors_browser.default.green(k) : O$1 === 1 ? import_picocolors_browser.default.red(ce) : import_picocolors_browser.default.red(de);
|
|
5596
|
+
$ = I$1 ?? $, L$1 || (e === "timer" ? s.write(`${j$1} ${$} ${D$1(m)}
|
|
5597
|
+
`) : s.write(`${j$1} ${$}
|
|
5598
|
+
`)), A(), g();
|
|
5599
|
+
};
|
|
5600
|
+
return {
|
|
5601
|
+
start: T$1,
|
|
5602
|
+
stop: (I$1 = "") => W$1(I$1, 0),
|
|
5603
|
+
message: (I$1 = "") => {
|
|
5604
|
+
$ = _$1(I$1 ?? $);
|
|
5605
|
+
},
|
|
5606
|
+
cancel: (I$1 = "") => W$1(I$1, 1),
|
|
5607
|
+
error: (I$1 = "") => W$1(I$1, 2),
|
|
5608
|
+
clear: () => W$1("", 0, !0),
|
|
5609
|
+
get isCancelled() {
|
|
5610
|
+
return y$1;
|
|
5611
|
+
}
|
|
5612
|
+
};
|
|
5613
|
+
}, Ye = {
|
|
5614
|
+
light: w("─", "-"),
|
|
5615
|
+
heavy: w("━", "="),
|
|
5616
|
+
block: w("█", "#")
|
|
5617
|
+
};
|
|
5618
|
+
var oe = (e, r) => e.includes(`
|
|
5619
|
+
`) ? e.split(`
|
|
5620
|
+
`).map((s) => r(s)).join(`
|
|
5621
|
+
`) : r(e), qt = (e) => {
|
|
5622
|
+
const r = (s, i) => {
|
|
5623
|
+
const n = s.label ?? String(s.value);
|
|
5624
|
+
switch (i) {
|
|
5625
|
+
case "disabled": return `${import_picocolors_browser.default.gray(K)} ${oe(n, import_picocolors_browser.default.gray)}${s.hint ? ` ${import_picocolors_browser.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
5626
|
+
case "selected": return `${oe(n, import_picocolors_browser.default.dim)}`;
|
|
5627
|
+
case "active": return `${import_picocolors_browser.default.green(Y)} ${n}${s.hint ? ` ${import_picocolors_browser.default.dim(`(${s.hint})`)}` : ""}`;
|
|
5628
|
+
case "cancelled": return `${oe(n, (o) => import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(o)))}`;
|
|
5629
|
+
default: return `${import_picocolors_browser.default.dim(K)} ${oe(n, import_picocolors_browser.default.dim)}`;
|
|
5630
|
+
}
|
|
5631
|
+
};
|
|
5632
|
+
return new Wt({
|
|
5633
|
+
options: e.options,
|
|
5634
|
+
signal: e.signal,
|
|
5635
|
+
input: e.input,
|
|
5636
|
+
output: e.output,
|
|
5637
|
+
initialValue: e.initialValue,
|
|
5638
|
+
render() {
|
|
5639
|
+
const s = `${N(this.state)} `, i = `${Ee(this.state)} `, n = Bt(e.output, e.message, i, s), o = `${import_picocolors_browser.default.gray(h)}
|
|
5640
|
+
${n}
|
|
5641
|
+
`;
|
|
5642
|
+
switch (this.state) {
|
|
5643
|
+
case "submit": {
|
|
5644
|
+
const u = `${import_picocolors_browser.default.gray(h)} `;
|
|
5645
|
+
return `${o}${Bt(e.output, r(this.options[this.cursor], "selected"), u)}`;
|
|
5646
|
+
}
|
|
5647
|
+
case "cancel": {
|
|
5648
|
+
const u = `${import_picocolors_browser.default.gray(h)} `;
|
|
5649
|
+
return `${o}${Bt(e.output, r(this.options[this.cursor], "cancelled"), u)}
|
|
5650
|
+
${import_picocolors_browser.default.gray(h)}`;
|
|
5651
|
+
}
|
|
5652
|
+
default: {
|
|
5653
|
+
const u = `${import_picocolors_browser.default.cyan(h)} `, l = o.split(`
|
|
5654
|
+
`).length;
|
|
5655
|
+
return `${o}${u}${J({
|
|
5656
|
+
output: e.output,
|
|
5657
|
+
cursor: this.cursor,
|
|
5658
|
+
options: this.options,
|
|
5659
|
+
maxItems: e.maxItems,
|
|
5660
|
+
columnPadding: u.length,
|
|
5661
|
+
rowPadding: l + 2,
|
|
5662
|
+
style: (a, d) => r(a, a.disabled ? "disabled" : d ? "active" : "inactive")
|
|
5663
|
+
}).join(`
|
|
5664
|
+
${u}`)}
|
|
5665
|
+
${import_picocolors_browser.default.cyan(x)}
|
|
5666
|
+
`;
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5670
|
+
}).prompt();
|
|
5671
|
+
}, Jt = (e) => {
|
|
5672
|
+
const r = (s, i = "inactive") => {
|
|
5673
|
+
const n = s.label ?? String(s.value);
|
|
5674
|
+
return i === "selected" ? `${import_picocolors_browser.default.dim(n)}` : i === "cancelled" ? `${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(n))}` : i === "active" ? `${import_picocolors_browser.default.bgCyan(import_picocolors_browser.default.gray(` ${s.value} `))} ${n}${s.hint ? ` ${import_picocolors_browser.default.dim(`(${s.hint})`)}` : ""}` : `${import_picocolors_browser.default.gray(import_picocolors_browser.default.bgWhite(import_picocolors_browser.default.inverse(` ${s.value} `)))} ${n}${s.hint ? ` ${import_picocolors_browser.default.dim(`(${s.hint})`)}` : ""}`;
|
|
5675
|
+
};
|
|
5676
|
+
return new Tt({
|
|
5677
|
+
options: e.options,
|
|
5678
|
+
signal: e.signal,
|
|
5679
|
+
input: e.input,
|
|
5680
|
+
output: e.output,
|
|
5681
|
+
initialValue: e.initialValue,
|
|
5682
|
+
caseSensitive: e.caseSensitive,
|
|
5683
|
+
render() {
|
|
5684
|
+
const s = `${import_picocolors_browser.default.gray(h)}
|
|
5685
|
+
${N(this.state)} ${e.message}
|
|
5686
|
+
`;
|
|
5687
|
+
switch (this.state) {
|
|
5688
|
+
case "submit": {
|
|
5689
|
+
const i = `${import_picocolors_browser.default.gray(h)} `, n = this.options.find((u) => u.value === this.value) ?? e.options[0];
|
|
5690
|
+
return `${s}${Bt(e.output, r(n, "selected"), i)}`;
|
|
5691
|
+
}
|
|
5692
|
+
case "cancel": {
|
|
5693
|
+
const i = `${import_picocolors_browser.default.gray(h)} `;
|
|
5694
|
+
return `${s}${Bt(e.output, r(this.options[0], "cancelled"), i)}
|
|
5695
|
+
${import_picocolors_browser.default.gray(h)}`;
|
|
5696
|
+
}
|
|
5697
|
+
default: {
|
|
5698
|
+
const i = `${import_picocolors_browser.default.cyan(h)} `;
|
|
5699
|
+
return `${s}${this.options.map((o, u) => Bt(e.output, r(o, u === this.cursor ? "active" : "inactive"), i)).join(`
|
|
5700
|
+
`)}
|
|
5701
|
+
${import_picocolors_browser.default.cyan(x)}
|
|
5702
|
+
`;
|
|
5703
|
+
}
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5706
|
+
}).prompt();
|
|
5707
|
+
}, ze = `${import_picocolors_browser.default.gray(h)} `, H = {
|
|
5708
|
+
message: async (e, { symbol: r = import_picocolors_browser.default.gray(h) } = {}) => {
|
|
5709
|
+
process.stdout.write(`${import_picocolors_browser.default.gray(h)}
|
|
5710
|
+
${r} `);
|
|
5711
|
+
let s = 3;
|
|
5712
|
+
for await (let i of e) {
|
|
5713
|
+
i = i.replace(/\n/g, `
|
|
5714
|
+
${ze}`), i.includes(`
|
|
5715
|
+
`) && (s = 3 + (0, import___vite_browser_external.stripVTControlCharacters)(i.slice(i.lastIndexOf(`
|
|
5716
|
+
`))).length);
|
|
5717
|
+
const n = (0, import___vite_browser_external.stripVTControlCharacters)(i).length;
|
|
5718
|
+
s + n < process.stdout.columns ? (s += n, process.stdout.write(i)) : (process.stdout.write(`
|
|
5719
|
+
${ze}${i.trimStart()}`), s = 3 + (0, import___vite_browser_external.stripVTControlCharacters)(i.trimStart()).length);
|
|
5720
|
+
}
|
|
5721
|
+
process.stdout.write(`
|
|
5722
|
+
`);
|
|
5723
|
+
},
|
|
5724
|
+
info: (e) => H.message(e, { symbol: import_picocolors_browser.default.blue(ge) }),
|
|
5725
|
+
success: (e) => H.message(e, { symbol: import_picocolors_browser.default.green(fe) }),
|
|
5726
|
+
step: (e) => H.message(e, { symbol: import_picocolors_browser.default.green(k) }),
|
|
5727
|
+
warn: (e) => H.message(e, { symbol: import_picocolors_browser.default.yellow(Fe) }),
|
|
5728
|
+
warning: (e) => H.warn(e),
|
|
5729
|
+
error: (e) => H.message(e, { symbol: import_picocolors_browser.default.red(ye) })
|
|
5730
|
+
}, Xt = async (e, r) => {
|
|
5731
|
+
for (const s of e) {
|
|
5732
|
+
if (s.enabled === !1) continue;
|
|
5733
|
+
const i = Ie(r);
|
|
5734
|
+
i.start(s.title);
|
|
5735
|
+
const n = await s.task(i.message);
|
|
5736
|
+
i.stop(n || s.title);
|
|
5737
|
+
}
|
|
5738
|
+
}, Yt = (e) => e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), zt = (e) => {
|
|
5739
|
+
const r = e.output ?? process.stdout, s = rt(r), i = import_picocolors_browser.default.gray(h), n = e.spacing ?? 1, o = 3, u = e.retainLog === !0, l = !ue() && Te(r);
|
|
5740
|
+
r.write(`${i}
|
|
5741
|
+
`), r.write(`${import_picocolors_browser.default.green(k)} ${e.title}
|
|
5742
|
+
`);
|
|
5743
|
+
for (let m = 0; m < n; m++) r.write(`${i}
|
|
5744
|
+
`);
|
|
5745
|
+
const a = [{
|
|
5746
|
+
value: "",
|
|
5747
|
+
full: ""
|
|
5748
|
+
}];
|
|
5749
|
+
let d = !1;
|
|
5750
|
+
const g = (m) => {
|
|
5751
|
+
if (a.length === 0) return;
|
|
5752
|
+
let f = 0;
|
|
5753
|
+
m && (f += n + 2);
|
|
5754
|
+
for (const F of a) {
|
|
5755
|
+
const { value: v, result: S$1 } = F;
|
|
5756
|
+
let B = S$1?.message ?? v;
|
|
5757
|
+
if (B.length === 0) continue;
|
|
5758
|
+
S$1 === void 0 && F.header !== void 0 && F.header !== "" && (B += `
|
|
5759
|
+
${F.header}`);
|
|
5760
|
+
const b = B.split(`
|
|
5761
|
+
`).reduce((A, C) => C === "" ? A + 1 : A + Math.ceil((C.length + o) / s), 0);
|
|
5762
|
+
f += b;
|
|
5763
|
+
}
|
|
5764
|
+
f > 0 && (f += 1, r.write(import_src.erase.lines(f)));
|
|
5765
|
+
}, E = (m, f, F) => {
|
|
5766
|
+
const v = F ? `${m.full}
|
|
5767
|
+
${m.value}` : m.value;
|
|
5768
|
+
m.header !== void 0 && m.header !== "" && R.message(m.header.split(`
|
|
5769
|
+
`).map(import_picocolors_browser.default.bold), {
|
|
5770
|
+
output: r,
|
|
5771
|
+
secondarySymbol: i,
|
|
5772
|
+
symbol: i,
|
|
5773
|
+
spacing: 0
|
|
5774
|
+
}), R.message(v.split(`
|
|
5775
|
+
`).map(import_picocolors_browser.default.dim), {
|
|
5776
|
+
output: r,
|
|
5777
|
+
secondarySymbol: i,
|
|
5778
|
+
symbol: i,
|
|
5779
|
+
spacing: f ?? n
|
|
5780
|
+
});
|
|
5781
|
+
}, p = () => {
|
|
5782
|
+
for (const m of a) {
|
|
5783
|
+
const { header: f, value: F, full: v } = m;
|
|
5784
|
+
(f === void 0 || f.length === 0) && F.length === 0 || E(m, void 0, u === !0 && v.length > 0);
|
|
5785
|
+
}
|
|
5786
|
+
}, y$1 = (m, f, F) => {
|
|
5787
|
+
if (g(!1), (F?.raw !== !0 || !d) && m.value !== "" && (m.value += `
|
|
5788
|
+
`), m.value += Yt(f), d = F?.raw === !0, e.limit !== void 0) {
|
|
5789
|
+
const v = m.value.split(`
|
|
5790
|
+
`), S$1 = v.length - e.limit;
|
|
5791
|
+
if (S$1 > 0) {
|
|
5792
|
+
const B = v.splice(0, S$1);
|
|
5793
|
+
u && (m.full += (m.full === "" ? "" : `
|
|
5794
|
+
`) + B.join(`
|
|
5795
|
+
`));
|
|
5796
|
+
}
|
|
5797
|
+
m.value = v.join(`
|
|
5798
|
+
`);
|
|
5799
|
+
}
|
|
5800
|
+
l && $();
|
|
5801
|
+
}, $ = () => {
|
|
5802
|
+
for (const m of a) m.result ? m.result.status === "error" ? R.error(m.result.message, {
|
|
5803
|
+
output: r,
|
|
5804
|
+
secondarySymbol: i,
|
|
5805
|
+
spacing: 0
|
|
5806
|
+
}) : R.success(m.result.message, {
|
|
5807
|
+
output: r,
|
|
5808
|
+
secondarySymbol: i,
|
|
5809
|
+
spacing: 0
|
|
5810
|
+
}) : m.value !== "" && E(m, 0);
|
|
5811
|
+
}, c = (m, f) => {
|
|
5812
|
+
g(!1), m.result = f, l && $();
|
|
5813
|
+
};
|
|
5814
|
+
return {
|
|
5815
|
+
message(m, f) {
|
|
5816
|
+
y$1(a[0], m, f);
|
|
5817
|
+
},
|
|
5818
|
+
group(m) {
|
|
5819
|
+
const f = {
|
|
5820
|
+
header: m,
|
|
5821
|
+
value: "",
|
|
5822
|
+
full: ""
|
|
5823
|
+
};
|
|
5824
|
+
return a.push(f), {
|
|
5825
|
+
message(F, v) {
|
|
5826
|
+
y$1(f, F, v);
|
|
5827
|
+
},
|
|
5828
|
+
error(F) {
|
|
5829
|
+
c(f, {
|
|
5830
|
+
status: "error",
|
|
5831
|
+
message: F
|
|
5832
|
+
});
|
|
5833
|
+
},
|
|
5834
|
+
success(F) {
|
|
5835
|
+
c(f, {
|
|
5836
|
+
status: "success",
|
|
5837
|
+
message: F
|
|
5838
|
+
});
|
|
5839
|
+
}
|
|
5840
|
+
};
|
|
5841
|
+
},
|
|
5842
|
+
error(m, f) {
|
|
5843
|
+
g(!0), R.error(m, {
|
|
5844
|
+
output: r,
|
|
5845
|
+
secondarySymbol: i,
|
|
5846
|
+
spacing: 1
|
|
5847
|
+
}), f?.showLog !== !1 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
5848
|
+
},
|
|
5849
|
+
success(m, f) {
|
|
5850
|
+
g(!0), R.success(m, {
|
|
5851
|
+
output: r,
|
|
5852
|
+
secondarySymbol: i,
|
|
5853
|
+
spacing: 1
|
|
5854
|
+
}), f?.showLog === !0 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
5855
|
+
}
|
|
5856
|
+
};
|
|
5857
|
+
}, Qt = (e) => new $t({
|
|
5858
|
+
validate: e.validate,
|
|
5859
|
+
placeholder: e.placeholder,
|
|
5860
|
+
defaultValue: e.defaultValue,
|
|
5861
|
+
initialValue: e.initialValue,
|
|
5862
|
+
output: e.output,
|
|
5863
|
+
signal: e.signal,
|
|
5864
|
+
input: e.input,
|
|
5865
|
+
render() {
|
|
5866
|
+
const r = (e?.withGuide ?? _.withGuide) !== !1, s = `${`${r ? `${import_picocolors_browser.default.gray(h)}
|
|
5867
|
+
` : ""}${N(this.state)} `}${e.message}
|
|
5868
|
+
`, i = e.placeholder ? import_picocolors_browser.default.inverse(e.placeholder[0]) + import_picocolors_browser.default.dim(e.placeholder.slice(1)) : import_picocolors_browser.default.inverse(import_picocolors_browser.default.hidden("_")), n = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
|
|
5869
|
+
switch (this.state) {
|
|
5870
|
+
case "error": {
|
|
5871
|
+
const u = this.error ? ` ${import_picocolors_browser.default.yellow(this.error)}` : "", l = r ? `${import_picocolors_browser.default.yellow(h)} ` : "", a = r ? import_picocolors_browser.default.yellow(x) : "";
|
|
5872
|
+
return `${s.trim()}
|
|
5873
|
+
${l}${n}
|
|
5874
|
+
${a}${u}
|
|
5875
|
+
`;
|
|
5876
|
+
}
|
|
5877
|
+
case "submit": {
|
|
5878
|
+
const u = o ? ` ${import_picocolors_browser.default.dim(o)}` : "";
|
|
5879
|
+
return `${s}${r ? import_picocolors_browser.default.gray(h) : ""}${u}`;
|
|
5880
|
+
}
|
|
5881
|
+
case "cancel": {
|
|
5882
|
+
const u = o ? ` ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(o))}` : "", l = r ? import_picocolors_browser.default.gray(h) : "";
|
|
5883
|
+
return `${s}${l}${u}${o.trim() ? `
|
|
5884
|
+
${l}` : ""}`;
|
|
5885
|
+
}
|
|
5886
|
+
default: return `${s}${r ? `${import_picocolors_browser.default.cyan(h)} ` : ""}${n}
|
|
5887
|
+
${r ? import_picocolors_browser.default.cyan(x) : ""}
|
|
5888
|
+
`;
|
|
5889
|
+
}
|
|
5890
|
+
}
|
|
5891
|
+
}).prompt();
|
|
5892
|
+
var PromptManager = class PromptManager {
|
|
5893
|
+
#context;
|
|
5894
|
+
#onCancel;
|
|
5895
|
+
constructor(options) {
|
|
5896
|
+
this.#context = options.context;
|
|
5897
|
+
this.#onCancel = options.onCancel;
|
|
5898
|
+
}
|
|
5899
|
+
static isInteractiveEnvironment() {
|
|
5900
|
+
if (typeof process !== "undefined" && process.stdin) return process.stdin.isTTY === true;
|
|
5901
|
+
return false;
|
|
5902
|
+
}
|
|
5903
|
+
static shouldTriggerInteractive(promptWhen, flags, args) {
|
|
5904
|
+
switch (promptWhen) {
|
|
5905
|
+
case "always": return true;
|
|
5906
|
+
case "interactive-flag": return args["interactive"] === true;
|
|
5907
|
+
case "missing": return flags.some(({ name }) => {
|
|
5908
|
+
const value = args[name];
|
|
5909
|
+
return value === void 0 || value === null || value === "";
|
|
5910
|
+
});
|
|
5911
|
+
default: return false;
|
|
5912
|
+
}
|
|
5913
|
+
}
|
|
5914
|
+
static sortFlagsBySequence(flags) {
|
|
5915
|
+
return [...flags].sort((a, b) => {
|
|
5916
|
+
const seqA = a.flag.promptSequence ?? a.index;
|
|
5917
|
+
const seqB = b.flag.promptSequence ?? b.index;
|
|
5918
|
+
if (seqA !== seqB) return seqA - seqB;
|
|
5919
|
+
return a.index - b.index;
|
|
5920
|
+
});
|
|
5921
|
+
}
|
|
5922
|
+
async executePrompts(flags) {
|
|
5923
|
+
const flagsWithIndex = flags.map((f, index) => ({
|
|
5924
|
+
...f,
|
|
5925
|
+
index
|
|
5926
|
+
}));
|
|
5927
|
+
const sortedFlags = PromptManager.sortFlagsBySequence(flagsWithIndex);
|
|
5928
|
+
const answers = {};
|
|
5929
|
+
for (const { flag, name } of sortedFlags) try {
|
|
5930
|
+
if (!flag.prompt) continue;
|
|
5931
|
+
const config = await flag.prompt(this.#context);
|
|
5932
|
+
answers[name] = await this.#executePromptWithValidation(name, config);
|
|
5933
|
+
this.#context.promptAnswers = {
|
|
5934
|
+
...this.#context.promptAnswers,
|
|
5935
|
+
...answers
|
|
5936
|
+
};
|
|
5937
|
+
} catch (error) {
|
|
5938
|
+
if (this.#isCancelled(error)) {
|
|
5939
|
+
await this.#handleCancel();
|
|
5940
|
+
return {
|
|
5941
|
+
success: false,
|
|
5942
|
+
answers,
|
|
5943
|
+
cancelled: true
|
|
5944
|
+
};
|
|
5945
|
+
}
|
|
5946
|
+
throw error;
|
|
5947
|
+
}
|
|
5948
|
+
return {
|
|
5949
|
+
success: true,
|
|
5950
|
+
answers,
|
|
5951
|
+
cancelled: false
|
|
5952
|
+
};
|
|
5953
|
+
}
|
|
5954
|
+
async #executePromptWithValidation(name, config) {
|
|
5955
|
+
while (true) {
|
|
5956
|
+
const value = await this.#executePrompt(config);
|
|
5957
|
+
if (Ct(value)) throw new Error("USER_CANCELLED");
|
|
5958
|
+
if (config.validate) {
|
|
5959
|
+
const validationResult = await config.validate(value, this.#context);
|
|
5960
|
+
if (validationResult === true) return value;
|
|
5961
|
+
else if (typeof validationResult === "string") {
|
|
5962
|
+
R.error(validationResult);
|
|
5963
|
+
continue;
|
|
5964
|
+
} else {
|
|
5965
|
+
R.error(`Invalid value for ${name}`);
|
|
5966
|
+
continue;
|
|
5967
|
+
}
|
|
5968
|
+
}
|
|
5969
|
+
return value;
|
|
5970
|
+
}
|
|
5971
|
+
}
|
|
5972
|
+
async #executePrompt(config) {
|
|
5973
|
+
switch (config.type) {
|
|
5974
|
+
case "text": return Qt({
|
|
5975
|
+
message: config.message,
|
|
5976
|
+
placeholder: config.placeholder,
|
|
5977
|
+
initialValue: config.initial
|
|
5978
|
+
});
|
|
5979
|
+
case "password": return Gt({ message: config.message });
|
|
5980
|
+
case "confirm": return Mt$1({
|
|
5981
|
+
message: config.message,
|
|
5982
|
+
initialValue: config.initial ?? false
|
|
5983
|
+
});
|
|
5984
|
+
case "select": return qt({
|
|
5985
|
+
message: config.message,
|
|
5986
|
+
options: this.#normalizeOptions(config.options ?? []),
|
|
5987
|
+
initialValue: config.initial,
|
|
5988
|
+
maxItems: config.maxItems
|
|
5989
|
+
});
|
|
5990
|
+
case "multiselect": return Lt$1({
|
|
5991
|
+
message: config.message,
|
|
5992
|
+
options: this.#normalizeOptions(config.options ?? []),
|
|
5993
|
+
initialValues: config.initial,
|
|
5994
|
+
maxItems: config.maxItems
|
|
5995
|
+
});
|
|
5996
|
+
default: throw new Error(`Unknown prompt type: ${config.type}`);
|
|
5997
|
+
}
|
|
5998
|
+
}
|
|
5999
|
+
#normalizeOptions(options) {
|
|
6000
|
+
return options.map((opt) => {
|
|
6001
|
+
if (typeof opt === "string") return {
|
|
6002
|
+
value: opt,
|
|
6003
|
+
label: opt
|
|
6004
|
+
};
|
|
6005
|
+
return opt;
|
|
6006
|
+
});
|
|
6007
|
+
}
|
|
6008
|
+
async #handleCancel() {
|
|
6009
|
+
Pt("Operation cancelled by user");
|
|
6010
|
+
if (this.#onCancel) await this.#onCancel(this.#context);
|
|
6011
|
+
}
|
|
6012
|
+
#isCancelled(error) {
|
|
6013
|
+
if (error instanceof Error) return error.message === "USER_CANCELLED";
|
|
6014
|
+
return false;
|
|
6015
|
+
}
|
|
6016
|
+
};
|
|
6017
|
+
function detectAndStripSystemFlags(processArgs) {
|
|
6018
|
+
const systemArgs = {};
|
|
6019
|
+
const filteredArgs = [];
|
|
6020
|
+
for (let i = 0; i < processArgs.length; i++) {
|
|
6021
|
+
const arg = processArgs[i];
|
|
6022
|
+
const nextArg = processArgs[i + 1];
|
|
6023
|
+
const hasNextArg = nextArg !== void 0 && !nextArg.startsWith("-");
|
|
6024
|
+
switch (arg) {
|
|
6025
|
+
case "--s-debug":
|
|
6026
|
+
systemArgs.debug = true;
|
|
6027
|
+
break;
|
|
6028
|
+
case "--s-debug-print":
|
|
6029
|
+
systemArgs.debugPrint = true;
|
|
6030
|
+
break;
|
|
6031
|
+
case "--s-enable-fuzzy":
|
|
6032
|
+
systemArgs.enableFuzzy = true;
|
|
6033
|
+
break;
|
|
6034
|
+
case "--s-with-env":
|
|
6035
|
+
systemArgs.withEnv = hasNextArg ? nextArg : true;
|
|
6036
|
+
if (hasNextArg) i++;
|
|
6037
|
+
break;
|
|
6038
|
+
case "--s-save-to-env":
|
|
6039
|
+
systemArgs.saveToEnv = true;
|
|
6040
|
+
break;
|
|
6041
|
+
case "--s-build-dxt":
|
|
6042
|
+
systemArgs.buildDxt = hasNextArg ? nextArg : true;
|
|
6043
|
+
if (hasNextArg) i++;
|
|
6044
|
+
break;
|
|
6045
|
+
case "--s-mcp-serve":
|
|
6046
|
+
systemArgs.mcpServe = true;
|
|
6047
|
+
break;
|
|
6048
|
+
case "--s-mcp-transport":
|
|
6049
|
+
if (hasNextArg) {
|
|
6050
|
+
systemArgs.mcpTransport = nextArg;
|
|
6051
|
+
i++;
|
|
6052
|
+
}
|
|
6053
|
+
break;
|
|
6054
|
+
case "--s-mcp-port":
|
|
6055
|
+
if (hasNextArg) {
|
|
6056
|
+
systemArgs.mcpPort = parseInt(nextArg, 10);
|
|
6057
|
+
i++;
|
|
6058
|
+
}
|
|
6059
|
+
break;
|
|
6060
|
+
case "--s-mcp-host":
|
|
6061
|
+
if (hasNextArg) {
|
|
6062
|
+
systemArgs.mcpHost = nextArg;
|
|
6063
|
+
i++;
|
|
6064
|
+
}
|
|
6065
|
+
break;
|
|
6066
|
+
case "--s-mcp-path":
|
|
6067
|
+
if (hasNextArg) {
|
|
6068
|
+
systemArgs.mcpPath = nextArg;
|
|
6069
|
+
i++;
|
|
6070
|
+
}
|
|
6071
|
+
break;
|
|
6072
|
+
case "--s-mcp-transports":
|
|
6073
|
+
if (hasNextArg) {
|
|
6074
|
+
systemArgs.mcpTransports = nextArg;
|
|
6075
|
+
i++;
|
|
6076
|
+
}
|
|
6077
|
+
break;
|
|
6078
|
+
case "--s-mcp-log-path":
|
|
6079
|
+
if (hasNextArg) {
|
|
6080
|
+
systemArgs.mcpLogPath = nextArg;
|
|
6081
|
+
i++;
|
|
6082
|
+
}
|
|
6083
|
+
break;
|
|
6084
|
+
case "--s-mcp-cors":
|
|
6085
|
+
if (hasNextArg) {
|
|
6086
|
+
try {
|
|
6087
|
+
systemArgs.mcpCors = JSON.parse(nextArg);
|
|
6088
|
+
} catch {
|
|
6089
|
+
systemArgs.mcpCors = nextArg;
|
|
6090
|
+
}
|
|
6091
|
+
i++;
|
|
6092
|
+
}
|
|
6093
|
+
break;
|
|
6094
|
+
case "--s-mcp-auth":
|
|
6095
|
+
if (hasNextArg) {
|
|
6096
|
+
try {
|
|
6097
|
+
systemArgs.mcpAuth = JSON.parse(nextArg);
|
|
6098
|
+
} catch {
|
|
6099
|
+
systemArgs.mcpAuth = nextArg;
|
|
6100
|
+
}
|
|
6101
|
+
i++;
|
|
6102
|
+
}
|
|
6103
|
+
break;
|
|
6104
|
+
case "--transport":
|
|
6105
|
+
if (hasNextArg) {
|
|
6106
|
+
systemArgs.mcpTransport = nextArg;
|
|
6107
|
+
i++;
|
|
6108
|
+
}
|
|
6109
|
+
break;
|
|
6110
|
+
case "--port":
|
|
6111
|
+
if (hasNextArg) {
|
|
6112
|
+
systemArgs.mcpPort = parseInt(nextArg, 10);
|
|
6113
|
+
i++;
|
|
6114
|
+
}
|
|
6115
|
+
break;
|
|
6116
|
+
case "--host":
|
|
6117
|
+
if (hasNextArg) {
|
|
6118
|
+
systemArgs.mcpHost = nextArg;
|
|
6119
|
+
i++;
|
|
6120
|
+
}
|
|
6121
|
+
break;
|
|
6122
|
+
case "--path":
|
|
6123
|
+
if (hasNextArg) {
|
|
6124
|
+
systemArgs.mcpPath = nextArg;
|
|
6125
|
+
i++;
|
|
6126
|
+
}
|
|
6127
|
+
break;
|
|
6128
|
+
case "--transports":
|
|
6129
|
+
if (hasNextArg) {
|
|
6130
|
+
systemArgs.mcpTransports = nextArg;
|
|
6131
|
+
i++;
|
|
6132
|
+
}
|
|
6133
|
+
break;
|
|
6134
|
+
default: filteredArgs.push(arg);
|
|
6135
|
+
}
|
|
6136
|
+
}
|
|
6137
|
+
return {
|
|
6138
|
+
systemArgs,
|
|
6139
|
+
filteredArgs
|
|
6140
|
+
};
|
|
6141
|
+
}
|
|
4012
6142
|
var ArgParserError = class extends Error {
|
|
4013
6143
|
constructor(message, cmdChain = []) {
|
|
4014
6144
|
super(message);
|
|
@@ -4049,6 +6179,8 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4049
6179
|
#effectiveWorkingDirectory = null;
|
|
4050
6180
|
#rootPath = null;
|
|
4051
6181
|
#workingDirectoryResolved = false;
|
|
6182
|
+
#promptWhen = "interactive-flag";
|
|
6183
|
+
#onCancel;
|
|
4052
6184
|
constructor(options = {}, initialFlags) {
|
|
4053
6185
|
this.#appName = options.appName || "app";
|
|
4054
6186
|
if (options.blankSpaceWidth && !isNaN(Number(options.blankSpaceWidth)) && Number(options.blankSpaceWidth) > 20) this.#parameters.blankSpaceWidth = Number(options.blankSpaceWidth);
|
|
@@ -4085,6 +6217,8 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4085
6217
|
this.#dxtGenerator = new DxtGenerator(this);
|
|
4086
6218
|
this.#configurationManager = new ConfigurationManager(this);
|
|
4087
6219
|
if (options.subCommands) for (const sub of options.subCommands) this.addSubCommand(sub);
|
|
6220
|
+
this.#promptWhen = options.promptWhen ?? "interactive-flag";
|
|
6221
|
+
this.#onCancel = options.onCancel;
|
|
4088
6222
|
}
|
|
4089
6223
|
get flags() {
|
|
4090
6224
|
return this.#flagManager.flags;
|
|
@@ -4128,6 +6262,14 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4128
6262
|
getSubCommands() {
|
|
4129
6263
|
return this.#subCommands;
|
|
4130
6264
|
}
|
|
6265
|
+
setPromptWhen(promptWhen) {
|
|
6266
|
+
this.#promptWhen = promptWhen;
|
|
6267
|
+
return this;
|
|
6268
|
+
}
|
|
6269
|
+
setOnCancel(onCancel) {
|
|
6270
|
+
this.#onCancel = onCancel;
|
|
6271
|
+
return this;
|
|
6272
|
+
}
|
|
4131
6273
|
async _addToOutput(flag, arg, output, _parseOptions) {
|
|
4132
6274
|
let value = arg;
|
|
4133
6275
|
if (flag["type"] === Boolean) if (typeof arg === "boolean") value = arg;
|
|
@@ -4205,7 +6347,20 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4205
6347
|
this.#flagManager.addFlag(flag);
|
|
4206
6348
|
return this;
|
|
4207
6349
|
}
|
|
6350
|
+
getPromptableFlags() {
|
|
6351
|
+
const promptableFlags = [];
|
|
6352
|
+
for (const flag of this.#flagManager.flags) if ("prompt" in flag && typeof flag["prompt"] === "function") promptableFlags.push({
|
|
6353
|
+
flag,
|
|
6354
|
+
name: flag["name"]
|
|
6355
|
+
});
|
|
6356
|
+
return promptableFlags;
|
|
6357
|
+
}
|
|
6358
|
+
getPromptWhen() {
|
|
6359
|
+
return this.#promptWhen;
|
|
6360
|
+
}
|
|
4208
6361
|
addSubCommand(subCommandConfig) {
|
|
6362
|
+
if ("promptWhen" in subCommandConfig && subCommandConfig.promptWhen) subCommandConfig.parser.setPromptWhen?.(subCommandConfig.promptWhen);
|
|
6363
|
+
if ("onCancel" in subCommandConfig && subCommandConfig.onCancel) subCommandConfig.parser.setOnCancel?.(subCommandConfig.onCancel);
|
|
4209
6364
|
if (this.#subCommands.has(subCommandConfig.name)) throw new Error(`Sub-command '${subCommandConfig.name}' already exists`);
|
|
4210
6365
|
const subParser = subCommandConfig.parser;
|
|
4211
6366
|
if (!(subParser instanceof ArgParserBase)) throw new Error(`Parser for subcommand '${subCommandConfig.name}' is not an instance of ArgParserBase. Please provide 'new ArgParserBase(...)' for the 'parser' property of an ISubCommand.`);
|
|
@@ -4225,7 +6380,7 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4225
6380
|
return this;
|
|
4226
6381
|
}
|
|
4227
6382
|
#propagateFlagsRecursive(parser) {
|
|
4228
|
-
for (const [_, subConfig] of parser.getSubCommands()) {
|
|
6383
|
+
for (const [_$1, subConfig] of parser.getSubCommands()) {
|
|
4229
6384
|
const childParser = subConfig.parser;
|
|
4230
6385
|
if (!(childParser instanceof ArgParserBase)) continue;
|
|
4231
6386
|
if (childParser.#inheritParentFlags === FlagInheritance.AllParents) {
|
|
@@ -4314,9 +6469,9 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4314
6469
|
foundCwd = resolvedPath;
|
|
4315
6470
|
process.chdir(resolvedPath);
|
|
4316
6471
|
const allChdirIndices = [];
|
|
4317
|
-
for (let j = 0; j < processArgs.length; j++) for (const p of parserChain) for (const f of p.#flagManager.flags) if (f["setWorkingDirectory"] && f["options"].includes(processArgs[j])) allChdirIndices.push({
|
|
4318
|
-
index: j,
|
|
4319
|
-
flag: processArgs[j]
|
|
6472
|
+
for (let j$1 = 0; j$1 < processArgs.length; j$1++) for (const p of parserChain) for (const f of p.#flagManager.flags) if (f["setWorkingDirectory"] && f["options"].includes(processArgs[j$1])) allChdirIndices.push({
|
|
6473
|
+
index: j$1,
|
|
6474
|
+
flag: processArgs[j$1]
|
|
4320
6475
|
});
|
|
4321
6476
|
if (allChdirIndices.length > 1) this.#logger.warn(SimpleChalk_default.yellow(`Warning: Multiple working directory flags detected. Using '${option}' (last one in command chain).`));
|
|
4322
6477
|
break;
|
|
@@ -4621,18 +6776,30 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4621
6776
|
else throw new Error("parse() called without arguments in non-Node.js environment. Please provide arguments explicitly: parse(['--flag', 'value'])");
|
|
4622
6777
|
this.#resetDynamicFlagsRecursive();
|
|
4623
6778
|
const originalProcessArgs = [...processArgs];
|
|
4624
|
-
|
|
6779
|
+
const { systemArgs: detectedSystemArgs } = detectAndStripSystemFlags(processArgs);
|
|
6780
|
+
if (typeof process !== "undefined" && (process.env["ARGPARSER_FUZZY_MODE"] === "true" || detectedSystemArgs.enableFuzzy === true) && !options?.skipHelpHandling) return {
|
|
4625
6781
|
_fuzzyModePreventedExecution: true,
|
|
4626
|
-
_originalInputArgs: originalProcessArgs
|
|
6782
|
+
_originalInputArgs: originalProcessArgs,
|
|
6783
|
+
systemArgs: detectedSystemArgs
|
|
4627
6784
|
};
|
|
4628
6785
|
const globalCheckResult = await this.#_handleGlobalChecks(processArgs, options);
|
|
4629
|
-
|
|
6786
|
+
const { filteredArgs: processArgsWithoutSystemFlags } = detectAndStripSystemFlags(processArgs);
|
|
6787
|
+
processArgs.length = 0;
|
|
6788
|
+
processArgs.push(...processArgsWithoutSystemFlags);
|
|
6789
|
+
if (globalCheckResult !== false) {
|
|
6790
|
+
if (globalCheckResult !== true && typeof globalCheckResult === "object") globalCheckResult.systemArgs = detectedSystemArgs;
|
|
6791
|
+
return globalCheckResult === true ? {} : globalCheckResult;
|
|
6792
|
+
}
|
|
4630
6793
|
try {
|
|
4631
6794
|
const { finalParser: identifiedFinalParser, commandChain: identifiedCommandChain, parserChain: identifiedParserChain } = this.#_identifyCommandChainAndParsers(processArgs, this, [], [this]);
|
|
4632
6795
|
const saveToEnvResult = identifiedFinalParser.#_handleSaveToEnvFlag(processArgs, identifiedParserChain);
|
|
4633
|
-
if (saveToEnvResult !== false)
|
|
4634
|
-
|
|
6796
|
+
if (saveToEnvResult !== false) {
|
|
6797
|
+
if (saveToEnvResult !== true && typeof saveToEnvResult === "object") saveToEnvResult.systemArgs = detectedSystemArgs;
|
|
6798
|
+
return saveToEnvResult === true ? {} : saveToEnvResult;
|
|
6799
|
+
}
|
|
6800
|
+
const { finalArgs, handlerToExecute, systemArgs } = await this._parseRecursive(processArgs, this, {}, [], options, void 0, detectedSystemArgs);
|
|
4635
6801
|
if (identifiedCommandChain.length > 0) finalArgs.$commandChain = identifiedCommandChain;
|
|
6802
|
+
if (systemArgs && Object.keys(systemArgs).length > 0) finalArgs.systemArgs = systemArgs;
|
|
4636
6803
|
if (this.#fuzzyMode) finalArgs._originalInputArgs = originalProcessArgs;
|
|
4637
6804
|
if (!this.#fuzzyMode) this.#_validateMandatoryFlags(finalArgs, identifiedParserChain, identifiedCommandChain);
|
|
4638
6805
|
this.#_applyDefaultValues(finalArgs, identifiedFinalParser);
|
|
@@ -4659,7 +6826,7 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4659
6826
|
parseAsync(processArgs, options) {
|
|
4660
6827
|
return this.parse(processArgs, options);
|
|
4661
6828
|
}
|
|
4662
|
-
async _parseRecursive(argsToParse, currentParser, accumulatedParentArgs, commandChainSoFar, options, parentParser) {
|
|
6829
|
+
async _parseRecursive(argsToParse, currentParser, accumulatedParentArgs, commandChainSoFar, options, parentParser, systemArgs) {
|
|
4663
6830
|
let subCommandIndex = -1;
|
|
4664
6831
|
let subCommandName = null;
|
|
4665
6832
|
for (let i = 0; i < argsToParse.length; i++) {
|
|
@@ -4699,8 +6866,29 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4699
6866
|
},
|
|
4700
6867
|
rootPath: this.#rootPath || void 0,
|
|
4701
6868
|
logger: this.#logger,
|
|
4702
|
-
isMcp: options?.isMcp || false
|
|
6869
|
+
isMcp: options?.isMcp || false,
|
|
6870
|
+
systemArgs,
|
|
6871
|
+
promptAnswers: {},
|
|
6872
|
+
isInteractive: false
|
|
4703
6873
|
};
|
|
6874
|
+
const promptableFlags = currentParser.getPromptableFlags();
|
|
6875
|
+
if (PromptManager.shouldTriggerInteractive(currentParser.#promptWhen, promptableFlags, currentLevelArgs) && PromptManager.isInteractiveEnvironment()) {
|
|
6876
|
+
const promptResult = await new PromptManager({
|
|
6877
|
+
context: handlerContext,
|
|
6878
|
+
onCancel: currentParser.#onCancel
|
|
6879
|
+
}).executePrompts(promptableFlags);
|
|
6880
|
+
if (promptResult.success) {
|
|
6881
|
+
Object.assign(currentLevelArgs, promptResult.answers);
|
|
6882
|
+
Object.assign(finalParseResultArgs, promptResult.answers);
|
|
6883
|
+
handlerContext.promptAnswers = promptResult.answers;
|
|
6884
|
+
handlerContext.isInteractive = true;
|
|
6885
|
+
handlerContext.args = currentLevelArgs;
|
|
6886
|
+
} else if (promptResult.cancelled) return {
|
|
6887
|
+
finalArgs: finalParseResultArgs,
|
|
6888
|
+
handlerToExecute: void 0,
|
|
6889
|
+
systemArgs
|
|
6890
|
+
};
|
|
6891
|
+
}
|
|
4704
6892
|
if (currentParser.#handler) handlerToExecute = {
|
|
4705
6893
|
handler: currentParser.#handler,
|
|
4706
6894
|
context: handlerContext
|
|
@@ -4711,7 +6899,8 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4711
6899
|
};
|
|
4712
6900
|
return {
|
|
4713
6901
|
finalArgs: finalParseResultArgs,
|
|
4714
|
-
handlerToExecute
|
|
6902
|
+
handlerToExecute,
|
|
6903
|
+
systemArgs
|
|
4715
6904
|
};
|
|
4716
6905
|
}
|
|
4717
6906
|
if (firstUnconsumedIndex < argsForCurrentLevel.length) {
|
|
@@ -4727,7 +6916,7 @@ var ArgParserBase = class ArgParserBase {
|
|
|
4727
6916
|
...accumulatedParentArgs,
|
|
4728
6917
|
...currentLevelArgs
|
|
4729
6918
|
};
|
|
4730
|
-
return await this._parseRecursive(nextArgs, nextParser, combinedArgsForNextLevel, nextCommandChain, options, currentParser);
|
|
6919
|
+
return await this._parseRecursive(nextArgs, nextParser, combinedArgsForNextLevel, nextCommandChain, options, currentParser, systemArgs);
|
|
4731
6920
|
}
|
|
4732
6921
|
async #parseFlags(args, options) {
|
|
4733
6922
|
let flags = this.#flagManager.flags;
|
|
@@ -6431,7 +8620,7 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
|
|
|
6431
8620
|
const cliTools = generateMcpToolsFromArgParser(this, options);
|
|
6432
8621
|
const unifiedToolNames = Array.from(this._tools.keys());
|
|
6433
8622
|
const legacyMcpToolNames = Array.from(this._mcpTools.keys());
|
|
6434
|
-
const cliToolNames = cliTools.map((t) => t.name);
|
|
8623
|
+
const cliToolNames = cliTools.map((t$1) => t$1.name);
|
|
6435
8624
|
const allToolNames = [
|
|
6436
8625
|
...unifiedToolNames,
|
|
6437
8626
|
...legacyMcpToolNames,
|
|
@@ -6477,10 +8666,10 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
|
|
|
6477
8666
|
async testMcpToolRouting(toolName, args = {}) {
|
|
6478
8667
|
try {
|
|
6479
8668
|
const tools = this.toMcpTools();
|
|
6480
|
-
const tool = tools.find((t) => t.name === toolName);
|
|
8669
|
+
const tool = tools.find((t$1) => t$1.name === toolName);
|
|
6481
8670
|
if (!tool) return {
|
|
6482
8671
|
success: false,
|
|
6483
|
-
error: `Tool '${toolName}' not found. Available tools: ${tools.map((t) => t.name).join(", ")}`
|
|
8672
|
+
error: `Tool '${toolName}' not found. Available tools: ${tools.map((t$1) => t$1.name).join(", ")}`
|
|
6484
8673
|
};
|
|
6485
8674
|
const startTime = Date.now();
|
|
6486
8675
|
return {
|
|
@@ -6620,9 +8809,9 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
|
|
|
6620
8809
|
...legacyMcpTools,
|
|
6621
8810
|
...cliTools
|
|
6622
8811
|
].reduce((acc, tool) => {
|
|
6623
|
-
if (!acc.find((t) => t.name === tool.name)) acc.push(tool);
|
|
8812
|
+
if (!acc.find((t$1) => t$1.name === tool.name)) acc.push(tool);
|
|
6624
8813
|
else {
|
|
6625
|
-
const toolSource = unifiedTools.find((t) => t.name === tool.name) ? "unified" : legacyMcpTools.find((t) => t.name === tool.name) ? "legacy MCP" : "CLI-generated";
|
|
8814
|
+
const toolSource = unifiedTools.find((t$1) => t$1.name === tool.name) ? "unified" : legacyMcpTools.find((t$1) => t$1.name === tool.name) ? "legacy MCP" : "CLI-generated";
|
|
6626
8815
|
console.warn(`[MCP Tool Registration] ${toolSource} tool '${tool.name}' overrides other tool definitions`);
|
|
6627
8816
|
}
|
|
6628
8817
|
return acc;
|
|
@@ -6688,15 +8877,15 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
|
|
|
6688
8877
|
const tools = this.toMcpTools(toolOptions);
|
|
6689
8878
|
logger$7.mcpError(`Generated ${tools.length} MCP tools`);
|
|
6690
8879
|
const uniqueTools = tools.reduce((acc, tool) => {
|
|
6691
|
-
if (!acc.find((t) => t.name === tool.name)) acc.push(tool);
|
|
8880
|
+
if (!acc.find((t$1) => t$1.name === tool.name)) acc.push(tool);
|
|
6692
8881
|
return acc;
|
|
6693
8882
|
}, []);
|
|
6694
8883
|
logger$7.mcpError(`After deduplication: ${uniqueTools.length} unique tools`);
|
|
6695
8884
|
uniqueTools.forEach((tool) => {
|
|
6696
8885
|
logger$7.mcpError(`Registering tool: ${tool.name}`);
|
|
6697
8886
|
let zodSchema;
|
|
6698
|
-
const toolFromUnified = Array.from(this._tools.values()).find((t) => t.name === tool.name);
|
|
6699
|
-
const toolFromLegacy = Array.from(this._mcpTools.values()).find((t) => t.name === tool.name);
|
|
8887
|
+
const toolFromUnified = Array.from(this._tools.values()).find((t$1) => t$1.name === tool.name);
|
|
8888
|
+
const toolFromLegacy = Array.from(this._mcpTools.values()).find((t$1) => t$1.name === tool.name);
|
|
6700
8889
|
if (toolFromUnified && toolFromUnified.flags) zodSchema = convertFlagsToZodSchema(toolFromUnified.flags);
|
|
6701
8890
|
else if (toolFromLegacy && toolFromLegacy.inputSchema) zodSchema = toolFromLegacy.inputSchema;
|
|
6702
8891
|
else zodSchema = zod.z.object({});
|
|
@@ -7019,13 +9208,13 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
|
|
|
7019
9208
|
const base64urlDecode = (s) => Buffer.from(s.replace(/-/g, "+").replace(/_/g, "/"), "base64");
|
|
7020
9209
|
const verifyJwt = async (token) => {
|
|
7021
9210
|
if (!authOpts?.jwt) return false;
|
|
7022
|
-
const [h, p, sig] = token.split(".");
|
|
7023
|
-
if (!h || !p || !sig) return false;
|
|
7024
|
-
const header = JSON.parse(base64urlDecode(h).toString("utf8"));
|
|
9211
|
+
const [h$1, p, sig] = token.split(".");
|
|
9212
|
+
if (!h$1 || !p || !sig) return false;
|
|
9213
|
+
const header = JSON.parse(base64urlDecode(h$1).toString("utf8"));
|
|
7025
9214
|
const payload = JSON.parse(base64urlDecode(p).toString("utf8"));
|
|
7026
9215
|
const alg = header.alg;
|
|
7027
9216
|
if (authOpts.jwt.algorithms && !authOpts.jwt.algorithms.includes(alg)) return false;
|
|
7028
|
-
const data = Buffer.from(`${h}.${p}`);
|
|
9217
|
+
const data = Buffer.from(`${h$1}.${p}`);
|
|
7029
9218
|
const signature = base64urlDecode(sig);
|
|
7030
9219
|
if (alg === "HS256") {
|
|
7031
9220
|
const secret = authOpts.jwt.secret;
|
|
@@ -7403,9 +9592,9 @@ var ArgParserFuzzyTester = class {
|
|
|
7403
9592
|
const flagArgs = this.generateFlagArgs(flag, "valid");
|
|
7404
9593
|
if (flagArgs.length > 0) combinations.push([...mandatoryArgs, ...flagArgs]);
|
|
7405
9594
|
}
|
|
7406
|
-
if (optionalFlags.length > 1) for (let i = 0; i < optionalFlags.length - 1; i++) for (let j = i + 1; j < optionalFlags.length; j++) {
|
|
9595
|
+
if (optionalFlags.length > 1) for (let i = 0; i < optionalFlags.length - 1; i++) for (let j$1 = i + 1; j$1 < optionalFlags.length; j$1++) {
|
|
7407
9596
|
const flag1Args = this.generateFlagArgs(optionalFlags[i], "valid");
|
|
7408
|
-
const flag2Args = this.generateFlagArgs(optionalFlags[j], "valid");
|
|
9597
|
+
const flag2Args = this.generateFlagArgs(optionalFlags[j$1], "valid");
|
|
7409
9598
|
if (flag1Args.length > 0 && flag2Args.length > 0) combinations.push([
|
|
7410
9599
|
...mandatoryArgs,
|
|
7411
9600
|
...flag1Args,
|
|
@@ -7540,6 +9729,7 @@ exports.ConfigPluginRegistry = ConfigPluginRegistry;
|
|
|
7540
9729
|
exports.DxtPathResolver = DxtPathResolver;
|
|
7541
9730
|
exports.EnvConfigPlugin = EnvConfigPlugin;
|
|
7542
9731
|
exports.FlagInheritance = FlagInheritance;
|
|
9732
|
+
exports.FlagManager = FlagManager;
|
|
7543
9733
|
exports.JsonConfigPlugin = JsonConfigPlugin;
|
|
7544
9734
|
Object.defineProperty(exports, "Logger", {
|
|
7545
9735
|
enumerable: true,
|
|
@@ -7548,6 +9738,7 @@ Object.defineProperty(exports, "Logger", {
|
|
|
7548
9738
|
}
|
|
7549
9739
|
});
|
|
7550
9740
|
exports.OutputSchemaPatterns = OutputSchemaPatterns;
|
|
9741
|
+
exports.PromptManager = PromptManager;
|
|
7551
9742
|
exports.SimpleChalk = SimpleChalk_default;
|
|
7552
9743
|
exports.TomlConfigPlugin = TomlConfigPlugin;
|
|
7553
9744
|
exports.YamlConfigPlugin = YamlConfigPlugin;
|