import SwiftUI

public enum FeaturedArtistAlertStyle: Equatable {
    public struct TextCopy: Equatable, Codable {
        static let empty: TextCopy = .init(backgroundImage: nil, buttonLabel: "")

        let backgroundImage: Image?
        let buttonLabel: String

        public init(backgroundImage: Image?, buttonLabel: String) {
            self.backgroundImage = backgroundImage
            self.buttonLabel = buttonLabel
        }

        enum CodingKeys: CodingKey {
            case backgroundImage
            case buttonLabel
        }

        public init(from decoder: Decoder) throws {
            let container = try decoder.container(keyedBy: CodingKeys.self)
            backgroundImage = nil
            buttonLabel = try container.decode(String.self, forKey: .buttonLabel)
        }

        public func encode(to encoder: Encoder) throws {
            var container = encoder.container(keyedBy: CodingKeys.self)
            try container.encode(buttonLabel, forKey: .buttonLabel)
        }
    }

    public static func == (lhs: FeaturedArtistAlertStyle, rhs: FeaturedArtistAlertStyle) -> Bool {
        return lhs.textCopy == rhs.textCopy
    }

    case preset(FeaturedArtistAlertStyle.Preset)
    case custom(FeaturedArtistAlertStyle.TextCopy)

    public var textCopy: FeaturedArtistAlertStyle.TextCopy {
        switch self {
        case .preset(let preset): return preset.textCopy
        case .custom(let copyData): return copyData
        }
    }
}
