import * as i0 from '@angular/core';
import { Output, Directive, EventEmitter, Component, NgModule, Injectable } from '@angular/core';
import * as i1 from 'ngx-bootstrap/modal';
import { UpgradeComponent } from '@angular/upgrade/static';
import { gettext } from '@c8y/ngx-components/gettext';
import * as i2 from '@c8y/ngx-components';
import { ActionBarItemComponent, RealtimeButtonComponent, DeviceStatusComponent, C8yTranslateDirective, C8yTranslatePipe, OperationRealtimeService, ManagedObjectRealtimeService, CoreModule, ViewContext, hookRoute } from '@c8y/ngx-components';
import * as i4 from '@angular/router';
import * as i2$1 from '@c8y/client';
import { isEmpty, includes } from 'lodash-es';
import { of, BehaviorSubject, pipe, Subject } from 'rxjs';
import { map, startWith, takeUntil, filter } from 'rxjs/operators';
import * as i6 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import { NgFor, NgIf, AsyncPipe, CommonModule } from '@angular/common';
import { OperationsTimelineComponent, OperationsTimelineModule } from '@c8y/ngx-components/operations/operations-timeline';

class CommandTemplates extends UpgradeComponent {
    constructor(elementRef, injector) {
        super('c8yCommandTemplates', elementRef, injector);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplates, deps: [{ token: i0.ElementRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.25", type: CommandTemplates, isStandalone: true, selector: "c8y-command-templates-directive", outputs: { close: "close", dismiss: "dismiss" }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplates, decorators: [{
            type: Directive,
            args: [{ selector: 'c8y-command-templates-directive' }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Injector }], propDecorators: { close: [{
                type: Output
            }], dismiss: [{
                type: Output
            }] } });

/* https://stackoverflow.com/a/65290658 */
function rootScopeCommandTemplateFactory($injector) {
    return $injector.get('$rootScope').$new();
}
class CommandTemplatesComponent {
    constructor(modalRef) {
        this.modalRef = modalRef;
        this.onTemplateSelected = new EventEmitter();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplatesComponent, deps: [{ token: i1.BsModalRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.25", type: CommandTemplatesComponent, isStandalone: true, selector: "c8y-command-templates", providers: [
            {
                deps: ['$injector'],
                provide: '$scope',
                useFactory: rootScopeCommandTemplateFactory
            }
        ], ngImport: i0, template: `<c8y-command-templates-directive
    (close)="modalRef.hide(); onTemplateSelected.next($event)"
    (dismiss)="modalRef.hide()"
  ></c8y-command-templates-directive>`, isInline: true, dependencies: [{ kind: "directive", type: CommandTemplates, selector: "c8y-command-templates-directive", outputs: ["close", "dismiss"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplatesComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'c8y-command-templates',
                    template: `<c8y-command-templates-directive
    (close)="modalRef.hide(); onTemplateSelected.next($event)"
    (dismiss)="modalRef.hide()"
  ></c8y-command-templates-directive>`,
                    providers: [
                        {
                            deps: ['$injector'],
                            provide: '$scope',
                            useFactory: rootScopeCommandTemplateFactory
                        }
                    ],
                    imports: [CommandTemplates]
                }]
        }], ctorParameters: () => [{ type: i1.BsModalRef }] });

class CommandTemplatesModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplatesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplatesModule, imports: [CommandTemplates, CommandTemplatesComponent], exports: [CommandTemplatesComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplatesModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: CommandTemplatesModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommandTemplates, CommandTemplatesComponent],
                    exports: [CommandTemplatesComponent]
                }]
        }] });

class DeviceShellGuard {
    constructor() {
        this.operation = 'c8y_Command';
    }
    canActivate(route) {
        const device = route.data.contextData || route.parent.data.contextData;
        const supportedOperations = (device && device.c8y_SupportedOperations) || [];
        return supportedOperations.indexOf(this.operation) >= 0;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellGuard }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellGuard, decorators: [{
            type: Injectable
        }] });

var CommandDeliveryType;
(function (CommandDeliveryType) {
    CommandDeliveryType["DEFAULT"] = "Default";
    CommandDeliveryType["SMS"] = "SMS";
})(CommandDeliveryType || (CommandDeliveryType = {}));

