# shellcheck shell=dash disable=1091,2034
# Thank and Salute Oh My Zsh Creator Robby Russell (https://github.com/robbyrussell)

___x_cmd_theme_prompt_format(){
    ___x_cmd_theme_robby "$@"
}

# cvs
___x_cmd_theme_robby(){
    case "$1" in
        mini)       ___x_cmd_theme_robbymini "$@"  ;;
        *)          ___x_cmd_theme_robbyfull "$@"  ;;
    esac
}

xrc:theme:widget msg symbol cwd vcm emoji
___x_cmd_theme_robbyfull(){
    local x_;

    ___x_cmd_theme_headline_print

    ___x_cmd_theme_widget_symbol "➜" "➜" "➜"
    local X_left="${X_symbol} "

    ___x_cmd_theme_widget_cwd_git
    [ -z "$X_cwd" ] || X_left="${X_left} ${X_cwd}"

    ___x_cmd_theme_widget_vcm
    [ -z "$X_vcm" ] || X_left="${X_left} ${X_vcm}"

    ___x_cmd_theme_widget_emoji
    ___x_cmd_theme_widget_emoji_escape_bug
    [ -z "$X_emoji" ] || X_left="${X_emoji}  ${X_left}"

    printf "%s "       "$X_left"
}

XT_transient_ps1(){
    local x_=""
    theme:feature:get transient_time
    case "$x_" in
        always)
            ___x_cmd_theme_comp_transient time
            ___X_CMD_THEME_TIME_H_M_S="$x_"
            ___x_cmd_theme_widget_hms 2>/dev/null
            [ -z "$X_hms" ] || X_ps1="${X_hms} " ;;
    esac

    ___x_cmd_theme_widget_symbol "➜" "➜" "➜" 2>/dev/null
    [ -z "$X_symbol" ] || X_ps1="${X_ps1}${X_symbol} "
}

___x_cmd_theme_widget_vcm(){
    X_vcm=""
    local x_=
    [ -z "$x_git" ] || {
        X_vcm="${x_git##*/}"
        if theme:comp:git:changed;    then
            theme:style_ "%${XTW_vcm_style_ref_dirty}%"     "$X_vcm";                   X_vcm="${x_}"
            label="$XTW_vcm_label_dirty";
            theme:style_ "%${XTW_vcm_style_label_dirty}%"   "$label";                   label="${x_}"
        else
            theme:style_ "%${XTW_vcm_style_ref_clean}%"     "$X_vcm";                   X_vcm="${x_}"
            label="$XTW_vcm_label_clean";
            [ -z "$label" ] || {
            theme:style_ "%${XTW_vcm_style_label_clean}%"   "$label";                   label="${x_}";
            }
        fi
        x_="git:("; theme:style_ "%${XTW_vcm_style}%" "$x_"; X_vcm="${x_}${X_vcm}"
        x_=")";     theme:style_ "%${XTW_vcm_style}%" "$x_"; X_vcm="${X_vcm}${x_}"
        [ -z "$label" ] || X_vcm="${X_vcm} ${label}"
        return
    }

    [ -z "$x_svn" ] || {
        x_=
        return
    }

    [ -z "$x_hg" ] || {
        x_=
        return
    }
}

XTW_vcm_label_clean=""
XTW_vcm_label_dirty="✗"

___x_cmd_theme_linecount_ps1=1

case "$___X_CMD_THEME_TERM_COLORTYPE" in
    8)
        theme:color cyan red
        # symbol
        XTW_symbol_style_true="green"
        XTW_symbol_style_false="red"
        # cwd
        XTW_cwd_style="bold cyan"
        XTW_cwd_style_git="bold cyan"
        # vcm
        XTW_vcm_style="bold blue"
        XTW_vcm_style_ref_clean="bold red"
        XTW_vcm_style_ref_dirty="bold red"
        XTW_vcm_style_label_clean=""
        XTW_vcm_style_label_dirty="bold yellow"
        ;;
esac
