Phase transitions in dispersive non-Hermitian optical systems