She was at a loss for what to do next.

Literal

She [topic-は] next [at-に] what did [if-ら] good [question-のか] at-a-loss.

途方に暮れる means 'to be at a loss, be completely stumped.' 次に何をしたらいいのか is an embedded question: 'what should I do next.'