import SwiftUI

/// Main entry point for the CommandNotch application.
/// Provides a MenuBarExtra for quick access to settings and app controls.
/// The notch windows and terminal sessions are managed by AppDelegate + ScreenManager.
@main
struct CommandNotchApp: App {

    @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    @StateObject private var settingsController = AppSettingsController.shared

    var body: some Scene {
        MenuBarExtra(
            "CommandNotch",
            systemImage: "terminal",
            isInserted: Binding(
                get: { settingsController.settings.display.showMenuBarIcon },
                set: { newValue in
                    settingsController.update { $0.display.showMenuBarIcon = newValue }
                }
            )
        ) {
            Button("Toggle Notch") {
                ScreenManager.shared.toggleNotchOnActiveScreen()
            }
            .keyboardShortcut(.return, modifiers: .command)

            Divider()

            Button("Settings...") {
                SettingsWindowController.shared.showSettings()
            }
            .keyboardShortcut(",", modifiers: .command)

            Divider()

            Button("Quit CommandNotch") {
                NSApplication.shared.terminate(nil)
            }
            .keyboardShortcut("Q", modifiers: .command)
        }
    }
}
