Refractive Guide Switching a Regenerative Amplifier Free-Electron Laser for High Peak and Average Power Hard X Rays.