Zend certified PHP/Magento developer

How to rewrite jquery code in jquery ui widget

How to remake this code in ui jquery widget?

There is such jquery code. When you select an item using the checkbox, the item is cloned and added to another block.
Tell me how to rewrite it in jquery ui widget since magento uses them to inject js code. Even if you have suggestions on how to improve the code, then I would love to read your ideas 🙂

I will also be glad of any help from such examples, thanks

example on codepen: https://codepen.io/annbin/pen/VwYRerL