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

// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld('electronAPI', {
    // Image file operations
    selectImages: () => ipcRenderer.invoke('select-images'),
    selectDirectory: () => ipcRenderer.invoke('select-directory'),
    readDirectory: (dirPath) => ipcRenderer.invoke('read-directory', dirPath),
    readImageDirectoryRecursive: (dirPath) => ipcRenderer.invoke('read-image-directory-recursive', dirPath),
    copyImage: (sourcePath, destPath) => ipcRenderer.invoke('copy-image', sourcePath, destPath),
    
    // Audio file operations
    selectAudio: () => ipcRenderer.invoke('select-audio'),
    readAudioDirectory: (dirPath) => ipcRenderer.invoke('read-audio-directory', dirPath),
    copyAudio: (sourcePath, destPath) => ipcRenderer.invoke('copy-audio', sourcePath, destPath),
    
    // Video file operations
    selectVideos: () => ipcRenderer.invoke('select-videos'),
    readVideoDirectory: (dirPath) => ipcRenderer.invoke('read-video-directory', dirPath),
    readVideoDirectoryRecursive: (dirPath) => ipcRenderer.invoke('read-video-directory-recursive', dirPath),
    copyVideo: (sourcePath, destPath) => ipcRenderer.invoke('copy-video', sourcePath, destPath),
    deleteVideo: (filePath) => ipcRenderer.invoke('delete-video', filePath),
    
    // File system utilities
    getAppPath: () => ipcRenderer.invoke('get-app-path'),
    pathJoin: (...paths) => ipcRenderer.invoke('path-join', ...paths),
    fileExists: (filePath) => ipcRenderer.invoke('file-exists', filePath),
    createDirectory: (dirPath) => ipcRenderer.invoke('create-directory', dirPath),
    deleteFile: (filePath) => ipcRenderer.invoke('delete-file', filePath),
    saveBase64Image: (filePath, base64Data) => ipcRenderer.invoke('save-base64-image', filePath, base64Data),
    
    // Platform info
    platform: process.platform,
    
    // Child window management
    openChildWindow: (options) => ipcRenderer.invoke('open-child-window', options),
    focusMainWindow: () => ipcRenderer.invoke('focus-main-window'),
    
    // Version info
    versions: {
        node: process.versions.node,
        electron: process.versions.electron
    }
});