Semi-infinite flags. II: Local and global intersection cohomology of quasimaps spaces Continuity of plurisubharmonic envelopes in non-Archimedean geometry and test ideals. With an appendix by José Ignacio Burgos Gil and Martín Sombra. 