782.
(a) In any of the circumstances described in subdivision (c), if evidence of sexual conduct of the complaining witness is offered to attack the credibility of the complaining witness under Section 780, the following procedure shall be followed:(1) A written motion shall be made by the defendant to the court and prosecutor stating that the defense has an offer of proof of the relevance of evidence of the sexual conduct of the complaining witness that is proposed to be presented and of its relevance in attacking the credibility of the complaining witness.
(2) The written motion shall be accompanied by an affidavit in which the offer of proof shall be stated. The affidavit shall be filed under seal and only unsealed by the court to determine if the offer of proof is sufficient to order a hearing pursuant to paragraph (3). After that determination, the affidavit shall be resealed by the court.
(3) If the court finds that the offer of proof is sufficient, the court shall order a hearing out of the presence of the jury, if any, and at the hearing allow the questioning of the complaining witness regarding the offer of proof made by the defendant.
(4) At the conclusion of the hearing, if the court finds that evidence proposed to be offered by the defendant regarding the sexual conduct of the complaining witness is relevant pursuant to Section 780, and is not inadmissible pursuant to Section 352, the court may make an order stating what evidence may be introduced by the defendant, and the nature of the questions to be permitted. The defendant may then offer evidence pursuant to the order of the court.
(5) An affidavit resealed by the court pursuant to paragraph (2) shall remain sealed, unless the defendant raises an issue on appeal or collateral review relating to the offer of proof contained in the sealed document. If the defendant raises that issue on appeal, the court shall allow the Attorney General and appellate counsel for the defendant access to the sealed affidavit. If the issue is raised on collateral review, the court shall allow the district attorney and defendant’s counsel access to the sealed affidavit. The use of the information contained in the affidavit shall be limited solely to the pending proceeding.
(b) (1) As used in this section, “complaining witness” means:
(A) The alleged victim of the crime charged, the prosecution of which is subject to this section, pursuant to paragraph (1) of subdivision (c).
(B) An alleged victim offering testimony pursuant to paragraph (2) or (3) of subdivision (c).
(2) As used in this section, “evidence of sexual conduct” includes those portions of a social media account about the complaining witness, including any text, image, video, or picture, which depict sexual content, sexual history, nudity or partial nudity, intimate sexual activity, communications about sex, sexual fantasies, and other information that appeals to a prurient interest, unless it is related to the alleged offense.
(c) The procedure provided by subdivision (a) shall apply in any of the following circumstances:
(1) In a prosecution under Section 261, 262, 264.1, 286, 287, 288, 288.5, or 289 of, or former Section 288a of, the Penal Code, or for assault with intent to commit, attempt to commit, or conspiracy to commit any crime defined in any of those sections, except if the crime is alleged to have occurred in a local detention facility, as defined in Section 6031.4 of the Penal Code, or in the state prison, as defined in Section 4504.
(2) When an alleged victim testifies pursuant to subdivision (b) of Section 1101 as a victim of a crime listed in Section 243.4, 261, 261.5, 269, 285, 286, 287, 288, 288.5, 289, 314, or 647.6 of, or former Section 288a of, the Penal Code, except if the crime is alleged to have occurred in a local detention facility, as defined in Section 6031.4 of the Penal Code, or in the state prison, as defined in Section 4504 of the Penal Code.
(3) When an alleged victim of a sexual offense testifies pursuant to Section 1108, except if the crime is alleged to have occurred in a local detention facility, as defined in Section 6031.4 of the Penal Code, or in the state prison, as defined in Section 4504 of the Penal Code.