<!-- Buttons to add to the header. -->
<core-navbar-buttons slot="end">
    <ion-button fill="clear" (click)="openModuleSummary()" aria-haspopup="true" [attr.aria-label]="'core.info' | translate">
        <ion-icon name="fas-info-circle" slot="icon-only" aria-hidden="true"></ion-icon>
    </ion-button>
</core-navbar-buttons>

<!-- Content. -->
<core-loading [hideUntil]="!showLoading" class="safe-area-page list-item-limited-width">

    <!-- Activity info. -->
    <core-course-module-info [module]="module" [description]="description" [component]="component" [componentId]="componentId"
        [courseId]="courseId" (completionChanged)="onCompletionChange()">
    </core-course-module-info>

    <ng-container *ngIf="groupInfo && (groupInfo.separateGroups || groupInfo.visibleGroups)">
        <ion-card class="core-info-card" *ngIf="groupInfo.groups && groupInfo.groups.length > 1">
            <ion-item>
                <ion-icon name="fas-question-circle" slot="start" aria-hidden="true"></ion-icon>
                <ion-label>{{ 'addon.mod_bigbluebuttonbn.view_groups_selection_warning' | translate }}</ion-label>
            </ion-item>
        </ion-card>

        <ion-item class="ion-text-wrap core-group-selector">
            <ion-label id="addon-bigbluebuttonbn-groupslabel">
                <ng-container *ngIf="groupInfo.separateGroups">{{'core.groupsseparate' | translate }}</ng-container>
                <ng-container *ngIf="groupInfo.visibleGroups">{{'core.groupsvisible' | translate }}</ng-container>
            </ion-label>
            <ion-select [(ngModel)]="groupId" (ionChange)="groupChanged()" aria-labelledby="addon-bigbluebuttonbn-groupslabel"
                interface="action-sheet" [interfaceOptions]="{header: 'core.group' | translate}">
                <ion-select-option *ngFor="let groupOpt of groupInfo.groups" [value]="groupOpt.id">
                    {{groupOpt.name}}
                </ion-select-option>
            </ion-select>
        </ion-item>
    </ng-container>

    <ng-container *ngIf="meetingInfo">
        <ion-item class="ion-text-wrap" *ngIf="meetingInfo.openingtime">
            <ion-label>
                <h3>{{ 'addon.mod_bigbluebuttonbn.mod_form_field_openingtime' | translate }}</h3>
            </ion-label>
            <p slot="end">{{ meetingInfo.openingtime * 1000 | coreFormatDate }}</p>
        </ion-item>
        <ion-item class="ion-text-wrap" *ngIf="meetingInfo.closingtime">
            <ion-label>
                <h3>{{ 'addon.mod_bigbluebuttonbn.mod_form_field_closingtime' | translate }}</h3>
            </ion-label>
            <p slot="end">{{ meetingInfo.closingtime * 1000 | coreFormatDate }}</p>
        </ion-item>

        <ion-item class="ion-text-wrap" *ngIf="meetingInfo.canjoin && !meetingInfo.statusrunning">
            <ion-label>
                <p>{{ 'addon.mod_bigbluebuttonbn.view_message_conference_room_ready' | translate }}</p>
            </ion-label>
        </ion-item>

        <ng-container *ngIf="meetingInfo.statusrunning">
            <ion-item class="ion-text-wrap">
                <ion-label>
                    <p>{{ 'addon.mod_bigbluebuttonbn.view_message_conference_in_progress' | translate }}</p>
                </ion-label>
            </ion-item>

            <ion-item class="ion-text-wrap" *ngIf="meetingInfo.startedat">
                <ion-label>
                    <h3>{{ 'addon.mod_bigbluebuttonbn.view_message_session_started_at' | translate }}</h3>
                </ion-label>
                <p slot="end">{{ meetingInfo.startedat * 1000 | coreFormatDate: "strftimetime" }}</p>
            </ion-item>

            <ion-item class="ion-text-wrap">
                <ion-label>
                    <h3 *ngIf="meetingInfo.moderatorplural">
                        {{ 'addon.mod_bigbluebuttonbn.view_message_moderators' | translate }}
                    </h3>
                    <h3 *ngIf="!meetingInfo.moderatorplural">
                        {{ 'addon.mod_bigbluebuttonbn.view_message_moderator' | translate }}
                    </h3>
                </ion-label>
                <p slot="end">{{ meetingInfo.moderatorcount }}</p>
            </ion-item>

            <ion-item class="ion-text-wrap">
                <ion-label>
                    <h3 *ngIf="meetingInfo.participantplural">
                        {{ 'addon.mod_bigbluebuttonbn.view_message_viewers' | translate }}
                    </h3>
                    <h3 *ngIf="!meetingInfo.participantplural">
                        {{ 'addon.mod_bigbluebuttonbn.view_message_viewer' | translate }}
                    </h3>
                </ion-label>
                <p slot="end">{{ meetingInfo.participantcount }}</p>
            </ion-item>
        </ng-container>

        <ion-card *ngIf="!meetingInfo.canjoin" class="core-warning-card">
            <ion-item class="ion-text-wrap">
                <ion-icon name="fas-exclamation-triangle" slot="start" aria-hidden="true"></ion-icon>
                <ion-label>{{ meetingInfo.statusmessage }}</ion-label>
            </ion-item>
        </ion-card>
    </ng-container>

    <div collapsible-footer *ngIf="!showLoading" slot="fixed">
        <div class="list-item-limited-width adaptable-buttons-row"
            *ngIf="meetingInfo && (meetingInfo.canjoin || meetingInfo.statusrunning && meetingInfo.ismoderator)">
            <ion-button *ngIf="meetingInfo.statusrunning && meetingInfo.ismoderator" fill="outline" class="ion-margin ion-text-wrap"
                expand="block" (click)="endMeeting()">
                {{ 'addon.mod_bigbluebuttonbn.view_conference_action_end' | translate }}
            </ion-button>
            <ion-button *ngIf="meetingInfo.canjoin" class="ion-margin ion-text-wrap" expand="block" (click)="joinRoom()">
                {{ 'addon.mod_bigbluebuttonbn.view_conference_action_join' | translate }}
            </ion-button>
        </div>

        <core-course-module-navigation [courseId]="courseId" [currentModuleId]="module.id">
        </core-course-module-navigation>
    </div>
</core-loading>
