#!/bin/bash

# ─────────────────────────────────────────
#  Dependency Checker
# ─────────────────────────────────────────

DEPS=(
    eww
    steam
    code
    firefox
    vesktop
    kitty
    wofi
    thunar
    fastfetch
    jq
    python-gobject # arch
)

PASS=0
FAIL=0
MISSING=()

# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
CYAN='\033[0;36m'
BOLD='\033[1m'
RESET='\033[0m'

echo ""
echo -e "${BOLD}${CYAN}  Checking dependencies...${RESET}"
echo -e "  ──────────────────────────"

for dep in "${DEPS[@]}"; do
    if command -v "$dep" &>/dev/null; then
        echo -e "  ${GREEN}✓${RESET}  $dep"
        ((PASS++))
    else
        echo -e "  ${RED}✗${RESET}  $dep ${RED}(not found)${RESET}"
        MISSING+=("$dep")
        ((FAIL++))
    fi
done

echo -e "  ──────────────────────────"
echo -e "  ${GREEN}${PASS} found${RESET}  |  ${RED}${FAIL} missing${RESET}"
echo ""

if [ ${#MISSING[@]} -gt 0 ]; then
    echo -e "${BOLD}  Missing:${RESET} ${MISSING[*]}"
    echo ""
    exit 1
else
    echo -e "${GREEN}${BOLD}  All dependencies satisfied!${RESET}"
    echo ""
    exit 0
fi