/**
 * In-Memory AgentGraphOverride Repository
 *
 * Test-friendly adapter for {@link IAgentGraphOverrideRepository}. Enforces
 * the unique-agentType invariant locally so tests exercise the same rule
 * the SQLite adapter enforces.
 */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { injectable } from 'tsyringe';
let InMemoryAgentGraphOverrideRepository = class InMemoryAgentGraphOverrideRepository {
    byId = new Map();
    byAgent = new Map();
    async findActive(agentType) {
        const id = this.byAgent.get(agentType);
        if (!id)
            return null;
        const row = this.byId.get(id);
        return row ? { ...row } : null;
    }
    async listAll() {
        return [...this.byId.values()]
            .map((row) => ({ ...row }))
            .sort((a, b) => a.agentType.localeCompare(b.agentType));
    }
    async create(override) {
        if (this.byId.has(override.id)) {
            throw new Error(`AgentGraphOverride with id "${override.id}" already exists`);
        }
        if (this.byAgent.has(override.agentType)) {
            throw new Error(`AgentGraphOverride already exists for agentType=${override.agentType}`);
        }
        this.byId.set(override.id, { ...override });
        this.byAgent.set(override.agentType, override.id);
    }
    async update(override) {
        if (!this.byId.has(override.id)) {
            throw new Error(`AgentGraphOverride with id "${override.id}" not found`);
        }
        this.byId.set(override.id, { ...override });
        this.byAgent.set(override.agentType, override.id);
    }
    async delete(agentType) {
        const id = this.byAgent.get(agentType);
        if (!id)
            return;
        this.byAgent.delete(agentType);
        this.byId.delete(id);
    }
};
InMemoryAgentGraphOverrideRepository = __decorate([
    injectable()
], InMemoryAgentGraphOverrideRepository);
export { InMemoryAgentGraphOverrideRepository };
