"""
Packet Decoder Widget - 3-panel packet inspection interface
"""

from textual.widgets import Static, DataTable, Tree
from textual.containers import Horizontal, Vertical
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from ....analysis.core import EthernetAnalyzer


class PacketDecoderWidget(Horizontal):
    """
    3-Panel Packet Decoder Interface
    
    Layout:
    - Left: Flow summary tree
    - Center: Packet list table
    - Right: Field details tree
    """
    
    def __init__(self, analyzer: 'EthernetAnalyzer', **kwargs):
        super().__init__(**kwargs)
        self.analyzer = analyzer
        
    def compose(self):
        """Create the 3-panel layout"""
        
        # Left panel: Flow summary
        with Vertical(id="flow-summary-panel"):
            yield Static("Flow Summary", id="flow-summary-title")
            flow_tree = Tree("Flows", id="flow-tree")
            yield flow_tree
        
        # Center panel: Packet list
        with Vertical(id="packet-list-panel"):
            yield Static("Packet Details", id="packet-list-title")
            packet_table = DataTable(id="packet-table")
            packet_table.add_columns("Time", "Src", "Dst", "Protocol", "Info")
            yield packet_table
        
        # Right panel: Field details
        with Vertical(id="field-details-panel"):
            yield Static("Field Analysis", id="field-details-title")
            field_tree = Tree("Fields", id="field-tree")
            yield field_tree
    
    def on_mount(self) -> None:
        """Initialize the widget"""
        self.refresh_data()
    
    def refresh_data(self) -> None:
        """Refresh packet decoder data"""
        # TODO: Implement packet data refresh
        pass