'use server';
import { resolve } from '../../lib/server-container.js';
export async function createEpic(input) {
    try {
        const useCase = resolve('CreateEpicUseCase');
        const result = await useCase.execute(input);
        if (!result.ok)
            return { error: result.error };
        return { epic: result.epic };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to create epic';
        return { error: message };
    }
}
export async function listEpics(projectId) {
    try {
        const useCase = resolve('ListEpicsUseCase');
        const result = await useCase.execute(projectId);
        return { epics: result.epics };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to list epics';
        return { error: message };
    }
}
export async function updateEpic(epicId, fields) {
    try {
        const useCase = resolve('UpdateEpicUseCase');
        const result = await useCase.execute({ epicId, ...fields });
        if (!result.ok)
            return { error: result.error };
        return { epic: result.epic };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to update epic';
        return { error: message };
    }
}
export async function deleteEpic(epicId) {
    try {
        const useCase = resolve('DeleteEpicUseCase');
        const result = await useCase.execute(epicId);
        if (!result.ok)
            return { error: result.error };
        return {};
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to delete epic';
        return { error: message };
    }
}
