In fact, this effect is not difficult to achieve.
The difficult thing is how to make it convenient for users to use.
The first checkbox implements select all and reverse selection
The last checkbox implements deselect
This is just a JS example.
This HTML has no actual value.