Unified theory of attractive and repulsive polarons in a one-dimensional Bose gas