#!/usr/bin/env sh
set -eu

APP_SUPPORT_ROOT="${HOME}/Library/Application Support/IuVeConnectAgent"
LOGS_ROOT="${HOME}/Library/Logs/IuVeConnectAgent"

case "$APP_SUPPORT_ROOT" in
  "$HOME"/Library/Application\ Support/IuVeConnectAgent) ;;
  *)
    printf '%s\n' '{"ok":false,"adapter":"macos","error":"unsafe_path_guard_app_support"}'
    exit 3
    ;;
esac

case "$LOGS_ROOT" in
  "$HOME"/Library/Logs/IuVeConnectAgent) ;;
  *)
    printf '%s\n' '{"ok":false,"adapter":"macos","error":"unsafe_path_guard_logs"}'
    exit 3
    ;;
esac

if [ -d "$APP_SUPPORT_ROOT" ]; then
  rm -rf -- "$APP_SUPPORT_ROOT"
fi

if [ -d "$LOGS_ROOT" ]; then
  rm -rf -- "$LOGS_ROOT"
fi

printf '%s\n' "{\"ok\":true,\"adapter\":\"macos\",\"mode\":\"skeleton\",\"removed_application_support_root\":\"${APP_SUPPORT_ROOT}\",\"removed_logs_root\":\"${LOGS_ROOT}\",\"service_uninstall\":\"disabled\"}"
