Stability, composition and function of palladium surfaces in oxidizing environments: A first-principles statistical mechanics approach