/**
 * @packageDocumentation
 * @module help-menu
 */
import { DialogService, DialogSize } from '@alauda/ui';
import { ChangeDetectionStrategy, Component, Input, } from '@angular/core';
import { forkJoin } from 'rxjs';
import { finalize } from 'rxjs/operators';
import { K8sApiService } from '../../api/public-api';
import { K8sUtilService, PUBLIC_NAMESPACE } from '../../utils/public-api';
const CONFIG = {
    type: 'configmaps',
    apiVersion: 'v1',
};
export class HelpMenuComponent {
    constructor(dialogService, k8sApi, k8sUtil) {
        this.dialogService = dialogService;
        this.k8sApi = k8sApi;
        this.k8sUtil = k8sUtil;
        this.loading = false;
    }
    openDocLink() {
        window.open(this.docLink);
    }
    openHealthCheckLink() {
        window.open('/console-platform/health-check', '_blank', 'noopener=yes,noreferrer=yes');
    }
    viewPlatformInfo(templateRef) {
        this.componentVersionList = [];
        this.loading = true;
        forkJoin([
            this.k8sApi.getGlobalResourceList({
                definition: CONFIG,
                namespace: PUBLIC_NAMESPACE,
                queryParams: {
                    labelSelector: this.k8sUtil.normalizeType('component-version'),
                },
            }),
            this.k8sApi.getGlobalResource({
                definition: CONFIG,
                name: 'platform',
                namespace: PUBLIC_NAMESPACE,
            }),
            this.k8sApi.getGlobalResource({
                definition: CONFIG,
                name: 'platform-info',
                namespaced: true,
            }),
        ])
            .pipe(finalize(() => (this.loading = false)))
            .subscribe(([cms, config, platformInfo]) => {
            for (const cm of cms.items) {
                try {
                    const components = JSON.parse(cm.data.component);
                    this.componentVersionList = [
                        ...this.componentVersionList,
                        ...components,
                    ];
                }
                catch (_a) { }
            }
            this.componentVersionList.sort((a, b) => a.index - b.index);
            this.platformVersion = config.data.version;
            this.platformName = platformInfo.data.platformName;
            this.platformTip = {
                zh: platformInfo.data.portalSubTitleZH,
                en: platformInfo.data.portalSubTitleEN,
            };
        });
        this.dialogRef = this.dialogService.open(templateRef, {
            size: DialogSize.Big,
            fitViewport: true,
        });
    }
    close() {
        var _a;
        (_a = this.dialogRef) === null || _a === void 0 ? void 0 : _a.close();
    }
}
HelpMenuComponent.decorators = [
    { type: Component, args: [{
                selector: 'acl-help-menu',
                template: "<div class=\"menu\" [auiDropdown]=\"menu\">\n  <aui-icon icon=\"basic:question\" class=\"menu__icon\"></aui-icon>\n  <aui-icon class=\"menu__pointer\" icon=\"angle_down\"></aui-icon>\n</div>\n\n<aui-menu #menu>\n  <aui-menu-item *ngIf=\"docLink\" (click)=\"openDocLink()\">\n    <aui-icon icon=\"basic:help_doc\"></aui-icon>\n    <span>{{ 'help_doc' | translate }}</span>\n  </aui-menu-item>\n\n  <aui-menu-item [divide]=\"true\" (click)=\"viewPlatformInfo(platformInfo)\">\n    <aui-icon icon=\"basic:info\"></aui-icon>\n    <span>{{ 'about_platform' | translate }}</span>\n  </aui-menu-item>\n\n  <aui-menu-item\n    *aclFeatureGate=\"'module-health'\"\n    [divide]=\"true\"\n    (click)=\"openHealthCheckLink()\"\n  >\n    <aui-icon icon=\"basic:health_examination\"></aui-icon>\n    <span>{{ 'platform_health_check' | translate }}</span>\n  </aui-menu-item>\n  <ng-content></ng-content>\n</aui-menu>\n\n<ng-template #platformInfo>\n  <aui-dialog-content class=\"paltform-about-dialog\">\n    <div class=\"platform__version\">\n      <div class=\"platform__version-title\">\n        <img src=\"api/v1/cm/ui-logos/logo\" />\n        <span class=\"line\"></span>\n        <div class=\"platform__version-title__name-version\">\n          <span class=\"platform__version-title__name\">{{\n            platformName || 'ACP+'\n          }}</span>\n          <span>{{ platformVersion }}</span>\n        </div>\n      </div>\n      <div class=\"platform__version-desc\">\n        {{ platformTip | translate }}\n      </div>\n    </div>\n    <div class=\"platform__component-info\">\n      <div class=\"label\">\n        {{ 'platform_related_open_source_component_info' | translate }}\n      </div>\n      <ng-container *ngIf=\"!loading; else loadingTmp\">\n        <div\n          class=\"component-container\"\n          *ngIf=\"componentVersionList?.length; else noComponent\"\n        >\n          <div\n            class=\"component-item\"\n            *ngFor=\"let componentVersion of componentVersionList\"\n          >\n            <img [src]=\"'icons/' + componentVersion.name + '.svg'\" />\n            <div class=\"component-item-info\">\n              <div class=\"component-item-info__name\">\n                {{ componentVersion.name }}\n              </div>\n              <div class=\"component-item-info__version\">\n                {{ componentVersion.version }}\n              </div>\n            </div>\n          </div>\n        </div>\n      </ng-container>\n    </div>\n    <div class=\"platform__action\">\n      <button aui-button (click)=\"close()\">{{ 'close' | translate }}</button>\n    </div>\n  </aui-dialog-content>\n</ng-template>\n\n<ng-template #noComponent>\n  <div class=\"no-component\">{{ 'no_open_source_components' | translate }}</div>\n</ng-template>\n\n<ng-template #loadingTmp>\n  <div class=\"loading\">\n    <acl-loading-mask [loading]=\"loading\"></acl-loading-mask>\n  </div>\n</ng-template>\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".menu{display:flex;align-items:center;padding:0 8px;height:28px;border-radius:2px;color:var(--aui-color-text-help);cursor:pointer}.menu:hover{color:var(--aui-color-white);background-color:rgba(var(--aui-color-white),.16)}.menu__icon{font-size:16px}.menu__pointer{font-size:12px;margin-left:-2px}.platform__version{font-size:18px;color:#fff;padding:32px 24px;background-image:url(\"data:image/svg+xml,%3Csvg xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22 width%3D%22800%22 height%3D%22140%22 viewBox%3D%220 0 800 140%22%3E%3Cdefs%3E%3ClinearGradient id%3D%22b%22 x1%3D%22100%25%22 x2%3D%222.734%25%22 y1%3D%2250.918%25%22 y2%3D%2250.116%25%22%3E%3Cstop offset%3D%220%25%22 stop-color%3D%22%2384B3FF%22%2F%3E%3Cstop offset%3D%22100%25%22 stop-color%3D%22%234D7CFE%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient id%3D%22d%22 x1%3D%2250%25%22 x2%3D%2250%25%22 y1%3D%220%25%22 y2%3D%2283.267%25%22%3E%3Cstop offset%3D%220%25%22 stop-color%3D%22%23FFF%22 stop-opacity%3D%220%22%2F%3E%3Cstop offset%3D%22100%25%22 stop-color%3D%22%2368FFFF%22 stop-opacity%3D%22.16%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient id%3D%22e%22 x1%3D%2250%25%22 x2%3D%2250%25%22 y1%3D%220%25%22 y2%3D%2291.263%25%22%3E%3Cstop offset%3D%220%25%22 stop-color%3D%22%23FFF%22 stop-opacity%3D%220%22%2F%3E%3Cstop offset%3D%22100%25%22 stop-color%3D%22%2368FFFF%22 stop-opacity%3D%22.16%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient id%3D%22f%22 x1%3D%2259.921%25%22 x2%3D%2259.921%25%22 y1%3D%220%25%22 y2%3D%2258.499%25%22%3E%3Cstop offset%3D%220%25%22 stop-color%3D%22%23FFF%22 stop-opacity%3D%220%22%2F%3E%3Cstop offset%3D%22100%25%22 stop-color%3D%22%2368FFFF%22 stop-opacity%3D%22.16%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient id%3D%22g%22 x1%3D%2250%25%22 x2%3D%2250%25%22 y1%3D%220%25%22 y2%3D%2283.267%25%22%3E%3Cstop offset%3D%220%25%22 stop-color%3D%22%23FFF%22 stop-opacity%3D%220%22%2F%3E%3Cstop offset%3D%22100%25%22 stop-color%3D%22%2368FFFF%22 stop-opacity%3D%22.16%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient id%3D%22h%22 x1%3D%2250%25%22 x2%3D%2270.076%25%22 y1%3D%2257.875%25%22 y2%3D%22-30.443%25%22%3E%3Cstop offset%3D%220%25%22 stop-color%3D%22%23FFF%22 stop-opacity%3D%220%22%2F%3E%3Cstop offset%3D%22100%25%22 stop-color%3D%22%2368FFFF%22 stop-opacity%3D%22.16%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient id%3D%22i%22 x1%3D%2250%25%22 x2%3D%2254.322%25%22 y1%3D%2257.875%25%22 y2%3D%22-25.456%25%22%3E%3Cstop offset%3D%220%25%22 stop-color%3D%22%23FFF%22 stop-opacity%3D%220%22%2F%3E%3Cstop offset%3D%22100%25%22 stop-color%3D%22%2368FFFF%22 stop-opacity%3D%22.16%22%2F%3E%3C%2FlinearGradient%3E%3Cpath id%3D%22a%22 d%3D%22M0 0h800v140H0z%22%2F%3E%3C%2Fdefs%3E%3Cg fill%3D%22none%22%3E%3Cmask id%3D%22c%22 fill%3D%22%23fff%22%3E%3Cuse xlink%3Ahref%3D%22%23a%22%2F%3E%3C%2Fmask%3E%3Cuse fill%3D%22url(%23b)%22 xlink%3Ahref%3D%22%23a%22%2F%3E%3Cg mask%3D%22url(%23c)%22%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M730.479 18.37l56.483 28.117-54.227 27.099.111.055-56.483 28.227-56.484-28.227 54.331-27.047-.215-.107L730.48 18.37z%22 opacity%3D%22.6%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23e)%22 opacity%3D%22.6%22 d%3D%22M676.688 108.779l-.333-35.3-56.476 8.544v54.914z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23f)%22 opacity%3D%22.6%22 d%3D%22M676.174 105.728l-.322-59.804 110.772 55.332.338 59.896z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M395.477 31.73l56.483 28.117-54.227 27.098.111.056-56.483 28.227L284.877 87l54.331-27.048-.215-.106 56.484-28.118zm517.123 0l56.483 28.117-54.227 27.098.111.056-56.483 28.227L802 87l54.331-27.048-.215-.106L912.6 31.73z%22 opacity%3D%22.4%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M110.6 98.528l56.483 28.118-54.227 27.098.111.056-56.483 28.226L0 153.8l54.331-27.048-.215-.106L110.6 98.528z%22 opacity%3D%22.6%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23g)%22 opacity%3D%22.6%22 d%3D%22M575.184 57.614l31.329 15.895-31.329 15.834-31.328-15.834z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23h)%22 opacity%3D%22.6%22 d%3D%22M543.021 107.538l31.746 16.04V89.456l-31.746-15.977z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23i)%22 opacity%3D%22.6%22 d%3D%22M606.513 107.547l-31.746 16.031V89.447l31.746-15.968z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath stroke%3D%22%2360ACFF%22 stroke-width%3D%22.8%22 opacity%3D%22.3%22 d%3D%22M445.694 80.158l31.329-15.895-31.329-15.834-31.328 15.834zM600.989 0l56.483 28.118-54.227 27.098.111.056-56.483 28.226-56.484-28.226 54.331-27.048-.215-.106L600.99 0zM341.174 133.597l56.484 28.118-54.227 27.098.11.056-56.483 28.227-56.483-28.227 54.33-27.048-.214-.106 56.483-28.118z%22%2F%3E%3C%2Fg%3E%3Cg mask%3D%22url(%23c)%22%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M730.479 18.37l56.483 28.117-54.227 27.099.111.055-56.483 28.227-56.484-28.227 54.331-27.047-.215-.107L730.48 18.37z%22 opacity%3D%22.6%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23e)%22 opacity%3D%22.6%22 d%3D%22M676.688 108.779l-.333-35.3-56.476 8.544v54.914z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23f)%22 opacity%3D%22.6%22 d%3D%22M676.174 105.728l-.322-59.804 110.772 55.332.338 59.896z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M395.477 31.73l56.483 28.117-54.227 27.098.111.056-56.483 28.227L284.877 87l54.331-27.048-.215-.106 56.484-28.118zm517.123 0l56.483 28.117-54.227 27.098.111.056-56.483 28.227L802 87l54.331-27.048-.215-.106L912.6 31.73z%22 opacity%3D%22.4%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M110.6 98.528l56.483 28.118-54.227 27.098.111.056-56.483 28.226L0 153.8l54.331-27.048-.215-.106L110.6 98.528z%22 opacity%3D%22.6%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23g)%22 opacity%3D%22.6%22 d%3D%22M575.184 57.614l31.329 15.895-31.329 15.834-31.328-15.834z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23h)%22 opacity%3D%22.6%22 d%3D%22M543.021 107.538l31.746 16.04V89.456l-31.746-15.977z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23i)%22 opacity%3D%22.6%22 d%3D%22M606.513 107.547l-31.746 16.031V89.447l31.746-15.968z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath stroke%3D%22%2360ACFF%22 stroke-width%3D%22.8%22 opacity%3D%22.3%22 d%3D%22M445.694 80.158l31.329-15.895-31.329-15.834-31.328 15.834zM600.989 0l56.483 28.118-54.227 27.098.111.056-56.483 28.226-56.484-28.226 54.331-27.048-.215-.106L600.99 0zM341.174 133.597l56.484 28.118-54.227 27.098.11.056-56.483 28.227-56.483-28.227 54.33-27.048-.214-.106 56.483-28.118z%22%2F%3E%3C%2Fg%3E%3Cg mask%3D%22url(%23c)%22%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M730.479 18.37l56.483 28.117-54.227 27.099.111.055-56.483 28.227-56.484-28.227 54.331-27.047-.215-.107L730.48 18.37z%22 opacity%3D%22.6%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23e)%22 opacity%3D%22.6%22 d%3D%22M676.688 108.779l-.333-35.3-56.476 8.544v54.914z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23f)%22 opacity%3D%22.6%22 d%3D%22M676.174 105.728l-.322-59.804 110.772 55.332.338 59.896z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M395.477 31.73l56.483 28.117-54.227 27.098.111.056-56.483 28.227L284.877 87l54.331-27.048-.215-.106 56.484-28.118zm517.123 0l56.483 28.117-54.227 27.098.111.056-56.483 28.227L802 87l54.331-27.048-.215-.106L912.6 31.73z%22 opacity%3D%22.4%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23d)%22 d%3D%22M110.6 98.528l56.483 28.118-54.227 27.098.111.056-56.483 28.226L0 153.8l54.331-27.048-.215-.106L110.6 98.528z%22 opacity%3D%22.6%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23g)%22 opacity%3D%22.6%22 d%3D%22M575.184 57.614l31.329 15.895-31.329 15.834-31.328-15.834z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23h)%22 opacity%3D%22.6%22 d%3D%22M543.021 107.538l31.746 16.04V89.456l-31.746-15.977z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath fill%3D%22url(%23i)%22 opacity%3D%22.6%22 d%3D%22M606.513 107.547l-31.746 16.031V89.447l31.746-15.968z%22 transform%3D%22translate(-129.49)%22%2F%3E%3Cpath stroke%3D%22%2360ACFF%22 stroke-width%3D%22.8%22 opacity%3D%22.3%22 d%3D%22M445.694 80.158l31.329-15.895-31.329-15.834-31.328 15.834zM600.989 0l56.483 28.118-54.227 27.098.111.056-56.483 28.226-56.484-28.226 54.331-27.048-.215-.106L600.99 0zM341.174 133.597l56.484 28.118-54.227 27.098.11.056-56.483 28.227-56.483-28.227 54.33-27.048-.214-.106 56.483-28.118z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E\")}.platform__version-title{display:flex;align-items:center;margin-bottom:24px}.platform__version-title__name{margin-right:8px;font-size:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.platform__version-title__name-version{display:flex;flex-wrap:wrap;flex:1;overflow:hidden;align-items:baseline}.platform__version-title img{height:36px;max-width:240px}.platform__version-title .line{height:36px;width:1px;opacity:.66;background-color:#fff;margin:0 12px}.platform__component-info{color:#999;padding:20px 24px 0}.platform__component-info .label{font-size:14px;margin-bottom:12px}.platform__component-info .component-container{display:grid;grid-template-columns:repeat(3,1fr);grid-gap:12px;max-height:300px;overflow-y:auto}.platform__component-info .component-item{display:flex;align-items:center;padding:12px;height:66px;border-radius:2px;background-color:#f8f8f8}.platform__component-info .component-item img{width:36px;height:36px}.platform__component-info .component-item-info{margin-left:12px;color:#333}.platform__component-info .component-item-info__name{font-size:18px;font-weight:500}.platform__component-info .component-item-info__version{font-size:14px}.platform__action{padding:20px 24px 24px;display:flex;justify-content:flex-end}.no-component{height:60px;border:dashed 1px #ccc;background-color:#fff;display:flex;align-items:center;justify-content:center}.loading{height:300px;display:flex;justify-content:center;align-items:center}\n"]
            },] }
];
HelpMenuComponent.ctorParameters = () => [
    { type: DialogService },
    { type: K8sApiService },
    { type: K8sUtilService }
];
HelpMenuComponent.propDecorators = {
    docLink: [{ type: Input }]
};
//# sourceMappingURL=data:application/json;base64, 