/// <reference types="vite/client" />

interface ElectronAPI {
  // Auth
  register: (email: string, password: string) => Promise<any>;
  login: (email: string, password: string) => Promise<any>;
  getMe: () => Promise<any>;

  // Devices
  registerDevice: (data: { device_name: string; device_fingerprint: string; public_key: string }) => Promise<any>;
  listDevices: () => Promise<any>;
  updateDeviceStatus: (id: number, status: string) => Promise<any>;
  deleteDevice: (id: number) => Promise<any>;

  // Nodes
  listNodes: () => Promise<any>;
  getAvailableNodes: () => Promise<any>;

  // Connections
  requestConnection: (data: { device_id: number; node_id: number }) => Promise<any>;
  disconnect: (deviceId: number) => Promise<any>;
  getConnectionLogs: () => Promise<any>;

  // Relay
  connectToRelay: (host: string, port: number, token: string, deviceId: number) => Promise<any>;
  sendRelayMessage: (targetDeviceId: number, payload: string) => Promise<any>;
  disconnectFromRelay: () => Promise<any>;

  // Events
  onRelayMessage: (callback: (msg: any) => void) => void;
  onRelayStatus: (callback: (status: string) => void) => void;
  removeRelayListeners: () => void;
}

declare global {
  interface Window {
    electronAPI: ElectronAPI;
  }
}
