The Socioeconomics of State Formation in Medieval Afghanistan