Available potential vorticity and wave-averaged quasi-geostrophic flow