Origin of nanoscale potential fluctuations in two-dimensional semiconductors