import { Component, Input } from '@angular/core';
import { gettext } from '@c8y/ngx-components';
import { ControlContainer, NgForm } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "ngx-bootstrap/popover";
export class UserDataMappingComponent {
    constructor(controlContainer) {
        this.controlContainer = controlContainer;
        this.CLAIM_NAMES = gettext('Token claims can be checked in Audit Logs under Single sign-on type.');
        this.RETRIVE_FROM_ACCESS_TOKEN = gettext('Retrieve from Access token');
        this.RETRIVE_FROM_ID_TOKEN = gettext('Retrieve from ID token');
    }
    ngAfterContentInit() {
        if (!this.templateModel.accessTokenToUserDataMappings) {
            this.templateModel.accessTokenToUserDataMappings = {};
        }
    }
    get useIdToken() {
        return this.templateModel.useIdToken || false;
    }
    setUseIdToken(useIdToken) {
        this.templateModel.useIdToken = useIdToken;
        this.controlContainer.control.markAsDirty();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: UserDataMappingComponent, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: UserDataMappingComponent, selector: "c8y-sso-user-data-mapping", 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        User data mappings\n      </div>\n    </div>\n\n    <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n      <fieldset class=\"c8y-fieldset p-24\">\n        <legend>{{ 'Source of user data mapping' | translate }}</legend>\n        <c8y-form-group>\n          <label\n            title=\"{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}\"\n            class=\"c8y-radio input-sm\"\n          >\n            <input\n              type=\"radio\"\n              name=\"userAccessMappingSource\"\n              data-cy=\"user-access-mapping-from-access-token\"\n              [checked]=\"!useIdToken\"\n              (change)=\"setUseIdToken(false)\"\n            />\n            <span></span>\n            <span>{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}</span>\n          </label>\n          <label\n            title=\"{{ RETRIVE_FROM_ID_TOKEN | translate }}\"\n            class=\"c8y-radio input-sm\"\n          >\n            <input\n              type=\"radio\"\n              name=\"userAccessMappingSource\"\n              data-cy=\"user-access-mapping-from-id-token\"\n              [checked]=\"useIdToken\"\n              (change)=\"setUseIdToken(true)\"\n            />\n            <span></span>\n            <span>{{ RETRIVE_FROM_ID_TOKEN | translate }}</span>\n          </label>\n        </c8y-form-group>\n      </fieldset>\n\n      <fieldset class=\"c8y-fieldset p-24\">\n        <legend>\n          {{ 'Claim names' | translate }}\n          <button\n            class=\"btn-help btn-help--sm\"\n            type=\"button\"\n            [attr.aria-label]=\"'Help' | translate\"\n            popover=\"{{ CLAIM_NAMES | translate }}\"\n            placement=\"right\"\n            triggers=\"focus\"\n          ></button>\n        </legend>\n\n        <div class=\"row\">\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"firstName\"\n                class=\"control-label\"\n                translate\n              >\n                First name\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"firstName\"\n                id=\"firstName\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.firstNameClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'given_name' }\"\n              />\n            </c8y-form-group>\n          </div>\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"lastName\"\n                class=\"control-label\"\n                translate\n              >\n                Last name\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"lastName\"\n                id=\"lastName\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.lastNameClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'family_name' }\"\n              />\n            </c8y-form-group>\n          </div>\n        </div>\n        <div class=\"row\">\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"email\"\n                class=\"control-label\"\n                translate\n              >\n                Email\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"email\"\n                id=\"email\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.emailClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'email' }\"\n              />\n            </c8y-form-group>\n          </div>\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"phoneNumber\"\n                class=\"control-label\"\n                translate\n              >\n                Phone number\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"phoneNumber\"\n                id=\"phoneNumber\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.phoneNumberClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'phone_number' }\"\n              />\n            </c8y-form-group>\n          </div>\n        </div>\n      </fieldset>\n    </div>\n  </div>\n</div>\n", dependencies: [{ kind: "directive", type: i2.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i2.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: i3.PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: UserDataMappingComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-sso-user-data-mapping', 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        User data mappings\n      </div>\n    </div>\n\n    <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n      <fieldset class=\"c8y-fieldset p-24\">\n        <legend>{{ 'Source of user data mapping' | translate }}</legend>\n        <c8y-form-group>\n          <label\n            title=\"{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}\"\n            class=\"c8y-radio input-sm\"\n          >\n            <input\n              type=\"radio\"\n              name=\"userAccessMappingSource\"\n              data-cy=\"user-access-mapping-from-access-token\"\n              [checked]=\"!useIdToken\"\n              (change)=\"setUseIdToken(false)\"\n            />\n            <span></span>\n            <span>{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}</span>\n          </label>\n          <label\n            title=\"{{ RETRIVE_FROM_ID_TOKEN | translate }}\"\n            class=\"c8y-radio input-sm\"\n          >\n            <input\n              type=\"radio\"\n              name=\"userAccessMappingSource\"\n              data-cy=\"user-access-mapping-from-id-token\"\n              [checked]=\"useIdToken\"\n              (change)=\"setUseIdToken(true)\"\n            />\n            <span></span>\n            <span>{{ RETRIVE_FROM_ID_TOKEN | translate }}</span>\n          </label>\n        </c8y-form-group>\n      </fieldset>\n\n      <fieldset class=\"c8y-fieldset p-24\">\n        <legend>\n          {{ 'Claim names' | translate }}\n          <button\n            class=\"btn-help btn-help--sm\"\n            type=\"button\"\n            [attr.aria-label]=\"'Help' | translate\"\n            popover=\"{{ CLAIM_NAMES | translate }}\"\n            placement=\"right\"\n            triggers=\"focus\"\n          ></button>\n        </legend>\n\n        <div class=\"row\">\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"firstName\"\n                class=\"control-label\"\n                translate\n              >\n                First name\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"firstName\"\n                id=\"firstName\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.firstNameClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'given_name' }\"\n              />\n            </c8y-form-group>\n          </div>\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"lastName\"\n                class=\"control-label\"\n                translate\n              >\n                Last name\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"lastName\"\n                id=\"lastName\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.lastNameClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'family_name' }\"\n              />\n            </c8y-form-group>\n          </div>\n        </div>\n        <div class=\"row\">\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"email\"\n                class=\"control-label\"\n                translate\n              >\n                Email\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"email\"\n                id=\"email\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.emailClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'email' }\"\n              />\n            </c8y-form-group>\n          </div>\n          <div class=\"col-sm-6\">\n            <c8y-form-group>\n              <label\n                for=\"phoneNumber\"\n                class=\"control-label\"\n                translate\n              >\n                Phone number\n              </label>\n              <input\n                class=\"form-control\"\n                name=\"phoneNumber\"\n                id=\"phoneNumber\"\n                [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.phoneNumberClaimName\"\n                [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'phone_number' }\"\n              />\n            </c8y-form-group>\n          </div>\n        </div>\n      </fieldset>\n    </div>\n  </div>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.ControlContainer }], propDecorators: { templateModel: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 