'use server';
import { resolve } from '../../lib/server-container.js';
export async function deleteFeature(featureId, cleanup, cascadeDelete, closePr) {
    if (!featureId?.trim()) {
        return { error: 'id is required' };
    }
    try {
        const deleteFeatureUseCase = resolve('DeleteFeatureUseCase');
        const options = {};
        if (cleanup !== undefined)
            options.cleanup = cleanup;
        if (cascadeDelete !== undefined)
            options.cascadeDelete = cascadeDelete;
        if (closePr !== undefined)
            options.closePr = closePr;
        const feature = Object.keys(options).length > 0
            ? await deleteFeatureUseCase.execute(featureId, options)
            : await deleteFeatureUseCase.execute(featureId);
        return { feature };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to delete feature';
        return { error: message };
    }
}
