{"version":3,"file":"processTree.cjs","names":[],"sources":["../src/processTree.ts"],"sourcesContent":["export function buildChildrenByParentMap(psOutput: string): Map<number, number[]> {\n  const childrenByParent = new Map<number, number[]>();\n  for (const line of psOutput.split('\\n')) {\n    const matched = /^\\s*(\\d+)\\s+(\\d+)\\s*$/.exec(line);\n    if (!matched) {\n      continue;\n    }\n\n    const childPid = Number(matched[1]);\n    const parentPid = Number(matched[2]);\n    const children = childrenByParent.get(parentPid);\n    if (children) {\n      children.push(childPid);\n    } else {\n      childrenByParent.set(parentPid, [childPid]);\n    }\n  }\n  return childrenByParent;\n}\n\nexport function collectDescendantPids(rootPid: number, childrenByParent: Map<number, number[]>): number[] {\n  const descendants: number[] = [];\n  const queue = [...(childrenByParent.get(rootPid) ?? [])];\n  let index = 0;\n  while (index < queue.length) {\n    const pid = queue[index] as number;\n    index += 1;\n    descendants.push(pid);\n    queue.push(...(childrenByParent.get(pid) ?? []));\n  }\n  return descendants;\n}\n"],"mappings":"aAAA,SAAgB,EAAyB,EAAyC,CAChF,IAAM,EAAmB,IAAI,IAC7B,IAAK,IAAM,KAAQ,EAAS,MAAM;CAAI,EAAG,CACvC,IAAM,EAAU,wBAAwB,KAAK,CAAI,EACjD,GAAI,CAAC,EACH,SAGF,IAAM,EAAW,OAAO,EAAQ,EAAE,EAC5B,EAAY,OAAO,EAAQ,EAAE,EAC7B,EAAW,EAAiB,IAAI,CAAS,EAC3C,EACF,EAAS,KAAK,CAAQ,EAEtB,EAAiB,IAAI,EAAW,CAAC,CAAQ,CAAC,CAE9C,CACA,OAAO,CACT,CAEA,SAAgB,EAAsB,EAAiB,EAAmD,CACxG,IAAM,EAAwB,CAAC,EACzB,EAAQ,CAAC,GAAI,EAAiB,IAAI,CAAO,GAAK,CAAC,CAAE,EACnD,EAAQ,EACZ,KAAO,EAAQ,EAAM,QAAQ,CAC3B,IAAM,EAAM,EAAM,GAClB,GAAS,EACT,EAAY,KAAK,CAAG,EACpB,EAAM,KAAK,GAAI,EAAiB,IAAI,CAAG,GAAK,CAAC,CAAE,CACjD,CACA,OAAO,CACT"}