"""Parse the JSON a model *meant* to emit — py-06's repair, as a library function."""

from __future__ import annotations

import json
import re


def repair_json(s: str) -> object:
    """Return the object ``s`` was trying to be, repairing the four usual injuries.

    In order: a fenced block (```json … ``` or ``` … ```) is unwrapped; single-quoted
    strings become double-quoted (only when the text contains no double quotes at all —
    otherwise an apostrophe inside a string would be destroyed); a comma before ``}`` or
    ``]`` is dropped; and a truncated tail has its open string, arrays and objects closed
    in the right order. Valid JSON passes through untouched.

    Text that is not JSON even after all four repairs raises ValueError.
    """
    ...
