; or (ii) the juvenile— (I) is not charged with any offense; and (II) (aa) is an alien; or (bb) is alleged to be dependent, neglected, or abused; and (B) require that— (i) not later than 3 years after the date of enactment of the Juvenile Justice and Delinquency Prevention Reauthorization Act of 2017 , unless a court finds, after a hearing and in writing, that it is in the interest of justice, juveniles awaiting trial or other legal process who are treated as adults for purposes of prosecution in criminal court and housed in a secure facility— (I) shall not have sight or sound contact with adult inmates; and (II) except as provided in paragraph (13), may not be held in any jail or lockup for adults; (ii) in determining under subparagraph (A) whether it is in the interest of justice to permit a juvenile to be held in any jail or lockup for adults, or have sight or sound contact with adult inmates, a court shall consider— (I) the age of the juvenile; (II) the physical and mental maturity of the juvenile; (III) the present mental state of the juvenile, including whether the juvenile presents an imminent risk of harm to the juvenile; (IV) the nature and circumstances of the alleged offense; (V) the juvenile's history of prior delinquent acts; (VI) the relative ability of the available adult and juvenile detention facilities to not only meet the specific needs of the juvenile but also to protect the safety of the public as well as other detained youth; and (VII) any other relevant factor; and (iii) if a court determines under subparagraph (A) that it is in the interest of justice to permit a juvenile to be held in any jail or lockup for adults— (I) the court shall hold a hearing not less frequently than once every 30 days, or in the case of a rural jurisdiction, not less frequently than once every 45 days, to review whether it is still in the interest of justice to permit the juvenile to be so held or have such sight or sound contact