#!/usr/bin/env python3
"""
EA Bridge path resolution.

Resolves the bridge layout so gold_trader can find the market_snapshot.json
and other EA output files that live under the MT5 Common/Files directory.
"""

from pathlib import Path
from typing import Optional


def resolve_bridge_layout(project_root: Path) -> dict[str, Path]:
    """Return the bridge directory layout.

    layout["root"] points to the MT5 Common/Files directory where the EA
    writes market_snapshot.json, terminal_status.json, and the from_ea/
    to_ea/ subdirectories.
    """
    import config_manager

    mt5_files = config_manager.get_mt5_dir()

    # The EA bridge lives under gold_autotrade/bridge/ inside MT5 Common/Files
    bridge_root = mt5_files / "gold_autotrade" / "bridge"

    return {
        "root": mt5_files,          # Common/Files (market_snapshot.json lives here)
        "bridge_root": bridge_root,  # Common/Files/gold_autotrade/bridge/
        "from_ea": bridge_root / "from_ea",
        "to_ea": bridge_root / "to_ea",
    }
