export class ToggleRepositoryEnabledUseCase {
    deps;
    constructor(deps) {
        this.deps = deps;
    }
    execute(input) {
        if (!this.deps.existsSync(input.configPath)) {
            throw new Error(`Configuration file not found: ${input.configPath}\nRun 'reviewflow init' to create one.`);
        }
        const raw = this.deps.readFileSync(input.configPath, 'utf-8');
        let config;
        try {
            config = JSON.parse(raw);
        }
        catch {
            throw new Error(`Invalid JSON in configuration file: ${input.configPath}`);
        }
        const target = config.repositories.find((repo) => repo.localPath === input.localPath);
        if (!target) {
            return { updated: null, configPath: input.configPath };
        }
        target.enabled = input.enabled;
        this.deps.writeFileSync(input.configPath, JSON.stringify(config, null, 2));
        return { updated: target, configPath: input.configPath };
    }
}
//# sourceMappingURL=toggleRepositoryEnabled.usecase.js.map