Offline Imitation Learning by Controlling the Effective Planning Horizon