poof 2.2.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs ADDED
@@ -0,0 +1,877 @@
1
+ #!/usr/bin/env node
2
+ import path from 'node:path';
3
+ import S$1 from 'tty';
4
+ import poof from './index.mjs';
5
+ import 'node:fs/promises';
6
+ import 'node:os';
7
+ import 'node:child_process';
8
+ import 'node:url';
9
+ import 'node:timers/promises';
10
+
11
+ var O$2 = Object.defineProperty;
12
+ var a = (t, e) => O$2(t, "name", { value: e, configurable: true });
13
+ const P$1 = "known-flag", _$2 = "unknown-flag", D$1 = "argument", B$1 = /\B([A-Z])/g, G$2 = a((t) => t.replaceAll(B$1, "-$1").toLowerCase(), "camelToKebab"), { hasOwnProperty: K$2 } = Object.prototype, h$1 = a((t, e) => K$2.call(t, e), "hasOwn"), F$1 = a((t) => typeof t == "function" ? [t, false] : Array.isArray(t) ? [t[0], true] : F$1(t.type), "parseFlagType"), $$2 = a((t, e) => t === Boolean ? e !== "false" : e, "normalizeBoolean"), m$1 = a((t, e) => typeof e == "boolean" ? e : t === Number && e === "" ? Number.NaN : t(e), "applyParser"), R$2 = /[\s.:=]/, T$2 = a((t) => {
14
+ const e = `Flag name "${t}"`;
15
+ if (t.length === 0) throw new Error(`${e} cannot be empty`);
16
+ if (t.length === 1) throw new Error(`${e} must be longer than a character`);
17
+ const n = t.match(R$2);
18
+ if (n) throw new Error(`${e} cannot contain "${n?.[0]}"`);
19
+ }, "validateFlagName"), d$1 = a((t, e, n) => {
20
+ if (h$1(t, e)) throw new Error(`Duplicate flags named "${e}"`);
21
+ t[e] = n;
22
+ }, "setFlag"), U$2 = a((t) => {
23
+ const e = {};
24
+ for (const n in t) {
25
+ if (!h$1(t, n)) continue;
26
+ T$2(n);
27
+ const s = t[n], r = [[], ...F$1(s), s];
28
+ d$1(e, n, r);
29
+ const l = G$2(n);
30
+ if (n !== l && d$1(e, l, r), "alias" in s && typeof s.alias == "string") {
31
+ const { alias: o } = s, i = `Flag alias "${o}" for flag "${n}"`;
32
+ if (o.length === 0) throw new Error(`${i} cannot be empty`);
33
+ if (o.length > 1) throw new Error(`${i} must be a single character`);
34
+ d$1(e, o, r);
35
+ }
36
+ }
37
+ return e;
38
+ }, "createRegistry"), W$2 = a((t, e) => {
39
+ const n = {};
40
+ for (const s in t) {
41
+ if (!h$1(t, s)) continue;
42
+ const [r, , l, o] = e[s];
43
+ if (r.length === 0 && "default" in o) {
44
+ let { default: i } = o;
45
+ typeof i == "function" && (i = i()), n[s] = i;
46
+ } else n[s] = l ? r : r.pop();
47
+ }
48
+ return n;
49
+ }, "finalizeFlags"), A = "--", j$2 = 3, v$1 = /^-{1,2}\w/, V$2 = a((t) => {
50
+ if (!v$1.test(t)) return;
51
+ const e = !t.startsWith(A);
52
+ let n = t.slice(e ? 1 : 2), s, r = -1;
53
+ for (const l of ["=", ":", "."]) {
54
+ const o = n.indexOf(l);
55
+ o !== -1 && (r === -1 || o < r) && (r = o);
56
+ }
57
+ return r !== -1 && (s = n.slice(r + 1), n = n.slice(0, r)), [n, s, e];
58
+ }, "parseFlagArgv"), L$2 = a((t, { onFlag: e, onArgument: n }) => {
59
+ let s;
60
+ const r = a((l, o) => {
61
+ if (typeof s != "function") return true;
62
+ s(l, o), s = void 0;
63
+ }, "triggerValueCallback");
64
+ for (let l = 0; l < t.length; l += 1) {
65
+ const o = t[l];
66
+ if (o === A) {
67
+ r();
68
+ const c = t.slice(l + 1);
69
+ n?.(c, [l], true);
70
+ break;
71
+ }
72
+ const i = V$2(o);
73
+ if (i) {
74
+ if (r(), !e) continue;
75
+ const [c, f, w] = i;
76
+ if (w) for (let u = 0; u < c.length; u += 1) {
77
+ r();
78
+ const g = u === c.length - 1;
79
+ s = e(c[u], g ? f : void 0, [l, u + 1, g]);
80
+ }
81
+ else s = e(c, f, [l]);
82
+ } else r(o, [l]) && n?.([o], [l]);
83
+ }
84
+ r();
85
+ }, "argvIterator"), k$2 = a((t, e) => {
86
+ for (let n = e.length - 1; n >= 0; n -= 1) {
87
+ const [s, r, l] = e[n];
88
+ if (r) {
89
+ const o = t[s];
90
+ let i = o.slice(0, r);
91
+ if (l || (i += o.slice(r + 1)), i !== "-") {
92
+ t[s] = i;
93
+ continue;
94
+ }
95
+ }
96
+ t.splice(s, 1);
97
+ }
98
+ }, "spliceFromArgv"), z$2 = a((t, e = process.argv.slice(2), { ignore: n } = {}) => {
99
+ const s = [], r = U$2(t), l = {}, o = [];
100
+ return o[A] = [], L$2(e, { onFlag(i, c, f) {
101
+ const g = (f.length === j$2 || i.length > 1) && h$1(r, i);
102
+ if (!n?.(g ? P$1 : _$2, i, c)) {
103
+ if (g) {
104
+ const [y, p] = r[i], b = $$2(p, c), N = a((C, E) => {
105
+ s.push(f), E && s.push(E), y.push(m$1(p, C || ""));
106
+ }, "getFollowingValue");
107
+ return b === void 0 ? N : N(b);
108
+ }
109
+ h$1(l, i) || (l[i] = []), l[i].push(c === void 0 ? true : c), s.push(f);
110
+ }
111
+ }, onArgument: a((i, c, f) => {
112
+ n?.(D$1, e[c[0]]) || (o.push(...i), f ? (o[A] = i, e.splice(c[0])) : s.push(c));
113
+ }, "onArgument") }), k$2(e, s), { flags: W$2(t, r), unknownFlags: l, _: o };
114
+ }, "typeFlag"); a((t, e, n = process.argv.slice(2)) => {
115
+ const s = new Set(t.split(",").map((c) => V$2(c)?.[0])), [r, l] = F$1(e), o = [], i = [];
116
+ return L$2(n, { onFlag: a((c, f, w) => {
117
+ if (!s.has(c) || !l && o.length > 0) return;
118
+ const u = $$2(r, f), g = a((y, p) => {
119
+ i.push(w), p && i.push(p), o.push(m$1(r, y || ""));
120
+ }, "getFollowingValue");
121
+ return u === void 0 ? g : g(u);
122
+ }, "onFlag") }), k$2(n, i), l ? o : o[0];
123
+ }, "getFlag");
124
+
125
+ var O$1 = Object.defineProperty;
126
+ var n = (D, F) => O$1(D, "name", { value: F, configurable: true });
127
+ const M$1 = n((D) => {
128
+ const F = process.stdout.columns ?? Number.POSITIVE_INFINITY;
129
+ return typeof D == "function" && (D = D(F)), D || (D = {}), Array.isArray(D) ? { columns: D, stdoutColumns: F } : { columns: D.columns ?? [], stdoutColumns: D.stdoutColumns ?? F };
130
+ }, "getOptions");
131
+ function j$1({ onlyFirst: D = false } = {}) {
132
+ const u = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
133
+ return new RegExp(u, D ? void 0 : "g");
134
+ }
135
+ n(j$1, "ansiRegex");
136
+ const k$1 = j$1();
137
+ function w(D) {
138
+ if (typeof D != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof D}\``);
139
+ return D.replace(k$1, "");
140
+ }
141
+ n(w, "stripAnsi");
142
+ function P(D) {
143
+ return D === 161 || D === 164 || D === 167 || D === 168 || D === 170 || D === 173 || D === 174 || D >= 176 && D <= 180 || D >= 182 && D <= 186 || D >= 188 && D <= 191 || D === 198 || D === 208 || D === 215 || D === 216 || D >= 222 && D <= 225 || D === 230 || D >= 232 && D <= 234 || D === 236 || D === 237 || D === 240 || D === 242 || D === 243 || D >= 247 && D <= 250 || D === 252 || D === 254 || D === 257 || D === 273 || D === 275 || D === 283 || D === 294 || D === 295 || D === 299 || D >= 305 && D <= 307 || D === 312 || D >= 319 && D <= 322 || D === 324 || D >= 328 && D <= 331 || D === 333 || D === 338 || D === 339 || D === 358 || D === 359 || D === 363 || D === 462 || D === 464 || D === 466 || D === 468 || D === 470 || D === 472 || D === 474 || D === 476 || D === 593 || D === 609 || D === 708 || D === 711 || D >= 713 && D <= 715 || D === 717 || D === 720 || D >= 728 && D <= 731 || D === 733 || D === 735 || D >= 768 && D <= 879 || D >= 913 && D <= 929 || D >= 931 && D <= 937 || D >= 945 && D <= 961 || D >= 963 && D <= 969 || D === 1025 || D >= 1040 && D <= 1103 || D === 1105 || D === 8208 || D >= 8211 && D <= 8214 || D === 8216 || D === 8217 || D === 8220 || D === 8221 || D >= 8224 && D <= 8226 || D >= 8228 && D <= 8231 || D === 8240 || D === 8242 || D === 8243 || D === 8245 || D === 8251 || D === 8254 || D === 8308 || D === 8319 || D >= 8321 && D <= 8324 || D === 8364 || D === 8451 || D === 8453 || D === 8457 || D === 8467 || D === 8470 || D === 8481 || D === 8482 || D === 8486 || D === 8491 || D === 8531 || D === 8532 || D >= 8539 && D <= 8542 || D >= 8544 && D <= 8555 || D >= 8560 && D <= 8569 || D === 8585 || D >= 8592 && D <= 8601 || D === 8632 || D === 8633 || D === 8658 || D === 8660 || D === 8679 || D === 8704 || D === 8706 || D === 8707 || D === 8711 || D === 8712 || D === 8715 || D === 8719 || D === 8721 || D === 8725 || D === 8730 || D >= 8733 && D <= 8736 || D === 8739 || D === 8741 || D >= 8743 && D <= 8748 || D === 8750 || D >= 8756 && D <= 8759 || D === 8764 || D === 8765 || D === 8776 || D === 8780 || D === 8786 || D === 8800 || D === 8801 || D >= 8804 && D <= 8807 || D === 8810 || D === 8811 || D === 8814 || D === 8815 || D === 8834 || D === 8835 || D === 8838 || D === 8839 || D === 8853 || D === 8857 || D === 8869 || D === 8895 || D === 8978 || D >= 9312 && D <= 9449 || D >= 9451 && D <= 9547 || D >= 9552 && D <= 9587 || D >= 9600 && D <= 9615 || D >= 9618 && D <= 9621 || D === 9632 || D === 9633 || D >= 9635 && D <= 9641 || D === 9650 || D === 9651 || D === 9654 || D === 9655 || D === 9660 || D === 9661 || D === 9664 || D === 9665 || D >= 9670 && D <= 9672 || D === 9675 || D >= 9678 && D <= 9681 || D >= 9698 && D <= 9701 || D === 9711 || D === 9733 || D === 9734 || D === 9737 || D === 9742 || D === 9743 || D === 9756 || D === 9758 || D === 9792 || D === 9794 || D === 9824 || D === 9825 || D >= 9827 && D <= 9829 || D >= 9831 && D <= 9834 || D === 9836 || D === 9837 || D === 9839 || D === 9886 || D === 9887 || D === 9919 || D >= 9926 && D <= 9933 || D >= 9935 && D <= 9939 || D >= 9941 && D <= 9953 || D === 9955 || D === 9960 || D === 9961 || D >= 9963 && D <= 9969 || D === 9972 || D >= 9974 && D <= 9977 || D === 9979 || D === 9980 || D === 9982 || D === 9983 || D === 10045 || D >= 10102 && D <= 10111 || D >= 11094 && D <= 11097 || D >= 12872 && D <= 12879 || D >= 57344 && D <= 63743 || D >= 65024 && D <= 65039 || D === 65533 || D >= 127232 && D <= 127242 || D >= 127248 && D <= 127277 || D >= 127280 && D <= 127337 || D >= 127344 && D <= 127373 || D === 127375 || D === 127376 || D >= 127387 && D <= 127404 || D >= 917760 && D <= 917999 || D >= 983040 && D <= 1048573 || D >= 1048576 && D <= 1114109;
144
+ }
145
+ n(P, "isAmbiguous");
146
+ function z$1(D) {
147
+ return D === 12288 || D >= 65281 && D <= 65376 || D >= 65504 && D <= 65510;
148
+ }
149
+ n(z$1, "isFullWidth");
150
+ function G$1(D) {
151
+ return D >= 4352 && D <= 4447 || D === 8986 || D === 8987 || D === 9001 || D === 9002 || D >= 9193 && D <= 9196 || D === 9200 || D === 9203 || D === 9725 || D === 9726 || D === 9748 || D === 9749 || D >= 9776 && D <= 9783 || D >= 9800 && D <= 9811 || D === 9855 || D >= 9866 && D <= 9871 || D === 9875 || D === 9889 || D === 9898 || D === 9899 || D === 9917 || D === 9918 || D === 9924 || D === 9925 || D === 9934 || D === 9940 || D === 9962 || D === 9970 || D === 9971 || D === 9973 || D === 9978 || D === 9981 || D === 9989 || D === 9994 || D === 9995 || D === 10024 || D === 10060 || D === 10062 || D >= 10067 && D <= 10069 || D === 10071 || D >= 10133 && D <= 10135 || D === 10160 || D === 10175 || D === 11035 || D === 11036 || D === 11088 || D === 11093 || D >= 11904 && D <= 11929 || D >= 11931 && D <= 12019 || D >= 12032 && D <= 12245 || D >= 12272 && D <= 12287 || D >= 12289 && D <= 12350 || D >= 12353 && D <= 12438 || D >= 12441 && D <= 12543 || D >= 12549 && D <= 12591 || D >= 12593 && D <= 12686 || D >= 12688 && D <= 12773 || D >= 12783 && D <= 12830 || D >= 12832 && D <= 12871 || D >= 12880 && D <= 42124 || D >= 42128 && D <= 42182 || D >= 43360 && D <= 43388 || D >= 44032 && D <= 55203 || D >= 63744 && D <= 64255 || D >= 65040 && D <= 65049 || D >= 65072 && D <= 65106 || D >= 65108 && D <= 65126 || D >= 65128 && D <= 65131 || D >= 94176 && D <= 94180 || D === 94192 || D === 94193 || D >= 94208 && D <= 100343 || D >= 100352 && D <= 101589 || D >= 101631 && D <= 101640 || D >= 110576 && D <= 110579 || D >= 110581 && D <= 110587 || D === 110589 || D === 110590 || D >= 110592 && D <= 110882 || D === 110898 || D >= 110928 && D <= 110930 || D === 110933 || D >= 110948 && D <= 110951 || D >= 110960 && D <= 111355 || D >= 119552 && D <= 119638 || D >= 119648 && D <= 119670 || D === 126980 || D === 127183 || D === 127374 || D >= 127377 && D <= 127386 || D >= 127488 && D <= 127490 || D >= 127504 && D <= 127547 || D >= 127552 && D <= 127560 || D === 127568 || D === 127569 || D >= 127584 && D <= 127589 || D >= 127744 && D <= 127776 || D >= 127789 && D <= 127797 || D >= 127799 && D <= 127868 || D >= 127870 && D <= 127891 || D >= 127904 && D <= 127946 || D >= 127951 && D <= 127955 || D >= 127968 && D <= 127984 || D === 127988 || D >= 127992 && D <= 128062 || D === 128064 || D >= 128066 && D <= 128252 || D >= 128255 && D <= 128317 || D >= 128331 && D <= 128334 || D >= 128336 && D <= 128359 || D === 128378 || D === 128405 || D === 128406 || D === 128420 || D >= 128507 && D <= 128591 || D >= 128640 && D <= 128709 || D === 128716 || D >= 128720 && D <= 128722 || D >= 128725 && D <= 128727 || D >= 128732 && D <= 128735 || D === 128747 || D === 128748 || D >= 128756 && D <= 128764 || D >= 128992 && D <= 129003 || D === 129008 || D >= 129292 && D <= 129338 || D >= 129340 && D <= 129349 || D >= 129351 && D <= 129535 || D >= 129648 && D <= 129660 || D >= 129664 && D <= 129673 || D >= 129679 && D <= 129734 || D >= 129742 && D <= 129756 || D >= 129759 && D <= 129769 || D >= 129776 && D <= 129784 || D >= 131072 && D <= 196605 || D >= 196608 && D <= 262141;
152
+ }
153
+ n(G$1, "isWide");
154
+ function Z$1(D) {
155
+ if (!Number.isSafeInteger(D)) throw new TypeError(`Expected a code point, got \`${typeof D}\`.`);
156
+ }
157
+ n(Z$1, "validate");
158
+ function V$1(D, { ambiguousAsWide: F = false } = {}) {
159
+ return Z$1(D), z$1(D) || G$1(D) || F && P(D) ? 2 : 1;
160
+ }
161
+ n(V$1, "eastAsianWidth");
162
+ var Y = n(() => /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g, "emojiRegex");
163
+ const K$1 = new Intl.Segmenter(), U$1 = new RegExp("^\\p{Default_Ignorable_Code_Point}$", "u");
164
+ function d(D, F = {}) {
165
+ if (typeof D != "string" || D.length === 0) return 0;
166
+ const { ambiguousIsNarrow: u = true, countAnsiEscapeCodes: C = false } = F;
167
+ if (C || (D = w(D)), D.length === 0) return 0;
168
+ let E = 0;
169
+ const t = { ambiguousAsWide: !u };
170
+ for (const { segment: i } of K$1.segment(D)) {
171
+ const e = i.codePointAt(0);
172
+ if (!(e <= 31 || e >= 127 && e <= 159) && !(e >= 8203 && e <= 8207 || e === 65279) && !(e >= 768 && e <= 879 || e >= 6832 && e <= 6911 || e >= 7616 && e <= 7679 || e >= 8400 && e <= 8447 || e >= 65056 && e <= 65071) && !(e >= 55296 && e <= 57343) && !(e >= 65024 && e <= 65039) && !U$1.test(i)) {
173
+ if (Y().test(i)) {
174
+ E += 2;
175
+ continue;
176
+ }
177
+ E += V$1(e, t);
178
+ }
179
+ }
180
+ return E;
181
+ }
182
+ n(d, "stringWidth");
183
+ const x$1 = n((D) => Math.max(...D.split(`
184
+ `).map((F) => d(F))), "getLongestLineWidth"), q = n((D) => {
185
+ const F = [];
186
+ for (const u of D) {
187
+ const { length: C } = u, E = C - F.length;
188
+ for (let t = 0; t < E; t += 1) F.push(0);
189
+ for (let t = 0; t < C; t += 1) {
190
+ const i = x$1(u[t]);
191
+ i > F[t] && (F[t] = i);
192
+ }
193
+ }
194
+ return F;
195
+ }, "getColumnContentWidths"), y = /^\d+%$/, S = { width: "auto", align: "left", contentWidth: 0, paddingLeft: 0, paddingRight: 0, paddingTop: 0, paddingBottom: 0, horizontalPadding: 0, paddingLeftString: "", paddingRightString: "" }, H$1 = n((D, F) => {
196
+ const u = [];
197
+ for (let C = 0; C < D.length; C += 1) {
198
+ const E = F[C] ?? "auto";
199
+ if (typeof E == "number" || E === "auto" || E === "content-width" || typeof E == "string" && y.test(E)) {
200
+ u.push({ ...S, width: E, contentWidth: D[C] });
201
+ continue;
202
+ }
203
+ if (E && typeof E == "object") {
204
+ const t = { ...S, ...E, contentWidth: D[C] };
205
+ t.horizontalPadding = t.paddingLeft + t.paddingRight, u.push(t);
206
+ continue;
207
+ }
208
+ throw new Error(`Invalid column width: ${JSON.stringify(E)}`);
209
+ }
210
+ return u;
211
+ }, "initColumns"), J$1 = n((D, F) => {
212
+ for (const u of D) {
213
+ const { width: C } = u;
214
+ if (C === "content-width" && (u.width = u.contentWidth), C === "auto") {
215
+ const B = Math.min(20, u.contentWidth);
216
+ u.width = B, u.autoOverflow = u.contentWidth - B;
217
+ }
218
+ if (typeof C == "string" && y.test(C)) {
219
+ const B = Number.parseFloat(C.slice(0, -1)) / 100;
220
+ u.width = Math.floor(F * B) - (u.paddingLeft + u.paddingRight);
221
+ }
222
+ const { horizontalPadding: E } = u, t = 1, i = t + E;
223
+ if (i >= F) {
224
+ const B = i - F, A = Math.ceil(u.paddingLeft / E * B), a = B - A;
225
+ u.paddingLeft -= A, u.paddingRight -= a, u.horizontalPadding = u.paddingLeft + u.paddingRight;
226
+ }
227
+ u.paddingLeftString = u.paddingLeft ? " ".repeat(u.paddingLeft) : "", u.paddingRightString = u.paddingRight ? " ".repeat(u.paddingRight) : "";
228
+ const e = F - u.horizontalPadding;
229
+ u.width = Math.max(Math.min(u.width, e), t);
230
+ }
231
+ }, "resolveColumnWidths"), R$1 = n(() => Object.assign([], { columns: 0 }), "makeRow"), Q$1 = n((D, F) => {
232
+ const u = [R$1()];
233
+ let [C] = u;
234
+ for (const E of D) {
235
+ const t = E.width + E.horizontalPadding;
236
+ C.columns + t > F && (C = R$1(), u.push(C)), C.push(E), C.columns += t;
237
+ }
238
+ for (const E of u) {
239
+ const t = E.reduce((r, o) => r + o.width + o.horizontalPadding, 0);
240
+ let i = F - t;
241
+ if (i === 0) continue;
242
+ const e = E.filter((r) => "autoOverflow" in r), B = e.filter((r) => r.autoOverflow > 0), A = B.reduce((r, o) => r + o.autoOverflow, 0), a = Math.min(A, i);
243
+ for (const r of B) {
244
+ const o = Math.floor(r.autoOverflow / A * a);
245
+ r.width += o, i -= o;
246
+ }
247
+ const l = Math.floor(i / e.length);
248
+ for (let r = 0; r < e.length; r += 1) {
249
+ const o = e[r];
250
+ r === e.length - 1 ? o.width += i : o.width += l, i -= l;
251
+ }
252
+ }
253
+ return u;
254
+ }, "balanceAuto"), X$1 = n((D, F, u) => {
255
+ const C = H$1(u, F);
256
+ return J$1(C, D), Q$1(C, D);
257
+ }, "computeColumnWidths"), p = 10, v = n((D = 0) => (F) => `\x1B[${F + D}m`, "wrapAnsi16"), _$1 = n((D = 0) => (F) => `\x1B[${38 + D};5;${F}m`, "wrapAnsi256"), L$1 = n((D = 0) => (F, u, C) => `\x1B[${38 + D};2;${F};${u};${C}m`, "wrapAnsi16m"), s$1 = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
258
+ Object.keys(s$1.modifier);
259
+ const DD = Object.keys(s$1.color), uD = Object.keys(s$1.bgColor);
260
+ [...DD, ...uD];
261
+ function FD() {
262
+ const D = /* @__PURE__ */ new Map();
263
+ for (const [F, u] of Object.entries(s$1)) {
264
+ for (const [C, E] of Object.entries(u)) s$1[C] = { open: `\x1B[${E[0]}m`, close: `\x1B[${E[1]}m` }, u[C] = s$1[C], D.set(E[0], E[1]);
265
+ Object.defineProperty(s$1, F, { value: u, enumerable: false });
266
+ }
267
+ return Object.defineProperty(s$1, "codes", { value: D, enumerable: false }), s$1.color.close = "\x1B[39m", s$1.bgColor.close = "\x1B[49m", s$1.color.ansi = v(), s$1.color.ansi256 = _$1(), s$1.color.ansi16m = L$1(), s$1.bgColor.ansi = v(p), s$1.bgColor.ansi256 = _$1(p), s$1.bgColor.ansi16m = L$1(p), Object.defineProperties(s$1, { rgbToAnsi256: { value: n((F, u, C) => F === u && u === C ? F < 8 ? 16 : F > 248 ? 231 : Math.round((F - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(F / 255 * 5) + 6 * Math.round(u / 255 * 5) + Math.round(C / 255 * 5), "value"), enumerable: false }, hexToRgb: { value: n((F) => {
268
+ const u = /[a-f\d]{6}|[a-f\d]{3}/i.exec(F.toString(16));
269
+ if (!u) return [0, 0, 0];
270
+ let [C] = u;
271
+ C.length === 3 && (C = [...C].map((t) => t + t).join(""));
272
+ const E = Number.parseInt(C, 16);
273
+ return [E >> 16 & 255, E >> 8 & 255, E & 255];
274
+ }, "value"), enumerable: false }, hexToAnsi256: { value: n((F) => s$1.rgbToAnsi256(...s$1.hexToRgb(F)), "value"), enumerable: false }, ansi256ToAnsi: { value: n((F) => {
275
+ if (F < 8) return 30 + F;
276
+ if (F < 16) return 90 + (F - 8);
277
+ let u, C, E;
278
+ if (F >= 232) u = ((F - 232) * 10 + 8) / 255, C = u, E = u;
279
+ else {
280
+ F -= 16;
281
+ const e = F % 36;
282
+ u = Math.floor(F / 36) / 5, C = Math.floor(e / 6) / 5, E = e % 6 / 5;
283
+ }
284
+ const t = Math.max(u, C, E) * 2;
285
+ if (t === 0) return 30;
286
+ let i = 30 + (Math.round(E) << 2 | Math.round(C) << 1 | Math.round(u));
287
+ return t === 2 && (i += 60), i;
288
+ }, "value"), enumerable: false }, rgbToAnsi: { value: n((F, u, C) => s$1.ansi256ToAnsi(s$1.rgbToAnsi256(F, u, C)), "value"), enumerable: false }, hexToAnsi: { value: n((F) => s$1.ansi256ToAnsi(s$1.hexToAnsi256(F)), "value"), enumerable: false } }), s$1;
289
+ }
290
+ n(FD, "assembleStyles");
291
+ const CD = FD(), g = /* @__PURE__ */ new Set(["\x1B", "\x9B"]), ED = 39, m = "\x07", N = "[", eD = "]", T$1 = "m", h = `${eD}8;;`, $$1 = n((D) => `${g.values().next().value}${N}${D}${T$1}`, "wrapAnsiCode"), W$1 = n((D) => `${g.values().next().value}${h}${D}${m}`, "wrapAnsiHyperlink"), tD = n((D) => D.split(" ").map((F) => d(F)), "wordLengths"), b = n((D, F, u) => {
292
+ const C = [...F];
293
+ let E = false, t = false, i = d(w(D.at(-1)));
294
+ for (const [e, B] of C.entries()) {
295
+ const A = d(B);
296
+ if (i + A <= u ? D[D.length - 1] += B : (D.push(B), i = 0), g.has(B) && (E = true, t = C.slice(e + 1, e + 1 + h.length).join("") === h), E) {
297
+ t ? B === m && (E = false, t = false) : B === T$1 && (E = false);
298
+ continue;
299
+ }
300
+ i += A, i === u && e < C.length - 1 && (D.push(""), i = 0);
301
+ }
302
+ !i && D.at(-1).length > 0 && D.length > 1 && (D[D.length - 2] += D.pop());
303
+ }, "wrapWord"), nD = n((D) => {
304
+ const F = D.split(" ");
305
+ let u = F.length;
306
+ for (; u > 0 && !(d(F[u - 1]) > 0); ) u--;
307
+ return u === F.length ? D : F.slice(0, u).join(" ") + F.slice(u).join("");
308
+ }, "stringVisibleTrimSpacesRight"), iD = n((D, F, u = {}) => {
309
+ if (u.trim !== false && D.trim() === "") return "";
310
+ let C = "", E, t;
311
+ const i = tD(D);
312
+ let e = [""];
313
+ for (const [l, r] of D.split(" ").entries()) {
314
+ u.trim !== false && (e[e.length - 1] = e.at(-1).trimStart());
315
+ let o = d(e.at(-1));
316
+ if (l !== 0 && (o >= F && (u.wordWrap === false || u.trim === false) && (e.push(""), o = 0), (o > 0 || u.trim === false) && (e[e.length - 1] += " ", o++)), u.hard && i[l] > F) {
317
+ const c = F - o, f = 1 + Math.floor((i[l] - c - 1) / F);
318
+ Math.floor((i[l] - 1) / F) < f && e.push(""), b(e, r, F);
319
+ continue;
320
+ }
321
+ if (o + i[l] > F && o > 0 && i[l] > 0) {
322
+ if (u.wordWrap === false && o < F) {
323
+ b(e, r, F);
324
+ continue;
325
+ }
326
+ e.push("");
327
+ }
328
+ if (o + i[l] > F && u.wordWrap === false) {
329
+ b(e, r, F);
330
+ continue;
331
+ }
332
+ e[e.length - 1] += r;
333
+ }
334
+ u.trim !== false && (e = e.map((l) => nD(l)));
335
+ const B = e.join(`
336
+ `), A = [...B];
337
+ let a = 0;
338
+ for (const [l, r] of A.entries()) {
339
+ if (C += r, g.has(r)) {
340
+ const { groups: c } = new RegExp(`(?:\\${N}(?<code>\\d+)m|\\${h}(?<uri>.*)${m})`).exec(B.slice(a)) || { groups: {} };
341
+ if (c.code !== void 0) {
342
+ const f = Number.parseFloat(c.code);
343
+ E = f === ED ? void 0 : f;
344
+ } else c.uri !== void 0 && (t = c.uri.length === 0 ? void 0 : c.uri);
345
+ }
346
+ const o = CD.codes.get(Number(E));
347
+ A[l + 1] === `
348
+ ` ? (t && (C += W$1("")), E && o && (C += $$1(o))) : r === `
349
+ ` && (E && o && (C += $$1(E)), t && (C += W$1(t))), a += r.length;
350
+ }
351
+ return C;
352
+ }, "exec");
353
+ function BD(D, F, u) {
354
+ return String(D).normalize().replaceAll(`\r
355
+ `, `
356
+ `).split(`
357
+ `).map((C) => iD(C, F, u)).join(`
358
+ `);
359
+ }
360
+ n(BD, "wrapAnsi");
361
+ const I = n((D) => Array.from({ length: D }).fill(""), "emptyLines"), oD = n((D, F) => {
362
+ const u = [];
363
+ let C = 0;
364
+ for (const E of D) {
365
+ let t = 0;
366
+ const i = E.map((B) => {
367
+ let A = F[C] ?? "";
368
+ C += 1, B.preprocess && (A = B.preprocess(A)), x$1(A) > B.width && (A = BD(A, B.width, { hard: true }));
369
+ let a = A.split(`
370
+ `);
371
+ if (B.postprocess) {
372
+ const { postprocess: l } = B;
373
+ a = a.map((r, o) => l.call(B, r, o));
374
+ }
375
+ return B.paddingTop && a.unshift(...I(B.paddingTop)), B.paddingBottom && a.push(...I(B.paddingBottom)), a.length > t && (t = a.length), { ...B, lines: a };
376
+ }), e = [];
377
+ for (let B = 0; B < t; B += 1) {
378
+ const A = i.map((a) => {
379
+ const l = a.lines[B] ?? "", r = Number.isFinite(a.width) ? " ".repeat(a.width - d(l)) : "";
380
+ let o = a.paddingLeftString;
381
+ return a.align === "right" && (o += r), o += l, a.align === "left" && (o += r), o + a.paddingRightString;
382
+ }).join("");
383
+ e.push(A);
384
+ }
385
+ u.push(e.join(`
386
+ `));
387
+ }
388
+ return u.join(`
389
+ `);
390
+ }, "renderRow"), rD = n((D, F) => {
391
+ if (!D || D.length === 0) return "";
392
+ const u = q(D), C = u.length;
393
+ if (C === 0) return "";
394
+ const { stdoutColumns: E, columns: t } = M$1(F);
395
+ if (t.length > C) throw new Error(`${t.length} columns defined, but only ${C} columns found`);
396
+ const i = X$1(E, t, u);
397
+ return D.map((e) => oD(i, e)).join(`
398
+ `);
399
+ }, "terminalColumns"), sD = ["<", ">", "=", ">=", "<="], aD = n((D) => {
400
+ if (!sD.includes(D)) throw new TypeError(`Invalid breakpoint operator: ${D}`);
401
+ }, "assertOperator"), AD = n((D) => {
402
+ const F = Object.keys(D).map((u) => {
403
+ const [C, E] = u.split(" ");
404
+ aD(C);
405
+ const t = Number.parseInt(E, 10);
406
+ if (Number.isNaN(t)) throw new TypeError(`Invalid breakpoint value: ${E}`);
407
+ const i = D[u];
408
+ return { operator: C, breakpoint: t, value: i };
409
+ }).sort((u, C) => C.breakpoint - u.breakpoint);
410
+ return (u) => F.find(({ operator: C, breakpoint: E }) => C === "=" && u === E || C === ">" && u > E || C === "<" && u < E || C === ">=" && u >= E || C === "<=" && u <= E)?.value;
411
+ }, "breakpoints");
412
+
413
+ var B = Object.defineProperty;
414
+ var s = (t, e) => B(t, "name", { value: e, configurable: true });
415
+ const R = s((t) => t.replaceAll(/[\W_]([a-z\d])?/gi, (e, r) => r ? r.toUpperCase() : ""), "camelCase"), D = s((t) => t.replaceAll(/\B([A-Z])/g, "-$1").toLowerCase(), "kebabCase"), L = { "> 80": [{ width: "content-width", paddingLeft: 2, paddingRight: 8 }, { width: "auto" }], "> 40": [{ width: "auto", paddingLeft: 2, paddingRight: 8, preprocess: s((t) => t.trim(), "preprocess") }, { width: "100%", paddingLeft: 2, paddingBottom: 1 }], "> 0": { stdoutColumns: 1e3, columns: [{ width: "content-width", paddingLeft: 2, paddingRight: 8 }, { width: "content-width" }] } };
416
+ function T(t) {
417
+ let e = false;
418
+ return { type: "table", data: { tableData: Object.keys(t).sort((a, i) => a.localeCompare(i)).map((a) => {
419
+ const i = t[a], o = "alias" in i;
420
+ return o && (e = true), { name: a, flag: i, flagFormatted: `--${D(a)}`, aliasesEnabled: e, aliasFormatted: o ? `-${i.alias}` : void 0 };
421
+ }).map((a) => (a.aliasesEnabled = e, [{ type: "flagName", data: a }, { type: "flagDescription", data: a }])), tableBreakpoints: L } };
422
+ }
423
+ s(T, "renderFlags");
424
+ const E = s((t) => !t || (t.version ?? (t.help ? t.help.version : void 0)), "getVersion"), C = s((t) => {
425
+ const e = "parent" in t && t.parent?.name;
426
+ return (e ? `${e} ` : "") + t.name;
427
+ }, "getName");
428
+ function k(t) {
429
+ const e = [];
430
+ t.name && e.push(C(t));
431
+ const r = E(t) ?? ("parent" in t && E(t.parent));
432
+ if (r && e.push(`v${r}`), e.length !== 0) return { id: "name", type: "text", data: `${e.join(" ")}
433
+ ` };
434
+ }
435
+ s(k, "getNameAndVersion");
436
+ function _(t) {
437
+ const { help: e } = t;
438
+ if (!(!e || !e.description)) return { id: "description", type: "text", data: `${e.description}
439
+ ` };
440
+ }
441
+ s(_, "getDescription");
442
+ function F(t) {
443
+ const e = t.help || {};
444
+ if ("usage" in e) return e.usage ? { id: "usage", type: "section", data: { title: "Usage:", body: Array.isArray(e.usage) ? e.usage.join(`
445
+ `) : e.usage } } : void 0;
446
+ if (t.name) {
447
+ const r = [], n = [C(t)];
448
+ if (t.flags && Object.keys(t.flags).length > 0 && n.push("[flags...]"), t.parameters && t.parameters.length > 0) {
449
+ const { parameters: a } = t, i = a.indexOf("--"), o = i !== -1 && a.slice(i + 1).some((l) => l.startsWith("<"));
450
+ n.push(a.map((l) => l !== "--" ? l : o ? "--" : "[--]").join(" "));
451
+ }
452
+ if (n.length > 1 && r.push(n.join(" ")), "commands" in t && t.commands?.length && r.push(`${t.name} <command>`), r.length > 0) return { id: "usage", type: "section", data: { title: "Usage:", body: r.join(`
453
+ `) } };
454
+ }
455
+ }
456
+ s(F, "getUsage");
457
+ function H(t) {
458
+ return !("commands" in t) || !t.commands?.length ? void 0 : { id: "commands", type: "section", data: { title: "Commands:", body: { type: "table", data: { tableData: t.commands.map((n) => {
459
+ const { help: a } = n.options;
460
+ return [n.options.name, typeof a == "object" && a.description || ""];
461
+ }), tableOptions: [{ width: "content-width", paddingLeft: 2, paddingRight: 8 }] } }, indentBody: 0 } };
462
+ }
463
+ s(H, "getCommands");
464
+ function U(t) {
465
+ if (!(!t.flags || Object.keys(t.flags).length === 0)) return { id: "flags", type: "section", data: { title: "Flags:", body: T(t.flags), indentBody: 0 } };
466
+ }
467
+ s(U, "getFlags");
468
+ function V(t) {
469
+ const { help: e } = t;
470
+ if (!e || !e.examples || e.examples.length === 0) return;
471
+ let { examples: r } = e;
472
+ if (Array.isArray(r) && (r = r.join(`
473
+ `)), r) return { id: "examples", type: "section", data: { title: "Examples:", body: r } };
474
+ }
475
+ s(V, "getExamples");
476
+ function J(t) {
477
+ if (!("alias" in t) || !t.alias) return;
478
+ const { alias: e } = t;
479
+ return { id: "aliases", type: "section", data: { title: "Aliases:", body: Array.isArray(e) ? e.join(", ") : e } };
480
+ }
481
+ s(J, "getAliases");
482
+ const M = s((t) => [k, _, F, H, U, V, J].map((e) => e(t)).filter(Boolean), "generateHelp"), W = S$1.WriteStream.prototype.hasColors();
483
+ class z {
484
+ static {
485
+ s(this, "Renderers");
486
+ }
487
+ text(e) {
488
+ return e;
489
+ }
490
+ bold(e) {
491
+ return W ? `\x1B[1m${e}\x1B[22m` : e.toLocaleUpperCase();
492
+ }
493
+ indentText({ text: e, spaces: r }) {
494
+ return e.replaceAll(/^/gm, " ".repeat(r));
495
+ }
496
+ heading(e) {
497
+ return this.bold(e);
498
+ }
499
+ section({ title: e, body: r, indentBody: n = 2 }) {
500
+ return `${(e ? `${this.heading(e)}
501
+ ` : "") + (r ? this.indentText({ text: this.render(r), spaces: n }) : "")}
502
+ `;
503
+ }
504
+ table({ tableData: e, tableOptions: r, tableBreakpoints: n }) {
505
+ return rD(e.map((a) => a.map((i) => this.render(i))), n ? AD(n) : r);
506
+ }
507
+ flagParameter(e) {
508
+ return e === Boolean ? "" : e === String ? "<string>" : e === Number ? "<number>" : Array.isArray(e) ? this.flagParameter(e[0]) : "<value>";
509
+ }
510
+ flagOperator(e) {
511
+ return " ";
512
+ }
513
+ flagName(e) {
514
+ const { flag: r, flagFormatted: n, aliasesEnabled: a, aliasFormatted: i } = e;
515
+ let o = "";
516
+ if (i ? o += `${i}, ` : a && (o += " "), o += n, "placeholder" in r && typeof r.placeholder == "string") o += `${this.flagOperator(e)}${r.placeholder}`;
517
+ else {
518
+ const l = this.flagParameter("type" in r ? r.type : r);
519
+ l && (o += `${this.flagOperator(e)}${l}`);
520
+ }
521
+ return o;
522
+ }
523
+ flagDefault(e) {
524
+ return JSON.stringify(e);
525
+ }
526
+ flagDescription({ flag: e }) {
527
+ let r = "description" in e ? e.description ?? "" : "";
528
+ if ("default" in e) {
529
+ let { default: n } = e;
530
+ typeof n == "function" && (n = n()), n && (r += ` (default: ${this.flagDefault(n)})`);
531
+ }
532
+ return r;
533
+ }
534
+ render(e) {
535
+ if (typeof e == "string") return e;
536
+ if (Array.isArray(e)) return e.map((r) => this.render(r)).join(`
537
+ `);
538
+ if ("type" in e && this[e.type]) {
539
+ const r = this[e.type];
540
+ if (typeof r == "function") return r.call(this, e.data);
541
+ }
542
+ throw new Error(`Invalid node type: ${JSON.stringify(e)}`);
543
+ }
544
+ }
545
+ const $ = s((t) => t.length > 0 && !t.includes(" "), "isValidScriptName"), { stringify: f } = JSON, Z = /[|\\{}()[\]^$+*?.]/;
546
+ function x(t) {
547
+ const e = [];
548
+ let r, n;
549
+ for (const a of t) {
550
+ if (n) throw new Error(`Invalid parameter: Spread parameter ${f(n)} must be last`);
551
+ const i = a[0], o = a.at(-1);
552
+ let l;
553
+ if (i === "<" && o === ">" && (l = true, r)) throw new Error(`Invalid parameter: Required parameter ${f(a)} cannot come after optional parameter ${f(r)}`);
554
+ if (i === "[" && o === "]" && (l = false, r = a), l === void 0) throw new Error(`Invalid parameter: ${f(a)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);
555
+ let c = a.slice(1, -1);
556
+ const m = c.slice(-3) === "...";
557
+ m && (n = a, c = c.slice(0, -3));
558
+ const u = c.match(Z);
559
+ if (u) throw new Error(`Invalid parameter: ${f(a)}. Invalid character found ${f(u[0])}`);
560
+ e.push({ name: c, required: l, spread: m });
561
+ }
562
+ return e;
563
+ }
564
+ s(x, "parseParameters");
565
+ function O(t, e, r, n) {
566
+ for (let a = 0; a < e.length; a += 1) {
567
+ const { name: i, required: o, spread: l } = e[a], c = R(i);
568
+ if (c in t) throw new Error(`Invalid parameter: ${f(i)} is used more than once.`);
569
+ const m = l ? r.slice(a) : r[a];
570
+ if (l && (a = e.length), o && (!m || l && m.length === 0)) return console.error(`Error: Missing required parameter ${f(i)}
571
+ `), n(), process.exit(1);
572
+ t[c] = m;
573
+ }
574
+ }
575
+ s(O, "mapParametersToArguments");
576
+ function G(t) {
577
+ return t !== false;
578
+ }
579
+ s(G, "helpEnabled");
580
+ function j(t, e, r, n) {
581
+ const a = { ...e.flags }, i = e.version && !("version" in a);
582
+ i && (a.version = { type: Boolean, description: "Show version" });
583
+ const { help: o } = e, l = G(o);
584
+ l && !("help" in a) && (a.help = { type: Boolean, alias: "h", description: "Show help" });
585
+ const c = z$2(a, n, { ignore: e.ignoreArgv }), m = s(() => {
586
+ console.log(e.version);
587
+ }, "showVersion");
588
+ if (i && c.flags.version === true) return m(), process.exit(0);
589
+ const u = new z(), N = l && o?.render ? o.render : (d) => u.render(d), h = s((d) => {
590
+ const p = M({ ...e, ...d ? { help: d } : {}, flags: a });
591
+ console.log(N(p, u));
592
+ }, "showHelp");
593
+ if (l && c.flags.help === true) return h(), process.exit(0);
594
+ if (e.parameters) {
595
+ let { parameters: d } = e, p = c._;
596
+ const g = d.indexOf("--"), y = d.slice(g + 1), w = /* @__PURE__ */ Object.create(null);
597
+ let b = [];
598
+ g > -1 && y.length > 0 && (d = d.slice(0, g), b = c._["--"], p = p.slice(0, -b.length || void 0)), O(w, x(d), p, h), g > -1 && y.length > 0 && O(w, x(y), b, h), Object.assign(c._, w);
599
+ }
600
+ const v = { ...c, showVersion: m, showHelp: h }, A = { command: t, ...v };
601
+ if (typeof r == "function") {
602
+ const d = r(v);
603
+ if (d && "then" in d) return Object.assign(Promise.resolve(d), A);
604
+ }
605
+ return A;
606
+ }
607
+ s(j, "cliBase");
608
+ function K(t, e) {
609
+ const r = /* @__PURE__ */ new Map();
610
+ for (const n of e) {
611
+ const a = [n.options.name], { alias: i } = n.options;
612
+ i && (Array.isArray(i) ? a.push(...i) : a.push(i));
613
+ for (const o of a) {
614
+ if (r.has(o)) throw new Error(`Duplicate command name found: ${f(o)}`);
615
+ r.set(o, n);
616
+ }
617
+ }
618
+ return r.get(t);
619
+ }
620
+ s(K, "getCommand");
621
+ function Q(t, e, r = process.argv.slice(2)) {
622
+ if (!t) throw new Error("Options is required");
623
+ if ("name" in t && (!t.name || !$(t.name))) throw new Error(`Invalid script name: ${f(t.name)}`);
624
+ const n = r[0];
625
+ if (t.commands && n && $(n)) {
626
+ const a = K(n, t.commands);
627
+ if (a) return j(a.options.name, { ...a.options, parent: t }, a.callback, r.slice(1));
628
+ }
629
+ return j(void 0, t, e, r);
630
+ }
631
+ s(Q, "cli");
632
+ function X(t, e) {
633
+ if (!t) throw new Error("Command options are required");
634
+ const { name: r } = t;
635
+ if (r === void 0) throw new Error("Command name is required");
636
+ if (!$(r)) throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);
637
+ return { options: t, callback: e };
638
+ }
639
+ s(X, "command");
640
+
641
+ const peq = new Uint32Array(65536);
642
+ const myers_32 = (a, b) => {
643
+ const n = a.length;
644
+ const m = b.length;
645
+ const lst = 1 << n - 1;
646
+ let pv = -1;
647
+ let mv = 0;
648
+ let sc = n;
649
+ let i = n;
650
+ while (i--) {
651
+ peq[a.charCodeAt(i)] |= 1 << i;
652
+ }
653
+ for (i = 0; i < m; i++) {
654
+ let eq = peq[b.charCodeAt(i)];
655
+ const xv = eq | mv;
656
+ eq |= (eq & pv) + pv ^ pv;
657
+ mv |= ~(eq | pv);
658
+ pv &= eq;
659
+ if (mv & lst) {
660
+ sc++;
661
+ }
662
+ if (pv & lst) {
663
+ sc--;
664
+ }
665
+ mv = mv << 1 | 1;
666
+ pv = pv << 1 | ~(xv | mv);
667
+ mv &= xv;
668
+ }
669
+ i = n;
670
+ while (i--) {
671
+ peq[a.charCodeAt(i)] = 0;
672
+ }
673
+ return sc;
674
+ };
675
+ const myers_x = (b, a) => {
676
+ const n = a.length;
677
+ const m = b.length;
678
+ const mhc = [];
679
+ const phc = [];
680
+ const hsize = Math.ceil(n / 32);
681
+ const vsize = Math.ceil(m / 32);
682
+ for (let i = 0; i < hsize; i++) {
683
+ phc[i] = -1;
684
+ mhc[i] = 0;
685
+ }
686
+ let j = 0;
687
+ for (; j < vsize - 1; j++) {
688
+ let mv2 = 0;
689
+ let pv2 = -1;
690
+ const start2 = j * 32;
691
+ const vlen2 = Math.min(32, m) + start2;
692
+ for (let k = start2; k < vlen2; k++) {
693
+ peq[b.charCodeAt(k)] |= 1 << k;
694
+ }
695
+ for (let i = 0; i < n; i++) {
696
+ const eq = peq[a.charCodeAt(i)];
697
+ const pb = phc[i / 32 | 0] >>> i & 1;
698
+ const mb = mhc[i / 32 | 0] >>> i & 1;
699
+ const xv = eq | mv2;
700
+ const xh = ((eq | mb) & pv2) + pv2 ^ pv2 | eq | mb;
701
+ let ph = mv2 | ~(xh | pv2);
702
+ let mh = pv2 & xh;
703
+ if (ph >>> 31 ^ pb) {
704
+ phc[i / 32 | 0] ^= 1 << i;
705
+ }
706
+ if (mh >>> 31 ^ mb) {
707
+ mhc[i / 32 | 0] ^= 1 << i;
708
+ }
709
+ ph = ph << 1 | pb;
710
+ mh = mh << 1 | mb;
711
+ pv2 = mh | ~(xv | ph);
712
+ mv2 = ph & xv;
713
+ }
714
+ for (let k = start2; k < vlen2; k++) {
715
+ peq[b.charCodeAt(k)] = 0;
716
+ }
717
+ }
718
+ let mv = 0;
719
+ let pv = -1;
720
+ const start = j * 32;
721
+ const vlen = Math.min(32, m - start) + start;
722
+ for (let k = start; k < vlen; k++) {
723
+ peq[b.charCodeAt(k)] |= 1 << k;
724
+ }
725
+ let score = m;
726
+ for (let i = 0; i < n; i++) {
727
+ const eq = peq[a.charCodeAt(i)];
728
+ const pb = phc[i / 32 | 0] >>> i & 1;
729
+ const mb = mhc[i / 32 | 0] >>> i & 1;
730
+ const xv = eq | mv;
731
+ const xh = ((eq | mb) & pv) + pv ^ pv | eq | mb;
732
+ let ph = mv | ~(xh | pv);
733
+ let mh = pv & xh;
734
+ score += ph >>> m - 1 & 1;
735
+ score -= mh >>> m - 1 & 1;
736
+ if (ph >>> 31 ^ pb) {
737
+ phc[i / 32 | 0] ^= 1 << i;
738
+ }
739
+ if (mh >>> 31 ^ mb) {
740
+ mhc[i / 32 | 0] ^= 1 << i;
741
+ }
742
+ ph = ph << 1 | pb;
743
+ mh = mh << 1 | mb;
744
+ pv = mh | ~(xv | ph);
745
+ mv = ph & xv;
746
+ }
747
+ for (let k = start; k < vlen; k++) {
748
+ peq[b.charCodeAt(k)] = 0;
749
+ }
750
+ return score;
751
+ };
752
+ const distance = (a, b) => {
753
+ if (a.length < b.length) {
754
+ const tmp = b;
755
+ b = a;
756
+ a = tmp;
757
+ }
758
+ if (b.length === 0) {
759
+ return a.length;
760
+ }
761
+ if (a.length <= 32) {
762
+ return myers_32(a, b);
763
+ }
764
+ return myers_x(a, b);
765
+ };
766
+ const closest = (str, arr) => {
767
+ let min_distance = Infinity;
768
+ let min_index = 0;
769
+ for (let i = 0; i < arr.length; i++) {
770
+ const dist = distance(str, arr[i]);
771
+ if (dist < min_distance) {
772
+ min_distance = dist;
773
+ min_index = i;
774
+ }
775
+ }
776
+ return arr[min_index];
777
+ };
778
+
779
+ var name = "poof";
780
+ var version = "3.0.1";
781
+ var description = "Fast, non-blocking rm -rf alternative. Deletes files instantly while cleanup runs in the background.";
782
+ var packageJson = {
783
+ name: name,
784
+ version: version,
785
+ description: description};
786
+
787
+ const knownFlags = ["dry", "verbose", "dangerous", "version", "help"];
788
+ const findClosestFlag = (unknown) => {
789
+ const match = closest(unknown, knownFlags);
790
+ return distance(unknown, match) <= 2 ? match : void 0;
791
+ };
792
+ const friendlyMessages = {
793
+ EBUSY: "Resource busy or locked",
794
+ EPERM: "Operation not permitted",
795
+ ENOENT: "File not found"
796
+ };
797
+ const formatError = ({ error }) => {
798
+ const { code, message } = error;
799
+ if (code && code in friendlyMessages) {
800
+ return friendlyMessages[code];
801
+ }
802
+ return message;
803
+ };
804
+ const argv = Q({
805
+ name: packageJson.name,
806
+ version: packageJson.version,
807
+ parameters: ["[globs...]"],
808
+ help: {
809
+ description: packageJson.description
810
+ },
811
+ flags: {
812
+ dry: {
813
+ type: Boolean,
814
+ alias: "d",
815
+ description: "Simulate the deletion"
816
+ },
817
+ verbose: {
818
+ type: Boolean,
819
+ alias: "v",
820
+ description: "Log removed files"
821
+ },
822
+ dangerous: {
823
+ type: Boolean,
824
+ description: "Allow deleting paths outside current directory"
825
+ }
826
+ }
827
+ });
828
+ const unknownFlags = Object.keys(argv.unknownFlags);
829
+ if (unknownFlags.length > 0) {
830
+ for (const flag of unknownFlags) {
831
+ const closestMatch = findClosestFlag(flag);
832
+ const suggestion = closestMatch ? ` (Did you mean --${closestMatch}?)` : "";
833
+ console.error(`Unknown flag: --${flag}.${suggestion}`);
834
+ }
835
+ process.exit(1);
836
+ }
837
+ (async () => {
838
+ const { globs } = argv._;
839
+ if (globs.length === 0) {
840
+ argv.showHelp();
841
+ return;
842
+ }
843
+ const cwd = process.cwd();
844
+ const { deleted, errors } = await poof(globs, {
845
+ dry: argv.flags.dry,
846
+ dangerous: argv.flags.dangerous
847
+ });
848
+ if (deleted.length === 0 && errors.length === 0) {
849
+ console.warn("No matches found");
850
+ }
851
+ if (argv.flags.dry) {
852
+ console.log("Dry run (no files deleted)");
853
+ if (deleted.length > 0) {
854
+ console.log("Would delete:");
855
+ for (const file of deleted) {
856
+ console.log(` - ${path.relative(cwd, file)}`);
857
+ }
858
+ }
859
+ return;
860
+ }
861
+ if (argv.flags.verbose) {
862
+ for (const file of deleted) {
863
+ console.log(`Removed: ${path.relative(cwd, file)}`);
864
+ }
865
+ }
866
+ if (errors.length > 0) {
867
+ console.error("Errors:");
868
+ for (const error of errors) {
869
+ const displayPath = path.isAbsolute(error.path) ? path.relative(cwd, error.path) : error.path;
870
+ console.error(` - ${displayPath}: ${formatError(error)}`);
871
+ }
872
+ process.exit(1);
873
+ }
874
+ })().catch((error) => {
875
+ console.error(error);
876
+ process.exit(1);
877
+ });