class DeviceShellService {
    constructor(optionsService, operationService, inventoryService) {
        this.optionsService = optionsService;
        this.operationService = operationService;
        this.inventoryService = inventoryService;
        this.MO_TYPE = 'c8y_DeviceShellTemplate';
    }
    getDeliveryTypes() {
        return [
            {
                name: gettext(CommandDeliveryType.DEFAULT),
                default: true
            },
            {
                name: gettext(CommandDeliveryType.SMS)
            }
        ];
    }
    async canSendCommandsViaSMS() {
        return !!(await this.optionsService.getSystemOption('messaging', 'provider', false));
    }
    createCommandOperation(deviceId, command, deliveryType) {
        const operation = {
            deviceId,
            description: gettext('Execute shell command') + (command.name ? `: ${command.name}` : ''),
            deliveryType: deliveryType === CommandDeliveryType.SMS ? CommandDeliveryType.SMS : undefined,
            c8y_Command: {
                text: command.text
            }
        };
        return this.operationService.create(operation);
    }
    async getCommandTemplatesForDeviceType(deviceTypes) {
        const staticTemplates = await this.getStaticCommandTemplates(deviceTypes);
        const dynamicTemplates = await this.getDynamicCommandTemplates(deviceTypes);
        return [...staticTemplates, ...dynamicTemplates];
    }
    async getStaticCommandTemplates(deviceTypes) {
        const templates = [];
        deviceTypes.forEach(deviceType => {
            const inMemory = this.getCommandTemplatesForDeviceTypeInMemory(deviceType);
            if (inMemory) {
                templates.push(...this.extractCommandTemplatesFromData(deviceType, inMemory));
            }
        });
        return templates;
    }
    getCommandTemplatesForDeviceTypeInMemory(deviceType) {
        const raw = localStorage.getItem('devicecommands');
        if (!raw) {
            return undefined;
        }
        try {
            const store = JSON.parse(raw);
            return store?.[deviceType];
        }
        catch {
            return undefined;
        }
    }
    async getDynamicCommandTemplates(deviceTypes) {
        const query = {
            __filter: {
                type: this.MO_TYPE,
                deviceType: { __in: deviceTypes }
            },
            __orderby: [{ creationTime: -1 }]
        };
        const resultList = await this.inventoryService.listQuery(query, { pageSize: 1000 });
        const results = resultList.data;
        return results.map(r => ({
            ...r,
            deviceType: Array.isArray(r.deviceType) ? r.deviceType[0] : r.deviceType
        }));
    }
    extractCommandTemplatesFromData(deviceType, data) {
        let templates;
        if (Array.isArray(data)) {
            templates = data.flatMap(d => this.getExtendedTemplates(d.templates, d.syntax, deviceType));
        }
        else {
            templates = this.getExtendedTemplates(data.templates, data.syntax, deviceType);
        }
        return templates;
    }
    getExtendedTemplates(templates, syntax, deviceType) {
        return (templates || []).map(t => ({ ...t, syntax, deviceType }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellService, deps: [{ token: i2.OptionsService }, { token: i2$1.OperationService }, { token: i2$1.InventoryService }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellService, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i2.OptionsService }, { type: i2$1.OperationService }, { type: i2$1.InventoryService }] });

class DeviceShellSharedModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellSharedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellSharedModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellSharedModule, providers: [DeviceShellService] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellSharedModule, decorators: [{
            type: NgModule,
            args: [{
                    providers: [DeviceShellService]
                }]
        }] });

