"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var hotspots_exports = {};
__export(hotspots_exports, {
  register: () => register
});
module.exports = __toCommonJS(hotspots_exports);
var path = __toESM(require("path"));
var import_ui = require("../ui");
function register(program) {
  program.command("hotspots [projectPath]").description("Find the most-connected symbols by edge degree").option("--limit <n>", "Max results (default: 20)", "20").option("--format <fmt>", "Output format: table | json", "table").action(async (projectPath, opts) => {
    const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
    const target = path.resolve(projectPath ?? process.cwd());
    const cg = await KiroGraph.open(target);
    const limit = Math.max(1, Math.min(100, parseInt(opts.limit) || 20));
    const hotspots = cg.findHotspots(limit);
    cg.close();
    if (hotspots.length === 0) {
      console.log(`
  ${import_ui.dim}No symbols found in index.${import_ui.reset}
`);
      return;
    }
    if (opts.format === "json") {
      console.log(JSON.stringify(hotspots, null, 2));
      return;
    }
    console.log();
    console.log(`  ${import_ui.violet}${import_ui.bold}Hotspots${import_ui.reset}  ${import_ui.dim}most-connected symbols${import_ui.reset}
`);
    const maxDegree = hotspots[0].degree;
    const BAR_WIDTH = 20;
    for (let i = 0; i < hotspots.length; i++) {
      const n = hotspots[i];
      const rank = String(i + 1).padStart(2);
      const bar = Math.round(n.degree / maxDegree * BAR_WIDTH);
      const barStr = "\u2588".repeat(bar) + "\u2591".repeat(BAR_WIDTH - bar);
      console.log(`  ${import_ui.dim}${rank}.${import_ui.reset} ${import_ui.violet}${import_ui.bold}${n.name}${import_ui.reset}  ${import_ui.dim}${n.kind}${import_ui.reset}`);
      console.log(`      ${import_ui.violet}${barStr}${import_ui.reset}  ${import_ui.bold}${n.degree}${import_ui.reset}${import_ui.dim} edges (\u2191${n.inDegree} \u2193${n.outDegree})${import_ui.reset}`);
      console.log(`      ${import_ui.dim}${n.filePath}:${n.startLine}${import_ui.reset}`);
    }
    console.log(`
  ${import_ui.dim}${hotspots.length} result(s)${import_ui.reset}
`);
  });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  register
});
//# sourceMappingURL=hotspots.js.map
