§ 777. Application by mortgagee or lienor of record or other person having an interest in the property. a. If, after a trial, the court shall determine that the facts alleged in the petition have been affirmatively established by the petitioners, that no defense thereto specified in section seven hundred seventy-five of this article has been affirmatively established by the owner or a mortgagee or lienor of record, and that the facts alleged in the petition warrant the granting of the relief sought, and if the owner or any mortgagee or lienor of record or other person having an interest in the property, shall apply to the court to be permitted to remove or remedy the conditions specified in such petition and shall (1) demonstrate the ability promptly to undertake the work required; and (2) post security for the performance thereof within the time, and in the amount and manner, deemed necessary by the court, then the court, in lieu of rendering judgment as provided in section seven hundred seventy-six of this article, may issue an order permitting such person to perform the work within a time fixed by the court but in no event more than sixty days from the date of the order of the court unless the court grants an extension of time for good cause shown. The provisions of this subdivision shall only be available to the mortgagee or lienor once with respect to any petition filed pursuant to this article.
b. If, after the issuance of an order pursuant to subdivision a of this section, but before the time fixed in such order for the completion of the work prescribed therein, it shall appear to the petitioners that the person permitted to do the same is not proceeding with due diligence, the petitions may apply to the court on notice to those persons who have appeared in the proceeding for a hearing to determine whether judgment should be rendered immediately as provided in subdivision c of this section.
c. If, upon a hearing authorized in subdivision b hereof, the court shall determine that such owner, mortgagee, lienor or other person is not proceeding with due diligence, or upon the failure of such owner, mortgagee, lienor or other person to complete the work in accordance with the provisions of said order, the court shall render a final judgment appointing an administrator as authorized in section seven hundred seventy-eight of this article. Such judgment shall direct the administrator to apply the security posted by such person to the removing or remedying of the condition or conditions specified in the petition. In the event that the amount of such security should be insufficient for such purpose, such judgment shall direct the deposit of rents with the administrator, as authorized by section seven hundred seventy-six of this article, to the extent of such deficiency. In the event that such security should exceed the amount required to remove or remedy such condition or conditions, such judgment shall direct the administrator to file with the court, upon completion of the work prescribed therein, a full accounting of the amount of such security and the expenditures made pursuant to such judgment, and to turn over such surplus to the person who posted such security, together with a copy of such accounting.