{% requireEdition CraftPro %}

{% set isImageUploaded = craft.rebrand.isImageUploaded(imageType) %}

<div class="cp-image cp-image-{{ imageType }}" data-type="{{ imageType }}">
    <div class="cp-current-image{% if isImageUploaded %} checkered{% endif %}"
        {% if isImageUploaded -%}
            {% set image = craft.rebrand.getImageVariable(imageType) %}
            {% if image.width > 0 and image.height > 0 %}
                 style="width: {{ image.width }}px; height: {{ image.height }}px;"
                 data-url="{{ image.url }}"
             {% endif %}
        {%- endif %}
        >
        {% if image is defined and image is not empty -%}
            <img src="{{ url(image.url) }}" alt="{% if imageType == 'logo' %}{{ "Login Page Logo"|t('app') }}{% else %}{{ "Site Icon"|t('app') }}{% endif %}" />
        {%- endif %}
    </div>

    <div class="cp-image-controls">
        {% if disabled is defined and disabled == true %}
            {# don't show any of that #}
        {% else %}
            <input type="file" name="image" class="hidden" />
            {% if isImageUploaded %}
                <div class="flex flex-nowrap">
                    <button type="button" class="btn upload">{% if imageType == 'logo' %}{{ block('changeLogoLabel') }}{% else %}{{ block('changeIconLabel') }}{% endif %}</button>
                    <button type="button" class="btn delete">{% if imageType == 'logo' %}{{ block('deleteLogoLabel') }}{% else %}{{ block('deleteIconLabel') }}{% endif %}</button>
                </div>
            {% else %}
                <div class="flex flex-nowrap">
                    <button type="button" class="btn upload">{% if imageType == 'logo' %}{{ block('uploadLogoLabel') }}{% else %}{{ block('uploadIconLabel') }}{% endif %}</button>
                </div>
            {% endif %}
        {% endif %}
    </div>
</div>
