// @bun
// ../../node_modules/.bun/llmz@0.0.79+ed0f774122d294fe/node_modules/llmz/dist/chunk-YEAWWJSJ.js
var isInternalLine = (line) => {
  return line.includes("/llmz/") || line.includes("\\llmz\\src\\") || line.includes("node_modules");
};
function cleanStackTrace(stack, cleanInternal = true) {
  let lines = stack.split(`
`);
  const until = lines.findIndex((line) => isInternalLine(line));
  if (cleanInternal && until >= 0) {
    lines = lines.slice(0, until);
  } else {
    lines = lines.map((line) => {
      let llmzIndex = line.indexOf("/llmz/");
      if (llmzIndex === -1) {
        llmzIndex = line.indexOf("\\llmz\\");
      }
      if (llmzIndex === -1) {
        return line;
      }
      let lastSpaceIndex = line.lastIndexOf(" ", llmzIndex);
      if (lastSpaceIndex === -1) {
        lastSpaceIndex = 0;
      }
      const maybeParen = line[lastSpaceIndex + 1] === "(" ? "(" : "";
      return line.slice(0, lastSpaceIndex + 1) + maybeParen + line.slice(llmzIndex);
    });
  }
  return lines.join(`
`);
}

export { cleanStackTrace };
