//
//  ClientFactory.swift
//  Meow
//

import Foundation
import CatFactsKit
import ComposableArchitecture

public struct ClientFactory: Sendable {
    public func createClient(baseURL: URL) -> CatFacts {
        return CatFacts(baseURL: baseURL)
    }
}

extension ClientFactory: DependencyKey, TestDependencyKey {
    public static var liveValue: ClientFactory {
        ClientFactory()
    }

    public static var testValue: ClientFactory {
        ClientFactory()
    }
}

public extension DependencyValues {
    var clientFactory: ClientFactory {
        get { self[ClientFactory.self] }
        set { self[ClientFactory.self] = newValue }
    }
}
