import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { map, switchMap } from 'rxjs';
import { Md5 } from 'ts-md5';
import { ResourceSelectContextService } from '../../context.service';
import { AuthorizationStateService } from './../../../../authorization/state.service';
import * as i0 from "@angular/core";
import * as i1 from "./../../../../authorization/state.service";
import * as i2 from "../../context.service";
export class ResourceDashboardComponent {
    constructor(auth, contextService) {
        this.auth = auth;
        this.contextService = contextService;
        this.email$ = this.auth
            .getTokenPayload()
            .pipe(map(info => info.email));
        this.user$ = this.email$.pipe(switchMap(email => this.contextService.getUser(Md5.hashStr(email).toString())));
    }
}
ResourceDashboardComponent.ɵfac = function ResourceDashboardComponent_Factory(t) { return new (t || ResourceDashboardComponent)(i0.ɵɵdirectiveInject(i1.AuthorizationStateService), i0.ɵɵdirectiveInject(i2.ResourceSelectContextService)); };
ResourceDashboardComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResourceDashboardComponent, selectors: [["acl-resource-dashboard"]], inputs: { numbers: "numbers" }, decls: 32, vars: 22, consts: [[1, "dashboard"], [1, "user"], [1, "user__avatar"], ["src", "images/avatar.svg", "alt", ""], [1, "user__info"], [1, "with-colon"], [1, "stats"], [1, "stats__item"], ["icon", "bicolor:project", 1, "acl-colorful-icon", "highlight"], [1, "number"], ["icon", "bicolor:server", 1, "acl-colorful-icon", "highlight"]], template: function ResourceDashboardComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "span", 2);
        i0.ɵɵelement(3, "img", 3);
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(4, "div", 4)(5, "span");
        i0.ɵɵtext(6);
        i0.ɵɵpipe(7, "translate");
        i0.ɵɵpipe(8, "async");
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(9, "span")(10, "span", 5);
        i0.ɵɵtext(11);
        i0.ɵɵpipe(12, "translate");
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(13, "span");
        i0.ɵɵtext(14);
        i0.ɵɵpipe(15, "aclRelativeTime");
        i0.ɵɵpipe(16, "async");
        i0.ɵɵelementEnd()()()();
        i0.ɵɵelementStart(17, "div", 6)(18, "span", 7);
        i0.ɵɵelement(19, "aui-icon", 8);
        i0.ɵɵelementStart(20, "span");
        i0.ɵɵtext(21);
        i0.ɵɵpipe(22, "translate");
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(23, "span", 9);
        i0.ɵɵtext(24);
        i0.ɵɵelementEnd()();
        i0.ɵɵelementStart(25, "span", 7);
        i0.ɵɵelement(26, "aui-icon", 10);
        i0.ɵɵelementStart(27, "span");
        i0.ɵɵtext(28);
        i0.ɵɵpipe(29, "translate");
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(30, "span", 9);
        i0.ɵɵtext(31);
        i0.ɵɵelementEnd()()()();
    } if (rf & 2) {
        let tmp_2_0;
        i0.ɵɵadvance(6);
        i0.ɵɵtextInterpolate2(" ", i0.ɵɵpipeBind1(7, 8, "hello"), "", i0.ɵɵpipeBind1(8, 10, ctx.email$), " ");
        i0.ɵɵadvance(5);
        i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(12, 12, "last_login_time"));
        i0.ɵɵadvance(3);
        i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(15, 14, (tmp_2_0 = i0.ɵɵpipeBind1(16, 16, ctx.user$)) == null ? null : tmp_2_0.spec == null ? null : tmp_2_0.spec.last_login_time));
        i0.ɵɵadvance(7);
        i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(22, 18, "project_number"));
        i0.ɵɵadvance(3);
        i0.ɵɵtextInterpolate((ctx.numbers == null ? null : ctx.numbers.project) || 0);
        i0.ɵɵadvance(4);
        i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(29, 20, "cluster_number"));
        i0.ɵɵadvance(3);
        i0.ɵɵtextInterpolate((ctx.numbers == null ? null : ctx.numbers.cluster) || 0);
    } }, styles: ["[_nghost-%COMP%]{display:block}.dashboard[_ngcontent-%COMP%]{height:100px;padding:20px;color:#fff;display:flex;border-radius:var(--aui-border-radius-l);background-color:rgb(var(--aui-color-primary));background-image:url(^images/overview-banner.svg);background-size:cover;background-position:center}.user[_ngcontent-%COMP%]{display:flex;margin-right:180px}.user__avatar[_ngcontent-%COMP%]{width:60px;height:60px;background-color:rgb(var(--aui-color-n-10));border-radius:50%;margin-right:20px}.user[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:60px}.user__info[_ngcontent-%COMP%]{display:flex;flex-direction:column}.user__info[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{line-height:20px;font-size:12px}.user__info[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:first-child{line-height:24px;font-size:18px;margin:6px 0 4px}.stats[_ngcontent-%COMP%]{font-size:14px;display:flex;align-items:center}.stats__item[_ngcontent-%COMP%]{margin-right:60px;display:flex;align-items:flex-end}.stats__item[_ngcontent-%COMP%]   .number[_ngcontent-%COMP%]{font-size:36px;font-weight:500;margin-left:8px;line-height:1}.stats__item[_ngcontent-%COMP%]   aui-icon[_ngcontent-%COMP%]{display:flex;margin-right:8px;width:32px;height:32px;font-size:32px}.with-colon[_ngcontent-%COMP%]:after{content:\":\";margin-right:8px}"], changeDetection: 0 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResourceDashboardComponent, [{
        type: Component,
        args: [{ selector: 'acl-resource-dashboard', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"dashboard\">\n  <div class=\"user\">\n    <span class=\"user__avatar\">\n      <img\n        src=\"images/avatar.svg\"\n        alt=\"\"\n      />\n    </span>\n    <div class=\"user__info\">\n      <span> {{ 'hello' | translate }}{{ email$ | async }} </span>\n      <span>\n        <span class=\"with-colon\">{{ 'last_login_time' | translate }}</span>\n        <span>{{\n          (user$ | async)?.spec?.last_login_time | aclRelativeTime\n        }}</span>\n      </span>\n    </div>\n  </div>\n  <div class=\"stats\">\n    <span class=\"stats__item\">\n      <aui-icon\n        class=\"acl-colorful-icon highlight\"\n        icon=\"bicolor:project\"\n      ></aui-icon>\n      <span>{{ 'project_number' | translate }}</span>\n      <span class=\"number\">{{ numbers?.project || 0 }}</span>\n    </span>\n    <span class=\"stats__item\">\n      <aui-icon\n        class=\"acl-colorful-icon highlight\"\n        icon=\"bicolor:server\"\n      ></aui-icon>\n      <span>{{ 'cluster_number' | translate }}</span>\n      <span class=\"number\">{{ numbers?.cluster || 0 }}</span>\n    </span>\n  </div>\n</div>\n", styles: [":host{display:block}.dashboard{height:100px;padding:20px;color:#fff;display:flex;border-radius:var(--aui-border-radius-l);background-color:rgb(var(--aui-color-primary));background-image:url(^images/overview-banner.svg);background-size:cover;background-position:center}.user{display:flex;margin-right:180px}.user__avatar{width:60px;height:60px;background-color:rgb(var(--aui-color-n-10));border-radius:50%;margin-right:20px}.user img{width:60px}.user__info{display:flex;flex-direction:column}.user__info>span{line-height:20px;font-size:12px}.user__info>span:first-child{line-height:24px;font-size:18px;margin:6px 0 4px}.stats{font-size:14px;display:flex;align-items:center}.stats__item{margin-right:60px;display:flex;align-items:flex-end}.stats__item .number{font-size:36px;font-weight:500;margin-left:8px;line-height:1}.stats__item aui-icon{display:flex;margin-right:8px;width:32px;height:32px;font-size:32px}.with-colon:after{content:\":\";margin-right:8px}\n"] }]
    }], function () { return [{ type: i1.AuthorizationStateService }, { type: i2.ResourceSelectContextService }]; }, { numbers: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 