Stability and electronic structure of potassium-intercalated hexagonal boron nitride from density functional calculations