import { Component, Input } from '@angular/core';
import { ControlContainer, NgForm } from '@angular/forms';
import { validationMethodConfig } from './external-token-config.model';
import { RequestConfiguration } from './request-configuration.model';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/ngx-components";
import * as i2 from "@angular/common";
import * as i3 from "@angular/forms";
import * as i4 from "ngx-bootstrap/collapse";
import * as i5 from "./request-configuration.component";
import * as i6 from "./user-id-configuration.component";
export class ExternalTokenConfigComponent {
    constructor() {
        this.validationMethods = validationMethodConfig;
    }
    get externalTokenConfig() {
        return this.templateModel.externalTokenConfig;
    }
    onValidationMethodChange(event) {
        this.externalTokenConfig.validationMethod = event;
        this.externalTokenConfig.tokenValidationRequest = new RequestConfiguration(this.validationMethods[event].defaults);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ExternalTokenConfigComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: ExternalTokenConfigComponent, selector: "c8y-external-token-config", inputs: { templateModel: "templateModel" }, ngImport: i0, template: "<div class=\"p-24\">\n  <div class=\"row\">\n    <div class=\"col-xs-12 col-sm-3 col-md-2\">\n      <div\n        class=\"h4 text-normal text-right text-left-xs\"\n        translate\n      >\n        External token configuration\n      </div>\n    </div>\n\n    <div\n      class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\"\n      *ngIf=\"templateModel\"\n    >\n      <label\n        class=\"c8y-switch\"\n        data-cy=\"c8y-authentication--external-token-configuration-switcher\"\n        title=\"{{ 'Allow authentication with access token from external IAM system' | translate }}\"\n      >\n        <input\n          id=\"enabled\"\n          name=\"enabled\"\n          type=\"checkbox\"\n          [(ngModel)]=\"externalTokenConfig.enabled\"\n        />\n        <span></span>\n        <span class=\"control-label\">\n          {{ 'Allow authentication with access token from external IAM system' | translate }}\n        </span>\n      </label>\n\n      <div\n        class=\"collapse\"\n        [collapse]=\"!externalTokenConfig.enabled\"\n        [isAnimated]=\"true\"\n      >\n        <ng-container *ngIf=\"externalTokenConfig.enabled\">\n          <c8y-user-id-configuration\n            [userIdConfig]=\"externalTokenConfig.userOrAppIdConfig\"\n            [withHeader]=\"false\"\n          ></c8y-user-id-configuration>\n\n          <label\n            class=\"c8y-switch\"\n            title=\"{{ 'Validate access token' | translate }}\"\n            for=\"validationRequired\"\n          >\n            <input\n              id=\"validationRequired\"\n              name=\"validationRequired\"\n              type=\"checkbox\"\n              [(ngModel)]=\"externalTokenConfig.validationRequired\"\n            />\n            <span></span>\n            <span class=\"control-label\">{{ 'Validate access token' | translate }}</span>\n          </label>\n          <div\n            class=\"collapse\"\n            [collapse]=\"!externalTokenConfig.validationRequired\"\n            [isAnimated]=\"true\"\n          >\n            <ng-container *ngIf=\"externalTokenConfig.validationRequired\">\n              <div class=\"row\">\n                <div class=\"col-sm-6 m-t-16\">\n                  <label\n                    class=\"control-label\"\n                    for=\"validationMethod\"\n                    translate\n                  >\n                    Validation method\n                  </label>\n                  <div class=\"c8y-select-wrapper\">\n                    <select\n                      class=\"form-control\"\n                      id=\"validationMethod\"\n                      name=\"validationMethod\"\n                      [ngModel]=\"externalTokenConfig.validationMethod\"\n                      (ngModelChange)=\"onValidationMethodChange($event)\"\n                    >\n                      <option\n                        *ngFor=\"let validationMethod of validationMethods | keyvalue\"\n                        [ngValue]=\"validationMethod.key\"\n                      >\n                        {{ validationMethod.value.label | translate }}\n                      </option>\n                    </select>\n                    <span></span>\n                  </div>\n                </div>\n              </div>\n              <div class=\"row\">\n                <c8y-request-configuration\n                  [templateModel]=\"externalTokenConfig\"\n                  [requestName]=\"'Token validation request' | translate\"\n                  [requestType]=\"'tokenValidationRequest'\"\n                ></c8y-request-configuration>\n              </div>\n              <div class=\"row\">\n                <div class=\"col-sm-6 m-l-8\">\n                  <c8y-form-group>\n                    <label\n                      class=\"control-label\"\n                      for=\"accessTokenValidityCheckIntervalInMinutes\"\n                      translate\n                    >\n                      Access token validation frequency\n                    </label>\n                    <div class=\"input-group\">\n                      <input\n                        class=\"form-control\"\n                        id=\"accessTokenValidityCheckIntervalInMinutes\"\n                        name=\"accessTokenValidityCheckIntervalInMinutes\"\n                        type=\"number\"\n                        required\n                        [(ngModel)]=\"externalTokenConfig.accessTokenValidityCheckIntervalInMinutes\"\n                        [placeholder]=\"'e.g. {{ example }}' | translate: { example: '1' }\"\n                        step=\"1\"\n                        [min]=\"1\"\n                      />\n                      <span\n                        class=\"input-group-addon\"\n                        translate\n                      >\n                        minutes\n                      </span>\n                    </div>\n                  </c8y-form-group>\n                </div>\n              </div>\n            </ng-container>\n          </div>\n        </ng-container>\n      </div>\n    </div>\n  </div>\n</div>\n", dependencies: [{ kind: "directive", type: i1.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.MinValidationDirective, selector: "[min]", inputs: ["min"] }, { kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.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: i3.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i3.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i3.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i3.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i1.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: i1.RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: i4.CollapseDirective, selector: "[collapse]", inputs: ["display", "isAnimated", "collapse"], outputs: ["collapsed", "collapses", "expanded", "expands"], exportAs: ["bs-collapse"] }, { kind: "component", type: i5.RequestConfigurationComponent, selector: "c8y-request-configuration", inputs: ["templateModel", "requestName", "requestType"] }, { kind: "component", type: i6.UserIdConfigurationComponent, selector: "c8y-user-id-configuration", inputs: ["userIdConfig", "withHeader"] }, { kind: "pipe", type: i1.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i2.KeyValuePipe, name: "keyvalue" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ExternalTokenConfigComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-external-token-config', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], template: "<div class=\"p-24\">\n  <div class=\"row\">\n    <div class=\"col-xs-12 col-sm-3 col-md-2\">\n      <div\n        class=\"h4 text-normal text-right text-left-xs\"\n        translate\n      >\n        External token configuration\n      </div>\n    </div>\n\n    <div\n      class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\"\n      *ngIf=\"templateModel\"\n    >\n      <label\n        class=\"c8y-switch\"\n        data-cy=\"c8y-authentication--external-token-configuration-switcher\"\n        title=\"{{ 'Allow authentication with access token from external IAM system' | translate }}\"\n      >\n        <input\n          id=\"enabled\"\n          name=\"enabled\"\n          type=\"checkbox\"\n          [(ngModel)]=\"externalTokenConfig.enabled\"\n        />\n        <span></span>\n        <span class=\"control-label\">\n          {{ 'Allow authentication with access token from external IAM system' | translate }}\n        </span>\n      </label>\n\n      <div\n        class=\"collapse\"\n        [collapse]=\"!externalTokenConfig.enabled\"\n        [isAnimated]=\"true\"\n      >\n        <ng-container *ngIf=\"externalTokenConfig.enabled\">\n          <c8y-user-id-configuration\n            [userIdConfig]=\"externalTokenConfig.userOrAppIdConfig\"\n            [withHeader]=\"false\"\n          ></c8y-user-id-configuration>\n\n          <label\n            class=\"c8y-switch\"\n            title=\"{{ 'Validate access token' | translate }}\"\n            for=\"validationRequired\"\n          >\n            <input\n              id=\"validationRequired\"\n              name=\"validationRequired\"\n              type=\"checkbox\"\n              [(ngModel)]=\"externalTokenConfig.validationRequired\"\n            />\n            <span></span>\n            <span class=\"control-label\">{{ 'Validate access token' | translate }}</span>\n          </label>\n          <div\n            class=\"collapse\"\n            [collapse]=\"!externalTokenConfig.validationRequired\"\n            [isAnimated]=\"true\"\n          >\n            <ng-container *ngIf=\"externalTokenConfig.validationRequired\">\n              <div class=\"row\">\n                <div class=\"col-sm-6 m-t-16\">\n                  <label\n                    class=\"control-label\"\n                    for=\"validationMethod\"\n                    translate\n                  >\n                    Validation method\n                  </label>\n                  <div class=\"c8y-select-wrapper\">\n                    <select\n                      class=\"form-control\"\n                      id=\"validationMethod\"\n                      name=\"validationMethod\"\n                      [ngModel]=\"externalTokenConfig.validationMethod\"\n                      (ngModelChange)=\"onValidationMethodChange($event)\"\n                    >\n                      <option\n                        *ngFor=\"let validationMethod of validationMethods | keyvalue\"\n                        [ngValue]=\"validationMethod.key\"\n                      >\n                        {{ validationMethod.value.label | translate }}\n                      </option>\n                    </select>\n                    <span></span>\n                  </div>\n                </div>\n              </div>\n              <div class=\"row\">\n                <c8y-request-configuration\n                  [templateModel]=\"externalTokenConfig\"\n                  [requestName]=\"'Token validation request' | translate\"\n                  [requestType]=\"'tokenValidationRequest'\"\n                ></c8y-request-configuration>\n              </div>\n              <div class=\"row\">\n                <div class=\"col-sm-6 m-l-8\">\n                  <c8y-form-group>\n                    <label\n                      class=\"control-label\"\n                      for=\"accessTokenValidityCheckIntervalInMinutes\"\n                      translate\n                    >\n                      Access token validation frequency\n                    </label>\n                    <div class=\"input-group\">\n                      <input\n                        class=\"form-control\"\n                        id=\"accessTokenValidityCheckIntervalInMinutes\"\n                        name=\"accessTokenValidityCheckIntervalInMinutes\"\n                        type=\"number\"\n                        required\n                        [(ngModel)]=\"externalTokenConfig.accessTokenValidityCheckIntervalInMinutes\"\n                        [placeholder]=\"'e.g. {{ example }}' | translate: { example: '1' }\"\n                        step=\"1\"\n                        [min]=\"1\"\n                      />\n                      <span\n                        class=\"input-group-addon\"\n                        translate\n                      >\n                        minutes\n                      </span>\n                    </div>\n                  </c8y-form-group>\n                </div>\n              </div>\n            </ng-container>\n          </div>\n        </ng-container>\n      </div>\n    </div>\n  </div>\n</div>\n" }]
        }], propDecorators: { templateModel: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 