import { Component, EventEmitter, Input, Output } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/router";
import * as i2 from "@angular/common";
import * as i3 from "@ionic/angular";
import * as i4 from "@softpak/frontend-components-ng/dist/frontend-components-ng";
import * as i5 from "../spf-capitalize/spf-capitalize.pipe";
import * as i6 from "@ngx-translate/core";
export class SpaWelcomeComponent {
    constructor(router) {
        this.router = router;
        this.channels = [];
        this.channelSelected = new EventEmitter();
    }
    ngOnChanges() {
        this.productionChannels = this.channels.filter(connection => connection.isProduction);
        this.autoSelect();
    }
    onSelectChannel(channel) {
        this.channelSelected.emit(channel);
        this.router.navigate(['/']);
    }
    // Automatically select channel, if there is only one.
    autoSelect() {
        if (this.productionChannels.length === 1) {
            this.onSelectChannel(this.productionChannels.find((_, index) => index === 0));
        }
    }
}
SpaWelcomeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaWelcomeComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
SpaWelcomeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: SpaWelcomeComponent, selector: "spa-welcome", inputs: { channels: "channels", txtTitle: "txtTitle" }, outputs: { channelSelected: "channelSelected" }, usesOnChanges: true, ngImport: i0, template: "<ion-header>\n  <ion-toolbar>\n      <ion-title>\n        {{ txtTitle | translate | capitalize }}\n      </ion-title>\n      <ion-buttons slot=\"end\">\n      </ion-buttons>\n  </ion-toolbar>\n</ion-header>\n<ion-content class=\"ion-padding\">\n  <spn-button class=\"block mb-2\" [spfFullWidth]=\"true\" *ngFor=\"let channel of productionChannels\" (click)=\"onSelectChannel(channel)\">\n      {{ channel.brand }}\n  </spn-button>\n</ion-content>\n", styles: [":host{display:block;height:100%}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i3.IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { kind: "component", type: i3.IonContent, selector: "ion-content", inputs: ["color", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"] }, { kind: "component", type: i3.IonHeader, selector: "ion-header", inputs: ["collapse", "mode", "translucent"] }, { kind: "component", type: i3.IonTitle, selector: "ion-title", inputs: ["color", "size"] }, { kind: "component", type: i3.IonToolbar, selector: "ion-toolbar", inputs: ["color", "mode"] }, { kind: "component", type: i4.SpnButton, selector: "spn-button", inputs: ["spfClass", "spfClassObject", "spfDisabled", "spfForm", "spfFullHeight", "spfFullWidth", "spfSeverity", "spfSize", "spfTabIndex", "spfType"] }, { kind: "pipe", type: i5.SpfCapitalizePipe, name: "capitalize" }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaWelcomeComponent, decorators: [{
            type: Component,
            args: [{ selector: 'spa-welcome', template: "<ion-header>\n  <ion-toolbar>\n      <ion-title>\n        {{ txtTitle | translate | capitalize }}\n      </ion-title>\n      <ion-buttons slot=\"end\">\n      </ion-buttons>\n  </ion-toolbar>\n</ion-header>\n<ion-content class=\"ion-padding\">\n  <spn-button class=\"block mb-2\" [spfFullWidth]=\"true\" *ngFor=\"let channel of productionChannels\" (click)=\"onSelectChannel(channel)\">\n      {{ channel.brand }}\n  </spn-button>\n</ion-content>\n", styles: [":host{display:block;height:100%}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.Router }]; }, propDecorators: { channels: [{
                type: Input
            }], txtTitle: [{
                type: Input
            }], channelSelected: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3BhLXdlbGNvbWUuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvYW5ndWxhci1jb21wb25lbnRzL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