import { Component } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { distinctUntilChanged, filter, map } from 'rxjs/operators';
import { ClipboardService } from '../../clipboard/clipboard.service';
import { AppStateService } from '../../common/ui-state.service';
import { HeaderService } from '../../header/header.service';
import { VersionService } from '../version.service';
import saveAs from 'file-saver';
import { PlatformDetailsService } from '../platform-details.service';
import * as i0 from "@angular/core";
import * as i1 from "../version.service";
import * as i2 from "../../common/ui-state.service";
import * as i3 from "../../clipboard/clipboard.service";
import * as i4 from "ngx-bootstrap/modal";
import * as i5 from "../platform-details.service";
import * as i6 from "../../header/header.service";
import * as i7 from "../../common/icon.directive";
import * as i8 from "../../i18n/c8y-translate.directive";
import * as i9 from "@angular/common";
import * as i10 from "../../i18n/c8y-translate.pipe";
export class VersionListComponent {
    constructor(version, appState, clipboardService, modalService, platformDetails, headerService) {
        this.version = version;
        this.appState = appState;
        this.clipboardService = clipboardService;
        this.modalService = modalService;
        this.platformDetails = platformDetails;
        this.headerService = headerService;
        this.versionsToDirectlyDisplay$ = this.version.nonHiddenItems$;
        this.currentTenantId$ = this.appState.currentTenant.pipe(map(tenant => tenant?.name), filter(tenantId => !!tenantId), distinctUntilChanged());
        this.open$ = this.headerService.rightDrawerOpen$;
    }
    async downloadPlatformDetails() {
        const obj = await this.platformDetails.getPlatformDetailsObject();
        const json = JSON.stringify(obj, undefined, 2);
        const blob = new Blob([json]);
        saveAs(blob, 'platform-details.json');
    }
    copyIt(text) {
        this.clipboardService.writeText(text);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: VersionListComponent, deps: [{ token: i1.VersionService }, { token: i2.AppStateService }, { token: i3.ClipboardService }, { token: i4.BsModalService }, { token: i5.PlatformDetailsService }, { token: i6.HeaderService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: VersionListComponent, selector: "c8y-version-list", ngImport: i0, template: "<div class=\"separator-top p-t-8 p-b-8\">\n  <div class=\"c8y-right-drawer__item sticky-top\">\n    <i c8yIcon=\"c8y-cumulocity-iot\"></i>\n    <span class=\"text-bold\">{{ 'Platform info' | translate }}</span>\n  </div>\n\n  <ul class=\"list-unstyled\">\n    <li\n      class=\"c8y-right-drawer__item\"\n      *ngIf=\"currentTenantId$ | async as tenantId\"\n    >\n      <span\n        class=\"flex-grow text-muted m-0 text-12 text-truncate\"\n        translate\n      >\n        Tenant ID\n      </span>\n      <button\n        class=\"m-l-auto flex-no-shrink btn-clean p-0 btn-link\"\n        title=\"{{ 'Copy tenant ID to the clipboard' | translate }}\"\n        [attr.tabindex]=\"(open$ | async) ? '0' : '-1'\"\n        type=\"button\"\n        (click)=\"$event.stopPropagation(); copyIt(tenantId)\"\n      >\n        {{ tenantId }}\n        <i\n          class=\"text-14 m-0\"\n          [c8yIcon]=\"'clipboard'\"\n        ></i>\n      </button>\n    </li>\n    <li\n      class=\"c8y-right-drawer__item\"\n      *ngFor=\"let versionEntry of versionsToDirectlyDisplay$ | async\"\n    >\n      <span\n        class=\"flex-no-shrink text-muted text-12 text-truncate m-r-8\"\n        [title]=\"versionEntry.label | translate\"\n      >\n        {{ versionEntry.label | translate }}\n      </span>\n      <span\n        class=\"flex-grow text-right text-truncate\"\n        [title]=\"versionEntry.version | translate\"\n      >\n        {{ versionEntry.version }}\n      </span>\n    </li>\n    <li class=\"c8y-right-drawer__item\">\n      <button\n        class=\"btn btn-default btn-sm\"\n        [attr.tabindex]=\"(open$ | async) ? '0' : '-1'\"\n        title=\"{{ 'Download platform details' | translate }}\"\n        translate\n        (click)=\"downloadPlatformDetails()\"\n      >\n        Download platform details\n      </button>\n    </li>\n  </ul>\n</div>\n", dependencies: [{ kind: "directive", type: i7.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i8.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i9.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i10.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i9.AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: VersionListComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-version-list', template: "<div class=\"separator-top p-t-8 p-b-8\">\n  <div class=\"c8y-right-drawer__item sticky-top\">\n    <i c8yIcon=\"c8y-cumulocity-iot\"></i>\n    <span class=\"text-bold\">{{ 'Platform info' | translate }}</span>\n  </div>\n\n  <ul class=\"list-unstyled\">\n    <li\n      class=\"c8y-right-drawer__item\"\n      *ngIf=\"currentTenantId$ | async as tenantId\"\n    >\n      <span\n        class=\"flex-grow text-muted m-0 text-12 text-truncate\"\n        translate\n      >\n        Tenant ID\n      </span>\n      <button\n        class=\"m-l-auto flex-no-shrink btn-clean p-0 btn-link\"\n        title=\"{{ 'Copy tenant ID to the clipboard' | translate }}\"\n        [attr.tabindex]=\"(open$ | async) ? '0' : '-1'\"\n        type=\"button\"\n        (click)=\"$event.stopPropagation(); copyIt(tenantId)\"\n      >\n        {{ tenantId }}\n        <i\n          class=\"text-14 m-0\"\n          [c8yIcon]=\"'clipboard'\"\n        ></i>\n      </button>\n    </li>\n    <li\n      class=\"c8y-right-drawer__item\"\n      *ngFor=\"let versionEntry of versionsToDirectlyDisplay$ | async\"\n    >\n      <span\n        class=\"flex-no-shrink text-muted text-12 text-truncate m-r-8\"\n        [title]=\"versionEntry.label | translate\"\n      >\n        {{ versionEntry.label | translate }}\n      </span>\n      <span\n        class=\"flex-grow text-right text-truncate\"\n        [title]=\"versionEntry.version | translate\"\n      >\n        {{ versionEntry.version }}\n      </span>\n    </li>\n    <li class=\"c8y-right-drawer__item\">\n      <button\n        class=\"btn btn-default btn-sm\"\n        [attr.tabindex]=\"(open$ | async) ? '0' : '-1'\"\n        title=\"{{ 'Download platform details' | translate }}\"\n        translate\n        (click)=\"downloadPlatformDetails()\"\n      >\n        Download platform details\n      </button>\n    </li>\n  </ul>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.VersionService }, { type: i2.AppStateService }, { type: i3.ClipboardService }, { type: i4.BsModalService }, { type: i5.PlatformDetailsService }, { type: i6.HeaderService }] });
//# sourceMappingURL=data:application/json;base64, 