import APIClient
import Localization
import ShareAssetClient
import StatsigClient

extension Clip {
    func songArtConfig(id: String, lyricsStyle: ShareAssetLyricsStyle, stickerStyle: ShareAssetStickerStyle) -> VisualizerAssetConfig {
        var coverPresetAndSource: (
            preset: ShareAssetBackgroundPreset,
            imageURL: String?,
            videoURL: String?
        ) {
            if isScene {
                return (.coverVideo, largeImageUrl, videoToSongVideoOutputUrl)
            } else if let videoCoverUrl = videoCoverUrl, FeatureFlag.legacy.videoSongCover {
                return (.coverVideo, largeImageUrl, videoCoverUrl)
            } else {
                return (.coverImage, largeImageUrl, nil)
            }
        }

        return VisualizerAssetConfig(
            id: id,
            displayName: L10n.FeatureShareAssets.songArt,
            shareAssetConfig: .init(
                backgroundPreset: coverPresetAndSource.preset,
                stickerStyle: stickerStyle,
                lyricsStyle: lyricsStyle
            ),
            coverImageURL: coverPresetAndSource.imageURL,
            coverVideoURL: coverPresetAndSource.videoURL
        )
    }
}
