#!/bin/bash
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"

log "Installing Vesktop (Flatpak)..."
ensure_flatpak
sudo flatpak install --system -y flathub dev.vencord.Vesktop
apply_flatpak_theme "dev.vencord.Vesktop"

log "Deploying Vencord config..."
FLATPAK_CFG="$HOME/.var/app/dev.vencord.Vesktop/config"
mkdir -p "$FLATPAK_CFG"
if [[ -d "$HOME/Dotfiles/desktopenvs/hyprland/Vencord" ]]; then
    rm -rf "$FLATPAK_CFG/Vencord" "$FLATPAK_CFG/vesktop"
    cp -r "$HOME/Dotfiles/desktopenvs/hyprland/Vencord" "$FLATPAK_CFG/Vencord"
    cp -r "$HOME/Dotfiles/desktopenvs/hyprland/Vencord" "$FLATPAK_CFG/vesktop"
else
    warn "Vencord config not found at ~/Dotfiles/desktopenvs/hyprland/Vencord — skipping."
fi
log "Vesktop installed with Vencord theme."
