Dragging objects together, changes the label

I have an idea floating around that I want to develop, but I can’t quite find an example to start from. I usually can find something to copy and edit, but no such luck this time.

My idea: help students understand powers of i by grouping objects together

Ideally, they could break something like i^5 into 5 objects labeled “i” and then put pairs together that turn into an object labeled -1. They would continue to pair up the “i” objects until there are no more pairs.

It would be awesome if they could drag objects labeled -1 together that would turn into an object labeled 1 after that.

Any suggestions about where to start? Thank you!

Just wanted to say this is such a great idea.

It’ll be very complex to code, not sure I could, but just kudos for a great idea.