class DeviceShellComponent {
    constructor(service, operationRealtime, moRealtime, operationService, route, modalService, alertService) {
        this.service = service;
        this.operationRealtime = operationRealtime;
        this.moRealtime = moRealtime;
        this.operationService = operationService;
        this.route = route;
        this.modalService = modalService;
        this.alertService = alertService;
        this.device = this.route.snapshot.parent.data.contextData;
        this.device$ = of({});
        this.deliveryTypes = (this.service.getDeliveryTypes() || []).map(deliveryType => ({ ...deliveryType, isSupportedByCommand: true }));
        this.command = {};
        this.smsEnabled = false;
        this.sendingCommand$ = new BehaviorSubject(false);
        this.filterPipe = pipe(map((operations) => (operations || []).filter((operation) => !!operation.c8y_Command)));
        this.executeViaLabel = gettext('Execute via ({{deliveryType}})');
        this.destroyed$ = new Subject();
    }
    async ngOnInit() {
        this.smsEnabled = await this.service.canSendCommandsViaSMS();
        this.device$ = this.moRealtime.onUpdate$(this.device.id).pipe(startWith(this.device));
        this.operations = await this.operationService.list({
            deviceId: this.device.id,
            fragmentType: 'c8y_Command',
            dateFrom: new Date(0).toISOString(),
            dateTo: new Date().toISOString(),
            pageSize: 50,
            withTotalPages: true,
            revert: true
        });
        this.operationRealtime
            .onCreate$(this.device.id)
            .pipe(takeUntil(this.destroyed$))
            .subscribe(() => this.alertService.success(gettext('Command sent.')));
        this.operationRealtime
            .onUpdate$(this.device.id)
            .pipe(filter(op => op.failureReason !== 'Operation cancelled by user.'), // avoid duplicate alerts
        takeUntil(this.destroyed$))
            .subscribe(() => this.alertService.success(gettext('Command status updated.')));
    }
    getPredefinedCommand() {
        const modal = this.modalService.show(CommandTemplatesComponent, {
            ariaDescribedby: 'modal-body',
            ariaLabelledBy: 'modal-title'
        });
        modal.content.onTemplateSelected.pipe(takeUntil(this.destroyed$)).subscribe(result => {
            this.command = { ...result.commandTemplate };
            this.deliveryTypes = this.deliveryTypes.map(deliveryType => ({
                ...deliveryType,
                isSupportedByCommand: isEmpty(this.command.deliveryTypes) ||
                    includes(this.command.deliveryTypes, deliveryType.name)
            }));
        });
    }
    resetSupportedDeliveryTypes() {
        this.deliveryTypes = (this.service.getDeliveryTypes() || []).map(deliveryType => ({
            ...deliveryType,
            isSupportedByCommand: true
        }));
    }
    async execute(commandDeliveryType) {
        const useSMS = commandDeliveryType === CommandDeliveryType.SMS;
        if (useSMS && !this.smsEnabled) {
            this.alertService.warning(gettext('SMS transport is not configured.'));
            return;
        }
        this.sendingCommand$.next(true);
        await this.service.createCommandOperation(this.device.id, this.command, commandDeliveryType);
        this.command.text = '';
        this.command.name = '';
        this.resetSupportedDeliveryTypes();
        this.sendingCommand$.next(false);
    }
    ngOnDestroy() {
        this.destroyed$.next();
        this.destroyed$.complete();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellComponent, deps: [{ token: DeviceShellService }, { token: i2.OperationRealtimeService }, { token: i2.ManagedObjectRealtimeService }, { token: i2$1.OperationService }, { token: i4.ActivatedRoute }, { token: i1.BsModalService }, { token: i2.AlertService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.25", type: DeviceShellComponent, isStandalone: true, selector: "c8y-device-shell", providers: [OperationRealtimeService, ManagedObjectRealtimeService], ngImport: i0, template: "<c8y-action-bar-item [placement]=\"'right'\">\n  <c8y-realtime-btn [service]=\"operationRealtime\"></c8y-realtime-btn>\n</c8y-action-bar-item>\n\n<div class=\"card content-fullpage d-grid grid__col--6-6--md\">\n  <div class=\"inner-scroll d-flex d-col bg-level-0\">\n    <div class=\"card-header large-padding separator sticky-top\">\n      <div class=\"card-title\">\n        {{ 'Command' | translate }}\n      </div>\n    </div>\n\n    <div class=\"card-block d-flex d-col flex-grow large-padding\">\n      <div class=\"d-flex p-b-16\">\n        <button\n          class=\"btn btn-default btn-sm\"\n          type=\"button\"\n          (click)=\"getPredefinedCommand()\"\n          [title]=\"'Display a list of predefined commands' | translate\"\n          data-cy=\"shell--predefined-commands\"\n        >\n          {{ 'Predefined commands' | translate }}\n        </button>\n\n        <div class=\"m-l-auto\">\n          <device-status [mo]=\"device$ | async\"></device-status>\n        </div>\n      </div>\n      <textarea\n        [attr.aria-label]=\"'Commands' | translate\"\n        class=\"form-control inner-scroll flex-grow bg-level-2 text-monospace\"\n        [(ngModel)]=\"command.text\"\n        data-cy=\"shell-component--commands\"\n        (ngModelChange)=\"$event || resetSupportedDeliveryTypes()\"\n        placeholder=\"{{ 'Add commands or use predefined commands above.' | translate }}\"\n      ></textarea>\n    </div>\n\n    <div class=\"card-footer large-padding separator\">\n      <ng-container *ngFor=\"let deliveryType of deliveryTypes\">\n        <button\n          class=\"btn btn-primary\"\n          type=\"button\"\n          *ngIf=\"deliveryType.isSupportedByCommand\"\n          [disabled]=\"!command?.text || (sendingCommand$ | async)\"\n          (click)=\"execute(deliveryType.name)\"\n        >\n          <span\n            [title]=\"\n              deliveryType.default\n                ? ('Execute' | translate)\n                : (executeViaLabel | translate: { deliveryType: deliveryType.name })\n            \"\n          >\n            {{\n              deliveryType.default\n                ? ('Execute' | translate)\n                : (executeViaLabel | translate: { deliveryType: deliveryType.name })\n            }}\n          </span>\n        </button>\n      </ng-container>\n    </div>\n  </div>\n  <div class=\"inner-scroll bg-level-1\">\n    <div class=\"card-header large-padding separator sticky-top\">\n      <div class=\"card-title\">\n        {{ 'Operations' | translate }}\n      </div>\n    </div>\n    <div class=\"card-block large-padding\">\n      <c8y-operations-timeline\n        [operations]=\"operations\"\n        [sourceId]=\"device.id\"\n        [filterPipe]=\"filterPipe\"\n        [bodyTemplate]=\"timelineItemBody\"\n        [footerTemplates]=\"[timelineItemFooter]\"\n        [propertiesToHide]=\"['c8y_Command']\"\n      ></c8y-operations-timeline>\n      <ng-template #timelineItemBody let-operation>\n        <small>{{ operation.c8y_Command?.text || operation.description }}</small>\n      </ng-template>\n      <ng-template #timelineItemFooter let-operation>\n        <div *ngIf=\"operation.c8y_Command?.text\">\n          <div class=\"legend form-block\" translate>Command</div>\n          <!-- Keep this in a single line since `pre-text` will preserve all whitespaces in the `pre` tag.-->\n          <pre class=\"p-8 text-pre\"><code>{{operation.c8y_Command.text}}</code></pre>\n        </div>\n        <div *ngIf=\"operation.c8y_Command?.result\">\n          <div class=\"legend form-block\" translate>Response</div>\n          <!-- Keep this in a single line since `pre-text` will preserve all whitespaces in the `pre` tag.-->\n          <pre class=\"p-8 text-pre\"><code>{{operation.c8y_Command.result}}</code></pre>\n        </div>\n      </ng-template>\n    </div>\n  </div>\n</div>\n", dependencies: [{ kind: "component", type: ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId", "inGroupPriority"] }, { kind: "component", type: RealtimeButtonComponent, selector: "c8y-realtime-btn", inputs: ["service", "label", "title", "disabled"], outputs: ["onToggle"] }, { kind: "component", type: DeviceStatusComponent, selector: "device-status, c8y-device-status", inputs: ["mo", "size"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OperationsTimelineComponent, selector: "c8y-operations-timeline", inputs: ["operations", "sourceId", "filterPipe", "loadMoreMode", "bodyTemplate", "footerTemplates", "propertiesToHide"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-device-shell', providers: [OperationRealtimeService, ManagedObjectRealtimeService], imports: [
                        ActionBarItemComponent,
                        RealtimeButtonComponent,
                        DeviceStatusComponent,
                        FormsModule,
                        NgFor,
                        NgIf,
                        OperationsTimelineComponent,
                        C8yTranslateDirective,
                        AsyncPipe,
                        C8yTranslatePipe
                    ], template: "<c8y-action-bar-item [placement]=\"'right'\">\n  <c8y-realtime-btn [service]=\"operationRealtime\"></c8y-realtime-btn>\n</c8y-action-bar-item>\n\n<div class=\"card content-fullpage d-grid grid__col--6-6--md\">\n  <div class=\"inner-scroll d-flex d-col bg-level-0\">\n    <div class=\"card-header large-padding separator sticky-top\">\n      <div class=\"card-title\">\n        {{ 'Command' | translate }}\n      </div>\n    </div>\n\n    <div class=\"card-block d-flex d-col flex-grow large-padding\">\n      <div class=\"d-flex p-b-16\">\n        <button\n          class=\"btn btn-default btn-sm\"\n          type=\"button\"\n          (click)=\"getPredefinedCommand()\"\n          [title]=\"'Display a list of predefined commands' | translate\"\n          data-cy=\"shell--predefined-commands\"\n        >\n          {{ 'Predefined commands' | translate }}\n        </button>\n\n        <div class=\"m-l-auto\">\n          <device-status [mo]=\"device$ | async\"></device-status>\n        </div>\n      </div>\n      <textarea\n        [attr.aria-label]=\"'Commands' | translate\"\n        class=\"form-control inner-scroll flex-grow bg-level-2 text-monospace\"\n        [(ngModel)]=\"command.text\"\n        data-cy=\"shell-component--commands\"\n        (ngModelChange)=\"$event || resetSupportedDeliveryTypes()\"\n        placeholder=\"{{ 'Add commands or use predefined commands above.' | translate }}\"\n      ></textarea>\n    </div>\n\n    <div class=\"card-footer large-padding separator\">\n      <ng-container *ngFor=\"let deliveryType of deliveryTypes\">\n        <button\n          class=\"btn btn-primary\"\n          type=\"button\"\n          *ngIf=\"deliveryType.isSupportedByCommand\"\n          [disabled]=\"!command?.text || (sendingCommand$ | async)\"\n          (click)=\"execute(deliveryType.name)\"\n        >\n          <span\n            [title]=\"\n              deliveryType.default\n                ? ('Execute' | translate)\n                : (executeViaLabel | translate: { deliveryType: deliveryType.name })\n            \"\n          >\n            {{\n              deliveryType.default\n                ? ('Execute' | translate)\n                : (executeViaLabel | translate: { deliveryType: deliveryType.name })\n            }}\n          </span>\n        </button>\n      </ng-container>\n    </div>\n  </div>\n  <div class=\"inner-scroll bg-level-1\">\n    <div class=\"card-header large-padding separator sticky-top\">\n      <div class=\"card-title\">\n        {{ 'Operations' | translate }}\n      </div>\n    </div>\n    <div class=\"card-block large-padding\">\n      <c8y-operations-timeline\n        [operations]=\"operations\"\n        [sourceId]=\"device.id\"\n        [filterPipe]=\"filterPipe\"\n        [bodyTemplate]=\"timelineItemBody\"\n        [footerTemplates]=\"[timelineItemFooter]\"\n        [propertiesToHide]=\"['c8y_Command']\"\n      ></c8y-operations-timeline>\n      <ng-template #timelineItemBody let-operation>\n        <small>{{ operation.c8y_Command?.text || operation.description }}</small>\n      </ng-template>\n      <ng-template #timelineItemFooter let-operation>\n        <div *ngIf=\"operation.c8y_Command?.text\">\n          <div class=\"legend form-block\" translate>Command</div>\n          <!-- Keep this in a single line since `pre-text` will preserve all whitespaces in the `pre` tag.-->\n          <pre class=\"p-8 text-pre\"><code>{{operation.c8y_Command.text}}</code></pre>\n        </div>\n        <div *ngIf=\"operation.c8y_Command?.result\">\n          <div class=\"legend form-block\" translate>Response</div>\n          <!-- Keep this in a single line since `pre-text` will preserve all whitespaces in the `pre` tag.-->\n          <pre class=\"p-8 text-pre\"><code>{{operation.c8y_Command.result}}</code></pre>\n        </div>\n      </ng-template>\n    </div>\n  </div>\n</div>\n" }]
        }], ctorParameters: () => [{ type: DeviceShellService }, { type: i2.OperationRealtimeService }, { type: i2.ManagedObjectRealtimeService }, { type: i2$1.OperationService }, { type: i4.ActivatedRoute }, { type: i1.BsModalService }, { type: i2.AlertService }] });

class ShellModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: ShellModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.25", ngImport: i0, type: ShellModule, imports: [CommonModule,
            CoreModule,
            OperationsTimelineModule,
            CommandTemplatesModule,
            DeviceShellSharedModule,
            DeviceShellComponent], exports: [DeviceShellComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: ShellModule, imports: [CommonModule,
            CoreModule,
            OperationsTimelineModule,
            CommandTemplatesModule,
            DeviceShellSharedModule,
            DeviceShellComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: ShellModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        CoreModule,
                        OperationsTimelineModule,
                        CommandTemplatesModule,
                        DeviceShellSharedModule,
                        DeviceShellComponent
                    ],
                    exports: [DeviceShellComponent]
                }]
        }] });

const DEVICE_SHELL_ROUTE = {
    path: 'shell',
    context: ViewContext.Device,
    component: DeviceShellComponent,
    label: gettext('Shell'),
    icon: 'terminal',
    canActivate: [DeviceShellGuard]
};
class DeviceShellModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellModule, imports: [ShellModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellModule, providers: [DeviceShellGuard, hookRoute(DEVICE_SHELL_ROUTE)], imports: [ShellModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: DeviceShellModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [ShellModule],
                    providers: [DeviceShellGuard, hookRoute(DEVICE_SHELL_ROUTE)]
                }]
        }] });

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

export { CommandDeliveryType, CommandTemplates, CommandTemplatesComponent, CommandTemplatesModule, DeviceShellComponent, DeviceShellGuard, DeviceShellModule, DeviceShellService, DeviceShellSharedModule, ShellModule, rootScopeCommandTemplateFactory };
//# sourceMappingURL=c8y-ngx-components-device-shell.mjs.map
