<template name="messageAttachment">
    <div class="attachment">
        <div class="attachment-block">
            <div class="attachment-block-border background-info-font-color" style="background-color: {{color}}"></div>
            {{#if title}}
                <div class="attachment-title">
                    {{#if title_link}}
                        <a href="{{title_link}}" target="_blank" rel="noopener noreferrer">{{title}}</a>
                        {{#if title_link_download}}
                            <a class="icon-download attachment-download-icon" href="{{title_link}}" target="_blank" download="" rel="noopener noreferrer"></a>
                        {{/if}}
                    {{else}}
                        {{title}}
                    {{/if}}
                </div>
            {{/if}}

            {{#if image_url}}
                <div class="attachment-image">
                    <figure>
                        <div class="inline-image" style="background-image: url('{{image_url}}');">
                            <img src="{{image_url}}" height="{{getImageHeight image_dimensions.height}}" class="gallery-item" data-title="{{title}}" data-description="{{description}}">
                        </div>
                        {{#if description}}
                            <figcaption class="attachment-description">{{description}}</figcaption>
                        {{/if}}
                    </figure>
                </div>
            {{/if}}

            {{#if audio_url}}
                <div class="attachment-audio">
                    <audio controls>
                        <source src="{{audio_url}}" type="{{audio_type}}" data-description="{{description}}">
                        Your browser does not support the audio element.
                    </audio>
                </div>
            {{/if}}

            {{#if video_url}}
                <div class="attachment-video">
                    <video controls class="inline-video">
                        <source src="{{video_url}}" type="{{video_type}}" data-description="{{description}}">
                        Your browser does not support the video element.
                    </video>
                </div>
            {{/if}}

            {{#unless image_url}}
                {{#if description}}
                    <div class="attachment-description">{{description}}</div>
                {{/if}}
            {{/unless}}

            {{#each attachments}}
                {{> messageAttachment}}
            {{/each}}
        </div>
    </div>
</template>
