import Foundation
import Recording

/// The preinstalling service used by the previews, which resolves every locale as supported and downloads nothing.
struct PreviewPreinstalling: Preinstalling {

    /// The stream of events the service emits, which finishes immediately.
    let events: AsyncStream<PreinstallingEvent> = .init { continuation in
        continuation.finish()
    }

    /// Simulates the preinstallation of the speech model assets of the given locale, downloading nothing.
    ///
    /// - Parameter locale: The locale to preinstall the speech model assets for.
    func preinstall(
        for locale: Locale
    ) async {
        // The previews preinstall no speech model assets.
    }

    /// Returns the given locale as its own supported equivalent.
    ///
    /// - Parameter locale: The locale to find a supported equivalent for.
    /// - Returns: The given locale, unchanged.
    func supportedLocale(
        equivalentTo locale: Locale
    ) async -> Locale? {
        locale
    }

    /// Returns a sample of supported locales for the locale picker.
    ///
    /// - Returns: A pair of sample locales.
    func supportedLocales() async -> [Locale] {
        [
            Locale(identifier: "en-US"),
            Locale(identifier: "nl-NL"),
        ]
    }

}
