import { __decorate, __metadata } from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd/message';
import { TranslateService } from '@ngx-translate/core';
import { API, DEF } from '../../../../api';
let IdentityClientsCreateComponent = class IdentityClientsCreateComponent {
    constructor(nzMessageService, translateService) {
        this.nzMessageService = nzMessageService;
        this.translateService = translateService;
        this.clientCreating = false;
        this.formGroup = new FormGroup({
            clientId: new FormControl('', {
                validators: Validators.required,
            }),
            clientName: new FormControl('', {
                validators: [Validators.required],
            }),
            description: new FormControl(''),
            clientUri: new FormControl(''),
            logoutUri: new FormControl(''),
            logoUri: new FormControl(''),
            clientType: new FormControl(0),
        });
        this.ok = new EventEmitter();
        this.visible = false;
        this.visibleChange = new EventEmitter();
    }
    handleAfterClose() {
        this.formGroup.reset({
            clientType: 0,
        });
    }
    handleCancel() {
        this.visibleChange.emit(false);
    }
    handleOk() {
        if (this.formGroup.invalid) {
            return;
        }
        this.clientCreating = true;
        API.Identity.ClientController.Post(undefined, new DEF.Identity.SaveClientQuery(this.formGroup.getRawValue())).subscribe({
            next: () => {
                this.clientCreating = false;
                this.visibleChange.emit(false);
                this.ok.emit();
                this.nzMessageService.success(this.translateService.instant('projects/fe-ng/src/lib/page/identity/clients/create/identity--clients--create.create_successfully'));
            },
            error: () => {
                this.clientCreating = false;
            },
        });
    }
};
IdentityClientsCreateComponent.ctorParameters = () => [
    { type: NzMessageService },
    { type: TranslateService }
];
__decorate([
    Output(),
    __metadata("design:type", EventEmitter)
], IdentityClientsCreateComponent.prototype, "ok", void 0);
__decorate([
    Input(),
    __metadata("design:type", Boolean)
], IdentityClientsCreateComponent.prototype, "visible", void 0);
__decorate([
    Output(),
    __metadata("design:type", EventEmitter)
], IdentityClientsCreateComponent.prototype, "visibleChange", void 0);
IdentityClientsCreateComponent = __decorate([
    Component({
        selector: 'kg---identity--clients--create',
        template: "<nz-modal\n  (nzAfterClose)=\"handleAfterClose()\"\n  (nzOnCancel)=\"handleCancel()\"\n  [nzBodyStyle]=\"{\n    padding: '12px 16px 6px 16px'\n  }\"\n  [nzCancelDisabled]=\"clientCreating\"\n  [nzClosable]=\"!clientCreating\"\n  [nzKeyboard]=\"false\"\n  [nzMaskClosable]=\"false\"\n  [nzTitle]=\"'projects/fe-ng/src/lib/page/identity/clients/create/identity--clients--create.title' | i18n\"\n  [nzVisible]=\"visible\"\n  nzWidth=\"748px\"\n>\n  <form (ngSubmit)=\"handleOk()\" [formGroup]=\"formGroup\" nz-form nzLayout=\"vertical\">\n    <nz-form-item>\n      <nz-form-label [nzFor]=\"'clientId'\" [nzRequired]=\"true\">\n        {{ 'projects/fe-ng/src/lib/page/identity/clients/identity--clients.client_id' | i18n }}:\n      </nz-form-label>\n      <nz-form-control [nzErrorTip]=\"'app__required' | i18n\">\n        <input [attr.id]=\"'clientId'\" [formControlName]=\"'clientId'\" nz-input />\n      </nz-form-control>\n    </nz-form-item>\n\n    <nz-form-item>\n      <nz-form-label [nzFor]=\"'clientName'\" [nzRequired]=\"true\">\n        {{ 'projects/fe-ng/src/lib/page/identity/clients/identity--clients.client_name' | i18n }}:\n      </nz-form-label>\n      <nz-form-control [nzErrorTip]=\"'app__required' | i18n\">\n        <input [attr.id]=\"'clientName'\" [formControlName]=\"'clientName'\" nz-input />\n      </nz-form-control>\n    </nz-form-item>\n\n    <nz-form-item>\n      <nz-form-label [nzFor]=\"'description'\">{{ 'app__description' | i18n }}:</nz-form-label>\n      <nz-form-control>\n        <input [attr.id]=\"'description'\" [formControlName]=\"'description'\" nz-input />\n      </nz-form-control>\n    </nz-form-item>\n\n    <nz-form-item>\n      <nz-form-label [nzFor]=\"'clientUri'\">\n        {{ 'projects/fe-ng/src/lib/page/identity/clients/create/identity--clients--create.client_uri' | i18n }}:\n      </nz-form-label>\n      <nz-form-control>\n        <input [attr.id]=\"'clientUri'\" [formControlName]=\"'clientUri'\" nz-input />\n      </nz-form-control>\n    </nz-form-item>\n\n    <nz-form-item>\n      <nz-form-label [nzFor]=\"'logoutUri'\">\n        {{ 'projects/fe-ng/src/lib/page/identity/clients/create/identity--clients--create.logout_uri' | i18n }}:\n      </nz-form-label>\n      <nz-form-control>\n        <input [attr.id]=\"'logoutUri'\" [formControlName]=\"'logoutUri'\" nz-input />\n      </nz-form-control>\n    </nz-form-item>\n\n    <nz-form-item>\n      <nz-form-label [nzFor]=\"'logoUri'\">\n        {{ 'projects/fe-ng/src/lib/page/identity/clients/create/identity--clients--create.logo_uri' | i18n }}:\n      </nz-form-label>\n      <nz-form-control>\n        <input [attr.id]=\"'logoUri'\" [formControlName]=\"'logoUri'\" nz-input />\n      </nz-form-control>\n    </nz-form-item>\n\n    <nz-form-item>\n      <nz-form-label [nzFor]=\"'clientType'\">\n        {{ 'projects/fe-ng/src/lib/page/identity/clients/create/identity--clients--create.client_type' | i18n }}:\n      </nz-form-label>\n      <nz-form-control>\n        <nz-select [attr.id]=\"'clientType'\" [formControlName]=\"'clientType'\">\n          <nz-option\n            [nzLabel]=\"'projects/fe-ng/src/lib/page/identity/shared/pipes/client-type/kg--identity--client-type.empty' | i18n\"\n            [nzValue]=\"0\"\n          ></nz-option>\n          <nz-option\n            [nzLabel]=\"'projects/fe-ng/src/lib/page/identity/shared/pipes/client-type/kg--identity--client-type.web_server_side_renderer' | i18n\"\n            [nzValue]=\"1\"\n          ></nz-option>\n          <nz-option\n            [nzLabel]=\"'projects/fe-ng/src/lib/page/identity/shared/pipes/client-type/kg--identity--client-type.web_hybrid' | i18n\"\n            [nzValue]=\"2\"\n          ></nz-option>\n          <nz-option [nzLabel]=\"'projects/fe-ng/src/lib/page/identity/shared/pipes/client-type/kg--identity--client-type.spa' | i18n\" [nzValue]=\"3\"></nz-option>\n          <nz-option\n            [nzLabel]=\"'projects/fe-ng/src/lib/page/identity/shared/pipes/client-type/kg--identity--client-type.native' | i18n\"\n            [nzValue]=\"4\"\n          ></nz-option>\n          <nz-option\n            [nzLabel]=\"'projects/fe-ng/src/lib/page/identity/shared/pipes/client-type/kg--identity--client-type.machine' | i18n\"\n            [nzValue]=\"5\"\n          ></nz-option>\n          <nz-option\n            [nzLabel]=\"'projects/fe-ng/src/lib/page/identity/shared/pipes/client-type/kg--identity--client-type.device' | i18n\"\n            [nzValue]=\"6\"\n          ></nz-option>\n        </nz-select>\n      </nz-form-control>\n    </nz-form-item>\n\n    <button [hidden]=\"true\"></button>\n  </form>\n\n  <div *nzModalFooter>\n    <button (click)=\"handleCancel()\" [disabled]=\"clientCreating\" nz-button nzType=\"default\">\n      <i nz-icon nzTheme=\"outline\" nzType=\"stop\"></i>\n      {{ 'app__cancel' | i18n }}\n    </button>\n\n    <button (click)=\"handleOk()\" [disabled]=\"formGroup.invalid\" [nzLoading]=\"clientCreating\" nz-button nzType=\"primary\">\n      <i nz-icon nzTheme=\"outline\" nzType=\"check\"></i>\n      {{ 'app__ok' | i18n }}\n    </button>\n  </div>\n</nz-modal>\n"
    }),
    __metadata("design:paramtypes", [NzMessageService, TranslateService])
], IdentityClientsCreateComponent);
export { IdentityClientsCreateComponent };
//# sourceMappingURL=data:application/json;base64, 