#![cfg_attr(coverage, allow(unused_imports))]
//! Client relay orchestration for HID input, media downlinks, and webcam/mic uplinks.

use anyhow::Result;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use std::time::{Duration, Instant};
use tokio::sync::{broadcast, mpsc};
use tokio_stream::{
    StreamExt,
    wrappers::{BroadcastStream, errors::BroadcastStreamRecvError},
};
use tonic::{Request, transport::Channel};
use tracing::{debug, error, info, trace, warn};
use winit::{
    event::Event,
    event_loop::{ControlFlow, EventLoopBuilder},
    platform::wayland::EventLoopBuilderExtWayland,
};

use lesavka_common::lesavka::{
    AudioPacket, Empty, KeyboardReport, MonitorRequest, MouseReport, UpstreamMediaBundle,
    VideoPacket, relay_client::RelayClient,
};

#[cfg(not(coverage))]
use crate::output::video::{MonitorWindow, UnifiedMonitorWindow};
use crate::{
    app_support, handshake, input::camera::CameraCapture, input::inputs::InputAggregator,
    input::microphone::MicrophoneCapture, output::audio::AudioOut, paste, relay_transport,
};

pub struct LesavkaClientApp {
    aggregator: Option<InputAggregator>,
    server_addr: String,
    dev_mode: bool,
    headless: bool,
    kbd_tx: broadcast::Sender<KeyboardReport>,
    mou_tx: broadcast::Sender<MouseReport>,
    paste_rx: Option<mpsc::UnboundedReceiver<String>>,
    remote_capture_enabled: Arc<AtomicBool>,
}

include!("app/session_lifecycle.rs");
include!("app/input_streams.rs");
include!("app/downlink_media.rs");
include!("app/uplink_media.rs");

include!("app/audio_recovery_config.rs");
