"use strict";
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("electronAPI", {
  // 应用信息
  getAppVersion: () => ipcRenderer.invoke("get-app-version"),
  getPlatform: () => ipcRenderer.invoke("get-platform"),
  // 窗口控制
  minimizeWindow: () => ipcRenderer.send("window-minimize"),
  maximizeWindow: () => ipcRenderer.send("window-maximize"),
  closeWindow: () => ipcRenderer.send("window-close"),
  quitApp: () => ipcRenderer.send("app-quit"),
  // 真正退出应用
  isMaximized: () => ipcRenderer.invoke("window-is-maximized"),
  onMaximizedChange: (callback) => {
    ipcRenderer.on("window-maximized", (_event, isMaximized) => callback(isMaximized));
  },
  // 文件操作
  selectFile: (options) => ipcRenderer.invoke("select-file", options),
  selectFolder: () => ipcRenderer.invoke("select-folder"),
  // 通知
  showNotification: (title, body) => ipcRenderer.send("show-notification", { title, body }),
  // Webview Cookie 操作
  getWebviewCookies: (partition, url) => ipcRenderer.invoke("get-webview-cookies", partition, url),
  clearWebviewCookies: (partition) => ipcRenderer.invoke("clear-webview-cookies", partition),
  setWebviewCookies: (partition, cookies) => ipcRenderer.invoke("set-webview-cookies", partition, cookies),
  // Webview 截图（用于 AI 分析）
  captureWebviewPage: (webContentsId) => ipcRenderer.invoke("capture-webview-page", webContentsId),
  // Webview 自动操作
  webviewSendMouseClick: (webContentsId, x, y) => ipcRenderer.invoke("webview-send-mouse-click", webContentsId, x, y),
  webviewSendTextInput: (webContentsId, text) => ipcRenderer.invoke("webview-send-text-input", webContentsId, text),
  webviewGetElementPosition: (webContentsId, selector) => ipcRenderer.invoke("webview-get-element-position", webContentsId, selector),
  webviewClickByText: (webContentsId, text) => ipcRenderer.invoke("webview-click-by-text", webContentsId, text),
  // CDP 网络拦截
  enableNetworkIntercept: (webContentsId, patterns) => ipcRenderer.invoke("enable-network-intercept", webContentsId, patterns),
  disableNetworkIntercept: (webContentsId) => ipcRenderer.invoke("disable-network-intercept", webContentsId),
  updateNetworkPatterns: (webContentsId, patterns) => ipcRenderer.invoke("update-network-patterns", webContentsId, patterns),
  onNetworkInterceptData: (callback) => {
    ipcRenderer.on("network-intercept-data", (_event, data) => callback(data));
  },
  removeNetworkInterceptListener: () => {
    ipcRenderer.removeAllListeners("network-intercept-data");
  }
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 9328 characters]
