import { hasDesktopInvoke, invokeDesktop, isDesktopShell } from '@/lib/desktop'; type InvokeArgs = Record; export const invokeDesktopCommand = async ( command: string, args?: InvokeArgs, ): Promise => { if (!hasDesktopInvoke()) { throw new Error('Desktop runtime is not available'); } return invokeDesktop(command, args) as Promise; }; export const startDesktopWindowDrag = async (): Promise => { if (!isDesktopShell()) { return; } try { await invokeDesktopCommand('desktop_start_window_drag'); } catch { // ignore } }; export const setDesktopWindowTitle = async (title: string): Promise => { if (!isDesktopShell()) { return; } try { await invokeDesktopCommand('desktop_set_window_title', { title }); } catch { // ignore } }; export const setDesktopWindowTheme = async ( themeMode?: string, themeVariant?: string, ): Promise => { if (!isDesktopShell()) { return; } try { await invokeDesktopCommand('desktop_set_window_theme', { themeMode, themeVariant }); } catch { // ignore } }; export const getDesktopAppVersion = async (): Promise => { if (!isDesktopShell()) { return null; } try { const version = await invokeDesktopCommand('desktop_get_app_version'); return typeof version === 'string' && version.trim().length > 0 ? version : null; } catch { return null; } };