Theory of two-channel thermal unimolecular reactions. 1. General formulation