#!/bin/bash

# Find and disable globe spinning in all Mapbox globe files

echo "Disabling globe auto-rotation in all visualizations..."

# Files with spinGlobe function
files=(
    "mapbox_test/mapbox_globe_2/src/index.js"
    "mapbox_test/mapbox_globe_4/src/index.js"
    "mapbox_test/mapbox_globe_10/src/index.js"
    "mapbox_test/mapbox_globe_11/src/index.js"
    "mapbox_test/mapbox_globe_12/src/index.js"
    "mapbox_test/mapbox_globe_13/src/index.js"
    "mapbox_test/mapbox_globe_14/src/index.js"
    "vaccine_timeseries/vaccine_timeseries_1_measles/index.html"
    "vaccine_timeseries/vaccine_timeseries_3_covid/index.html"
)

for file in "${files[@]}"; do
    if [ -f "$file" ]; then
        echo "Processing: $file"
        # Comment out spinGlobe() function call
        sed -i 's/^\([[:space:]]*\)spinGlobe();/\1\/\/ spinGlobe(); \/\/ Auto-rotation disabled/' "$file"
        # Set spinEnabled to false
        sed -i 's/let spinEnabled = true/let spinEnabled = false/' "$file"
        # Set rotationActive to false
        sed -i 's/let rotationActive = true/let rotationActive = false/' "$file"
    fi
done

echo "✅ Globe auto-rotation disabled in all visualizations"
