#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SOURCE="$SCRIPT_DIR/Missing Effects"
DESTINATION="/Applications/Adobe Premiere Pro 2026/Adobe Premiere Pro 2026.app/Contents/PlugIns/Common"

# Check if effects folder exists
if [ ! -d "$SOURCE" ]; then
  osascript -e 'display dialog "The folder \"Missing Effects\" was not found.\nIt must be located next to the file Fix Premiere.command." buttons {"OK"} with icon stop'
  exit 1
fi

# Check if Premiere is installed
if [ ! -d "/Applications/Adobe Premiere Pro 2026" ]; then
  osascript -e 'display dialog "Adobe Premiere Pro 2026 was not found in the Applications folder." buttons {"OK"} with icon stop'
  exit 1
fi

# Check if destination folder exists
if [ ! -d "$DESTINATION" ]; then
  osascript -e 'display dialog "The destination folder was not found:\n\n'"$DESTINATION"'\n\nInstallation was cancelled." buttons {"OK"} with icon stop'
  exit 1
fi

# Copy files with GUI admin password prompt
osascript <<EOF
do shell script "cp -R '$SOURCE/'* '$DESTINATION'" with administrator privileges
EOF

# Success message
osascript -e 'display dialog "Effects were successfully installed.\nPlease restart Adobe Premiere Pro." buttons {"OK"} with icon note'

exit 0
