"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 sync_if_dirty_exports = {};
__export(sync_if_dirty_exports, {
  register: () => register
});
module.exports = __toCommonJS(sync_if_dirty_exports);
var path = __toESM(require("path"));
var import_ui = require("../ui");
var import_utils = require("./utils");
function register(program) {
  program.command("sync-if-dirty [projectPath]").description("Sync only if a dirty marker is present").option("-q, --quiet", "Suppress output").action(async (projectPath, opts) => {
    const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
    const target = path.resolve(projectPath ?? process.cwd());
    if (!KiroGraph.isInitialized(target)) {
      process.exit(0);
    }
    const cg = await KiroGraph.open(target);
    const result = await cg.syncIfDirty();
    if (!opts.quiet) {
      if (result) {
        const changed = result.added.length + result.modified.length + result.removed.length;
        if (changed === 0) {
          console.log(`  ${import_ui.dim}Index up to date.${import_ui.reset}`);
        } else {
          console.log((0, import_utils.formatSyncCounts)(result));
        }
        if (result.errors.length) console.warn(`  \x1B[33m\u26A0 ${result.errors.length} warning(s)\x1B[0m`);
        (0, import_utils.warnFallback)(cg.getEngineFallback());
      } else {
        console.log(`  ${import_ui.dim}Not dirty, skipped.${import_ui.reset}`);
      }
    }
    cg.close();
  });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  register
});
//# sourceMappingURL=sync-if-dirty.js.map
