import { type HdoSessionLike } from './domainProxy';
import type { HdoDeviceRegistrationInput, HdoNodeInput, HdoPluginSettings, HdoRelayMode, HdoPublishedServiceInput, HdoRateLimitInput, HdoServiceInput, HdoSnapshot } from './types';
type WireGuardPeerConnectInput = {
    action?: 'up' | 'down' | 'restart' | null;
    skipIfActive?: boolean | null;
    fallbackToAppManaged?: boolean | null;
};
type HdoEventListener = (event: Record<string, unknown>) => void;
interface MarketplaceDbLike {
    getActiveSession?(): {
        accessToken: string | null;
        refreshToken: string | null;
        expiresAt: string | null;
        user: Record<string, unknown> | null;
    } | null;
    setSession?(session: {
        accessToken: string | null;
        refreshToken: string | null;
        expiresAt: string | null;
        user: Record<string, unknown> | null;
    }): void;
    clearSession?(): void;
    listInstalled?(): unknown[];
}
interface PluginManagerLike {
    install?(input: {
        id?: string | null;
        npm?: string | null;
        version?: string | null;
        tarballUrl?: string | null;
        autoGrant?: boolean | 'manifest' | string[] | null;
        activate?: boolean | null;
    }): Promise<unknown>;
    uninstall?(id: string): Promise<unknown>;
    activate?(id: string): Promise<unknown>;
    deactivate?(id: string): Promise<unknown>;
    upgrade?(id: string, version?: string | null): Promise<unknown>;
    listInstalled?(): unknown[];
}
interface HdoTaskRunSummary {
    attempted: number;
    done: number;
    failed: number;
    skipped: number;
    results: Array<Record<string, unknown>>;
}
type WireGuardRecoveryInput = string | null | {
    reason?: string | null;
    allowPrivileged?: boolean | null;
};
export interface HdoControllerContext {
    userDataDir: string;
    marketServerBaseUrl?: string | null;
    bundledWireGuardDir?: string | null;
    session?: HdoSessionLike | null;
    marketplaceDb?: MarketplaceDbLike;
    pluginManager?: PluginManagerLike;
    log: {
        info(msg: string, meta?: Record<string, unknown>): void;
        warn(msg: string, meta?: Record<string, unknown>): void;
        error(msg: string, meta?: Record<string, unknown>): void;
    };
}
export declare class HdoController {
    private readonly ctx;
    private readonly settingsPath;
    private settings;
    private lastError;
    private taskRunner;
    private wireGuardRecovery;
    private readonly domainProxy;
    private readonly eventListeners;
    private lastPresenceReportAt;
    private lastPresenceStatus;
    constructor(ctx: HdoControllerContext);
    getSettings(): HdoPluginSettings;
    onEvent(listener: HdoEventListener): () => void;
    updateSettings(patch: Partial<HdoPluginSettings>): HdoPluginSettings;
    snapshot(): Promise<HdoSnapshot>;
    registerDevice(input: HdoDeviceRegistrationInput): Promise<unknown>;
    reportPluginStates(deviceId?: string | null): Promise<unknown[]>;
    reportDevicePresence(status: HdoDeviceRegistrationInput['status'], options?: {
        throttleMs?: number;
    }): Promise<unknown | null>;
    private reportAnonymousH2iDirectReady;
    private reportAccountH2iDirectReady;
    private probeH2iDirectReadyIps;
    anonymousConnect(input?: {
        serverUrl?: string | null;
        appId?: string | null;
        installId?: string | null;
        deviceLabel?: string | null;
        platform?: string | null;
        relayMode?: HdoRelayMode | 'mesh-server' | 'mesh-service-p2p' | 'mesh-p2p' | null;
        rotate?: boolean | null;
        autoConnect?: boolean | null;
    }): Promise<Record<string, unknown>>;
    login(input: {
        serverUrl?: string | null;
        identifier?: string | null;
        password?: string | null;
    }): Promise<Record<string, unknown>>;
    accountConnect(input?: {
        serverUrl?: string | null;
        identifier?: string | null;
        password?: string | null;
        relayMode?: HdoRelayMode | 'mesh-server' | 'mesh-service-p2p' | 'mesh-p2p' | null;
        rotate?: boolean | null;
        autoConnect?: boolean | null;
    }): Promise<Record<string, unknown>>;
    executePendingTasks(): Promise<HdoTaskRunSummary>;
    refreshManifest(deviceId?: string | null): Promise<Record<string, unknown>>;
    refreshSubscription(deviceId?: string | null): Promise<string>;
    prepareWireGuardPeer(input?: {
        rotate?: boolean | null;
    }): Promise<Record<string, unknown>>;
    openWireGuardProfile(): Promise<Record<string, unknown>>;
    connectWireGuardPeer(input?: WireGuardPeerConnectInput): Promise<Record<string, unknown>>;
    private connectWireGuardPeerDarwin;
    private connectWireGuardPeerWindows;
    private ensureWindowsDnsPriorityAfterConnect;
    private connectWireGuardPeerWgQuick;
    private waitForWireGuardState;
    recoverWireGuardPeer(input?: WireGuardRecoveryInput): Promise<Record<string, unknown>>;
    private normalizeWireGuardRecoveryInput;
    private recoverWireGuardPeerInner;
    repairWireGuardRoutes(): Promise<Record<string, unknown>>;
    private stopWireGuardForControlPlaneRetry;
    applyDomainProxyFromManifest(manifestInput?: Record<string, unknown> | null): Promise<Record<string, unknown>>;
    prepareDomainProxyFromManifest(manifestInput?: Record<string, unknown> | null): Promise<Record<string, unknown>>;
    wireGuardLaunchDaemonStatus(): Record<string, unknown> | null;
    installWireGuardLaunchDaemon(): Promise<Record<string, unknown>>;
    uninstallWireGuardLaunchDaemon(input?: {
        stopTunnel?: boolean | null;
        rememberDisabled?: boolean | null;
    }): Promise<Record<string, unknown>>;
    shutdown(): Promise<void>;
    private reportPresenceInBackground;
    private rememberWireGuardDesiredActive;
    private rememberCurrentNetworkLease;
    private rememberNetworkLease;
    private restoreNetworkLease;
    private networkLease;
    private writeNetworkLease;
    private currentNetworkLeaseMode;
    private isAnonymousNetworkActive;
    private emitEvent;
    private publicStateEvent;
    wireGuardStatus(): Record<string, unknown> | null;
    upsertNode(input: HdoNodeInput): Promise<unknown>;
    heartbeatNode(id: string): Promise<unknown>;
    upsertService(input: HdoServiceInput): Promise<unknown>;
    publishService(input: HdoPublishedServiceInput): Promise<unknown>;
    upsertRateLimit(input: HdoRateLimitInput): Promise<unknown>;
    installCommands(): {
        domestic: string;
        home: string;
        oversea: string;
    };
    private serverBaseUrl;
    private sessionSnapshot;
    private localPluginStates;
    private runTasksInBackground;
    private executePendingTasksInner;
    private canRunTask;
    private executeClaimedTask;
    private accessToken;
    private apiGet;
    private apiPost;
    private apiPostPublic;
    private apiJson;
    private apiJsonPublic;
    private apiText;
    private fetch;
    private fetchPublic;
    private refreshAccessToken;
    private ensureSettingsForCurrentSession;
    private currentSessionUserId;
    private loadSettings;
    private saveSettings;
    private writeWireGuardProfile;
    private shutdownWireGuardConfigPath;
}
export {};
