#!/usr/bin/env python3

import sys
import os

sys.path.insert(0, "/home/ouaillaamiri/Development/Oit LAB/CaDaR")

from cadar import CaDaR


def debug_long_vowels():
    """Debug long vowel processing in detail"""
    print("=== Detailed Debug: Long Vowels ===")

    cadar = CaDaR()

    # Test all long vowels
    test_cases = ["aa", "ii", "uu", "oo", "laa", "mii", "duu", "soo"]

    for test in test_cases:
        print(f"\n--- Testing '{test}' ---")

        # Latin to Arabic
        arabic = cadar.bizi2ara(test)
        print(f"Latin→Arabic: '{test}' → '{arabic}'")

        # Arabic back to Latin
        roundtrip = cadar.ara2bizi(arabic)
        print(f"Arabic→Latin: '{arabic}' → '{roundtrip}'")

        # Check if roundtrip is successful
        if roundtrip == test:
            print("✅ Perfect roundtrip!")
        else:
            print(f"❌ Roundtrip failed: expected '{test}', got '{roundtrip}'")

    # Test individual characters vs sequences
    print(f"\n--- Character vs Sequence Analysis ---")

    # Test single 'a' vs 'aa'
    a_single = cadar.bizi2ara("a")
    a_double = cadar.bizi2ara("aa")
    print(f"Single 'a': 'a' → '{a_single}'")
    print(f"Double 'a': 'aa' → '{a_double}'")

    if a_double == a_single:
        print("❌ ERROR: 'aa' produces same result as 'a'")
    else:
        print("✅ 'aa' produces different result from 'a'")

    # Test roundtrip for both
    a_single_rt = cadar.ara2bizi(a_single)
    a_double_rt = cadar.ara2bizi(a_double)
    print(f"Single 'a' roundtrip: '{a_single}' → '{a_single_rt}'")
    print(f"Double 'a' roundtrip: '{a_double}' → '{a_double_rt}'")

    print("=" * 50)


if __name__ == "__main__":
    debug_long_vowels()
