import { NgTemplateOutlet } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import * as i0 from '@angular/core';
import { inject, input, computed, signal, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { elementDocument } from '@siemens/element-icons';
import { SiCollapsiblePanelComponent } from '@siemens/element-ng/accordion';
import { SiCopyrightNoticeComponent } from '@siemens/element-ng/copyright-notice';
import { addIcons, SiIconComponent } from '@siemens/element-ng/icon';
import { SiLinkDirective } from '@siemens/element-ng/link';
import { SiTranslatePipe } from '@siemens/element-translate-ng/translate';

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
class SiAboutComponent {
    http = inject(HttpClient);
    sanitizer = inject(DomSanitizer);
    /**
     * Title shown above the about information.
     */
    aboutTitle = input.required(...(ngDevMode ? [{ debugName: "aboutTitle" }] : []));
    /**
     * Define mode to display the licenses. See {@link LicenseInfo}
     */
    licenseInfo = input.required(...(ngDevMode ? [{ debugName: "licenseInfo" }] : []));
    /**
     * Path to the application logo. Use for image
     */
    icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : []));
    /**
     * Name of element icon. Use as alternative to image
     */
    iconName = input(...(ngDevMode ? [undefined, { debugName: "iconName" }] : []));
    /**
     * Title of this application.
     */
    appName = input.required(...(ngDevMode ? [{ debugName: "appName" }] : []));
    /**
     * Sub titles of the application. Shown as a list below the application name. (Optional)
     */
    subheading = input(...(ngDevMode ? [undefined, { debugName: "subheading" }] : []));
    /**
     * Link to `Acceptable Use Policy`.
     */
    acceptableUsePolicyLink = input(...(ngDevMode ? [undefined, { debugName: "acceptableUsePolicyLink" }] : []));
    /**
     * Link to `Corporate Information`.
     */
    imprintLink = input(...(ngDevMode ? [undefined, { debugName: "imprintLink" }] : []));
    /**
     * Link to `Privacy Notice`.
     */
    privacyLink = input(...(ngDevMode ? [undefined, { debugName: "privacyLink" }] : []));
    /**
     * Link to `Cookie Notice`.
     */
    cookieNoticeLink = input(...(ngDevMode ? [undefined, { debugName: "cookieNoticeLink" }] : []));
    /**
     * Link to `Terms of Use`.
     */
    termsLink = input(...(ngDevMode ? [undefined, { debugName: "termsLink" }] : []));
    /**
     * Additional links listed in the about section.
     *
     * @defaultValue []
     */
    links = input([], ...(ngDevMode ? [{ debugName: "links" }] : []));
    /**
     * Copyright information to be displayed. Alternatively, you can use the {@link SI_COPYRIGHT_DETAILS} global inject.
     */
    copyrightDetails = input(...(ngDevMode ? [undefined, { debugName: "copyrightDetails" }] : []));
    sanitizedUrl = computed(() => {
        const licenseInfo = this.licenseInfo();
        return licenseInfo.iframe != null
            ? this.sanitizer.bypassSecurityTrustResourceUrl(licenseInfo.iframe)
            : undefined;
    }, ...(ngDevMode ? [{ debugName: "sanitizedUrl" }] : []));
    licenseApi = signal([], ...(ngDevMode ? [{ debugName: "licenseApi" }] : []));
    icons = addIcons({ elementDocument });
    ngOnInit() {
        const licenseInfo = this.licenseInfo();
        if (licenseInfo.api) {
            this.http.get(licenseInfo.api, { responseType: 'json' }).subscribe(data => {
                this.licenseApi.set(data);
                if (this.licenseApi().length === 1) {
                    data[0].isOpen = false;
                    this.licenseApi.set([...data]);
                    this.toggleLoadLicenseApi(this.licenseApi()[0]);
                }
            });
        }
    }
    toggleLoadLicenseApi(apiInfo) {
        const licenseApi = this.licenseApi();
        if (!apiInfo.isOpen && !apiInfo.files) {
            this.http.get(apiInfo.href, { responseType: 'json' }).subscribe(files => {
                apiInfo.files = files;
                this.licenseApi.set([...licenseApi]);
            });
        }
        apiInfo.isOpen = !apiInfo.isOpen;
        this.licenseApi.set([...licenseApi]);
    }
    toggleLoadLicenseContent(apiInfo) {
        const licenseApi = this.licenseApi();
        apiInfo.isOpen = !apiInfo.isOpen;
        if (!apiInfo.content) {
            this.http.get(apiInfo.href, { responseType: 'text' }).subscribe((content) => {
                apiInfo.content = content;
                this.licenseApi.set([...licenseApi]);
            });
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiAboutComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.8", type: SiAboutComponent, isStandalone: true, selector: "si-about", inputs: { aboutTitle: { classPropertyName: "aboutTitle", publicName: "aboutTitle", isSignal: true, isRequired: true, transformFunction: null }, licenseInfo: { classPropertyName: "licenseInfo", publicName: "licenseInfo", isSignal: true, isRequired: true, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, iconName: { classPropertyName: "iconName", publicName: "iconName", isSignal: true, isRequired: false, transformFunction: null }, appName: { classPropertyName: "appName", publicName: "appName", isSignal: true, isRequired: true, transformFunction: null }, subheading: { classPropertyName: "subheading", publicName: "subheading", isSignal: true, isRequired: false, transformFunction: null }, acceptableUsePolicyLink: { classPropertyName: "acceptableUsePolicyLink", publicName: "acceptableUsePolicyLink", isSignal: true, isRequired: false, transformFunction: null }, imprintLink: { classPropertyName: "imprintLink", publicName: "imprintLink", isSignal: true, isRequired: false, transformFunction: null }, privacyLink: { classPropertyName: "privacyLink", publicName: "privacyLink", isSignal: true, isRequired: false, transformFunction: null }, cookieNoticeLink: { classPropertyName: "cookieNoticeLink", publicName: "cookieNoticeLink", isSignal: true, isRequired: false, transformFunction: null }, termsLink: { classPropertyName: "termsLink", publicName: "termsLink", isSignal: true, isRequired: false, transformFunction: null }, links: { classPropertyName: "links", publicName: "links", isSignal: true, isRequired: false, transformFunction: null }, copyrightDetails: { classPropertyName: "copyrightDetails", publicName: "copyrightDetails", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"row mx-6 mt-6\">\n  <div class=\"col-md-6 mb-6\">\n    <div class=\"card overflow-hidden\">\n      <div class=\"card-header text-truncate\">\n        {{ aboutTitle() }}\n      </div>\n\n      <div>\n        <div class=\"list-group-item text-center\">\n          @let appIcon = iconName();\n          @if (icon()) {\n            <img\n              class=\"rounded-circle\"\n              height=\"150\"\n              [src]=\"icon()\"\n              [alt]=\"appName() + '\\'s Logo'\"\n            />\n          } @else if (appIcon) {\n            <si-icon class=\"app-icon\" [icon]=\"appIcon\" />\n          }\n          <h3>{{ appName() }}</h3>\n          @for (item of subheading(); track $index) {\n            <p>{{ item }}</p>\n          }\n          <si-copyright-notice [copyright]=\"copyrightDetails()\" />\n        </div>\n\n        @if (imprintLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: imprintLink() }\"\n          />\n        }\n        @if (privacyLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: privacyLink() }\"\n          />\n        }\n        @if (cookieNoticeLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: cookieNoticeLink() }\"\n          />\n        }\n        @if (termsLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: termsLink() }\"\n          />\n        }\n        @if (acceptableUsePolicyLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: acceptableUsePolicyLink() }\"\n          />\n        }\n        @for (item of links(); track $index) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: item }\"\n          />\n        }\n      </div>\n    </div>\n  </div>\n\n  <div class=\"col-md-6 mb-6\">\n    <div class=\"card overflow-hidden\" [class.h-100]=\"licenseInfo().iframe\">\n      <div class=\"card-header text-truncate\">\n        {{ licenseInfo().title }}\n      </div>\n\n      <div class=\"h-100\">\n        @if (licenseInfo().text) {\n          <pre class=\"list-group-item\">{{ licenseInfo().text }}</pre>\n        }\n\n        @if (sanitizedUrl()) {\n          <iframe class=\"w-100 h-100\" [src]=\"sanitizedUrl()\" [title]=\"licenseInfo().title\"></iframe>\n        }\n\n        @if (licenseInfo().api) {\n          @for (api of licenseApi(); track $index) {\n            <si-collapsible-panel\n              colorVariant=\"base-0\"\n              class=\"license-api\"\n              [heading]=\"api.name\"\n              (panelToggle)=\"toggleLoadLicenseApi(api)\"\n            >\n              @for (file of api.files; track $index) {\n                <si-collapsible-panel\n                  colorVariant=\"base-0\"\n                  class=\"license-api-file\"\n                  [icon]=\"licenseInfo().icon ? licenseInfo().icon : icons.elementDocument\"\n                  [heading]=\"file.name\"\n                  (panelToggle)=\"toggleLoadLicenseContent(file)\"\n                >\n                  <pre class=\"license-api-file-content px-6 pt-6\">{{ file.content }}</pre>\n                </si-collapsible-panel>\n              }\n            </si-collapsible-panel>\n          }\n        }\n      </div>\n    </div>\n  </div>\n</div>\n\n<ng-template #linkTemplate let-link=\"link\">\n  <a\n    class=\"list-group-item si-h5 text-body focus-inside\"\n    siLinkDefaultTarget=\"_blank\"\n    [siLink]=\"link\"\n  >\n    {{ link.title | translate }}\n  </a>\n</ng-template>\n", styles: [".list-group-item{border-width:0 0 1px;padding-inline:16px}.list-group-item.with-border:first-child{border-block-start-width:1px}.list-group-item:last-child{border-block-end-width:0}.app-icon{font-size:150px}iframe{border-style:none;min-block-size:500px;margin-block-end:-5px}pre{word-break:break-word;white-space:pre-wrap}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: SiCollapsiblePanelComponent, selector: "si-collapsible-panel", inputs: ["heading", "headerCssClasses", "contentBgClasses", "contentCssClasses", "opened", "icon", "disabled", "colorVariant", "badge", "badgeColor"], outputs: ["openedChange", "panelToggle"] }, { kind: "component", type: SiCopyrightNoticeComponent, selector: "si-copyright-notice", inputs: ["copyright"] }, { kind: "component", type: SiIconComponent, selector: "si-icon", inputs: ["icon"] }, { kind: "directive", type: SiLinkDirective, selector: "[siLink]", inputs: ["siLink", "siLinkDefaultTarget", "actionParam", "activeClass", "exactMatch", "ariaCurrent"], outputs: ["activeChange"], exportAs: ["siLink"] }, { kind: "pipe", type: SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiAboutComponent, decorators: [{
            type: Component,
            args: [{ selector: 'si-about', imports: [
                        NgTemplateOutlet,
                        SiCollapsiblePanelComponent,
                        SiCopyrightNoticeComponent,
                        SiIconComponent,
                        SiLinkDirective,
                        SiTranslatePipe
                    ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"row mx-6 mt-6\">\n  <div class=\"col-md-6 mb-6\">\n    <div class=\"card overflow-hidden\">\n      <div class=\"card-header text-truncate\">\n        {{ aboutTitle() }}\n      </div>\n\n      <div>\n        <div class=\"list-group-item text-center\">\n          @let appIcon = iconName();\n          @if (icon()) {\n            <img\n              class=\"rounded-circle\"\n              height=\"150\"\n              [src]=\"icon()\"\n              [alt]=\"appName() + '\\'s Logo'\"\n            />\n          } @else if (appIcon) {\n            <si-icon class=\"app-icon\" [icon]=\"appIcon\" />\n          }\n          <h3>{{ appName() }}</h3>\n          @for (item of subheading(); track $index) {\n            <p>{{ item }}</p>\n          }\n          <si-copyright-notice [copyright]=\"copyrightDetails()\" />\n        </div>\n\n        @if (imprintLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: imprintLink() }\"\n          />\n        }\n        @if (privacyLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: privacyLink() }\"\n          />\n        }\n        @if (cookieNoticeLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: cookieNoticeLink() }\"\n          />\n        }\n        @if (termsLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: termsLink() }\"\n          />\n        }\n        @if (acceptableUsePolicyLink()) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: acceptableUsePolicyLink() }\"\n          />\n        }\n        @for (item of links(); track $index) {\n          <ng-container\n            [ngTemplateOutlet]=\"linkTemplate\"\n            [ngTemplateOutletContext]=\"{ link: item }\"\n          />\n        }\n      </div>\n    </div>\n  </div>\n\n  <div class=\"col-md-6 mb-6\">\n    <div class=\"card overflow-hidden\" [class.h-100]=\"licenseInfo().iframe\">\n      <div class=\"card-header text-truncate\">\n        {{ licenseInfo().title }}\n      </div>\n\n      <div class=\"h-100\">\n        @if (licenseInfo().text) {\n          <pre class=\"list-group-item\">{{ licenseInfo().text }}</pre>\n        }\n\n        @if (sanitizedUrl()) {\n          <iframe class=\"w-100 h-100\" [src]=\"sanitizedUrl()\" [title]=\"licenseInfo().title\"></iframe>\n        }\n\n        @if (licenseInfo().api) {\n          @for (api of licenseApi(); track $index) {\n            <si-collapsible-panel\n              colorVariant=\"base-0\"\n              class=\"license-api\"\n              [heading]=\"api.name\"\n              (panelToggle)=\"toggleLoadLicenseApi(api)\"\n            >\n              @for (file of api.files; track $index) {\n                <si-collapsible-panel\n                  colorVariant=\"base-0\"\n                  class=\"license-api-file\"\n                  [icon]=\"licenseInfo().icon ? licenseInfo().icon : icons.elementDocument\"\n                  [heading]=\"file.name\"\n                  (panelToggle)=\"toggleLoadLicenseContent(file)\"\n                >\n                  <pre class=\"license-api-file-content px-6 pt-6\">{{ file.content }}</pre>\n                </si-collapsible-panel>\n              }\n            </si-collapsible-panel>\n          }\n        }\n      </div>\n    </div>\n  </div>\n</div>\n\n<ng-template #linkTemplate let-link=\"link\">\n  <a\n    class=\"list-group-item si-h5 text-body focus-inside\"\n    siLinkDefaultTarget=\"_blank\"\n    [siLink]=\"link\"\n  >\n    {{ link.title | translate }}\n  </a>\n</ng-template>\n", styles: [".list-group-item{border-width:0 0 1px;padding-inline:16px}.list-group-item.with-border:first-child{border-block-start-width:1px}.list-group-item:last-child{border-block-end-width:0}.app-icon{font-size:150px}iframe{border-style:none;min-block-size:500px;margin-block-end:-5px}pre{word-break:break-word;white-space:pre-wrap}\n"] }]
        }], propDecorators: { aboutTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "aboutTitle", required: true }] }], licenseInfo: [{ type: i0.Input, args: [{ isSignal: true, alias: "licenseInfo", required: true }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], iconName: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconName", required: false }] }], appName: [{ type: i0.Input, args: [{ isSignal: true, alias: "appName", required: true }] }], subheading: [{ type: i0.Input, args: [{ isSignal: true, alias: "subheading", required: false }] }], acceptableUsePolicyLink: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptableUsePolicyLink", required: false }] }], imprintLink: [{ type: i0.Input, args: [{ isSignal: true, alias: "imprintLink", required: false }] }], privacyLink: [{ type: i0.Input, args: [{ isSignal: true, alias: "privacyLink", required: false }] }], cookieNoticeLink: [{ type: i0.Input, args: [{ isSignal: true, alias: "cookieNoticeLink", required: false }] }], termsLink: [{ type: i0.Input, args: [{ isSignal: true, alias: "termsLink", required: false }] }], links: [{ type: i0.Input, args: [{ isSignal: true, alias: "links", required: false }] }], copyrightDetails: [{ type: i0.Input, args: [{ isSignal: true, alias: "copyrightDetails", required: false }] }] } });

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
class SiAboutModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiAboutModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.8", ngImport: i0, type: SiAboutModule, imports: [SiAboutComponent], exports: [SiAboutComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiAboutModule, imports: [SiAboutComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiAboutModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [SiAboutComponent],
                    exports: [SiAboutComponent]
                }]
        }] });

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

/**
 * Generated bundle index. Do not edit.
 */

export { SiAboutComponent, SiAboutModule };
//# sourceMappingURL=siemens-element-ng-about.mjs.map
