The old ExtendScript can be used to reverse the selection
app.activeDocument.selection.invert();
But UXP cannot be used to reverse the selection, no response
async()=>{
const app=require(‘photoshop’).app
await app.activeDocument.selection.invert();
}