import { ipcMain } from 'electron'

import { loadSettings, saveSettings } from '../services/settingsService'
import type { ModelConfig } from '../types/model'
import type { LoadSettingsResponse, SaveSettingsResponse } from '../types/settings'

export function registerSettingsIpc(): void {
  ipcMain.handle('settings:load', async (): Promise<LoadSettingsResponse> => {
    return loadSettings()
  })

  ipcMain.handle(
    'settings:save',
    async (_, modelConfig: ModelConfig): Promise<SaveSettingsResponse> => {
    return saveSettings(modelConfig)
  })
}
