Theory of third-harmonic generation in metal vapors under two-photon resonance conditions