{% load i18n %}

<div class="ddcu_wrapper" data-ddcu-token="{{ ddcu_token }}" data-ddcu-guu-path="{{ guu_path }}" {% if immediate_submit %}data-immediatesubmit="yes"{% endif %} {% if allow_multiple %}data-allowmultiple="yes"{% endif %}>
    <input
        type="hidden" name="{{ widget.name }}"
        {% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}
        {% include "django/forms/widgets/attrs.html" %}
    >
    {% if allow_multiple %}
        <div class="ddcu_m_file_list">
            {% for path, filename in existing_files %}
                <div data-path="{{ path }}" class="ddcu_m_file_entry">
                    <span class="ddcu_m_filename">{{ filename }}</span>
                    <span class="ddcu_m_marked_for_deletion ddcu_hidden">{% trans "this file will be deleted" %}</span>
                    <span class="ddcu_m_delete ddcu_button">{% trans "Delete" %}</span>
                    <span class="ddcu_m_cancel_deletion ddcu_button ddcu_hidden">{% trans "Cancel" %}</span>
                </div>
            {% endfor %}
            <div class="ddcu_m_file_entry ddcu_hidden ddcu_m_new_file_template">
                <span class="ddcu_m_filename"></span>
                <span class="ddcu_m_marked_for_deletion ddcu_hidden">{% trans "will be deleted" %}</span>
                <span class="ddcu_m_delete ddcu_button">{% trans "Delete" %}</span>
                <span class="ddcu_m_cancel_deletion ddcu_button ddcu_hidden">{% trans "Cancel" %}</span>
            </div>
        </div>
        <label>
            <span class="ddcu_m_add_file ddcu_button">{% if ddcu_image %}{% trans "Add image(s)" %}{% else %}{% trans "Add file(s)" %}{% endif %}</span>
            <input type="file" class="ddcu_m_file_input" {% if ddcu_image %}accept="image/*"{% endif %} multiple="multiple"/>
        </label>
    {% else %}
        <span class="ddcu_current_file_name">{{ current_file_name }}</span>
        <label>
            <span class="ddcu_choose_file ddcu_button">{% if ddcu_image %}{% trans "Choose image" %}{% else %}{% trans "Choose file" %}{% endif %}</span>
            {% if show_replace_button %}
                <span class="ddcu_choose_other_file ddcu_button">{% if ddcu_image %}{% trans "Choose other image" %}{% else %}{% trans "Choose other file" %}{% endif %}</span>
            {% endif %}
            <input type="file" class="ddcu_file_input" {% if ddcu_image %}accept="image/*"{% endif %}/>
        </label>
        {% if input_clearable %}<span class="ddcu_delete_file ddcu_button">{% if ddcu_image %}{% trans "Delete image" %}{% else %}{% trans "Delete file" %}{% endif %}</span>{% endif %}
    {% endif %}
</div>
<div class="ddcu_overlay"><p class="ddcu_overlay_text">{% trans "Uploading file, please wait..." %}</p></div>