  We consider the variational problem associated with the Freidlin--Wentzell
Large Deviation Principle (LDP) for the Stochastic Heat Equation (SHE). For a
general class of initial-terminal conditions, we show that a minimizer of this
variational problem exists, and any minimizer solves a system of imaginary-time
Nonlinear Schr\"{o}dinger equations. This system is integrable. Utilizing the
integrability, we prove that the formulas from the physics work Krajenbrink and
Le Doussal (2021) hold for every minimizer of the variational problem. As an
application, we consider the Freidlin--Wentzell LDP for the SHE with the delta
initial condition. Under a technical assumption on the poles of the reflection
coefficients, we prove the explicit expression for the one-point rate function
that was predicted in the physics works Le Doussal, Majumdar, Rosso, and Schehr
(2016) and Krajenbrink and Le Doussal (2021). Under the same assumption, we
give detailed pointwise estimates of the most probable shape in the upper-tail
limit.
