import { Component, ElementRef, EventEmitter, Inject, Output } from '@angular/core';
import { FeedbackSearchComponent } from '@aztrix/components/feedback';
import { OverlayService } from '@aztrix/components/overlay';
import { BACKEND_URL } from '@aztrix/environment';
import { avatarUrl, profileName, profileUsername } from '@aztrix/helpers';
import { ProfileService } from '@aztrix/sdk';
import { BehaviorSubject, map, shareReplay } from 'rxjs';
import { ACCOUNT_BILLING, ACCOUNT_CONTACTS, ACCOUNT_SETTINGS } from './tokens';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/components/overlay";
import * as i2 from "@aztrix/sdk";
import * as i3 from "@angular/common";
import * as i4 from "./account-button/account-button.component";
import * as i5 from "./account-header/account-header.component";
import * as i6 from "@aztrix/translate";
import * as i7 from "rxjs";
export class AccountComponent {
    constructor(billing, contacts, settings, backendUrl, _elementRef, _overlay, _profile) {
        this.billing = billing;
        this.contacts = contacts;
        this.settings = settings;
        this.backendUrl = backendUrl;
        this._elementRef = _elementRef;
        this._overlay = _overlay;
        this._profile = _profile;
        this.logout = new EventEmitter();
        this.myProfile$ = this._profile.getMeProfile('FULL').pipe(shareReplay(1));
        this.title$ = this.myProfile$.pipe(map((profile) => profileName(profile)));
        this.description$ = this.myProfile$.pipe(map((profile) => profileUsername(profile)));
        this.avatar$ = this.myProfile$.pipe(map((profile) => avatarUrl(profile)));
    }
    openFeedbackModal() {
        this._overlay.createModal(this._elementRef, FeedbackSearchComponent, {});
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AccountComponent, deps: [{ token: ACCOUNT_BILLING }, { token: ACCOUNT_CONTACTS }, { token: ACCOUNT_SETTINGS }, { token: BACKEND_URL }, { token: i0.ElementRef }, { token: i1.OverlayService }, { token: i2.ProfileService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: AccountComponent, selector: "ax-account", outputs: { logout: "logout" }, ngImport: i0, template: "<div class=\"route content\">\n  <ax-account-header\n    [avatar]=\"(avatar$ | async) || undefined\"\n    [title]=\"(title$ | async) || undefined\"\n    [description]=\"(description$ | async) || undefined\"\n  >\n    <ax-account-button\n      *ngIf=\"billing\"\n      class=\"tier-button\"\n      icon=\"lightning-bolt-outline\"\n      [title]=\"'tiers.upgrade' | translate\"\n      [url]=\"'/account/billing/tiers'\"\n      color=\"primary\"\n    ></ax-account-button>\n  </ax-account-header>\n\n  <div class=\"body\">\n    <ax-account-button\n      icon=\"account-outline\"\n      [title]=\"'me.account.profile.title' | translate\"\n      [url]=\"'/account/my-account'\"\n      spacing=\"MEDIUM\"\n    ></ax-account-button>\n\n    <ax-account-button\n      *ngIf=\"settings\"\n      icon=\"cog-outline\"\n      [title]=\"'label.settings' | translate\"\n      [url]=\"'/account/settings'\"\n    ></ax-account-button>\n\n    <ax-account-button\n      *ngIf=\"contacts\"\n      icon=\"account-group-outline\"\n      [title]=\"'label.contacts' | translate\"\n      [url]=\"'/account/contacts'\"\n    ></ax-account-button>\n\n    <ax-account-button\n      *ngIf=\"billing\"\n      icon=\"receipt-text-outline\"\n      [title]=\"'settings.payment.title' | translate\"\n      [url]=\"'/account/billing'\"\n    ></ax-account-button>\n\n    <ng-content></ng-content>\n\n    <ax-account-button\n      icon=\"xml\"\n      [title]=\"'settings.account.organisation.developer.title' | translate\"\n      [url]=\"'/account/developer'\"\n      spacing=\"MEDIUM\"\n    ></ax-account-button>\n\n    <ax-account-button\n      icon=\"gavel\"\n      [title]=\"'label.policies' | translate\"\n      [url]=\"backendUrl.value + '/policy'\"\n      target=\"_blank\"\n    ></ax-account-button>\n\n    <ax-account-button\n      icon=\"help-circle-outline\"\n      [title]=\"'label.feedback' | translate\"\n      (click)=\"openFeedbackModal()\"\n    ></ax-account-button>\n\n    <ax-account-button\n      icon=\"logout\"\n      outline\n      color=\"grey\"\n      [title]=\"'label.logout' | translate\"\n      (click)=\"logout.emit()\"\n    ></ax-account-button>\n  </div>\n</div>\n", styles: [":host{display:block;max-width:var(--container-max-width);width:100%;margin:0 auto;padding:1rem}.content,.body{display:flex;flex-direction:column;gap:.75rem}.tier-button{margin-top:1rem}\n"], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i4.AccountButtonComponent, selector: "ax-account-button", inputs: ["title", "hint", "color", "postIcon"] }, { kind: "component", type: i5.AccountHeaderComponent, selector: "ax-account-header", inputs: ["avatar", "title", "description"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AccountComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-account', template: "<div class=\"route content\">\n  <ax-account-header\n    [avatar]=\"(avatar$ | async) || undefined\"\n    [title]=\"(title$ | async) || undefined\"\n    [description]=\"(description$ | async) || undefined\"\n  >\n    <ax-account-button\n      *ngIf=\"billing\"\n      class=\"tier-button\"\n      icon=\"lightning-bolt-outline\"\n      [title]=\"'tiers.upgrade' | translate\"\n      [url]=\"'/account/billing/tiers'\"\n      color=\"primary\"\n    ></ax-account-button>\n  </ax-account-header>\n\n  <div class=\"body\">\n    <ax-account-button\n      icon=\"account-outline\"\n      [title]=\"'me.account.profile.title' | translate\"\n      [url]=\"'/account/my-account'\"\n      spacing=\"MEDIUM\"\n    ></ax-account-button>\n\n    <ax-account-button\n      *ngIf=\"settings\"\n      icon=\"cog-outline\"\n      [title]=\"'label.settings' | translate\"\n      [url]=\"'/account/settings'\"\n    ></ax-account-button>\n\n    <ax-account-button\n      *ngIf=\"contacts\"\n      icon=\"account-group-outline\"\n      [title]=\"'label.contacts' | translate\"\n      [url]=\"'/account/contacts'\"\n    ></ax-account-button>\n\n    <ax-account-button\n      *ngIf=\"billing\"\n      icon=\"receipt-text-outline\"\n      [title]=\"'settings.payment.title' | translate\"\n      [url]=\"'/account/billing'\"\n    ></ax-account-button>\n\n    <ng-content></ng-content>\n\n    <ax-account-button\n      icon=\"xml\"\n      [title]=\"'settings.account.organisation.developer.title' | translate\"\n      [url]=\"'/account/developer'\"\n      spacing=\"MEDIUM\"\n    ></ax-account-button>\n\n    <ax-account-button\n      icon=\"gavel\"\n      [title]=\"'label.policies' | translate\"\n      [url]=\"backendUrl.value + '/policy'\"\n      target=\"_blank\"\n    ></ax-account-button>\n\n    <ax-account-button\n      icon=\"help-circle-outline\"\n      [title]=\"'label.feedback' | translate\"\n      (click)=\"openFeedbackModal()\"\n    ></ax-account-button>\n\n    <ax-account-button\n      icon=\"logout\"\n      outline\n      color=\"grey\"\n      [title]=\"'label.logout' | translate\"\n      (click)=\"logout.emit()\"\n    ></ax-account-button>\n  </div>\n</div>\n", styles: [":host{display:block;max-width:var(--container-max-width);width:100%;margin:0 auto;padding:1rem}.content,.body{display:flex;flex-direction:column;gap:.75rem}.tier-button{margin-top:1rem}\n"] }]
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [ACCOUNT_BILLING]
                }] }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [ACCOUNT_CONTACTS]
                }] }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [ACCOUNT_SETTINGS]
                }] }, { type: i7.BehaviorSubject, decorators: [{
                    type: Inject,
                    args: [BACKEND_URL]
                }] }, { type: i0.ElementRef }, { type: i1.OverlayService }, { type: i2.ProfileService }], propDecorators: { logout: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 