Does the inverter sync with main? If it doesnt beware you will have spikes during switching and this can kill electronic appliances!! Also note that there are no "fast" ats systems as such. You can get around 20ms in mechanical switching but those can cause lights to flicker.
A proper ATS have both electrical such as mechanical interlocking so that it cant engage both sides. Skipp all those junk chinese ones out there because many of them dont come with proper interlocking.
What you look for is a mechanical relay where you have 2 relayse with aux ports and mechanical interlocking
You basically look at the same as is called reverse contactor for motors
Here is one and
here is another
Using normal relays are not suited for it even though they are used like that in a UPS Though note that a ups is Either offline = longer time to switch or online where it is synced with grid.
Priority is something that you can build as you like. As long as the contactor have aux ports on the side for this. Both linked have it.
I have also done alot of videos regarding this and how you can wire such up and to think about.
And to end this. Switching between 2 AC sources without grid-synk can cause issues to some electronics so beware of that and it might be better to have an UPS in between that handle that.