/**
 * DeleteCustomAgentUseCase
 *
 * Removes a custom agent and its associated prompt + graph overrides.
 * No-op when no agent exists. Built-in agents cannot be deleted —
 * attempting to delete one is a defensive error.
 */
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { inject, injectable } from 'tsyringe';
import { listBuiltinAgentTypes } from '../../services/builtin-prompt-registry.js';
let DeleteCustomAgentUseCase = class DeleteCustomAgentUseCase {
    agents;
    prompts;
    graphs;
    constructor(agents, prompts, graphs) {
        this.agents = agents;
        this.prompts = prompts;
        this.graphs = graphs;
    }
    async execute(input) {
        if (!input.agentType.trim())
            throw new Error('agentType is required');
        if (listBuiltinAgentTypes().some((t) => t.agentType === input.agentType)) {
            throw new Error(`Built-in agent "${input.agentType}" cannot be deleted`);
        }
        const promptRows = await this.prompts.listForAgent(input.agentType);
        for (const row of promptRows) {
            await this.prompts.delete(row.agentType, row.promptId);
        }
        await this.graphs.delete(input.agentType);
        await this.agents.delete(input.agentType);
    }
};
DeleteCustomAgentUseCase = __decorate([
    injectable(),
    __param(0, inject('ICustomAgentRepository')),
    __param(1, inject('IAgentPromptOverrideRepository')),
    __param(2, inject('IAgentGraphOverrideRepository')),
    __metadata("design:paramtypes", [Object, Object, Object])
], DeleteCustomAgentUseCase);
export { DeleteCustomAgentUseCase };
