// Pont sécurisé entre le processus principal Electron et le renderer (Vue).
const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('poissechat', {
  version: process.versions.electron,
  getSettings: () => ipcRenderer.invoke('settings:get'),
  setSettings: (partial) => ipcRenderer.send('settings:set', partial),
  onSettingsChanged: (callback) => {
    ipcRenderer.on('settings:changed', (_event, settings) => callback(settings));
  },
  closeSettingsWindow: () => ipcRenderer.send('settings:close-window'),
  onStopMedia: (callback) => ipcRenderer.on('media:stop', callback),
  onPauseState: (callback) => {
    ipcRenderer.on('livechat:pause-state', (_event, state) => callback(state));
  },
});
