// 
//  SelfieCamApp.swift
//  SelfieCam
//
//  Created by Matt Bruce on 1/4/26.
//

import SwiftUI
import Bedrock

@main
struct SelfieCamApp: App {
    /// Premium manager for checking subscription status on launch
    @State private var premiumManager = PremiumManager()
    
    init() {
        Design.showDebugLogs = true
        
        // Register SelfieCam theme with Bedrock
        Theme.register(
            text: AppTextColors.self,
            surface: AppSurface.self,
            accent: AppAccent.self,
            status: AppStatus.self
        )
        Theme.register(border: AppBorder.self)
    }

    var body: some Scene {
        WindowGroup {
            ZStack {
                Color.BrandColors.primary
                    .ignoresSafeArea()

                AppLaunchView(config: .selfieCam) {
                    RootView()
                }
            }
            .onAppear {
                // Set screen brightness to 100% on app launch
                UIScreen.main.brightness = 1.0
            }
            .task {
                // Refresh subscription status on launch (handles fresh installs)
                await premiumManager.checkSubscriptionStatus()
                
                // Start listening for real-time customer info updates
                premiumManager.startListeningForCustomerInfoUpdates()
            }
        }
    }
}
