//
// Copyright 2026 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Compound
import CompoundDesignTokens
import SwiftUI

enum CompoundExtensions {
    @MainActor
    static func applyLetroOverrides() {
        Color.compound.applyLetroOverrides()
        UIColor.compound.applyLetroOverrides()
        CompoundIcon.applyLetroOverrides()
    }
}

extension CompoundColors {
    @MainActor
    func applyLetroOverrides() {
        override(\.gradientActionStop1, with: .letroGradient1)
        override(\.gradientActionStop2, with: .letroGradient2)
        override(\.gradientActionStop3, with: .letroGradient3)
        override(\.gradientActionStop4, with: .letroGradient5)
        override(\.gradientSubtleStop1, with: .letroGradient1.opacity(0.33))
        override(\.gradientSubtleStop2, with: .letroGradient2.opacity(0.22))
        override(\.gradientSubtleStop3, with: .letroGradient3.opacity(0.11))
        override(\.gradientSubtleStop4, with: .letroGradient4.opacity(0.07))
        override(\.gradientSubtleStop5, with: .letroGradient5.opacity(0.04))
        override(\.bgActionPrimaryRest, with: .letroPrimary)
        override(\.bgActionPrimaryPressed, with: .letroGradient1)
        override(\.bgActionPrimaryDisabled, with: .letroGray.opacity(0.4))
        override(\.iconAccentTertiary, with: .letroPrimary)
        override(\.bgAccentRest, with: .letroPrimary)
        override(\.textActionPrimary, with: .letroPrimary)
    }
}

extension CompoundUIColors {
    @MainActor
    func applyLetroOverrides() {
        override(\.gradientActionStop1, with: .letroGradient1)
        override(\.gradientActionStop2, with: .letroGradient2)
        override(\.gradientActionStop3, with: .letroGradient3)
        override(\.gradientActionStop4, with: .letroGradient5)
        override(\.gradientSubtleStop1, with: .letroGradient1.withAlphaComponent(0.33))
        override(\.gradientSubtleStop2, with: .letroGradient2.withAlphaComponent(0.22))
        override(\.gradientSubtleStop3, with: .letroGradient3.withAlphaComponent(0.11))
        override(\.gradientSubtleStop4, with: .letroGradient4.withAlphaComponent(0.07))
        override(\.gradientSubtleStop5, with: .letroGradient5.withAlphaComponent(0.04))
        override(\.bgActionPrimaryRest, with: .letroPrimary)
        override(\.bgActionPrimaryPressed, with: .letroGradient1)
        override(\.bgActionPrimaryDisabled, with: .letroGray.withAlphaComponent(0.4))
        override(\.iconAccentTertiary, with: .letroPrimary)
        override(\.bgAccentRest, with: .letroPrimary)
        override(\.textActionPrimary, with: .letroPrimary)
    }
}

extension CompoundIcon {
    @MainActor
    static func applyLetroOverrides() {
        override(\.chat, with: Image("images/letro-icon-chat"))
        override(\.chatSolid, with: Image("images/letro-icon-chatSolid"))
        override(\.space, with: Image("images/letro-icon-space"))
        override(\.spaceSolid, with: Image("images/letro-icon-spaceSolid"))
    }
}
