<!-- Buttons to add to the header. -->
<core-navbar-buttons slot="end">
    <core-context-menu>
        <core-context-menu-item *ngIf="externalUrl" [priority]="900" [content]="'core.openinbrowser' | translate" [href]="externalUrl"
            iconAction="fas-external-link-alt" [showBrowserWarning]="false"></core-context-menu-item>
        <core-context-menu-item *ngIf="description" [priority]="800" [content]="'core.moduleintro' | translate"
            (action)="expandDescription()" iconAction="fas-arrow-right"></core-context-menu-item>
        <core-context-menu-item *ngIf="blog" [priority]="750" content="{{'addon.blog.blog' | translate}}" iconAction="far-newspaper"
            (action)="gotoBlog()"></core-context-menu-item>
        <core-context-menu-item [priority]="700" [content]="'core.refresh' | translate" (action)="doRefresh(null, $event)"
            [iconAction]="refreshIcon" [closeOnClick]="false"></core-context-menu-item>
        <core-context-menu-item *ngIf="prefetchStatusIcon" [priority]="600" [content]="prefetchText" (action)="prefetch($event)"
            [iconAction]="prefetchStatusIcon" [closeOnClick]="false"></core-context-menu-item>
        <core-context-menu-item *ngIf="size" [priority]="500" [content]="'core.clearstoreddata' | translate:{$a: size}"
            iconDescription="fas-archive" (action)="removeFiles($event)" iconAction="fas-trash" [closeOnClick]="false">
        </core-context-menu-item>
    </core-context-menu>
</core-navbar-buttons>

<!-- Content. -->
<core-loading [hideUntil]="loaded">

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

    <ion-list>
        <ion-item>
            <ion-label>
                <h2>{{ 'addon.mod_book.toc' | translate }}</h2>
            </ion-label>
        </ion-item>

        <ion-item class="ion-text-wrap" *ngFor="let chapter of chapters" [class.item-dimmed]="chapter.hidden" button detail="true"
            (click)="openBook(chapter.id)">
            <ion-label>
                <p [class.ion-padding-start]="addPadding && chapter.level == 1 ? true : null">
                    <span *ngIf="showNumbers" class="addon-mod-book-number">{{chapter.indexNumber}}&nbsp;</span>
                    <span *ngIf="showBullets" class="addon-mod-book-bullet">&bull;&nbsp;</span>
                    <core-format-text [text]="chapter.title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
                    </core-format-text>
                </p>
            </ion-label>
        </ion-item>

        <ion-button class="ion-margin" expand="block" (click)="openBook()">
            <span *ngIf="!hasStartedBook">{{ 'core.start' | translate }}</span>
            <span *ngIf="hasStartedBook">{{ 'core.resume' | translate }}</span>
        </ion-button>

    </ion-list>

</core-loading>

<core-course-module-navigation [hidden]="!loaded" [courseId]="courseId" [currentModule]="module" (completionChanged)="onCompletionChange()">
</core-course-module-navigation>