Active Test-Time Adaptation: Theoretical Analyses and An Algorithm