#!/usr/bin/env python3
import re
from pathlib import Path

root = Path('/Users/yanxuyao/Vap/QGVAPlayer/QGVAPlayer')
parity = root / 'LNSwift/Bridges/LN_API_PARITY_TABLE.md'
facade = root / 'LNSwift/Core/LNVAPFacade.swift'

parity_text = parity.read_text(encoding='utf-8')
facade_text = facade.read_text(encoding='utf-8')

expected = set()
for token in re.findall(r'`LNVAPFacade\.([^`]+)`', parity_text):
    # token may include " / `lnXxx:`" in same line; split conservatively.
    for part in token.split(' / '):
        part = part.strip()
        if not part:
            continue
        # keep selector-like text only
        if re.match(r'^[A-Za-z_][A-Za-z0-9_:]*$', part):
            expected.add(part)

exposed = set(re.findall(r'@objc\(([^\)]+)\)', facade_text))
missing = sorted(s for s in expected if s not in exposed)

print(f'expected_from_table={len(expected)}')
print(f'exposed_in_facade={len(exposed)}')
if missing:
    print('MISSING_SELECTORS:')
    for s in missing:
        print(s)
    raise SystemExit(1)
print('OK: parity table selectors all exposed in LNVAPFacade')
