import { Component, Input } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@sunbird-cb/utils-v2";
import * as i2 from "@angular/common";
import * as i3 from "@angular/material/icon";
// import { UserMiniProfileService } from '../../mini-profile/user-mini-profile.service'
// import { NsMiniProfile } from '../../mini-profile/mini-profile.model'
export class UserImageComponent {
    constructor(configSvc) {
        this.configSvc = configSvc;
        this.email = '';
        this.userId = null;
        this.userName = '';
        this.imageType = 'initial';
        this.imageUrl = null;
        this.imageSize = 'large';
        this.basePicUrl = `/apis/protected/v8/user/profile/graph/photo/`;
        this.errorOccurred = false;
        this.verifiedMicrosoftEmail = '';
        this.shortName = '';
    }
    ngOnInit() { }
    ngOnChanges() {
        if (this.email &&
            this.configSvc.instanceConfig &&
            this.configSvc.instanceConfig.microsoft &&
            this.configSvc.instanceConfig.microsoft.validEmailExtensions) {
            if (this.configSvc.instanceConfig.microsoft.validEmailExtensions.some(extension => this.email.includes(extension))) {
                this.verifiedMicrosoftEmail = this.email;
            }
        }
        if (this.userName && this.userName !== '  ') {
            const userNameArr = this.userName.split(' ').slice(0, 2);
            this.shortName = userNameArr
                .map(u => u[0])
                .join('')
                .toUpperCase();
        }
        else {
            this.imageType = 'initial';
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserImageComponent, deps: [{ token: i1.ConfigurationsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: UserImageComponent, selector: "ws-widget-user-image", inputs: { email: "email", userId: "userId", userName: "userName", imageType: "imageType", imageUrl: "imageUrl", imageSize: "imageSize" }, usesOnChanges: true, ngImport: i0, template: "<!-- <img alt=\"user-image\" *ngIf=\"(!errorOccurred && verifiedMicrosoftEmail?.length) || imageUrl\" class=\"user-image\"\n  [src]=\"verifiedMicrosoftEmail?.length ? basePicUrl + verifiedMicrosoftEmail : imageUrl\"\n  (error)=\"errorOccurred = true\" /> -->\n<ng-container>\n  <mat-icon class=\"user-icon\" *ngIf=\"imageType === 'initial'\">person</mat-icon>\n  <span class=\"mat-app-background rounded-icon\" *ngIf=\"imageType === 'rounded'\">\n    <mat-icon class=\"user-icon\">person</mat-icon>\n  </span>\n  <span class=\"name-initials-image font-normal ws-mat-primary-default-text ws-mat-accent-background\"\n    *ngIf=\"imageType === 'name-initial'\">{{ shortName }}</span>\n  <div *ngIf=\"imageType === 'user-photo'\">\n    <img *ngIf=\"imageUrl\" [src]=\"imageUrl\" alt=\"user-image\" class=\"user-image\" [ngClass]=\"{'user-image-small': imageSize === 'small'}\">\n    <div class=\"user-image\" [ngClass]=\"{'user-image-small': imageSize === 'small'}\">\n      <span class=\"name-initials-image font-normal ws-mat-primary-default-text ws-mat-accent-background\"\n      *ngIf=\"!imageUrl\">{{ shortName }}</span>\n    </div>\n  </div>\n</ng-container>\n", styles: [".user-image{width:70px;height:70px;border-radius:50%;object-fit:cover}.user-image-small{width:50px;height:50px;border-radius:50%;object-fit:cover}.user-icon{font-size:100%;width:100%;height:100%;vertical-align:initial!important}.rounded-icon{display:inline-block;border-radius:50%;padding:4px;box-sizing:border-box}.name-initials-image{border-radius:50%;padding:4px;box-sizing:border-box;width:100%;display:flex;height:100%;align-items:center;justify-content:center}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserImageComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ws-widget-user-image', template: "<!-- <img alt=\"user-image\" *ngIf=\"(!errorOccurred && verifiedMicrosoftEmail?.length) || imageUrl\" class=\"user-image\"\n  [src]=\"verifiedMicrosoftEmail?.length ? basePicUrl + verifiedMicrosoftEmail : imageUrl\"\n  (error)=\"errorOccurred = true\" /> -->\n<ng-container>\n  <mat-icon class=\"user-icon\" *ngIf=\"imageType === 'initial'\">person</mat-icon>\n  <span class=\"mat-app-background rounded-icon\" *ngIf=\"imageType === 'rounded'\">\n    <mat-icon class=\"user-icon\">person</mat-icon>\n  </span>\n  <span class=\"name-initials-image font-normal ws-mat-primary-default-text ws-mat-accent-background\"\n    *ngIf=\"imageType === 'name-initial'\">{{ shortName }}</span>\n  <div *ngIf=\"imageType === 'user-photo'\">\n    <img *ngIf=\"imageUrl\" [src]=\"imageUrl\" alt=\"user-image\" class=\"user-image\" [ngClass]=\"{'user-image-small': imageSize === 'small'}\">\n    <div class=\"user-image\" [ngClass]=\"{'user-image-small': imageSize === 'small'}\">\n      <span class=\"name-initials-image font-normal ws-mat-primary-default-text ws-mat-accent-background\"\n      *ngIf=\"!imageUrl\">{{ shortName }}</span>\n    </div>\n  </div>\n</ng-container>\n", styles: [".user-image{width:70px;height:70px;border-radius:50%;object-fit:cover}.user-image-small{width:50px;height:50px;border-radius:50%;object-fit:cover}.user-icon{font-size:100%;width:100%;height:100%;vertical-align:initial!important}.rounded-icon{display:inline-block;border-radius:50%;padding:4px;box-sizing:border-box}.name-initials-image{border-radius:50%;padding:4px;box-sizing:border-box;width:100%;display:flex;height:100%;align-items:center;justify-content:center}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.ConfigurationsService }]; }, propDecorators: { email: [{
                type: Input
            }], userId: [{
                type: Input
            }], userName: [{
                type: Input
            }], imageType: [{
                type: Input
            }], imageUrl: [{
                type: Input
            }], imageSize: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 