import { Component } from '@angular/core';
import { map } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "../channel.service";
import * as i2 from "../custom-templates.service";
import * as i3 from "../theme.service";
import * as i4 from "@angular/common";
import * as i5 from "../icon/icon.component";
import * as i6 from "../paginated-list/paginated-list.component";
import * as i7 from "../channel-preview/channel-preview.component";
import * as i8 from "@ngx-translate/core";
/**
 * The `ChannelList` component renders the list of channels.
 */
export class ChannelListComponent {
    constructor(channelService, customTemplatesService, themeService) {
        this.channelService = channelService;
        this.customTemplatesService = customTemplatesService;
        this.themeService = themeService;
        this.isLoadingMoreChannels = false;
        this.subscriptions = [];
        this.theme$ = this.themeService.theme$;
        this.channels$ = this.channelService.channels$;
        this.hasMoreChannels$ = this.channelService.hasMoreChannels$;
        this.isError$ = this.channelService.channelQueryState$.pipe(map((s) => !this.isLoadingMoreChannels && s?.state === 'error'));
        this.isInitializing$ = this.channelService.channelQueryState$.pipe(map((s) => !this.isLoadingMoreChannels && s?.state === 'in-progress'));
        this.subscriptions.push(this.customTemplatesService.channelPreviewTemplate$.subscribe((template) => (this.customChannelPreviewTemplate = template)));
    }
    ngOnDestroy() {
        this.subscriptions.forEach((s) => s.unsubscribe());
    }
    async loadMoreChannels() {
        this.isLoadingMoreChannels = true;
        await this.channelService.loadMoreChannels();
        this.isLoadingMoreChannels = false;
    }
    trackByChannelId(_, item) {
        return item.cid;
    }
}
ChannelListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: ChannelListComponent, deps: [{ token: i1.ChannelService }, { token: i2.CustomTemplatesService }, { token: i3.ThemeService }], target: i0.ɵɵFactoryTarget.Component });
ChannelListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: ChannelListComponent, selector: "stream-channel-list", ngImport: i0, template: "<div\n  #container\n  data-testid=\"channel-list-container\"\n  class=\"str-chat str-chat-angular__channel-list str-chat__channel-list str-chat-channel-list messaging str-chat__theme-{{\n    theme$ | async\n  }}\"\n>\n  <div\n    *ngIf=\"\n      (isError$ | async) === false && (isInitializing$ | async) === false;\n      else statusIndicator\n    \"\n    class=\"str-chat__channel-list-messenger\"\n  >\n    <div class=\"str-chat__channel-list-messenger__main\">\n      <ng-content select=\"[channel-list-top]\"></ng-content>\n      <div\n        *ngIf=\"!(channels$ | async)?.length\"\n        class=\"str-chat__channel-list-empty\"\n      >\n        <stream-icon icon=\"chat-bubble\"></stream-icon>\n        <p data-testid=\"empty-channel-list-indicator\">\n          {{ \"streamChat.You have no channels currently\" | translate }}\n        </p>\n      </div>\n      <p\n        *ngIf=\"!(channels$ | async)?.length\"\n        class=\"str-chat__channel-list-empty-v1\"\n        data-testid=\"empty-channel-list-indicator\"\n      >\n        {{ \"streamChat.You have no channels currently\" | translate }}\n      </p>\n      <stream-paginated-list\n        [items]=\"(channels$ | async) ?? []\"\n        [hasMore]=\"(hasMoreChannels$ | async) ?? false\"\n        [isLoading]=\"isLoadingMoreChannels\"\n        (loadMore)=\"loadMoreChannels()\"\n        [trackBy]=\"trackByChannelId\"\n      >\n        <ng-template let-channel=\"item\">\n          <ng-template #defaultTemplate let-channelInput=\"channel\">\n            <stream-channel-preview\n              data-testclass=\"channel-preview\"\n              [channel]=\"channelInput\"\n            ></stream-channel-preview>\n          </ng-template>\n          <div>\n            <ng-container\n              *ngTemplateOutlet=\"\n                customChannelPreviewTemplate || defaultTemplate;\n                context: { channel: channel }\n              \"\n            ></ng-container>\n          </div>\n        </ng-template>\n      </stream-paginated-list>\n      <ng-content select=\"[channel-list-bottom]\"></ng-content>\n    </div>\n  </div>\n</div>\n\n<ng-template #statusIndicator>\n  <ng-container *ngIf=\"isError$ | async\">\n    <ng-container *ngTemplateOutlet=\"chatDown\"></ng-container>\n  </ng-container>\n  <ng-container *ngIf=\"isInitializing$ | async\">\n    <ng-container *ngTemplateOutlet=\"loadingChannels\"></ng-container>\n  </ng-container>\n</ng-template>\n\n<ng-template #chatDown>\n  <div data-testid=\"chatdown-container\" class=\"str-chat__down\">\n    <ng-container *ngTemplateOutlet=\"loadingChannels\"></ng-container>\n  </div>\n</ng-template>\n\n<ng-template #loadingChannels>\n  <div\n    data-testid=\"loading-indicator-full-size\"\n    class=\"str-chat__loading-channels\"\n  >\n    <ng-container *ngTemplateOutlet=\"loadingChannel\"></ng-container>\n    <ng-container *ngTemplateOutlet=\"loadingChannel\"></ng-container>\n    <ng-container *ngTemplateOutlet=\"loadingChannel\"></ng-container>\n  </div>\n</ng-template>\n\n<ng-template #loadingChannel>\n  <div\n    class=\"str-chat__loading-channels-item str-chat__channel-preview-loading\"\n  >\n    <div class=\"str-chat__loading-channels-avatar\"></div>\n    <div\n      class=\"str-chat__loading-channels-meta str-chat__channel-preview-end-loading\"\n    >\n      <div class=\"str-chat__loading-channels-username\"></div>\n      <div class=\"str-chat__loading-channels-status\"></div>\n    </div>\n  </div>\n</ng-template>\n", dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i5.IconComponent, selector: "stream-icon", inputs: ["icon"] }, { kind: "component", type: i6.PaginatedListComponent, selector: "stream-paginated-list", inputs: ["items", "isLoading", "hasMore", "trackBy"], outputs: ["loadMore"] }, { kind: "component", type: i7.ChannelPreviewComponent, selector: "stream-channel-preview", inputs: ["channel"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: ChannelListComponent, decorators: [{
            type: Component,
            args: [{ selector: 'stream-channel-list', template: "<div\n  #container\n  data-testid=\"channel-list-container\"\n  class=\"str-chat str-chat-angular__channel-list str-chat__channel-list str-chat-channel-list messaging str-chat__theme-{{\n    theme$ | async\n  }}\"\n>\n  <div\n    *ngIf=\"\n      (isError$ | async) === false && (isInitializing$ | async) === false;\n      else statusIndicator\n    \"\n    class=\"str-chat__channel-list-messenger\"\n  >\n    <div class=\"str-chat__channel-list-messenger__main\">\n      <ng-content select=\"[channel-list-top]\"></ng-content>\n      <div\n        *ngIf=\"!(channels$ | async)?.length\"\n        class=\"str-chat__channel-list-empty\"\n      >\n        <stream-icon icon=\"chat-bubble\"></stream-icon>\n        <p data-testid=\"empty-channel-list-indicator\">\n          {{ \"streamChat.You have no channels currently\" | translate }}\n        </p>\n      </div>\n      <p\n        *ngIf=\"!(channels$ | async)?.length\"\n        class=\"str-chat__channel-list-empty-v1\"\n        data-testid=\"empty-channel-list-indicator\"\n      >\n        {{ \"streamChat.You have no channels currently\" | translate }}\n      </p>\n      <stream-paginated-list\n        [items]=\"(channels$ | async) ?? []\"\n        [hasMore]=\"(hasMoreChannels$ | async) ?? false\"\n        [isLoading]=\"isLoadingMoreChannels\"\n        (loadMore)=\"loadMoreChannels()\"\n        [trackBy]=\"trackByChannelId\"\n      >\n        <ng-template let-channel=\"item\">\n          <ng-template #defaultTemplate let-channelInput=\"channel\">\n            <stream-channel-preview\n              data-testclass=\"channel-preview\"\n              [channel]=\"channelInput\"\n            ></stream-channel-preview>\n          </ng-template>\n          <div>\n            <ng-container\n              *ngTemplateOutlet=\"\n                customChannelPreviewTemplate || defaultTemplate;\n                context: { channel: channel }\n              \"\n            ></ng-container>\n          </div>\n        </ng-template>\n      </stream-paginated-list>\n      <ng-content select=\"[channel-list-bottom]\"></ng-content>\n    </div>\n  </div>\n</div>\n\n<ng-template #statusIndicator>\n  <ng-container *ngIf=\"isError$ | async\">\n    <ng-container *ngTemplateOutlet=\"chatDown\"></ng-container>\n  </ng-container>\n  <ng-container *ngIf=\"isInitializing$ | async\">\n    <ng-container *ngTemplateOutlet=\"loadingChannels\"></ng-container>\n  </ng-container>\n</ng-template>\n\n<ng-template #chatDown>\n  <div data-testid=\"chatdown-container\" class=\"str-chat__down\">\n    <ng-container *ngTemplateOutlet=\"loadingChannels\"></ng-container>\n  </div>\n</ng-template>\n\n<ng-template #loadingChannels>\n  <div\n    data-testid=\"loading-indicator-full-size\"\n    class=\"str-chat__loading-channels\"\n  >\n    <ng-container *ngTemplateOutlet=\"loadingChannel\"></ng-container>\n    <ng-container *ngTemplateOutlet=\"loadingChannel\"></ng-container>\n    <ng-container *ngTemplateOutlet=\"loadingChannel\"></ng-container>\n  </div>\n</ng-template>\n\n<ng-template #loadingChannel>\n  <div\n    class=\"str-chat__loading-channels-item str-chat__channel-preview-loading\"\n  >\n    <div class=\"str-chat__loading-channels-avatar\"></div>\n    <div\n      class=\"str-chat__loading-channels-meta str-chat__channel-preview-end-loading\"\n    >\n      <div class=\"str-chat__loading-channels-username\"></div>\n      <div class=\"str-chat__loading-channels-status\"></div>\n    </div>\n  </div>\n</ng-template>\n" }]
        }], ctorParameters: function () { return [{ type: i1.ChannelService }, { type: i2.CustomTemplatesService }, { type: i3.ThemeService }]; } });
//# sourceMappingURL=data:application/json;base64, 