import { getConfig } from "../../config.js";
import { getGeneralEngines } from "./verticals/general.js";
import { getNewsEngines } from "./verticals/news.js";
import { getCodeEngines } from "./verticals/code.js";
import { getDocsEngines } from "./verticals/docs.js";
import { getPapersEngines } from "./verticals/papers.js";
import { getImageEngines } from "./verticals/images.js";
const KEY_REQUIRED = {
  brave: { envVar: "BRAVE_API_KEY", registeredWithoutKey: false },
  "brave-image": { envVar: "BRAVE_API_KEY", registeredWithoutKey: false },
  "github-code": { envVar: "WIGOLO_GITHUB_TOKEN", registeredWithoutKey: true }
};
function isKeyAvailable(engineName) {
  const req = KEY_REQUIRED[engineName];
  if (!req) return true;
  if (req.envVar === "BRAVE_API_KEY") return !!getConfig().braveApiKey;
  return typeof process.env[req.envVar] === "string" && process.env[req.envVar].length > 0;
}
function hintFor(engineName) {
  const req = KEY_REQUIRED[engineName];
  if (!req) return void 0;
  return `set ${req.envVar} to enable this engine`;
}
function getEngineHealthSummary() {
  const verticals = [
    ["general", getGeneralEngines()],
    ["news", getNewsEngines()],
    ["code", getCodeEngines()],
    ["docs", getDocsEngines()],
    ["papers", getPapersEngines()],
    ["images", getImageEngines()]
  ];
  const out = [];
  const seen = /* @__PURE__ */ new Set();
  for (const [vertical, entries] of verticals) {
    for (const entry of entries) {
      const name = entry.engine.name;
      seen.add(name);
      const req = KEY_REQUIRED[name];
      let status = "ok";
      let hint;
      if (req && !isKeyAvailable(name)) {
        status = "needs-key";
        hint = hintFor(name);
      }
      out.push({
        name,
        vertical,
        status,
        ...hint ? { hint } : {},
        ...entry.weight !== void 0 ? { weight: entry.weight } : {}
      });
    }
  }
  for (const name of Object.keys(KEY_REQUIRED)) {
    if (seen.has(name)) continue;
    if (!isKeyAvailable(name)) {
      out.push({
        name,
        vertical: name === "brave-image" ? "images" : "general",
        status: "disabled",
        hint: hintFor(name)
      });
    }
  }
  return out;
}
export {
  getEngineHealthSummary
};
//# sourceMappingURL=engine-health.js.map