import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ContextRouteService, gettext, PluginsService } from '@c8y/ngx-components';
import * as i0 from "@angular/core";
import * as i1 from "@angular/router";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "@angular/common";
import * as i4 from "./package-contents/packages-contents.component";
import * as i5 from "./package-versions-list/package-versions-list.component";
export class PackageVersionsComponent {
    constructor(activatedRoute, contextRouteService, pluginsService) {
        this.activatedRoute = activatedRoute;
        this.contextRouteService = contextRouteService;
        this.pluginsService = pluginsService;
        this.package = {};
        this.packageContentsTitle = gettext('Version {{ selectedVersion }} package contents');
    }
    async ngOnInit() {
        this.package = this.contextRouteService.getContextData(this.activatedRoute)?.contextData;
    }
    async showPluginOverview(plugin) {
        this.selectedPlugin = plugin;
        const baseUrl = `/apps/${plugin.id}/`;
        this.pluginBaseUrl = baseUrl;
        this.pluginMarkdown = await this.pluginsService.getReadmeFileContent(baseUrl);
    }
    closeOverview() {
        this.selectedPlugin = null;
    }
    clearSelectedVersion() {
        this.selectedVersion = null;
    }
    selectVersion(version) {
        if (this.selectedVersion !== version) {
            this.selectedVersion = version;
            this.closeOverview();
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PackageVersionsComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2.ContextRouteService }, { token: i2.PluginsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: PackageVersionsComponent, selector: "c8y-package-versions", ngImport: i0, template: "<c8y-title>{{ package?.name | humanizeAppName | async }}</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    [icon]=\"'c8y-atom'\"\n    [label]=\"'Ecosystem' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item\n    [icon]=\"'big-parcel'\"\n    [label]=\"'Extensions' | translate\"\n    [path]=\"'ecosystem/extension/extensions'\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item [label]=\"package?.name | humanizeAppName | async\"></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item [label]=\"'Versions' | translate\"></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<div\n  class=\"card content-fullpage d-grid\"\n  [ngClass]=\"{ 'grid__col--6-6-0': !selectedPlugin, 'grid__col--0-6-6': !!selectedPlugin }\"\n>\n  <c8y-package-versions-list\n    class=\"d-contents\"\n    (onVersionSelect)=\"selectVersion($event)\"\n  ></c8y-package-versions-list>\n\n  <!-- Package contents -->\n  <div\n    class=\"inner-scroll split-view__detail\"\n    [ngClass]=\"{ 'split-view__detail--selected': selectedVersion }\"\n  >\n    <div class=\"large-padding card-header separator visible-sm visible-xs fit-w sticky-top\">\n      <div class=\"d-flex a-i-center\">\n        <button\n          class=\"btn-clean text-primary m-r-8\"\n          title=\"{{ 'Back' | translate }}\"\n          (click)=\"clearSelectedVersion()\"\n        >\n          <i c8yIcon=\"chevron-left\"></i>\n          <span translate>Back</span>\n        </button>\n        <div class=\"card-title\">\n          {{ packageContentsTitle | translate: { selectedVersion } }}\n        </div>\n      </div>\n    </div>\n    <div class=\"card-header large-padding separator sticky-top visible-md visible-lg\">\n      <div class=\"card-title\">\n        <ng-container *ngIf=\"selectedVersion\">\n          {{ packageContentsTitle | translate: { selectedVersion } }}\n        </ng-container>\n      </div>\n    </div>\n    <div class=\"inner-scroll split-view__list\">\n      <c8y-package-contents\n        [selectedVersion]=\"selectedVersion\"\n        [selectedPlugin]=\"selectedPlugin\"\n        (showOverview)=\"showPluginOverview($event)\"\n      ></c8y-package-contents>\n    </div>\n  </div>\n\n  <!-- Plugin readme -->\n  <div\n    class=\"inner-scroll split-view__detail\"\n    [ngClass]=\"{ 'split-view__detail--selected': selectedPlugin }\"\n  >\n    <div\n      class=\"card-header separator sticky-top\"\n      *ngIf=\"selectedPlugin\"\n    >\n      <button\n        class=\"btn-clean\"\n        (click)=\"closeOverview()\"\n      >\n        <i c8yIcon=\"caret-back\"></i>\n        {{ 'Back to package versions overview ' | translate }}\n      </button>\n    </div>\n    <div\n      class=\"card-block p-l-16 p-r-16 overflow-visible\"\n      *ngIf=\"selectedPlugin\"\n    >\n      <div\n        class=\"markdown-content\"\n        *ngIf=\"pluginMarkdown\"\n        [innerHTML]=\"pluginMarkdown | markdownToHtml: { baseUrl: pluginBaseUrl } | async\"\n      ></div>\n      <c8y-ui-empty-state\n        [icon]=\"'user-manual'\"\n        [title]=\"'No README.md found for plugin' | translate\"\n        [subtitle]=\"\n          'To view the contents of &quot;README&quot;, add the file &quot;README.md&quot; to the plugin.'\n            | translate\n        \"\n        *ngIf=\"!pluginMarkdown\"\n        [horizontal]=\"true\"\n      ></c8y-ui-empty-state>\n    </div>\n  </div>\n</div>\n", dependencies: [{ kind: "component", type: i2.BreadcrumbComponent, selector: "c8y-breadcrumb" }, { kind: "component", type: i2.BreadcrumbItemComponent, selector: "c8y-breadcrumb-item", inputs: ["icon", "translate", "label", "path", "injector"] }, { kind: "component", type: i2.EmptyStateComponent, selector: "c8y-ui-empty-state", inputs: ["icon", "title", "subtitle", "horizontal"] }, { kind: "directive", type: i2.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i2.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.TitleComponent, selector: "c8y-title", inputs: ["pageTitleUpdate"] }, { kind: "component", type: i4.PackageContentsComponent, selector: "c8y-package-contents", inputs: ["selectedVersion", "selectedPlugin"], outputs: ["showOverview"] }, { kind: "component", type: i5.PackageVersionsListComponent, selector: "c8y-package-versions-list", outputs: ["onVersionSelect"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }, { kind: "pipe", type: i2.HumanizeAppNamePipe, name: "humanizeAppName" }, { kind: "pipe", type: i2.MarkdownToHtmlPipe, name: "markdownToHtml" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PackageVersionsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-package-versions', template: "<c8y-title>{{ package?.name | humanizeAppName | async }}</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    [icon]=\"'c8y-atom'\"\n    [label]=\"'Ecosystem' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item\n    [icon]=\"'big-parcel'\"\n    [label]=\"'Extensions' | translate\"\n    [path]=\"'ecosystem/extension/extensions'\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item [label]=\"package?.name | humanizeAppName | async\"></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item [label]=\"'Versions' | translate\"></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<div\n  class=\"card content-fullpage d-grid\"\n  [ngClass]=\"{ 'grid__col--6-6-0': !selectedPlugin, 'grid__col--0-6-6': !!selectedPlugin }\"\n>\n  <c8y-package-versions-list\n    class=\"d-contents\"\n    (onVersionSelect)=\"selectVersion($event)\"\n  ></c8y-package-versions-list>\n\n  <!-- Package contents -->\n  <div\n    class=\"inner-scroll split-view__detail\"\n    [ngClass]=\"{ 'split-view__detail--selected': selectedVersion }\"\n  >\n    <div class=\"large-padding card-header separator visible-sm visible-xs fit-w sticky-top\">\n      <div class=\"d-flex a-i-center\">\n        <button\n          class=\"btn-clean text-primary m-r-8\"\n          title=\"{{ 'Back' | translate }}\"\n          (click)=\"clearSelectedVersion()\"\n        >\n          <i c8yIcon=\"chevron-left\"></i>\n          <span translate>Back</span>\n        </button>\n        <div class=\"card-title\">\n          {{ packageContentsTitle | translate: { selectedVersion } }}\n        </div>\n      </div>\n    </div>\n    <div class=\"card-header large-padding separator sticky-top visible-md visible-lg\">\n      <div class=\"card-title\">\n        <ng-container *ngIf=\"selectedVersion\">\n          {{ packageContentsTitle | translate: { selectedVersion } }}\n        </ng-container>\n      </div>\n    </div>\n    <div class=\"inner-scroll split-view__list\">\n      <c8y-package-contents\n        [selectedVersion]=\"selectedVersion\"\n        [selectedPlugin]=\"selectedPlugin\"\n        (showOverview)=\"showPluginOverview($event)\"\n      ></c8y-package-contents>\n    </div>\n  </div>\n\n  <!-- Plugin readme -->\n  <div\n    class=\"inner-scroll split-view__detail\"\n    [ngClass]=\"{ 'split-view__detail--selected': selectedPlugin }\"\n  >\n    <div\n      class=\"card-header separator sticky-top\"\n      *ngIf=\"selectedPlugin\"\n    >\n      <button\n        class=\"btn-clean\"\n        (click)=\"closeOverview()\"\n      >\n        <i c8yIcon=\"caret-back\"></i>\n        {{ 'Back to package versions overview ' | translate }}\n      </button>\n    </div>\n    <div\n      class=\"card-block p-l-16 p-r-16 overflow-visible\"\n      *ngIf=\"selectedPlugin\"\n    >\n      <div\n        class=\"markdown-content\"\n        *ngIf=\"pluginMarkdown\"\n        [innerHTML]=\"pluginMarkdown | markdownToHtml: { baseUrl: pluginBaseUrl } | async\"\n      ></div>\n      <c8y-ui-empty-state\n        [icon]=\"'user-manual'\"\n        [title]=\"'No README.md found for plugin' | translate\"\n        [subtitle]=\"\n          'To view the contents of &quot;README&quot;, add the file &quot;README.md&quot; to the plugin.'\n            | translate\n        \"\n        *ngIf=\"!pluginMarkdown\"\n        [horizontal]=\"true\"\n      ></c8y-ui-empty-state>\n    </div>\n  </div>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.ActivatedRoute }, { type: i2.ContextRouteService }, { type: i2.PluginsService }] });
//# sourceMappingURL=data:application/json;base64, 