import django, os, json
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
django.setup()
from apps.editor.models import Project

p = Project.objects.get(pk=25)
draft = p.editor_draft or {}
seqs = draft.get('sequences', [])
seq = next((s for s in seqs if s.get('id') == 'editorial-approved-1775801543726-thematic-14-67066'), None)

modes = seq.get('clipDisplayModes', {})
adjs = seq.get('clipDisplayAdjustments', {})
manual_ids = seq.get('manualClipDisplayBlockIds', [])

print(f"Total mode entries: {len(modes)}")
print(f"Total adj entries: {len(adjs)}")
print(f"Manual IDs: {len(manual_ids)}")

for mid in manual_ids[:5]:
    m = modes.get(mid, {})
    m_port = None
    if isinstance(m, dict):
        m_port = (m.get('byAspect') or {}).get('portrait')
    a = adjs.get(mid, {})
    port = (a.get('byAspect') or {}).get('portrait', {})
    fit = port.get('fit', {})
    fill = port.get('fill', {})
    print(f"\nBlock: ...{mid[-20:]}")
    print(f"  mode(portrait): {m_port}")
    if fit:
        cr = fit.get('cropRect')
        print(f"  fit cropRect: x={cr.get('x', 0):.4f} y={cr.get('y', 0):.4f} w={cr.get('width', 1):.4f} h={cr.get('height', 1):.4f}")
        print(f"  fit cropPreset: {fit.get('cropPreset')}")
        kfs = fit.get('cropKeyframes', [])
        print(f"  fit cropKeyframes: {len(kfs)}")
        for kf in kfs[:3]:
            kcr = kf.get('cropRect', {})
            print(f"    t={kf.get('timeMs')}ms x={kcr.get('x', 0):.4f}")
    if fill:
        cr = fill.get('cropRect')
        print(f"  fill cropRect: x={cr.get('x', 0):.4f} y={cr.get('y', 0):.4f} w={cr.get('width', 1):.4f} h={cr.get('height', 1):.4f}")
