Semi-infinite flags. II: Local and global intersection cohomology of quasimaps spaces Trigonometric weight functions as \(K\)-theoretic stable envelope maps for the cotangent bundle of a flag variety 