(a)
Notwithstanding any other provision of law, the magistrate may, upon motion of the prosecutor, close the examination in the manner described in Section 868 during the testimony of a witness:
(1)
Who is a minor or a dependent person, as defined in paragraph (3) of subdivision (f) of Section 288, with a substantial cognitive impairment and is the complaining victim of a sex offense, where testimony before the general public would be likely to cause serious psychological harm to the witness and where no alternative procedures, including, but not limited to, video recorded deposition or contemporaneous examination in another place communicated to the courtroom by means of closed-circuit television, are available to avoid the
perceived harm.
(2)
Whose life would be subject to a substantial risk in appearing before the general public, and where no alternative security measures, including, but not limited to, efforts to conceal his or her features or physical description, searches of members of the public attending the examination, or the temporary exclusion of other actual or potential witnesses, would be adequate to minimize the perceived threat.
(b)
In any case where public access to the courtroom is restricted during the examination of a witness pursuant to this section, a transcript of the testimony of the witness shall be made available to the public as soon as is practicable.