Theory of a resonant level coupled to several conduction-electron channels in equilibrium and out of equilibrium