// Type declarations for SparkBun preload globals
// These are set dynamically per-webview before the preload script runs

declare global {
	interface Window {
		__sparkbunWebviewId: number;
		__sparkbunWindowId: number;
		__sparkbunRpcSocketPort: number;
		__sparkbunHostSocketPort?: number;
		__sparkbunSecretKeyBytes: number[];
		// Event-only bridge (all webviews, including sandboxed)
		__sparkbunEventBridge?: {
			postMessage: (message: string) => void;
		};
		// Internal RPC bridge (trusted webviews only)
		__sparkbunInternalBridge?: {
			postMessage: (message: string) => void;
		};
		// User RPC bridge (trusted webviews only)
		__sparkbunHostBridge?: {
			postMessage: (message: string) => void;
		};
		__sparkbunBunBridge?: {
			postMessage: (message: string) => void;
		};
		__sparkbun_encrypt: (
			plaintext: string,
		) => Promise<{ encryptedData: string; iv: string; tag: string }>;
		__sparkbun_decrypt: (
			encryptedData: string,
			iv: string,
			tag: string,
		) => Promise<string>;
		__sparkbunSendToHost: (message: unknown) => void;
		__sparkbunPendingHostMessages?: unknown[];
		__sparkbun: {
			receiveMessageFromHost: (msg: unknown) => void;
			receiveInternalMessageFromHost: (msg: unknown) => void;
			receiveMessageFromBun: (msg: unknown) => void;
			receiveInternalMessageFromBun: (msg: unknown) => void;
		};
	}
}

export {};
