embassies – What happens to an embassy when the country it represents stops existing?

There are numerous Afghan nationals and Afghan embassies abroad, with at least some of the staff in those embassies not supporting the new regime/government.

What would happen to the embassy staff, their status, the embassy and the buildings it occupies?

Would all the staff become refugees or stateless?