import { Component, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ApplicationService } from '@c8y/client';
import { AlertService, ContextRouteService } from '@c8y/ngx-components';
import { packageProperties } from '@c8y/ngx-components/ecosystem/shared';
import * as i0 from "@angular/core";
import * as i1 from "@angular/router";
import * as i2 from "@c8y/client";
import * as i3 from "@c8y/ngx-components";
import * as i4 from "@angular/common";
import * as i5 from "./contents-plugins/contents-plugins.component";
import * as i6 from "./contents-apps/contents-apps.component";
export class PackageContentsComponent {
    constructor(activatedRoute, applicationService, alertService, contextRouteService) {
        this.activatedRoute = activatedRoute;
        this.applicationService = applicationService;
        this.alertService = alertService;
        this.contextRouteService = contextRouteService;
        this.package = {};
        this.isLoading = false;
        this.packageVersionProperties = packageProperties;
    }
    async ngOnChanges(changes) {
        if (changes.selectedVersion.currentValue) {
            this.loadManifest(this.selectedVersion);
        }
        this.selectedVersionManifest = undefined;
    }
    async loadManifest(version) {
        this.package = this.contextRouteService.getContextData(this.activatedRoute)?.contextData;
        this.isLoading = true;
        this.selectedVersionManifest = await this.getManifest(version);
        this.isLoading = false;
    }
    async getManifest(version) {
        try {
            return await this.applicationService.getAppManifest(this.package, version);
        }
        catch (error) {
            this.alertService.addServerFailure(error);
        }
        return undefined;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: PackageContentsComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2.ApplicationService }, { token: i3.AlertService }, { token: i3.ContextRouteService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: PackageContentsComponent, selector: "c8y-package-contents", inputs: { selectedVersion: "selectedVersion" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"inner-scroll\">\n  <ng-container *ngIf=\"!selectedVersionManifest && !isLoading\">\n    <div class=\"p-16\">\n      <c8y-ui-empty-state\n        [icon]=\"'big-parcel'\"\n        [horizontal]=\"true\"\n        [title]=\"'No package selected' | translate\"\n        [subtitle]=\"'Select a package from the list to display the package contents.' | translate\"\n      ></c8y-ui-empty-state>\n    </div>\n  </ng-container>\n\n  <ng-container *ngIf=\"isLoading\">\n    <c8y-loading></c8y-loading>\n  </ng-container>\n\n  <ng-container *ngIf=\"selectedVersionManifest && !isLoading\">\n    <!-- DETAILS -->\n    <div class=\"card-block p-t-0\">\n      <c8y-properties-list\n        [data]=\"selectedVersionManifest\"\n        [emptyLabel]=\"'--'\"\n        [properties]=\"packageVersionProperties\"\n      >\n      </c8y-properties-list>\n      \n        <!-- APPS -->\n      <c8y-contents-apps\n      class=\"p-t-16 d-block\"\n      [selectedVersionManifest]=\"selectedVersionManifest\"\n      ></c8y-contents-apps>\n\n      <!-- PLUGINS -->\n      <c8y-contents-plugins\n      class=\"p-t-16 d-block\"\n      [selectedVersionManifest]=\"selectedVersionManifest\"\n      ></c8y-contents-plugins>\n    </div>\n  </ng-container>\n</div>\n", dependencies: [{ kind: "component", type: i3.EmptyStateComponent, selector: "c8y-ui-empty-state", inputs: ["icon", "title", "subtitle", "horizontal"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.LoadingComponent, selector: "c8y-loading", inputs: ["layout", "progress", "message"] }, { kind: "component", type: i3.PropertiesListComponent, selector: "c8y-properties-list", inputs: ["properties", "title", "icon", "data", "groups", "noParse", "emptyLabel"] }, { kind: "component", type: i5.PackageVersionsPluginsComponent, selector: "c8y-contents-plugins", inputs: ["selectedVersionManifest"] }, { kind: "component", type: i6.PackageVersionsAppsComponent, selector: "c8y-contents-apps", inputs: ["selectedVersionManifest"] }, { kind: "pipe", type: i3.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: PackageContentsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-package-contents', template: "<div class=\"inner-scroll\">\n  <ng-container *ngIf=\"!selectedVersionManifest && !isLoading\">\n    <div class=\"p-16\">\n      <c8y-ui-empty-state\n        [icon]=\"'big-parcel'\"\n        [horizontal]=\"true\"\n        [title]=\"'No package selected' | translate\"\n        [subtitle]=\"'Select a package from the list to display the package contents.' | translate\"\n      ></c8y-ui-empty-state>\n    </div>\n  </ng-container>\n\n  <ng-container *ngIf=\"isLoading\">\n    <c8y-loading></c8y-loading>\n  </ng-container>\n\n  <ng-container *ngIf=\"selectedVersionManifest && !isLoading\">\n    <!-- DETAILS -->\n    <div class=\"card-block p-t-0\">\n      <c8y-properties-list\n        [data]=\"selectedVersionManifest\"\n        [emptyLabel]=\"'--'\"\n        [properties]=\"packageVersionProperties\"\n      >\n      </c8y-properties-list>\n      \n        <!-- APPS -->\n      <c8y-contents-apps\n      class=\"p-t-16 d-block\"\n      [selectedVersionManifest]=\"selectedVersionManifest\"\n      ></c8y-contents-apps>\n\n      <!-- PLUGINS -->\n      <c8y-contents-plugins\n      class=\"p-t-16 d-block\"\n      [selectedVersionManifest]=\"selectedVersionManifest\"\n      ></c8y-contents-plugins>\n    </div>\n  </ng-container>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.ActivatedRoute }, { type: i2.ApplicationService }, { type: i3.AlertService }, { type: i3.ContextRouteService }], propDecorators: { selectedVersion: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 