import Foundation

/**
 A string key used in markdown to indicate special elements
 */
enum CommandType: String {

    /// An image
    /// Format:  `![image](<imageId>;<caption?>]`
    case image

    /// Labels with an icon and a value
    /// Format: `![labels](<icon=value>...)`
    case labels

    /// A video
    /// Format: `![video](<fileId>;<option1...>]`
    case video

    /**
     A variable number of buttons for file downloads, external links or other uses
     
     Format: `![buttons](type=<specification>;...)`
     Types:
     - Download: `download=<fileId>,<text>,<download-filename?>`
     - External link: `external=<url>,<text>`
     - Git: `git=<url>,<text>`
     - Play: `play-circle=<text>,<click-action>`
     */
    case buttons

    /// A box with a title and content
    /// Format: `![box](<title>;<body>)`
    case box

    /// A 3D model to display
    /// Format: `![model](<file>;<description>)`
    case model

    /// A pretty link to another page on the site.
    /// Format: `![page](<pageId>)`
    case pageLink = "page"

    /// A pretty link to a tag list on the site.
    /// Format: `![tag](<tagId>)`
    case tagLink = "tag"

    /// Additional HTML code included verbatim into the page.
    /// Format: `![html](<fileId>)`
    case includedHtml = "html"

    /// SVG Image showing only a part of the image
    /// Format `![svg](<fileId>;<<x>;<y>;<width>;<height>>?)`
    case svg

    /// A player to play audio files
    /// Format: `![audio-player](<fileId>;<text>)`
    case audioPlayer = "audio-player"

    /// Add svg icons to the page for use in html components
    /// Format: `![icons](icon-id;...)`
    case icons

    /**
     Create an image comparison with a slider.
     Format: `![compare](image1;image2)`
     */
    case imageCompare = "compare"


    var processor: CommandProcessor.Type {
        switch self {
        case .image: return ImageCommand.self
        case .labels: return LabelsCommand.self
        case .video: return VideoCommand.self
        case .buttons: return ButtonCommand.self
        case .box: return BoxCommand.self
        case .model: return ModelCommand.self
        case .pageLink: return PageLinkCommand.self
        case .tagLink: return TagLinkCommand.self
        case .includedHtml: return HtmlCommand.self
        case .svg: return SvgCommand.self
        case .audioPlayer: return AudioPlayerCommand.self
        case .icons: return IconCommand.self
        case .imageCompare: return ImageCompareCommand.self
        }
    }
}

extension CommandType: CaseIterable {
    
}
