{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template core_message/message_area_messages_area

    Messages area template.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * none

    Context variables required for this template:
    * isonline - boolean
    * isblocked - boolean
    * otheruserid - int
    * otheruserfullname - string
    * messages - array of messages

    Example context (json):
    {
        "isonline": true,
        "isblocked": true,
        "otheruserid": 1,
        "otheruserfullname": "Sam Student",
        "messages": [
            {
                "text": "Hello there!"
            }
        ]
    }
}}
{{#otheruserid}}
<div class="messages-header">
    <div class="view-toggle btn-container">
        <button class="btn btn-link" data-action="show-contacts">&lt; {{#str}} messages, message {{/str}}</button>
    </div>
    <div class="delete-all btn-container">
        <button class="btn btn-link" data-action="delete-all-messages" aria-label="{{#str}} deleteallmessages, message {{/str}}">
            {{#str}} deleteall {{/str}}
        </button>
    </div>
    <div class="name-container">
        <div class="name">
            <button class="btn btn-link" data-action="view-contact-profile" data-userid="{{otheruserid}}">{{otheruserfullname}}</button>
            {{#isblocked}}
                <span data-region="contact-icon-blocked">
                    {{#pix}} t/block, core, {{#str}} contactblocked, message {{/str}} {{/pix}}
                </span>
            {{/isblocked}}
        </div>
        {{#showonlinestatus}}
            <div class="status {{#isonline}}online{{/isonline}}">
                <span class="offline-text">{{#str}} offline, message {{/str}}</span>
                <span class="online-text">{{#str}} online, message {{/str}}</span>
            </div>
        {{/showonlinestatus}}
    </div>
    <div class="delete-instructions">
        {{#str}} selectmessagestodelete, message {{/str}}
    </div>
    <div class="actions" data-region="messages-header-actions">
        <button class="btn btn-link messages-delete" data-action="start-delete-messages"
                aria-label="{{#str}} editmessages, message {{/str}}">{{#str}}edit{{/str}}</button>
        <button class="btn btn-link cancel-messages-delete" data-action="cancel-delete-messages"
                aria-label="{{#str}} canceledit, message {{/str}}">{{#str}}cancel{{/str}}</button>
    </div>
</div>
{{/otheruserid}}
{{#contactsfirst}}
<div class="messages-header">
    <div class="name-container">
        <div class="name">
            {{#str}}newmessagesearch, message{{/str}}
        </div>
    </div>
</div>
{{/contactsfirst}}
<div class="messages" data-region="messages" data-userid="{{otheruserid}}">
    {{> core_message/message_area_messages }}
</div>
{{#otheruserid}}
<div class="response" data-region="response">
    {{#iscurrentuser}}
        <div class="message-box">
            {{> core_message/message_area_response }}
        </div>
    {{/iscurrentuser}}
    <div class="delete-confirmation">
        <button class="btn btn-link confirm" data-action="delete-messages">{{#str}} deleteselectedmessages, message {{/str}}</button>
    </div>
</div>
{{/otheruserid}}
