import Foundation
import RealFlags

public extension ParameterStores {
    /// Flags used for local debug. never fetched from statsig
    struct LocalOnly: FlagCollectionProtocol {
        @Flag(key: "askNotificationsOnRootView", default: true, description: "Disable this to test the notifications question on black screen, otherwise we ask for notif permission as soon as the RootView appears")
        public var askNotificationsOnRootView: Bool

        public init() {}
    }
}

public extension ParameterStores.LocalOnly {
    static var loader: FlagsLoader<Self> {
        let fileName = "\(Self.self)_localflags.json"

        let localProvider = {
            if let applicationSupportDirectory = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first {
                return LocalProvider(localURL: applicationSupportDirectory.appendingPathComponent(fileName))
            } else {
                assertionFailure("couldn't construct application support directory URL")
                return LocalProvider()
            }
        }()

        return FlagsLoader(Self.self, providers: [localProvider])
    }
}
