main
1"use strict";
2const {
3 __create,
4 __spreadValues,
5 __spreadProps,
6 __commonJS,
7 __export,
8 __toESM,
9 __toCommonJS,
10 __async
11} = require('./esblib.cjs');
12
13
14// node_modules/isexe/dist/cjs/posix.js
15var require_posix = __commonJS({
16 "node_modules/isexe/dist/cjs/posix.js"(exports2) {
17 "use strict";
18 Object.defineProperty(exports2, "__esModule", { value: true });
19 exports2.sync = exports2.isexe = void 0;
20 var fs_1 = require("fs");
21 var promises_1 = require("fs").promises;
22 var isexe = (_0, ..._1) => __async(null, [_0, ..._1], function* (path, options = {}) {
23 const { ignoreErrors = false } = options;
24 try {
25 return checkStat(yield (0, promises_1.stat)(path), options);
26 } catch (e) {
27 const er = e;
28 if (ignoreErrors || er.code === "EACCES")
29 return false;
30 throw er;
31 }
32 });
33 exports2.isexe = isexe;
34 var sync = (path, options = {}) => {
35 const { ignoreErrors = false } = options;
36 try {
37 return checkStat((0, fs_1.statSync)(path), options);
38 } catch (e) {
39 const er = e;
40 if (ignoreErrors || er.code === "EACCES")
41 return false;
42 throw er;
43 }
44 };
45 exports2.sync = sync;
46 var checkStat = (stat, options) => stat.isFile() && checkMode(stat, options);
47 var checkMode = (stat, options) => {
48 var _a, _b, _c, _d, _e, _f, _g, _h;
49 const myUid = (_b = options.uid) != null ? _b : (_a = process.getuid) == null ? void 0 : _a.call(process);
50 const myGroups = (_e = (_d = options.groups) != null ? _d : (_c = process.getgroups) == null ? void 0 : _c.call(process)) != null ? _e : [];
51 const myGid = (_h = (_g = options.gid) != null ? _g : (_f = process.getgid) == null ? void 0 : _f.call(process)) != null ? _h : myGroups[0];
52 if (myUid === void 0 || myGid === void 0) {
53 throw new Error("cannot get uid or gid");
54 }
55 const groups = /* @__PURE__ */ new Set([myGid, ...myGroups]);
56 const mod = stat.mode;
57 const uid = stat.uid;
58 const gid = stat.gid;
59 const u = parseInt("100", 8);
60 const g2 = parseInt("010", 8);
61 const o = parseInt("001", 8);
62 const ug = u | g2;
63 return !!(mod & o || mod & g2 && groups.has(gid) || mod & u && uid === myUid || mod & ug && myUid === 0);
64 };
65 }
66});
67
68// node_modules/isexe/dist/cjs/win32.js
69var require_win32 = __commonJS({
70 "node_modules/isexe/dist/cjs/win32.js"(exports2) {
71 "use strict";
72 Object.defineProperty(exports2, "__esModule", { value: true });
73 exports2.sync = exports2.isexe = void 0;
74 var fs_1 = require("fs");
75 var promises_1 = require("fs").promises;
76 var isexe = (_0, ..._1) => __async(null, [_0, ..._1], function* (path, options = {}) {
77 const { ignoreErrors = false } = options;
78 try {
79 return checkStat(yield (0, promises_1.stat)(path), path, options);
80 } catch (e) {
81 const er = e;
82 if (ignoreErrors || er.code === "EACCES")
83 return false;
84 throw er;
85 }
86 });
87 exports2.isexe = isexe;
88 var sync = (path, options = {}) => {
89 const { ignoreErrors = false } = options;
90 try {
91 return checkStat((0, fs_1.statSync)(path), path, options);
92 } catch (e) {
93 const er = e;
94 if (ignoreErrors || er.code === "EACCES")
95 return false;
96 throw er;
97 }
98 };
99 exports2.sync = sync;
100 var checkPathExt = (path, options) => {
101 const { pathExt = process.env.PATHEXT || "" } = options;
102 const peSplit = pathExt.split(";");
103 if (peSplit.indexOf("") !== -1) {
104 return true;
105 }
106 for (let i = 0; i < peSplit.length; i++) {
107 const p = peSplit[i].toLowerCase();
108 const ext = path.substring(path.length - p.length).toLowerCase();
109 if (p && ext === p) {
110 return true;
111 }
112 }
113 return false;
114 };
115 var checkStat = (stat, path, options) => stat.isFile() && checkPathExt(path, options);
116 }
117});
118
119// node_modules/isexe/dist/cjs/options.js
120var require_options = __commonJS({
121 "node_modules/isexe/dist/cjs/options.js"(exports2) {
122 "use strict";
123 Object.defineProperty(exports2, "__esModule", { value: true });
124 }
125});
126
127// node_modules/isexe/dist/cjs/index.js
128var require_cjs = __commonJS({
129 "node_modules/isexe/dist/cjs/index.js"(exports2) {
130 "use strict";
131 var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
132 if (k2 === void 0) k2 = k;
133 var desc = Object.getOwnPropertyDescriptor(m, k);
134 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
135 desc = { enumerable: true, get: function() {
136 return m[k];
137 } };
138 }
139 Object.defineProperty(o, k2, desc);
140 }) : (function(o, m, k, k2) {
141 if (k2 === void 0) k2 = k;
142 o[k2] = m[k];
143 }));
144 var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
145 Object.defineProperty(o, "default", { enumerable: true, value: v });
146 }) : function(o, v) {
147 o["default"] = v;
148 });
149 var __importStar = exports2 && exports2.__importStar || function(mod) {
150 if (mod && mod.__esModule) return mod;
151 var result = {};
152 if (mod != null) {
153 for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
154 }
155 __setModuleDefault(result, mod);
156 return result;
157 };
158 var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
159 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
160 };
161 Object.defineProperty(exports2, "__esModule", { value: true });
162 exports2.sync = exports2.isexe = exports2.posix = exports2.win32 = void 0;
163 var posix = __importStar(require_posix());
164 exports2.posix = posix;
165 var win32 = __importStar(require_win32());
166 exports2.win32 = win32;
167 __exportStar(require_options(), exports2);
168 var platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
169 var impl = platform === "win32" ? win32 : posix;
170 exports2.isexe = impl.isexe;
171 exports2.sync = impl.sync;
172 }
173});
174
175// node_modules/which/lib/index.js
176var require_lib = __commonJS({
177 "node_modules/which/lib/index.js"(exports2, module2) {
178 "use strict";
179 var { isexe, sync: isexeSync } = require_cjs();
180 var { join, delimiter, sep, posix } = require("path");
181 var isWindows = process.platform === "win32";
182 var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
183 var rRel = new RegExp(`^\\.${rSlash.source}`);
184 var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
185 var getPathInfo = (cmd, {
186 path: optPath = process.env.PATH,
187 pathExt: optPathExt = process.env.PATHEXT,
188 delimiter: optDelimiter = delimiter
189 }) => {
190 const pathEnv = cmd.match(rSlash) ? [""] : [
191 // windows always checks the cwd first
192 ...isWindows ? [process.cwd()] : [],
193 ...(optPath || /* istanbul ignore next: very unusual */
194 "").split(optDelimiter)
195 ];
196 if (isWindows) {
197 const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
198 const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]);
199 if (cmd.includes(".") && pathExt[0] !== "") {
200 pathExt.unshift("");
201 }
202 return { pathEnv, pathExt, pathExtExe };
203 }
204 return { pathEnv, pathExt: [""] };
205 };
206 var getPathPart = (raw, cmd) => {
207 const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
208 const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
209 return prefix + join(pathPart, cmd);
210 };
211 var which2 = (_0, ..._1) => __async(null, [_0, ..._1], function* (cmd, opt = {}) {
212 const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
213 const found = [];
214 for (const envPart of pathEnv) {
215 const p = getPathPart(envPart, cmd);
216 for (const ext of pathExt) {
217 const withExt = p + ext;
218 const is = yield isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
219 if (is) {
220 if (!opt.all) {
221 return withExt;
222 }
223 found.push(withExt);
224 }
225 }
226 }
227 if (opt.all && found.length) {
228 return found;
229 }
230 if (opt.nothrow) {
231 return null;
232 }
233 throw getNotFoundError(cmd);
234 });
235 var whichSync = (cmd, opt = {}) => {
236 const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
237 const found = [];
238 for (const pathEnvPart of pathEnv) {
239 const p = getPathPart(pathEnvPart, cmd);
240 for (const ext of pathExt) {
241 const withExt = p + ext;
242 const is = isexeSync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
243 if (is) {
244 if (!opt.all) {
245 return withExt;
246 }
247 found.push(withExt);
248 }
249 }
250 }
251 if (opt.all && found.length) {
252 return found;
253 }
254 if (opt.nothrow) {
255 return null;
256 }
257 throw getNotFoundError(cmd);
258 };
259 module2.exports = which2;
260 which2.sync = whichSync;
261 }
262});
263
264// src/vendor-core.ts
265var vendor_core_exports = {};
266__export(vendor_core_exports, {
267 VoidStream: () => VoidStream,
268 buildCmd: () => buildCmd,
269 chalk: () => chalk2,
270 exec: () => exec,
271 isStringLiteral: () => isStringLiteral,
272 ps: () => ps,
273 which: () => which
274});
275module.exports = __toCommonJS(vendor_core_exports);
276
277// node_modules/chalk/source/vendor/ansi-styles/index.js
278var ANSI_BACKGROUND_OFFSET = 10;
279var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
280var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
281var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
282var styles = {
283 modifier: {
284 reset: [0, 0],
285 // 21 isn't widely supported and 22 does the same thing
286 bold: [1, 22],
287 dim: [2, 22],
288 italic: [3, 23],
289 underline: [4, 24],
290 overline: [53, 55],
291 inverse: [7, 27],
292 hidden: [8, 28],
293 strikethrough: [9, 29]
294 },
295 color: {
296 black: [30, 39],
297 red: [31, 39],
298 green: [32, 39],
299 yellow: [33, 39],
300 blue: [34, 39],
301 magenta: [35, 39],
302 cyan: [36, 39],
303 white: [37, 39],
304 // Bright color
305 blackBright: [90, 39],
306 gray: [90, 39],
307 // Alias of `blackBright`
308 grey: [90, 39],
309 // Alias of `blackBright`
310 redBright: [91, 39],
311 greenBright: [92, 39],
312 yellowBright: [93, 39],
313 blueBright: [94, 39],
314 magentaBright: [95, 39],
315 cyanBright: [96, 39],
316 whiteBright: [97, 39]
317 },
318 bgColor: {
319 bgBlack: [40, 49],
320 bgRed: [41, 49],
321 bgGreen: [42, 49],
322 bgYellow: [43, 49],
323 bgBlue: [44, 49],
324 bgMagenta: [45, 49],
325 bgCyan: [46, 49],
326 bgWhite: [47, 49],
327 // Bright color
328 bgBlackBright: [100, 49],
329 bgGray: [100, 49],
330 // Alias of `bgBlackBright`
331 bgGrey: [100, 49],
332 // Alias of `bgBlackBright`
333 bgRedBright: [101, 49],
334 bgGreenBright: [102, 49],
335 bgYellowBright: [103, 49],
336 bgBlueBright: [104, 49],
337 bgMagentaBright: [105, 49],
338 bgCyanBright: [106, 49],
339 bgWhiteBright: [107, 49]
340 }
341};
342var modifierNames = Object.keys(styles.modifier);
343var foregroundColorNames = Object.keys(styles.color);
344var backgroundColorNames = Object.keys(styles.bgColor);
345var colorNames = [...foregroundColorNames, ...backgroundColorNames];
346function assembleStyles() {
347 const codes = /* @__PURE__ */ new Map();
348 for (const [groupName, group] of Object.entries(styles)) {
349 for (const [styleName, style] of Object.entries(group)) {
350 styles[styleName] = {
351 open: `\x1B[${style[0]}m`,
352 close: `\x1B[${style[1]}m`
353 };
354 group[styleName] = styles[styleName];
355 codes.set(style[0], style[1]);
356 }
357 Object.defineProperty(styles, groupName, {
358 value: group,
359 enumerable: false
360 });
361 }
362 Object.defineProperty(styles, "codes", {
363 value: codes,
364 enumerable: false
365 });
366 styles.color.close = "\x1B[39m";
367 styles.bgColor.close = "\x1B[49m";
368 styles.color.ansi = wrapAnsi16();
369 styles.color.ansi256 = wrapAnsi256();
370 styles.color.ansi16m = wrapAnsi16m();
371 styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
372 styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
373 styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
374 Object.defineProperties(styles, {
375 rgbToAnsi256: {
376 value(red, green, blue) {
377 if (red === green && green === blue) {
378 if (red < 8) {
379 return 16;
380 }
381 if (red > 248) {
382 return 231;
383 }
384 return Math.round((red - 8) / 247 * 24) + 232;
385 }
386 return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
387 },
388 enumerable: false
389 },
390 hexToRgb: {
391 value(hex) {
392 const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
393 if (!matches) {
394 return [0, 0, 0];
395 }
396 let [colorString] = matches;
397 if (colorString.length === 3) {
398 colorString = [...colorString].map((character) => character + character).join("");
399 }
400 const integer = Number.parseInt(colorString, 16);
401 return [
402 /* eslint-disable no-bitwise */
403 integer >> 16 & 255,
404 integer >> 8 & 255,
405 integer & 255
406 /* eslint-enable no-bitwise */
407 ];
408 },
409 enumerable: false
410 },
411 hexToAnsi256: {
412 value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
413 enumerable: false
414 },
415 ansi256ToAnsi: {
416 value(code) {
417 if (code < 8) {
418 return 30 + code;
419 }
420 if (code < 16) {
421 return 90 + (code - 8);
422 }
423 let red;
424 let green;
425 let blue;
426 if (code >= 232) {
427 red = ((code - 232) * 10 + 8) / 255;
428 green = red;
429 blue = red;
430 } else {
431 code -= 16;
432 const remainder = code % 36;
433 red = Math.floor(code / 36) / 5;
434 green = Math.floor(remainder / 6) / 5;
435 blue = remainder % 6 / 5;
436 }
437 const value = Math.max(red, green, blue) * 2;
438 if (value === 0) {
439 return 30;
440 }
441 let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
442 if (value === 2) {
443 result += 60;
444 }
445 return result;
446 },
447 enumerable: false
448 },
449 rgbToAnsi: {
450 value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
451 enumerable: false
452 },
453 hexToAnsi: {
454 value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
455 enumerable: false
456 }
457 });
458 return styles;
459}
460var ansiStyles = assembleStyles();
461var ansi_styles_default = ansiStyles;
462
463// node_modules/chalk/source/vendor/supports-color/index.js
464var import_node_process = __toESM(require("process"), 1);
465var import_node_os = __toESM(require("os"), 1);
466var import_node_tty = __toESM(require("tty"), 1);
467function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
468 const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
469 const position = argv.indexOf(prefix + flag);
470 const terminatorPosition = argv.indexOf("--");
471 return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
472}
473var { env } = import_node_process.default;
474var flagForceColor;
475if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
476 flagForceColor = 0;
477} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
478 flagForceColor = 1;
479}
480function envForceColor() {
481 if ("FORCE_COLOR" in env) {
482 if (env.FORCE_COLOR === "true") {
483 return 1;
484 }
485 if (env.FORCE_COLOR === "false") {
486 return 0;
487 }
488 return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
489 }
490}
491function translateLevel(level) {
492 if (level === 0) {
493 return false;
494 }
495 return {
496 level,
497 hasBasic: true,
498 has256: level >= 2,
499 has16m: level >= 3
500 };
501}
502function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
503 const noFlagForceColor = envForceColor();
504 if (noFlagForceColor !== void 0) {
505 flagForceColor = noFlagForceColor;
506 }
507 const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
508 if (forceColor === 0) {
509 return 0;
510 }
511 if (sniffFlags) {
512 if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
513 return 3;
514 }
515 if (hasFlag("color=256")) {
516 return 2;
517 }
518 }
519 if ("TF_BUILD" in env && "AGENT_NAME" in env) {
520 return 1;
521 }
522 if (haveStream && !streamIsTTY && forceColor === void 0) {
523 return 0;
524 }
525 const min = forceColor || 0;
526 if (env.TERM === "dumb") {
527 return min;
528 }
529 if (import_node_process.default.platform === "win32") {
530 const osRelease = import_node_os.default.release().split(".");
531 if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
532 return Number(osRelease[2]) >= 14931 ? 3 : 2;
533 }
534 return 1;
535 }
536 if ("CI" in env) {
537 if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
538 return 3;
539 }
540 if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
541 return 1;
542 }
543 return min;
544 }
545 if ("TEAMCITY_VERSION" in env) {
546 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
547 }
548 if (env.COLORTERM === "truecolor") {
549 return 3;
550 }
551 if (env.TERM === "xterm-kitty") {
552 return 3;
553 }
554 if (env.TERM === "xterm-ghostty") {
555 return 3;
556 }
557 if (env.TERM === "wezterm") {
558 return 3;
559 }
560 if ("TERM_PROGRAM" in env) {
561 const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
562 switch (env.TERM_PROGRAM) {
563 case "iTerm.app": {
564 return version >= 3 ? 3 : 2;
565 }
566 case "Apple_Terminal": {
567 return 2;
568 }
569 }
570 }
571 if (/-256(color)?$/i.test(env.TERM)) {
572 return 2;
573 }
574 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
575 return 1;
576 }
577 if ("COLORTERM" in env) {
578 return 1;
579 }
580 return min;
581}
582function createSupportsColor(stream, options = {}) {
583 const level = _supportsColor(stream, __spreadValues({
584 streamIsTTY: stream && stream.isTTY
585 }, options));
586 return translateLevel(level);
587}
588var supportsColor = {
589 stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
590 stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
591};
592var supports_color_default = supportsColor;
593
594// node_modules/chalk/source/utilities.js
595function stringReplaceAll(string, substring, replacer) {
596 let index = string.indexOf(substring);
597 if (index === -1) {
598 return string;
599 }
600 const substringLength = substring.length;
601 let endIndex = 0;
602 let returnValue = "";
603 do {
604 returnValue += string.slice(endIndex, index) + substring + replacer;
605 endIndex = index + substringLength;
606 index = string.indexOf(substring, endIndex);
607 } while (index !== -1);
608 returnValue += string.slice(endIndex);
609 return returnValue;
610}
611function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
612 let endIndex = 0;
613 let returnValue = "";
614 do {
615 const gotCR = string[index - 1] === "\r";
616 returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
617 endIndex = index + 1;
618 index = string.indexOf("\n", endIndex);
619 } while (index !== -1);
620 returnValue += string.slice(endIndex);
621 return returnValue;
622}
623
624// node_modules/chalk/source/index.js
625var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
626var GENERATOR = Symbol("GENERATOR");
627var STYLER = Symbol("STYLER");
628var IS_EMPTY = Symbol("IS_EMPTY");
629var levelMapping = [
630 "ansi",
631 "ansi",
632 "ansi256",
633 "ansi16m"
634];
635var styles2 = /* @__PURE__ */ Object.create(null);
636var applyOptions = (object, options = {}) => {
637 if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
638 throw new Error("The `level` option should be an integer from 0 to 3");
639 }
640 const colorLevel = stdoutColor ? stdoutColor.level : 0;
641 object.level = options.level === void 0 ? colorLevel : options.level;
642};
643var chalkFactory = (options) => {
644 const chalk3 = (...strings) => strings.join(" ");
645 applyOptions(chalk3, options);
646 Object.setPrototypeOf(chalk3, createChalk.prototype);
647 return chalk3;
648};
649function createChalk(options) {
650 return chalkFactory(options);
651}
652Object.setPrototypeOf(createChalk.prototype, Function.prototype);
653for (const [styleName, style] of Object.entries(ansi_styles_default)) {
654 styles2[styleName] = {
655 get() {
656 const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
657 Object.defineProperty(this, styleName, { value: builder });
658 return builder;
659 }
660 };
661}
662styles2.visible = {
663 get() {
664 const builder = createBuilder(this, this[STYLER], true);
665 Object.defineProperty(this, "visible", { value: builder });
666 return builder;
667 }
668};
669var getModelAnsi = (model, level, type, ...arguments_) => {
670 if (model === "rgb") {
671 if (level === "ansi16m") {
672 return ansi_styles_default[type].ansi16m(...arguments_);
673 }
674 if (level === "ansi256") {
675 return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
676 }
677 return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
678 }
679 if (model === "hex") {
680 return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
681 }
682 return ansi_styles_default[type][model](...arguments_);
683};
684var usedModels = ["rgb", "hex", "ansi256"];
685for (const model of usedModels) {
686 styles2[model] = {
687 get() {
688 const { level } = this;
689 return function(...arguments_) {
690 const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
691 return createBuilder(this, styler, this[IS_EMPTY]);
692 };
693 }
694 };
695 const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
696 styles2[bgModel] = {
697 get() {
698 const { level } = this;
699 return function(...arguments_) {
700 const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
701 return createBuilder(this, styler, this[IS_EMPTY]);
702 };
703 }
704 };
705}
706var proto = Object.defineProperties(() => {
707}, __spreadProps(__spreadValues({}, styles2), {
708 level: {
709 enumerable: true,
710 get() {
711 return this[GENERATOR].level;
712 },
713 set(level) {
714 this[GENERATOR].level = level;
715 }
716 }
717}));
718var createStyler = (open, close, parent) => {
719 let openAll;
720 let closeAll;
721 if (parent === void 0) {
722 openAll = open;
723 closeAll = close;
724 } else {
725 openAll = parent.openAll + open;
726 closeAll = close + parent.closeAll;
727 }
728 return {
729 open,
730 close,
731 openAll,
732 closeAll,
733 parent
734 };
735};
736var createBuilder = (self, _styler, _isEmpty) => {
737 const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
738 Object.setPrototypeOf(builder, proto);
739 builder[GENERATOR] = self;
740 builder[STYLER] = _styler;
741 builder[IS_EMPTY] = _isEmpty;
742 return builder;
743};
744var applyStyle = (self, string) => {
745 if (self.level <= 0 || !string) {
746 return self[IS_EMPTY] ? "" : string;
747 }
748 let styler = self[STYLER];
749 if (styler === void 0) {
750 return string;
751 }
752 const { openAll, closeAll } = styler;
753 if (string.includes("\x1B")) {
754 while (styler !== void 0) {
755 string = stringReplaceAll(string, styler.close, styler.open);
756 styler = styler.parent;
757 }
758 }
759 const lfIndex = string.indexOf("\n");
760 if (lfIndex !== -1) {
761 string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
762 }
763 return openAll + string + closeAll;
764};
765Object.defineProperties(createChalk.prototype, styles2);
766var chalk = createChalk();
767var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
768var source_default = chalk;
769
770// src/vendor-core.ts
771var import_which = __toESM(require_lib(), 1);
772
773// node_modules/@webpod/ps/target/esm/index.mjs
774var import_node_process4 = __toESM(require("process"), 1);
775var import_node_fs = __toESM(require("fs"), 1);
776var import_node_os2 = __toESM(require("os"), 1);
777
778// node_modules/@webpod/ingrid/target/esm/index.mjs
779var EOL = /\r?\n|\r|\n/;
780var EMPTY = "-";
781var parseLine = (line, sep = " ") => {
782 if (typeof line !== "string") throw new Error("parseLine: line must be a string");
783 const result = {
784 spaces: [],
785 words: []
786 };
787 const capture = () => {
788 if (word) {
789 result.words.push({
790 s,
791 e: s + word.length - 1,
792 w: word
793 });
794 word = "";
795 s = -1;
796 }
797 };
798 let bb;
799 let word = "";
800 let s = -1;
801 for (const i in [...line]) {
802 const prev = line[+i - 1];
803 const char = line[i];
804 if (bb) {
805 word += char;
806 if (char === bb && prev !== "\\") {
807 bb = void 0;
808 }
809 continue;
810 }
811 if (char === sep) {
812 result.spaces.push(+i);
813 capture();
814 continue;
815 }
816 if (s === -1) s = +i;
817 if (char === '"' || char === "'") bb = char;
818 word += char;
819 }
820 capture();
821 return result;
822};
823var parseLines = (input, sep) => input.split(EOL).filter(Boolean).map((l) => parseLine(l, sep));
824var countWordsByIndex = ({ words }, index) => words.filter(({ e }) => e < index).length;
825var getBorders = (lines) => lines[0].spaces.reduce((m, i) => {
826 const c = countWordsByIndex(lines[0], i);
827 if (lines.every((l) => l.spaces.includes(i) && c === countWordsByIndex(l, i))) {
828 m.push(i);
829 }
830 return m;
831}, []);
832var parseUnixGrid = (input) => {
833 const lines = parseLines(input);
834 const borders = getBorders(lines);
835 const _borders = [Number.NEGATIVE_INFINITY, ...borders, Number.POSITIVE_INFINITY];
836 const grid = [];
837 for (const { words } of lines) {
838 const row = [];
839 grid.push(row);
840 for (const n in words) {
841 const { w, s, e } = words[n];
842 for (const _b in _borders) {
843 const a = _borders[+_b];
844 const b = _borders[+_b + 1];
845 if (b === void 0) break;
846 const block = row[_b] || (row[_b] = []);
847 if (s > a && e < b) block.push(w);
848 }
849 }
850 }
851 return gridToData(grid);
852};
853var gridToData = (grid) => {
854 const data = [];
855 const [headers, ...body] = grid;
856 for (const row of body) {
857 const entry = {};
858 data.push(entry);
859 for (const i in headers) {
860 const keys = headers[i];
861 if (keys.length === 0) continue;
862 if (keys.length > row[i].length) {
863 throw new Error("Malformed grid: row has more columns than headers");
864 }
865 for (const k in keys) {
866 const key = keys[k];
867 const to = +k + 1 === keys.length ? Number.POSITIVE_INFINITY : +k + 1;
868 entry[key] = row[i].slice(+k, to);
869 }
870 }
871 }
872 return data;
873};
874var parseWinGrid = (input, debug = false) => {
875 const lines = input.split(/\r*\n+/).filter(Boolean);
876 const headline = lines.shift();
877 const headers = headline.trim().split(/\s\s+/);
878 const hl = headers.length;
879 const ll = headline.length;
880 if (debug) {
881 console.log("Headers:", headers);
882 console.log("Line lengths:", lines.map((l) => l.length));
883 }
884 if (lines.every((l) => ll / l.length < 2)) {
885 const spaces = Array.from({ length: ll }).map(
886 (_, i) => lines.every((l) => l[i] === " ")
887 );
888 const borders = spaces.reduce((m, v, i, a) => {
889 if (v && !a[i - 1]) m.push(i);
890 return m;
891 }, [0]);
892 const data2 = [];
893 debug && console.log("Borders:", borders);
894 for (const line of lines) {
895 const props = [];
896 for (const i in headers) {
897 const k = headers[i];
898 const s = borders[i];
899 const e = borders[+i + 1] || ll;
900 const v = line.slice(s, e).trim();
901 props.push([k, [v || EMPTY]]);
902 }
903 data2.push(Object.fromEntries(props));
904 }
905 return data2;
906 }
907 let w = "";
908 let p;
909 const body = input.slice(headline.length);
910 const vals = [];
911 const data = [];
912 const cap = (v) => {
913 const _v = w.trim() || (vals.length === 0 ? v : w.trim());
914 if (!_v) return;
915 vals.push(_v);
916 if (vals.length === hl) {
917 data.push(Object.fromEntries(headers.map((h, i) => [h, [vals[i]]])));
918 vals.length = 0;
919 }
920 w = "";
921 };
922 for (const c of body) {
923 w += c;
924 if (c === " ") {
925 if (p === "\n") {
926 cap(EMPTY);
927 } else if (p === " ") {
928 cap();
929 }
930 } else if (c === "\n") {
931 cap();
932 }
933 p = c;
934 }
935 cap();
936 return data;
937};
938var parsers = {
939 unix: parseUnixGrid,
940 win: parseWinGrid
941};
942var parse = (input, { format = "unix", debug = false } = {}) => {
943 const parser = parsers[format];
944 if (!parser) throw new Error(`unsupported format: ${format}`);
945 return parser(input, debug);
946};
947
948// node_modules/zurk/target/esm/spawn.mjs
949var cp = __toESM(require("child_process"), 1);
950var import_node_process3 = __toESM(require("process"), 1);
951var import_node_events = __toESM(require("events"), 1);
952var import_node_stream = require("stream");
953
954// node_modules/zurk/target/esm/util.mjs
955var import_node_process2 = __toESM(require("process"), 1);
956var g = !import_node_process2.default.versions.deno && global || globalThis;
957var immediate = g.setImmediate || ((f) => g.setTimeout(f, 0));
958var noop = () => {
959};
960var randomId = () => Math.random().toString(36).slice(2);
961var isPromiseLike = (value) => typeof (value == null ? void 0 : value.then) === "function";
962var isStringLiteral = (pieces, ...rest) => {
963 var _a;
964 return (pieces == null ? void 0 : pieces.length) > 0 && ((_a = pieces.raw) == null ? void 0 : _a.length) === pieces.length && // Object.isFrozen(pieces) &&
965 rest.length + 1 === pieces.length;
966};
967var assign = (target, ...extras) => Object.defineProperties(target, extras.reduce((m, extra) => __spreadValues(__spreadValues({}, m), Object.fromEntries(Object.entries(Object.getOwnPropertyDescriptors(extra)).filter(([, v]) => !Object.prototype.hasOwnProperty.call(v, "value") || v.value !== void 0))), {}));
968var buildCmd = (quote2, pieces, args, subs = substitute) => {
969 if (args.some(isPromiseLike))
970 return Promise.all(args).then((args2) => buildCmd(quote2, pieces, args2, subs));
971 let cmd = pieces[0], i = 0;
972 while (i < args.length) {
973 const s = Array.isArray(args[i]) ? args[i].map((x) => quote2(subs(x))).join(" ") : quote2(subs(args[i]));
974 cmd += s + pieces[++i];
975 }
976 return cmd;
977};
978var substitute = (arg) => typeof (arg == null ? void 0 : arg.stdout) === "string" ? arg.stdout.replace(/\n$/, "") : `${arg}`;
979
980// node_modules/zurk/target/esm/spawn.mjs
981var defaults = {
982 get id() {
983 return randomId();
984 },
985 cmd: "",
986 get cwd() {
987 return import_node_process3.default.cwd();
988 },
989 sync: false,
990 args: [],
991 input: null,
992 env: import_node_process3.default.env,
993 get ee() {
994 return new import_node_events.default();
995 },
996 get ac() {
997 return g.AbortController && new AbortController();
998 },
999 get signal() {
1000 var _a;
1001 return (_a = this.ac) == null ? void 0 : _a.signal;
1002 },
1003 on: {},
1004 detached: import_node_process3.default.platform !== "win32",
1005 shell: true,
1006 spawn: cp.spawn,
1007 spawnSync: cp.spawnSync,
1008 spawnOpts: {},
1009 get store() {
1010 return createStore();
1011 },
1012 callback: noop,
1013 get stdin() {
1014 return new VoidStream();
1015 },
1016 get stdout() {
1017 return new VoidStream();
1018 },
1019 get stderr() {
1020 return new VoidStream();
1021 },
1022 stdio: ["pipe", "pipe", "pipe"],
1023 run: immediate,
1024 stack: ""
1025};
1026var normalizeCtx = (...ctxs) => assign(
1027 __spreadValues({}, defaults),
1028 { get signal() {
1029 var _a;
1030 return (_a = this.ac) == null ? void 0 : _a.signal;
1031 } },
1032 ...ctxs
1033);
1034var processInput = (child, input) => {
1035 if (input && child.stdin && !child.stdin.destroyed) {
1036 if (input instanceof import_node_stream.Readable) {
1037 input.pipe(child.stdin);
1038 } else {
1039 child.stdin.write(input);
1040 child.stdin.end();
1041 }
1042 }
1043};
1044var VoidStream = class extends import_node_stream.Transform {
1045 _transform(chunk, _, cb) {
1046 this.emit("data", chunk);
1047 cb();
1048 }
1049};
1050var buildSpawnOpts = ({ spawnOpts, stdio, cwd, shell, input, env: env2, detached, signal }) => __spreadProps(__spreadValues({}, spawnOpts), {
1051 env: env2,
1052 cwd,
1053 stdio,
1054 shell,
1055 input,
1056 windowsHide: true,
1057 detached,
1058 signal
1059});
1060var toggleListeners = (pos, ee, on = {}) => {
1061 for (const [name, listener] of Object.entries(on)) {
1062 ee[pos](name, listener);
1063 }
1064 if (pos === "on")
1065 ee.once("end", () => toggleListeners("off", ee, on));
1066};
1067var createStore = () => ({
1068 stdout: [],
1069 stderr: [],
1070 stdall: []
1071});
1072var invoke = (c) => {
1073 var _a, _b;
1074 const now = Date.now();
1075 const stdio = [c.stdin, c.stdout, c.stderr];
1076 const push = (kind, data) => {
1077 c.store[kind].push(data);
1078 c.store.stdall.push(data);
1079 c.ee.emit(kind, data, c);
1080 c.ee.emit("stdall", data, c);
1081 };
1082 try {
1083 if (c.sync) {
1084 toggleListeners("on", c.ee, c.on);
1085 const opts = buildSpawnOpts(c);
1086 const r = c.spawnSync(c.cmd, c.args, opts);
1087 c.ee.emit("start", r, c);
1088 if (((_a = r.stdout) == null ? void 0 : _a.length) > 0) {
1089 c.stdout.write(r.stdout);
1090 push("stdout", r.stdout);
1091 }
1092 if (((_b = r.stderr) == null ? void 0 : _b.length) > 0) {
1093 c.stderr.write(r.stderr);
1094 push("stderr", r.stderr);
1095 }
1096 c.callback(null, c.fulfilled = __spreadProps(__spreadValues({}, r), {
1097 get stdout() {
1098 return c.store.stdout.join("");
1099 },
1100 get stderr() {
1101 return c.store.stderr.join("");
1102 },
1103 get stdall() {
1104 return c.store.stdall.join("");
1105 },
1106 stdio,
1107 duration: Date.now() - now,
1108 ctx: c
1109 }));
1110 c.ee.emit("end", c.fulfilled, c);
1111 } else {
1112 c.run(() => {
1113 var _a2, _b2, _c;
1114 toggleListeners("on", c.ee, c.on);
1115 let error = null;
1116 let aborted = false;
1117 const opts = buildSpawnOpts(c);
1118 const child = c.spawn(c.cmd, c.args, opts);
1119 const onAbort = (event) => {
1120 if (opts.detached && child.pid) {
1121 try {
1122 import_node_process3.default.kill(-child.pid);
1123 } catch (e) {
1124 child.kill();
1125 }
1126 }
1127 aborted = true;
1128 c.ee.emit("abort", event, c);
1129 };
1130 c.child = child;
1131 c.ee.emit("start", child, c);
1132 (_a2 = opts.signal) == null ? void 0 : _a2.addEventListener("abort", onAbort);
1133 processInput(child, c.input || c.stdin);
1134 (_b2 = child.stdout) == null ? void 0 : _b2.on("data", (d) => {
1135 push("stdout", d);
1136 }).pipe(c.stdout);
1137 (_c = child.stderr) == null ? void 0 : _c.on("data", (d) => {
1138 push("stderr", d);
1139 }).pipe(c.stderr);
1140 child.once("error", (e) => {
1141 error = e;
1142 c.ee.emit("err", error, c);
1143 }).once("exit", () => {
1144 var _a3, _b3;
1145 if (aborted) {
1146 (_a3 = child.stdout) == null ? void 0 : _a3.destroy();
1147 (_b3 = child.stderr) == null ? void 0 : _b3.destroy();
1148 }
1149 }).once("close", (status, signal) => {
1150 var _a3;
1151 c.fulfilled = {
1152 error,
1153 status,
1154 signal,
1155 get stdout() {
1156 return c.store.stdout.join("");
1157 },
1158 get stderr() {
1159 return c.store.stderr.join("");
1160 },
1161 get stdall() {
1162 return c.store.stdall.join("");
1163 },
1164 stdio,
1165 duration: Date.now() - now,
1166 ctx: c
1167 };
1168 (_a3 = opts.signal) == null ? void 0 : _a3.removeEventListener("abort", onAbort);
1169 c.callback(error, c.fulfilled);
1170 c.ee.emit("end", c.fulfilled, c);
1171 });
1172 }, c);
1173 }
1174 } catch (error) {
1175 c.callback(
1176 error,
1177 c.fulfilled = {
1178 error,
1179 status: null,
1180 signal: null,
1181 stdout: "",
1182 stderr: "",
1183 stdall: "",
1184 stdio,
1185 duration: Date.now() - now,
1186 ctx: c
1187 }
1188 );
1189 c.ee.emit("err", error, c);
1190 c.ee.emit("end", c.fulfilled, c);
1191 }
1192 return c;
1193};
1194var exec = (ctx) => invoke(normalizeCtx(ctx));
1195
1196// node_modules/@webpod/ps/target/esm/index.mjs
1197var IS_WIN = import_node_process4.default.platform === "win32";
1198var IS_WIN2025_PLUS = IS_WIN && Number.parseInt(import_node_os2.default.release().split(".")[2], 10) >= 26e3;
1199var LOOKUPS = {
1200 wmic: {
1201 cmd: "wmic process get ProcessId,ParentProcessId,CommandLine",
1202 args: [],
1203 parse(stdout) {
1204 return parse(removeWmicPrefix(stdout), { format: "win" });
1205 }
1206 },
1207 ps: {
1208 cmd: "ps",
1209 args: ["-lx"],
1210 parse(stdout) {
1211 return parse(stdout, { format: "unix" });
1212 }
1213 },
1214 pwsh: {
1215 cmd: "pwsh",
1216 args: ["-NoProfile", "-Command", '"Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine | ConvertTo-Json -Compress"'],
1217 parse(stdout) {
1218 let arr = [];
1219 try {
1220 arr = JSON.parse(stdout);
1221 } catch (e) {
1222 return [];
1223 }
1224 return arr.map((p) => ({
1225 ProcessId: [p.ProcessId + ""],
1226 ParentProcessId: [p.ParentProcessId + ""],
1227 CommandLine: p.CommandLine ? [p.CommandLine] : []
1228 }));
1229 }
1230 }
1231};
1232var isBin = (f) => {
1233 if (f === "") return false;
1234 if (!f.includes("/") && !f.includes("\\")) return true;
1235 if (f.length > 3 && f[0] === '"')
1236 return f[f.length - 1] === '"' ? isBin(f.slice(1, -1)) : false;
1237 try {
1238 if (!import_node_fs.default.existsSync(f)) return false;
1239 const stat = import_node_fs.default.lstatSync(f);
1240 return stat.isFile() || stat.isSymbolicLink();
1241 } catch (e) {
1242 return false;
1243 }
1244};
1245var lookup = (query = {}, cb = noop2) => _lookup({ query, cb, sync: false });
1246var lookupSync = (query = {}, cb = noop2) => _lookup({ query, cb, sync: true });
1247lookup.sync = lookupSync;
1248var _lookup = ({
1249 query = {},
1250 cb = noop2,
1251 sync = false
1252}) => {
1253 const pFactory = sync ? makePseudoDeferred.bind(null, []) : makeDeferred;
1254 const { promise, resolve, reject } = pFactory();
1255 const result = [];
1256 const lookupFlow = IS_WIN ? IS_WIN2025_PLUS ? "pwsh" : "wmic" : "ps";
1257 const {
1258 parse: parse2,
1259 cmd,
1260 args
1261 } = LOOKUPS[lookupFlow];
1262 const callback = (err, { stdout }) => {
1263 if (err) {
1264 reject(err);
1265 cb(err);
1266 return;
1267 }
1268 result.push(...filterProcessList(normalizeOutput(parse2(stdout)), query));
1269 resolve(result);
1270 cb(null, result);
1271 };
1272 exec({
1273 cmd,
1274 args,
1275 callback,
1276 sync,
1277 run(cb2) {
1278 cb2();
1279 }
1280 });
1281 return Object.assign(promise, result);
1282};
1283var filterProcessList = (processList, query = {}) => {
1284 const pidList = (query.pid === void 0 ? [] : [query.pid].flat(1)).map((v) => v + "");
1285 const filters = [
1286 (p) => query.command ? new RegExp(query.command, "i").test(p.command) : true,
1287 (p) => query.arguments ? new RegExp(query.arguments, "i").test(p.arguments.join(" ")) : true,
1288 (p) => query.ppid ? query.ppid + "" === p.ppid : true
1289 ];
1290 return processList.filter(
1291 (p) => (pidList.length === 0 || pidList.includes(p.pid)) && filters.every((f) => f(p))
1292 );
1293};
1294var removeWmicPrefix = (stdout) => {
1295 const s = stdout.indexOf(LOOKUPS.wmic.cmd + import_node_os2.default.EOL);
1296 const e = stdout.includes(">") ? stdout.trimEnd().lastIndexOf(import_node_os2.default.EOL) : stdout.length;
1297 return (s > 0 ? stdout.slice(s + LOOKUPS.wmic.cmd.length, e) : stdout.slice(0, e)).trimStart();
1298};
1299var pickTree = (list, pid, recursive = false) => {
1300 const children = list.filter((p) => p.ppid === pid + "");
1301 return [
1302 ...children,
1303 ...children.flatMap((p) => recursive ? pickTree(list, p.pid, true) : [])
1304 ];
1305};
1306var _tree = ({
1307 cb = noop2,
1308 opts,
1309 sync = false
1310}) => {
1311 if (typeof opts === "string" || typeof opts === "number") {
1312 return _tree({ opts: { pid: opts }, cb, sync });
1313 }
1314 const onError = (err) => cb(err);
1315 const onData = (all) => {
1316 if (opts === void 0) return all;
1317 const { pid, recursive = false } = opts;
1318 const list = pickTree(all, pid, recursive);
1319 cb(null, list);
1320 return list;
1321 };
1322 try {
1323 const all = _lookup({ sync });
1324 return sync ? onData(all) : all.then(onData, (err) => {
1325 onError(err);
1326 throw err;
1327 });
1328 } catch (err) {
1329 onError(err);
1330 return Promise.reject(err);
1331 }
1332};
1333var tree = (opts, cb) => __async(null, null, function* () {
1334 return _tree({ opts, cb });
1335});
1336var treeSync = (opts, cb) => _tree({ opts, cb, sync: true });
1337tree.sync = treeSync;
1338var kill = (pid, opts, next) => {
1339 if (typeof opts == "function") {
1340 return kill(pid, void 0, opts);
1341 }
1342 if (typeof opts == "string" || typeof opts == "number") {
1343 return kill(pid, { signal: opts }, next);
1344 }
1345 const { promise, resolve, reject } = makeDeferred();
1346 const {
1347 timeout = 30,
1348 signal = "SIGTERM"
1349 } = opts || {};
1350 try {
1351 import_node_process4.default.kill(+pid, signal);
1352 } catch (e) {
1353 reject(e);
1354 next == null ? void 0 : next(e);
1355 return promise;
1356 }
1357 let checkConfident = 0;
1358 let checkTimeoutTimer;
1359 let checkIsTimeout = false;
1360 const checkKilled = (finishCallback) => lookup({ pid }, (err, list = []) => {
1361 if (checkIsTimeout) return;
1362 if (err) {
1363 clearTimeout(checkTimeoutTimer);
1364 reject(err);
1365 finishCallback == null ? void 0 : finishCallback(err, pid);
1366 } else if (list.length > 0) {
1367 checkConfident = checkConfident - 1 || 0;
1368 checkKilled(finishCallback);
1369 } else {
1370 checkConfident++;
1371 if (checkConfident === 5) {
1372 clearTimeout(checkTimeoutTimer);
1373 resolve(pid);
1374 finishCallback == null ? void 0 : finishCallback(null, pid);
1375 } else {
1376 checkKilled(finishCallback);
1377 }
1378 }
1379 });
1380 if (next) {
1381 checkKilled(next);
1382 checkTimeoutTimer = setTimeout(() => {
1383 checkIsTimeout = true;
1384 next(new Error("Kill process timeout"));
1385 }, timeout * 1e3);
1386 } else {
1387 resolve(pid);
1388 }
1389 return promise;
1390};
1391var normalizeOutput = (data) => data.reduce((m, d) => {
1392 var _a, _b;
1393 const pid = (_a = d.PID || d.ProcessId) == null ? void 0 : _a[0];
1394 const ppid = (_b = d.PPID || d.ParentProcessId) == null ? void 0 : _b[0];
1395 const _cmd = d.CMD || d.CommandLine || d.COMMAND || [];
1396 const cmd = _cmd.length === 1 ? _cmd[0].split(/\s+/) : _cmd;
1397 if (pid && cmd.length > 0) {
1398 const c = cmd.findIndex((_v, i) => isBin(cmd.slice(0, i).join(" ")));
1399 const command = (c === -1 ? cmd : cmd.slice(0, c)).join(" ");
1400 const args = c === -1 ? [] : cmd.slice(c);
1401 m.push({
1402 pid,
1403 ppid,
1404 command,
1405 arguments: args
1406 });
1407 }
1408 return m;
1409}, []);
1410var makeDeferred = () => {
1411 let resolve;
1412 let reject;
1413 const promise = new Promise((res, rej) => {
1414 resolve = res;
1415 reject = rej;
1416 });
1417 return { resolve, reject, promise };
1418};
1419var makePseudoDeferred = (r = {}) => ({
1420 promise: r,
1421 resolve: identity,
1422 reject(e) {
1423 throw e;
1424 }
1425});
1426var noop2 = () => {
1427};
1428var identity = (v) => v;
1429var index_default = { kill, lookup, lookupSync, tree, treeSync };
1430
1431// src/vendor-core.ts
1432var import_internals = require("./internals.cjs");
1433var chalk2 = import_internals.bus.wrap("chalk", source_default);
1434var which = import_internals.bus.wrap("which", import_which.default);
1435var ps = import_internals.bus.wrap("ps", index_default);
1436/* c8 ignore next 100 */
1437// Annotate the CommonJS export names for ESM import in node:
14380 && (module.exports = {
1439 VoidStream,
1440 buildCmd,
1441 chalk,
1442 exec,
1443 isStringLiteral,
1444 ps,
1445 which
1446});