"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_exports = {};
__export(sync_exports, {
  register: () => register
});
module.exports = __toCommonJS(sync_exports);
var path = __toESM(require("path"));
var import_ui = require("../ui");
var import_progress = require("../progress");
var import_utils = require("./utils");
function register(program) {
  program.command("sync [projectPath]").description("Incremental sync of changed files").option("--files <files...>", "Specific files to sync").option("-q, --quiet", "Suppress progress output").option("--progress", "Verbose per-file progress output (implies errors are shown inline)").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);
    let progressHandler;
    if (opts.quiet) {
      progressHandler = void 0;
    } else if (opts.progress) {
      progressHandler = import_progress.renderSyncProgressVerbose;
    } else {
      progressHandler = import_progress.renderSyncProgress;
    }
    const result = await cg.sync({
      files: opts.files,
      onProgress: progressHandler
    });
    const changed = result.added.length + result.modified.length + result.removed.length;
    if (changed === 0) {
      if (!opts.quiet) process.stdout.write("\n");
      console.log(`  ${import_ui.dim}Nothing to sync \u2014 index is up to date.${import_ui.reset}`);
    } else {
      (0, import_progress.renderSyncSummary)(result);
    }
    if (result.errors.length) {
      if (opts.progress) {
        console.warn(`
  \x1B[33m\u26A0 ${result.errors.length} error(s) during sync:\x1B[0m`);
        for (const err of result.errors) {
          console.warn(`    \x1B[33m${err}\x1B[0m`);
        }
      } else {
        console.warn(`  \x1B[33m\u26A0 ${result.errors.length} warning(s)\x1B[0m`);
      }
    }
    (0, import_utils.warnFallback)(cg.getEngineFallback());
    cg.close();
  });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  register
});
//# sourceMappingURL=sync.js.map
