const {contextBridge, ipcRenderer} = require('electron');

contextBridge.exposeInMainWorld('electronAPI', {
    writeFile: (fileName, content) => ipcRenderer.invoke('write-file', fileName, content),
    readFile: (fileName) => ipcRenderer.invoke('read-file', fileName),
    deleteFile: (fileName) => ipcRenderer.invoke('delete-file', fileName),
    changeContent: (nextPage) => ipcRenderer.invoke('change-content', nextPage),
    showAlert: (message) => ipcRenderer.invoke('show-alert', message),
    closeAlertWindow: () => ipcRenderer.send('close-alert-window'),
    openJsonDirConfigDialog: (fileName) => ipcRenderer.invoke('open-json-dir-config', fileName),
    openDirDialog: () => ipcRenderer.invoke('open-dir-dialog'),
    openFileDialog: () => ipcRenderer.invoke('open-file-dialog'),
    checkFileExists: (fileName) => ipcRenderer.invoke('check-file-exists', fileName),

    startMainProcesses: async (args) => ipcRenderer.invoke('start-main-processes', args),
    killBeforeLogout: async() => ipcRenderer.invoke('kill-before-logout'),
    decryptFiles: async(destPath) => ipcRenderer.invoke('decrypt-backup-files', destPath),

    showFileInExplorer: (filePath) => ipcRenderer.invoke('show-file-in-explorer', filePath),
    removePathFromReceivedFiles: (filePath) => ipcRenderer.invoke('remove-path-from-received-files', filePath)
});