#!/bin/bash

RED='\033[0;31m'
RESET='\033[0m'


PLUGIN_NAME="NAM Studio"
VST3_PATH="$HOME/.vst3/$PLUGIN_NAME.vst3"
LV2_PATH="$HOME/.lv2/lv2/$PLUGIN_NAME.lv2"
OPT_PATH="$HOME/Documents/VZtec/$PLUGIN_NAME"

animated_dots() {
    for ((i = 0; i < 50; i++)); do
        echo -n "."
        sleep 0.01
    done
    echo ""
}

echo ""
echo "Attention: This will remove $PLUGIN_NAME from your system."
read -p "Proceed with uninstallation? (y/n): " confirm

if [[ ! $confirm =~ ^[Yy]*$ ]]; then
    echo "Aborted."
    exit 0
fi

echo ""
echo "Removing components..."


[ -d "$VST3_PATH" ] && rm -rf "$VST3_PATH" && echo "Removed VST3."
[ -d "$LV2_PATH" ] && rm -rf "$LV2_PATH" && echo "Removed LV2."

if [ -d "$OPT_PATH" ]; then
    rm -rf "$OPT_PATH"
    echo "Removed Library files."
fi

if [ -d "/opt/VZtec" ] && [ -z "$(ls -A /opt/VZtec)" ]; then
    rmdir OPT_PATH
fi

echo ""
printf "${RED}$PLUGIN_NAME uninstalled successfully.${RESET}\n"
animated_dots