There was a time when it seemed Tesla could do no wrong. In little more than a decade, it went from technology upstart to mass-market carmaker, invested billions in its clean energy business, and saw its value rocket. But now the company is struggling with falling car sales and intense competition …