Chelsea edged Wrexham 4-2 in a dramatic FA Cup tie, with extra-time goals from Garnacho and Joao Pedro sealing their place in the quarter-finals.