import { Component, Input } from '@angular/core';
import { FetchClient } from '@c8y/client';
import { gettext } from '@c8y/ngx-components';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/client";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "@angular/common";
export class LicenseViewComponent {
    constructor(fetchClient) {
        this.fetchClient = fetchClient;
        this.content = gettext('Loading license content…');
        this.FALL_BACK_URL = 'https://spdx.org/licenses/';
    }
    async ngOnInit() {
        const response = await this.fetchClient.fetch(this.url);
        if (response.status === 200) {
            this.content = await response.text();
            return;
        }
        this.content = '';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: LicenseViewComponent, deps: [{ token: i1.FetchClient }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: LicenseViewComponent, selector: "c8y-license-view", inputs: { url: "url", name: "name" }, ngImport: i0, template: "<ng-container *ngIf=\"content\">\n  <a [href]=\"url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"small pull-right\">\n    <i c8yIcon=\"external-link\" class=\"m-r-4\"></i>\n    <span translate>Open in new window</span>\n  </a>\n  <textarea\n    [attr.aria-label]=\"'License' | translate\"\n    class=\"form-control bg-level-1 text-monospace small m-b-16\"\n    readonly\n    style=\"height: 170px\"\n    [textContent]=\"content\"\n  ></textarea>\n</ng-container>\n\n<div class=\"alert alert-warning\" role=\"alert\" *ngIf=\"!content && name\">\n  <strong translate>No license attached</strong>\n  <p translate>\n    The author of the package hasn't included a license file in a format that can be displayed.\n    Verify the license online, for example, with a website like:\n  </p>\n  <a [href]=\"FALL_BACK_URL + name\" target=\"_blank\" rel=\"noopener noreferrer\">\n    {{ FALL_BACK_URL }}{{ name }}\n  </a>\n</div>\n\n<div class=\"alert alert-danger\" role=\"alert\" *ngIf=\"!content && !name\">\n  <strong translate>No license found</strong>\n  <p translate>\n    There is no license attached to this package. You can continue installing it at your own risk.\n  </p>\n</div>\n", dependencies: [{ kind: "directive", type: i2.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i2.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: LicenseViewComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-license-view', template: "<ng-container *ngIf=\"content\">\n  <a [href]=\"url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"small pull-right\">\n    <i c8yIcon=\"external-link\" class=\"m-r-4\"></i>\n    <span translate>Open in new window</span>\n  </a>\n  <textarea\n    [attr.aria-label]=\"'License' | translate\"\n    class=\"form-control bg-level-1 text-monospace small m-b-16\"\n    readonly\n    style=\"height: 170px\"\n    [textContent]=\"content\"\n  ></textarea>\n</ng-container>\n\n<div class=\"alert alert-warning\" role=\"alert\" *ngIf=\"!content && name\">\n  <strong translate>No license attached</strong>\n  <p translate>\n    The author of the package hasn't included a license file in a format that can be displayed.\n    Verify the license online, for example, with a website like:\n  </p>\n  <a [href]=\"FALL_BACK_URL + name\" target=\"_blank\" rel=\"noopener noreferrer\">\n    {{ FALL_BACK_URL }}{{ name }}\n  </a>\n</div>\n\n<div class=\"alert alert-danger\" role=\"alert\" *ngIf=\"!content && !name\">\n  <strong translate>No license found</strong>\n  <p translate>\n    There is no license attached to this package. You can continue installing it at your own risk.\n  </p>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.FetchClient }], propDecorators: { url: [{
                type: Input
            }], name: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGljZW5zZS12aWV3LmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2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