 import macOSThemeKit
 
 class PacketsViewController: BaseViewController {
-
+    
+    struct TableIdentifiers {
+        static let statusCode = "statusCode"
+        static let method = "method"
+        static let url = "url"
+        static let date = "date"
+    }
+    
+    enum FilterTags: Int {
+        case address, status, method
+    }
+    
     static var statusColumnWidth = CGFloat(50.0)
     static var methodColumnWidth = CGFloat(55.0)
     static var dateColumnWidth = CGFloat(150.0)

    
}

extension PacketsViewController: NSTableViewDelegate, NSTableViewDataSource
{
    func numberOfRows(in tableView: NSTableView) -> Int {
        
        return self.viewModel?.itemCount() ?? 0
    }
    
    
    func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
        
        return FlatTableRowView()
    }
    
    
    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
        
        if (tableColumn?.identifier)!.rawValue == "statusCode" {
            
            let cell: StatusPacketTableCellView = self.tableView.makeView(withOwner: nil)!
            cell.packet = self.viewModel?.item(at: row)
            cell.backgroundStyle = .normal
            return cell
            
        }else if (tableColumn?.identifier)!.rawValue == "method" {
            
            let cell: MethodPacketTableCellView = self.tableView.makeView(withOwner: nil)!
            cell.packet = self.viewModel?.item(at: row)
            cell.backgroundStyle = .normal
            return cell
            
        }else if (tableColumn?.identifier)!.rawValue == "url" {
            
            let cell: URLPacketTableCellView = self.tableView.makeView(withOwner: nil)!
            cell.packet = self.viewModel?.item(at: row)
            cell.backgroundStyle = .normal
            return cell
            
        }else if (tableColumn?.identifier)!.rawValue == "date" {
            
            let cell: DatePacketTableCellView = self.tableView.makeView(withOwner: nil)!
            cell.packet = self.viewModel?.item(at: row)
            cell.backgroundStyle = .normal
            return cell
        }
        
        return nil
    }
    
    func tableViewSelectionDidChange(_ notification: Notification) {
        
        let selectedRow = self.tableView.selectedRow
        
        if selectedRow >= 0 , let item = self.viewModel?.item(at: selectedRow) {
            
            if item !== self.viewModel?.selectedItem {
                
                self.onPacketSelect?(item)
            }
        }else {
            
            self.onPacketSelect?(nil)
        }
    }
    
}

        self.setupTableViewHeaders()
    }
    
    private func setupFilterTextFields() {
        self.addressFilterTextField.backgroundColor = ThemeColor.controlBackgroundColor
        self.addressFilterTextField.tag = FilterTags.address.rawValue
        self.addressFilterTextField.delegate = self
        
        self.statusFilterTextField.backgroundColor = ThemeColor.controlBackgroundColor
        self.statusFilterTextField.tag = FilterTags.status.rawValue
        self.statusFilterTextField.delegate = self
        
        self.methodFilterTextField.backgroundColor = ThemeColor.controlBackgroundColor
        self.methodFilterTextField.tag = FilterTags.method.rawValue
        self.methodFilterTextField.delegate = self
    }
    
    func refresh() {
        self.tableView.reloadData()
