Mechanics of stretchable batteries and supercapacitors