import { contextBridge, ipcRenderer } from "electron";
const api = {
  openNoteWindow: (noteId) => {
    ipcRenderer.send("open-note-window", noteId);
  },
  onNoteCreated: (callback) => {
    ipcRenderer.on("note-created", (_, data) => callback(data));
  },
  onNoteUpdated: (callback) => {
    ipcRenderer.on("note-updated", (_, data) => callback(data));
  },
  onNoteDeleted: (callback) => {
    ipcRenderer.on("note-deleted", (_, data) => callback(data));
  }
};
const notesAPI = {
  call: (method, ...args) => ipcRenderer.invoke("notesAPI:call", method, args)
};
if (process.contextIsolated) {
  try {
    contextBridge.exposeInMainWorld("api", api);
    contextBridge.exposeInMainWorld("notesAPI", notesAPI);
  } catch (error) {
    console.error(error);
  }
} else {
  window.api = api;
}
