import { SidebarChatProvider } from '../sidebarProvider';

/**
 * Handles brain-profile / wiki sync messages from the sidebar webview.
 */
export async function handleBrainMessage(provider: SidebarChatProvider, data: any): Promise<boolean> {
    switch (data.type) {
        case 'manageBrains':
            await provider._manageBrains();
            return true;
        case 'syncBrain':
            await provider.syncBrain();
            await provider._sendBrainStatus();
            return true;
        case 'addBrain':
            await provider._addBrainProfile();
            return true;
        case 'editBrain':
            await provider._editBrainProfile(data.id);
            return true;
        case 'deleteBrain':
            await provider._deleteBrainProfile(data.id);
            return true;
        case 'saveWikiRaw':
            await provider._saveWikiRaw();
            return true;
        case 'setBrainProfile':
            await provider._setActiveBrainProfile(data.id);
            return true;
        default:
            return false;
    }
}
