#ProtonMail doesn't support grabbing your email via IMAP. They do have an export tool (https://proton.me/support/proton-mail-export-tool) but it spits out a bunch of .eml files with JSON metadata.
I wrote a quick script to convert such an export into a classic mbox file, which should be suitable for importing into, say, #Fastmail
...if you were, for some reason, considering migrating away from Proton Mail.
Anyway, the script is here:
https://gist.github.com/deadpixi/e5beb30630ecb4353f92f61bffb77a19
(I wrote the script in like 5 minutes, don't judge me.)