"""Hash pinned public LingBot World V2 source documents without installing or running the model."""

import hashlib
import json
import urllib.request

SOURCE_REVISION = "1895d300d8ac936401689b26389f51cbd36530eb"
MODEL_REVISION = "7e36a5f919f86cb4255cc9bfc30adb44963fbde1"
BASE = f"https://raw.githubusercontent.com/Robbyant/lingbot-world-v2/{SOURCE_REVISION}"
MODEL = (
    f"https://huggingface.co/robbyant/lingbot-world-v2-1.3b-causal-fast/resolve/{MODEL_REVISION}"
)
DOCUMENTS = {
    "README.md": f"{BASE}/README.md",
    "generate.py": f"{BASE}/generate.py",
    "wan/image2video.py": f"{BASE}/wan/image2video.py",
    "wan/utils/cam_utils.py": f"{BASE}/wan/utils/cam_utils.py",
    "wan/configs/shared_config.py": f"{BASE}/wan/configs/shared_config.py",
    "wan/configs/wan_i2v_1_3B.py": f"{BASE}/wan/configs/wan_i2v_1_3B.py",
    "LICENSE.txt": f"{BASE}/LICENSE.txt",
    "model/README.md": f"{MODEL}/README.md",
}


def audit():
    result = []
    for name, url in DOCUMENTS.items():
        request = urllib.request.Request(url, headers={"User-Agent": "CloutSourceAudit/1.0"})
        with urllib.request.urlopen(request, timeout=30) as response:
            data = response.read()
        result.append(
            {"name": name, "bytes": len(data), "sha256": hashlib.sha256(data).hexdigest()}
        )
    return {"sourceRevision": SOURCE_REVISION, "modelRevision": MODEL_REVISION, "documents": result}


if __name__ == "__main__":
    print(json.dumps(audit(), indent=2))
