UNPKG

@infordata-web/portal-common-component-lib

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.14.

6,879 lines 445 kB
import { Injectable, ɵɵdefineInjectable, ɵɵinject, ApplicationRef, ChangeDetectorRef, Pipe, Injector, NgModule, EventEmitter, Component, Input, Output, ViewChild, Inject, ViewEncapsulation, Directive, TemplateRef, ViewContainerRef, ComponentFactoryResolver, ElementRef, HostListener } from '@angular/core';
import { AsyncPipe, CommonModule } from '@angular/common';
import { HttpClient, HttpClientModule, HttpHeaders } from '@angular/common/http';
import { Observable, Subject, defer, merge, of, ReplaySubject, BehaviorSubject, combineLatest, Subscription, iif } from 'rxjs';
import { switchMap, tap, shareReplay, map, scan, delay, startWith, pluck, auditTime, concatMap, catchError, filter, debounceTime, withLatestFrom, distinctUntilChanged, take } from 'rxjs/operators';
import { MatDialogModule, MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dialog';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import '@angular/localize/init';
import { FormGroup, FormControl, FormGroupDirective, Validators, NgControl, ReactiveFormsModule } from '@angular/forms';
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
import { SelectionModel } from '@angular/cdk/collections';
import { I18NService, I18nLibModule } from 'portal-i18n-lib';
import { MatSelectModule } from '@angular/material/select';
import { NativeDateAdapter, MatNativeDateModule, MatOptionModule, MAT_DATE_LOCALE, MAT_DATE_FORMATS, DateAdapter } from '@angular/material/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatRadioModule } from '@angular/material/radio';
import { MatCheckboxModule } from '@angular/material/checkbox';
import * as moment from 'moment';
import { UtenteDTO } from 'angular-portal-shell-app';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { MatListModule } from '@angular/material/list';
import { saveAs } from 'file-saver';
import { NgxJsonViewerModule } from 'ngx-json-viewer';
import { MatSortModule } from '@angular/material/sort';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MomentDateModule, MAT_MOMENT_DATE_ADAPTER_OPTIONS, MomentDateAdapter } from '@angular/material-moment-adapter';
import { ibanValidator } from 'ngx-iban';
import { NgxsFormPluginModule } from '@ngxs/form-plugin';

class ConfigurationService {
    constructor(configurazioneModulo) {
        this.nameApp = configurazioneModulo.nameApp;
        this.lingua$ = configurazioneModulo.lingua$;
        this.servicePaths = configurazioneModulo.servicePaths;
        this.userProfile = configurazioneModulo.userProfile;
        this.appPath = configurazioneModulo.appPath;
    }
}
ConfigurationService.decorators = [
    { type: Injectable }
];
ConfigurationService.ctorParameters = () => [
    { type: undefined }
];

class TranslateService {
    constructor(http, appRef, configurationService) {
        this.http = http;
        this.appRef = appRef;
        this.configurationService = configurationService;
        this.traduzioniLib$ = new Observable();
        this.communicatoreConEsterno$ = new Subject();
        this.i18nApiUrl = this.configurationService.servicePaths.get("I18N_MS_API_URL");
        console.log('[DAG_I18N_MS_URL]', this.i18nApiUrl);
        this.traduzioniLib$ = this.configurationService.lingua$.pipe(switchMap(language => this.getBundleTraduzioni$(language)), tap(_ => setTimeout(() => this.appRef.tick(), 0)), shareReplay());
    }
    getTraduzione$(codice) {
        return defer(() => this.traduzioniLib$.pipe(map(bundle => bundle.get(codice) || codice)));
    }
    getBundleTraduzioni$(language) {
        const url = this.i18nApiUrl + '/v1/labels/' + this.configurationService.nameApp + '/' + language;
        return this.http.get(url).pipe(map(this.reduceLabels), tap(_ => this.communicatoreConEsterno$.next(true)));
    }
    reduceLabels(labels) {
        const reduced = labels.reduce((acc, label) => {
            return acc.set(label["codiceLabel"], label["label"]);
        }, new Map());
        return reduced;
    }
}
TranslateService.ɵprov = ɵɵdefineInjectable({ factory: function TranslateService_Factory() { return new TranslateService(ɵɵinject(HttpClient), ɵɵinject(ApplicationRef), ɵɵinject(ConfigurationService)); }, token: TranslateService, providedIn: "root" });
TranslateService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
TranslateService.ctorParameters = () => [
    { type: HttpClient },
    { type: ApplicationRef },
    { type: ConfigurationService }
];

class TranslatePipe {
    constructor(translate, injector) {
        this.translate = translate;
        this.injector = injector;
        this.asyncPipe = new AsyncPipe(injector.get(ChangeDetectorRef));
    }
    transform(key) {
        return this.asyncPipe.transform(this.translate.getTraduzione$(key));
    }
    ngOnDestroy() {
        this.asyncPipe.ngOnDestroy();
    }
}
TranslatePipe.decorators = [
    { type: Pipe, args: [{
                name: 'traduzione'
            },] }
];
TranslatePipe.ctorParameters = () => [
    { type: TranslateService },
    { type: Injector }
];

class TranslateModule {
    constructor() { }
}
TranslateModule.decorators = [
    { type: NgModule, args: [{
                declarations: [TranslatePipe],
                imports: [
                    HttpClientModule,
                    CommonModule,
                    MatDialogModule,
                    BrowserModule,
                    BrowserAnimationsModule,
                ],
                providers: [TranslatePipe],
                exports: [TranslatePipe]
            },] }
];
TranslateModule.ctorParameters = () => [];

class ComponentOutputStatus {
    static of(status, output) {
        const componentStatus = new ComponentOutputStatus();
        componentStatus.status = status;
        componentStatus.output = output;
        return componentStatus;
    }
    ifValid(effect) {
        if (status) {
            effect(this.output);
        }
    }
    each(effect) {
        effect(this.output);
    }
    mapValue(mapper) {
        return ComponentOutputStatus.of(this.status, mapper(this.output));
    }
}

class ContattoDTO {
}

class MessageService {
    constructor() {
        this.defaultMessage = "required";
        this.messages = {
            maxlength: "validation-maxlength",
            requiredInfoDecreto: "validation-requiredInfoDecreto",
            requiredMail: "validation-requiredMail",
            cfInvalidoFormalmente: "validation-cfInvalidoFormalmente",
            invalidCF: "validation-invalidCF",
            nSentenza: "validation-nSentenza",
            required: "validation-required",
            email: "validation-email",
            tel: "validation-tel",
            iban: "validation-iban",
            partitaIVAInvalida: "validation-partitaIVAInvalida",
            partitaIVAMaxLen2: "validation-partitaIVAMaxLen2",
            money: "validation-money",
            invalidName: "validation-invalidName",
            invalidDate: "validation-invalidDate",
            pattern: "validation-pattern",
            invalidDateFormat: "validation-invalidDateFormat",
            requiredDefinizione: "validation-requiredDefinizione",
            validationServiceFailed: "validation-validationServiceFailed",
            cfValidationPG: "validation-cfValidationPG",
            cfDifferentRichiedente: "validation-cfDifferentRichiedente",
            requiredDomicilio: "validation-requiredDomicilio",
            requiredSede: "validation-requiredSede"
        };
    }
    produceMessage(errorType, control) {
        if (Object.keys(control.errors)[0]) {
            return this.getMessage(Object.keys(control.errors)[0]);
        }
        else {
            return this.getMessage(this.defaultMessage);
        }
    }
    getMessage(messageKey) {
        const message = this.messages[messageKey];
        if (message) {
            return message;
        }
        else {
            return messageKey;
        }
    }
    produceCFMessage(control) {
        let message = this.getMessage(this.defaultMessage);
        if (control.hasError("cfInvalidoFormalmente")) {
            message = this.messages["cfInvalidoFormalmente"];
        }
        else if (control.hasError("invalidCF")) {
            message = this.messages["invalidCF"];
        }
        else if (control.hasError("cfDifferentRichiedente")) {
            message = this.messages["cfDifferentRichiedente"];
        }
        return message;
    }
    getErrorData(control) {
        let message = this.getMessage(this.defaultMessage);
        if (control.hasError("required") && !control.errors.matDatepickerParse) {
            message = this.messages["required"];
        }
        else if (control.hasError("invalidDate")) {
            message = this.messages["invalidDate"];
        }
        else if (control.errors.matDatepickerParse) {
            message = this.messages["invalidDateFormat"];
        }
        return message;
    }
}
MessageService.ɵprov = ɵɵdefineInjectable({ factory: function MessageService_Factory() { return new MessageService(); }, token: MessageService, providedIn: "root" });
MessageService.decorators = [
    { type: Injectable, args: [{
                providedIn: "root",
            },] }
];
MessageService.ctorParameters = () => [];

class ContattiComponent {
    constructor(msg) {
        this.msg = msg;
        this.done = new EventEmitter();
    }
    ngOnInit() {
        // console.log('[ContattoDTO]', this.contatti);
        this.form = new FormGroup({});
        if (this.recapiti$) {
            this.initContatto();
        }
        const email = new FormControl({ value: this.contatti.email, disabled: false });
        this.form.addControl('email', email);
        const pec = new FormControl({ value: this.contatti.pec, disabled: false });
        this.form.addControl('pec', pec);
        const telefono = new FormControl({ value: this.contatti.telefono, disabled: false });
        this.form.addControl('telefono', telefono);
        const changes$ = this.form.valueChanges.pipe(map(_ => {
            const contattoNew = new ContattoDTO();
            contattoNew.email = email.value;
            contattoNew.pec = pec.value;
            contattoNew.telefono = telefono.value;
            return ComponentOutputStatus.of(this.form.valid, contattoNew);
        }));
        this.form.setValidators(form => {
            return (!form.get('pec').value && !form.get('email').value) ?
                { requiredMail: true } : null;
        });
        this.subscription = changes$.subscribe(newContact => this.done.emit(newContact));
    }
    initContatto() {
        this.listaEmail$ = this.recapiti$.pipe(map(r => r.filter(t => t.tipoRecapito.codice == "EMAIL")));
        this.listaPec$ = this.recapiti$.pipe(map(r => r.filter(t => t.tipoRecapito.codice == "PEC")));
        this.listaTelefono$ = this.recapiti$.pipe(map(r => r.filter(t => t.tipoRecapito.codice == "PHONE" ||
            t.tipoRecapito.codice == "CELL")));
        // console.log('[listaTelefono]', this.listaTelefono);
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    ngAfterContentInit() {
        this.form.updateValueAndValidity({ emitEvent: true });
    }
}
ContattiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-contatti',
                template: "\t<form [formGroup]=\"form\">\r\n\t\t<div class=\"collapse-body mt-2\">\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{'required' | traduzione}}{{'email-recapito' | traduzione}}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"email\">\r\n\t\t\t\t\t\t\t<mat-option [value]=\"null\">{{ 'seleziona' | traduzione }}</mat-option>\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let item of listaEmail$ | async\" [value]=\"item.id\">\r\n\t\t\t\t\t\t\t\t{{ item.recapito}}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"form.controls['email'].invalid\">\r\n\t\t\t\t\t\t\t{{msg.produceMessage('email', form.controls['email']) | traduzione}}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t<mat-hint *infoTip=\"'email-recapito'\"></mat-hint>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{'required' | traduzione}}{{'pec-recapito' | traduzione}}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"pec\">\r\n\t\t\t\t\t\t\t<mat-option [value]=\"null\"> {{ 'seleziona' | traduzione }} </mat-option>\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let item of listaPec$ | async\" [value]=\"item.id\">\r\n\t\t\t\t\t\t\t\t{{ item.recapito}}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"form.controls['pec'].invalid\">\r\n\t\t\t\t\t\t\t{{msg.produceMessage('email', form.controls['pec']) | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t<mat-hint *infoTip=\"'pec-recapito'\"></mat-hint>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{'telefono-recapito' | traduzione}}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"telefono\">\r\n\t\t\t\t\t\t\t<mat-option [value]=\"null\"> {{ 'seleziona' | traduzione }} </mat-option>\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let item of listaTelefono$ | async\" [value]=\"item.id\">\r\n\t\t\t\t\t\t\t\t{{ item.recapito}}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"form.controls['telefono'].invalid\">\r\n\t\t\t\t\t\t\t{{msg.produceMessage('tel', form.controls['telefono']) | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t<mat-hint *infoTip=\"'telefono-recapito'\"></mat-hint>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<br><br>\r\n\t\t<div class=\"col-md-12\">\r\n\t\t\t<mat-error *ngIf=\"form.getError('requiredMail')\">\r\n\t\t\t\t{{msg.produceMessage('requiredMail', form) | traduzione }}\r\n\t\t\t</mat-error>\r\n\t\t</div>\r\n\t</form>\r\n",
                styles: [""]
            },] }
];
ContattiComponent.ctorParameters = () => [
    { type: MessageService }
];
ContattiComponent.propDecorators = {
    recapiti$: [{ type: Input }],
    contatti: [{ type: Input }],
    done: [{ type: Output }]
};

class DatiAnagraficiComponent {
    constructor() { }
    ngOnChanges(changes) { }
    ngOnInit() {
        this.form = new FormGroup({});
    }
}
DatiAnagraficiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-dati-anagrafici',
                template: "<div form [formGroup]=\"form\" *ngIf=\"datiPersonaFisica$ | async as datiPersonaFisica\">\r\n\t<!-- <h2 class=\"border-bottom font-weight-bold h3\">{{'dati-anagrafici' | traduzione}}</h2> -->\r\n\t<h3 class=\"border-bottom font-weight-bold h5\"><info-tip-label label=\"dati-anagrafici\"></info-tip-label></h3>\r\n\t<div class=\"row mt-3\">\r\n\t\t<div class=\"col-md-3\">\r\n\t\t\t<p class=\"mb-0 font-weight-bold\">{{'codice-fiscale' | traduzione}}:</p>\r\n\t\t\t<p>{{datiPersonaFisica.codiceFiscale}}</p>\r\n\t\t\t<mat-hint *infoTip=\"'codice-fiscale'\"></mat-hint>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"col-md-3\">\r\n\t\t\t<p class=\"mb-0 font-weight-bold\">{{'nome' | traduzione}}:</p>\r\n\t\t\t<p>{{datiPersonaFisica.nome}}</p>\r\n\t\t\t<mat-hint *infoTip=\"'nome'\"></mat-hint>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"col-md-3\">\r\n\t\t\t<p class=\"mb-0 font-weight-bold\">{{'cognome' | traduzione}}:</p>\r\n\t\t\t<p>{{datiPersonaFisica.cognome}}</p>\r\n\t\t\t<mat-hint *infoTip=\"'cognome'\"></mat-hint>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"col-md-3\">\r\n\t\t\t<p class=\"mb-0 font-weight-bold\">{{'data-nascita' | traduzione}}:</p>\r\n\t\t\t<p>{{datiPersonaFisica.dataNascita}}</p>\r\n\t\t\t<mat-hint *infoTip=\"'data-nascita'\"></mat-hint>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<div class=\"row mt-4\">\r\n\t\t<div class=\"col-md-3\">\r\n\t\t\t<p class=\"mb-0 font-weight-bold\">{{'stato-nascita' | traduzione}}:</p>\r\n\t\t\t<p>{{datiPersonaFisica.nazioneNascita.denominazione}}</p>\r\n\t\t\t<mat-hint *infoTip=\"'stato-nascita'\"></mat-hint>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"col-md-3\">\r\n\t\t\t<p class=\"mb-0 font-weight-bold\">{{'sesso' | traduzione}}:</p>\r\n\t\t\t<p>{{datiPersonaFisica.tipoSesso.codice}}</p>\r\n\t\t\t<mat-hint *infoTip=\"'sesso'\"></mat-hint>\r\n\t\t</div>\r\n\t</div>\r\n</div>\r\n",
                styles: [""]
            },] }
];
DatiAnagraficiComponent.ctorParameters = () => [];
DatiAnagraficiComponent.propDecorators = {
    datiPersonaFisica$: [{ type: Input }]
};

class DatiResidenzaComponent {
    constructor() {
        this.indirizzoToltip = "INDIRIZZO";
        this.civicoToltip = "civico";
        this.nazioneToltip = "nazione";
        this.provinciaToltip = "provincia";
        this.regioneToltip = "regione";
        this.comuneToltip = "comune";
        this.capToltip = "cap";
    }
    ngOnChanges(changes) { }
    ngOnInit() {
        this.form = new FormGroup({});
    }
}
DatiResidenzaComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-dati-residenza',
                template: "<!-- <p>Dati Residenza works!</p> -->\r\n<mat-expansion-panel class=\"panel\" [expanded]=\"true\">\r\n\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\r\n\t\t<mat-panel-title>\r\n\t\t\t<!-- <h3>{{'dati-residenza' | traduzione}}</h3> -->\r\n\t\t\t<h3 class=\"mb-0 h5\"><info-tip-label label=\"dati-residenza\"></info-tip-label></h3>\r\n\t\t</mat-panel-title>\r\n\t</mat-expansion-panel-header>\r\n\t<div form [formGroup]=\"form\" class=\"collapse-body mt-2\">\r\n\t\t<ng-container *ngIf=\"residenza$ | async as residenza\">\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-md-10\">\r\n\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'indirizzo' | traduzione }}:</p>\r\n\t\t\t\t\t<p>{{residenza?.indirizzo}}</p>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"indirizzoToltip\"></mat-hint> -->\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-2\">\r\n\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'civico' | traduzione }}:</p>\r\n\t\t\t\t\t<p>{{residenza?.civico}}</p>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"civicoToltip\"></mat-hint> -->\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'nazione' | traduzione }}:</p>\r\n\t\t\t\t\t<p>{{residenza?.nazione?.denominazione}}</p>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"nazioneToltip\"></mat-hint> -->\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-8\">\r\n\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'regione' | traduzione }}:</p>\r\n\t\t\t\t\t<p>{{residenza?.regione?.denominazione}}</p>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"regioneToltip\"></mat-hint> -->\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'provincia' | traduzione }}:</p>\r\n\t\t\t\t\t<p>{{residenza?.provincia?.denominazione}}</p>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"provinciaToltip\"></mat-hint> -->\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'comune' | traduzione }}:</p>\r\n\t\t\t\t\t<p>{{residenza?.comune?.denominazione}}</p>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"comuneToltip\"></mat-hint> -->\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'cap' | traduzione }}:</p>\r\n\t\t\t\t\t<p>{{residenza?.cap}}</p>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"capToltip\"></mat-hint> -->\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</ng-container>\r\n\t</div>\r\n</mat-expansion-panel>\r\n",
                styles: [""]
            },] }
];
DatiResidenzaComponent.ctorParameters = () => [];
DatiResidenzaComponent.propDecorators = {
    residenza$: [{ type: Input }]
};

class DomicilioDTO {
}

class Tuple {
    static of(_1, _2) {
        const tuple = new Tuple();
        tuple._1 = _1;
        tuple._2 = _2;
        return tuple;
    }
}

// @dynamic
class ComponentReducer {
    static reducer2(m1, m2, isComplete, startValue) {
        const cardinality = 2;
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducer3(m1, m2, m3, isComplete, startValue) {
        const cardinality = 3;
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2), ComponentReducer.ordinal(m3, 3));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducer4(m1, m2, m3, m4, isComplete, startValue) {
        const cardinality = 4;
        //TODO
        // m3.subscribe(_ => console.log("m3", _))
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2), ComponentReducer.ordinal(m3, 3), ComponentReducer.ordinal(m4, 4));
        // merged.subscribe(_ => console.log("merged", _));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducer5(m1, m2, m3, m4, m5, isComplete, startValue) {
        const cardinality = 5;
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2), ComponentReducer.ordinal(m3, 3), ComponentReducer.ordinal(m4, 4), ComponentReducer.ordinal(m5, 5));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducer6(m1, m2, m3, m4, m5, m6, isComplete, startValue) {
        const cardinality = 6;
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2), ComponentReducer.ordinal(m3, 3), ComponentReducer.ordinal(m4, 4), ComponentReducer.ordinal(m5, 5), ComponentReducer.ordinal(m6, 6));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducer7(m1, m2, m3, m4, m5, m6, m7, isComplete, startValue) {
        const cardinality = 7;
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2), ComponentReducer.ordinal(m3, 3), ComponentReducer.ordinal(m4, 4), ComponentReducer.ordinal(m5, 5), ComponentReducer.ordinal(m6, 6), ComponentReducer.ordinal(m7, 7));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducer8(m1, m2, m3, m4, m5, m6, m7, m8, isComplete, startValue) {
        const cardinality = 8;
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2), ComponentReducer.ordinal(m3, 3), ComponentReducer.ordinal(m4, 4), ComponentReducer.ordinal(m5, 5), ComponentReducer.ordinal(m6, 6), ComponentReducer.ordinal(m7, 7), ComponentReducer.ordinal(m8, 8));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducer9(m1, m2, m3, m4, m5, m6, m7, m8, m9, isComplete, startValue) {
        const cardinality = 9;
        const merged = merge(ComponentReducer.ordinal(m1, 1), ComponentReducer.ordinal(m2, 2), ComponentReducer.ordinal(m3, 3), ComponentReducer.ordinal(m4, 4), ComponentReducer.ordinal(m5, 5), ComponentReducer.ordinal(m6, 6), ComponentReducer.ordinal(m7, 7), ComponentReducer.ordinal(m8, 8), ComponentReducer.ordinal(m9, 9));
        return ComponentReducer.reducerInternal(merged, startValue, cardinality, isComplete);
    }
    static reducerInternal(mergedMutators, startValue, cardinality, isComplete) {
        const accumulatorAndValidity = Tuple.of([], startValue); // startValue è un valore normalizzato
        return mergedMutators.pipe(
        //TODO
        // tap(_ => console.log("mergedMutators", _)),
        scan((accumulator, mutator) => {
            accumulator._2.mapValue(mutator._2.output);
            accumulator._1[mutator._1] = mutator._2.status;
            //TODO
            // console.log("muttator", accumulator._2.mapValue(mutator._2.output));
            // console.log("accumulator", accumulator);
            return accumulator;
        }, accumulatorAndValidity //valore iniziale
        ), map((accumulator) => {
            const validities = accumulator._1;
            const isValid = isComplete(accumulator._2.output) &&
                validities.reduce((acc, x) => acc && (x == null || x), true);
            return ComponentOutputStatus.of(isValid, accumulator._2.output);
        }), delay(0), startWith(startValue));
    }
    static ordinal(mutator, order) {
        return mutator.pipe(map(x => Tuple.of(order, x)));
    }
}

class DatiDomicilioComponent {
    constructor(msg) {
        this.msg = msg;
        this.done = new EventEmitter();
        this.displayedColumns = ['tipo', 'presso', 'indirizzo', 'preferito', 'seleziona'];
        this.changesRecapito$ = new Subject();
        this.validazioneDomicilio = false;
        this.tipoToltip = "tipo";
        this.pressoToltip = "presso";
        this.indirizzoToltip = "indirizzo";
        this.selezionaToltip = "seleziona";
        this.preferitoToltip = "preferito";
    }
    ngOnInit() {
        // console.log('[domicilio]', this.domicilio);
        console.log('[domicili]', this.domicili);
        this.form = new FormGroup({});
        let valid = true;
        if (!this.domicilio) {
            this.initDomicilio();
            valid = false;
        }
        this.dataSource = new MatTableDataSource(this.domicili);
        this.selection = new SelectionModel(false, []);
        this.initialSelection();
        const domicilio = new FormControl({ value: this.domicilio.hasSelezionatoDomicilio, disabled: false });
        this.form.addControl('domicilio', domicilio);
        const selected = new FormControl({ value: '', disabled: false });
        this.form.addControl('selected', selected);
        this.checkDomicilio$ = domicilio.valueChanges.pipe(shareReplay())
            .pipe(tap(checkDomicilio => {
            if (checkDomicilio == false) {
                this.selection.clear();
            }
        }), startWith(this.domicilio.idDomicilioSelezionato != null));
        const changesCheckDomicilio$ = this.checkDomicilio$.pipe(map(checkDomicilio => ComponentOutputStatus.of(true, (domicilio) => {
            domicilio.hasSelezionatoDomicilio = checkDomicilio;
            if (checkDomicilio == false) {
                domicilio.contatto.email = null;
                domicilio.contatto.pec = null;
                domicilio.contatto.telefono = null;
                this.form.get('selected').setValue('');
            }
        })));
        const changesDomicilio$ = this.selection.changed.pipe(tap((value) => {
            // console.log("changesDomicilio$", value);
            this.validazioneDomicilio = value.added.length > 0 ? false : true;
        }), map(change => ComponentOutputStatus.of(true, domicilio => {
            domicilio.idDomicilioSelezionato = change.added.length > 0 ? change.added[0].id : null;
        })));
        this.subscription = ComponentReducer.reducer3(changesCheckDomicilio$, changesDomicilio$, this.changesRecapito$, domicilio => {
            return domicilio.hasSelezionatoDomicilio ?
                domicilio.idDomicilioSelezionato != null : true;
        }, ComponentOutputStatus.of(true, this.domicilio))
            .subscribe(domicilio => {
            // console.log('[DatiDomicilioComponent] status', status);
            this.done.emit(domicilio);
        });
        this.form.setValidators(form => {
            if (form.get('domicilio').value && !form.get('selected').value) {
                this.validazioneDomicilio = true;
                return { requiredDomicilio: true };
            }
            else {
                return null;
            }
            //TODO
            // return form.get('domicilio').value &&
            // 	!form.get('selected').value ?
            // 	// this.selection.isEmpty() ?
            // 	// this.selection.selected.length === 1 ?
            // 	{ requiredDomicilio: true } : null;
        });
    }
    initialSelection() {
        if (this.domicilio.idDomicilioSelezionato) {
            setTimeout(() => {
                this.dataSource.data
                    .forEach(row => {
                    if (row.id == this.domicilio.idDomicilioSelezionato) {
                        this.selection.select(row);
                        this.validazioneDomicilio = false;
                    }
                });
            }, 0);
        }
    }
    initDomicilio() {
        this.domicilio = new DomicilioDTO();
        this.domicilio.contatto = new ContattoDTO();
    }
    recapitiReady(recapitiStatus) {
        // console.log('[recapitiReady]', recapitiStatus);
        this.changesRecapito$.next(recapitiStatus.mapValue((contatto) => (dich) => (dich.contatto = contatto)));
    }
    ngOnDestroy() {
        if (this.subscription != null) {
            this.subscription.unsubscribe();
        }
    }
}
DatiDomicilioComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-dati-domicilio',
                template: "<mat-expansion-panel class=\"panel\" [expanded]=\"domicilio.hasSelezionatoDomicilio\">\r\n\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\r\n\t\t<mat-panel-title>\r\n\t\t\t<!-- <h3>{{'domicilio' | traduzione}}</h3> -->\r\n\t\t\t<h3 class=\"mb-0 h5\"><info-tip-label label=\"domicilio\"></info-tip-label></h3>\r\n\t\t</mat-panel-title>\r\n\t</mat-expansion-panel-header>\r\n\t<form [formGroup]=\"form\">\r\n\t\t<div class=\"collapse-body mt-2\">\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<section class=\"example-section col-md-2\">\r\n\t\t\t\t\t<mat-checkbox\r\n\t\t\t\t\t\tformControlName=\"domicilio\"\r\n\t\t\t\t\t\tclass=\"example-margin\">\r\n\t\t\t\t\t\t<!-- {{'seleziona-domicilio' | traduzione}} -->\r\n\t\t\t\t\t\t<info-tip-label label=\"seleziona-domicilio\"></info-tip-label>\r\n\t\t\t\t\t</mat-checkbox>\r\n\t\t\t\t</section>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<ng-container *ngIf=\"checkDomicilio$ | async\">\r\n\r\n\t\t<h4 class=\"border-bottom font-weight-bold mt-4 h5\"><info-tip-label label=\"domicili-inseriti\"></info-tip-label></h4>\r\n    <ng-container *ngIf=\"domicili?.length > 0; else noDomicili\">\r\n\t\t\t<mat-table [dataSource]=\"dataSource\" class=\"mat-elevation-z8 mt-3 border\">\r\n\r\n\t\t\t\t<!-- Tipo Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"tipo\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'tipo' | traduzione}} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.tipoDomicilio.descrizione}} </mat-cell>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"tipoToltip\"></mat-hint> -->\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Presso Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"presso\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'presso' | traduzione}} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.indirizzo.presso}} </mat-cell>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"pressoToltip\"></mat-hint> -->\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Indirizzo Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"indirizzo\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'indirizzo' | traduzione}} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\">\r\n\t\t\t\t\t\t<span *ngIf=\"!element.indirizzo.estero\"> {{element.indirizzo.indirizzo}}\r\n\t\t\t\t\t\t\t{{element.indirizzo.civico}} {{element.indirizzo.cap}} -\r\n\t\t\t\t\t\t\t{{element.indirizzo.comune.denominazione}} {{element.indirizzo.provinciaLabel}}</span>\r\n\t\t\t\t\t\t<span *ngIf=\"element.indirizzo.estero\"> {{element.indirizzo.nazione.denominazione}} -\r\n\t\t\t\t\t\t\t{{element.indirizzo.indirizzo}} </span>\r\n\t\t\t\t\t</mat-cell>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"indirizzoToltip\"></mat-hint> -->\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Preferito Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"preferito\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'preferito' | traduzione}} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\">\r\n\t\t\t\t\t\t<!-- <mat-checkbox class=\"example-margin\" [disabled]=\"true\">\r\n\t\t\t\t\t\t</mat-checkbox> -->\r\n\t\t\t\t\t\t<!-- <mat-checkbox *ngIf=\"!element.preferito\" class=\"example-margin\" [disabled]=\"true\">\r\n\t\t\t\t\t\t</mat-checkbox> -->\r\n\t\t\t\t\t\t<mat-checkbox *ngIf=\"element.preferito\" class=\"example-margin\" [checked]=\"true\"\r\n\t\t\t\t\t\t\t[disabled]=\"true\"></mat-checkbox>\r\n\t\t\t\t\t</mat-cell>\r\n\t\t\t\t\t<!-- <mat-hint *infoTip=\"preferitoToltip\"></mat-hint> -->\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Selezione Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"seleziona\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'seleziona' | traduzione}}\r\n\t\t\t\t\t \t<!-- <mat-checkbox (change)=\"$event ? masterToggle() : null\"\r\n\t\t\t\t\t\t\t\t\t[checked]=\"selection.hasValue() && isAllSelected()\"\r\n\t\t\t\t\t\t\t\t\t[indeterminate]=\"selection.hasValue() && !isAllSelected()\"\r\n\t\t\t\t\t\t\t\t\tformControlName=\"selected2\">\r\n\t\t\t\t\t\t</mat-checkbox> -->\r\n\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"selezionaToltip\"></mat-hint> -->\r\n\t\t\t\t\t</mat-header-cell>\r\n\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let row\">\r\n\t\t\t\t\t\t<mat-checkbox\r\n\t\t\t\t\t\t\t(click)=\"$event.stopPropagation()\"\r\n\t\t\t\t\t\t\t(change)=\"$event ? selection.toggle(row) : null\"\r\n\t\t\t\t\t\t\t[checked]=\"selection.isSelected(row)\"\r\n\t\t\t\t\t\t\tformControlName=\"selected\">\r\n\t\t\t\t\t\t</mat-checkbox>\r\n\t\t\t\t\t</mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\r\n\t\t\t\t<mat-row *matRowDef=\"let row; columns: displayedColumns;\"></mat-row>\r\n\r\n\t\t\t</mat-table>\r\n\t\t\t<div class=\"collapse-body mt-2\">\r\n\t\t\t\t<div class=\"col-md-12\">\r\n\t\t\t\t\t<mat-error *ngIf=\"validazioneDomicilio\">\r\n\t\t\t\t\t\t{{'validation-requiredDomicilio' | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</ng-container>\r\n\t\t<ng-template #noDomicili>\r\n\t\t\t<div class=\"collapse-body mt-2\">\r\n\t\t\t\t<div class=\"col-md-12\">\r\n\t\t\t\t\t<mat-error >\r\n\t\t\t\t\t\t{{'no-domicili' | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</ng-template>\r\n\r\n\t\t\t<div class=\"collapse-body mt-2\" *ngIf=\"(recapiti$ | async)\">\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<div class=\"col-12\">\r\n\t\t\t\t\t\t<mat-card>\r\n\t\t\t\t\t\t\t<lib-contatti\r\n\t\t\t\t\t\t\t\t[contatti]=\"domicilio.contatto\"\r\n\t\t\t\t\t\t\t\t[recapiti$]=\"recapiti$\"\r\n\t\t\t\t\t\t\t\t(done)=\"recapitiReady($event)\"\r\n\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t</lib-contatti>\r\n\t\t\t\t\t\t</mat-card>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\r\n\t\t</ng-container>\r\n\t</form>\r\n</mat-expansion-panel>\r\n",
                styles: [""]
            },] }
];
DatiDomicilioComponent.ctorParameters = () => [
    { type: MessageService }
];
DatiDomicilioComponent.propDecorators = {
    domicili: [{ type: Input }],
    recapiti$: [{ type: Input }],
    domicilio: [{ type: Input }],
    done: [{ type: Output }],
    formGroupDirective: [{ type: ViewChild, args: [FormGroupDirective,] }]
};

class DatiRichiedenteDTO {
}

class RichiedenteComponent {
    constructor() {
        this.nextStep = new EventEmitter();
        this.salvaBozza = new EventEmitter();
        this.changesPersonaFisica$ = new Subject();
        this.changesResidenza$ = new Subject();
        this.changesRecapito$ = new Subject();
        this.changesDomicilio$ = new Subject();
        //isFormValid: boolean;
        this.direction = "only-forward";
        this.isFinal = false;
        this.isDomicilioElettoValid = false;
    }
    ngOnInit() {
        //console.log('[DatiRichiedenteDTO]', this.datiRichiedente);
        this.form = new FormGroup({});
        let valid = true;
        if (!this.datiRichiedente) {
            this.initRichiedente();
            valid = false;
        }
        const dichiarante$ = ComponentReducer.reducer4(this.changesPersonaFisica$, this.changesResidenza$, this.changesRecapito$, this.changesDomicilio$, (dich) => {
            // console.log("[dich]", dich);
            // console.log("[hasSelezionatoDomicilio]", dich.domicilio.hasSelezionatoDomicilio);
            let isValid;
            if (!dich.domicilio.hasSelezionatoDomicilio && dich.domicilio.hasSelezionatoDomicilio != undefined) {
                isValid = dich.contatto != null;
            }
            else {
                isValid = dich.domicilio != null;
            }
            //TODO
            // this.isDomicilioElettoValid
            // 	? dich.domicilio != null // se il domicilio non è validato controlla se diverso da null se lo è torna false altrimenti true.
            // 	: true // se già è validato torna true.
            // return (
            // 	dich.contatto != null ||  // basterebbe uno dei due diverso da null per tronare false
            // 	this.isDomicilioElettoValid
            // );
            valid = isValid;
            return isValid;
        }, ComponentOutputStatus.of(valid, this.datiRichiedente) // normalizzazione componente dichiarante
        );
        dichiarante$.subscribe((dichiarante) => {
            console.log("[RichiedenteComponent] datiRichiedente", dichiarante);
            //TODO
            //this.isFormValid = dichiarante.status;
            if (dichiarante.output.domicilio.hasSelezionatoDomicilio == false) {
                //TODO
                // this.isDichiaranteValid = dichiarante.output.infoContatto.email != null || dichiarante.output.infoContatto.pec != null;
                this.isDichiaranteValid = this.hasSelecteDichiarante(dichiarante);
            }
            else {
                //TODO
                // this.isDichiaranteValid = (dichiarante.output.infoContatto.email != null || dichiarante.output.infoContatto.pec != null) &&
                // 	(dichiarante.output.domicilio.idDomicilioSelezionato != null) &&
                // 	(dichiarante.output.domicilio.contatto.email != null || dichiarante.output.domicilio.contatto.pec != null);
                this.isDichiaranteValid = this.hasSelecteDichiaranteAnd(dichiarante);
            }
        });
        //TODO
        //--------viene passato dall'input--------//
        // this.personaFisica$ = this.personaFisicaService.getPersonaFisicaUtente$()
        //   .pipe(shareReplay());
        this.datiPersonaFisica$ = this.personaFisica$
            .pipe(pluck("datiPersonaFisica"));
        this.residenza$ = this.personaFisica$
            .pipe(pluck("residenza"));
        this.recapiti$ = this.personaFisica$
            .pipe(pluck("recapiti"), map(recapiti => recapiti || []));
        this.domicili$ = this.personaFisica$
            .pipe(pluck("domicili"));
    }
    recapitiReady(recapitiStatus) {
        // console.log('[racapitiStatus]', recapitiStatus);
        this.changesRecapito$.next(recapitiStatus.mapValue((contatto) => (dich) => {
            return dich.contatto = contatto;
        }));
    }
    domiciliReady(domiciliStatus) {
        // console.log('[domiciliStatus]', domiciliStatus);
        this.changesDomicilio$.next(domiciliStatus.mapValue((domicilio) => (dich) => {
            dich.domicilio = domicilio;
            //TODO: fix
            // (this.isDomicilioElettoValid = domicilio.idDomicilioSelezionato != null);
        }));
    }
    initRichiedente() {
        this.datiRichiedente = new DatiRichiedenteDTO();
        this.datiRichiedente.contatto = new ContattoDTO();
        //TODO
        this.datiRichiedente.domicilio = new DomicilioDTO();
        this.datiRichiedente.domicilio.contatto = new ContattoDTO();
        this.datiRichiedente.domicilio.idDomicilioSelezionato = null;
    }
    forward(_) {
        this.nextStep.emit(this.datiRichiedente);
    }
    complete(_) { }
    onSalvaBozza(_) {
        this.salvaBozza.emit(this.datiRichiedente);
    }
    ngOnDestroy() {
        if (this.domicilioElettoSub) {
            this.domicilioElettoSub.unsubscribe();
        }
    }
    hasSelecteDichiarante(dichiarante) {
        return dichiarante.output.contatto.email != null || dichiarante.output.contatto.pec != null;
        ;
    }
    hasSelecteDichiaranteAnd(dichiarante) {
        return this.hasSelecteDichiarante(dichiarante) &&
            (dichiarante.output.domicilio.idDomicilioSelezionato != null) &&
            (dichiarante.output.domicilio.contatto.email != null || dichiarante.output.domicilio.contatto.pec != null);
    }
}
RichiedenteComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-richiedente',
                template: "<div class=\"mt-3 mb-5\" [formGroup]=\"form\">\r\n\t\t<lib-dati-anagrafici\r\n\t\t\t[datiPersonaFisica$]=\"datiPersonaFisica$\"\r\n\t\t>\r\n\t\t</lib-dati-anagrafici>\r\n\t<div class=\"mt-4\"></div>\r\n\t<lib-dati-residenza\r\n\t\t[residenza$]=\"residenza$\"\r\n\t>\r\n\t</lib-dati-residenza>\r\n\r\n\t<mat-expansion-panel class=\"panel mt-4\" [expanded]=\"true\">\r\n\t\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\r\n\t\t\t<mat-panel-title>\r\n\t\t\t\t<!-- <h3>{{'recapiti' | traduzione}}</h3> -->\r\n\t\t\t\t<h3 class=\"mb-0 h5\"><info-tip-label label=\"recapiti\"></info-tip-label></h3>\r\n\t\t\t</mat-panel-title>\r\n\t\t</mat-expansion-panel-header>\r\n\t\t<lib-contatti\r\n\t\t\t[contatti]=\"datiRichiedente.contatto\"\r\n\t\t\t[recapiti$]=\"recapiti$\"\r\n\t\t\t(done)=\"recapitiReady($event)\"\r\n\t\t>\r\n\t\t</lib-contatti>\r\n\t</mat-expansion-panel>\r\n\t<div class=\"mt-4\"></div>\r\n\t<div *ngIf=\"(personaFisica$ | async)\">\r\n\t\t<lib-dati-domicilio\r\n\t\t\t[domicilio]=\"datiRichiedente.domicilio\"\r\n\t\t\t[domicili]=\"domicili$ | async\"\r\n\t\t\t[recapiti$]=\"recapiti$\"\r\n\t\t\t(done)=\"domiciliReady($event)\"\r\n\t\t>\r\n\t\t</lib-dati-domicilio>\r\n\t</div>\r\n\t<lib-stepper-navigator\r\n\t\t[form]=\"form\"\r\n\t\t[direction]=\"direction\"\r\n\t\t[isFinal]=\"isFinal\"\r\n\t\t[isContainerValid]=\"isDichiaranteValid\"\r\n\t\t(goForward)=\"forward($event)\"\r\n\t\t(salvaBozza)=\"onSalvaBozza($event)\"\r\n\t\t(complete)=\"complete($event)\"\r\n\t>\r\n\t</lib-stepper-navigator>\r\n</div>\r\n",
                styles: [".mat-card{border-radius:0!important;border-top:5px solid #0a2644}.divider{background-color:#737373;height:1px;width:100%}.mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fff!important}.mat-select-value{max-width:100%;width:100%!important}"]
            },] }
];
RichiedenteComponent.ctorParameters = () => [];
RichiedenteComponent.propDecorators = {
    datiRichiedente: [{ type: Input }],
    personaFisica$: [{ type: Input }],
    nextStep: [{ type: Output }],
    salvaBozza: [{ type: Output }]
};

const TipiRichiedente = {
    RICORRENTE: 'Ricorrente',
    EREDE_RICORRENTE: 'Erede del Ricorrente',
    PERSONA_GIURIDICA_RAPPRESENTANTE_LEGALE: 'Persona Giuridica/Legale rappresentante di Società/Ditta/Ente',
    PROCURATORE_ANTISTATARIO: 'Procuratore Antistatario',
    EREDE_PROCURATORE_ANTISTATARIO: 'Erede del procuratore antistatario',
    TUTORE_PROCURATORE_LEGALE: 'Tutore/Procuratore legale',
    CURATORE_FALLIMENTARE: 'Curatore Fallimentare',
    ME_MEDESIMO: "Me medesimo"
};
const CodiceTipiRichiedente = {
    CODICE_RICORRENTE: 'RICORRENTE',
    CODICE_PROCURATORE_ANTISTATARIO: 'ANTISTATARIO',
    CODICE_EREDE_RICORRENTE: 'EREDE_RICORRENTE',
    CODICE_PERSONA_GIURIDICA_RAPPRESENTANTE_LEGALE: 'RAPPR_LEG',
    CODICE_EREDE_PROCURATORE_ANTISTATARIO: 'EREDE_ANTISTATARIO',
    CODICE_TUTORE_PROCURATORE_LEGALE: 'TUT',
    CODICE_CURATORE_FALLIMENTARE: 'CURATORE_FALLIMENTARE',
    CODICE_ME_MEDESIMO: 'ME_MEDESIMO'
};

class InfoAnagrafichePFDTO {
}

class InfoNascitaPFDTO {
}

class NaturaRichiedenteDTO {
}

class PersonaFisicaBaseDTO {
}
function nuovaPFBase() {
    const newPF = new PersonaFisicaBaseDTO();
    newPF.cognome = 'nuova-persona-fisica';
    newPF.nome = '';
    newPF.idPersona = 'nuovo';
    newPF.codTipoDelega = '';
    return newPF;
}

class PersonaFisicaDTO {
}

class PersonaGiuridicaBaseDTO {
}
function nuovaPGBase() {
    let newPG = new PersonaGiuridicaBaseDTO();
    newPG.ragioneSociale = 'nuova-persona-giuridica';
    newPG.idPersona = 'nuovo';
    newPG.codTipoDelega = '';
    return newPG;
}

class PersonaGiuridicaDTO {
}

class RappresentanteDTO {
}

class MieDelegheDTO {
}

class DelegheService {
    constructor(http, configurationService) {
        this.http = http;
        this.configurationService = configurationService;
        this.DELEGA_VALIDATA = 'TRUE';
        this.rst_mock = [
            {
                "codiceFiscale": "TR",
                "codiceOrdinante": "Terni",
                "dataFine": new Date('10/06/2025'),
                "dataInizio": new Date('10/06/2025'),
                "denominazioneRTS": "RTS 1",
                "provinceCompetenza": ["TR"]
            },
            {
                "codiceFiscale": "RM",
                "codiceOrdinante": "Roma",
                "dataFine": new Date('10/06/2025'),
                "dataInizio": new Date('10/06/2025'),
                "denominazioneRTS": "RTS 1",
                "provinceCompetenza": ["TR"]
            },
            {
                "codiceFiscale": "MI",
                "codiceOrdinante": "Milano",
                "dataFine": new Date('10/06/2025'),
                "dataInizio": new Date('10/06/2025'),
                "denominazioneRTS": "RTS 1",
                "provinceCompetenza": ["TR"]
            }
        ];
        this.urlAnagrafe = this.configurationService.servicePaths.get("ANAGRAFE_MS_API_URL") + "/v1";
        this.urlAnagrafe2 = this.configurationService.servicePaths.get("ANAGRAFE_MS_API_URL") + "/v2";
        this.urlDeleghe = this.configurationService.servicePaths.get("DELEGHE_MS_API_URL") + "/v1";
        this.urlDeposito = configurationService.servicePaths.get("DEPOSITO_MS_API_URL") + "/v1";
    }
    getDatiSocieta(id) {
        // console.log('[getDatiSocieta - lib]', id);
        return this.http.put(this.urlDeposito + `/supporto/personagiuridica/delega`, id);
    }
    getPersona(id) {
        // console.log('[getPersona - lib]', id);
        return this.http.get(this.urlAnagrafe + `/personaFisica/${id}`);
        // return this.http.get<PersonaFisica>(this.urlAnagrafe + "/personaFisica/" + "{id}");
    }
    getMieDeleghe() {
        return this.http.get(this.urlDeleghe + `/deleghe/mie`)
            .pipe(map(deleghe => {
            const deleghePF = deleghe.personeFisiche ?
                deleghe.personeFisiche.filter(d => this.DELEGA_VALIDATA == d.validata)
                : [];
            const deleghePG = deleghe.personeGiuridiche ?
                deleghe.personeGiuridiche.filter(d => this.DELEGA_VALIDATA == d.validata)
                : [];
            const delegheValidate = new MieDelegheDTO();
            delegheValidate.personeFisiche = deleghePF;
            delegheValidate.personeGiuridiche = deleghePG;
            return delegheValidate;
        }));
    }
    getListaPfPaged(pageSize, pageNumber, data) {
        // return this.http.post(this.urlAnagrafe + `/personeFisiche?offset=0&pageNumber=${pageNumber}&pageSize=${pageSize}&paged=false&sort.sorted=false&sort.unsorted=false&unpaged=false`, data);
        return this.http.post(this.urlAnagrafe + `/personeFisiche?offset=0&pageNumber=${pageNumber}&pageSize=${pageSize}&paged=false&sort.sorted=false&sort.unsorted=false&unpaged=false`, data);
    }
    //TODO
    getListaPg(paginationData, filtroRicercaPersonaPG) {
        return this.http.post(this.urlAnagrafe + `/personeGiuridiche`, filtroRicercaPersonaPG, { params: paginationData });
    }
    getListaPgPaged(pageSize, pageNumber, data) {
        return this.http.post(this.urlAnagrafe + `/personeGiuridiche?offset=0&pageNumber=${pageNumber}&pageSize=${pageSize}&paged=false&sort.sorted=false&sort.unsorted=false&unpaged=false`, data);
    }
    getPersonaGiuridicaCodiceFiscale(codiceFiscale) {
        // console.log('[getPersonaGiuridicaCodiceFiscale] - codiceFiscale', codiceFiscale);
        //TODO
        // const url: string = this.urlAnagrafe2 + `/personaGiuridica/codiceFiscale`;
        // SE_SI_TRATTA_DI_UNA_NUOVA_PG => SI_DEVE_CHIAMARE_LA_SEGUENTE_SERVIZIO
        const url = this.urlDeposito + `/supporto/personagiuridica`;
        // console.log('[getPersonaGiuridicaCodiceFiscale] - url', url);
        return this.http.put(url, codiceFiscale);
    }
    getPersonaFiscaleCodiceFiscale(codiceFiscale) {
        // console.log('[getPersonaFiscaleCodiceFiscale] - codiceFiscale', codiceFiscale);
        const url = this.urlAnagrafe2 + `/personaFisica/codiceFiscale`;
        // console.log('[getPersonaFiscaleCodiceFiscale] - url', url);
        return this.http.put(url, codiceFiscale);
    }
    getListRtsCodiceRegione(listaCodiceRegione) {
        // console.log('[getListRtsCodiceRegione] - listaCodiceRegione', listaCodiceRegione);
        const url = this.urlDeposito + `/rtsdto`;
        // console.log('[getListRtsCodiceRegione] - url', url);
        // return this.http.put<Array<RtsDTO>>(url, listaCodiceRegione);
        return of(this.rst_mock);
    }
    naturaRichiedente(request) {
        const url = this.urlDeposito + `/naturarichiedente`;
        // console.log('[naturaRichiedente] - url', url);
        // console.log('[naturaRichiedente] - request', request);
        return this.http.put(url, request);
    }
    getValidaPersonaFisica(request) {
        console.log('[getValidaPersonaFisica] - request', request);
        const url = this.urlDeposito + `/supporto`;
        console.log('[getValidaPersonaFisica] - url', url);
        return this.http.put(url, request);
    }
    getAllProvince() {
        const url = this.urlAnagrafe + `/province/mappa/`;
        console.log('[MappaProvince] - url', url);
        return this.http.get(url).pipe(shareReplay());
    }
}
DelegheService.ɵprov = ɵɵdefineInjectable({ factory: function DelegheService_Factory() { return new DelegheService(ɵɵinject(HttpClient), ɵɵinject(ConfigurationService)); }, token: DelegheService, providedIn: "root" });
DelegheService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
DelegheService.ctorParameters = () => [
    { type: HttpClient },
    { type: ConfigurationService }
];

class Utente {
    constructor(codiceFiscale, nome, cognome, dataDiNascita, email, pec, denominazione, partitaIVA, idPersonaFisica) {
        this.codiceFiscale = codiceFiscale;
        this.nome = nome;
        this.cognome = cognome;
        this.dataDiNascita = dataDiNascita;
        this.email = email;
        this.pec = pec;
        this.denominazione = denominazione;
        this.partitaIVA = partitaIVA;
        this.idPersonaFisica = idPersonaFisica;
    }
    hasPartitaIva() {
        return this.partitaIVA != null && this.partitaIVA.length == 11;
    }
}

class UtenteService {
    constructor(configurationService) {
        this.configurationService = configurationService;
        console.log('[UtenteService]');
        // console.log('[userProfile]', configurationService.userProfile);
        let utenteDTO = new UtenteDTO();
        utenteDTO = configurationService.userProfile;
        if (utenteDTO) {
            this.userDetails = utenteDTO.spidUserDetails;
            this.utente = new Utente(this.userDetails.fiscalNumber, this.userDetails.name, this.userDetails.familyName, this.userDetails.dateOfBirth, this.userDetails.email, this.userDetails.digitalAddress, this.userDetails.companyName, this.userDetails.ivaCode, utenteDTO.idPersonaFisica
            //TODO
            // utenteDTO.idPersonaFisica = "df2a6439-1439-4273-b1ec-2a3d8245faa5"
            // utenteDTO.idPersonaFisica = "978089b2-d63c-4274-8cee-de843110749a"
            );
        }
    }
    getSpidUserDetails() {
        return this.userDetails;
    }
    getUtente() {
        return this.utente;
    }
}
UtenteService.ɵprov = ɵɵdefineInjectable({ factory: function UtenteService_Factory() { return new UtenteService(ɵɵinject(ConfigurationService)); }, token: UtenteService, providedIn: "root" });
UtenteService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
UtenteService.ctorParameters = () => [
    { type: ConfigurationService }
];

const isDefined = x => x !== undefined;
const ɵ0 = isDefined;
const isUndefined = x => x === undefined;
const ɵ1 = isUndefined;
const isNotUndefined = x => not(isUndefined(x));
const ɵ2 = isNotUndefined;
const isNull = x => x === null;
const ɵ3 = isNull;
const isNullOrUndefined = x => isNull(x) || isUndefined(x);
const ɵ4 = isNullOrUndefined;
const isNotNull = x => x !== null;
const ɵ5 = isNotNull;
const isNotNullOrUndefined = x => not(isNullOrUndefined(x));
const ɵ6 = isNotNullOrUndefined;
const isString = x => typeof x == "string";
const ɵ7 = isString;
const self = x => x;
const ɵ8 = self;
const curry = (v) => () => v;
const ɵ9 = curry;
const bind = (f) => thisArg => f.bind(thisArg);
const ɵ10 = bind;
const partial1 = (f) => a1 => args => f(a1, ...args);
const ɵ11 = partial1;
const lazyApply1 = (f) => a1 => f(a1);
const ɵ12 = lazyApply1;
const is = (a) => b => a === b;
const ɵ13 = is;
const isGreaterThan = (a) => (b) => b > a;
const ɵ14 = isGreaterThan;
const isLessThan = (a) => (b) => b < a;
const ɵ15 = isLessThan;
const isGreaterOrEqualTo = (a) => (b) => b >= a;
const ɵ16 = isGreaterOrEqualTo;
const isLessOrEqualTo = (a) => (b) => b <= a;
const ɵ17 = isLessOrEqualTo;
const not = (a) => !a;
const ɵ18 = not;
const coalesce = (obj, orValue) => (v => (v.valueOf = () => isDefined(obj) ? obj : orValue, v))((prop) => coalesce((obj || {})[prop], orValue));
const ɵ19 = coalesce;
const givenMap = ({
    [true]: () => givenFound,
    [false]: () => givenNotFound
});
const givenFound = (x, newVal) => ({
    when: () => givenFound(x, newVal),
    otherwise: () => givenFound(x, newVal),
    valueOf: curry(newVal)
});
const ɵ20 = givenFound;
const givenNotFound = (x, newVal) => ({
    when: (condition, newVal) => givenMap[condition(x)]()(x, newVal),
    otherwise: val => givenNotFound(x, val),
    valueOf: curry(newVal)
});
const ɵ21 = givenNotFound;
const given = (x) => ({
    when: (condition, newVal) => givenMap[condition(x)]()(x, newVal),
    otherwise: curry,
    valueOf: curry(x)
});
const ɵ22 = given;
const ftor = x => ({ map: f => ftor(f(x)), valueOf: curry(x) });
const ɵ23 = ftor;
const protoOf = x => given(x)
    .when(isNull, curry(null))
    .when(isUndefined, curry(undefined))
    .otherwise(() => Object.getPrototypeOf(x))
    .valueOf()();
const ɵ24 = protoOf;
const constructorOf = x => protoOf(x).constructor;
const ɵ25 = constructorOf;
const annotationsOf = x => constructorOf(x)['__annotations__'];
const ɵ26 = annotationsOf;
const constructorNameOf = x => constructorOf(x).name;
const ɵ27 = constructorNameOf;

class GenericModalData {
}
class Azione {
    constructor(testo, effetto = () => { }) {
        this.testo = testo;
        this.effetto = effetto;
    }
}

class GenericModalComponent {
    constructor(modalData, dialogRef) {
        this.modalData = modalData;
        this.dialogRef = dialogRef;
    }
    eseguiAzione(azione) {
        if (azione.effetto) {
            azione.effetto();
        }
    }
}
GenericModalComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-generic-modal',
                template: "<!-- <p>generic-modal works!</p> -->\r\n<h1 mat-dialog-title>\r\n\t{{ modalData.title | traduzione }}\r\n</h1>\r\n<div mat-dialog-content>\r\n\t<p *ngFor=\"let paragrafo of modalData.paragrafi\">\r\n\t\t{{paragrafo | traduzione}}\r\n\t</p>\r\n</div>\r\n<div mat-dialog-actions class=\"d-flex flex-row-reverse mb-0\">\r\n\r\n\t<button *ngFor=\"let azione of modalData.azioni\" mat-raised-button color=\"primary\" [mat-dialog-close]=\"\"\r\n\t\t(click)=\"eseguiAzione(azione)\" cdkFocusInitial>\r\n\t\t{{azione.testo | traduzione}}\r\n\t</button>\r\n\r\n</div>",
                styles: [""]
            },] }
];
GenericModalComponent.ctorParameters = () => [
    { type: GenericModalData, decorators: [{ type: Inject, args: [MAT_DIALOG_DATA,] }] },
    { type: MatDialogRef }
];

class Modals {
    constructor(dialog) {
        this.dialog = dialog;
        this.AZIONE_DEFAULT = [new Azione("ok")];
    }
    success(paragrafi, azioni = this.AZIONE_DEFAULT) {
        const modalData = this.buildModalData("modal-ok", paragrafi, azioni);
        this.openConfirm(modalData);
    }
    failure(paragrafi, azioni = this.AZIONE_DEFAULT) {
        const modalData = this.buildModalData("modal-ko", paragrafi, azioni);
        this.openConfirm(modalData);
    }
    buildModalData(title, paragrafi, azioni) {
        const data = new GenericModalData();
        data.title = title;
        data.paragrafi = paragrafi;
        data.azioni = azioni;
        return data;
    }
    openConfirm(modalData) {
        this.dialog.open(GenericModalComponent, {
            data: modalData,
            panelClass: modalData.title === "modal-ok" ? 'custom-modalbox-ok' : 'custom-modalbox-ko'
        });
    }
}
Modals.ɵprov = ɵɵdefineInjectable({ factory: function Modals_Factory() { return new Modals(ɵɵinject(MatDialog)); }, token: Modals, providedIn: "root" });
Modals.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
Modals.ctorParameters = () => [
    { type: MatDialog }
];

function log(text, value) {
    console.log(text, value);
}
class DelegheComponent {
    constructor(delegheService, modals, msg, utenteService, ref) {
        this.delegheService = delegheService;
        this.modals = modals;
        this.msg = msg;
        this.utenteService = utenteService;
        this.ref = ref;
        this.nextStep = new EventEmitter();
        this.previousStep = new EventEmitter();
        this.salvaBozza = new EventEmitter();
        this.isGeneralContractor = new EventEmitter();
        this.displayedColumns = ['tipo', 'indirizzo', 'seleziona'];
        this.CODICE_LEGALE = "LEGALE";
        this.direction = "both-ways";
        this.isFinal = false;
        this.defaultDeleghe = false;
        this.showComponentPF = false;
        this.showComponentPG = false;
        this.isSearching = false;
        this.formControlGeneralContractor = false;
        this.flagDelegaSeStesso = false;
        this.changesPersonaFisica$ = new Subject();
        this.changesPersonaGiuridica$ = new Subject();
        this.validazioneeSede = false;
        this.couldBeDittaIndividuale = true;
    }
    ngOnInit() {
        var _a;
        this.utente = this.utenteService.getUtente();
        console.log('[DelegheComponent] - Utente', this.utente);
        this.tipologiaDeposito$
            .subscribe(deposito => {
            console.log('[tipologiaDeposito$]', deposito);
            //TODO
            if (deposito.codice == "CDE") {
                this.formControlGeneralContractor = true;
            }
            this.codiceTipoDeposito = deposito.codice;
        });
        //TODO
        const richiedenteSubscription = this.tipologieRichiedenti$
            // .pipe(
            // 	pluck("residenza"))
            .subscribe(richiedente => {
            console.log('[NaturaRichiedenteDTO]', richiedente);
            if (this.rappresentanza) {
                let selectedItem = richiedente.find(r => r.codice == this.rappresentanza.codiceDelega);
                if (selectedItem) {
                    this.couldBeDittaIndividuale = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.dittaIndividuale;
                }
            }
        }, _ => {
            // this.modals.failure([
            // 	"recupero.natura.failure"
            // ], []);
        });
        this.form = new FormGroup({});
        let valid = true;
        if (!this.rappresentanza) {
            this.initRappresentante();
            valid = false;
        }
        else {
            this.idSedeSelezionata = this.rappresentanza.idSedeSelezionata;
            if (this.rappresentanza.nuovaPersona) {
                this.isNew = true;
                this.delega = 'nuovo';
                if (this.rappresentanza.tipoRappresentante == "PF") {
                    this.listaDelegheDefault = [nuovaPFBase()];
                    this.showComponentPF = true;
                    log("showComponentPF", this.showComponentPF);
                }
                else {
                    this.listaDelegheDefault = [nuovaPGBase()];
                    this.showComponentPG = true;
                }
                this.defaultDeleghe = true;
                this.listaDeleghe = [];
                const richiedenteSubscription = this.tipologieRichiedenti$.pipe(map(r => r.filter(t => t.codice == this.rappresentanza.codiceDelega))).subscribe(richiedente => {
                    const filterByTipoRichiedente = (tipiRichiedente) => tipiRichiedente.filter(tr => tr.codTipoDelega == richiedente[0].codice);
                    if (this.isPersonaFisica(richiedente[0].tipoPersona)) {
                        this.deleghe$.pipe(pluck("personeFisiche"), map(filterByTipoRichiedente)).
                            subscribe((res) => {
                            if (res.length > 0) {
                                this.listaDeleghe = [...res, ...this.listaDeleghe];
                            }
                            // console.log('[ListaDeleghe - personeFisiche ]', this.listaDeleghe);
                        });
                    }
                    if (this.isPersonaGiuridica(richiedente[0].tipoPersona)) {
                        this.deleghe$.pipe(pluck("personeGiuridiche"), map(filterByTipoRichiedente)).
                            subscribe((res) => {
                            if (res.length > 0) {
                                if (this.listaDeleghe.length > 0) {
                                    this.listaDeleghe = [...res, ...this.listaDeleghe];
                                }
                                else {
                                    this.listaDeleghe = [...res];
                                }
                            }
                        });
                    }
                    if (richiedente[0].tipoPersona.length > 1) {
                        if (this.rappresentanza.tipoRappresentante == "PF") {
                            this.listaDeleghe = [...this.listaDeleghe, nuovaPFBase(), nuovaPGBase()];
                        }
                        else {
                            this.listaDeleghe = [...this.listaDeleghe, nuovaPGBase(), nuovaPFBase()];
                        }
                    }
                    else {
                        if (richiedente[0].tipoPersona.find(element => element == "PF")) {
                            this.listaDeleghe = [...this.listaDeleghe, nuovaPFBase()];
                        }
                        else {
                            this.listaDeleghe = [...this.listaDeleghe, nuovaPGBase()];
                        }
                    }
                    this.listaDelegheDefault = [this.listaDeleghe.find(el => el.idPersona == "nuovo")];
                    this.deleghe.setValue(this.listaDelegheDefault[0]);
                    richiedenteSubscription.unsubscribe();
                }, _ => {
                });
            }
        }
        this.nsDanteCausa = "nsRapprDc";
        this.nsTutore = "nsRapprTut";
        this.nsLegale = "nsRapprLeg";
        this.namespaceInfoPf = this.nsTutore + "PFinfoPF";
        this.nspg = this.nsLegale + "pg";
        if ((_a = this === null || this === void 0 ? void 0 : this.rappresentanza) === null || _a === void 0 ? void 0 : _a.codiceDelega) {
            const initalTipoRichiedente = this.fromIdAndTipo(this.rappresentanza.codiceDelega, this.rappresentanza.tipoRappresentante);
            this.tipoRichiedente = new FormControl({ value: initalTipoRichiedente, disabled: false }, [Validators.required]);
        }
        else {
            this.tipoRichiedente = new FormControl({ value: null, disabled: false }, [Validators.required]);
        }
        this.form.addControl("tipoRichiedente", this.tipoRichiedente);
        this.deleghe = new FormControl({ value: '', disabled: false }, 
        // { value: this.defaultDeleghe ? this.listaDelegheDefault[0] : '', disabled: false },
        [Validators.required]);
        this.form.addControl("deleghe", this.deleghe);
        this.generalContractor = new FormControl({ value: this.generalContractorValue, disabled: false });
        this.form.addControl('generalContractor', this.generalContractor);
        this.selection = new SelectionModel(false, []);
        const selected = new FormControl({ value: '', disabled: false });
        this.form.addControl('selected', selected);
        if (this.tipoRichiedente.value != undefined &&
            !this.rappresentanza.nuovaPersona &&
            this.tipoRichiedente.value != CodiceTipiRichiedente.CODICE_ME_MEDESIMO) {
            const richiedenteSubscription = this.tipologieRichiedenti$.pipe(map(r => r.filter(t => t.codice == this.rappresentanza.codiceDelega)), tap((tipo) => {
                console.log('initDeleghe:', tipo[0]);
                this.initDeleghe(tipo[0]);
            })).subscribe(richiedente => {
                if (this.isPersonaFisica(richiedente[0].tipoPersona)) {
                    this.personaFisicaBase = this.initPersonaFisica(this.rappresentanza.idPersona);
                }
                if (this.isPersonaGiuridica(richiedente[0].tipoPersona)) {
                    this.personaGiuridicaBase = this.initPersonaGiuridica(this.rappresentanza.idPersona);
                }
                richiedenteSubscription.unsubscribe();
            }, _ => {
            });
        }
        this.tipoRichiedente$ = this.tipoRichiedente.valueChanges.pipe(tap(_ => {
            this.deleghe.setValue(null);
            this.resetValidation();
            this.flagDelegaSeStesso = false;
            this.ref.detectChanges();
        }), tap((tipo) => {
            var _a;
            if (tipo.codice != CodiceTipiRichiedente.CODICE_ME_MEDESIMO) {
                this.initDeleghe(tipo);
                this.rappresentanza.idSedeSelezionata = null;
            }
            else {
                this.resetDeleghe();
                this.rappresentanza.idPersona = (_a = this.utente) === null || _a === void 0 ? void 0 : _a.idPersonaFisica;
                this.rappresentanza.tipoRappresentante = "PF";
            }
        }), shareReplay());
        const changesDelega$ = this.deleghe.valueChanges.pipe(map(delega => {
            return ComponentOutputStatus.of(true, rappresentanza => {
                if (delega != undefined && delega != null) {
                    this.delega = delega.idPersona;
                    if (!this.defaultDeleghe) {
                        this.setDelega(delega);
                    }
                    else {
                        this.defaultDeleghe = false;
                    }
                    this.flagDelegaSeStesso = false;
                    this.ref.detectChanges();
                    rappresentanza.idPersona = delega.idPersona != 'nuovo' ? delega.idPersona : null;
                }
            });
        }));
        const tipoRichiedenteChanges$ = this.tipoRichiedente$.pipe(map((tipoRichiedente) => {
            return ComponentOutputStatus.of(this.tipoRichiedente.valid, (rap) => {
                // rap.tipoRappresentante = tipoRichiedente.descrizione;
                rap.codiceDelega = tipoRichiedente.codice;
            });
        }));
        const rappresentante$ = ComponentReducer.reducer4(tipoRichiedenteChanges$, changesDelega$, this.changesPersonaFisica$, this.changesPersonaGiuridica$, (richiedente) => {
            let isValid;
            if (coalesce(richiedente, '')('codiceDelega').valueOf() != CodiceTipiRichiedente.CODICE_ME_MEDESIMO) {
                if (this.delega == 'nuovo') {
                    isValid = (this.rappresentanza.personaFisica != null ||
                        this.rappresentanza.personaGiuridica != null) &&
                        this.deleghe.value && !this.flagDelegaSeStesso;
                }
                else {
                    // isValid = this.rappresentanza.idPersona != null && this.deleghe.value;
                    isValid =
                        richiedente.idPersona != null &&
                            this.deleghe.value &&
                            !this.flagDelegaSeStesso;
                }
            }
            else {
                isValid = true;
            }
            this.ref.detectChanges();
            return isValid;
        }, ComponentOutputStatus.of(valid, this.rappresentanza));
        rappresentante$.subscribe((delegante) => {
            console.log("[DelegheComponent] rappresentanza", delegante);
            this.isFormValid = delegante.status;
        });
    }
    resetValidation() {
        this.changesPersonaFisica$.next(ComponentOutputStatus.of(true, (personaFisica) => (rap) => { }));
        this.changesPersonaGiuridica$.next(ComponentOutputStatus.of(true, (personaGiuridica) => (rap) => { }));
    }
    forward(_) {
        this.nextStep.emit(this.rappresentanza);
    }
    onSalvaBozza($event) {
        this.salvaBozza.emit(this.rappresentanza);
    }
    backward($event) {
        this.previousStep.emit(this.rappresentanza);
    }
    complete($event) { }
    initRappresentante() {
        this.rappresentanza = new RappresentanteDTO();
    }
    ngOnDestroy() {
        if (this.tipoRichiedenteSub) {
            this.tipoRichiedenteSub.unsubscribe();
        }
        if (this.$selected) {
            this.$selected.unsubscribe();
        }
    }
    setDelega(persona) {
        this.delega = persona.idPersona;
        this.resetDeleghe();
        this.showComponentPF = false;
        this.showComponentPG = false;
        if (persona.cognome) {
            if (persona.idPersona != "nuovo") {
                this.getPersonaFisica(persona.idPersona);
            }
            else {
                this.mapperPersonaFisica(null);
                setTimeout(() => this.showComponentPF = true, 0);
            }
        }
        if (persona.ragioneSociale) {
            if (persona.idPersona != "nuovo") {
                this.getPersonaGiuridica(persona.idPersona);
            }
            else {
                this.mapperPersonaGiuridica(null);
                setTimeout(() => this.showComponentPG = true, 0);
            }
        }
    }
    hasSelecteDelegante() {
        return this.deleghe.value;
    }
    viewDeleghe() {
        return (coalesce(this.tipoRichiedente.value, '')('codice').valueOf() === "" ||
            coalesce(this.tipoRichiedente.value, '')('codice').valueOf() === CodiceTipiRichiedente.CODICE_ME_MEDESIMO);
    }
    getPersonaFisica(id) {
        this.resetValidation();
        this.rappresentanza.idSedeSelezionata = null;
        this.showComponentPF = false;
        this.personaFisica$ = this.delegheService.getPersona(id)
            .pipe(shareReplay());
        this.pfSubscription = this.personaFisica$.pipe().subscribe((pf) => {
            var _a, _b;
            this.mapperPersonaFisica(pf.datiPersonaFisica);
            this.personaFisica = pf.datiPersonaFisica;
            this.rappresentanza.idPersona = id;
            this.rappresentanza.tipoRappresentante = "PF";
            this.rappresentanza.codiceRegione = (_b = (_a = pf === null || pf === void 0 ? void 0 : pf.residenza) === null || _a === void 0 ? void 0 : _a.regione) === null || _b === void 0 ? void 0 : _b.sigla;
            this.showComponentPF = true;
            this.showComponentPG = false;
        }, _ => {
        });
    }
    getPersonaGiuridica(id) {
        this.resetValidation();
        this.rappresentanza.idSedeSelezionata = null;
        this.showComponentPG = false;
        this.personaGiuridica$ = this.delegheService.getDatiSocieta(id)
            .pipe(shareReplay());
        this.pgSubscription = this.personaGiuridica$.pipe().subscribe((pg) => {
            var _a, _b, _c;
            this.form.get('selected').setValue('');
            this.mapperPersonaGiuridica(pg);
            this.personaGiuridica = pg;
            this.rappresentanza.idPersona = id;
            this.rappresentanza.tipoRappresentante = "PG";
            this.showComponentPG = true;
            this.showComponentPF = false;
            if ((pg === null || pg === void 0 ? void 0 : pg.sedi) != undefined) {
                const sede = pg.sedi.filter(sedeLegale => sedeLegale.tipoSede.codice === "LEGALE");
                this.rappresentanza.codiceRegione = (_c = (_b = (_a = sede[0]) === null || _a === void 0 ? void 0 : _a.indirizzo) === null || _b === void 0 ? void 0 : _b.regione) === null || _c === void 0 ? void 0 : _c.sigla;
            }
            this.ref.detectChanges();
        }, _ => {
        });
    }
    isPersonaFisica(tipoPersona) {
        let isValid;
        if (tipoPersona.find(element => element == "PF")) {
            isValid = true;
        }
        else {
            isValid = false;
        }
        return isValid;
    }
    isPersonaGiuridica(tipoPersona) {
        let isValid;
        if (tipoPersona.find(element => element == "PG")) {
            isValid = true;
        }
        else {
            isValid = false;
        }
        return isValid;
    }
    initDeleghe(tipoRichiedente) {
        this.listaDeleghe = [];
        console.log('tipoRichiedente:', tipoRichiedente);
        this.couldBeDittaIndividuale = tipoRichiedente === null || tipoRichiedente === void 0 ? void 0 : tipoRichiedente.dittaIndividuale;
        const filterByTipoRichiedente = (tipiRichiedente) => tipiRichiedente.filter(tr => tr.codTipoDelega == tipoRichiedente.codice);
        if (this.isPersonaFisica(tipoRichiedente.tipoPersona)) {
            this.deleghe$.pipe(pluck("personeFisiche"), map(filterByTipoRichiedente)).
                subscribe((res) => {
                this.listaDeleghe = [...res, nuovaPFBase()];
                this.deleghe.setValue(this.listaDeleghe.find(el => el.idPersona == this.rappresentanza.idPersona));
            });
        }
        if (this.isPersonaGiuridica(tipoRichiedente.tipoPersona)) {
            this.deleghe$.pipe(pluck("personeGiuridiche"), map(filterByTipoRichiedente)).
                subscribe((res) => {
                if (this.listaDeleghe.length > 0) {
                    this.listaDeleghe = this.listaDeleghe.reduce((acc, currentValue, index) => {
                        if (this.listaDeleghe.length - 1 == index) {
                            acc.push(...res, nuovaPGBase());
                        }
                        return acc;
                    }, this.listaDeleghe);
                }
                else {
                    this.listaDeleghe = [...res, nuovaPGBase()];
                }
                this.deleghe.setValue(this.listaDeleghe.find(el => el.idPersona == this.rappresentanza.idPersona));
            });
        }
    }
    resetDeleghe() {
        this.rappresentanza.idPersona = null;
        this.rappresentanza.nuovaPersona = false;
        this.rappresentanza.personaFisica = null;
        this.rappresentanza.personaGiuridica = null;
        this.rappresentanza.tipoRappresentante = null;
        this.personaGiuridica = null;
        this.personaGiuridica$ = null;
        this.personaFisica = null;
    }
    mapperPersonaFisica(datiPersona) {
        var _a, _b;
        const personaFisica = new PersonaFisicaDTO();
        const infoAnagrafiche = new InfoAnagrafichePFDTO();
        personaFisica.infoAnagrafiche = infoAnagrafiche;
        const infoNascita = new InfoNascitaPFDTO();
        personaFisica.infoNascita = infoNascita;
        if (datiPersona) {
            infoAnagrafiche.codFiscale = datiPersona.codiceFiscale;
            infoAnagrafiche.cognome = datiPersona.cognome;
            infoAnagrafiche.nome = datiPersona.nome;
            personaFisica.infoAnagrafiche = infoAnagrafiche;
            infoNascita.comuneNascita = (_a = datiPersona.comuneNascita) === null || _a === void 0 ? void 0 : _a.codiceCatastale;
            infoNascita.provinciaNascita = (_b = datiPersona.provinciaNascita) === null || _b === void 0 ? void 0 : _b.sigla;
            infoNascita.dataNascita = moment(datiPersona.dataNascita, "DD/MM/YYYY").toDate();
            personaFisica.infoNascita = infoNascita;
        }
        this.rappresentanza.personaFisica = personaFisica;
    }
    initPersonaFisica(id) {
        let personaFisica = new PersonaFisicaBaseDTO();
        this.showComponentPF = false;
        this.personaFisica$ = this.delegheService.getPersona(id)
            .pipe(shareReplay());
        this.pfSubscription = this.personaFisica$.pipe(pluck("datiPersonaFisica")).subscribe((pf) => {
            this.mapperPersonaFisica(pf);
            this.rappresentanza.idPersona = id;
            personaFisica.codTipoDelega = this.rappresentanza.codiceDelega;
            personaFisica.codiceFiscale = pf.codiceFiscale;
            personaFisica.cognome = pf.cognome;
            personaFisica.nome = pf.nome;
            personaFisica.idPersona = pf.id;
            this.showComponentPF = true;
            this.showComponentPG = false;
        }, _ => {
        });
        return personaFisica;
    }
    initPersonaGiuridica(id) {
        let personaGiuridica = new PersonaGiuridicaBaseDTO();
        this.showComponentPG = false;
        this.personaGiuridica$ = this.delegheService.getDatiSocieta(id)
            .pipe(shareReplay());
        this.pgSubscription = this.personaGiuridica$.pipe().subscribe((pg) => {
            this.mapperPersonaGiuridica(pg);
            personaGiuridica.codTipoDelega = this.rappresentanza.codiceDelega;
            personaGiuridica.codiceFiscale = pg.datiPersonaGiuridica.codiceFiscale;
            personaGiuridica.ragioneSociale = pg.datiPersonaGiuridica.ragioneSociale;
            personaGiuridica.pIva = pg.datiPersonaGiuridica.partitaIVA;
            personaGiuridica.idPersona = pg.datiPersonaGiuridica.id;
            this.rappresentanza.idPersona = id;
            this.showComponentPG = true;
            this.showComponentPF = false;
            this.deleghe.setValue(this.listaDeleghe.find(el => el.idPersona == personaGiuridica.idPersona));
        }, _ => {
        });
        return personaGiuridica;
    }
    mapperPersonaGiuridica(datiPersona) {
        // console.log('[mapperPersonaGiuridica]', datiPersona);
        const personaGiuridica = new PersonaGiuridicaDTO();
        if (datiPersona) {
            personaGiuridica.codiceFiscale = datiPersona.datiPersonaGiuridica.codiceFiscale;
            personaGiuridica.ragioneSociale = datiPersona.datiPersonaGiuridica.ragioneSociale;
            personaGiuridica.partitaIVA = datiPersona.datiPersonaGiuridica.partitaIVA;
            personaGiuridica.idPersonaGiuridica = datiPersona.datiPersonaGiuridica.id;
            personaGiuridica.sedi = datiPersona.sedi;
        }
        this.rappresentanza.personaGiuridica = personaGiuridica;
    }
    personaFisicaReady(personaFisicaStatus) {
        console.log('[personaFisicaReady]', personaFisicaStatus);
        this.resetValidation();
        this.rappresentanza.idSedeSelezionata = null;
        this.changesPersonaFisica$.next(personaFisicaStatus.mapValue((personaFisica) => (rap) => {
            var _a, _b, _c;
            this.rappresentanza.idPersona = personaFisica.id;
            rap.personaFisica = personaFisica;
            if (this.delega == "nuovo") {
                rap.codiceRegione = personaFisica.infoAnagrafiche.codiceRegione;
                rap.nuovaPersona = true;
            }
            (rap.tipoRappresentante = "PF");
            if (((_a = this.utente) === null || _a === void 0 ? void 0 : _a.codiceFiscale) === ((_c = (_b = personaFisica === null || personaFisica === void 0 ? void 0 : personaFisica.infoAnagrafiche) === null || _b === void 0 ? void 0 : _b.codFiscale) === null || _c === void 0 ? void 0 : _c.toUpperCase())) {
                this.flagDelegaSeStesso = true;
            }
            else {
                this.flagDelegaSeStesso = false;
            }
            this.ref.detectChanges();
        }));
    }
    personaGiuridicaReady(personaGiuridicaStatus) {
        console.log("[personaGiuridicaReady]", personaGiuridicaStatus);
        this.resetValidation();
        this.flagDelegaSeStesso = false;
        this.changesPersonaGiuridica$.next(personaGiuridicaStatus.mapValue(personaGiuridica => (rap) => {
            var _a;
            rap.personaGiuridica = personaGiuridica;
            rap.tipoRappresentante = "PG";
            this.rappresentanza.idSedeSelezionata = null;
            this.rappresentanza.idPersona = personaGiuridica.idPersonaGiuridica;
            if (((_a = personaGiuridica === null || personaGiuridica === void 0 ? void 0 : personaGiuridica.sedi) === null || _a === void 0 ? void 0 : _a.length) > 0) {
                this.rappresentanza.idSedeSelezionata = personaGiuridica.sedi[0].id;
            }
            if (this.delega == "nuovo") {
                this.isValidSedi = personaGiuridicaStatus.status;
                rap.nuovaPersona = true;
                rap.codiceRegione = personaGiuridica.codiceRegione;
            }
            this.ref.detectChanges();
        }));
    }
    richiedenteComparator(m1, m2) {
        return (m1 || {}).codice == (m2 || {}).codice;
    }
    delegheComparator(m1, m2) {
        return (m1 || {}).codTipoDelega == (m2 || {}).codTipoDelega;
    }
    fromIdAndTipo(codice, tipoNaturaRichiedente) {
        const naturaRichiedente = new NaturaRichiedenteDTO();
        naturaRichiedente.codice = codice;
        naturaRichiedente.descrizione = tipoNaturaRichiedente;
        return naturaRichiedente;
    }
    onChangeGeneralContractor(event) {
        this.isGeneralContractor.emit(event.checked);
    }
}
DelegheComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-deleghe',
                template: "<div class=\"mt-3 mb-5\" [formGroup]=\"form\">\r\n\t<mat-card>\r\n\t\t<h3 class=\"h5 mb-0\">\r\n\t\t\t<info-tip-label label=\"tipo-richiedente\"></info-tip-label>\r\n\t\t</h3>\r\n\t\t<div class=\"row\">\r\n\r\n\t\t\t<div class=\"col-md-8\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<mat-label>{{'required' | traduzione}}{{'tipo-soggetto' | traduzione}}</mat-label>\r\n\t\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"tipoRichiedente\"\r\n\t\t\t\t\t\t\t\t\t\t\t[compareWith]=\"richiedenteComparator\">\r\n\t\t\t\t\t\t<mat-option *ngFor=\"let tipoRichiedenteTipo of tipologieRichiedenti$ | async\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t[value]=\"tipoRichiedenteTipo\">\r\n\t\t\t\t\t\t\t{{ tipoRichiedenteTipo.descrizione }}\r\n\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls[ 'tipoRichiedente'].invalid\">\r\n\t\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['tipoRichiedente']) | traduzione}}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t<mat-hint *infoTip=\"'tipo-soggetto'\"></mat-hint>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<div class=\"row\" *ngIf=\"!viewDeleghe()\">\r\n\t\t\t<div class=\"col-md-8\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<mat-label>{{'required' | traduzione}}{{'deleghe-rappresentante' | traduzione }}</mat-label>\r\n\t\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"deleghe\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<mat-option *ngFor=\"let item of listaDeleghe\" [value]=\"item\">\r\n\t\t\t\t\t\t\t<ng-container *ngIf=\"item.ragioneSociale else templatePersonaFisica\">\r\n\t\t\t\t\t\t\t\t{{item.idPersona === 'nuovo' ? (item.ragioneSociale | traduzione) : item.ragioneSociale}}\r\n\t\t\t\t\t\t\t</ng-container>\r\n\t\t\t\t\t\t\t<ng-template #templatePersonaFisica>\r\n\t\t\t\t\t\t\t\t{{(item.idPersona === 'nuovo' ? (item.nome + ' ' + (item.cognome | traduzione)) : (item.nome + ' ' + item.cognome))}}\r\n\t\t\t\t\t\t\t</ng-template>\r\n\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t<mat-error *ngIf=\"form.controls['deleghe'].invalid\">\r\n\t\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['deleghe']) | traduzione}}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t<mat-hint *infoTip=\"'deleghe-rappresentante'\"></mat-hint>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<br>\r\n\t</mat-card>\r\n\t<div class=\"mt-4\"></div>\r\n\t<mat-expansion-panel class=\"panel\" *ngIf=\"hasSelecteDelegante() && !viewDeleghe()\" [expanded]=\"true\">\r\n\t\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\r\n\t\t\t<mat-panel-title>\r\n\t\t\t\t<h3 class=\"h5 mb-0\">\r\n\t\t\t\t\t<info-tip-label label=\"tipologia-rappresentante-{{codiceTipoDeposito}}\"></info-tip-label>\r\n\t\t\t\t</h3>\r\n\t\t\t</mat-panel-title>\r\n\t\t</mat-expansion-panel-header>\r\n\t\t<div class=\"mt-4\"></div>\r\n\t\t<div *ngIf=\"formControlGeneralContractor\" class=\"col-md-4\">\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<mat-checkbox formControlName=\"generalContractor\" (change)=\"onChangeGeneralContractor($event)\">\r\n\t\t\t\t\t<info-tip-label label=\"general-contractor\"></info-tip-label>\r\n\t\t\t\t</mat-checkbox>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\r\n\t\t<lib-persona-fisica\r\n\t\t\t*ngIf=\"showComponentPF\"\r\n\t\t\t(done)=\"personaFisicaReady($event)\"\r\n\t\t\t[nazioni]=\"nazioni\"\r\n\t\t\t[province]=\"province\"\r\n\t\t\t[namespace]=\"namespaceInfoPf\"\r\n\t\t\t[infoPersonaFisica]=\"rappresentanza?.personaFisica\"\r\n\t\t\t[idDelega]=\"rappresentanza?.idPersona\"\r\n\t\t\t[validatorFormControl]=\"true\"\r\n\t\t\t[nuovaPersona]=\"isNew\"\r\n\t\t>\r\n\t\t</lib-persona-fisica>\r\n\r\n\t\t<lib-persona-giuridica\r\n\t\t\t*ngIf=\"showComponentPG\"\r\n\t\t\t(done)=\"personaGiuridicaReady($event)\"\r\n\t\t\t[namespace]=\"nspg\"\r\n\t\t\t[datisocieta]=\"rappresentanza?.personaGiuridica\"\r\n\t\t\t[validatorFormControl]=\"true\"\r\n\t\t\t[gestioneSedi]=\"true\"\r\n\t\t\t[idSedeSelezionata]=\"idSedeSelezionata\"\r\n\t\t\t[personaGiuridicaFromDeleghe$]=\"personaGiuridica$\"\r\n\t\t\t[couldBeDittaIndividuale]=\"couldBeDittaIndividuale\"\r\n\t\t>\r\n\t\t</lib-persona-giuridica>\r\n\t</mat-expansion-panel>\r\n\t<div class=\"collapse-body mt-2\">\r\n\t\t<div class=\"col-md-12\">\r\n\t\t\t<mat-error *ngIf=\"flagDelegaSeStesso\">\r\n\t\t\t\t{{'validation-tipo-ricorrente' | traduzione }}\r\n\t\t\t</mat-error>\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"mt-4\"></div>\r\n\t<lib-stepper-navigator\r\n\t\t[form]=\"form\"\r\n\t\t[direction]=\"direction\"\r\n\t\t[isFinal]=\"isFinal\"\r\n\t\t[isContainerValid]=\"isFormValid\"\r\n\t\t(goForward)=\"forward($event)\"\r\n\t\t(goBackward)=\"backward($event)\"\r\n\t\t(salvaBozza)=\"onSalvaBozza($event)\"\r\n\t\t(complete)=\"complete($event)\"\r\n\t>\r\n\t</lib-stepper-navigator>\r\n</div>\r\n",
                styles: [".mat-card{border-radius:0!important;border-top:5px solid #0a2644}.divider{background-color:#737373;height:1px;width:100%}.mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fff!important}.mat-select-value{max-width:100%;width:100%!important}"]
            },] }
];
DelegheComponent.ctorParameters = () => [
    { type: DelegheService },
    { type: Modals },
    { type: MessageService },
    { type: UtenteService },
    { type: ChangeDetectorRef }
];
DelegheComponent.propDecorators = {
    rappresentanza: [{ type: Input }],
    province: [{ type: Input }],
    nazioni: [{ type: Input }],
    tipologieRichiedenti$: [{ type: Input }],
    deleghe$: [{ type: Input }],
    tipologiaDeposito$: [{ type: Input }],
    generalContractorValue: [{ type: Input }],
    nextStep: [{ type: Output }],
    previousStep: [{ type: Output }],
    salvaBozza: [{ type: Output }],
    isGeneralContractor: [{ type: Output }]
};

const SAMPLE_TIME = 1000;
const EMPTY_PF = {
    id: null,
    infoAnagrafiche: {
        codFiscale: null,
        codiceRegione: null,
        cognome: null,
        nome: null
    },
    infoNascita: {
        comuneNascita: null,
        dataNascita: null,
        provinciaNascita: null,
        nazioneNascita: null,
        isNatoEstero: null,
        codCatNazioneNascita: null
    }
};
class PersonaFisicaComponent {
    constructor(delegheService) {
        this.delegheService = delegheService;
        this.done = new EventEmitter();
        this.changesPF$ = new ReplaySubject(1);
        this.changesNascita$ = new ReplaySubject(1);
        this.readOnly = false;
        this.isPersonaFisicaValid = new BehaviorSubject(false);
        this.datiVerifica = {};
    }
    ngOnInit() {
        this.form = new FormGroup({});
        let valid = false;
        if (!this.infoPersonaFisica) {
            this.initPersonaFisica();
            valid = false;
        }
        else {
            this.readOnly = true;
        }
        if (this.idDelega == null || this.nuovaPersona) {
            this.readOnly = false;
        }
        this.namespaceInfoPf = this.namespace + "infoPF";
        this.namespaceInfoNascita = this.namespace + "infoNascita";
        const mappaProvince$ = this.delegheService.getAllProvince();
        this.personaFisicaChangedSub = combineLatest([this.changesPF$, this.changesNascita$, mappaProvince$])
            .pipe(map(([validPF, changesNascita, allProvince]) => {
            var _a;
            let provincia = allProvince[(_a = changesNascita === null || changesNascita === void 0 ? void 0 : changesNascita.output) === null || _a === void 0 ? void 0 : _a.provinciaNascita];
            return [validPF, changesNascita, provincia];
        }), auditTime(SAMPLE_TIME), concatMap(([infoAnagrafiche, infoNascita, provincia]) => this.getPersonaFisicaValid(infoAnagrafiche, infoNascita, provincia)), startWith(ComponentOutputStatus.of(valid, this.infoPersonaFisica)), tap(pf => this.done.emit(pf)))
            .subscribe();
    }
    getPersonaFisicaValid(infoAnagrafiche, infoNascita, provincia) {
        console.log("FORM VALIDITY", infoNascita.status);
        if (!infoNascita.status || !infoAnagrafiche.status) {
            this.isPersonaFisicaValid.next(false);
            return of(ComponentOutputStatus.of(false, EMPTY_PF));
        }
        return this.validatePersonaFisica(infoAnagrafiche.output, infoNascita.output)
            .pipe(tap(() => this.isPersonaFisicaValid.next(true)), map((response) => {
            const isPersonaFisicaValid = isNotNull(response);
            return this.toValidPf(isPersonaFisicaValid, response, infoAnagrafiche.output, provincia, infoNascita);
        }), tap(({ isValid }) => this.isPersonaFisicaValid.next(isValid)), tap(({ persona }) => this.infoPersonaFisica = persona), map(v => ComponentOutputStatus.of(v.isValid, v.persona)), catchError(_ => of(ComponentOutputStatus.of(false, EMPTY_PF))));
    }
    toValidPf(isPersonaFisicaValid, response, infoAnagrafiche, provincia, infoNascita) {
        var _a, _b;
        return {
            isValid: isPersonaFisicaValid,
            persona: {
                id: response === null || response === void 0 ? void 0 : response.id,
                infoAnagrafiche: {
                    codFiscale: String(infoAnagrafiche.codFiscale),
                    codiceRegione: String(provincia === null || provincia === void 0 ? void 0 : provincia.siglaReg),
                    cognome: String(infoAnagrafiche.cognome),
                    nome: String(infoAnagrafiche.nome)
                },
                infoNascita: {
                    comuneNascita: ((_a = infoNascita === null || infoNascita === void 0 ? void 0 : infoNascita.output) === null || _a === void 0 ? void 0 : _a.comuneNascita) ? String(infoNascita.output.comuneNascita) : null,
                    dataNascita: infoNascita.output.dataNascita,
                    provinciaNascita: String(infoNascita.output.provinciaNascita),
                    nazioneNascita: String(infoNascita.output.nazioneNascita),
                    codCatNazioneNascita: String(infoNascita.output.codCatNazioneNascita),
                    isNatoEstero: ((_b = infoNascita.output) === null || _b === void 0 ? void 0 : _b.isNatoEstero) ? infoNascita.output.isNatoEstero : false
                }
            }
        };
    }
    validatePersonaFisica(infoAnagrafiche, infoNascita) {
        // var d = new Date(infoNascita.dataNascita);
        // d.toLocaleString('it-IT', { timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone })
        return this.delegheService.getValidaPersonaFisica({
            codiceFiscale: infoAnagrafiche.codFiscale,
            cognome: infoAnagrafiche.cognome,
            comune: (infoNascita === null || infoNascita === void 0 ? void 0 : infoNascita.isNatoEstero) ? null : infoNascita === null || infoNascita === void 0 ? void 0 : infoNascita.comuneNascita
            // , dataNascita: new Date(moment(infoNascita.dataNascita, 'DD/MM/YYYY').add(23, 'hour').add(59, 'minute').add(59, 'second').toDate())
            ,
            dataNascita: new Date(infoNascita.dataNascita).toISOString(),
            nome: infoAnagrafiche.nome,
            provinciaNascita: infoNascita.provinciaNascita,
            siglaNazione: infoNascita.nazioneNascita,
            codCatNazioneNascita: infoNascita === null || infoNascita === void 0 ? void 0 : infoNascita.codCatNazioneNascita
        });
    }
    initPersonaFisica() {
        this.infoPersonaFisica = new PersonaFisicaDTO();
    }
    infoPfReady(inFoPfStatus) {
        // console.log("[infoPfReady]", inFoPfStatus);
        this.changesPF$.next(inFoPfStatus);
    }
    infoNascitaReady(infoNascitaPf) {
        // console.log("[infoNascitaReady]", infoNascitaPf);
        this.changesNascita$.next(infoNascitaPf);
    }
    ngOnDestroy() {
        this.personaFisicaChangedSub.unsubscribe();
    }
    resetForm() {
        this.infoPF._resetForm();
        this.infoNascita._resetForm();
    }
}
PersonaFisicaComponent.decorators = [
    { type: Component, args: [{
                selector: "lib-persona-fisica",
                template: "<form [formGroup]=\"form\">\r\n\t<lib-info-pf\r\n\t\t[cfDifferentFrom]=\"cfDifferentFrom\"\r\n\t\t[namespace]=\"namespaceInfoPf\"\r\n\t\t(done)=\"infoPfReady($event)\"\r\n\t\t[infopf]=\"infoPersonaFisica?.infoAnagrafiche\"\r\n\t\t[readOnly]=\"readOnly\"\r\n\t\t[validatorFormControl]=\"true\"\r\n\t\t#infoPF\r\n\t>\r\n\t</lib-info-pf>\r\n\t<lib-info-nascita\r\n\t\t[province]=\"province\"\r\n\t\t(done)=\"infoNascitaReady($event)\"\r\n\t\t[infonascita]=\"infoPersonaFisica?.infoNascita\"\r\n\t\t[readOnly]=\"readOnly\"\r\n\t\t#infoNascita\r\n\t>\r\n\t</lib-info-nascita>\r\n\t<div class=\"collapse-body mt-2\">\r\n\t\t<div class=\"col-md-12\">\r\n\t\t\t<mat-error *ngIf=\"!(isPersonaFisicaValid | async)\">\r\n\t\t\t\t{{'validationPF' | traduzione }}\r\n\t\t\t</mat-error>\r\n\t\t</div>\r\n\t</div>\r\n</form>\r\n",
                styles: [""]
            },] }
];
PersonaFisicaComponent.ctorParameters = () => [
    { type: DelegheService }
];
PersonaFisicaComponent.propDecorators = {
    infoPersonaFisica: [{ type: Input }],
    cfDifferentFrom: [{ type: Input }],
    province: [{ type: Input }],
    nazioni: [{ type: Input }],
    namespace: [{ type: Input }],
    idDelega: [{ type: Input }],
    nuovaPersona: [{ type: Input }],
    done: [{ type: Output }],
    infoPF: [{ type: ViewChild, args: ['infoPF',] }],
    infoNascita: [{ type: ViewChild, args: ['infoNascita',] }]
};

class CodiceFiscaleService {
}

// @Injectable()
// @dynamic
class ValidationService {
    constructor(checkCFService) {
        this.checkCFService = checkCFService;
    }
    static ValidateMail(control) {
        if (ValidationService.formatoEmail.test(control.value)) {
            return null;
        }
        return { invalidMail: true };
    }
    static ValidateDate(control) {
        if (new Date().getTime() < control.value) {
            return { invalidDate: true };
        }
        return null;
    }
    static ValidateName(control) {
        if (ValidationService.formatoName.test(control.value)) {
            return null;
        }
        return { invalidName: true };
    }
    static ValidatePassword(control) {
        if (ValidationService.passwordPattern.test(control.value)) {
            return null;
        }
        return { invalidPassword: true };
    }
    static ValidateIban(control) {
        if (ValidationService.iban.test(control.value)) {
            return null;
        }
        return { invalidIban: true };
    }
    static ValidateCodiceFiscale(control) {
        if (ValidationService.codiceFiscale.test(control.value)) {
            return null;
        }
        return { codiceFiscaleInvalido: true };
    }
    static ValidatePartitaIva(control) {
        if (ValidationService.partitaIva.test(control.value)) {
            return null;
        }
        return { invalidPartitaIva: true };
    }
    static pattern(pattern, error) {
        return (c) => Validators.pattern(pattern)(c) ? { [error]: true } : null;
    }
    static trigger(dependentControl, predicate = (_) => _) {
        const originalValidator = dependentControl.validator;
        return (dependentValidators) => {
            return (control) => {
                if (predicate(control.value)) {
                    for (const validator of dependentValidators) {
                        const newError = validator(dependentControl);
                        if (newError) {
                            dependentControl.setErrors(newError);
                            break;
                        }
                    }
                    dependentControl.setValidators(dependentValidators);
                }
                else {
                    dependentControl.setValidators(originalValidator);
                    dependentControl.setErrors(null);
                }
                return null;
            };
        };
    }
    static NotEquals(value, message) {
        return (control) => {
            return value != control.value
                ? null
                : {
                    [message]: true,
                };
        };
    }
    userValidator(tipoPersona) {
        return (control) => {
            return this.checkCFService
                .validaCodiceFiscale$(control.value, tipoPersona)
                .pipe(map((outcome) => (!outcome.valid ? { invalidCF: true } : null)), catchError((error) => {
                return of({ validationServiceFailed: true });
            }));
        };
    }
}
ValidationService.capPattern = "[0-9][0-9][0-9][0-9][0-9]";
ValidationService.passwordPattern = /^(?:(?=.*\d)(?=.*[A-Z]).{8,})/;
ValidationService.zeroCentoPattern = "^([0-9]|[1-9][0-9]|100)$";
// tslint:disable-next-line:max-line-length
ValidationService.formatoData = /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/;
ValidationService.importoPattern = "^[0-9]+(,[0-9]{1,2}){0,1}$";
// tslint:disable-next-line:max-line-length
ValidationService.formatoEmail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
// tslint:disable-next-line:max-line-length
ValidationService.iban = /^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$/;
// /^[A-Za-z]{6}[0-9]{2}[A-Za-z]{1}[0-9]{2}[A-Za-z]{1}[0-9]{3}[A-Za-z]{1}$/
ValidationService.codiceFiscale = /([a-z]{6}|[A-Z]{6})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})(a|b|c|d|e|h|l|m|p|r|s|t|A|B|C|D|E|H|L|M|P|R|S|T)((((l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|0|1|2|3|4|5|6)(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1}))|71|70|TM|Tm|tM|tm|TL|tl|Tl|tL))([a-z]{1}|[A-Z]{1})(L|M|N|P|Q|R|S|T|U|V|\d{1})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})([a-z]{1}|[A-Z]{1})/;
ValidationService.partitaIva = /^[0-9]{11}$/;
ValidationService.partitaIvaMaxLen2 = /^[0-9]{2,11}$/;
ValidationService.codiceFiscalePiva = "^[A-Za-z]{6}[0-9]{2}[A-Za-z]{1}[0-9]{2}[A-Za-z]{1}[0-9]{3}[A-Za-z]{1}$|^[0-9]{11}$";
ValidationService._codiceFiscalePiva = /^[A-Za-z]{6}[0-9]{2}[A-Za-z]{1}[0-9]{2}[A-Za-z]{1}[0-9]{3}[A-Za-z]{1}$|^[0-9]{11}$/;
ValidationService.anno = /^[1-2][0-9]{3}$/;
ValidationService.nSentenza = /^[0-9]*\/[1-2][0-9]{3}$/;
ValidationService.numberPattern = /^[0-9]*$/;
ValidationService.phoneNumberPattern = /^\+{0,1}[0-9]*$/;
ValidationService.moneyPattern = /^([0-9]+)|((([1-9][0-9]*)|([0-9]))([,])[0-9]{2})$/;
ValidationService.moneyCommaSeparated = /^\d+,\d{2}$/;
ValidationService.numbers = /^\d+/;
ValidationService.formatoName = /^[a-zA-Zàèìòùé ']+$/;

class InfoPfComponent {
    constructor(msg, validationService, cfService, delegheService) {
        this.msg = msg;
        this.validationService = validationService;
        this.cfService = cfService;
        this.delegheService = delegheService;
        this.readOnly = false;
        this.validatorFormControl = false;
        this.done = new EventEmitter();
        this.codiceRegione = "";
    }
    ngOnInit() {
        // console.log('[InfoAnagrafichePFDTO]', this.infopf);
        this.form = new FormGroup({});
        if (this.resetForm) {
            this.subscription = this.resetForm.subscribe(val => val ? this.pulisciForm() : "");
        }
        if (!this.infopf) {
            this.initInfoPf();
        }
        const cfValidators = [
            Validators.required,
            ValidationService.pattern(ValidationService.codiceFiscale, "cfInvalidoFormalmente"),
        ];
        if (this.cfDifferentFrom != null) {
            cfValidators.push(ValidationService.NotEquals(this.cfDifferentFrom, "cfDifferentRichiedente"));
        }
        const codiceFiscale = new FormControl({ value: this.infopf.codFiscale, disabled: false }, 
        // cfValidators
        // this.validatorFormControl ? cfValidators: Validators.nullValidator,
        [
            this.validatorFormControl ? Validators.required : Validators.nullValidator,
            ValidationService.pattern(ValidationService.codiceFiscale, "cfInvalidoFormalmente"),
        ]
        //TODO
        // [this.validationService.userValidator(TipiPersona.PERSONA_FISICA)]
        );
        this.form.addControl("codiceFiscale", codiceFiscale);
        const nome = new FormControl({ value: this.infopf.nome, disabled: false }, [
            // Validators.required,
            //	ValidationService.ValidateName,
            this.validatorFormControl ? Validators.required : Validators.nullValidator,
            ValidationService.pattern(ValidationService.formatoName, "formatoName")
        ]);
        this.form.addControl("nome", nome);
        const cognome = new FormControl({ value: this.infopf.cognome, disabled: false }, [
            //Validators.required,
            //ValidationService.ValidateName
            this.validatorFormControl ? Validators.required : Validators.nullValidator,
            ValidationService.pattern(ValidationService.formatoName, "formatoName")
        ]);
        this.form.addControl("cognome", cognome);
        // TODO
        // this.validationSub = codiceFiscale.valueChanges.pipe(
        // 	filter(val => val.length == 16),
        // 	auditTime(500)
        // )
        // 	.pipe(
        // 		tap((_) => {
        // 			if (codiceFiscale.errors) {
        // 				delete codiceFiscale.errors["invalidCF"];
        // 			}
        // 		}),
        // 		filter((cf) => codiceFiscale.valid),
        // 		switchMap((cf) =>
        // 			//TODO
        // 			// this.cfService
        // 			// 	.validaCodiceFiscale$(cf, "F")
        // 			// 	.pipe(catchError((err) => empty()))
        // 			this.delegheService.getPersonaFiscaleCodiceFiscale(cf)
        // 				.pipe(
        // 					//TODO
        // 					// catchError((err) => empty())
        // 					catchError(err => {
        // 						codiceFiscale.setErrors({ invalidCF: true });
        // 						return EMPTY;
        // 					})
        // 				)
        // 		),
        // 		tap((validationResult) => {
        // 			console.log('[validationResult]', validationResult);
        // 			// if (!validationResult.valid) {
        // 			if (validationResult == null) {
        // 				codiceFiscale.setErrors({ invalidCF: true });
        // 			} else {
        // 				if (validationResult.residenza != undefined) {
        // 					this.codiceRegione = validationResult?.residenza?.regione?.sigla;
        // 				}
        // 			}
        // 			this.form.updateValueAndValidity();
        // 		})
        // 	)
        // 	.subscribe();
        const changes$ = this.form.valueChanges.pipe(map((_) => {
            this.removeSpace(this.form.controls["codiceFiscale"].value);
            const pf = new InfoAnagrafichePFDTO();
            pf.codFiscale = this.form.controls["codiceFiscale"].value;
            pf.nome = this.form.controls["nome"].value;
            pf.cognome = this.form.controls["cognome"].value;
            pf.codiceRegione = this.codiceRegione;
            return pf;
        }), startWith(this.infopf), map((pf) => {
            // console.log(
            // 	"pf form valid",
            // 	FormUtils.getFormValidationErrors(this.form)
            // );
            const status = ComponentOutputStatus.of(!this.form.invalid || this.readOnly == true, pf);
            // console.log("status", status);
            return status;
        }));
        this.pfSub = changes$.subscribe((_) => this.done.emit(_));
        if (this.readOnly) {
            this.form.disable();
        }
    }
    removeSpace(value) {
        var reWhiteSpace = /\s/g;
        if (reWhiteSpace.test(value)) {
            this.form.get('codiceFiscale').setValue(value.replace(reWhiteSpace, ''));
        }
    }
    ngOnDestroy() {
        if (this.pfSub) {
            this.pfSub.unsubscribe();
        }
        if (this.validationSub) {
            this.validationSub.unsubscribe();
        }
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
    initInfoPf() {
        const infoPfNew = new InfoAnagrafichePFDTO();
        //TODO
        // if (this.userDetail) {
        // 	infoPfNew.codFiscale = this.userDetail["fiscalNumber"];
        // 	infoPfNew.cognome = this.userDetail["familyName"];
        // 	infoPfNew.nome = this.userDetail["name"];
        // }
        this.infopf = infoPfNew;
    }
    pulisciForm() {
        const keys = Object.keys(this.form.value);
        keys.forEach(key => {
            const control = this.form.get(key);
            control.setValue("");
        });
    }
    _resetForm() {
        var _a;
        (_a = this.form) === null || _a === void 0 ? void 0 : _a.reset();
    }
}
InfoPfComponent.decorators = [
    { type: Component, args: [{
                selector: "lib-info-pf",
                template: "<form [formGroup]=\"form\">\r\n\t<div class=\"row my-2\">\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'codice-fiscale' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{validatorFormControl ? ('required' | traduzione): ''}} {{'codice-fiscale' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"codiceFiscale\" uppercase style=\"text-transform: uppercase\" maxlength=\"16\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['codiceFiscale'].invalid\">\r\n\t\t\t\t\t{{msg.produceCFMessage(form.controls['codiceFiscale']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'codice-fiscale'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'nome' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{validatorFormControl ? ('required' | traduzione): ''}} {{'nome' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"nome\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['nome'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio',form.controls['nome']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'nome'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'cognome' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{validatorFormControl ? ('required' | traduzione): ''}} {{'cognome' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"cognome\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['cognome'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio',form.controls['cognome']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'cognome'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n</form>",
                styles: [""]
            },] }
];
InfoPfComponent.ctorParameters = () => [
    { type: MessageService },
    { type: ValidationService },
    { type: CodiceFiscaleService },
    { type: DelegheService }
];
InfoPfComponent.propDecorators = {
    infopf: [{ type: Input }],
    namespace: [{ type: Input }],
    cfDifferentFrom: [{ type: Input }],
    readOnly: [{ type: Input }],
    resetForm: [{ type: Input }],
    validatorFormControl: [{ type: Input }],
    done: [{ type: Output }]
};

class TerritorioService {
    constructor(http, configurationService, appRef) {
        this.http = http;
        this.configurationService = configurationService;
        this.appRef = appRef;
        console.log('[TerritorioService]');
        this.urlAnagrafe = configurationService.servicePaths.get("ANAGRAFE_MS_API_URL") + "/v1";
        console.log('[urlAnagrafe - lib]', this.urlAnagrafe);
        const lingua$ = configurationService.lingua$;
        // console.log('[lingua]', configurationService.servicePaths.get("I18N_MS_API_URL"));
        //TODO
        // const urlNazioni: string = this.paths.get_V1Nazioni();
        const urlNazioni = this.urlAnagrafe + "/nazioni";
        // console.log('[urlNazioni]', urlNazioni);
        this.nazioni$ = lingua$.pipe(switchMap(lingua => this.http.get(urlNazioni, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => appRef.tick()), shareReplay());
        //TODO
        // const urlProvince: string = this.paths.get_V1Province();
        const urlProvince = this.urlAnagrafe + '/province';
        // console.log('[urlProvince]', urlProvince);
        // TODO
        // const urlRegioni: string = this.urlAnagrafe + '/regioni';
        const urlRegioni = this.urlAnagrafe + '/regioni/nonSoppresse/';
        //TODO
        // this.province$ = this.http.get<Array<Localita>>(urlProvince);
        this.province$ = lingua$.pipe(switchMap(lingua => this.http.get(urlProvince, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => appRef.tick()), shareReplay());
        this.regioni$ = lingua$.pipe(switchMap(lingua => this.http.get(urlRegioni, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => appRef.tick()), shareReplay());
    }
    getProvince$() {
        return this.province$;
    }
    getProvincePerRegione$(regione) {
        //TODO
        // return this.configurationService.lingua$
        // 	.pipe(switchMap(lingua => this.http.get<Array<Localita>>(
        // 		this.urlAnagrafe + `/regione/${regione.sigla}/province`,
        // 		{ headers: new HttpHeaders({ 'i18n_language': lingua }) }
        // 	)));
        const url = `${this.urlAnagrafe}/regione/${regione.sigla}/province/nonSoppresse/?codiceRegione=${regione.sigla}`;
        return this.configurationService.lingua$.pipe(switchMap(lingua => this.http.get(url, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => this.appRef.tick()), shareReplay());
    }
    getComuni$(siglaProvincia) {
        //TODO
        // const url: string = this.paths.get_V1ComuniByProvincia(siglaProvincia);
        // const url: string = `${this.urlAnagrafe}/provincia/${siglaProvincia}/comuni`
        const url = `${this.urlAnagrafe}/provincia/${siglaProvincia}/comuni/nonSoppressi`;
        return this.http.get(url).pipe(shareReplay());
    }
    getComune$(codiceCatastale) {
        const url = `${this.urlAnagrafe}/comune/codiceCatastale/${codiceCatastale}`;
        return this.http.get(url).pipe(shareReplay());
    }
    getNazioni$() {
        return this.nazioni$;
    }
    getCap$(idComune) {
        //TODO
        // const url: string = this.paths.get_V1CapByIdComune(idComune);
        const url = `${this.urlAnagrafe}/comuni/${idComune}/cap`;
        return this.http.get(url);
    }
    getRegioni$() {
        return this.regioni$;
    }
}
TerritorioService.ɵprov = ɵɵdefineInjectable({ factory: function TerritorioService_Factory() { return new TerritorioService(ɵɵinject(HttpClient), ɵɵinject(ConfigurationService), ɵɵinject(ApplicationRef)); }, token: TerritorioService, providedIn: "root" });
TerritorioService.decorators = [
    { type: Injectable, args: [{ providedIn: 'root'
            },] }
];
TerritorioService.ctorParameters = () => [
    { type: HttpClient },
    { type: ConfigurationService },
    { type: ApplicationRef }
];

class InfoNascitaComponent {
    constructor(msg, territorio, validationService, territorioService) {
        this.msg = msg;
        this.territorio = territorio;
        this.validationService = validationService;
        this.territorioService = territorioService;
        this.maxDate = new Date();
        this.readOnly = false;
        this.done = new EventEmitter();
        this.ITALIA = 'IT';
        this.ITALIACodCat = 'Z000';
        this.nazioni$ = territorioService.getNazioni$();
        this.nazioni$.subscribe(nazioni => {
            this.nazioni = nazioni;
        });
    }
    ngOnChanges(changes) {
        this.initialize();
    }
    ngOnInit() {
        var _a, _b, _c;
        // console.log('[InfoNascitaComponent] infonascita', this.infonascita);
        this.form = new FormGroup({});
        this.initialize();
        // const isNatoEstero =
        // 	this.infonascita.comuneNascita != null &&
        // 	this.infonascita.comuneNascita.startsWith("Z");
        const isNatoEstero = ((_a = this.infonascita) === null || _a === void 0 ? void 0 : _a.isNatoEstero) ? this.infonascita.isNatoEstero : false;
        if (!isNatoEstero) {
            this.infonascita.nazioneNascita = this.ITALIA;
            this.infonascita.codCatNazioneNascita = this.ITALIACodCat;
        }
        const isNatoEsteroCheck = new FormControl({ value: isNatoEstero, disabled: false }, [Validators.required]);
        this.form.addControl("isNatoEstero", isNatoEsteroCheck);
        const provinciaNascita = new FormControl({ value: this.infonascita.provinciaNascita, disabled: false }, [Validators.required]);
        this.form.addControl("provinciaNascita", provinciaNascita);
        const comuneNascita = new FormControl({ value: ((_b = this.infonascita) === null || _b === void 0 ? void 0 : _b.comuneNascita) ? (_c = this.infonascita) === null || _c === void 0 ? void 0 : _c.comuneNascita : this.ITALIACodCat, disabled: false }, [Validators.required]);
        this.form.addControl("comuneNascita", comuneNascita);
        const dataNascita = new FormControl({ value: this.infonascita.dataNascita, disabled: false }, [Validators.required, ValidationService.ValidateDate]);
        this.form.addControl("dataNascita", dataNascita);
        const codCatNazioneNascita = new FormControl({ value: this.infonascita.codCatNazioneNascita, disabled: false }, [Validators.required]);
        this.form.addControl("codCatNazioneNascita", codCatNazioneNascita);
        if (this.readOnly) {
            this.form.disable();
            this.isNatoEstero$ = isNatoEsteroCheck.valueChanges.pipe(startWith(isNatoEstero));
        }
        else {
            this.isNatoEstero$ = isNatoEsteroCheck.valueChanges.pipe(tap(isEstero => isEstero
                ? codCatNazioneNascita.setValue(null)
                : (provinciaNascita.setValue(null), comuneNascita.setValue(null))), startWith(isNatoEstero), tap((isEstero) => {
                if (isEstero) {
                    codCatNazioneNascita.enable();
                    comuneNascita.disable();
                    provinciaNascita.disable();
                }
                else {
                    codCatNazioneNascita.disable();
                    comuneNascita.enable();
                    provinciaNascita.enable();
                }
            }));
        }
        const changes$ = this.form.valueChanges.pipe(map((_) => {
            var _a, _b;
            const infonascita = new InfoNascitaPFDTO();
            infonascita.dataNascita = moment(this.form.controls["dataNascita"].value).toDate();
            if ((_a = this.form.controls["isNatoEstero"]) === null || _a === void 0 ? void 0 : _a.value) {
                infonascita.isNatoEstero = this.form.controls["isNatoEstero"].value;
                //infonascita.comuneNascita = null;
                if ((_b = this.form.controls["codCatNazioneNascita"]) === null || _b === void 0 ? void 0 : _b.value) {
                    let nazioneSelected = this.nazioni.find(nazione => { var _a; return nazione.codiceCatastale == ((_a = this.form.controls["codCatNazioneNascita"]) === null || _a === void 0 ? void 0 : _a.value); });
                    if (nazioneSelected) {
                        infonascita.codCatNazioneNascita = nazioneSelected.codiceCatastale;
                        infonascita.nazioneNascita = nazioneSelected.sigla;
                        infonascita.comuneNascita = nazioneSelected.codiceCatastale;
                    }
                }
                infonascita.provinciaNascita = "EE";
            }
            else {
                infonascita.isNatoEstero = null;
                infonascita.comuneNascita = this.form.controls["comuneNascita"].value;
                infonascita.provinciaNascita = this.form.controls["provinciaNascita"].value;
                infonascita.codCatNazioneNascita = this.ITALIACodCat;
                infonascita.nazioneNascita = this.ITALIA;
            }
            return infonascita;
        }), startWith(this.infonascita), map((infonascita) => ComponentOutputStatus.of(this.form.valid || this.readOnly, infonascita)));
        this.subscription = changes$.subscribe((_) => this.done.emit(_));
        this.comuni$ = provinciaNascita.valueChanges.pipe(tap(_ => comuneNascita.setValue(null)), startWith(this.infonascita.provinciaNascita), filter((x) => x), switchMap((value) => this.territorio.getComuni$(value)));
    }
    initialize() {
        if (!this.infonascita) {
            this.infonascita = this.initInfoNascita();
        }
    }
    initInfoNascita() {
        const initInfoNascitaNew = new InfoNascitaPFDTO();
        return initInfoNascitaNew;
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    compareComuni(c1, c2) {
        return c1 && c2 ? c1.codiceCatastale === c2.codiceCatastale : c1 === c2;
    }
    _resetForm() {
        var _a;
        (_a = this.form) === null || _a === void 0 ? void 0 : _a.reset();
    }
}
InfoNascitaComponent.decorators = [
    { type: Component, args: [{
                selector: "lib-info-nascita",
                template: "<div [formGroup]=\"form\">\r\n\t<mat-checkbox formControlName=\"isNatoEstero\" *ngIf=\"!readOnly\">\r\n\t\t<!-- {{'localita-nascita-estera' | traduzione}} -->\r\n\t\t<info-tip-label label=\"localita-nascita-estera\"></info-tip-label>\r\n\t</mat-checkbox>\r\n\r\n\t<div class=\"row my-2\">\r\n\t\t<div class=\"col-md-4\" *ngIf=\"!(isNatoEstero$ | async)\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-label>{{'required' | traduzione}}{{'provincia-nascita' | traduzione}}</mat-label>\r\n\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"provinciaNascita\">\r\n\t\t\t\t\t<mat-option *ngFor=\"let provincia of province | async\" [value]=\"provincia.sigla\">\r\n\t\t\t\t\t\t{{ provincia.denominazione }}\r\n\t\t\t\t\t</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['provinciaNascita'].invalid\">\r\n\t\t\t\t\t{{\r\n\t\t\t\t\tmsg.produceMessage(\r\n\t\t\t\t\t\"obbligatorio\",\r\n\t\t\t\t\tform.controls[\"provinciaNascita\"]\r\n\t\t\t\t\t) | traduzione\r\n\t\t\t\t\t}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'provincia-nascita'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"col-md-4\" *ngIf=\"!(isNatoEstero$ | async)\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-label>{{'required' | traduzione}}{{'comune-nascita' | traduzione}}</mat-label>\r\n\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"comuneNascita\">\r\n\t\t\t\t\t<mat-option *ngFor=\"let comune of comuni$ | async\" [value]=\"comune.codiceCatastale\">\r\n\t\t\t\t\t\t{{ comune.denominazione }}\r\n\t\t\t\t\t</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['comuneNascita'].invalid\">\r\n\t\t\t\t\t{{\r\n\t\t\t\t\tmsg.produceMessage(\"obbligatorio\", form.controls[\"comuneNascita\"]) | traduzione\r\n\t\t\t\t\t}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'comune-nascita'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"col-md-4\" *ngIf=\"isNatoEstero$ | async\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-label>{{'required' | traduzione}}{{'nazione-nascita' | traduzione}}</mat-label>\r\n\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"codCatNazioneNascita\">\r\n\t\t\t\t\t<mat-option *ngFor=\"let nazione of nazioni$ | async\" [value]=\"nazione.codiceCatastale\">\r\n\t\t\t\t\t\t{{ nazione.denominazione }}\r\n\t\t\t\t\t</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['codCatNazioneNascita'].invalid\">\r\n\t\t\t\t\t{{\r\n\t\t\t\t\tmsg.produceMessage(\"obbligatorio\", form.controls[\"codCatNazioneNascita\"]) | traduzione\r\n\t\t\t\t\t}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'nazione-nascita'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input [max]=\"maxDate\" matInput [matDatepicker]=\"dataNascita\"\r\n\t\t\t\t\tplaceholder=\"{{'required' | traduzione}}{{'data-nascita' | traduzione}}\" formControlName=\"dataNascita\" />\r\n\t\t\t\t<mat-datepicker-toggle matSuffix [for]=\"dataNascita\"></mat-datepicker-toggle>\r\n\t\t\t\t<mat-datepicker #dataNascita></mat-datepicker>\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['dataNascita'].invalid\">\r\n\t\t\t\t\t{{ msg.getErrorData(form.controls[\"dataNascita\"]) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'data-nascita'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n</div>\r\n",
                styles: [""]
            },] }
];
InfoNascitaComponent.ctorParameters = () => [
    { type: MessageService },
    { type: TerritorioService },
    { type: ValidationService },
    { type: TerritorioService }
];
InfoNascitaComponent.propDecorators = {
    infonascita: [{ type: Input }],
    province: [{ type: Input }],
    namespace: [{ type: Input }],
    readOnly: [{ type: Input }],
    done: [{ type: Output }]
};

class CodiceFiscaleServiceImpl extends CodiceFiscaleService {
    constructor(http, configurationService) {
        super();
        this.http = http;
        this.configurationService = configurationService;
        console.log('[CodiceFiscaleService]');
        //TODO
        // this.urlArgo = configurationService.servicePaths.get("ARGO_INTEGRATION_MS_API_URL") + "/v1";
        this.urlArgo = configurationService.servicePaths.get("ARGO_INTEGRATION_MS_API_URL") + "/v2";
        console.log('[urlArgo - lib]', this.urlArgo);
    }
    validaCodiceFiscale$(codiceFiscale, tipoPersona) {
        const url = this.urlArgo + '/checkfs/cf';
        return this.http.put(url, { codiceFiscale, tipoPersona });
        //TODO
        // const url: string = this.paths.get_V1CheckFC();
        // const url: string = this.urlArgo + '/checkfs/cf';
        // return this.http.get<ValidationOutcomeDTO>(url, {
        // 	params: {
        // 		codicefiscale: codiceFiscale,
        // 		tipopersona: tipoPersona
        // 	}
        // });
    }
}
CodiceFiscaleServiceImpl.ɵprov = ɵɵdefineInjectable({ factory: function CodiceFiscaleServiceImpl_Factory() { return new CodiceFiscaleServiceImpl(ɵɵinject(HttpClient), ɵɵinject(ConfigurationService)); }, token: CodiceFiscaleServiceImpl, providedIn: "root" });
CodiceFiscaleServiceImpl.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
CodiceFiscaleServiceImpl.ctorParameters = () => [
    { type: HttpClient },
    { type: ConfigurationService }
];

class PgValidation {
    constructor(valid, pg) {
        this.valid = valid;
        this.pg = pg;
    }
}
class PersonaGiuridicaComponent {
    constructor(msg, delegheService, dialog) {
        this.msg = msg;
        this.delegheService = delegheService;
        this.dialog = dialog;
        this.validatorFormControl = false;
        this.couldBeDittaIndividuale = true;
        this.done = new EventEmitter();
        this.changeSedi$ = new ReplaySubject(1);
        this.changePG$ = new ReplaySubject(1);
        this.personaSelected$ = new BehaviorSubject(null);
        this.CODICE_LEGALE = "LEGALE";
        this.errorSedi$ = new Subject();
    }
    ngOnDestroy() {
        var _a, _b, _c, _d;
        (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
        (_b = this.subValidation) === null || _b === void 0 ? void 0 : _b.unsubscribe();
        (_c = this.subCF) === null || _c === void 0 ? void 0 : _c.unsubscribe();
        (_d = this.invalidPgsSubscriptions) === null || _d === void 0 ? void 0 : _d.unsubscribe();
    }
    ngOnInit() {
        var _a, _b, _c;
        //GESTIONE_SEDI
        this.streamListaSedi$ = new ReplaySubject();
        this.changeSedi$.next(ComponentOutputStatus.of(!this.gestioneSedi, (pg) => pg));
        //SE_INPUT_DATI_SOSCIETA_ESISTE => RECUPERO LE SEDI
        ((_a = this.datisocieta) === null || _a === void 0 ? void 0 : _a.sedi) ?
            this.streamListaSedi$.next((_b = this.datisocieta) === null || _b === void 0 ? void 0 : _b.sedi) :
            null;
        //VALIDAZIONE_INIZIALE
        const valid = false;
        this.form = new FormGroup({});
        if (this.resetForm) {
            this.subscription = this.resetForm.subscribe(val => val ? this.pulisciForm() : "");
        }
        if (!this.datisocieta) {
            this.initDatiSocieta();
        }
        const codiceFiscale = new FormControl({ value: this.datisocieta.codiceFiscale, disabled: this.personaGiuridicaFromDeleghe$ == null ? false : true }, [
            this.validatorFormControl ? Validators.required : Validators.nullValidator,
            ValidationService.pattern(this.couldBeDittaIndividuale ? ValidationService._codiceFiscalePiva : ValidationService.partitaIva, "cfInvalidoFormalmente"),
        ]);
        this.form.addControl("codiceFiscale", codiceFiscale);
        const ragioneSociale = new FormControl({ value: this.datisocieta.ragioneSociale, disabled: true }, [
        // this.validatorFormControl ? Validators.required : Validators.nullValidator
        ]);
        this.form.addControl("ragioneSociale", ragioneSociale);
        const partitaIVA = new FormControl({ value: this.datisocieta.partitaIVA, disabled: true }, [
        // this.validatorFormControl ? Validators.required : Validators.nullValidator,
        // ValidationService.pattern(
        // 	ValidationService.partitaIva,
        // 	"partitaIVAInvalida"
        // ),
        ]);
        this.form.addControl("partitaIVA", partitaIVA);
        if (this.personaGiuridicaFromDeleghe$) {
            this.personaGiuridica$ = this.personaGiuridicaFromDeleghe$
                .pipe(map(pg => new PgValidation(true, pg)), catchError(_ => of(new PgValidation(false, null))), shareReplay());
        }
        else {
            this.personaGiuridica$ = this.form.get('codiceFiscale').valueChanges
                .pipe(auditTime(1000), switchMap(value => {
                return ((this.couldBeDittaIndividuale && ((value === null || value === void 0 ? void 0 : value.length) == 11 || (value === null || value === void 0 ? void 0 : value.length) == 16))
                    ||
                        (!this.couldBeDittaIndividuale && (value === null || value === void 0 ? void 0 : value.length) == 11))
                    ?
                        this.delegheService.getPersonaGiuridicaCodiceFiscale(value)
                            .pipe(map(pg => new PgValidation(true, pg)), catchError(_ => this.catchPersonaGiuridicaError())) :
                    of(new PgValidation(false, null));
            }), shareReplay(), tap((validationResult) => {
                console.log('[validationResult]', validationResult);
            }), shareReplay());
        }
        const validPgs$ = this.personaGiuridica$.pipe(filter(v => v.valid), map(v => v.pg));
        const invalidPgs$ = this.personaGiuridica$.pipe(filter(pg => !pg.valid));
        //EVOLUZIONE_PG
        const pg$ = this.buildStreamChangePG$(validPgs$);
        const pgChange$ = pg$.pipe(tap(pg => this.setSedi(pg['sedi'])), tap(pg => this.controlloSedeLegale(pg)), map(pg => {
            var _a;
            const validity = ((_a = pg['sedi']) === null || _a === void 0 ? void 0 : _a.find(sede => sede.tipoSede['codice'] == this.CODICE_LEGALE)) ?
                !this.form.invalid
                : false;
            return ComponentOutputStatus.of(validity, (personaGiuridica) => Object.keys(pg)
                .forEach(key => personaGiuridica[key] = pg[key]));
        }));
        //___Validazione___
        const changes$ = ComponentReducer
            .reducer2(pgChange$, this.changeSedi$, _ => true, ComponentOutputStatus.of(valid, this.datisocieta));
        //____OUTPUT_COMPONENT____
        this.subscription = changes$.subscribe((_) => this.done.emit(_));
        this.invalidPgsSubscriptions = invalidPgs$.subscribe(_ => {
            this.form.get('partitaIVA').setValue("");
            this.form.get('ragioneSociale').setValue("");
            this.personaSelected$.next(null);
            this.done.emit(ComponentOutputStatus.of(false, new PersonaGiuridicaDTO()));
        });
        if (this.datisocieta) {
            codiceFiscale.setValue((_c = this.datisocieta) === null || _c === void 0 ? void 0 : _c.codiceFiscale);
        }
        //CF_DALL'ESTERNO
        if (this.cf$) {
            this.subCF = this.cf$
                .pipe(tap(cf => codiceFiscale.setValue(cf)))
                .subscribe();
        }
    }
    ngOnChanges(changes) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
        console.log('ngOnChanges:', changes);
        if ((_b = (_a = this.form) === null || _a === void 0 ? void 0 : _a.controls) === null || _b === void 0 ? void 0 : _b.codiceFiscale) {
            (_d = (_c = this.form) === null || _c === void 0 ? void 0 : _c.controls) === null || _d === void 0 ? void 0 : _d.codiceFiscale.setValidators(null);
            (_f = (_e = this.form) === null || _e === void 0 ? void 0 : _e.controls) === null || _f === void 0 ? void 0 : _f.codiceFiscale.setValidators([
                this.validatorFormControl ? Validators.required : Validators.nullValidator,
                ValidationService.pattern(this.couldBeDittaIndividuale ? ValidationService._codiceFiscalePiva : ValidationService.partitaIva, "cfInvalidoFormalmente"),
            ]);
            if (((_g = changes === null || changes === void 0 ? void 0 : changes.couldBeDittaIndividuale) === null || _g === void 0 ? void 0 : _g.currentValue) == true || ((_h = changes === null || changes === void 0 ? void 0 : changes.couldBeDittaIndividuale) === null || _h === void 0 ? void 0 : _h.currentValue) == false) {
                if ((((_j = changes === null || changes === void 0 ? void 0 : changes.couldBeDittaIndividuale) === null || _j === void 0 ? void 0 : _j.currentValue) != ((_k = changes === null || changes === void 0 ? void 0 : changes.couldBeDittaIndividuale) === null || _k === void 0 ? void 0 : _k.previousValue)) || ((_l = changes === null || changes === void 0 ? void 0 : changes.couldBeDittaIndividuale) === null || _l === void 0 ? void 0 : _l.previousValue) === undefined) {
                    (_p = (_o = (_m = this.form) === null || _m === void 0 ? void 0 : _m.controls) === null || _o === void 0 ? void 0 : _o.codiceFiscale) === null || _p === void 0 ? void 0 : _p.patchValue(null);
                }
            }
            //this.form?.controls?.codiceFiscale?.updateValueAndValidity();
        }
    }
    catchPersonaGiuridicaError() {
        this.dialog.open(GenericModalComponent, { data: { title: 'persona-giuridica-by-cf-error-titolo',
                azioni: [new Azione('ok')],
                paragrafi: ['modalita-pagamento-dialog-testo']
            }, panelClass: 'custom-modalbox-ko' });
        return of(new PgValidation(false, null));
    }
    controlloSedeLegale(pg) {
        var _a, _b;
        const sedeLegale = (_a = pg['sedi']) === null || _a === void 0 ? void 0 : _a.find(sede => sede.tipoSede['codice'] == this.CODICE_LEGALE);
        let error;
        if (((_b = pg['sedi']) === null || _b === void 0 ? void 0 : _b.length) == 0 || !pg['sedi']) {
            error = "nessunaSede";
        }
        else if (!sedeLegale) {
            error = "nessunaSedeLegale";
        }
        this.errorSedi$.next(error);
    }
    buildStreamChangePG$(personaGiuridica$) {
        return personaGiuridica$
            .pipe(tap(pg => this.personaSelected$.next(pg)), map(pg => {
            var _a, _b, _c, _d;
            return {
                codiceFiscale: pg.datiPersonaGiuridica.codiceFiscale,
                partitaIVA: pg.datiPersonaGiuridica.partitaIVA,
                ragioneSociale: pg.datiPersonaGiuridica.ragioneSociale,
                idPersonaGiuridica: pg.datiPersonaGiuridica.id,
                codiceRegione: (_d = (_c = (_b = (_a = pg === null || pg === void 0 ? void 0 : pg.sedi) === null || _a === void 0 ? void 0 : _a.filter(sedeLegale => { var _a; return ((_a = sedeLegale === null || sedeLegale === void 0 ? void 0 : sedeLegale.tipoSede) === null || _a === void 0 ? void 0 : _a.codice) === "LEGALE"; })[0]) === null || _b === void 0 ? void 0 : _b.indirizzo) === null || _c === void 0 ? void 0 : _c.regione) === null || _d === void 0 ? void 0 : _d.sigla,
                sedi: pg.sedi,
                hasAmmUtenze: pg.hasAmmUtenze
            };
        }), tap(pg => {
            this.form.get('partitaIVA').setValue(pg['partitaIVA']);
            this.form.get('ragioneSociale').setValue(pg['ragioneSociale']);
        }), startWith(ComponentOutputStatus.of(false, pg => pg)));
    }
    setSedi(sedi) {
        given(sedi)
            .when(is(null), () => this.streamListaSedi$.next([]))
            .otherwise(() => this.streamListaSedi$.next(sedi))
            .valueOf()();
    }
    sediReady(sedeSelectedStatus) {
        // console.log("[sedeSelectedStatus]", sedeSelectedStatus);
        this.changeSedi$.next(sedeSelectedStatus.mapValue((sede) => (pg) => pg.sedi = sede));
    }
    initDatiSocieta() {
        this.datisocieta = new PersonaGiuridicaDTO();
    }
    pulisciForm() {
        const keys = Object.keys(this.form.value);
        keys.forEach(key => {
            const control = this.form.get(key);
            control.setValue("");
        });
    }
}
PersonaGiuridicaComponent.decorators = [
    { type: Component, args: [{
                selector: "lib-persona-giuridica",
                template: "<div [formGroup]=\"form\">\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}} {{'codice-fiscale' | traduzione}}\" -->\r\n\t\t\t\t<input matInput\r\n\t\t\t\t\tplaceholder=\"{{validatorFormControl ? ('required' | traduzione): ''}} {{'codice-fiscale' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"codiceFiscale\" uppercase style=\"text-transform: uppercase\" maxlength=\"16\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['codiceFiscale'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('codiceFiscaleInvalido', form.controls[ 'codiceFiscale']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'codice-fiscale'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<!-- <div class=\"col-md-4\" [hidden]= \"!editingDisabled\"> -->\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'ragione-sociale' | traduzione}}\" -->\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{validatorFormControl ? ('required' | traduzione): ''}} {{'ragione-sociale' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'ragione-sociale' | traduzione}}\" formControlName=\"ragioneSociale\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['ragioneSociale'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['ragioneSociale']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'ragione-sociale'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<!-- <div class=\"col-md-4\" [hidden]= \"!editingDisabled\"> -->\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'partita-iva' | traduzione}}\" -->\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{validatorFormControl ? ('required' | traduzione): ''}} {{'partita-iva' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'partita-iva' | traduzione}}\" formControlName=\"partitaIVA\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['partitaIVA'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('partitaIVAInvalida', form.controls['partitaIVA']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'partita-iva'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n\t<ng-container *ngIf=\"gestioneSedi; else noGestioneSedi\">\r\n\t\t<ng-container *ngIf=\"personaSelected$ | async\">\r\n\t\t\t<ng-container *ngIf=\"(personaGiuridicaFromDeleghe$ == null) && (personaSelected$ | async).hasAmmUtenze;\r\n\t\t\t\telse visualizzaSedi\">\r\n\t\t\t\t<mat-error>\r\n\t\t\t\t\t{{'contattare-amministratore' | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</ng-container>\r\n\t\t\t<ng-template #visualizzaSedi>\r\n\t\t\t\t<lib-tabella-sedi [sedi$]=\"streamListaSedi$\" (done)=\"sediReady($event)\"\r\n\t\t\t\t\t[idSedeSelezionata]=\"idSedeSelezionata\">\r\n\t\t\t\t</lib-tabella-sedi>\r\n\t\t\t</ng-template>\r\n\t\t</ng-container>\r\n\t</ng-container>\r\n\r\n\t<ng-template #noGestioneSedi>\r\n\t\t<div *ngIf=\" errorSedi$ | async as errorSedi\">\r\n\t\t\t<ng-container *ngIf=\"errorSedi=='nessunaSede'\">\r\n\t\t\t\t<mat-error>\r\n\t\t\t\t\t{{'nessunaSede' | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</ng-container>\r\n\t\t\t<ng-container *ngIf=\"errorSedi=='nessunaSedeLegale'\">\r\n\t\t\t\t<mat-error>\r\n\t\t\t\t\t{{'nessunaSedeLegale' | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</ng-container>\r\n\t\t</div>\r\n\t</ng-template>\r\n</div>",
                styles: [""]
            },] }
];
PersonaGiuridicaComponent.ctorParameters = () => [
    { type: MessageService },
    { type: DelegheService },
    { type: MatDialog }
];
PersonaGiuridicaComponent.propDecorators = {
    cf$: [{ type: Input }],
    datisocieta: [{ type: Input }],
    idSedeSelezionata: [{ type: Input }],
    namespace: [{ type: Input }],
    resetForm: [{ type: Input }],
    validatorFormControl: [{ type: Input }],
    gestioneSedi: [{ type: Input }],
    couldBeDittaIndividuale: [{ type: Input }],
    personaGiuridicaFromDeleghe$: [{ type: Input }],
    done: [{ type: Output }]
};

class IndirizzoComponent {
    constructor() {
        this.done = new EventEmitter();
    }
    ngOnInit() {
        console.log('[IndirizzoDTO]', this.indirizzo);
        this.form = new FormGroup({});
        const isIndirizzoEstero = this.indirizzo != null &&
            this.indirizzo.localita != null &&
            this.indirizzo.localita.comune != null &&
            this.indirizzo.localita.comune.startsWith('Z');
        const indirizzoEstero = new FormControl({ value: isIndirizzoEstero, disabled: false }, [Validators.required]);
        this.form.addControl('indirizzoEstero', indirizzoEstero);
        this.isIndirizzoEstero$ = indirizzoEstero.valueChanges.pipe(tap(_ => {
            this.done.emit(ComponentOutputStatus.of(false, null));
        }), shareReplay(), startWith(isIndirizzoEstero));
    }
    indirizzoReady(indirizzoStatus) {
        this.done.emit(indirizzoStatus);
    }
}
IndirizzoComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-indirizzo',
                template: "<div [formGroup]=\"form\">\r\n\t<mat-checkbox formControlName=\"indirizzoEstero\" [disabled]=\"viewOnly\">\r\n\t\t{{'indirizzo-estero' | traduzione}}\r\n\t</mat-checkbox>\r\n\r\n\t<lib-indirizzo-italiano\r\n\t\t*ngIf=\"!(isIndirizzoEstero$ | async)\"\r\n\t\t(done)=\"indirizzoReady($event)\"\r\n\t\t[indirizzo]=\"indirizzo\"\r\n\t\t[province]=\"province\"\r\n\t\t[viewOnly]=\"viewOnly\"\r\n\t>\r\n\t</lib-indirizzo-italiano>\r\n\r\n\t<lib-indirizzo-estero\r\n\t\t*ngIf=\"isIndirizzoEstero$ | async\"\r\n\t\t(done)=\"indirizzoReady($event)\"\r\n\t\t[indirizzo]=\"indirizzo\"\r\n\t\t[viewOnly]=\"viewOnly\"\r\n\t>\r\n\t</lib-indirizzo-estero>\r\n</div>",
                styles: [""]
            },] }
];
IndirizzoComponent.ctorParameters = () => [];
IndirizzoComponent.propDecorators = {
    indirizzo: [{ type: Input }],
    viewOnly: [{ type: Input }],
    province: [{ type: Input }],
    descrizioneLocalia: [{ type: Input }],
    done: [{ type: Output }]
};

class IndirizzoDTO {
}

class IndirizzoItalianoComponent {
    constructor(msg) {
        this.msg = msg;
        this.done = new EventEmitter();
        this.changesStrada$ = new Subject();
        this.changesLocalita$ = new Subject();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        let valid = true;
        if (!this.indirizzo) {
            this.indirizzo = new IndirizzoDTO();
            valid = false;
        }
        this.namespaceStrada = this.namespace + 'strada';
        this.namespaceLoc = this.namespace + 'loc';
        const indirizzoChanged$ = ComponentReducer.reducer2(this.changesStrada$, this.changesLocalita$, ind => ind.localita != null && ind.strada != null, ComponentOutputStatus.of(valid, this.indirizzo));
        this.indirizzoChangedSub = indirizzoChanged$.
            subscribe((newIndirizzo) => {
            this.done.emit(newIndirizzo);
        });
    }
    localitaReady(localitaStatus) {
        this.changesLocalita$.next(localitaStatus.mapValue(localita => (ind) => ind.localita = localita));
    }
    stradaReady(stradaStatus) {
        this.changesStrada$.next(stradaStatus.mapValue(strada => (ind) => ind.strada = strada));
    }
}
IndirizzoItalianoComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-indirizzo-italiano',
                template: "<div [formGroup]=\"form\">\r\n\t<lib-strada\r\n\t\t(done)=\"stradaReady($event)\"\r\n\t\t[strada]=\"indirizzo.strada\"\r\n\t\t[viewOnly]=\"viewOnly\"\r\n\t>\r\n\t</lib-strada>\r\n\t<lib-localita\r\n\t\t(done)=\"localitaReady($event)\"\r\n\t\t[localita]=\"indirizzo.localita\"\r\n\t\t[province$]=\"province\"\r\n\t\t[viewOnly]=\"viewOnly\"\r\n\t>\r\n\t</lib-localita>\r\n</div>",
                styles: [""]
            },] }
];
IndirizzoItalianoComponent.ctorParameters = () => [
    { type: MessageService }
];
IndirizzoItalianoComponent.propDecorators = {
    indirizzo: [{ type: Input }],
    viewOnly: [{ type: Input }],
    province: [{ type: Input }],
    done: [{ type: Output }],
    namespace: [{ type: Input }]
};

class LocalitaDTO {
}

class StradaDTO {
}

class IndirizzoEsteroComponent {
    constructor(msg, territorioService) {
        this.msg = msg;
        this.territorioService = territorioService;
        this.done = new EventEmitter();
        this.nazioni = territorioService.getNazioni$();
    }
    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
    ngOnInit() {
        this.form = new FormGroup({});
        let valid = true;
        if (!this.indirizzo) {
            this.indirizzo = new IndirizzoDTO();
            this.indirizzo.localita = new LocalitaDTO();
            this.indirizzo.strada = new StradaDTO();
            valid = false;
        }
        const indirizzo = new FormControl({ value: this.indirizzo.strada.inidirizzo, disabled: false }, [Validators.required, Validators.maxLength(50)]);
        this.form.addControl("indirizzo", indirizzo);
        // const zip = new FormControl(
        //   {value: this.indirizzo.localita.cap, disabled: false}, [Validators.required]
        // );
        // this.form.addControl('zip', zip);
        const nazioni = new FormControl({ value: this.indirizzo.localita.comune, disabled: false }, [Validators.required]);
        this.form.addControl("nazioni", nazioni);
        const changes$ = this.form.valueChanges.pipe(map((_) => {
            const localita = new LocalitaDTO();
            // localita.cap = zip.value;
            localita.provincia = "EE";
            localita.comune = nazioni.value;
            const strada = new StradaDTO();
            strada.inidirizzo = indirizzo.value;
            const indirizzoMapped = new IndirizzoDTO();
            indirizzoMapped.localita = localita;
            indirizzoMapped.strada = strada;
            return ComponentOutputStatus.of(this.form.valid, indirizzoMapped);
        }));
        this.subscription = changes$.subscribe((_) => this.done.emit(_));
    }
}
IndirizzoEsteroComponent.decorators = [
    { type: Component, args: [{
                selector: "lib-indirizzo-estero",
                template: "<form [formGroup]=\"form\">\r\n\t<div class=\"row my-2\">\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-label>{{'required' | traduzione}}{{'nazione' | traduzione}}</mat-label>\r\n\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"{{ 'nazioni' }}\">\r\n\t\t\t\t\t<mat-option *ngFor=\"let nazione of nazioni | async\" [value]=\"nazione.codiceCatastale\">\r\n\t\t\t\t\t\t{{ nazione.denominazione }}\r\n\t\t\t\t\t</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['nazioni'].invalid\">\r\n\t\t\t\t\t{{ msg.produceMessage(\"obbligatorio\", form.controls[\"nazioni\"]) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"row my-2\">\r\n\t\t<div class=\"col-md-12\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input matInput placeholder=\"{{'required' | traduzione}}{{'indirizzo' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"{{ 'indirizzo' }}\" />\r\n\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['indirizzo'].invalid\">\r\n\t\t\t\t\t{{ msg.produceMessage(\"obbligatorio\", form.controls[\"indirizzo\"]) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n</form>",
                styles: [""]
            },] }
];
IndirizzoEsteroComponent.ctorParameters = () => [
    { type: MessageService },
    { type: TerritorioService }
];
IndirizzoEsteroComponent.propDecorators = {
    indirizzo: [{ type: Input }],
    done: [{ type: Output }]
};

class StradaComponent {
    constructor(msg, territorio) {
        this.msg = msg;
        this.territorio = territorio;
        this.done = new EventEmitter();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        if (!this.strada) {
            this.initStrada();
        }
        const stradaIndirizzo = new FormControl({ value: this.strada.inidirizzo, disabled: this.viewOnly }, c => {
            if (this.viewOnly)
                return {};
            return String(c.value).trim().length > 0
                ? {}
                : { required: true };
        });
        this.form.addControl('stradaIndirizzo', stradaIndirizzo);
        const stradaCivico = new FormControl({ value: this.strada.civico, disabled: this.viewOnly }, c => {
            if (this.viewOnly)
                return {};
            return String(c.value).trim().length > 0
                ? {}
                : { required: true };
        });
        this.form.addControl('stradaCivico', stradaCivico);
        const stradaOut = new StradaDTO;
        stradaOut.inidirizzo = stradaIndirizzo.value;
        stradaOut.civico = stradaCivico.value;
        this.changes$ = new BehaviorSubject(ComponentOutputStatus.of(false, stradaOut));
        this.subScriptionChange = this.form.valueChanges.pipe(tap(valueChange => {
            const stradaOut = new StradaDTO();
            stradaOut.inidirizzo = valueChange.stradaIndirizzo;
            stradaOut.civico = valueChange.stradaCivico;
            return this.changes$.next(ComponentOutputStatus.of(
            /* 	this.form.valid  && */
            stradaOut.inidirizzo != null
                //    &&  stradaOut.tipoToponimo != null
                && stradaOut.civico != null, stradaOut));
        })).subscribe();
        this.subscription = this.changes$.subscribe(x => {
            this.done.emit(x);
            console.log("changes$", x);
        });
        this.changes$.next(ComponentOutputStatus.of(
        /* 	this.form.valid  && */
        stradaOut.inidirizzo != null
            //    &&  stradaOut.tipoToponimo != null
            && stradaOut.civico != null, stradaOut));
    }
    initStrada() {
        this.strada = new StradaDTO();
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
        this.subScriptionChange.unsubscribe();
    }
    ngAfterContentInit() {
        if (this.strada.inidirizzo != null && this.strada.tipoToponimo != null && this.strada.civico != null) {
            this.form.updateValueAndValidity({ emitEvent: true });
        }
    }
}
StradaComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-strada',
                template: "<form [formGroup]=\"form\">\r\n\t<div class=\"row my-2\">\r\n\t\t<div class=\"col-md-8\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input matInput placeholder=\"{{'required' | traduzione}}{{'indirizzo' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"stradaIndirizzo\">\r\n\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['stradaIndirizzo'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls[ 'stradaIndirizzo']) | traduzione}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input matInput placeholder=\"{{'required' | traduzione}}{{'civico' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"stradaCivico\">\r\n\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['stradaCivico'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['stradaCivico']) | traduzione}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n</form>",
                styles: [""]
            },] }
];
StradaComponent.ctorParameters = () => [
    { type: MessageService },
    { type: TerritorioService }
];
StradaComponent.propDecorators = {
    viewOnly: [{ type: Input }],
    strada: [{ type: Input }],
    done: [{ type: Output }]
};

class LocalitaComponent {
    constructor(msg, territorio) {
        this.msg = msg;
        this.territorio = territorio;
        this.done = new EventEmitter();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        if (!this.localita) {
            this.initLocalita();
        }
        const localitaProvincia = new FormControl({ value: this.localita.provincia, disabled: this.viewOnly }, c => {
            if (this.viewOnly)
                return {};
            return String(c.value).trim().length > 0
                ? {}
                : { required: true };
        });
        this.form.addControl("localitaProvincia", localitaProvincia);
        const localitaComune = new FormControl({ value: this.localita.comune, disabled: this.viewOnly }, c => {
            if (this.viewOnly)
                return {};
            return String(c.value).trim().length > 0
                ? {}
                : { required: true };
        });
        this.form.addControl("localitaComune", localitaComune);
        // if(this.viewCap) {
        const localitaCap = new FormControl({ value: this.localita.cap, disabled: this.viewOnly }, c => {
            if (this.viewOnly)
                return {};
            return String(c.value).trim().length > 0
                ? {}
                : { required: true };
        });
        this.form.addControl("localitaCap", localitaCap);
        // }
        this.comuni$ = localitaProvincia.valueChanges.pipe(startWith(this.localita.provincia), filter((x) => x), switchMap((value) => this.territorio.getComuni$(value)), shareReplay());
        this.cap$ = localitaComune.valueChanges.pipe(startWith(this.localita.comune), filter((comune) => comune != null), switchMap((codiceCatastale) => {
            return this.comuni$.pipe(map((comuni) => comuni.filter((comune) => comune.codiceCatastale === codiceCatastale)), filter((comuni) => comuni.length > 0), map((comuni) => comuni[0]), switchMap(comune => this.territorio.getCap$(comune.codiceIstat)));
        }));
        const changes$ = this.form.valueChanges.pipe(map((_) => {
            const localita = new LocalitaDTO();
            // if(this.viewCap) {
            localita.cap = this.form.controls["localitaCap"].value;
            // }
            localita.provincia = this.form.controls["localitaProvincia"].value;
            localita.comune = this.form.controls["localitaComune"].value;
            return ComponentOutputStatus.of(this.form.valid, localita);
        }));
        this.subscription = changes$.subscribe((_) => this.done.emit(_));
    }
    initLocalita() {
        this.localita = new LocalitaDTO();
    }
    compareComuni(c1, c2) {
        return c1 && c2 ? c1.cop === c2.cop : c1 === c2;
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
}
LocalitaComponent.decorators = [
    { type: Component, args: [{
                selector: "lib-localita",
                template: "<div [formGroup]=\"form\">\r\n\t<div class=\"row my-2\">\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-label>{{'required' | traduzione}}{{'provincia' | traduzione}}</mat-label>\r\n\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"localitaProvincia\">\r\n\t\t\t\t\t<mat-option *ngFor=\"let provincia of province$ | async\" [value]=\"provincia.sigla\">\r\n\t\t\t\t\t\t{{provincia.denominazione}}\r\n\t\t\t\t\t</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['localitaProvincia'].invalid\">\r\n\t\t\t\t\t{{\r\n\t\t\t\t\tmsg.produceMessage(\r\n\t\t\t\t\t\"obbligatorio\",\r\n\t\t\t\t\tform.controls[\"localitaProvincia\"]\r\n\t\t\t\t\t) | traduzione\r\n\t\t\t\t\t}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-label>{{'required' | traduzione}}{{'comune' | traduzione}}</mat-label>\r\n\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"localitaComune\">\r\n\t\t\t\t\t<mat-option *ngFor=\"let comune of comuni$ | async\" [value]=\"comune.codiceCatastale\">\r\n\t\t\t\t\t\t{{ comune.denominazione }}\r\n\t\t\t\t\t</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['localitaComune'].invalid\">\r\n\t\t\t\t\t{{\r\n\t\t\t\t\tmsg.produceMessage(\"obbligatorio\", form.controls[\"localitaComune\"]) | traduzione\r\n\t\t\t\t\t}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-select placeholder=\"{{'required' | traduzione}}{{'cap' | traduzione}}\" formControlName=\"localitaCap\">\r\n\t\t\t\t\t<mat-option *ngFor=\"let cap of cap$ | async\" [value]=\"cap\">\r\n\t\t\t\t\t\t{{ cap }}\r\n\t\t\t\t\t</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['localitaCap'].invalid\">\r\n\t\t\t\t\t{{ msg.produceMessage(\"obbligatorio\", form.controls[\"localitaCap\"]) | traduzione}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n</div>",
                styles: [""]
            },] }
];
LocalitaComponent.ctorParameters = () => [
    { type: MessageService },
    { type: TerritorioService }
];
LocalitaComponent.propDecorators = {
    viewOnly: [{ type: Input }],
    localita: [{ type: Input }],
    province$: [{ type: Input }],
    done: [{ type: Output }]
};

class DichiarazioneDTO {
}

class AccettazioneComponent {
    constructor() {
        this.completeProcess = new EventEmitter();
        this.salvaBozza = new EventEmitter();
        this.previousStep = new EventEmitter();
        this.direction = 'only-backward';
        this.isFinal = true;
    }
    ngOnInit() {
        this.form = new FormGroup({});
        const chk1 = new FormControl({ value: false, disabled: false }, [Validators.required]);
        this.form.addControl('chk1', chk1);
        const chk2 = new FormControl({ value: false, disabled: false }, [Validators.required]);
        this.form.addControl('chk2', chk2);
        const chk3 = new FormControl({ value: false, disabled: false }, [Validators.required]);
        this.form.addControl('chk3', chk3);
        const chk4 = new FormControl({ value: false, disabled: false }, [Validators.required]);
        this.form.addControl('chk4', chk4);
        const chk5 = new FormControl({ value: false, disabled: false }, [Validators.required]);
        this.form.addControl('chk5', chk5);
        const chk6 = new FormControl({ value: false, disabled: false }, [Validators.required]);
        this.form.addControl('chk6', chk6);
        if (!this.dichiarazioni) {
            this.initDichiarazione();
        }
    }
    forward($event) { }
    backward($event) {
        this.previousStep.emit(this.dichiarazioni);
    }
    complete($event) {
        this.setFormFieldControls();
        this.completeProcess.emit(this.dichiarazioni);
    }
    onSalvaBozza($event) {
        this.setFormFieldControls();
        this.salvaBozza.emit(this.dichiarazioni);
    }
    isFormValid() {
        return this.form.valid &&
            this.form.controls['chk1'].value &&
            this.form.controls['chk2'].value &&
            this.form.controls['chk3'].value &&
            this.form.controls['chk4'].value &&
            this.form.controls['chk5'].value &&
            ((this.isPersonaGiuridica && this.form.controls['chk6'].value) || !this.isPersonaGiuridica);
    }
    initDichiarazione() {
        this.dichiarazioni = new Array();
    }
    setFormFieldControls() {
        this.initDichiarazione();
        const dati1 = new DichiarazioneDTO();
        dati1.isChecked = this.form.controls['chk1'].value;
        dati1.dichiarazione = "1";
        this.dichiarazioni.push(dati1);
        const dati2 = new DichiarazioneDTO();
        dati2.isChecked = this.form.controls['chk2'].value;
        dati2.dichiarazione = "2";
        this.dichiarazioni.push(dati2);
        const dati3 = new DichiarazioneDTO();
        dati3.isChecked = this.form.controls['chk3'].value;
        dati3.dichiarazione = "3";
        this.dichiarazioni.push(dati3);
        const dati4 = new DichiarazioneDTO();
        dati4.isChecked = this.form.controls['chk4'].value;
        dati4.dichiarazione = "4";
        this.dichiarazioni.push(dati4);
        const dati5 = new DichiarazioneDTO();
        dati5.isChecked = this.form.controls['chk5'].value;
        dati5.dichiarazione = "5";
        this.dichiarazioni.push(dati5);
        const dati6 = new DichiarazioneDTO();
        dati6.isChecked = this.form.controls['chk6'].value;
        dati6.dichiarazione = "6";
        this.dichiarazioni.push(dati6);
    }
}
AccettazioneComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-accettazione',
                template: "<div class=\"mt-3 mb-5\" [formGroup]=\"form\">\r\n\t<mat-expansion-panel class=\"panel\" [expanded]=\"true\" >\r\n    <mat-expansion-panel-header\r\n      [collapsedHeight]=\"'48px'\"\r\n      [expandedHeight]=\"'48px'\"\r\n      class=\"custom-header\"\r\n    >\r\n      <mat-panel-title>\r\n        <h3 class=\"h5 mb-0\"><info-tip-label label=\"dichiarazioni-richiedente\"></info-tip-label></h3>\r\n      </mat-panel-title>\r\n    </mat-expansion-panel-header>\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-12 mb-3\">\r\n\t\t\t<h3 class=\"h5 mb-0\">\r\n\t\t\t\t<!-- <info-tip-label label=\"dichiarazioni-header\"></info-tip-label> -->\r\n\t\t\t\t<h3 class=\"h5 mb-0\"> <info-tip-label label=\"dichiarazioni-header\"></info-tip-label> </h3>\r\n\t\t\t\t<div class=\"divider\"></div>\r\n\t\t\t</h3>\r\n\t\t</div>\r\n\t\t<div class=\"col-12\">\r\n\t\t\t<mat-checkbox formControlName=\"chk1\">\r\n\t\t\t\t{{ 'dichiarazioni-row-1' | traduzione }}\r\n\t\t\t</mat-checkbox>\r\n\t\t\t<mat-checkbox formControlName=\"chk2\">\r\n\t\t\t\t{{ 'dichiarazioni-row-2' | traduzione }}\r\n\t\t\t</mat-checkbox>\r\n\t\t\t<mat-checkbox formControlName=\"chk3\">\r\n\t\t\t\t{{ 'dichiarazioni-row-3' | traduzione }}\r\n\t\t\t</mat-checkbox>\r\n\t\t\t<mat-checkbox formControlName=\"chk4\">\r\n\t\t\t\t{{ 'dichiarazioni-row-4' | traduzione }}\r\n\t\t\t</mat-checkbox>\r\n\t\t\t<mat-checkbox formControlName=\"chk5\">\r\n\t\t\t\t{{ 'dichiarazioni-row-5' | traduzione }}\r\n\t\t\t</mat-checkbox>\r\n\t\t\t<mat-checkbox formControlName=\"chk6\" *ngIf=\"isPersonaGiuridica\">\r\n\t\t\t\t{{ 'dichiarazioni-row-6' | traduzione }}\r\n\t\t\t</mat-checkbox>\r\n\t\t</div>\r\n\t</div>\r\n\t</mat-expansion-panel>\r\n\t<lib-stepper-navigator\r\n\t\t[form]=\"form\"\r\n\t\t[direction]=\"direction\"\r\n\t\t[isFinal]=\"isFinal\"\r\n\t\t[isContainerValid]=\"isFormValid()\"\r\n\t\t(goForward)=\"forward($event)\"\r\n\t\t(goBackward)=\"backward($event)\"\r\n\t\t(complete)=\"complete($event)\"\r\n\t\t(salvaBozza)=\"onSalvaBozza($event)\"\r\n\t>\r\n\t</lib-stepper-navigator>\r\n</div>\r\n",
                styles: [""]
            },] }
];
AccettazioneComponent.ctorParameters = () => [];
AccettazioneComponent.propDecorators = {
    dichiarazioni: [{ type: Input }],
    isPersonaGiuridica: [{ type: Input }],
    tipologiaDichiarazioni: [{ type: Input }],
    completeProcess: [{ type: Output }],
    salvaBozza: [{ type: Output }],
    previousStep: [{ type: Output }]
};

const TipiDocumento = {
    DSAN_EREDI: "DSAN_EREDI",
    ATTO_COSTITUTIVO: "ATTO_COSTITUTIVO",
    PROCURA: "PROCURA",
    PROVVEDIMENTO_FALLIMENTO: "PROVVEDIMENTO_FALLIMENTO",
    PROVVEDIMENTO_DEL_GIUDICE_TUTELARE: "PROVVEDIMENTO_DEL_GIUDICE_TUTELARE",
    PROVVEDIMENTO_DI_INCASSO_SOMME: "PROVVEDIMENTO_DI_INCASSO_SOMME",
    ALTRO: "ALTRO"
};

class DocumentazioneComponent {
    constructor(modals) {
        this.modals = modals;
        //TODO
        this.allegatiMock = [{
                chiaveCollegamento: "7afe2d6c-5757-4684-91fc-387c7c15dbf6",
                dataCreazione: "2021-01-08",
                dataInizioStaging: "2021-01-08",
                dataStaging: "2021-01-08",
                dataValidazione: null,
                descrizione: "Test request10",
                idCreatore: "1",
                idDocumento: "ad397ac0-f017-48e1-98fb-3e4c514adbdb",
                idIstanza: "2380b34a-4b2d-4a9b-896b-ba4a27cdbf7f",
                jsonMetadati: "",
                nome: "fileditest10.txt",
                proprietario: { tipoProprietario: "PF", idProprietario: "1", idSottoProprietario: null },
                statiDocumento: [{ idDocumento: "ad397ac0-f017-48e1-98fb-3e4c514adbdb", stato: "DOC_VALID", dataCambiamentoStato: "2021-01-08", nota: null, lastState: true }],
                tipoDocumento: { id: "e617df75-0c3b-41a6-b7a0-c514ede2e9ee", codice: "CU", descrizione: "Certifcazione Unica" },
                tipoServizio: { id: "f2c7415f-5a20-4f14-a379-d07d0d1cbd9a", codice: "CU", descrizione: "Certificazione Unica" },
                url: "/v1/documento/ad397ac0-f017-48e1-98fb-3e4c514adbdb/download"
            }];
        this.nextStep = new EventEmitter();
        this.salvaBozza = new EventEmitter();
        this.previousStep = new EventEmitter();
        this.direction = "both-ways";
        this.isFinal = false;
        this.avantiClicks$ = new Subject();
        this.indietroClicks$ = new Subject();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        if (!this.documenti) {
            this.initDocumnetazione();
        }
        this.addFiles$ = new Subject();
        this.removeFile$ = new Subject();
        this.removeFile$.subscribe(console.log);
        //------Si accumulano i documenti validi da inviare-------
        const adds$ = this.addFiles$.pipe(map((file) => (acc) => {
            if (file.file != null) {
                if (!file.file.name.toLowerCase().endsWith(".pdf")) {
                    // this.modals.failure(["Si prega di inserire solamente file in formato pdf"]);
                    this.modals.openConfirm(this.buildErrore("Si prega di inserire solamente file in formato pdf"));
                    return acc;
                }
                if (file.file.size == 0) {
                    // this.modals.failure(["Si prega di non inserire file vuoti"]);
                    this.modals.openConfirm(this.buildErrore("zero-file-size"));
                    return acc;
                }
                const fileExists = acc.find(loaded => loaded.file.name === file.file.name) != null;
                if (fileExists) {
                    // this.modals.failure(["Si prega di inserire un file diverso da quelli che sono stati inserti"]);
                    this.modals.openConfirm(this.buildErrore("Si prega di inserire un file diverso da quelli che sono stati inseriti"));
                    return acc;
                }
                this.caricaDocumenti.resetForm();
            }
            //console.log("[file]", [...acc, file]);
            return [...acc, file];
        }));
        this.nomeColonne$ =
            new Observable(ob => ob.next(["nr._Documento", "tipo_Documento", "data_Documento", "tipologia_emittente", "organo_emittente", "obbligatorio"]));
        this.mappatura$ = this.addFiles$.pipe(map(file => Object.keys(file[0])));
        const removals$ = this.removeFile$.pipe(map((index) => (acc) => {
            return acc.filter((_, i) => index !== i);
        }));
        this.files$ = merge(adds$, removals$).pipe(scan((acc, op) => op(acc), []), startWith([]), tap(_ => console.log("[DocumentazioneComponent] - metadatiDocumenti", _)), shareReplay());
        this.viewList$ = this.files$.pipe(map(files => files.length > 0));
        const presentAndMissing$ = combineLatest([this.files$, this.tipologieDocumento$])
            .pipe(map(([files, tipologieDocumento]) => {
            const tipiDoc = tipologieDocumento
                ? tipologieDocumento.filter((t) => t.codice != TipiDocumento.ALTRO)
                : [];
            const missing = tipiDoc.filter((tipoDoc) => {
                const typeFound = files.find((file) => file.tipoDocumento.codice == tipoDoc.codice);
                return typeFound ? false : true;
            });
            return Tuple.of(files, missing);
        }), shareReplay());
        //scrivere l'errore
        this.hasMissingFileTypes$ = presentAndMissing$.pipe(map((t) => t._2.length > 0), startWith(false));
        // //scrivere l'errore
        this.missingFileTypes$ = presentAndMissing$.pipe(map((t) => t._2));
        //emettere lista dei file caricati
        const present$ = presentAndMissing$.pipe(map((t) => t._1));
        this.subscription = this.avantiClicks$
            .pipe(debounceTime(250), withLatestFrom(present$), 
        // tap(([_, present]) => console.log("[present]", present)),
        tap(([_, present]) => this.nextStep.emit(present)))
            .subscribe();
        this.tipologieDocumentoAll$ = this.tipologieDocumento$;
    }
    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
    forward($event) {
        this.avantiClicks$.next($event);
    }
    backward(_) {
        this.previousStep.emit([]);
    }
    complete(_) { }
    onSalvaBozza(_) {
        this.salvaBozza.emit([]);
    }
    initDocumnetazione() {
        this.documenti = new Array();
    }
    buildErrore(msg) {
        const data = new GenericModalData();
        data.title = 'dialogTitleError';
        data.paragrafi =
            [msg
            ];
        const noOp = new Azione('ko');
        noOp.testo = 'KO';
        data.azioni = [noOp];
        return data;
    }
}
DocumentazioneComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-documentazione',
                template: "<div class=\"row\" class=\"mt-3 mb-5\">\r\n\t<mat-expansion-panel class=\"panel\" [expanded]=\"true\" [formGroup]=\"form\">\r\n    <mat-expansion-panel-header\r\n      [collapsedHeight]=\"'48px'\"\r\n      [expandedHeight]=\"'48px'\"\r\n      class=\"custom-header\"\r\n    >\r\n      <mat-panel-title>\r\n        <h3 class=\"h5 mb-0\"><info-tip-label label=\"documentazione\"></info-tip-label></h3>\r\n      </mat-panel-title>\r\n    </mat-expansion-panel-header>\r\n\t<div class=\"col-12\">\r\n\t\t<br>\r\n\t\t<div class=\"row\">\r\n\t\t\t<div class=\"col-12 mb-3\">\r\n\t\t\t\t<h3 class=\"h5 mb-0\"><info-tip-label label=\"documentazione-da-allegare\"></info-tip-label></h3>\r\n\t\t\t\t<div class=\"divider\"></div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<lib-carica-documenti\r\n\t\t\t[tipologieDocumento]=\"tipologieDocumentoAll$ | async\"\r\n\t\t\t[tipologieTipiEmittenti$]=\"tipologieTipiEmittenti$\"\r\n\t\t\t(onFileAdded)=\"addFiles$.next($event)\"\r\n\t\t\t#caricaDocumenti\r\n\t\t>\r\n\t\t</lib-carica-documenti>\r\n\t</div>\r\n\t<div class=\"col-12\" *ngIf=\"viewList$ | async\">\r\n\t\t<div class=\"d-flex border-bottom align-items-baseline mb-3\">\r\n\t\t\t<h3 class=\"h5 mb-0\">{{'documentazione-inserita' | traduzione}}</h3>\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"col-12\" *ngIf=\"viewList$ | async\">\r\n\t\t<lib-tabella-documenti [files$]=\"files$\" (indiceSelezionato)=\"removeFile$.next($event)\">\r\n\t\t</lib-tabella-documenti>\r\n\t</div>\r\n\t<div class=\"col-md-12\">\r\n\t\t<mat-error *ngIf=\"hasMissingFileTypes$ | async\">\r\n\t\t\t<p class=\"h6 mt-4\">{{'documenti-mancanti' | traduzione}}</p>\r\n\t\t\t<p *ngFor=\"let missing of missingFileTypes$ | async\">\r\n\t\t\t\t{{ missing.descrizione }}\r\n\t\t\t</p>\r\n\t\t</mat-error>\r\n\t</div>\r\n\t</mat-expansion-panel>\r\n\t<div class=\"mt-4\"></div>\r\n\t<lib-stepper-navigator\r\n\t\t[form]=\"form\"\r\n\t\t[direction]=\"direction\"\r\n\t\t[isFinal]=\"isFinal\"\r\n\t\t(goForward)=\"forward($event)\"\r\n\t\t(goBackward)=\"backward($event)\"\r\n\t\t(goBackward)=\"complete($event)\"\r\n\t\t(salvaBozza)=\"onSalvaBozza($event)\"\r\n\t\t[isContainerValid]=\"!(hasMissingFileTypes$ | async)\"\r\n\t>\r\n\t</lib-stepper-navigator>\r\n</div>\r\n",
                styles: [""]
            },] }
];
DocumentazioneComponent.ctorParameters = () => [
    { type: Modals }
];
DocumentazioneComponent.propDecorators = {
    documenti: [{ type: Input }],
    tipologieDocumento$: [{ type: Input }],
    tipologieTipiEmittenti$: [{ type: Input }],
    nextStep: [{ type: Output }],
    salvaBozza: [{ type: Output }],
    previousStep: [{ type: Output }],
    caricaDocumenti: [{ type: ViewChild, args: ['caricaDocumenti',] }]
};

class NewFile {
    constructor(tempId, file, tipoDocumento, soggettoEmittente, dataDocumento, numeroDocumento, codiceTipoEmittente, nota) {
        this.tempId = tempId;
        this.file = file;
        this.tipoDocumento = tipoDocumento;
        this.soggettoEmittente = soggettoEmittente;
        this.dataDocumento = dataDocumento;
        this.numeroDocumento = numeroDocumento;
        this.codiceTipoEmittente = codiceTipoEmittente;
        this.nota = nota;
    }
}

class InfoTipService {
    constructor(
    // @Host() @Inject(I18NService) private readonly i18nService: I18NService
    i18nService) {
        this.i18nService = i18nService;
        this.i18n$ = this.i18nService
            .model$
            .pipe(catchError(err => {
            console.error(err);
            return of([]);
        }))
            .pipe(shareReplay(1));
    }
    getInfo$(label) {
        return this.i18n$
            // .pipe(tap(_ => console.log("getInfo$", label, _)))
            .pipe(map(t => t.find(model => model.codiceLabel == label)));
    }
}
InfoTipService.ɵprov = ɵɵdefineInjectable({ factory: function InfoTipService_Factory() { return new InfoTipService(ɵɵinject(I18NService)); }, token: InfoTipService, providedIn: "root" });
InfoTipService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
                // , deps: [ I18NService ]
            },] }
];
InfoTipService.ctorParameters = () => [
    { type: I18NService }
];

class CaricaDocumentiComponent {
    constructor(msg, infoTipService) {
        this.msg = msg;
        this.infoTipService = infoTipService;
        this.onFileAdded = new EventEmitter();
        this.maxDate = new Date();
        this.validitaForm$ = new Subject();
        /* Stream files caricati */
        this.files$ = new BehaviorSubject(null);
    }
    ngOnInit() {
        // //TODO
        // if (!this.tipologieEmittente) {
        // 	this.tipologieEmittente = [{ codice: "TIPOLOGIE_EMITTENTE_1", descrizione: "tipologieEmittente1", id: "1", codiceLingua: "it_IT" }]
        // }
        this.form = new FormGroup({});
        const tipoDocumento = new FormControl({ value: null, disabled: false }, [Validators.required]);
        const soggettoEmittente = new FormControl({ value: "", disabled: false }, [Validators.required]);
        const dataDocumento = new FormControl({ value: "", disabled: false }, [Validators.required, ValidationService.ValidateDate]);
        const numeroDocumento = new FormControl({ value: "", disabled: false }, [Validators.required]);
        const tipologiaEmittente = new FormControl({ value: null, disabled: false }, []);
        const note = new FormControl({ value: "", disabled: false }, []);
        this.form.addControl('tipoDocumento', tipoDocumento);
        this.form.addControl('soggettoEmittente', soggettoEmittente);
        this.form.addControl('dataDocumento', dataDocumento);
        this.form.addControl('numeroDocumento', numeroDocumento);
        this.form.addControl('tipologiaEmittente', tipologiaEmittente);
        this.form.addControl('note', note);
        this.tipoDocumento$ = tipoDocumento.valueChanges.pipe(shareReplay());
        this.soggettoEmittente$ = soggettoEmittente.valueChanges.pipe(shareReplay());
        this.dataDocumento$ = dataDocumento.valueChanges.pipe(shareReplay());
        this.numeroDocumento$ = numeroDocumento.valueChanges
            .pipe(debounceTime(800), shareReplay());
        this.addFiles$ = new Subject();
        this.note$ = new Subject();
        this.tipologieEmittente$ = new Subject();
        const dtos$ = combineLatest([this.tipoDocumento$, this.files$, this.soggettoEmittente$, this.dataDocumento$, this.numeroDocumento$, this.tipologieEmittente$, this.note$])
            .pipe(map(([tipDocumento, file, soggettoEmittente, dataDocumento, numeroDocumento, codiceTipoEmittente, nota]) => {
            return new NewFile(new Date().getTime().toString(), file, tipDocumento, soggettoEmittente, dataDocumento, numeroDocumento, codiceTipoEmittente, nota);
        }));
        this.addFiles$.pipe(debounceTime(300), withLatestFrom(dtos$), tap(([_, dto]) => {
            this.onFileAdded.emit(dto);
            this.validitaForm$.next(true);
            this.pulisciForm();
        })).subscribe();
        this.infoTipService.getInfo$('numero-documento').subscribe(info => {
            this.numeroDocumentoCaption = info.tooltip;
        });
    }
    sfoglia(_) {
        if (this.fileInput.nativeElement) {
            this.fileInput.nativeElement.click();
        }
    }
    filesChanged() {
        const file = this.fileInput.nativeElement.files[0];
        this.files$.next(file);
        this.nameFileTruncated = this.formatFunction(file.name);
    }
    aggiungiFile(event) {
        this.tipologieEmittente$.next(this.form.value["tipologiaEmittente"]);
        this.note$.next(this.form.value["note"]);
        this.addFiles$.next(event);
        this.fileInput.nativeElement.value = '';
        //this.form.reset();
    }
    resetForm() {
        this.form.reset();
    }
    ngOnDistory() {
        this.subscription.unsubscribe();
    }
    formatFunction(nomeFile) {
        return nomeFile.length > 18 ? nomeFile.substring(0, 18) + '...' + nomeFile.substring(nomeFile.length, nomeFile.length - 4) : nomeFile;
    }
    pulisciForm() {
        Object.keys(this.form.value)
            .forEach(campo => {
            this.form.get(campo).setValue('');
        });
        this.files$.next(null);
    }
}
CaricaDocumentiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-carica-documenti',
                template: "<div class=\"row d-flex align-items-center\" [formGroup]=\"form\">\r\n\t<div class=\"col-12 col-md-6 my-2\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'tipo-documento' | traduzione}} {{' *'}}</mat-label>\r\n\t\t\t<mat-select formControlName=\"tipoDocumento\">\r\n\t\t\t\t<mat-option *ngFor=\"let tipoDocumento of tipologieDocumento\" [value]=\"tipoDocumento\">\r\n\t\t\t\t\t{{tipoDocumento.descrizione}}\r\n\t\t\t\t</mat-option>\r\n\t\t\t</mat-select>\r\n\t\t\t<mat-error *ngIf=\"form.controls['tipoDocumento'].invalid\">\r\n\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['tipoDocumento']) | traduzione}}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint *infoTip=\"'tipo-documento'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\t<div class=\"col-12 col-md-6 my-2\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'soggetto-emittente' | traduzione}}{{' *'}}</mat-label>\r\n\t\t\t<input matInput formControlName=\"soggettoEmittente\">\r\n\t\t\t<mat-error *ngIf=\"form.controls['soggettoEmittente'].invalid\">\r\n\t\t\t\t{{ msg.produceMessage('obbligatorio', form.controls['soggettoEmittente']) | traduzione}}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint *infoTip=\"'soggetto-emittente'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\r\n\t<div class=\"col-12 col-md-6 col-lg-3 my-2\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'data-documento' | traduzione}}{{' *'}}</mat-label>\r\n\t\t\t<input matInput [matDatepicker]=\"picker\" formControlName=\"dataDocumento\" [max]=\"maxDate\">\r\n\t\t\t<mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\r\n\t\t\t<mat-datepicker #picker></mat-datepicker>\r\n\t\t\t<mat-error *ngIf=\"form.controls['dataDocumento'].invalid\">\r\n\t\t\t\t{{ msg.getErrorData(form.controls[\"dataDocumento\"]) | traduzione }}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint *infoTip=\"'data-documento'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\r\n\t</div>\r\n\t<div class=\"col-12 col-md-6  col-lg-3 my-2\">\r\n\t\t<mat-form-field appearance=\"\"> \r\n\t\t\t<mat-label>{{'numero-documento' | traduzione}}{{'*'}}</mat-label>\r\n\t\t\t<input matInput formControlName=\"numeroDocumento\" #numeroDoc maxlength=\"49\">\r\n\t\t\t<mat-error *ngIf=\"form.controls['numeroDocumento'].invalid\">\r\n\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['numeroDocumento']) | traduzione}}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint align=\"start\" style=\"max-width: 70%!important;color: black!important;\">{{numeroDocumentoCaption}}</mat-hint>\r\n\t\t\t<mat-hint align=\"end\">{{numeroDoc.value.length}} / 49</mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\r\n\r\n\t<div class=\"col-12 col-md-9 col-lg-3 my-2\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'tipologia-emittente' | traduzione}}</mat-label>\r\n\t\t\t<!-- TODO -->\r\n\t\t\t<!-- <mat-select formControlName=\"tipologiaEmittente\">\r\n\t\t\t\t<mat-option [value]=\"null\">-- {{ 'placeholder' | traduzione }} --</mat-option>\r\n\t\t\t\t<mat-option *ngFor=\"let tipologiaEmittente of tipologieEmittente\" [value]=\"tipologiaEmittente\">\r\n\t\t\t\t\t{{tipologiaEmittente.descrizione}}\r\n\t\t\t\t</mat-option>\r\n\t\t\t</mat-select> -->\r\n\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"tipologiaEmittente\">\r\n\t\t\t\t<mat-option \r\n\t\t\t\t\t*ngFor=\"let tipoEmittente of tipologieTipiEmittenti$ | async\"\r\n\t\t\t\t\t[value]=\"tipoEmittente.codice\"\r\n\t\t\t\t>\r\n\t\t\t\t{{ tipoEmittente.descrizione }}\r\n\t\t\t\t</mat-option>\r\n\t\t\t</mat-select>\r\n\t\t\t<mat-hint *infoTip=\"'tipologia-emittente'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\t<div class=\"col-12 col-md-3 col-lg-3 my-2\">\r\n\t\t<button mat-stroked-button color=\"primary\" class=\"text-uppercase mb-2\" (click)=\"sfoglia($event)\">\r\n\t\t\t<i class=\"fas fa-upload\"></i> {{'upload-file' | traduzione}}\r\n\t\t</button>\r\n\r\n\t\t<p *ngIf=\"files$ | async as files\" class=\"position-absolute mb-0 mt-2 text-muted file-upl\">\r\n\t\t\t<i class=\"far fa-file-alt text-primary mr-1\" aria-hidden=\"true\"></i>\r\n\t\t\t{{nameFileTruncated}}\r\n\t\t\t<!-- <a href=\"#\" (click)=\"files$.next(null)\"><span class=\" ml-1 sr-only\">{{'scarta_il_file' |\r\n\t\t\t\t\ttraduzione}}</span><i class=\"fas fa-times-circle ml-2 text-danger\"></i></a> -->\r\n\t\t</p>\r\n\t</div>\r\n\t<div class=\"col-12 my-2\">\r\n\t\t<mat-form-field class=\"example-full-width\">\r\n\t\t\t<mat-label>{{'note' | traduzione}}</mat-label>\r\n\t\t\t<textarea matInput \r\n\t\t\tplaceholder=\"Lorem ipsum...\" \r\n\t\t\tformControlName=\"note\"\r\n\t\t\tmaxlength=\"511\"\r\n\t\t\t#testo\r\n\t\t\t></textarea>\r\n\t\t\t<mat-hint *infoTip=\"'note'\"></mat-hint>\r\n\t\t\t<mat-hint align=\"end\">{{testo.value.length}} / 511</mat-hint>\r\n\t\t</mat-form-field>\r\n\r\n\t</div>\r\n\t<div class=\"col-12 text-right my-2\">\r\n\t\t<button type=\"button\" mat-flat-button color=\"primary\" class=\"text-uppercase mb-2\" (click)=\"aggiungiFile($event)\"\r\n\t\t\t[disabled]=\"form.invalid || (files$ | async) == null\">\r\n\t\t\t{{'aggiungi' | traduzione}}\r\n\t\t</button>\r\n\t</div>\r\n\t<input #fileInput *ngIf=\"(tipoDocumento$ | async) != null\" type=\"file\" class=\"hidden\"\r\n\t\t(change)=\"filesChanged($event)\" accept=\".pdf\">\r\n</div>",
                styles: ["button#buttoneCarica{display:none}.file-upl{white-space:nowrap}"]
            },] }
];
CaricaDocumentiComponent.ctorParameters = () => [
    { type: MessageService },
    { type: InfoTipService }
];
CaricaDocumentiComponent.propDecorators = {
    tipologieDocumento: [{ type: Input }],
    tipologieEmittente: [{ type: Input }],
    tipologieTipiEmittenti$: [{ type: Input }],
    onFileAdded: [{ type: Output }],
    fileInput: [{ type: ViewChild, args: ['fileInput',] }]
};

class TipologiaDepositoComponent {
    constructor(msg) {
        this.msg = msg;
        this.tipologiaDepositoReady = new EventEmitter();
        this.dateRichiesta = new Date();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        this.tipologiaDeposito = new FormControl({ value: null, disabled: false }, [Validators.required]);
        this.form.addControl('tipologiaDeposito', this.tipologiaDeposito);
        this.dataRichiesta = new FormControl({ value: new Date(Date.now()), disabled: true }, [Validators.required, ValidationService.ValidateDate]);
        this.form.addControl("dataRichiesta", this.dataRichiesta);
    }
    compilaRichiesta() {
        this.selectedTipoDeposito = this.depositoReady();
        // console.log('[selectedTipoDeposito]', this.selectedTipoDeposito);
        const depToEmit = ComponentOutputStatus.of(true, this.selectedTipoDeposito);
        this.tipologiaDepositoReady.emit(depToEmit);
    }
    depositoReady() {
        return ({
            tipologiaDeposito: this.form.value['tipologiaDeposito'],
            dataRichiesta: new Date(moment(this.dataRichiesta.value, 'DD/MM/YYYY').toDate())
            //TODO
            // , dataRichiesta: new Date(moment(this.form.value['dataRichiesta'], 'DD/MM/YYYY').toDate())
        });
    }
}
TipologiaDepositoComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-tipologia-deposito',
                template: "<div class=\"row\">\r\n\t<div class=\"col-12\">\r\n\t\t<!-- <h2 class=\"h2\">{{'tipologia-deposito' | traduzione}}</h2> -->\r\n\t\t<h2><info-tip-label label=\"tipologia-deposito\"></info-tip-label></h2>\r\n\t</div>\r\n\t<div class=\"col-12\">\r\n\t\t<p>I depositi definitivi sono somme di denaro che devono essere versate da parte di soggetti pubblici o privati\r\n\t\t\t(persone fisiche o giuridiche) in base a legge o per disposizione delle Pubbliche Amministrazioni e che\r\n\t\t\tvengono poi custodite dal Ministero dell\u2019Economia e delle Finanze che cura anche la loro restituzione ai\r\n\t\t\tsoggetti che ne hanno diritto.</p>\r\n\t\t<p>\r\n\t\t\tSi classificano in depositi definitivi obbligatori e volontari:\r\n\t\t</p>\r\n\t\t<ul>\r\n\t\t\t<li>\r\n\t\t\t\t<p><b>Obbligatori:</b> sono quelli prescritti da Leggi o Regolamenti ovvero dall\u2019Autorit\u00E0 giudiziaria o\r\n\t\t\t\t\tamministrativa. Inoltre, sono obbligatori i depositi definitivi eseguiti in dipendenza di un vincolo\r\n\t\t\t\t\tlegale o sono ammessi dalla legge per conseguire un determinato effetto giuridico. Possono essere\r\n\t\t\t\t\teffettuati sia da soggetti privati che da soggetti pubblici.\r\n\t\t\t\t\tSi suddividono in:</p>\r\n\t\t\t\t<ul>\r\n\t\t\t\t\t<li>\r\n\t\t\t\t\t\t<p><b>amministrativi:</b> sono i depositi di somme relative alle procedure di esproprio ovvero\r\n\t\t\t\t\t\t\tquelli eseguiti o ordinati da una Pubblica Amministrazione (o soggetto delegato) o, infine,\r\n\t\t\t\t\t\t\tquelli che non possono essere restituiti senza il consenso di una Pubblica Amministrazione\r\n\t\t\t\t\t\t\t(o soggetto delegato). La pi\u00F9 rilevante figura di depositi definitivi amministrativi \u00E8\r\n\t\t\t\t\t\t\tquella per espropri</p>\r\n\t\t\t\t\t</li>\r\n\t\t\t\t\t<li>\r\n\t\t\t\t\t\t<p><b>cauzionali:</b> effettuati a garanzia di Pubbliche Amministrazioni in forza di leggi o\r\n\t\t\t\t\t\t\tregolamenti;\r\n\t\t\t\t\t</li>\r\n\t\t\t\t\t<li>\r\n\t\t\t\t\t\t<p><b>giudiziari:</b> ordinati dall\u2019Autorit\u00E0 giudiziaria o la cui propriet\u00E0 sia contestata\r\n\t\t\t\t\t\t\tgiudizialmente ovvero sia in attesa di definizione giudiziale;</p>\r\n\t\t\t\t\t</li>\r\n\t\t\t\t</ul>\r\n\t\t\t</li>\r\n\t\t\t<li>\r\n\t\t\t\t<p><b>Volontari:</b> possono essere effettuati depositi definitivi volontari allo scopo di impiego di\r\n\t\t\t\t\tcapitali esclusivamente da Enti ed Amministrazioni statali, Regioni, Enti locali e altri Enti\r\n\t\t\t\t\tpubblici ai sensi dell\u2019art. 1, comma1, lett.a) del D.Lgs. 30 luglio 1999 n. 284</p>\r\n\t\t\t</li>\r\n\t\t</ul>\r\n\r\n\t\t<p>\r\n\t\t\tIl servizio depositi definitivi \u00E8 gestito su tutto il territorio nazionale dalle Ragionerie territoriali\r\n\t\t\tdello Stato, il cui coordinamento giuridico, amministrativo e contabile \u00E8 affidato all\u2019Ufficio VI Direzione\r\n\t\t\tdei Servizi erogati alle Amministrazioni e ai terzi (DST).\r\n\t\t</p>\r\n\t</div>\r\n</div>\r\n<div class=\"d-flex border-bottom align-items-baseline mb-3\">\r\n\t<!-- <h3 class=\"mr-auto font-weight-bold mt-4 mb-0\">{{'seleziona-tipo-deposito' | traduzione}}</h3> -->\r\n\t<h3 class=\"mr-auto font-weight-bold mt-4 mb-0\"><info-tip-label label=\"seleziona-tipo-deposito\"></info-tip-label></h3>\r\n</div>\r\n<div class=\"row d-flex align-items-center\" [formGroup]=\"form\">\r\n\t<div class=\"col-12\">\r\n\t\t<div class=\"alert alert-info\" role=\"alert\">\r\n\t\t\t<span class=\"fas fa-info mr-2 info-icon\" aria-hidden=\"ture\"></span> {{'campi-obbligatori' | i18n }}\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"col-12 col-md-6 col-lg-6\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'required'| traduzione}}{{'tipologia-deposito' | traduzione }}</mat-label>\r\n\t\t\t<mat-select formControlName=\"tipologiaDeposito\">\r\n\t\t\t\t<mat-option *ngFor=\"let deposito of tipologieDeposito$ | async\" [value]=\"deposito\">\r\n\t\t\t\t\t{{deposito.descrizione}}\r\n\t\t\t\t</mat-option>\r\n\t\t\t</mat-select>\r\n\t\t\t<mat-error *ngIf=\"form.controls['tipologiaDeposito'].invalid\">\r\n\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['tipologiaDeposito']) | traduzione}}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint *infoTip=\"'tipologia-deposito'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\r\n\t<div class=\"col-12 col-md-3 col-lg-4\">\r\n\t\t<mat-form-field>\r\n\t\t\t<input [max]=\"dateRichiesta\" matInput [matDatepicker]=\"dataRichiesta\"\r\n\t\t\t\tplaceholder=\"{{'required' | traduzione}}{{'data-richiesta' | traduzione}}\"\r\n\t\t\t\tformControlName=\"dataRichiesta\" />\r\n\t\t\t<mat-datepicker-toggle matSuffix [for]=\"dataRichiesta\"></mat-datepicker-toggle>\r\n\t\t\t<mat-datepicker #dataRichiesta></mat-datepicker>\r\n\t\t\t<mat-error *ngIf=\"form.controls['dataRichiesta'].invalid\">\r\n\t\t\t\t{{ msg.getErrorData(form.controls[\"dataRichiesta\"]) | traduzione }}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint *infoTip=\"'data-richiesta'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\r\n\t<div class=\"col-12 col-md-3 col-lg-2 text-right\">\r\n\t\t<button mat-flat-button color=\"primary\" class=\"text-uppercase mb-2\" \r\n\t\t\t[disabled]=\"form.invalid\"\r\n\t\t\t(click)=\"compilaRichiesta()\">\r\n\t\t\t{{'compila-richiesta' | traduzione}}\r\n\t\t</button>\r\n\t</div>\r\n</div>\r\n",
                styles: [".mat-form-field-appearance-legacy .mat-form-field-wrapper{padding-bottom:1.34375em}"]
            },] }
];
TipologiaDepositoComponent.ctorParameters = () => [
    { type: MessageService }
];
TipologiaDepositoComponent.propDecorators = {
    tipologieDeposito$: [{ type: Input }],
    tipologiaDepositoReady: [{ type: Output }]
};

class AllegatiComponent {
    constructor(translateService, translatePipe, http, configurationService) {
        this.translateService = translateService;
        this.translatePipe = translatePipe;
        this.http = http;
        this.configurationService = configurationService;
        this.documentoDownload$ = new Subject();
        this.allegati = [];
        this.colonne = [];
        this.dettaglioDoc = new EventEmitter();
        this.cl1 = false;
        this.cl2 = false;
        this.cl3 = false;
        this.cl4 = false;
        this.cl5 = false;
        this.cl6 = false;
        this.cl7 = false;
        this.cl8 = false;
    }
    ngOnInit() {
        this.documentaleServiceUrl = this.configurationService.servicePaths.get('DOCUMENTALE_MS_API_URL');
        this.translatePipe.transform('');
        this.translateService.traduzioniLib$
            .pipe(tap(_ => _ ? this.loadingLinguage = true : null))
            .subscribe();
        // console.log('[colonne]', this.colonne);
        this.cl1 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_1").visibile;
        this.cl2 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_2").visibile;
        this.cl3 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_3").visibile;
        this.cl4 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_4").visibile;
        this.cl5 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_5").visibile;
        this.cl6 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_6").visibile;
        this.cl7 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_7").visibile;
        this.cl8 = this.colonne.find(tipoServizio => tipoServizio.chiave == "colonna_allegati_8").visibile;
        // console.log('[colonne] - cl1', this.cl1);
        // console.log('[colonne] - cl2', this.cl2);
        // console.log('[colonne] - cl3', this.cl3);
        // console.log('[colonne] - cl4', this.cl4);
        // console.log('[colonne] - cl5', this.cl5);
        // console.log('[colonne] - cl6', this.cl6);
        // console.log('[colonne] - cl7', this.cl7);
        // console.log('[colonne] - cl8', this.cl8);
    }
    downloadFile(documento) {
        const url = this.documentaleServiceUrl + documento.url;
        console.log('[url]', url);
        const headers = new HttpHeaders();
        headers.append('Accept', 'text/plain');
        this.http.get(url, { headers: headers, responseType: 'blob' }).subscribe(response => this.saveFile(response, documento.nome));
    }
    saveFile(response, nomeFile) {
        const blob = new Blob([response], { type: 'text/plain' });
        saveAs(blob, nomeFile);
    }
    isValid(stato) {
        if (stato.filter(s => s.lastState == true)) {
            return true;
        }
        else {
            return false;
        }
    }
    visualizzaDettaglio(allegato) {
        this.visualizzaDettagli = true;
        try {
            this.dataJson = JSON.parse(allegato.jsonMetadati);
        }
        catch (e) {
            this.dataJson = null;
            console.log('[error occored while you were typing the JSON]');
        }
        ;
        this.documentoSelezionato = allegato;
        this.dettaglioDoc.emit(this.visualizzaDettagli);
    }
}
AllegatiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-allegati',
                template: "<!-- <p>allegati works!</p> -->\r\n<div *ngIf=\"loadingLinguage\" class=\"row\">\r\n\t<div *ngIf=\"!visualizzaDettagli\" class=\"col-12\">\r\n\t\t<div class=\"table-responsive\">\r\n\t\t\t<table class=\"table border\">\r\n\t\t\t\t<thead>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th *ngIf=\"cl1\" scope=\"col\">{{'colonna_allegati_1' | traduzione}}</th>\r\n\t\t\t\t\t\t<th *ngIf=\"cl2\" scope=\"col\">{{'colonna_allegati_2' | traduzione}}</th>\r\n\t\t\t\t\t\t<th *ngIf=\"cl3\" scope=\"col\">{{'colonna_allegati_3' | traduzione}}</th>\r\n\t\t\t\t\t\t<th *ngIf=\"cl4\" scope=\"col\">{{'colonna_allegati_4' | traduzione}}</th>\r\n\t\t\t\t\t\t<th *ngIf=\"cl5\" scope=\"col\">{{'colonna_allegati_5' | traduzione}}</th>\r\n\t\t\t\t\t\t<th *ngIf=\"cl6\" scope=\"col\">{{'colonna_allegati_6' | traduzione}}</th>\r\n\t\t\t\t\t\t<th *ngIf=\"cl7\" scope=\"col\">{{'colonna_allegati_7' | traduzione}}</th>\r\n\t\t\t\t\t\t<th *ngIf=\"cl8\" scope=\"col\">{{'colonna_allegati_8' | traduzione}}</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</thead>\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr *ngFor=\"let allegato of allegati let i = index\">\r\n\t\t\t\t\t\t<td *ngIf=\"cl1\">{{allegato?.dataDocumento | date:'dd/MM/yyyy'}}</td>\r\n\t\t\t\t\t\t<td *ngIf=\"cl2\">{{allegato?.dataCreazione | date:'dd/MM/yyyy'}}</td>\r\n\t\t\t\t\t\t<td *ngIf=\"cl3\">{{allegato?.tipoServizio?.descrizione}}</td>\r\n\t\t\t\t\t\t<td *ngIf=\"cl4\">{{allegato.descrizione}}</td>\r\n\t\t\t\t\t\t<td *ngIf=\"cl5\">{{allegato.nome}}</td>\r\n\t\t\t\t\t\t<td *ngIf=\"cl6\">{{allegato?.tipoDocumento?.descrizione}}</td>\r\n\t\t\t\t\t\t<td *ngIf=\"cl7\">\r\n\t\t\t\t\t\t\t<button mat-flat-button color=\"\" class=\"btn btn-link\"\r\n\t\t\t\t\t\t\t\t[disabled]=\"!isValid(allegato.statiDocumento)\"\r\n\t\t\t\t\t\t\t\t(click)=\"downloadFile(allegato)\"\r\n\t\t\t\t\t\t\t\t[attr.aria-label]=\"'bt-download-doc' | traduzione\"\r\n\t\t\t\t\t\t\t\ttitle=\"{{'bt-download-doc' | traduzione}}\">\r\n\t\t\t\t\t\t\t\t<span class=\"fas fa-download\" aria-hidden=\"true\"></span>\r\n\t\t\t\t\t\t\t\t<p class=\"sr-only\">{{'bt-download-doc' | traduzione}}</p>\r\n\t\t\t\t\t\t\t</button>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td *ngIf=\"allegato.jsonMetadati && cl8\">\r\n\t\t\t\t\t\t\t<button mat-flat-button color=\"\" class=\"btn btn-link\"\r\n\t\t\t\t\t\t\t\t(click)=\"visualizzaDettaglio(allegato)\"\r\n\t\t\t\t\t\t\t\t[attr.aria-label]=\"'bt-visualizza-dettaglio' | traduzione\"\r\n\t\t\t\t\t\t\t\ttitle=\"{{'bt-visualizza-dettaglio' | traduzione}}\">\r\n\t\t\t\t\t\t\t\t<span class=\"fas fa-eye ml-2\" aria-hidden=\"true\"></span>\r\n\t\t\t\t\t\t\t\t<p class=\"sr-only\">{{'bt-visualizza-dettaglio' | traduzione}}</p>\r\n\t\t\t\t\t\t\t</button>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<!-- TODO -->\r\n\t\t\t\t\t<!-- <tr *ngIf=\"allegato.jsonMetadati\">\r\n\t\t\t\t\t\t<button mat-flat-button color=\"link\" class=\"btn btn-link\"\r\n\t\t\t\t\t\t\t(click)=\"visualizzaDettaglio(allegato)\">\r\n\t\t\t\t\t\t\t{{'colonna_allegati_8' | traduzione}}\r\n\t\t\t\t\t\t\t{{'Visualizza dettaglio' | traduzione}}\r\n\t\t\t\t\t\t\t<i class=\"fas fa-arrow-right ml-2\"></i>\r\n\t\t\t\t\t\t</button>\r\n\t\t\t\t\t\t<a (click)=\"visualizzaDettaglio(allegato)\" class=\"float\"\r\n\t\t\t\t\t\t\t>{{'Visualizza dettaglio' | traduzione}}\r\n\t\t\t\t\t\t\t<i class=\"bg-primary text-white fas fa-arrow-right ml-1 p-2 rounded \"></i>\r\n\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t<lib-visualizza-dettagli\r\n\t\t\t\t\t\t\t\t[documentoSelezionato]=\"allegato\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t</lib-visualizza-dettagli>\r\n\t\t\t\t\t</tr> -->\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t\t<div class=\"col-12\">\r\n\t\t\t<div *ngIf=\"visualizzaDettagli\" class=\"card card-primary shadow\">\r\n\t\t\t\t<div class=\"card-header px-3 py-2\">\r\n\t\t\t\t\t<h4 class=\"card-title mb-0 font-weight-bold d-inline text-uppercase h5\">\r\n\t\t\t\t\t\t{{documentoSelezionato?.tipoServizio?.descrizione}}</h4>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"card-body px-3 py-2\">\r\n\t\t\t\t\t<div class=\"row mt-2 mb-3\">\r\n\t\t\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">\r\n\t\t\t\t\t\t\t\t{{'colonna_allegati_1' | traduzione }}:\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t\t<p >{{documentoSelezionato?.dataDocumento | date:'dd/MM/yyyy'}}</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">\r\n\t\t\t\t\t\t\t\t{{'colonna_allegati_2' | traduzione }}:\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t\t<p>{{documentoSelezionato?.dataCreazione | date:'dd/MM/yyyy'}}</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">\r\n\t\t\t\t\t\t\t\t{{'colonna_allegati_3' | traduzione }}:\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t\t<p >{{documentoSelezionato?.tipoServizio?.descrizione}}</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">\r\n\t\t\t\t\t\t\t\t{{'colonna_allegati_5' | traduzione }}:\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t\t<p>{{documentoSelezionato?.nome}}</p>\r\n\t\t\t\t\t\t</div>\r\n\r\n\t\t\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">\r\n\t\t\t\t\t\t\t\t{{'colonna_allegati_4' | traduzione }}:\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t\t<p>{{documentoSelezionato?.descrizione}}</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">\r\n\t\t\t\t\t\t\t\t{{'colonna_allegati_6' | traduzione }}:\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t\t<p >{{documentoSelezionato?.tipoDocumento?.descrizione}}</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12 mb-3\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\"><strong>{{'colonna_allegati_7' | traduzione }}</strong></p>\r\n\t\t\t\t\t\t\t<button mat-flat-button color=\"link\" class=\"btn btn-primary\"\r\n\t\t\t\t\t\t\t\t[disabled]=\"!isValid(documentoSelezionato.statiDocumento)\"\r\n\t\t\t\t\t\t\t\t(click)=\"downloadFile(documentoSelezionato)\" aria-label=\"scarica il documento\">\r\n\t\t\t\t\t\t\t\tDownload <span class=\"fas fa-download fa-lg ml-2\" aria-hidden=\"true\"></span>\r\n\t\t\t\t\t\t\t</button>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"col-12\">\r\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\" aria-labelledby=\"ulteriori_documento\">{{'Ulteriori Dettagli' | traduzione }}:</p>\r\n\t\t\t\t\t\t\t<ngx-json-viewer *ngIf=\"dataJson\"\r\n\t\t\t\t\t\t\t\t[json]=\"dataJson\"\r\n\t\t\t\t\t\t\t\t[expanded]=\"true\"\r\n\t\t\t\t\t\t\t\tid=\"ulteriori_documento\"\r\n\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t</ngx-json-viewer>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</div>\r\n",
                styles: [".card-primary>.card-header{background-color:#d3deea}.table>thead{background-color:#0a2644;color:#fff}.table td,.table th{border-top:0;padding:.75rem;vertical-align:top}.table tr{border-bottom:1px solid #dee2e6}.table tbody tr:hover{background-color:#dee2e6}.btn-link{color:#0061c2}.btn-link:hover{color:#053a9a}.btn-primary{background-color:#0061c2}.btn-primary:hover{background-color:#053a9a}"]
            },] }
];
AllegatiComponent.ctorParameters = () => [
    { type: TranslateService },
    { type: TranslatePipe },
    { type: HttpClient },
    { type: ConfigurationService }
];
AllegatiComponent.propDecorators = {
    allegati: [{ type: Input }],
    visualizzaDettagli: [{ type: Input }],
    colonne: [{ type: Input }],
    dettaglioDoc: [{ type: Output }]
};

class VisualizzaDettagliComponent {
    constructor(traduzione, http, configurationService) {
        this.traduzione = traduzione;
        this.http = http;
        this.configurationService = configurationService;
    }
    ngOnInit() {
        console.log('[Documentale]', this.documentoSelezionato);
        this.documentaleServiceUrl = this.configurationService.servicePaths.get('DOCUMENTALE_MS_API_URL');
        this.dettagli = this.traduzione.transform('visualizzaDettagli');
        try {
            this.dataJson = JSON.parse(this.documentoSelezionato.jsonMetadati);
        }
        catch (e) {
            this.dataJson = null;
            console.log('[error occored while you were typing the JSON]');
        }
        ;
        // this.data = this.pagamento.dataValuta != null ?
        //   moment(new Date(this.pagamento.dataValuta)).format("DD/MM/YYYY") : '';
        // this.contaRighe();
    }
    accordionOpened() {
        this.dettagli = this.traduzione.transform('nascondiDettagli');
    }
    accordionClosed() {
        this.dettagli = this.traduzione.transform('visualizzaDettagli');
    }
    contaRighe() {
        // if (this.pagamento.motivoScarto) {
        // 	let par = this.pagamento.motivoScarto;
        // 	par = par.replace(/(^\s*)|(\s*$)/gi, "");
        // 	par = par.replace(/[ ]{2,}/gi, " ");
        // 	par = par.replace(/\n /, "\n");
        // 	let numeroRighe = par.split('').length / 180;
        // 	this.numeroRighe = Math.ceil(numeroRighe).toString()
        // }
    }
    downloadFile(documento) {
        const url = this.documentaleServiceUrl + documento.url;
        console.log('[url]', url);
        const headers = new HttpHeaders();
        headers.append('Accept', 'text/plain');
        this.http.get(url, { headers: headers, responseType: 'blob' }).subscribe(response => this.saveFile(response, documento.nome));
    }
    isValid(stato) {
        if (stato.filter(s => s.lastState == true)) {
            return true;
        }
        else {
            return false;
        }
    }
    saveFile(response, nomeFile) {
        const blob = new Blob([response], { type: 'text/plain' });
        saveAs(blob, nomeFile);
    }
}
VisualizzaDettagliComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-visualizza-dettagli',
                template: "<!-- <p>visualizza-dettagli works!</p> -->\r\n<mat-accordion class=\"example-headers-align\" multi>\r\n\t<mat-expansion-panel class=\"panel-dettagli\" (opened)=\"accordionOpened()\" (closed)=\"accordionClosed()\">\r\n\t\t<mat-expansion-panel-header class=\"detail-pagamenti\">\r\n\t\t\t<mat-panel-title class=\"text-white\">\r\n\t\t\t\t{{dettagli}}\r\n\t\t\t</mat-panel-title>\r\n\t\t</mat-expansion-panel-header>\r\n\t\t<div class=\"row mt-2\">\r\n\t\t\t<!-- <div class=\"col-4\">\r\n            <p class=\"mb-0\"><b>{{'beneficiario' | traduzione}}</b></p>\r\n            <p>{{pagamento?.denominazione}}</p>\r\n        </div>\r\n        <div class=\"col-4\">\r\n            <p class=\"mb-0\"><b>{{'dataValuta' | traduzione}}</b></p>\r\n            <p>{{data}}</p>\r\n        </div>\r\n        <div class=\"col-4\">\r\n            <p class=\"mb-0\"><b>{{'cro' | traduzione}}</b></p>\r\n            <p>{{pagamento?.cro}}</p>\r\n        </div>\r\n        <div class=\"col-12\">\r\n            <p class=\"mb-0\"><b>{{'modalitaPagamaneto' | traduzione}}</b></p>\r\n            <p>{{pagamento.modalitaPagamento?.descrizione}}</p>\r\n        </div>\r\n        <div *ngIf=\"pagamento.motivoScarto\" class=\"col-12 col-md-12\">\r\n            <p class=\"mb-0\"><b>{{'motivoScarto' | traduzione}}</b></p>\r\n            <textarea disabled=\"true\" matInput value={{pagamento.motivoScarto}} rows={{numeroRighe}}></textarea>\r\n        </div> -->\r\n\r\n\t\t</div>\r\n\t\t<div class=\"card-header px-3 py-2\">\r\n\t\t\t<h3 class=\"card-title mb-0 font-weight-bold d-inline text-uppercase !important\">\r\n\t\t\t\t{{documentoSelezionato.tipoServizio.descrizione}}</h3>\r\n\t\t</div>\r\n\t\t<div class=\"card-body px-3 py-2\">\r\n\t\t\t<div class=\"row mt-2 mb-3\">\r\n\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t<p class=\"mb-0\">\r\n\t\t\t\t\t\t<!-- <b>{{'colonna_allegati_1' | traduzione }}</b> -->\r\n\t\t\t\t\t\t<b>{{'Data Documento' | traduzione }}</b>\r\n\t\t\t\t\t</p>\r\n\t\t\t\t\t<p>{{documentoSelezionato.dataCreazione | date:'dd/MM/yyyy'}}</p>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t<p class=\"mb-0\">\r\n\t\t\t\t\t\t<!-- <b>{{'colonna_allegati_2' | traduzione }}</b> -->\r\n\t\t\t\t\t\t<b>{{'Data Caricamento' | traduzione }}</b>\r\n\t\t\t\t\t</p>\r\n\t\t\t\t\t<p>{{documentoSelezionato.dataCreazione | date:'dd/MM/yyyy'}}</p>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t<p class=\"mb-0\">\r\n\t\t\t\t\t\t<!-- <b>{{'colonna_allegati_3' | traduzione }}</b> -->\r\n\t\t\t\t\t\t<b>{{'Servizio' | traduzione }}</b>\r\n\t\t\t\t\t</p>\r\n\t\t\t\t\t<p>{{documentoSelezionato.tipoServizio.descrizione}}</p>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t<p class=\"mb-0\">\r\n\t\t\t\t\t\t<!-- <b>{{'colonna_allegati_5' | traduzione }}</b> -->\r\n\t\t\t\t\t\t<b>{{'Nome Documento' | traduzione }}</b>\r\n\t\t\t\t\t</p>\r\n\t\t\t\t\t<p>{{documentoSelezionato.nome}}</p>\r\n\t\t\t\t</div>\r\n\r\n\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t<p class=\"mb-0\">\r\n\t\t\t\t\t\t<!-- <b>{{'colonna_allegati_4' | traduzione }}</b> -->\r\n\t\t\t\t\t\t<b>{{'Descrizione' | traduzione }}</b>\r\n\t\t\t\t\t</p>\r\n\t\t\t\t\t<p>{{documentoSelezionato.descrizione}}</p>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t<p class=\"mb-0\">\r\n\t\t\t\t\t\t<!-- <b>{{'colonna_allegati_6' | traduzione }}</b> -->\r\n\t\t\t\t\t\t<b>{{'Tipo Documento' | traduzione }}</b>\r\n\t\t\t\t\t</p>\r\n\t\t\t\t\t<p>{{documentoSelezionato.tipoDocumento.descrizione}}</p>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-4 col-sm-6 col-xs-12\">\r\n\t\t\t\t\t<!-- <p class=\"mb-0\"><b>{{'colonna_allegati_7' | traduzione }}</b></p> -->\r\n\t\t\t\t\t<p class=\"mb-0\"><b>{{'Scarica' | traduzione }}</b></p>\r\n\t\t\t\t\t<button mat-flat-button color=\"link\" class=\"btn btn-link\"\r\n\t\t\t\t\t\t[disabled]=\"!isValid(documentoSelezionato.statiDocumento)\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<i class=\"fas fa-download text-subtitle\"></i>\r\n\t\t\t\t\t</button>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-12\">\r\n\t\t\t\t\t<!-- <p class=\"mb-0\"><b>{{'colonna_allegati_8' | traduzione }}</b></p> -->\r\n\t\t\t\t\t<p class=\"mb-0\"><b>{{'Visualizza dettaglio' | traduzione }}</b></p>\r\n\t\t\t\t\t<ngx-json-viewer *ngIf=\"dataJson\"\r\n\t\t\t\t\t\t[json]=\"dataJson\"\r\n\t\t\t\t\t\t[expanded]=\"true\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t</ngx-json-viewer>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</mat-expansion-panel>\r\n</mat-accordion>\r\n",
                styles: [".mat-flat-button{line-height:25px;padding:0 12px}.mat-expansion-panel:not([class*=mat-elevation-z]){box-shadow:0 3px 1px -2px transparent,0 0 0 0 transparent,0 0 0 0 transparent}.mat-expansion-panel:not(.mat-expanded) .mat-expansion-panel-header:not([aria-disabled=true]):hover{background:#1d65da}.mat-expansion-panel-header.mat-expanded:focus{background:#1953b0}.mat-expansion-indicator:after{color:#fff!important;margin-top:-3px}.mat-expansion-panel-header{background-color:#1953b0!important;display:inline-flex;height:25px;padding:0 12px}.mat-expansion-panel-header.mat-expanded:hover{background:#1d65da!important}.mat-expansion-panel-body{padding:0 3px 16px}.mat-input-element:disabled{color:#000}"]
            },] }
];
VisualizzaDettagliComponent.ctorParameters = () => [
    { type: TranslatePipe },
    { type: HttpClient },
    { type: ConfigurationService }
];
VisualizzaDettagliComponent.propDecorators = {
    documentoSelezionato: [{ type: Input }]
};

class AllegatiModule {
}
AllegatiModule.decorators = [
    { type: NgModule, args: [{
                declarations: [
                    AllegatiComponent,
                    VisualizzaDettagliComponent
                ],
                imports: [
                    CommonModule,
                    HttpClientModule,
                    MatTableModule,
                    TranslateModule,
                    MatExpansionModule,
                    NgxJsonViewerModule
                ],
                exports: [AllegatiComponent],
                providers: [],
            },] }
];

const ORGANO_CORTE_DI_APPELLO = 'CA';
const ORGANO_TAR = 'TA';
const TRIBUNALE = 'T';
class TipologicheService {
    constructor(http, configurationService, appRef) {
        this.http = http;
        this.configurationService = configurationService;
        this.appRef = appRef;
        this.documentiObbligatoriByTipoRichiedente = {
            [(CodiceTipiRichiedente.CODICE_RICORRENTE)]: [TipiDocumento.ALTRO],
            [(CodiceTipiRichiedente.CODICE_EREDE_RICORRENTE)]: [TipiDocumento.DSAN_EREDI, TipiDocumento.ALTRO],
            [(CodiceTipiRichiedente.CODICE_PERSONA_GIURIDICA_RAPPRESENTANTE_LEGALE)]: [TipiDocumento.ATTO_COSTITUTIVO,
                TipiDocumento.ALTRO],
            [(CodiceTipiRichiedente.CODICE_PROCURATORE_ANTISTATARIO)]: [TipiDocumento.ALTRO],
            [(CodiceTipiRichiedente.CODICE_EREDE_PROCURATORE_ANTISTATARIO)]: [TipiDocumento.DSAN_EREDI, TipiDocumento.ALTRO],
            [(CodiceTipiRichiedente.CODICE_TUTORE_PROCURATORE_LEGALE)]: [TipiDocumento.PROCURA,
                TipiDocumento.PROVVEDIMENTO_DI_INCASSO_SOMME,
                TipiDocumento.PROVVEDIMENTO_DEL_GIUDICE_TUTELARE, TipiDocumento.ALTRO],
            [(CodiceTipiRichiedente.CODICE_CURATORE_FALLIMENTARE)]: [TipiDocumento.ATTO_COSTITUTIVO,
                TipiDocumento.PROVVEDIMENTO_FALLIMENTO, TipiDocumento.ALTRO]
        };
        console.log('[TipologicheService]');
        // console.log('[configurationService]', configurationService);
        // this.urlArgo = configurationService.servicePaths.get("ARGO_INTEGRATION_MS_API_URL") + "/v1";
        // console.log('[urlArgo - lib]', this.urlArgo);
        const lingua$ = configurationService.lingua$;
        // console.log('[lingua]', configurationService.servicePaths.get("I18N_MS_API_URL"));
        this.urlAnagrafe = this.configurationService.servicePaths.get("ANAGRAFE_MS_API_URL") + "/api/v1";
        this.urlDeposito = configurationService.servicePaths.get("DEPOSITO_MS_API_URL") + "/v1";
        console.log('[urlDeposito - lib]', this.urlDeposito);
        //TODO
        // const url: string = this.paths.get_V1Tipologiche();
        // const url: string = this.urlArgo + '/tipologiche';
        const url = this.urlDeposito + '/tipologiche';
        this.tipologiche = lingua$.pipe(switchMap(lingua => this.http.get(url, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => appRef.tick()), shareReplay());
        //TODO
        // this.tipologiche = this.http.get<TipologicheDTO>(url).pipe(shareReplay());
        //TODO
        // const sscription = this.tipologiche
        // 	.pipe(
        // 		pluck("tipiDocumento"))
        // 	.subscribe(
        // 		t => {
        // 			console.log('[tipologiche]', t);
        // 		},
        // 		_ => {
        // 			// this.modals.failure([
        // 			// 	"recupero.tipologiche.failure"
        // 			// ], []);
        // 		}
        // 	);
        //TODO
        // this.V1_ORGANI_GIURISDIZIONALI = this.urlArgo + '/organiGiurisdizionali?tipo={tipoorgano}';
        this.V1_ORGANI_GIURISDIZIONALI = this.urlDeposito + '/organiGiurisdizionali?tipo={tipoorgano}';
        this.V1_TRIBUNALI = this.V1_ORGANI_GIURISDIZIONALI + '&provincia={provincia}';
    }
    tribunali_mock(siglaProvincia) {
        return [
            {
                "id": "2252",
                "codiceFiscale": "83005420589",
                "nomeUfficio": "Tribunale di CIVITAVECCHIA",
                "indirizzo": "VIA TERME DI TRAIANO 56/A",
                "comune": "CIVITAVECCHIA",
                "codiceistat": "58032",
                "cap": "00053",
                "telefono": "0766360273",
                "fax": " 0766 - 581285 (segreteria)0766 - 581284 (ufficio G.I.P.)0766 - 501949 (dibattimento)",
                "email": "tribunale.civitavecchia@giustizia.it",
                "pec": [
                    "dirigente.tribunale.civitavecchia@giustizia.it"
                ],
                // "avvisoPCT": " I recapiti di seguito riportati possono essere utilizzati in caso di problemi nell'accetazione dei depositi telematici, nella ricezione delle comunicazioni e notificazioni effettuate dalla cancelleria, nonché in caso di mancata visualizzazione dei propri fascicoli in consultazione.\n                ",
                // "telefonoPCT": "0766360282",
                // "orariPCT": "h.09.00/12.30 cancelleria da lunedì a venerdì h.09.00/12.30 assistenza lunedì, martedì, mercoledì",
                // "emailsPCT": "tribunale.civitavecchia@civile.ptel.giustiziacert.it",
                "codiceCatastale": "C773",
                // "isCorte": false,
                "siglaProvincia": siglaProvincia,
                "altroNome": ""
            },
            {
                "id": "2388",
                "codiceFiscale": "80416340588",
                "nomeUfficio": "Corte d'Appello di ROMA",
                "indirizzo": " Presidenza - dirigenza - sezioni civili - uffici amministrativi via Antonio Varisco, 3/5 06 - 398081 (centralino) tel: 06 - 39",
                "comune": "ROMA",
                "codiceistat": "58091",
                "cap": "00136",
                "telefono": "0766360273",
                "fax": " 0766 - 581285 (segreteria)0766 - 581284 (ufficio G.I.P.)0766 - 501949 (dibattimento)",
                "email": " ca.roma@giustizia.it",
                "pec": [],
                // "sitoweb": "http://www.giustizia.lazio.it/appello.it/base.php?inf=eud1.txt",
                // "infoChiusuraPatrono": "29 giugno",
                "codiceCatastale": "H501",
                // "isCorte": true,
                "siglaProvincia": siglaProvincia,
                "altroNome": ""
            }
        ];
    }
    tribunali_mock2(siglaProvincia) {
        return [
            {
                "id": "2330",
                "codiceFiscale": "80020770659",
                "nomeUfficio": "Tribunale di SALERNO",
                "indirizzo": "corso Garibaldi 184",
                "comune": "SALERNO",
                "codiceistat": "65116",
                "cap": "84122",
                "telefono": "0895645111",
                "fax": " 089 - 5645019089 - 251217089 - 251586",
                "email": "tribunale.salerno@giustizia.it",
                "pec": [
                    "prot.tribunale.salerno@giustiziacert.it"
                ],
                "codiceCatastale": "H703",
                "siglaProvincia": siglaProvincia,
                "altroNome": ""
            },
            {
                "id": "2299",
                "codiceFiscale": "94012670652",
                "nomeUfficio": "Tribunale di NOCERA INFERIORE",
                "indirizzo": "via Giovanni Falcone 12/14",
                "comune": "NOCERA INFERIORE",
                "codiceistat": "65078",
                "cap": "84014",
                "telefono": "0813239111",
                "fax": " 081 - 5173344",
                "email": "tribunale.nocerainferiore@giustizia.it",
                "pec": [
                    "prot.tribunale.nocerainferiore@giustiziacert.it"
                ],
                "codiceCatastale": "F912",
                "siglaProvincia": "SA",
                "altroNome": ""
            },
            {
                "id": "2389",
                "codiceFiscale": "80023290655",
                "nomeUfficio": "Corte d'Appello di SALERNO",
                "indirizzo": " Viale Unità d'Italia",
                "comune": "SALERNO",
                "codiceistat": "65116",
                "cap": "84100",
                "telefono": " 089 - 5645111089 - 5645157 (presidenza)",
                "fax": " 089 - 251662",
                "email": " ca.salerno@giustizia.it",
                "pec": [
                    "prot.tribunale.nocerainferiore@giustiziacert.it"
                ],
                "codiceCatastale": "H703",
                "siglaProvincia": siglaProvincia,
                "altroNome": ""
            }
        ];
    }
    getTipiDocumento$() {
        return this.tipologiche.pipe(map((tipogiche) => tipogiche.tipiDocumento), shareReplay());
    }
    getTipiDomicilio$() {
        return this.tipologiche.pipe(map((tipogiche) => tipogiche.tipiDomicilio), shareReplay());
    }
    getTipoEmittente$() {
        return this.tipologiche.pipe(map((tipogiche) => tipogiche.tipiEmittente), shareReplay());
    }
    getRts$() {
        return this.tipologiche.pipe(map((tipogiche) => tipogiche.rts), shareReplay());
    }
    getTipoContenzioso$() {
        return of(this.getTipoContenzioso()).pipe(shareReplay());
    }
    getTipiRuoloAltriSoggetti$() {
        return this.tipologiche.pipe(map((tipogiche) => tipogiche.tipiRuoloAltriSoggetti), shareReplay());
    }
    getTipiDeposito$() {
        return this.tipologiche.pipe(map((tipogiche) => tipogiche.tipoDeposito), shareReplay());
    }
    getTipiCatasto$() {
        return this.tipologiche.pipe(map((tipologiche) => tipologiche.tipoCatasto), shareReplay());
    }
    filterTipiPagamentoByTipoRichiedente(tipiPagamento, tipoRichiedente) {
        // console.log('[tipoRichiedente]', tipoRichiedente);
        const isPG = tipoRichiedente == CodiceTipiRichiedente.CODICE_PERSONA_GIURIDICA_RAPPRESENTANTE_LEGALE ||
            tipoRichiedente == CodiceTipiRichiedente.CODICE_CURATORE_FALLIMENTARE;
        return isPG ?
            tipiPagamento :
            tipiPagamento.filter(tipoPagamento => tipoPagamento.codice != 'C');
    }
    getTipoPagamentoByTipoRichiedente$(tipoRichiedente) {
        return this.getTipiModalitaDiPagamento$().pipe(map(tipiPagamento => this.filterTipiPagamentoByTipoRichiedente(tipiPagamento, tipoRichiedente)));
    }
    getCortiAppello$() {
        return;
        //TODO
        // const url: string = this.paths.get_V1Organo(ORGANO_CORTE_DI_APPELLO);
        // return this.http.get<Array<TipologicaDTO>>(url);
    }
    getTar$() {
        return;
        //TODO
        // const url: string = this.paths.get_V1Organo(ORGANO_TAR);
        // return this.http.get<Array<TipologicaDTO>>(url);
    }
    getTribunali$(siglaProvincia) {
        // return this.http.get<Array<TribunaleDTO>>(this.urlAnagrafe + `/tribunale/provincia/${siglaProvincia}/`).pipe(shareReplay());
        if (siglaProvincia === "RM") {
            return of(this.tribunali_mock(siglaProvincia));
        }
        else if (siglaProvincia === "SA") {
            return of(this.tribunali_mock2(siglaProvincia));
        }
        else {
            return of([]);
        }
    }
    get_V1Tribunale(tribunale, siglaProvincia) {
        const regexTipoOrgano = new RegExp('{tipoorgano}', 'gi');
        const regexProvincia = new RegExp('{provincia}', 'gi');
        return this.V1_TRIBUNALI
            .replace(regexTipoOrgano, tribunale)
            .replace(regexProvincia, siglaProvincia);
    }
    getTipoContenzioso() {
        return [
            { codice: '1', descrizione: 'Contenziosi giustizia amministrativa e Corte dei Conti', id: '1', codiceLingua: 'it_IT' },
        ];
    }
    getTipiModalitaDiPagamento$() {
        return this.tipologiche.pipe(pluck('tipiModalitaDiPagamento'));
    }
    getTipoDescrizioneCausale$() {
        return this.tipologiche.pipe(map((tipogiche) => tipogiche.tipoDescrizioneCausale), shareReplay());
    }
}
TipologicheService.ɵprov = ɵɵdefineInjectable({ factory: function TipologicheService_Factory() { return new TipologicheService(ɵɵinject(HttpClient), ɵɵinject(ConfigurationService), ɵɵinject(ApplicationRef)); }, token: TipologicheService, providedIn: "root" });
TipologicheService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
TipologicheService.ctorParameters = () => [
    { type: HttpClient },
    { type: ConfigurationService },
    { type: ApplicationRef }
];

class DatiTribunaleComponent {
    constructor(msg, tipologiche, appRef) {
        this.msg = msg;
        this.tipologiche = tipologiche;
        this.appRef = appRef;
        this.form = new FormGroup({});
        this.done = new EventEmitter();
    }
    ngOnDestroy() {
        if (this.$valuechangeTrib) {
            this.$valuechangeTrib.unsubscribe();
        }
        if (this.$changeTribunale) {
            this.$changeTribunale.unsubscribe();
        }
    }
    ngOnInit() {
        var _a, _b;
        const localitaProvinciaAC = new FormControl({ value: (_a = this === null || this === void 0 ? void 0 : this.autoritaOrdinante) === null || _a === void 0 ? void 0 : _a.codiceProvincia, disabled: false }, [Validators.required]);
        this.form.addControl("localitaProvinciaAC", localitaProvinciaAC);
        const tribunaleAC = new FormControl({ value: '', disabled: false }, c => {
            return String(c.value || '').length > 0
                ? {}
                : { 'required': 'Il campo è obbligatorio.' };
        });
        this.form.addControl("tribunaleAC", tribunaleAC);
        /* const tribunaleCF = new FormControl(
            { value: "", disabled: true }
        );
        this.form.addControl("tribunaleCF", tribunaleCF); */
        //reccupero_tribunali
        this.tribunali$ = localitaProvinciaAC.valueChanges
            .pipe(startWith((_b = this.autoritaOrdinante) === null || _b === void 0 ? void 0 : _b.codiceProvincia), switchMap((value) => this.tipologiche.getTribunali$(value)
            .pipe(withLatestFrom(of(value)))), 
        // tap(_ => console.log("outMergeMap", _)),
        //SE SI PROVIENE DALLE BOZZE => SI RESETTA IL TRIBUNALE
        tap(([tribunali, value]) => {
            var _a;
            if (value == ((_a = this.autoritaOrdinante) === null || _a === void 0 ? void 0 : _a.codiceProvincia)) {
                tribunaleAC.setValue(this.autoritaOrdinante.idTribunale);
            }
            else {
                tribunaleAC.setValue(null);
            }
        }), map(([tribunali, value]) => tribunali), shareReplay()
        // catchError(error=> )
        );
        //Build_output_steam
        const changeTribinali$ = defer(() => this.tribunali$);
        const streamOutput$ = combineLatest([
            changeTribinali$,
            tribunaleAC.valueChanges
        ])
            .pipe(map(([listaTribunali, tribunaleSelected]) => listaTribunali.find(tribunale => tribunale.id == tribunaleSelected)), map(tribunale => ComponentOutputStatus.of(this.form.valid, tribunale)));
        /* this.cf$ = tribunaleAC.valueChanges
            .pipe(
                tap(_ => console.log("cf$", _)),
                switchMap(value => this.tribunali$.pipe(
                    map(trib => trib.find(
                        tribunale => tribunale.codiceistat == value)?.codiceFiscale
                    ))
                )
            ) */
        //OUTPUT_COMPONENT
        this.$valuechangeTrib = streamOutput$.pipe().subscribe(out => this.done.emit(out));
    }
    resetTribunale() { }
}
DatiTribunaleComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-dati-tribunale',
                template: "<div class=\"row\" [formGroup]=\"form\">\r\n\t<div class=\"col-12\">\r\n\t\t<!-- <h4 class=\"h5\">{{'inserisci-dati-tribunale' | traduzione}}</h4> -->\r\n\t\t<h3 class=\"h5 mb-0\"><info-tip-label label=\"inserisci-dati-tribunale\"></info-tip-label></h3>\r\n\t</div>\r\n\t<div class=\"col-md-6\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'required' | traduzione}}{{'provincia' | traduzione}}</mat-label>\r\n\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"localitaProvinciaAC\">\r\n\t\t\t\t<mat-option *ngFor=\"let provincia of province | async\" [value]=\"provincia.sigla\">\r\n\t\t\t\t\t{{provincia.denominazione}}\r\n\t\t\t\t</mat-option>\r\n\t\t\t</mat-select>\r\n\t\t\t<mat-error *ngIf=\"form.touched && form.controls[ 'localitaProvinciaAC'].invalid\">\r\n\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls[ 'localitaProvinciaAC']) | traduzione}}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint *infoTip=\"'provincia'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\t<div class=\"col-md-6\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'required' | traduzione}}{{'tribunale' | traduzione}}</mat-label>\r\n\t\t\t<mat-select formControlName=\"tribunaleAC\">\r\n\t\t\t\t<mat-option *ngFor=\"let tribunale of tribunali$ | async\" [value]=\"tribunale.id\">\r\n\t\t\t\t\t{{tribunale.nomeUfficio}}\r\n\t\t\t\t</mat-option>\r\n\t\t\t</mat-select>\r\n\t\t\t<mat-error *ngIf=\"form.controls[ 'tribunaleAC'].invalid\">\r\n\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls[ 'tribunaleAC']) | traduzione}}\r\n\t\t\t</mat-error>\r\n\t\t\t<mat-hint *infoTip=\"'tribunale'\"></mat-hint>\r\n\t\t</mat-form-field>\r\n\t</div>\r\n\t<!-- <div class=\"col-md-4\" *ngIf=\"cf$ | async\">\r\n\t\t<mat-form-field>\r\n\t\t\t<mat-label>{{'codice-fiscale' | traduzione}}</mat-label>\r\n\t\t\t<input matInput formControlName=\"tribunaleCF\" [value]=\"cf$ | async\">\r\n\t\t</mat-form-field>\r\n\t</div> -->\r\n</div>\r\n",
                styles: [""]
            },] }
];
DatiTribunaleComponent.ctorParameters = () => [
    { type: MessageService },
    { type: TipologicheService },
    { type: ApplicationRef }
];
DatiTribunaleComponent.propDecorators = {
    province: [{ type: Input }],
    autoritaOrdinante: [{ type: Input }],
    done: [{ type: Output }]
};

const CodiceTipoPagamento = {
    CODICE_BONIFICO_SEPA: 'A',
    CODICE_BONIFICO_EXTRA_SEPA: 'B',
    CODICE_TESORERIA: 'C',
    CODICE_VAGLIA: 'D'
};

class ModalitaPagamentoDTO {
}
function fromIdAndTipo(idModalitaPagamento, tipoModalitaPagamento) {
    const modalitaPagamento = new ModalitaPagamentoDTO();
    modalitaPagamento.idModalitaPagamento = idModalitaPagamento;
    modalitaPagamento.tipologiaPagamento = {
        codice: tipoModalitaPagamento,
        id: "",
        descrizione: "",
        codiceLingua: ""
    };
    return modalitaPagamento;
}

class PagamentoDTO {
}

class BonificoDTO {
}

class BonificoExtraSepaDTO {
}

class TesoreriaDTO {
}

class VagliaBdiDTO {
}

function toBonificoSepa(modalitaPagamento) {
    const bonificoSepa = new BonificoDTO();
    bonificoSepa.iban = modalitaPagamento.conto;
    return bonificoSepa;
}
function toTesoreria(modalitaPagamento) {
    const tesoreria = new TesoreriaDTO();
    tesoreria.numeroConto = modalitaPagamento.conto;
    tesoreria.tesoreria = modalitaPagamento.tesoreria.codice;
    return tesoreria;
}
function toBonificoExtraSepa(modalitaPagamento) {
    console.log('[toBonificoExtraSepa]', modalitaPagamento);
    const bonificoExtraSepa = new BonificoExtraSepaDTO();
    bonificoExtraSepa.indirizzo = modalitaPagamento.indirizzo;
    bonificoExtraSepa.istitutoBancario = modalitaPagamento.denominazione;
    //TODO
    // bonificoExtraSepa.localita = modalitaPagamento.
    // bonificoExtraSepa.nazione = (modalitaPagamento.nazione || {}).codiceCatastale;
    bonificoExtraSepa.nazione = modalitaPagamento.nazione;
    bonificoExtraSepa.numeroConto = modalitaPagamento.conto + " " + modalitaPagamento.swiftBic;
    return bonificoExtraSepa;
}
function toVagliaBdi(modalitaPagamento) {
    const vaglia = new VagliaBdiDTO();
    vaglia.meMedesimo = true;
    vaglia.studioLegale = false;
    return vaglia;
}

class PagamentoComponent {
    constructor(msg) {
        this.msg = msg;
        this.nextStep = new EventEmitter();
        this.salvaBozza = new EventEmitter();
        this.previousStep = new EventEmitter();
        this.direction = 'both-ways';
        this.isFinal = false;
        this.changesVagliaBdi$ = new Subject();
        this.changesAttoPignoramento$ = new Subject();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        let valid = true;
        if (!this.pagamento) {
            this.initPagamento();
            valid = false;
        }
        // console.log('[PagamentoComponent] onInit', this.pagamento);
        this.tipoModalitaPagamento = new FormControl({ value: this.pagamento.tipoPagamento, disabled: false }, [Validators.required]);
        this.form.addControl('tipoModalitaPagamento', this.tipoModalitaPagamento);
        const initalModalitaPagamento = fromIdAndTipo(this.pagamento.idModalitaPagamento, this.pagamento.tipoPagamento);
        this.modalitaPagamento = new FormControl({ value: initalModalitaPagamento, disabled: false }, [Validators.required]);
        this.form.addControl('modalitaPagamento', this.modalitaPagamento);
        const changesTipoModalitaPagamento$ = this.tipoModalitaPagamento.valueChanges
            .pipe(shareReplay());
        this.modalitaPagamentoPerTipoSelezionato$ = changesTipoModalitaPagamento$
            .pipe(tap(_ => this.modalitaPagamento.setValue(null)), tap(_ => this.resetPagamenti()), startWith(this.pagamento.tipoPagamento), switchMap(tipoModalitaPagamento => this.modalitaPagamento$.pipe(map(modalitaPagamentoPF => {
            const modalitaPagamentoPerTipo = modalitaPagamentoPF.filter(mod => tipoModalitaPagamento == mod.tipologiaPagamento.codice);
            return modalitaPagamentoPerTipo;
        }))));
        const changesTipoRimborso$ = changesTipoModalitaPagamento$.pipe(map(tipoRimborso => {
            return ComponentOutputStatus.of(tipoRimborso != null, (pagamento) => pagamento.tipoPagamento = tipoRimborso);
        }));
        const changesModalitaRimborso$ = this.modalitaPagamento.valueChanges.pipe(map(rimborso => {
            return ComponentOutputStatus.of(true, _ => {
                // console.log('[PagamentoComponent] rimborso', rimborso);
                if (rimborso != undefined && rimborso != '') {
                    this.setRimborso(rimborso);
                }
            });
        }));
        const pagamentoChanges$ = ComponentReducer.reducer4(changesTipoRimborso$, changesModalitaRimborso$, this.changesVagliaBdi$, 
        //TODO
        this.changesAttoPignoramento$, this.pagamentoValid(), ComponentOutputStatus.of(valid, this.pagamento))
            .pipe(shareReplay());
        this.isFormValid$ = pagamentoChanges$.pipe(map(_ => _.status), startWith(valid));
        pagamentoChanges$.subscribe((pagStatus) => {
            console.log("[PagamentoComponent] status", pagStatus);
        });
    }
    pagamentoValid() {
        return pagamento => {
            let pagamentoValid;
            if (pagamento.tipoPagamento) {
                switch (pagamento.tipoPagamento) {
                    case (CodiceTipoPagamento.CODICE_BONIFICO_SEPA):
                        pagamentoValid = pagamento.bonifico != null;
                        break;
                    case (CodiceTipoPagamento.CODICE_BONIFICO_EXTRA_SEPA):
                        pagamentoValid = pagamento.bonificoExtraSepa != null;
                        break;
                    case (CodiceTipoPagamento.CODICE_TESORERIA):
                        pagamentoValid = pagamento.tesoreria != null;
                        break;
                    case (CodiceTipoPagamento.CODICE_VAGLIA):
                        pagamentoValid = pagamento.vagliaBDI != null;
                        break;
                    default:
                        pagamentoValid = false;
                }
            }
            else {
                pagamentoValid = false;
            }
            return pagamentoValid;
        };
    }
    modalitaComparator(m1, m2) {
        return (m1 || {}).idModalitaPagamento == (m2 || {}).idModalitaPagamento;
    }
    resetPagamenti() {
        this.changesVagliaBdi$.next(ComponentOutputStatus.of(true, (p) => p.vagliaBDI = null));
    }
    setRimborso(rimborso) {
        // console.log('[setRimborso]', rimborso);
        this.resetModalitaPagamento();
        this.pagamento.idModalitaPagamento = rimborso.idModalitaPagamento;
        switch (rimborso.tipologiaPagamento.codice) {
            case (CodiceTipoPagamento.CODICE_BONIFICO_SEPA):
                this.pagamento.bonifico = toBonificoSepa(rimborso);
                break;
            case (CodiceTipoPagamento.CODICE_BONIFICO_EXTRA_SEPA):
                this.pagamento.bonificoExtraSepa = toBonificoExtraSepa(rimborso);
                break;
            case (CodiceTipoPagamento.CODICE_TESORERIA):
                this.pagamento.tesoreria = toTesoreria(rimborso);
                break;
            case (CodiceTipoPagamento.CODICE_VAGLIA):
                this.pagamento.vagliaBDI = toVagliaBdi(rimborso);
                break;
            default:
        }
    }
    resetModalitaPagamento() {
        this.pagamento.idModalitaPagamento = null;
        this.pagamento.vagliaBDI = null;
        this.pagamento.tesoreria = null;
        this.pagamento.bonificoExtraSepa = null;
        this.pagamento.bonifico = null;
    }
    hasSelectedModalitaDiPagamentoAnd(v) {
        return this.hasSelectedModalitaDiPagamento() && v;
    }
    hasSelectedModalitaDiPagamento() {
        return this.modalitaPagamento.value;
    }
    //TODO
    isAutoritaGiudiziaria() {
        return this.hasSelectedModalitaDiPagamentoAnd(CodiceTipoPagamento.CODICE_BONIFICO_SEPA == this.tipoModalitaPagamento.value);
    }
    forward(_) {
        this.nextStep.emit(this.pagamento);
    }
    onSalvaBozza(_) {
        this.salvaBozza.emit(this.pagamento);
    }
    backward(_) {
        this.previousStep.emit(this.pagamento);
    }
    complete(_) { }
    initPagamento() {
        this.pagamento = new PagamentoDTO();
    }
    //TODO
    attoPignoramentoReady(attoPignoramnetoStatus) {
        // console.log('[attoPignoramentoReady]', attoPignoramnetoStatus);
        this.changesAttoPignoramento$.next(attoPignoramnetoStatus.mapValue((pign) => (at) => at.tribunale = pign));
    }
}
PagamentoComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-pagamento',
                template: "<mat-expansion-panel class=\"panel\" [expanded]=\"true\">\r\n\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\r\n\t\t<mat-panel-title>\r\n\t\t\t<h3>{{'modalita-pagamento' | traduzione}}</h3>\r\n\t\t</mat-panel-title>\r\n\t</mat-expansion-panel-header>\r\n\t<form [formGroup]=\"form\">\r\n\t\t<div class=\"collapse-body mt-2\">\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-md-6\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{'required'| traduzione}}{{'tipologia-pagamento' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"tipoModalitaPagamento\">\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let pagamento of tipologiePagamento$ | async\"\r\n\t\t\t\t\t\t\t\t[value]=\"pagamento.codice\">\r\n\t\t\t\t\t\t\t\t{{pagamento.descrizione}}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"form.controls['tipoModalitaPagamento'].invalid\">\r\n\t\t\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['tipoModalitaPagamento']) | traduzione}}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-6\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{'required'| traduzione}}{{'modalita-pagamento' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"modalitaPagamento\" [compareWith]=\"modalitaComparator\">\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let modalita of modalitaPagamentoPerTipoSelezionato$ | async\"\r\n\t\t\t\t\t\t\t\t[value]=\"modalita\">\r\n\t\t\t\t\t\t\t\t{{modalita.conto || modalita.tipologiaPagamento.descrizione}}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"form.controls['modalitaPagamento'].invalid\">\r\n\t\t\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['modalitaPagamento']) | traduzione}}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<lib-dati-tribunale *ngIf=\"isAutoritaGiudiziaria()\"\r\n\t\t\t\t(attoPignoramentoReady)=\"attoPignoramentoReady($event)\"\r\n\t\t\t\t[attoPignoramento]=\"attoPignoramento\"\r\n\t\t\t\t[province]=\"province\"\r\n\t\t\t>\r\n\t\t\t</lib-dati-tribunale>\r\n\t\t</div>\r\n\t</form>\r\n</mat-expansion-panel>\r\n<!-- TODO -->\r\n<!-- <div class=\"mt-4\"></div>\r\n<lp-stepper-navigator-rx\r\n\t\t[form]=\"form\"\r\n\t\t[direction]=\"direction\"\r\n\t\t[isFinal]=\"isFinal\"\r\n\t\t[isContainerValid]=\"isFormValid$\"\r\n\t\t(goForward)=\"forward($event)\"\r\n\t\t(goBackward)=\"backward($event)\"\r\n\t\t(complete)=\"complete($event)\"\r\n\t\t(salvaBozza)=\"onSalvaBozza($event)\"\r\n>\r\n</lp-stepper-navigator-rx> -->\r\n",
                styles: [".mat-card{border-radius:0!important;border-top:5px solid #0a2644}.divider{background-color:#737373;height:1px;width:100%}.mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fff!important}.mat-select-value{max-width:100%;width:100%!important}"]
            },] }
];
PagamentoComponent.ctorParameters = () => [
    { type: MessageService }
];
PagamentoComponent.propDecorators = {
    pagamento: [{ type: Input }],
    tipologiePagamento$: [{ type: Input }],
    modalitaPagamento$: [{ type: Input }],
    province: [{ type: Input }],
    attoPignoramento: [{ type: Input }],
    nextStep: [{ type: Output }],
    salvaBozza: [{ type: Output }],
    previousStep: [{ type: Output }]
};

class DatiDepositoDTO {
}

class DatiDepositoGiudiziarioDTO extends DatiDepositoDTO {
}

class DatiDeposito {
    constructor(msg, _ref, delegheService) {
        this.msg = msg;
        this._ref = _ref;
        this.delegheService = delegheService;
        this.rst_mock = [
            {
                "codiceFiscale": "TR",
                "codiceOrdinante": "Terni",
                "dataFine": new Date('10/06/2025'),
                "dataInizio": new Date('10/06/2025'),
                "denominazioneRTS": "RTS 1",
                "provinceCompetenza": ["TR"]
            },
            {
                "codiceFiscale": "RM",
                "codiceOrdinante": "Roma",
                "dataFine": new Date('10/06/2025'),
                "dataInizio": new Date('10/06/2025'),
                "denominazioneRTS": "RTS 1",
                "provinceCompetenza": ["TR"]
            },
            {
                "codiceFiscale": "MI",
                "codiceOrdinante": "Milano",
                "dataFine": new Date('10/06/2025'),
                "dataInizio": new Date('10/06/2025'),
                "denominazioneRTS": "RTS 1",
                "provinceCompetenza": ["TR"]
            }
        ];
        //TODO
        // DatiDepositoDTO
        // DatiDepositoGiudiziarioDTO
        // DatiDepositoNoEsproprioDTO
        this.datiDeposito = {};
        this.visibilityMask = {};
        this.nextStep = new EventEmitter();
        this.previousStep = new EventEmitter();
        this.salvaBozza = new EventEmitter();
        this.direction = "both-ways";
        this.isFinal = false;
    }
    isImportoFormatoValidoOLD(valoreImporto) {
        return /^(?:[0-9]+|(?:[0-9]{1,3}\.?)+)(?:,[0-9]{1,2})?€?$/
            .test(valoreImporto);
        42;
    }
    currencyToNumber(s) {
        return Number(s.replace(/\./g, '').replace(',', '.') || undefined);
    }
    isImportoFormatoValido(valoreImporto) {
        return /^(?:0|[1-9](?:[0-9]{0,2}\.[0-9]{3}(?:\.[0-9]{3})*|[0-9]*))(?:,[0-9]{2,2})€?$/
            .test(valoreImporto);
    }
    ngAfterViewInit() {
        this._ref.detectChanges();
    }
    ngOnInit() {
        this.form = new FormGroup({
            'causale': new FormControl({ value: '', disabled: !this.visibilityMask.causale }, c => {
                if (!this.visibilityMask.causale)
                    return {};
                return String(c.value || '').length > 0
                    ? {}
                    : { 'required': 'Il campo è obbligatorio.' };
            }),
            'importo': new FormControl({ value: '', disabled: !this.visibilityMask.importo }, c => {
                if (!this.visibilityMask.importo)
                    return {};
                // return this.isImportoFormatoValido(c.value)
                return this.isImportoFormatoValido(c.value)
                    ? {}
                    : { 'pattern': 'Formato non valido' };
            }),
            'rts-inoltro': new FormControl({ value: '', disabled: !this.visibilityMask.codiceRtsInoltro }, c => {
                if (!this.visibilityMask.codiceRtsInoltro)
                    return {};
                return String(c.value || '').length > 0
                    ? {}
                    : { 'required': 'Il campo è obbligatorio.' };
            }),
            'nota': new FormControl({ value: '', disabled: !this.visibilityMask.nota }, c => {
                if (!this.visibilityMask.nota)
                    return {};
                // return String(c.value).trim().length > 0
                // 	? {}
                // 	: { 'required': 'Il campo è obbligatorio.' };
            })
        });
        let valid = true;
        if (!this.datiDeposito) {
            this.initDatiDeposito();
            valid = false;
        }
        this._rts = this.rst_mock;
        this.listaRts$ = of(this.rst_mock);
        this.rts$ = of(this.rst_mock);
        // this.listaRts$.subscribe(
        // 	(rts) => {
        // 		console.log('[listaRts$]', rts);
        // 		if (rts != null) {
        // 			this.rts$ = this.delegheService.getListRtsCodiceRegione(rts);
        // 			this.rts$.subscribe(_rts => {
        // 				this._rts = _rts;
        // 				//console.log("_rts" + JSON.stringify(this._rts))
        // 			});
        // 		}
        // 	}
        // );
        this.form.controls['causale'].setValue(this.datiDeposito.causale);
        this.form.controls['importo'].setValue(this.datiDeposito.importo);
        this.form.controls['rts-inoltro'].setValue(this.datiDeposito.codiceRtsInoltro);
        this.form.controls['nota'].setValue(this.datiDeposito.nota);
        const changes$ = this.form.valueChanges.pipe(map(_ => {
            var _a;
            const dati = new DatiDepositoGiudiziarioDTO();
            dati.causale = this.form.controls['causale'].value;
            if (this.form.controls['importo'].value != undefined) {
                dati.importo = this.currencyToNumber(this.form.controls['importo'].value);
            }
            dati.codiceRtsInoltro = this.form.controls['rts-inoltro'].value;
            if ((dati === null || dati === void 0 ? void 0 : dati.codiceRtsInoltro) && (this === null || this === void 0 ? void 0 : this._rts)) {
                dati.denominazioneRTS = (_a = this._rts.find(x => x.codiceFiscale == (dati === null || dati === void 0 ? void 0 : dati.codiceRtsInoltro))) === null || _a === void 0 ? void 0 : _a.denominazioneRTS;
            }
            dati.nota = this.form.controls['nota'].value;
            this.datiDeposito = dati;
            // console.log("[dati]", this.form);
            return ComponentOutputStatus.of(this.form.valid, this.datiDeposito);
        }), startWith(ComponentOutputStatus.of(valid, this.datiDeposito)));
        this.subscription = changes$.subscribe(newDati => console.log('[DatiDepositoComponent] datiSpecificiDeposito', newDati));
    }
    forward($event) {
        this.nextStep.emit(this.datiDeposito);
    }
    backward($event) {
        this.previousStep.emit(this.datiDeposito);
    }
    onSalvaBozza($event) {
        this.salvaBozza.emit(this.datiDeposito);
    }
    complete($event) { }
    isFormValid() {
        return this.form.valid;
    }
    initDatiDeposito() {
        //TODO
        //this.datiDeposito = new DatiDepositoDTO() as T;
        this.datiDeposito = new DatiDepositoGiudiziarioDTO();
    }
    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
}
DatiDeposito.decorators = [
    { type: Component, args: [{
                selector: 'lib-dati-deposito',
                template: "<div class=\"mt-3 mb-5\">\r\n\t\t<mat-expansion-panel class=\"panel\" [expanded]=\"true\">\r\n\t\t\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\r\n\t\t\t\t<mat-panel-title>\r\n\t\t\t\t\t<h3 class=\"h5 mb-0\"><info-tip-label label=\"dati-deposito\"></info-tip-label></h3>\r\n\t\t\t\t</mat-panel-title>\r\n\t\t\t</mat-expansion-panel-header>\r\n\t\t\t<form [formGroup]=\"form\">\r\n\t\t\t\t<div class=\"collapse-body mt-2\">\r\n\t\t\t\t\t<div class=\"row\" *ngIf=\"visibilityMask.causale\">\r\n\t\t\t\t\t\t<div class=\"col-md-12\">\r\n\t\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t\t<input matInput\r\n\t\t\t\t\t\t\t\t\tplaceholder=\"{{ 'required' | traduzione }}{{ 'dati-deposito-causale' | traduzione }}\"\r\n\t\t\t\t\t\t\t\t\tformControlName=\"causale\"\r\n\t\t\t\t\t\t\t\t\tmaxlength=\"127\"\r\n\t\t\t\t\t\t\t\t\t#testoCausale>\r\n\t\t\t\t\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['causale'].invalid\">\r\n\t\t\t\t\t\t\t\t\t{{ msg.produceMessage('required', form.controls['causale']) | traduzione }}\r\n\t\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t\t\t<mat-hint *infoTip=\"'dati-deposito-causale'\"></mat-hint>\r\n\t\t\t\t\t\t\t\t<mat-hint align=\"end\">{{testoCausale.value.length}} / 127</mat-hint>\r\n\t\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<div class=\"col-md-4\" *ngIf=\"visibilityMask.importo\">\r\n\t\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t\t<input matInput\r\n\t\t\t\t\t\t\t\t\tplaceholder=\"{{'required' | traduzione }}{{'inserire-importo' | traduzione}}\"\r\n\t\t\t\t\t\t\t\t\tformControlName=\"importo\">\r\n\t\t\t\t\t\t\t\t\t<span matPrefix>&euro;</span>\r\n\t\t\t\t\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['importo'].invalid\">\r\n\t\t\t\t\t\t\t\t\t{{ msg.produceMessage('required', form.controls['importo']) | traduzione }}\r\n\t\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t\t\t<mat-hint *infoTip=\"'inserire-importo'\"></mat-hint>\r\n\t\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"col-md-4\" *ngIf=\"visibilityMask.codiceRtsInoltro\">\r\n\t\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'dati-deposito-rts-inoltro' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"rts-inoltro\">\r\n\t\t\t\t\t\t\t\t\t<mat-option\r\n\t\t\t\t\t\t\t\t\t\t*ngFor=\"let rts of rts$ | async\"\r\n\t\t\t\t\t\t\t\t\t\t[value]=\"rts.codiceFiscale\"\r\n\t\t\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\t\t{{ rts.denominazioneRTS }}\r\n\t\t\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t\t\t\t<!-- <mat-option\r\n\t\t\t\t\t\t\t\t\t\t*ngFor=\"let rts of listaRts\"\r\n\t\t\t\t\t\t\t\t\t\t[value]=\"rts.codiceFiscale\"\r\n\t\t\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\t{{ rts.codiceFiscale }}\r\n\t\t\t\t\t\t\t\t</mat-option> -->\r\n\t\t\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t\t\t<mat-error *ngIf=\"form.controls['rts-inoltro'].invalid\">\r\n\t\t\t\t\t\t\t\t\t{{ msg.produceMessage('required', form.controls['rts-inoltro']) | traduzione }}\r\n\t\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t\t\t<mat-hint *infoTip=\"'dati-deposito-rts-inoltro'\"></mat-hint>\r\n\t\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\" *ngIf=\"visibilityMask.nota\">\r\n\t\t\t\t\t\t<div class=\"col-md-12\">\r\n\t\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t\t<textarea \r\n\t\t\t\t\t\t\t\t    matInput\r\n\t\t\t\t\t\t\t\t\tplaceholder=\"{{ 'dati-deposito-nota' | traduzione }}\"\r\n\t\t\t\t\t\t\t\t\tformControlName=\"nota\"\r\n\t\t\t\t\t\t\t\t\tmaxlength=\"511\"\r\n\t\t\t\t\t\t\t\t\t#testo>\r\n\t\t\t\t\t\t\t\t</textarea>\r\n\t\t\t\t\t\t\t\t<mat-error *ngIf=\"form.touched && form.controls['nota'].invalid\">\r\n\t\t\t\t\t\t\t\t\t{{ msg.produceMessage('required', form.controls['nota']) | traduzione }}\r\n\t\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t\t\t<mat-hint *infoTip=\"'dati-deposito-nota'\"></mat-hint>\r\n\t\t\t\t\t\t\t\t<mat-hint align=\"end\">{{testo.value.length}} / 511</mat-hint>\r\n\t\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</form>\r\n\t\t</mat-expansion-panel>\r\n\t<lib-stepper-navigator\r\n\t\t[form]=\"form\"\r\n\t\t[direction]=\"direction\"\r\n\t\t[isFinal]=\"isFinal\"\r\n\t\t[isContainerValid]=\"isFormValid()\"\r\n\t\t(goForward)=\"forward($event)\"\r\n\t\t(goBackward)=\"backward($event)\"\r\n\t\t(salvaBozza)=\"onSalvaBozza($event)\"\r\n\t\t(complete)=\"complete($event)\"\r\n\t>\r\n\t</lib-stepper-navigator>\r\n</div>\r\n",
                styles: [".mat-card{border-radius:0!important;border-top:5px solid #0a2644}.divider{background-color:#737373;height:1px;width:100%}.mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fff!important}.mat-select-value{max-width:100%;width:100%!important}"]
            },] }
];
DatiDeposito.ctorParameters = () => [
    { type: MessageService },
    { type: ChangeDetectorRef },
    { type: DelegheService }
];
DatiDeposito.propDecorators = {
    datiDeposito: [{ type: Input }],
    visibilityMask: [{ type: Input }],
    listaRts$: [{ type: Input }],
    nextStep: [{ type: Output }],
    previousStep: [{ type: Output }],
    salvaBozza: [{ type: Output }]
};

class TabellaDocumentiComponent {
    constructor() {
        this.indiceSelezionato = new EventEmitter();
    }
    ngOnInit() { }
}
TabellaDocumentiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-tabella-documenti',
                template: "<mat-accordion displayMode=\"flat\" multi class=\"mat-table\">\r\n\t<section matSort class=\"mat-elevation-z2 mat-header-row\">\r\n\t\t<div class=\"mat-header-cell\" mat-sort-header=\"nrDocumento\">{{'nr-Documento' | traduzione}}</div>\r\n\t\t<div class=\"mat-header-cell\" mat-sort-header=\"tipoDocumento\"> {{'tipo-documento' | traduzione}}</div>\r\n\t\t<div class=\"mat-header-cell\" mat-sort-header=\"dataDocumento\">{{'data-documento' | traduzione}}</div>\r\n\t\t<div class=\"mat-header-cell\" mat-sort-header=\"fileName\">{{'file-name' | traduzione}}</div>\r\n\t\t<div class=\"mat-header-cell\" mat-sort-header=\"elimina\"></div>\r\n\t</section>\r\n\r\n\t<mat-expansion-panel *ngFor=\"let file of files$ | async; let i=index\">\r\n\t\t<mat-expansion-panel-header class=\"mat-row\">\r\n\t\t\t<div class=\"mat-cell\">{{file.numeroDocumento}}</div>\r\n\t\t\t<div class=\"mat-cell\">{{file.tipoDocumento.descrizione}}</div>\r\n\t\t\t<div class=\"mat-cell\">{{file.dataDocumento | date:'dd/MM/yyyy'}}</div>\r\n\t\t\t<div class=\"mat-cell\">{{file.file.name}}</div>\r\n\t\t\t<div class=\"mat-cell\">\r\n\t\t\t\t<button mat-flat-button\r\n\t\t\t\t\t\t\t\t(click)=\"indiceSelezionato.emit(i)\"\r\n\t\t\t\t\t\t\t\t[attr.aria-label]=\"'bt-elimina-documento' | traduzione\"\r\n\t\t\t\t\t\t\t\ttitle=\"{{'bt-elimina-documento' | traduzione}}\">\r\n\t\t\t\t\t<span class=\"fas fa-trash-alt icon-color-primary font-weight-bold\" aria-hidden=\"true\"></span>\r\n\t\t\t\t\t<p class=\"sr-only\">{{'bt-elimina-documento' | traduzione}}</p>\r\n\t\t\t\t</button>\r\n\t\t\t</div>\r\n\t\t</mat-expansion-panel-header>\r\n\r\n\t\t<div class=\"mt-2\">\r\n\t\t\t<span class=\"font-weight-bold\">\r\n\t\t\t\t{{'obbligatori' | traduzione}}:\r\n\t\t\t</span>\r\n\t\t\t<mat-checkbox [checked]=\"file.tipoDocumento.codice != 'ALTRO'\" [disabled]=\"true\"\r\n\t\t\t\t\t\t\t\t\t\tname=\"obbligatorio\">\r\n\t\t\t</mat-checkbox>\r\n\t\t</div>\r\n\r\n\t\t<div>\r\n\t\t\t<span class=\"font-weight-bold\">\r\n\t\t\t\t{{'tipologia-emittente' | traduzione}}:\r\n\t\t\t</span>\r\n\t\t\t<span class=\"ml-2\">{{file.codiceTipoEmittente || '' | titlecase }}</span>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"mt-2\">\r\n\t\t\t<span class=\"font-weight-bold\">\r\n\t\t\t\t{{'organo-emittente' | traduzione}}:\r\n\t\t\t</span>\r\n\t\t\t<span class=\"ml-2\">{{file.soggettoEmittente}}</span>\r\n\t\t</div>\r\n\r\n\t\t<div class=\"mt-2\">\r\n\t\t\t<span class=\"font-weight-bold\">\r\n\t\t\t\t{{'nota' | traduzione}}:\r\n\t\t\t</span>\r\n\t\t\t<span class=\"ml-2\">{{file.nota}}</span>\r\n\t\t</div>\r\n\r\n\t</mat-expansion-panel>\r\n</mat-accordion>\r\n",
                encapsulation: ViewEncapsulation.None,
                styles: ["lib-tabella-documenti .mat-accordion .mat-header-row{background-color:#0a2644!important;border-bottom:none;padding-left:1.5rem;padding-right:2rem}lib-tabella-documenti .mat-expansion-panel-header.mat-row{border-bottom:none;margin-top:2px}lib-tabella-documenti .mat-table{display:block}lib-tabella-documenti .mat-header-row{min-height:56px}lib-tabella-documenti .mat-row{min-height:48px}lib-tabella-documenti .mat-header-row,lib-tabella-documenti .mat-row{align-items:center;border-bottom-style:solid;border-bottom-width:1px;box-sizing:border-box;display:flex;padding:0 24px}lib-tabella-documenti .mat-header-row:after,lib-tabella-documenti .mat-row:after{content:\"\";display:inline-block;min-height:inherit}lib-tabella-documenti .mat-cell,lib-tabella-documenti .mat-header-cell{flex:1;overflow:hidden;word-wrap:break-word}lib-tabella-documenti .mat-row{min-height:120px}lib-tabella-documenti mat-checkbox label{margin-bottom:.25rem!important}"]
            },] }
];
TabellaDocumentiComponent.ctorParameters = () => [];
TabellaDocumentiComponent.propDecorators = {
    files$: [{ type: Input }],
    indiceSelezionato: [{ type: Output }]
};

class AltriSoggettiGiudiziarioDTO {
}

class AltriSoggettiNoEsproprioDTO {
}

class AltriSoggettiComponent {
    constructor(delegheService, modals, msg) {
        this.delegheService = delegheService;
        this.modals = modals;
        this.msg = msg;
        this.nextStep = new EventEmitter();
        this.salvaBozza = new EventEmitter();
        this.previousStep = new EventEmitter();
        //TODO
        // changesPF$ = new Subject<
        // 	ComponentOutputStatus<(value: AltriSoggettiGiudiziarioDTO) => void>
        // >();
        //TODO
        // changesPF2$ = new Subject<
        // 	ComponentOutputStatus<(value: AltriSoggettiNoEsproprioDTO) => void>
        // >();
        this.changesRicercaPG$ = new Subject();
        this.changesRicercaPF$ = new Subject();
        this.changesPersonaGiuridica$ = new Subject();
        this.changesPersonaFisica$ = new Subject();
        this.direction = "both-ways";
        this.isFinal = false;
        this.showComponentRicercaPF = false;
        this.showComponentRicercaPG = false;
        this.isSearching = false;
    }
    ngOnInit() {
        //console.log('[AltriSoggettiGiudiziarioDTO - AltriSoggettiNoEsproprioDTO]', this.altriSoggetti);
        this.form = new FormGroup({});
        let valid = true;
        this.nspg = "nsRapprLegpg";
        if (!this.altriSoggetti) {
            this.initAltriSoggetti();
            valid = false;
        }
        else {
            if (this.formControlSoggetto) {
                this.personaGiuridica = this.altriSoggetti.personaGiuridica;
                if (this.personaGiuridica) {
                    this.showComponentRicercaPG = true;
                }
                this.personaFisica = this.altriSoggetti.personaFisica;
                if (this.personaFisica) {
                    this.showComponentRicercaPF = true;
                }
                if (this.altriSoggetti.codiceTipoAltroSoggetto === 'SOGGETTO_DA_IDENTIFICARE') {
                    this.altriSoggetti.codiceRegione = '';
                }
            }
            else {
                if (!(this.altriSoggetti.soggettoNonIdentificato)) {
                    this.personaFisica = this.mapperPersonaFisica(this.altriSoggetti);
                }
            }
        }
        this.tipoSoggetto = new FormControl({ value: this.altriSoggetti.codiceTipoAltroSoggetto, disabled: false }, [Validators.required]);
        this.form.addControl('tipoSoggetto', this.tipoSoggetto);
        this.soggettoNonIdentificato = new FormControl({ value: this.altriSoggetti.soggettoNonIdentificato, disabled: false });
        this.form.addControl('soggettoNonIdentificato', this.soggettoNonIdentificato);
        this.namespaceInfoPf = this.namespace + "infoPF";
        if (!this.formControlSoggetto) {
            if (this.altriSoggetti.soggettoNonIdentificato) {
                this.showComponentRicercaPF = false;
            }
            else {
                this.showComponentRicercaPF = true;
            }
        }
        this.checkSoggetto$ = this.soggettoNonIdentificato.valueChanges.pipe(
        // tap(checkSoggetto => console.log('[checkSoggetto$] - soggettoNonIdentificato:', checkSoggetto)),
        tap((checkSoggetto) => {
            if (!checkSoggetto) {
                this.showComponentRicercaPF = true;
                this.isSearching = false;
            }
            else {
                this.resetSoggetti();
                this.showComponentRicercaPF = false;
                this.isSearching = false;
            }
        }), shareReplay());
        const changesCheckSoggetto$ = this.checkSoggetto$.pipe(
        // tap(checkSoggetto => console.log('[changesCheckSoggetto$] - soggettoNonIdentificato:', checkSoggetto)),
        map((checkSoggetto) => {
            this.changesPersonaFisica$.next(ComponentOutputStatus.of(true, (personaFisica) => (sogg) => { }));
            return ComponentOutputStatus.of(true, (soggetto) => (soggetto.soggettoNonIdentificato = checkSoggetto));
        }));
        this.tipoSoggetto$ = this.tipoSoggetto.valueChanges.pipe(
        // tap(tipo => console.log('[tipoSoggetto$] - codiceSoggetto:', tipo)),
        tap((tipo) => {
            if (tipo != 'SOGGETTO_DA_IDENTIFICARE') {
                this.setSoggetto(tipo);
                this.isSearching = false;
            }
            else {
                this.resetSoggetti();
                this.showComponentRicercaPF = false;
                this.showComponentRicercaPG = false;
                this.isSearching = false;
                this.resetValidation();
            }
        }), shareReplay());
        const tipoSoggettoChanges$ = this.tipoSoggetto$.pipe(
        // tap(tipoSoggettoChanges => console.log('[tipoSoggettoChanges$] - codiceTipoAltroSoggetto:', tipoSoggettoChanges)),
        map((tipo) => {
            return ComponentOutputStatus.of(this.tipoSoggetto.valid, (sog) => (sog.codiceTipoAltroSoggetto = tipo));
        }));
        const altriSoggetti$ = ComponentReducer.reducer4(tipoSoggettoChanges$, changesCheckSoggetto$, 
        // TODO
        // this.changesRicercaPF$,
        this.changesPersonaFisica$, 
        // this.changesRicercaPG$,
        // TODO
        this.changesPersonaGiuridica$, (soggetto) => {
            let isValid;
            // console.log('[codiceTipoAltroSoggetto]', (<AltriSoggettiNoEsproprioDTO>soggetto).codiceTipoAltroSoggetto);
            // console.log('[soggettoNonIdentificato]', (<AltriSoggettiGiudiziarioDTO>soggetto).soggettoNonIdentificato);
            if (this.formControlSoggetto) {
                switch (soggetto.codiceTipoAltroSoggetto) {
                    case 'PRESUNTO_BENEFICIARIO':
                        // isValid = (<AltriSoggettiNoEsproprioDTO>soggetto).idPersona != null && this.tipoSoggetto.value;
                        isValid = soggetto.idPersona != null && this.tipoSoggetto.value;
                        break;
                    case 'AUTORITA_ORDINANTE':
                        // isValid = (<AltriSoggettiNoEsproprioDTO>soggetto).idPersona != null && this.tipoSoggetto.value;
                        isValid = soggetto.idPersona != null && this.tipoSoggetto.value;
                        break;
                    default:
                        isValid = true;
                }
            }
            else {
                soggetto.soggettoNonIdentificato ?
                    // isValid = true : isValid = (<AltriSoggettiGiudiziarioDTO>soggetto).idPersona != null
                    isValid = true : isValid = soggetto.idPersona != null;
            }
            // console.log('[idPersona]', (<AltriSoggettiNoEsproprioDTO>soggetto).idPersona)
            // console.log('[idPersona]', (<AltriSoggettiGiudiziarioDTO>soggetto).idPersona)
            return isValid;
        }, ComponentOutputStatus.of(valid, this.altriSoggetti));
        altriSoggetti$.subscribe((soggetto) => {
            // console.log('[AltriSoggettiComponent] altriSoggetti', soggetto);
            this.altriSoggetti = soggetto.output;
            this.altriSoggetti.idPersona = soggetto.output.idPersona;
            this.isFormValid = soggetto.status;
        });
    }
    resetValidation() {
        this.changesPersonaFisica$.next(ComponentOutputStatus.of(true, (personaFisica) => (sogg) => { }));
        this.changesPersonaGiuridica$.next(ComponentOutputStatus.of(true, (personaGiuridica) => (sogg) => { }));
    }
    initAltriSoggetti() {
        if (this.formControlSoggetto) {
            this.altriSoggetti = new AltriSoggettiNoEsproprioDTO();
        }
        else {
            this.altriSoggetti = new AltriSoggettiGiudiziarioDTO();
        }
    }
    // TODO
    viewPersona() {
        if (this.formControlSoggetto) {
            return !this.tipoSoggetto.value ||
                this.tipoSoggetto.value === "SOGGETTO_DA_IDENTIFICARE";
        }
        else {
            let showComponent;
            this.checkSoggetto$.subscribe(_ => {
                // console.log('[checkSoggetto]', _);
                showComponent = _.valueOf();
            });
            return showComponent;
        }
    }
    setSoggetto(tipo) {
        // console.log('[setDelega]', delega);
        // console.log('[isPersonaFisica]', this.isPersonaFisica(this.rappresentanza.codiceDelega))
        // console.log('[isPersonaGiuridica]', this.isPersonaGiuridica(this.rappresentanza.codiceDelega))
        // console.log('[codiceDelega]', this.rappresentanza.codiceDelega);
        this.resetSoggetti();
        if (this.isPersonaFisica(tipo)) {
            this.showComponentRicercaPF = true;
            this.showComponentRicercaPG = false;
        }
        if (this.isPersonaGiuridica(tipo)) {
            this.showComponentRicercaPF = false;
            this.showComponentRicercaPG = true;
        }
    }
    resetSoggetti() {
        if (!this.altriSoggetti) {
            this.initAltriSoggetti();
        }
        if (this.formControlSoggetto) {
            this.altriSoggetti.personaGiuridica = null;
            this.personaGiuridica = null;
            this.altriSoggetti.codiceRegione = '';
        }
        else {
            this.altriSoggetti.soggettoNonIdentificato = this.soggettoNonIdentificato.value;
            this.altriSoggetti.cognome = null;
            this.altriSoggetti.nome = null;
            this.altriSoggetti.codFiscale = null;
            this.altriSoggetti.comuneNascita = null;
            this.altriSoggetti.provinciaNascita = null;
            this.altriSoggetti.dataNascita = null;
        }
        this.altriSoggetti.idPersona = null;
        this.altriSoggetti.personaFisica = null;
        this.personaFisica = null;
    }
    isPersonaFisica(codiceSoggetto) {
        return (codiceSoggetto === "PRESUNTO_BENEFICIARIO");
    }
    isPersonaGiuridica(codiceSoggetto) {
        return (codiceSoggetto === 'AUTORITA_ORDINANTE');
    }
    ricercaPFReady(ricercaPFStatus) {
        // console.log('[ricercaPFReady]', ricercaPFStatus);
        this.changesRicercaPF$.next(ricercaPFStatus.mapValue((infoPF) => (sogg) => {
            this.getPersonaFisica(infoPF.id);
            if (!this.formControlSoggetto) {
                sogg.soggettoNonIdentificato = false;
            }
            sogg.idPersona = infoPF.id;
        }));
    }
    personaFisicaReady(personaFisicaStatus) {
        //console.log('[personaFisicaReady]', personaFisicaStatus);
        this.changesPersonaFisica$.next(personaFisicaStatus.mapValue((personaFisica) => (sogg) => {
            var _a, _b, _c, _d, _e, _f;
            const pf = new PersonaFisicaDTO();
            pf.infoAnagrafiche = personaFisica.infoAnagrafiche;
            pf.infoNascita = personaFisica.infoNascita;
            pf.id = personaFisica.id;
            if (personaFisica.id) {
                sogg.idPersona = personaFisica.id;
            }
            sogg.personaFisica = pf;
            if (!this.formControlSoggetto) {
                this.soggettoNonIdentificato.value ?
                    sogg.soggettoNonIdentificato = this.soggettoNonIdentificato.value :
                    sogg.soggettoNonIdentificato = false;
                sogg.cognome = (_a = personaFisica === null || personaFisica === void 0 ? void 0 : personaFisica.infoAnagrafiche) === null || _a === void 0 ? void 0 : _a.cognome;
                sogg.nome = (_b = personaFisica === null || personaFisica === void 0 ? void 0 : personaFisica.infoAnagrafiche) === null || _b === void 0 ? void 0 : _b.nome;
                sogg.codFiscale = (_c = personaFisica === null || personaFisica === void 0 ? void 0 : personaFisica.infoAnagrafiche) === null || _c === void 0 ? void 0 : _c.codFiscale;
                sogg.comuneNascita = (_d = personaFisica === null || personaFisica === void 0 ? void 0 : personaFisica.infoNascita) === null || _d === void 0 ? void 0 : _d.comuneNascita;
                sogg.provinciaNascita = (_e = personaFisica === null || personaFisica === void 0 ? void 0 : personaFisica.infoNascita) === null || _e === void 0 ? void 0 : _e.provinciaNascita;
                //TODO
                // (<AltriSoggettiGiudiziarioDTO>sogg).dataNascita = new Date(moment(personaFisica?.infoNascita?.dataNascita, "DD/MM/YYYY").toDate());
                // (<AltriSoggettiGiudiziarioDTO>sogg).dataNascita = moment(personaFisica?.infoNascita?.dataNascita, "DD/MM/YYYY").toDate();
                sogg.dataNascita = (_f = personaFisica === null || personaFisica === void 0 ? void 0 : personaFisica.infoNascita) === null || _f === void 0 ? void 0 : _f.dataNascita;
            }
        }));
    }
    ricercaPGReady(ricercaPGStatus) {
        // console.log('[ricercaPGReady]', ricercaPGStatus);
        this.changesRicercaPG$.next(ricercaPGStatus.mapValue((infoPG) => (sogg) => {
            this.getPersonaGiuridica(infoPG.datiPersonaGiuridica.id);
            sogg.idPersona = infoPG.datiPersonaGiuridica.id;
        }));
    }
    personaGiuridicaReady(personaGiuridicaStatus) {
        // console.log("[personaGiuridicaReady]", personaGiuridicaStatus);
        this.changesPersonaGiuridica$.next(personaGiuridicaStatus.mapValue((personaGiuridica) => (sogg) => {
            var _a, _b, _c;
            const pg = new PersonaGiuridicaDTO();
            pg.codiceFiscale = personaGiuridica.codiceFiscale;
            pg.ragioneSociale = personaGiuridica.ragioneSociale;
            pg.partitaIVA = personaGiuridica.partitaIVA;
            pg.idPersonaGiuridica = personaGiuridica.idPersonaGiuridica;
            sogg.idPersona = personaGiuridica.idPersonaGiuridica;
            sogg.personaGiuridica = pg;
            if (personaGiuridica.sedi != undefined) {
                sogg.codiceRegione = (_c = (_b = (_a = personaGiuridica === null || personaGiuridica === void 0 ? void 0 : personaGiuridica.sedi[0]) === null || _a === void 0 ? void 0 : _a.indirizzo) === null || _b === void 0 ? void 0 : _b.regione) === null || _c === void 0 ? void 0 : _c.sigla;
            }
        }));
    }
    getPersonaFisica(id) {
        this.showComponentRicercaPF = false;
        //debugger
        this.personaFisica$ = this.delegheService.getPersona(id)
            .pipe(shareReplay());
        this.pfSubscription = this.personaFisica$.pipe(
        // pluck("datiPersonaFisica")
        ).subscribe(
        // (pf: DatiPersonaFisica) => {
        (pf) => {
            var _a, _b;
            //console.log('[pf]', pf);
            this.personaFisica = this.mapperPersonaFisica(pf.datiPersonaFisica);
            // this.personaFisica = pf;
            this.altriSoggetti.codiceRegione = (_b = (_a = pf === null || pf === void 0 ? void 0 : pf.residenza) === null || _a === void 0 ? void 0 : _a.regione) === null || _b === void 0 ? void 0 : _b.sigla;
            //(<AltriSoggettiGiudiziarioDTO>this.altriSoggetti).personaFisica = this.personaFisica;
            this.altriSoggetti.idPersona = id;
            // this.showComponentRicercaPF = true;
            if (this.personaFisica) {
                setTimeout(() => this.showComponentRicercaPF = true, 0);
            }
            this.isSearching = true;
        }, _ => {
            this.modals.failure([
                "recupero.datipersonafisica.failure"
            ], []);
        });
    }
    getPersonaGiuridica(id) {
        this.personaGiuridica$ = this.delegheService.getDatiSocieta(id)
            .pipe(shareReplay());
        this.pgSubscription = this.personaGiuridica$.pipe(
        // pluck("datiPersonaGiuridica")
        ).subscribe((pg) => {
            // console.log('[pg]', pg);
            this.mapperPersonaGiuridica(pg);
            this.personaGiuridica = pg;
            // (<AltriSoggettiNoEsproprioDTO>this.altriSoggetti).idPersona = id;
            this.altriSoggetti.idPersona = id;
            this.showComponentRicercaPG = false;
            this.isSearching = true;
            if (pg.sedi != undefined) {
                const sede = pg.sedi.filter(sedeLegale => sedeLegale.tipoSede.codice === "LEGALE");
                this.altriSoggetti.codiceRegione = sede[0].indirizzo.regione.sigla;
            }
        }, _ => {
            this.modals.failure([
                "recupero.datipersonagiuridica.failure"
            ], []);
        });
    }
    mapperPersonaFisica(datiPersona) {
        //console.log('[mapperPersonaFisica]- datiPersona', datiPersona);
        const personaFisica = new PersonaFisicaDTO();
        const infoAnagrafiche = new InfoAnagrafichePFDTO();
        infoAnagrafiche.codFiscale = datiPersona.codFiscale;
        infoAnagrafiche.cognome = datiPersona.cognome;
        infoAnagrafiche.nome = datiPersona.nome;
        personaFisica.infoAnagrafiche = infoAnagrafiche;
        personaFisica.id = datiPersona.idPersona;
        const infoNascita = new InfoNascitaPFDTO();
        infoNascita.comuneNascita = datiPersona.comuneNascita;
        infoNascita.provinciaNascita = datiPersona.provinciaNascita;
        infoNascita.dataNascita = datiPersona.dataNascita;
        personaFisica.infoNascita = infoNascita;
        this.altriSoggetti.personaFisica = personaFisica;
        //console.log('[mapperPersonaFisica]- personaFisica', personaFisica);
        //console.log('[mapperPersonaFisica]- altriSoggetti', this.altriSoggetti.personaFisica);
        setTimeout(() => this.showComponentRicercaPF = true, 0);
        return personaFisica;
    }
    mapperPersonaGiuridica(datiPersona) {
        // console.log('[mapperPersonaGiuridica]', datiPersona);
        if (!this.altriSoggetti) {
            this.initAltriSoggetti();
        }
        const personaGiuridica = new PersonaGiuridicaDTO();
        personaGiuridica.codiceFiscale = datiPersona.datiPersonaGiuridica.codiceFiscale;
        personaGiuridica.ragioneSociale = datiPersona.datiPersonaGiuridica.ragioneSociale;
        personaGiuridica.partitaIVA = datiPersona.datiPersonaGiuridica.partitaIVA;
        this.altriSoggetti.personaGiuridica = personaGiuridica;
    }
    enableSearch() {
        this.resetSoggetti();
        // console.log('[enableSearch] - codiceSoggetto:', (<AltriSoggettiNoEsproprioDTO>this.altriSoggetti).codiceTipoAltroSoggetto);
        // console.log('[enableSearch] - soggettoNonIdentificato:', (<AltriSoggettiGiudiziarioDTO>this.altriSoggetti).soggettoNonIdentificato);
        if (this.altriSoggetti.codiceTipoAltroSoggetto) {
            this.tipoSoggetto.setValue(this.altriSoggetti.codiceTipoAltroSoggetto);
            if (this.isPersonaFisica(this.altriSoggetti.codiceTipoAltroSoggetto)) {
                setTimeout(() => this.showComponentRicercaPF = true, 0);
            }
            if (this.isPersonaGiuridica(this.altriSoggetti.codiceTipoAltroSoggetto)) {
                setTimeout(() => this.showComponentRicercaPG = true, 0);
            }
        }
        else {
            this.soggettoNonIdentificato.setValue(this.altriSoggetti.soggettoNonIdentificato);
            setTimeout(() => this.showComponentRicercaPF = true, 0);
        }
    }
    forward(_) {
        this.nextStep.emit(this.altriSoggetti);
    }
    backward($event) {
        this.previousStep.emit(this.altriSoggetti);
    }
    complete($event) { }
    onSalvaBozza($event) {
        this.salvaBozza.emit(this.altriSoggetti);
    }
    ngOnDestroy() {
        if (this.altriSoggettiChangedSub) {
            this.altriSoggettiChangedSub.unsubscribe();
        }
    }
}
AltriSoggettiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-altri-soggetti',
                template: "<!-- <p>altri-soggetti works!</p> -->\r\n<div class=\"mt-3 mb-5\">\r\n\t<mat-expansion-panel class=\"panel\" [expanded]=\"true\">\r\n\t\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\r\n\t\t\t<mat-panel-title>\r\n\t\t\t\t<!-- <h3>{{'altri-soggetti' | traduzione}}</h3> -->\r\n\r\n\t\t\t\t<div *ngIf=\"!formControlSoggetto\">\r\n\t\t\t\t\t<h3 class=\"h5 mb-0\"><info-tip-label label=\"altri-soggetti\"></info-tip-label></h3>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div *ngIf=\"formControlSoggetto\">\r\n\t\t\t\t\t<h3 class=\"h5 mb-0\"><info-tip-label label=\"altri-soggetti-interessati\"></info-tip-label></h3>\r\n\t\t\t\t</div>\r\n\t\t\t</mat-panel-title>\r\n\t\t</mat-expansion-panel-header>\r\n\t\t<form [formGroup]=\"form\">\r\n\t\t\t<div class=\"collapse-body mt-2\">\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<div *ngIf=\"formControlSoggetto\" class=\"col-md-4\">\r\n\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t<mat-label>{{'required'| traduzione}}{{'soggetto' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t\t<mat-select placeholder=\"{{'seleziona' | traduzione}}\" formControlName=\"tipoSoggetto\">\r\n\t\t\t\t\t\t\t\t<mat-option *ngFor=\"let soggetto of tipologieSoggetto$ | async\"\r\n\t\t\t\t\t\t\t\t\t[value]=\"soggetto.codice\">\r\n\t\t\t\t\t\t\t\t\t{{soggetto.descrizione}}\r\n\t\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t\t<mat-error *ngIf=\"form.controls['tipoSoggetto'].invalid\">\r\n\t\t\t\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['tipoSoggetto']) | traduzione}}\r\n\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t\t<mat-hint *infoTip=\"'soggetto'\"></mat-hint>\r\n\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div *ngIf=\"!formControlSoggetto\" class=\"col-md-4\">\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<mat-checkbox\r\n\t\t\t\t\t\t\t\tformControlName=\"soggettoNonIdentificato\">\r\n\t\t\t\t\t\t\t\t{{'soggetto-non-identificato' | traduzione }}\r\n\t\t\t\t\t\t\t</mat-checkbox>\r\n\t\t\t\t\t\t\t<mat-hint *infoTip=\"'soggetto-non-identificato'\"></mat-hint>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"col-md-8\">\r\n\t\t\t\t\t\t<button\r\n\t\t\t\t\t\t\t*ngIf=\"isSearching && !showComponentRicercaPF && !showComponentRicercaPG\"\r\n\t\t\t\t\t\t\tmat-flat-button color=\"primary\"\r\n\t\t\t\t\t\t\tclass=\"text-uppercase mb-2\"\r\n\t\t\t\t\t\t\t(click)=\"enableSearch()\"\r\n\t\t\t\t\t\t\t> {{'ricerca' | traduzione}}\r\n\t\t\t\t\t\t</button>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<!-- TODO -->\r\n\t\t\t\t<!-- <lib-info-pf *ngIf=\"!viewPersona() \" -->\r\n\t\t\t\t<!-- <lib-info-pf *ngIf=\"!(checkSoggetto$ | async)\" -->\r\n\t\t\t\t<!-- <lib-info-pf *ngIf=\"!viewPersona()\"\r\n\t\t\t\t\t[cfDifferentFrom]=\"cfDifferentFrom\"\r\n\t\t\t\t\t[namespace]=\"namespaceInfoPf\"\r\n\t\t\t\t\t(done)=\"infoPfReady2($event)\"\r\n\t\t\t\t\t[infopf]=\"altriSoggetti\"\r\n\t\t\t\t\t[readOnly]=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t</lib-info-pf> -->\r\n\t\t\t\t<div class=\"mt-4\"></div>\r\n\t\t\t\t<!-- <lib-ricerca-pf\r\n\t\t\t\t\t*ngIf=\"showComponentRicercaPF\"\r\n\t\t\t\t\t[namespace]=\"namespaceInfoPf\"\r\n\t\t\t\t\t[readOnly]=\"false\"\r\n\t\t\t\t\t(done)=\"ricercaPFReady($event)\"\r\n\t\t\t\t>\r\n\t\t\t\t</lib-ricerca-pf>\r\n\t\t\t\t<lib-info-pf\r\n\t\t\t\t\t*ngIf=\"personaFisica\"\r\n\t\t\t\t\t[cfDifferentFrom]=\"cfDifferentFrom\"\r\n\t\t\t\t\t[namespace]=\"namespaceInfoPf\"\r\n\t\t\t\t\t[infopf]=\"altriSoggetti?.personaFisica?.infoAnagrafiche\"\r\n\t\t\t\t\t[readOnly]=\"true\"\r\n\t\t\t\t\t[validatorFormControl]=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t</lib-info-pf> -->\r\n\t\t\t\t<lib-persona-fisica\r\n\t\t\t\t\t*ngIf=\"showComponentRicercaPF\"\r\n\t\t\t\t\t(done)=\"personaFisicaReady($event)\"\r\n\t\t\t\t\t[nazioni]=\"nazioni\"\r\n\t\t\t\t\t[province]=\"province\"\r\n\t\t\t\t\t[namespace]=\"namespaceInfoPf\"\r\n\t\t\t\t\t[infoPersonaFisica]=\"altriSoggetti?.personaFisica\"\r\n\t\t\t\t\t[idDelega]=\"null\"\r\n\t\t\t\t\t[validatorFormControl]=\"true\"\r\n\t\t\t\t>\r\n\t\t\t\t</lib-persona-fisica>\r\n\t\t\t\t<!-- <lib-ricerca-pg\r\n\t\t\t\t\t*ngIf=\"showComponentRicercaPG\"\r\n\t\t\t\t\t[namespace]=\"nspg\"\r\n\t\t\t\t\t[readOnly]=\"false\"\r\n\t\t\t\t\t(done)=\"ricercaPGReady($event)\"\r\n\t\t\t\t>\r\n\t\t\t\t</lib-ricerca-pg>\r\n\t\t\t\t<lib-persona-giuridica\r\n\t\t\t\t\t*ngIf=\"personaGiuridica\"\r\n\t\t\t\t\t[namespace]=\"nspg\"\r\n\t\t\t\t\t[datisocieta]=\"altriSoggetti?.personaGiuridica\"\r\n\t\t\t\t\t[idDelega]=\"altriSoggetti.idPersona\"\r\n\t\t\t\t\t[validatorFormControl]=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t</lib-persona-giuridica> -->\r\n\t\t\t\t<!-- TODO -->\r\n\t\t\t\t<lib-persona-giuridica\r\n\t\t\t\t\t*ngIf=\"showComponentRicercaPG\"\r\n\t\t\t\t\t(done)=\"personaGiuridicaReady($event)\"\r\n\t\t\t\t\t[namespace]=\"nspg\"\r\n\t\t\t\t\t[datisocieta]=\"altriSoggetti?.personaGiuridica\"\r\n\t\t\t\t\t[idDelega]=\"null\"\r\n\t\t\t\t\t[validatorFormControl]=\"false\"\r\n\t\t\t\t\t[gestioneSedi]=\"false\"\r\n\t\t\t\t\t[couldBeDittaIndividuale]=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t</lib-persona-giuridica>\r\n\t\t\t</div>\r\n\t\t</form>\r\n\t</mat-expansion-panel>\r\n\t<div class=\"mt-4\"></div>\r\n\t<lib-stepper-navigator\r\n\t\t[form]=\"form\"\r\n\t\t[direction]=\"direction\"\r\n\t\t[isFinal]=\"isFinal\"\r\n\t\t[isContainerValid]=\"isFormValid\"\r\n\t\t(goForward)=\"forward($event)\"\r\n\t\t(goBackward)=\"backward($event)\"\r\n\t\t(salvaBozza)=\"onSalvaBozza($event)\"\r\n\t\t(complete)=\"complete($event)\"\r\n\t>\r\n\t</lib-stepper-navigator>\r\n</div>\r\n",
                styles: [""]
            },] }
];
AltriSoggettiComponent.ctorParameters = () => [
    { type: DelegheService },
    { type: Modals },
    { type: MessageService }
];
AltriSoggettiComponent.propDecorators = {
    altriSoggetti: [{ type: Input }],
    tipologieSoggetto$: [{ type: Input }],
    cfDifferentFrom: [{ type: Input }],
    namespace: [{ type: Input }],
    formControlSoggetto: [{ type: Input }],
    province: [{ type: Input }],
    nazioni: [{ type: Input }],
    nextStep: [{ type: Output }],
    salvaBozza: [{ type: Output }],
    previousStep: [{ type: Output }]
};

class StepperNavigatorComponent {
    constructor() {
        this.complete = new EventEmitter();
        this.goBackward = new EventEmitter();
        this.goForward = new EventEmitter();
        this.salvaBozza = new EventEmitter();
    }
    ngOnInit() {
        // console.log("isContainerValid", this.isContainerValid);
    }
    canGoForWard() {
        let forward = false;
        if (this.direction === 'only-forward' || this.direction === 'both-ways') {
            forward = true;
            ;
        }
        return forward;
    }
    canGoBackWard() {
        let backWard = false;
        if (this.direction === 'only-backward' || this.direction === 'both-ways') {
            backWard = true;
            ;
        }
        return backWard;
    }
    canComplete() {
        let complete = false;
        if (this.isFinal && this.isContainerValid) {
            complete = true;
        }
        return complete;
    }
    onComplete() {
        this.complete.emit();
    }
    onForward() {
        this.goForward.emit();
    }
    onBackward() {
        this.goBackward.emit();
    }
    onSalvaBozza() {
        this.salvaBozza.emit();
    }
}
StepperNavigatorComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-stepper-navigator',
                template: "<div class=\"row mt-4\">\r\n<div class=\"col-6\">\r\n\t<button *ngIf=\"canGoBackWard()\" mat-stroked-button (click)=\"onBackward()\" color=\"primary\">\r\n\t\t{{'indietro' | traduzione }}\r\n\t</button>\r\n</div>\r\n<div class=\"col-6 text-right\">\r\n\t<button class=\"ml-2\" *ngIf=\"isContainerValid\" mat-raised-button (click)=\"onSalvaBozza()\" color=\"primary\">\r\n\t\t{{ 'salva-bozza' | traduzione }}\r\n\t</button>\r\n\t<button class=\"ml-2\" *ngIf=\"canGoForWard() && isContainerValid\" mat-raised-button (click)=\"onForward()\"\r\n\t\tcolor=\"primary\">\r\n\t\t{{'avanti' | traduzione }}\r\n\t</button>\r\n\t<button class=\"ml-2\" *ngIf=\"canComplete()\" mat-raised-button color=\"primary\" (click)=\"onComplete()\">\r\n\t\t{{'invia' | traduzione }}\r\n\t</button>\r\n\t</div>\r\n</div>",
                styles: [""]
            },] }
];
StepperNavigatorComponent.ctorParameters = () => [];
StepperNavigatorComponent.propDecorators = {
    direction: [{ type: Input }],
    isFinal: [{ type: Input }],
    form: [{ type: Input }],
    isContainerValid: [{ type: Input }],
    complete: [{ type: Output }],
    goBackward: [{ type: Output }],
    goForward: [{ type: Output }],
    salvaBozza: [{ type: Output }]
};

class RicercaPfComponent {
    constructor(delegheService) {
        this.delegheService = delegheService;
        this.done = new EventEmitter();
        this.resetForm = new Subject();
        this.codiceFiscale = "";
        this.cognome = "";
        this.nome = "";
        this.offset = 0;
        this.pageNumber = 0;
        this.pageSize = 5;
        this.paged = true;
        this.viewIntPf = false;
        this.viewResultTable = false;
        this.resLenPf = 0;
        this.validationFormPF = false;
        this.displayedColumns = [
            'codiceFiscale',
            'nome',
            'cognome',
            'seleziona'
        ];
    }
    ngOnInit() {
    }
    infoPfReady(inFoPfStatus) {
        // console.log('[infoPfReady]', inFoPfStatus);
        this.validationFormPF = inFoPfStatus.status;
        if (inFoPfStatus.output.codFiscale != undefined) {
            this.codiceFiscale = inFoPfStatus === null || inFoPfStatus === void 0 ? void 0 : inFoPfStatus.output.codFiscale.toUpperCase().trim();
        }
        if (inFoPfStatus.output.cognome != undefined) {
            this.cognome = inFoPfStatus === null || inFoPfStatus === void 0 ? void 0 : inFoPfStatus.output.cognome.toUpperCase().trim();
        }
        if (inFoPfStatus.output.nome != undefined) {
            this.nome = inFoPfStatus === null || inFoPfStatus === void 0 ? void 0 : inFoPfStatus.output.nome.toUpperCase().trim();
        }
    }
    getListaPf() {
        this.listaPf = '';
        this.dataSource = new MatTableDataSource(this.listaPf);
        const pf = new PersonaFisicaBaseDTO();
        pf.codiceFiscale = this.codiceFiscale;
        pf.cognome = this.cognome;
        pf.nome = this.nome;
        // this.delegheService.getListaPfPaged(this.pageSize, this.pageNumber, pf);
        if (pf.codiceFiscale != "" && pf.cognome == "" && pf.nome == "") {
            console.log("[Ricerca Anagrafe Tributaria]");
            this.delegheService.getPersonaFiscaleCodiceFiscale(pf.codiceFiscale).pipe(
            // pluck("datiPersonaFisica")
            )
                .subscribe((res) => {
                console.log('[pg]', res);
                this.listaPf = res;
                console.log('[listaPf]', this.listaPf);
                if (this.listaPf) {
                    this.showNoResults = false;
                    this.viewIntPf = true;
                    this.viewResultTable = true;
                    // this.dataSource = new MatTableDataSource(this.listaPg['content']);
                    this.dataSource = new MatTableDataSource([this.listaPf]);
                    // this.dataSource = new MatTableDataSource([res]);
                    // this.dataSource.paginator = this.paginator;
                    // this.resLenPg = res['content'].length;
                    this.resLenPf = 1;
                }
                else {
                    this.showNoResults = true;
                    this.viewIntPf = false;
                    this.viewResultTable = false;
                    this.resLenPf = 0;
                }
            }, err => {
                // console.log('[errore - getListaPfPaged]', err);
                this.showNoResults = true;
                this.viewIntPf = false;
                this.viewResultTable = false;
                this.resLenPf = 0;
            });
        }
        else {
            console.log("[Ricerca Sul Portale]");
            this.personaFisica$ = this.delegheService.getListaPfPaged(this.pageSize, this.pageNumber, pf)
                .pipe(shareReplay());
            this.pfSubscription = this.personaFisica$.pipe(
            // pluck("datiPersonaFisica")
            ).subscribe((res) => {
                console.log('[pf]', res);
                this.listaPf = res;
                if (this.listaPf) {
                    this.showNoResults = false;
                    this.viewIntPf = true;
                    this.viewResultTable = true;
                    this.dataSource = new MatTableDataSource(this.listaPf['content']);
                    this.dataSource.paginator = this.paginator;
                    this.resLenPf = res['content'].length;
                }
                else {
                    this.viewIntPf = false;
                    this.viewResultTable = false;
                    this.showNoResults = true;
                    this.resLenPf = 0;
                }
            }, err => {
                // console.log('[errore - getListaPfPaged]', err);
                this.viewIntPf = false;
                this.viewResultTable = false;
                this.showNoResults = true;
                this.resLenPf = 0;
            });
        }
    }
    pulisciForm() {
        this.resetForm.next(true);
        this.viewResultTable = false;
        this.dataSource = new MatTableDataSource(null);
        this.viewIntPf = false;
        // console.log('[pulisciForm - resetForm]', this.resetForm);
    }
    areSearchParameterValid() {
        return (this.validationFormPF &&
            (this.codiceFiscale != "" ||
                this.cognome != "" ||
                this.nome != ""));
    }
    personaFisicaSelected(row) {
        // console.log('[PersonaFisica]', row);
        this.done.emit(ComponentOutputStatus.of(true, row.datiPersonaFisica));
    }
}
RicercaPfComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-ricerca-pf',
                template: "<!-- <p>ricerca-pf works!</p> -->\r\n<!-- <div class=\"row\">\r\n\t<div class=\"col-12\">\r\n\t\t<p class=\"h6\"> {{'ricerca-nel-portale-dag' | traduzione}} </p>\r\n\t</div>\r\n</div> -->\r\n<div class=\"row\">\r\n\t<div class=\"col-12\">\r\n\t\t<p class=\"mt-3\">{{'spiegazione' | traduzione }}</p>\r\n\t</div>\r\n</div>\r\n<!-- <lib-info-pf\r\n\t[namespace]=\"namespace\"\r\n\t(done)=\"infoPfReady($event)\"\r\n\t[readOnly]=\"false\"\r\n\t[resetForm]=\"resetForm\"\r\n\t[validatorFormControl]=\"false\"\r\n>\r\n</lib-info-pf> -->\r\n<lib-pf\r\n\t(done)=\"infoPfReady($event)\"\r\n\t[resetForm]=\"resetForm\"\r\n>\r\n</lib-pf>\r\n<div class=\"col-12\">\r\n\t<div class=\"float-right mt-4\">\r\n\t\t<button \r\n\t\t\t(click)=\"pulisciForm();\"\r\n\t\t\tmat-stroked-button color=\"primary\"\r\n\t\t\tclass=\"mr-3\"\r\n\t\t\t[disabled]=\"!areSearchParameterValid()\"\r\n\t\t> {{'pulisci' | traduzione | uppercase}}\r\n\t\t</button>\r\n\t\t<button\r\n\t\t\t(click)=\"getListaPf();\"\r\n\t\t\tmat-flat-button color=\"primary\"\r\n\t\t\t[disabled]=\"!areSearchParameterValid()\"\r\n\t\t> {{'ricerca' | traduzione | uppercase}}\r\n\t\t</button>\r\n\t</div>\r\n</div>\r\n<br>\r\n<br>\r\n<div class=\"col-12\">\r\n\t<ng-container>\r\n\t\t<div class=\"col-md-12 mt-3\">\r\n\t\t\t<div *ngIf=\"showNoResults\">\r\n\t\t\t\t<p>\r\n\t\t\t\t{{'nessuno-risultato' | traduzione}}\r\n\t\t\t\t</p>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<div *ngIf=\"viewIntPf\" class=\"mb-5\">\r\n\t\t\t<div class=\"col-md-12 mt-3\">\r\n\t\t\t\t<mat-chip-list>\r\n\t\t\t\t\t<p class=\"mr-3 mb-0\">{{'totale-risultati' | traduzione }} : {{resLenPf}}</p>\r\n\t\t\t\t</mat-chip-list>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<div [hidden]=\"!viewResultTable\">\r\n\t\t\t<mat-table\r\n\t\t\t\tmat-table\r\n\t\t\t\t[dataSource]=\"dataSource\"\r\n\t\t\t\tclass=\"mat-elevation-z8 mt-3 border\">\r\n\r\n\t\t\t\t<!-- Codice Fiscale Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"codiceFiscale\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'codice-fiscale' | traduzione }} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.datiPersonaFisica.codiceFiscale}} </mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Nome Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"nome\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'nome' | traduzione }} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.datiPersonaFisica.nome}} </mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Cognome Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"cognome\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'cognome' | traduzione }} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.datiPersonaFisica.cognome}} </mat-cell>\r\n\t\t\t\t</ng-container>\r\n\t\t\t\t\r\n\t\t\t\t<!-- Selezione Column -->\r\n\t\t\t\t<ng-container  matColumnDef=\"seleziona\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'seleziona' | traduzione}} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell  *matCellDef=\"let element\"> \r\n\t\t\t\t\t\t<button (click)=\"personaFisicaSelected(element)\" mat-flat-button color=\"primary\">\r\n\t\t\t\t\t\t\t{{'seleziona' | traduzione}}\r\n\t\t\t\t\t\t</button>\r\n\t\t\t\t\t</mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\r\n\t\t\t\t<mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\r\n\r\n\t\t\t</mat-table>\r\n\t\t\t<mat-paginator [pageSizeOptions]=\"[5, 10, 20]\" showFirstLastButtons></mat-paginator>\r\n\t\t</div>\r\n\t</ng-container>\r\n</div>",
                styles: [".mat-paginator{background:#fff}.mat-paginator,.mat-paginator-page-size .mat-select-trigger{color:rgba(0,0,0,.54)}.mat-paginator-decrement,.mat-paginator-increment{border-right:2px solid rgba(0,0,0,.54);border-top:2px solid rgba(0,0,0,.54)}.mat-paginator-first,.mat-paginator-last{border-top:2px solid rgba(0,0,0,.54)}.mat-icon-button[disabled] .mat-paginator-decrement,.mat-icon-button[disabled] .mat-paginator-first,.mat-icon-button[disabled] .mat-paginator-increment,.mat-icon-button[disabled] .mat-paginator-last{border-color:rgba(0,0,0,.38)}"]
            },] }
];
RicercaPfComponent.ctorParameters = () => [
    { type: DelegheService }
];
RicercaPfComponent.propDecorators = {
    namespace: [{ type: Input }],
    readOnly: [{ type: Input }],
    done: [{ type: Output }],
    paginator: [{ type: ViewChild, args: [MatPaginator, { static: true },] }]
};

class RicercaPgComponent {
    constructor(delegheService) {
        this.delegheService = delegheService;
        this.showRagioneSociale = true;
        this.showPartitaIVA = true;
        // @Output()
        // personaGiuridicaSelezionata: EventEmitter<PersonaGiuridica> = new EventEmitter<PersonaGiuridica>();
        this.done = new EventEmitter();
        this.resetForm = new Subject();
        this.codiceFiscale = "";
        this.ragioneSociale = "";
        this.partitaIVA = "";
        this.offset = 0;
        this.pageNumber = 0;
        this.pageSize = 5;
        this.paged = true;
        this.viewIntPg = false;
        this.viewResultTable = false;
        this.resLenPg = 0;
        this.validationFormPG = false;
        this.displayedColumns = [
            'ragioneSociale',
            'pIva',
            'codFiscale',
            'seleziona'
        ];
    }
    ngOnInit() {
    }
    personaGiuridicaReady(pgStatus) {
        var _a, _b;
        // console.log("[personaGiuridicaReady]", pgStatus);
        this.validationFormPG = pgStatus.status;
        if (pgStatus.output.codiceFiscale != undefined) {
            this.codiceFiscale = pgStatus === null || pgStatus === void 0 ? void 0 : pgStatus.output.codiceFiscale.toUpperCase().trim();
        }
        if (((_a = pgStatus.output) === null || _a === void 0 ? void 0 : _a.ragioneSociale) != undefined) {
            this.ragioneSociale = pgStatus === null || pgStatus === void 0 ? void 0 : pgStatus.output.ragioneSociale.toUpperCase().trim();
        }
        if (((_b = pgStatus.output) === null || _b === void 0 ? void 0 : _b.partitaIVA) != undefined) {
            this.partitaIVA = pgStatus === null || pgStatus === void 0 ? void 0 : pgStatus.output.partitaIVA.toUpperCase().trim();
        }
        //TODO
        // this.changesPersonaGiuridica$.next(
        // 	pgStatus.mapValue(pg => (rap: LegaleRappresentanteDTO) => rap.datiSocieta = pg)
        // );
    }
    getListaPg() {
        this.listaPg = '';
        this.dataSource = new MatTableDataSource(this.listaPg);
        const pg = new PersonaGiuridicaDTO();
        pg.codiceFiscale = this.codiceFiscale;
        pg.ragioneSociale = this.ragioneSociale;
        pg.partitaIVA = this.partitaIVA;
        if (pg.codiceFiscale != "" && pg.partitaIVA == "" && pg.ragioneSociale == "") {
            console.log("[Ricerca Anagrafe Tributaria]");
            this.delegheService.getPersonaGiuridicaCodiceFiscale(pg.codiceFiscale).pipe(
            // pluck("datiPersonaGiuridica")
            )
                .subscribe((res) => {
                console.log('[pg]', res);
                this.listaPg = res;
                // console.log('[listaPg]', this.listaPg);
                if (this.listaPg) {
                    this.showNoResults = false;
                    this.viewIntPg = true;
                    this.viewResultTable = true;
                    // this.dataSource = new MatTableDataSource(this.listaPg['content']);
                    this.dataSource = new MatTableDataSource([this.listaPg]);
                    // this.dataSource = new MatTableDataSource([res]);
                    // this.dataSource.paginator = this.paginator;
                    // this.resLenPg = res['content'].length;
                    this.resLenPg = 1;
                }
                else {
                    this.showNoResults = true;
                    this.viewIntPg = false;
                    this.viewResultTable = false;
                    this.resLenPg = 0;
                }
            }, err => {
                // console.log('[errore - getListaPfPaged]', err);
                this.showNoResults = true;
                this.viewIntPg = false;
                this.viewResultTable = false;
                this.resLenPg = 0;
            });
        }
        else {
            console.log("[Ricerca Sul Portale]");
            this.delegheService.getListaPgPaged(this.pageSize, this.pageNumber, pg).subscribe((res) => {
                console.log('[pg]', res);
                this.listaPg = res;
                // console.log('[listaPg]', this.listaPg);
                if (this.listaPg) {
                    this.showNoResults = false;
                    this.viewIntPg = true;
                    this.viewResultTable = true;
                    this.dataSource = new MatTableDataSource(this.listaPg['content']);
                    this.dataSource.paginator = this.paginator;
                    this.resLenPg = res['content'].length;
                }
                else {
                    this.showNoResults = true;
                    this.viewIntPg = false;
                    this.viewResultTable = false;
                    this.resLenPg = 0;
                }
            }, err => {
                // console.log('[errore - getListaPfPaged]', err);
                this.showNoResults = true;
                this.viewIntPg = false;
                this.viewResultTable = false;
                this.resLenPg = 0;
            });
        }
    }
    pulisciForm() {
        this.resetForm.next(true);
        this.viewResultTable = false;
        this.dataSource = new MatTableDataSource(null);
        this.viewIntPg = false;
        // console.log('[pulisciForm - resetForm]', this.resetForm);
    }
    areSearchParameterValid() {
        return (this.validationFormPG &&
            (this.codiceFiscale != "" ||
                this.ragioneSociale != "" ||
                this.partitaIVA != ""));
    }
    personaGiuridicaSelected(row) {
        // console.log('[PersonaGiuridica]', row);
        this.done.emit(ComponentOutputStatus.of(true, row));
    }
}
RicercaPgComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-ricerca-pg',
                template: "<!-- <p>ricerca-pg works!</p> -->\r\n<!-- <div class=\"row\">\r\n\t<div class=\"col-12\">\r\n\t\t<p class=\"h6\"> {{'ricerca-nel-portale-dag' | traduzione}} </p>\r\n\t</div>\r\n</div> -->\r\n<!-- <div class=\"row\">\r\n\t<div class=\"col-12\">\r\n\t\t<p class=\"mt-3\">{{'spiegazione' | traduzione }}</p>\r\n\t</div>\r\n</div> -->\r\n<!-- <lib-persona-giuridica\r\n\t(done)=\"personaGiuridicaReady($event)\"\r\n\t[namespace]=\"namespace\"\r\n\t[resetForm]=\"resetForm\"\r\n\t[validatorFormControl]=\"false\"\r\n>\r\n</lib-persona-giuridica> -->\r\n<lib-pg\r\n\t(done)=\"personaGiuridicaReady($event)\"\r\n\t[resetForm]=\"resetForm\"\r\n\t[showPartitaIVA]=\"showPartitaIVA\"\r\n\t[showRagioneSociale]=\"showRagioneSociale\"\r\n>\r\n</lib-pg>\r\n<div class=\"col-12\">\r\n\t<div class=\"float-right mt-4\">\r\n\t\t<button\r\n\t\t\t(click)=\"pulisciForm();\"\r\n\t\t\tmat-stroked-button color=\"primary\"\r\n\t\t\tclass=\"mr-3\"\r\n\t\t\t[disabled]=\"!areSearchParameterValid()\"\r\n\t\t> {{'pulisci' | traduzione | uppercase}}\r\n\t\t</button>\r\n\t\t<button\r\n\t\t\t(click)=\"getListaPg();\"\r\n\t\t\tmat-flat-button color=\"primary\"\r\n\t\t\t[disabled]=\"!areSearchParameterValid()\"\r\n\t\t>{{'ricerca' | traduzione | uppercase}}\r\n\t\t</button>\r\n\t</div>\r\n</div>\r\n<br>\r\n<br>\r\n<div class=\"col-12\">\r\n\t<ng-container>\r\n\t\t<div class=\"col-md-12 mt-3\">\r\n\t\t\t<div *ngIf=\"showNoResults\">\r\n\t\t\t\t<p>\r\n\t\t\t\t\t{{'nessuno-risultato' | traduzione}}\r\n\t\t\t\t</p>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<div *ngIf=\"viewIntPg\" class=\"mb-5\">\r\n\t\t\t<div class=\"col-md-12 mt-3\">\r\n\t\t\t\t<mat-chip-list>\r\n\t\t\t\t\t<p class=\"mr-3 mb-0\">{{'totale-risultati' | traduzione }} : {{resLenPg}}</p>\r\n\t\t\t\t</mat-chip-list>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<div [hidden]=\"!viewResultTable\">\r\n\t\t\t<mat-table mat-table [dataSource]=\"dataSource\" class=\"mat-elevation-z8 mt-3 border\">\r\n\r\n\t\t\t\t<!-- Ragione Sociale Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"ragioneSociale\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'ragione-sociale' | traduzione }} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.datiPersonaGiuridica.ragioneSociale}} </mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- PIVA Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"pIva\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'pIva' | traduzione }} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.datiPersonaGiuridica.partitaIVA}} </mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Codice Fiscale Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"codFiscale\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'codice-fiscale' | traduzione }} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\"> {{element.datiPersonaGiuridica.codiceFiscale}} </mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<!-- Selezione Column -->\r\n\t\t\t\t<ng-container matColumnDef=\"seleziona\">\r\n\t\t\t\t\t<mat-header-cell *matHeaderCellDef> {{'seleziona' | traduzione}} </mat-header-cell>\r\n\t\t\t\t\t<mat-cell *matCellDef=\"let element\">\r\n\t\t\t\t\t\t<button (click)=\"personaGiuridicaSelected(element)\" mat-flat-button color=\"primary\">\r\n\t\t\t\t\t\t\t{{'seleziona' | traduzione}}\r\n\t\t\t\t\t\t</button>\r\n\t\t\t\t\t</mat-cell>\r\n\t\t\t\t</ng-container>\r\n\r\n\t\t\t\t<mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\r\n\t\t\t\t<mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\r\n\r\n\t\t\t</mat-table>\r\n\t\t\t<mat-paginator [pageSizeOptions]=\"[5, 10, 20]\" showFirstLastButtons></mat-paginator>\r\n\t\t</div>\r\n\t</ng-container>\r\n</div>\r\n",
                styles: [".mat-header-cell{background-color:#dce9f5;color:#092644!important;font-weight:600}.mat-paginator{background:#fff}.mat-paginator,.mat-paginator-page-size .mat-select-trigger{color:rgba(0,0,0,.54)}.mat-paginator-decrement,.mat-paginator-increment{border-right:2px solid rgba(0,0,0,.54);border-top:2px solid rgba(0,0,0,.54)}.mat-paginator-first,.mat-paginator-last{border-top:2px solid rgba(0,0,0,.54)}.mat-icon-button[disabled] .mat-paginator-decrement,.mat-icon-button[disabled] .mat-paginator-first,.mat-icon-button[disabled] .mat-paginator-increment,.mat-icon-button[disabled] .mat-paginator-last{border-color:rgba(0,0,0,.38)}"]
            },] }
];
RicercaPgComponent.ctorParameters = () => [
    { type: DelegheService }
];
RicercaPgComponent.propDecorators = {
    namespace: [{ type: Input }],
    readOnly: [{ type: Input }],
    showRagioneSociale: [{ type: Input }],
    showPartitaIVA: [{ type: Input }],
    done: [{ type: Output }],
    paginator: [{ type: ViewChild, args: [MatPaginator, { static: true },] }]
};

class PgComponent {
    constructor(msg) {
        this.msg = msg;
        this.showRagioneSociale = true;
        this.showPartitaIVA = true;
        this.done = new EventEmitter();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        if (this.resetForm) {
            this.subscription = this.resetForm.subscribe(val => val ? this.pulisciForm() : "");
        }
        const codiceFiscale = new FormControl({ value: '', disabled: false }, 
        //TOLTO controllo per dare la possiibilità di inserimento anche della ditta individuale
        // [
        // 	// Validators.required,
        // 	ValidationService.pattern(
        // 		ValidationService.partitaIva,
        // 		"partitaIVAInvalida"
        // 	),
        // ]
        [ValidationService.pattern(ValidationService._codiceFiscalePiva, "cfInvalidoFormalmente")
        ]);
        this.form.addControl("codiceFiscale", codiceFiscale);
        if (this.showRagioneSociale) {
            const ragioneSociale = new FormControl({ value: '', disabled: false });
            this.form.addControl("ragioneSociale", ragioneSociale);
        }
        if (this.showPartitaIVA) {
            const partitaIVA = new FormControl({ value: '', disabled: false }, [
                // Validators.required,
                ValidationService.pattern(
                // ValidationService.partitaIvaMaxLen2,
                // "partitaIVAMaxLen2"
                ValidationService.partitaIva, "partitaIVAInvalida"),
            ]);
            this.form.addControl("partitaIVA", partitaIVA);
        }
        const changes$ = this.form.valueChanges.pipe(map((_) => {
            var _a, _b;
            const newSocieta = new PersonaGiuridicaDTO();
            newSocieta.codiceFiscale = this.form.controls["codiceFiscale"].value;
            newSocieta.ragioneSociale = (_a = this.form.controls["ragioneSociale"]) === null || _a === void 0 ? void 0 : _a.value;
            newSocieta.partitaIVA = (_b = this.form.controls["partitaIVA"]) === null || _b === void 0 ? void 0 : _b.value;
            return ComponentOutputStatus.of(this.form.valid, newSocieta);
        }));
        this.form.setValidators(form => {
            return (!form.get('codiceFiscale').value && (this.showPartitaIVA && !form.get('partitaIVA').value)) ?
                { requiredPG: true }
                : null;
        });
        this.subscription = changes$.subscribe((_) => this.done.emit(_));
    }
    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
    pulisciForm() {
        const keys = Object.keys(this.form.value);
        keys.forEach(key => {
            const control = this.form.get(key);
            control.setValue("");
        });
    }
}
PgComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-pg',
                template: "<div [formGroup]=\"form\">\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}} {{'codice-fiscale' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'codice-fiscale' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"codiceFiscale\" maxlength=\"16\" >\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['codiceFiscale'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('codiceFiscaleInvalido', form.controls[ 'codiceFiscale']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'codice-fiscale'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\" *ngIf=\"showRagioneSociale\">\r\n            <mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'ragione-sociale' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'ragione-sociale' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"ragioneSociale\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['ragioneSociale'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio', form.controls['ragioneSociale']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'ragione-sociale'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\" *ngIf=\"showPartitaIVA\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'partita-iva' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'partita-iva' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"partitaIVA\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['partitaIVA'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('partitaIVAInvalida', form.controls['partitaIVA']) | traduzione }}\r\n\t\t\t\t\t<!-- {{msg.produceMessage('partitaIVAMaxLen2', form.controls['partitaIVA']) | traduzione }} -->\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'partita-iva'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n        <div class=\"col-md-12\">\r\n            <mat-error *ngIf=\"form.getError('requiredPG')\">\r\n                {{msg.produceMessage('requiredPG', form) | traduzione }}\r\n            </mat-error>\r\n        </div>\r\n\t</div>\r\n</div>\r\n",
                styles: [""]
            },] }
];
PgComponent.ctorParameters = () => [
    { type: MessageService }
];
PgComponent.propDecorators = {
    resetForm: [{ type: Input }],
    showRagioneSociale: [{ type: Input }],
    showPartitaIVA: [{ type: Input }],
    done: [{ type: Output }]
};

class PfComponent {
    constructor(msg) {
        this.msg = msg;
        this.done = new EventEmitter();
    }
    ngOnInit() {
        this.form = new FormGroup({});
        if (this.resetForm) {
            this.subscription = this.resetForm.subscribe(val => val ? this.pulisciForm() : "");
        }
        const codiceFiscale = new FormControl({ value: '', disabled: false }, [
            ValidationService.pattern(ValidationService.codiceFiscale, "cfInvalidoFormalmente"),
        ]);
        this.form.addControl("codiceFiscale", codiceFiscale);
        const nome = new FormControl({ value: '', disabled: false }, [
            ValidationService.pattern(ValidationService.formatoName, "formatoName")
        ]);
        this.form.addControl("nome", nome);
        const cognome = new FormControl({ value: '', disabled: false }, [
            ValidationService.pattern(ValidationService.formatoName, "formatoName")
        ]);
        this.form.addControl("cognome", cognome);
        const changes$ = this.form.valueChanges.pipe(map((_) => {
            const pf = new InfoAnagrafichePFDTO();
            pf.codFiscale = this.form.controls["codiceFiscale"].value;
            pf.nome = this.form.controls["nome"].value;
            pf.cognome = this.form.controls["cognome"].value;
            return ComponentOutputStatus.of(this.form.valid, pf);
        }));
        this.form.setValidators(form => {
            return (!form.get('codiceFiscale').value &&
                (!form.get('cognome').value && !form.get('nome').value)) ?
                { requiredPF: true } : null;
        });
        this.subscription = changes$.subscribe((_) => this.done.emit(_));
    }
    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
    pulisciForm() {
        const keys = Object.keys(this.form.value);
        keys.forEach(key => {
            const control = this.form.get(key);
            control.setValue("");
        });
    }
}
PfComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-pf',
                template: "<form [formGroup]=\"form\">\r\n\t<div class=\"row my-2\">\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'codice-fiscale' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'codice-fiscale' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"codiceFiscale\" maxlength=\"16\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['codiceFiscale'].invalid\">\r\n\t\t\t\t\t{{msg.produceCFMessage(form.controls['codiceFiscale']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\">\r\n            <mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'cognome' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'cognome' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"cognome\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['cognome'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio',form.controls['cognome']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-md-4\">\r\n            <mat-form-field>\r\n\t\t\t\t<!-- <input matInput placeholder=\"{{'required' | traduzione}}{{'nome' | traduzione}}\" -->\r\n\t\t\t\t<input matInput placeholder=\"{{'nome' | traduzione}}\"\r\n\t\t\t\t\tformControlName=\"nome\">\r\n\t\t\t\t<mat-error *ngIf=\"form.controls['nome'].invalid\">\r\n\t\t\t\t\t{{msg.produceMessage('obbligatorio',form.controls['nome']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n        <div class=\"col-md-12\">\r\n            <mat-error *ngIf=\"form.getError('requiredPF')\">\r\n                {{msg.produceMessage('requiredPF', form) | traduzione }}\r\n            </mat-error>\r\n        </div>\r\n\t</div>\r\n</form>",
                styles: [""]
            },] }
];
PfComponent.ctorParameters = () => [
    { type: MessageService }
];
PfComponent.propDecorators = {
    resetForm: [{ type: Input }],
    done: [{ type: Output }]
};

class TabellaSediComponent {
    constructor(ref) {
        this.ref = ref;
        this.showLargeHeader = true;
        this.displayedColumns = ['tipo', 'indirizzo', 'seleziona'];
        this.done = new EventEmitter();
    }
    ngOnInit() {
        this.valid = false;
        this.selection = new SelectionModel(false, []);
        this.form = new FormGroup({});
        this.selected = new FormControl({ value: '', disabled: false });
        this.form.addControl('selected', this.selected);
        const changeSelection$ = this.selection.changed.pipe(map(change => {
            this.validazioneeSede = change.added.length > 0 ? true : false;
            return ComponentOutputStatus.of(this.validazioneeSede, change.added);
        }), tap(_ => console.log("changeSelection", _)));
        this.dataSource$ = this.sedi$
            .pipe(tap(_ => {
            this.selected.setValue('');
            this.selection.clear();
        }), map(sedi => new MatTableDataSource(sedi)), tap(_ => console.log("dataSource", _.data)), tap(dataSource => {
            this.idSedeSelezionata ?
                this.initialSelection(dataSource.data) :
                null;
            this.ref.detectChanges();
        }));
        changeSelection$.subscribe(output => this.done.emit(output));
    }
    initialSelection(sedi) {
        if (this.idSedeSelezionata) {
            setTimeout(() => {
                sedi
                    .forEach(row => {
                    if (row.id == this.idSedeSelezionata) {
                        this.selection.select(row);
                    }
                });
            }, 0);
        }
    }
}
TabellaSediComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-tabella-sedi',
                template: "<ng-container *ngIf=\"dataSource$ | async as dataSource\" [formGroup]=\"form\">\r\n\r\n    <h4 *ngIf=\"showLargeHeader\" class=\"border-bottom font-weight-bold mt-4 h5\"><info-tip-label label=\"sedi\"></info-tip-label></h4>\r\n\r\n    <h5 *ngIf=\"!showLargeHeader\" class=\"border-bottom font-weight-bold mt-4\" style=\"font-family: 'Roboto', Helvetica Neue, Arial, Noto Sans, sans-serif !important;font-size: 1rem;\"><info-tip-label label=\"sedi\"></info-tip-label></h5>\r\n\r\n    <mat-table *ngIf=\"dataSource.data.length > 0\" [dataSource]=\"dataSource\" class=\"mat-elevation-z8 mt-3 border\">\r\n\r\n        <!-- Tipo Column -->\r\n        <ng-container matColumnDef=\"tipo\">\r\n            <mat-header-cell *matHeaderCellDef> {{'tipo' | traduzione}} </mat-header-cell>\r\n            <mat-cell *matCellDef=\"let element\"> {{element.tipoSede.descrizione}} </mat-cell>\r\n            <mat-hint *infoTip=\"'tipo'\"></mat-hint>\r\n        </ng-container>\r\n\r\n        <!-- Indirizzo Column -->\r\n        <ng-container matColumnDef=\"indirizzo\">\r\n            <mat-header-cell *matHeaderCellDef> {{'indirizzo' | traduzione}} </mat-header-cell>\r\n            <mat-cell *matCellDef=\"let element\">\r\n                <span *ngIf=\"!element?.indirizzo?.estero\"> {{element?.indirizzo?.indirizzo}}\r\n                    {{element?.indirizzo?.civico}} {{element?.indirizzo?.cap}} -\r\n                    {{element?.indirizzo?.comune?.denominazione}}\r\n                    {{element?.indirizzo?.provincia?.denominazione}}</span>\r\n                <span *ngIf=\"element?.indirizzo?.estero\"> {{element?.indirizzo?.nazione?.denominazione}} -\r\n                    {{element?.indirizzo?.indirizzo}} </span>\r\n            </mat-cell>\r\n            <mat-hint *infoTip=\"'indirizzo'\"></mat-hint>\r\n        </ng-container>\r\n\r\n        <!-- Selezione Column -->\r\n        <ng-container matColumnDef=\"seleziona\">\r\n            <mat-header-cell *matHeaderCellDef> {{'seleziona' | traduzione}}\r\n            </mat-header-cell>\r\n            <mat-cell *matCellDef=\"let row\">\r\n                <mat-checkbox\r\n                    (click)=\"$event.stopPropagation()\"\r\n                    (change)=\"$event ? selection.toggle(row) : null\"\r\n                    [checked]=\"selection.isSelected(row)\"\r\n                    formControlName=\"selected\"\r\n                    [disabled]=\"disabled\">\r\n                </mat-checkbox>\r\n            </mat-cell>\r\n            <mat-hint *infoTip=\"'seleziona'\"></mat-hint>\r\n        </ng-container>\r\n\r\n        <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\r\n        <mat-row *matRowDef=\"let row; columns: displayedColumns;\"></mat-row>\r\n\r\n    </mat-table>\r\n    <ng-container *ngIf=\"dataSource.data.length > 0; else nessunaSede\">\r\n        <div class=\"collapse-body mt-2\">\r\n            <div class=\"col-md-12\">\r\n                <mat-error *ngIf=\"!validazioneeSede\">\r\n                    {{'requiredSede' | traduzione }}\r\n                </mat-error>\r\n            </div>\r\n        </div>\r\n    </ng-container>\r\n\r\n    <ng-template #nessunaSede>\r\n        <mat-error>\r\n            {{'nessunaSede' | traduzione }}\r\n        </mat-error>\r\n    </ng-template>\r\n\r\n</ng-container>\r\n",
                styles: [""]
            },] }
];
TabellaSediComponent.ctorParameters = () => [
    { type: ChangeDetectorRef }
];
TabellaSediComponent.propDecorators = {
    sedi$: [{ type: Input }],
    idSedeSelezionata: [{ type: Input }],
    disabled: [{ type: Input }],
    showLargeHeader: [{ type: Input }],
    done: [{ type: Output }]
};

class InfoTipLabelComponent {
}
InfoTipLabelComponent.decorators = [
    { type: Component, args: [{ selector: 'info-tip-label',
                template: '<ng-container *infoTip="label; showIcon: true"></ng-container>' },] }
];
InfoTipLabelComponent.propDecorators = {
    label: [{ type: Input }]
};

class InfoTipWrapperComponent {
}
InfoTipWrapperComponent.decorators = [
    { type: Component, args: [{ exportAs: 'dag-info-tip-wrapper', template: "<ng-container *ngIf=\"(showIcon || false); else noIcon\">\r\n\t<ng-container *ngIf=\"(info$ | async) as tip; else noTip\">\r\n\t\t<!-- {{tip.tipoLabel == \"CAMPO\" && \"SEZIONE_PAGINA\" ? '': tip.label}} -->\r\n\t\t{{ tip.label }}\r\n\t\t<!-- OLD\r\n\t\t<button class=\"dag-info-label mat-flat-button bg-transparent px-0\">\r\n\t\t\t<span class=\"fas fa-info-circle icon-color-primary ml-1\"\r\n\t\t\t\t[matTooltip]=\"tip.tooltip || tip.label\"\r\n\t\t\t><p class=\"sr-only\">{{ tip.tooltip }}</p></span>\r\n\t\t</button> -->\r\n\t\t<button class=\"dag-info-label mat-flat-button bg-transparent px-0\"\r\n\t\t\t[matTooltip]=\"tip.tooltip || tip.label\"\r\n\t\t\taria-label=\"{{tip.tooltip}}\">\r\n\t\t\t<span class=\"fas fa-info-circle icon-color-primary ml-1\">\r\n\t\t\t\t<p class=\"sr-only\">{{ tip.tooltip }}</p>\r\n\t\t\t</span>\r\n\t\t</button>\r\n\t</ng-container>\r\n\t<ng-template #noTip>\r\n\t\t<span class=\"dag-info-label\">\r\n\t\t\t{{ elseLabel }}\r\n\t\t\t<span\r\n\t\t\t\tclass=\"dag-info-tip ml-1\"\r\n\t\t\t\t[matTooltip]=\"elseLabel\"\r\n\t\t\t></span>\r\n\t\t</span>\r\n\t</ng-template>\r\n</ng-container>\r\n<ng-template #noIcon>\r\n\t<ng-container *ngIf=\"(info$ | async) as tip\">\r\n\t\t{{ tip.tooltip }}\r\n\t</ng-container>\r\n</ng-template>\r\n", styles: ["span.dag-info-tip:after{--color:#06f;--size:1rem;border:1px solid var(--color);border-color:var(--color);border-radius:var(--size);color:var(--color);content:\"i\";cursor:help;display:inline-block;font-size:var(--size);font-weight:700;height:var(--size);line-height:var(--size);text-align:center;vertical-align:middle;width:var(--size)}.dag-info-label{min-width:15px!important}"] },] }
];
InfoTipWrapperComponent.propDecorators = {
    info$: [{ type: Input }],
    elseLabel: [{ type: Input }],
    showIcon: [{ type: Input }]
};

class InfoTip {
    // private embeddedViewRef: EmbeddedViewRef<InfoTipDirectiveContext>;
    constructor(infoTipService, templateRef, viewContainer, componentFactoryResolver) {
        this.infoTipService = infoTipService;
        this.templateRef = templateRef;
        this.viewContainer = viewContainer;
        this.componentFactoryResolver = componentFactoryResolver;
    }
    ngOnInit() {
        const view = this.viewContainer.createEmbeddedView(this.templateRef);
        view.detach();
        this.wrapperRef = this.viewContainer.createComponent(this.componentFactoryResolver.resolveComponentFactory(InfoTipWrapperComponent));
        this.wrapperRef.instance.elseLabel = this.infoTip;
        this.wrapperRef.instance.showIcon = this.infoTipShowIcon || false;
        this.wrapperRef.instance.info$ = this.infoTipService.getInfo$(this.infoTip);
        view.reattach();
    }
    ngOnDestroy() {
        this.wrapperRef.destroy();
        // this.embeddedViewRef.destroy();
    }
}
InfoTip.decorators = [
    { type: Directive, args: [{
                exportAs: 'dag-info-tip',
                selector: '[infoTip]'
            },] }
];
InfoTip.ctorParameters = () => [
    { type: InfoTipService },
    { type: TemplateRef },
    { type: ViewContainerRef },
    { type: ComponentFactoryResolver }
];
InfoTip.propDecorators = {
    infoTip: [{ type: Input }],
    infoTipShowIcon: [{ type: Input }]
};

class InfoTipModule {
}
InfoTipModule.decorators = [
    { type: NgModule, args: [{ declarations: [InfoTip,
                    InfoTipWrapperComponent,
                    InfoTipLabelComponent
                ],
                exports: [InfoTip,
                    InfoTipLabelComponent
                ],
                imports: [MatTooltipModule,
                    CommonModule,
                    I18nLibModule
                ],
                id: 'dag-info-tip'
            },] }
];

class UpperCaseDirective {
    constructor(ref, control) {
        this.ref = ref;
        this.control = control;
    }
    input(event) {
        var _a;
        this.ref.nativeElement.value = event.target.value.toUpperCase();
        if ((_a = this === null || this === void 0 ? void 0 : this.control) === null || _a === void 0 ? void 0 : _a.control) {
            this.control.control.setValue(this.ref.nativeElement.value);
        }
    }
}
UpperCaseDirective.decorators = [
    { type: Directive, args: [{
                selector: '[uppercase]'
            },] }
];
UpperCaseDirective.ctorParameters = () => [
    { type: ElementRef },
    { type: NgControl }
];
UpperCaseDirective.propDecorators = {
    input: [{ type: HostListener, args: ['input', ['$event'],] }]
};

class UppercaseModule {
}
UppercaseModule.decorators = [
    { type: NgModule, args: [{
                declarations: [
                    UpperCaseDirective
                ],
                imports: [
                    CommonModule,
                ],
                exports: [
                    UpperCaseDirective
                ],
                providers: [],
            },] }
];

const MY_DATE_FORMATS = {
    parse: {
        dateInput: "DD/MM/YYYY",
    },
    display: {
        dateInput: "DD/MM/YYYY",
        monthYearLabel: "MM YYYY",
        dateA11yLabel: "DD/MM/YYYY",
        monthYearA11yLabel: "MM YYYY",
    },
};
NativeDateAdapter;
// export function delegheServiceFactory(http: HttpClient, injector: Injector) {
// 	return new DelegheService(http, injector);
// }
function codiceFiscaleServiceFactory(http, conf) {
    // return !environment.isMock
    // 	? new CodiceFiscaleServiceImpl(http, paths)
    // 	: new CodiceFiscaleServiceMock();
    return new CodiceFiscaleServiceImpl(http, conf);
}
function validationServiceFactory(checkCFService) {
    return new ValidationService(checkCFService);
}
const ɵ0$1 = { strict: true };
class DepositiModule {
}
DepositiModule.decorators = [
    { type: NgModule, args: [{
                declarations: [
                    ContattiComponent,
                    DatiAnagraficiComponent,
                    DatiDomicilioComponent,
                    DatiResidenzaComponent,
                    RichiedenteComponent,
                    DelegheComponent,
                    GenericModalComponent,
                    PersonaFisicaComponent,
                    InfoPfComponent,
                    InfoNascitaComponent,
                    PersonaGiuridicaComponent,
                    IndirizzoComponent,
                    IndirizzoItalianoComponent,
                    IndirizzoEsteroComponent,
                    StradaComponent,
                    LocalitaComponent,
                    AccettazioneComponent,
                    DocumentazioneComponent,
                    CaricaDocumentiComponent,
                    TipologiaDepositoComponent,
                    PagamentoComponent,
                    DatiTribunaleComponent,
                    DatiDeposito,
                    TabellaDocumentiComponent,
                    AltriSoggettiComponent,
                    StepperNavigatorComponent,
                    RicercaPfComponent,
                    RicercaPgComponent,
                    PgComponent,
                    PfComponent,
                    TabellaSediComponent
                ],
                entryComponents: [GenericModalComponent],
                imports: [
                    CommonModule,
                    HttpClientModule,
                    MatTableModule,
                    TranslateModule,
                    MatExpansionModule,
                    I18nLibModule,
                    MatSelectModule,
                    MatNativeDateModule,
                    MatButtonModule,
                    MatCardModule,
                    MatInputModule,
                    ReactiveFormsModule,
                    MatFormFieldModule,
                    MatDialogModule,
                    MatPaginatorModule,
                    MatIconModule,
                    MatProgressBarModule,
                    MatRadioModule,
                    MatCheckboxModule,
                    MatDatepickerModule,
                    MatOptionModule,
                    MatListModule,
                    AllegatiModule,
                    UppercaseModule,
                    NgbModule,
                    MatSortModule,
                    InfoTipModule,
                    MomentDateModule
                ],
                exports: [
                    RichiedenteComponent,
                    DelegheComponent,
                    AccettazioneComponent,
                    DocumentazioneComponent,
                    TipologiaDepositoComponent,
                    PagamentoComponent,
                    DatiDeposito,
                    StepperNavigatorComponent,
                    AltriSoggettiComponent,
                    RicercaPgComponent,
                    RicercaPfComponent,
                    AltriSoggettiComponent,
                    GenericModalComponent,
                    DatiTribunaleComponent,
                    IndirizzoComponent,
                    ContattiComponent,
                    PersonaFisicaComponent,
                    PersonaGiuridicaComponent,
                    TabellaSediComponent,
                    UppercaseModule
                ],
                providers: [
                    // {
                    // 	provide: I18N_CONFIG,
                    // 	useValue: {
                    // 		codiceApplicazione: "LP"
                    // 	}
                    // },
                    // {
                    // 	provide: TipologicheService
                    // },
                    {
                        provide: CodiceFiscaleService,
                        useFactory: codiceFiscaleServiceFactory,
                        deps: [HttpClient, ConfigurationService]
                    },
                    // {
                    // 	provide: DelegheService,
                    // 	// useFactory: delegheServiceFactory,
                    // 	// deps: [HttpClient, Injector],
                    // },
                    {
                        provide: ValidationService,
                        useFactory: validationServiceFactory,
                        deps: [CodiceFiscaleServiceImpl]
                    },
                    { provide: MAT_DATE_LOCALE, useValue: "it-IT" },
                    { provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS },
                    { provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: ɵ0$1 },
                    {
                        provide: DateAdapter,
                        useClass: MomentDateAdapter,
                        deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS],
                    },
                ],
            },] }
];

class TipologicaDTO {
}

class TipoDocumento {
    static of(codice, descrizione) {
        const td = new TipoDocumento();
        td.codice = codice;
        td.descrizione = descrizione;
        return td;
    }
}

class CostituzioneDepositoDTO {
}

class CostituzioneDepositoVolontarioDTO {
}

class CostituzioneDepositoCauzionaleDTO {
}

class CostituzioneDepositoEsproprioDTO {
}

class CostituzioneDepositoGiudiziarioDTO {
}

class CostituzioneDepositoNoEsproprioDTO {
}

class AutoritaOrdinanteDTO {
}

class DatiDepositoNoEsproprioDTO extends DatiDepositoDTO {
}

class EnteRichiedenteCauzioneDTO {
}

class AutoritaEsproprianteDTO {
}

class ParticellaDTO {
}

class DocumentoDTO {
}

class BozzaDepositoDTO {
}

class IdentificativoRichiestaDTO {
}

class CreazioneBozzaResponse {
}

class ComuneDTO {
}

class ProprietarioDTO {
}

class ProvinciaDTO {
}

class DatiOperaDTO {
}

class NaturaRichiedenteRequestDTO {
}

class TipiDocumentoRequestDTO {
}

class TipoDocumentoDTO {
}

class TribunaleDTO {
}

class RtsDTO {
}

class regioneDTO {
}

class NazioneDTO {
}

class ListaPagamentiComponent {
    constructor(translateService, translatePipe) {
        this.translateService = translateService;
        this.translatePipe = translatePipe;
    }
    ngOnInit() {
        this.translatePipe.transform('');
        this.translateService.traduzioniLib$
            .pipe(tap(_ => _ ? this.loadingLinguage = true : null))
            .subscribe();
    }
}
ListaPagamentiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-lista-pagamenti',
                template: "<div *ngIf=\"loadingLinguage\">\r\n    <div *ngFor=\"let pagamento of pagamenti; let indice = index \" class=\"card card-primary shadow mb-3\">\r\n        <div class=\"card-header px-3 py-2\">\r\n            <h4 class=\"card-title mb-0 font-weight-bold d-inline text-uppercase h5\">\r\n                {{pagamento.servizio?.descrizione}} - {{pagamento?.idPagamento}}</h4>\r\n            <span class=\"badge badge-light float-right text-uppercase\"><span\r\n                    class=\"font-weight-normal\">{{'statoPagamento' | traduzione }}</span>\r\n                {{pagamento?.stato}}</span>\r\n        </div>\r\n        <div class=\"card-body px-3 py-2\">\r\n            <lib-dati-pagamento [pagamento]=\"pagamento\"></lib-dati-pagamento>\r\n            <lib-visualizza-dettagli [pagamento]=\"pagamento\"></lib-visualizza-dettagli>\r\n        </div>\r\n        <!--   <div class=\"col-12 text-right mb-3\">\r\n            <button mat-flat-button color=\"primary\">\r\n                {{'buttonDownload' | traduzione }}\r\n            </button>\r\n        </div> -->\r\n    </div>\r\n</div>",
                styles: [".card-primary>.card-header{background-color:#b9c9d8}.btn-excel{line-height:27px;padding:0 8px}.mat-expansion-panel-body{padding-left:0!important;padding-right:0!important}"]
            },] }
];
ListaPagamentiComponent.ctorParameters = () => [
    { type: TranslateService },
    { type: TranslatePipe }
];
ListaPagamentiComponent.propDecorators = {
    pagamenti: [{ type: Input }]
};

class VisualizzaDettagliComponent$1 {
    constructor(traduzione) {
        this.traduzione = traduzione;
    }
    ngOnInit() {
        this.dettagli = this.traduzione.transform('visualizzaDettagli');
        this.data = this.pagamento.dataValuta != null ?
            moment(new Date(this.pagamento.dataValuta)).format("DD/MM/YYYY") : '';
        this.contaRighe();
    }
    accordionOpened() {
        this.dettagli = this.traduzione.transform('nascondiDettagli');
    }
    accordionClosed() {
        this.dettagli = this.traduzione.transform('visualizzaDettagli');
    }
    contaRighe() {
        if (this.pagamento.motivoScarto) {
            let par = this.pagamento.motivoScarto;
            par = par.replace(/(^\s*)|(\s*$)/gi, "");
            par = par.replace(/[ ]{2,}/gi, " ");
            par = par.replace(/\n /, "\n");
            let numeroRighe = par.split('').length / 180;
            this.numeroRighe = Math.ceil(numeroRighe).toString();
        }
    }
}
VisualizzaDettagliComponent$1.decorators = [
    { type: Component, args: [{
                selector: 'lib-visualizza-dettagli',
                template: "<mat-accordion class=\"example-headers-align\" multi>\r\n  <mat-expansion-panel class=\"panel-dettagli\" (opened)=\"accordionOpened()\" (closed)=\"accordionClosed()\">\r\n    <mat-expansion-panel-header class=\"detail-pagamenti\">\r\n      <mat-panel-title class=\"text-white\">\r\n        {{dettagli}}\r\n      </mat-panel-title>\r\n    </mat-expansion-panel-header>\r\n    <div class=\"detail-content\">\r\n    <div class=\"row mt-4\">\r\n      <div class=\"col-4\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'beneficiario' | traduzione}}:</p>\r\n        <p>{{pagamento?.denominazione}}</p>\r\n      </div>\r\n      <div class=\"col-4\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'dataValuta' | traduzione}}:</p>\r\n        <p>{{data}}</p>\r\n      </div>\r\n      <div class=\"col-4\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'cro' | traduzione}}:</p>\r\n        <p>{{pagamento?.cro}}</p>\r\n      </div>\r\n      <div class=\"col-12\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'modalitaPagamaneto' | traduzione}}:</p>\r\n        <p>{{pagamento.modalitaPagamento?.descrizione}}</p>\r\n      </div>\r\n      <div *ngIf=\"pagamento.motivoScarto\" class=\"col-12 col-md-12\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'motivoScarto' | traduzione}}:</p>\r\n        <textarea disabled=\"true\" matInput value={{pagamento.motivoScarto}} rows={{numeroRighe}}></textarea>\r\n      </div>\r\n    </div>\r\n    <h5 class=\"border-bottom font-weight-bold mt-4\">{{'titolo_cronologia_stati' | traduzione}}</h5>\r\n    <lib-tabella-cronologica-stati [idPagamento]=\"pagamento?.idPagamento\"></lib-tabella-cronologica-stati>\r\n  </div>\r\n  </mat-expansion-panel>\r\n</mat-accordion>\r\n",
                styles: [".mat-flat-button{line-height:25px;padding:0 12px}.mat-expansion-panel:not([class*=mat-elevation-z]){box-shadow:0 3px 1px -2px transparent,0 0 0 0 transparent,0 0 0 0 transparent}.mat-expansion-panel:not(.mat-expanded) .mat-expansion-panel-header:not([aria-disabled=true]):hover{background:#1d65da}.mat-expansion-panel-header.mat-expanded:focus{background:#1953b0}.mat-expansion-indicator:after{color:#fff!important;margin-top:-3px}.mat-expansion-panel-header{background-color:#1953b0!important;display:inline-flex;height:25px;padding:0 12px}.mat-expansion-panel-header.mat-expanded:hover{background:#1d65da!important}.detail-content{margin:0 -24px}.mat-input-element:disabled{color:#000}", `
  ::ng-deep .detail-pagamenti > .mat-expansion-indicator:after {
    color: white;
    margin-top: -3px;
  }
`]
            },] }
];
VisualizzaDettagliComponent$1.ctorParameters = () => [
    { type: TranslatePipe }
];
VisualizzaDettagliComponent$1.propDecorators = {
    pagamento: [{ type: Input }]
};

class DatiPagamentoComponent {
    constructor() { }
    ngOnInit() {
        this.dataR = this.pagamento.dataEmissione != null ?
            moment(new Date(this.pagamento.dataEmissione)).format("DD/MM/YYYY") : '';
    }
}
DatiPagamentoComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-dati-pagamento',
                template: "<div class=\"row mt-2 mb-3\">\r\n    <div class=\"col-4\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'dataPagamento' | traduzione  }}:</p>\r\n        <p>{{dataR}}</p>\r\n    </div>\r\n    <div class=\"col-4\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'causale' | traduzione }}:</p>\r\n        <p>{{pagamento?.causale}}</p>\r\n    </div>\r\n    <div class=\"col-4\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'importo' | traduzione }}:</p>\r\n        <p>{{pagamento?.importo | number :'1.2-2' | formattaImporto}}</p>\r\n    </div>\r\n    <div class=\"col-4\">\r\n        <p class=\"mb-0 font-weight-bold\">{{'identificativo' | traduzione }}:</p>\r\n        <p>{{pagamento?.identificativo}}</p>\r\n    </div>\r\n</div>\r\n",
                styles: [""]
            },] }
];
DatiPagamentoComponent.ctorParameters = () => [];
DatiPagamentoComponent.propDecorators = {
    pagamento: [{ type: Input }]
};

class FormattaImportoPipe {
    transform(value) {
        if (value) {
            // value.replace(',', 'v');
            let arrConfig = [[',', 'v'], ['.', ','], ['v', '.']];
            const reduced = arrConfig.reduce((acc, config) => {
                return acc.replace(config[0], config[1]);
            }, value);
            return reduced;
        }
        return '';
    }
}
FormattaImportoPipe.decorators = [
    { type: Pipe, args: [{
                name: 'formattaImporto'
            },] }
];

class Paths {
    constructor(configurationService) {
        this.configurationService = configurationService;
        this.V1 = this.configurationService.servicePaths.get("GESTIONE_PAGAMENTI_MS_API_URL") + "/v1/";
    }
    get_V1_CRONOLOGIA_STATI(idPagamento) {
        return this.V1 + 'cronologia/' + idPagamento;
    }
}
Paths.decorators = [
    { type: Injectable }
];
Paths.ctorParameters = () => [
    { type: ConfigurationService }
];

class PagamentiService {
    constructor(paths, http) {
        this.paths = paths;
        this.http = http;
    }
    getCronologiaStati$(idPagamento) {
        const url = this.paths.get_V1_CRONOLOGIA_STATI(idPagamento);
        return this.http.get(url).pipe(shareReplay());
    }
}
PagamentiService.ɵprov = ɵɵdefineInjectable({ factory: function PagamentiService_Factory() { return new PagamentiService(ɵɵinject(Paths), ɵɵinject(HttpClient)); }, token: PagamentiService, providedIn: "root" });
PagamentiService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
PagamentiService.ctorParameters = () => [
    { type: Paths },
    { type: HttpClient }
];

class TabellaCronologicaStatiComponent {
    constructor(pagamentiService) {
        this.pagamentiService = pagamentiService;
    }
    ngOnInit() {
        this.cronologiaStati$ = this.pagamentiService.getCronologiaStati$(this.idPagamento);
    }
}
TabellaCronologicaStatiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-tabella-cronologica-stati',
                template: "<div class=\"table-responsive\">\r\n\t<table class=\"table border\">\r\n\t\t<thead>\r\n\t\t\t<tr>\r\n\t\t\t\t<th scope=\"col\">{{'colonna_data' | traduzione}}</th>\r\n\t\t\t\t<th scope=\"col\">{{'colonna_stato'| traduzione}}</th>\r\n\t\t\t\t<th scope=\"col\">{{'colonna_note' | traduzione}}</th>\r\n\t\t\t</tr>\r\n\t\t</thead>\r\n\t\t<tbody>\r\n\t\t\t<tr *ngFor=\"let stato of cronologiaStati$ | async\">\r\n\t\t\t\t<td>{{stato.dataModifica | date: \"dd/MM/yyyy\"}}</td>\r\n\t\t\t\t<td>{{stato.descrizioneStato}}</td>\r\n\t\t\t\t<td>{{stato.nota}}</td>\r\n\t\t\t</tr>\r\n\t\t</tbody>\r\n\t</table>\r\n</div>\r\n",
                styles: [".card-primary>.card-header{background-color:#d3deea}.table>thead{background-color:#0a2644;color:#fff}.table td,.table th{border-top:0;padding:.75rem;vertical-align:top}.table tr{border-bottom:1px solid #dee2e6}.table tbody tr:hover{background-color:#dee2e6}.btn-link{color:#0061c2}.btn-link:hover{color:#053a9a}.btn-primary{background-color:#0061c2}.btn-primary:hover{background-color:#053a9a}"]
            },] }
];
TabellaCronologicaStatiComponent.ctorParameters = () => [
    { type: PagamentiService }
];
TabellaCronologicaStatiComponent.propDecorators = {
    idPagamento: [{ type: Input }]
};

class PagamentiModule {
}
PagamentiModule.decorators = [
    { type: NgModule, args: [{
                declarations: [ListaPagamentiComponent,
                    DatiPagamentoComponent,
                    VisualizzaDettagliComponent$1,
                    FormattaImportoPipe,
                    TabellaCronologicaStatiComponent
                ],
                imports: [
                    CommonModule,
                    HttpClientModule,
                    MatTableModule,
                    TranslateModule,
                    MatExpansionModule,
                    MatButtonModule,
                    MatInputModule
                ],
                exports: [ListaPagamentiComponent],
                providers: [Paths],
            },] }
];

class CronologiaStatoDTO {
}

class ConfigurationModule {
    static forRoot(configurazioneModulo) {
        let http;
        return {
            ngModule: ConfigurationModule,
            providers: [
                {
                    provide: ConfigurationService,
                    useFactory: () => new ConfigurationService(configurazioneModulo)
                }
            ]
        };
    }
}
ConfigurationModule.decorators = [
    { type: NgModule, args: [{
                declarations: [],
                imports: [
                    CommonModule
                ]
            },] }
];

const capPattern = '[0-9][0-9][0-9][0-9][0-9]';
const passwordPattern = /^(?:(?=.*\d)(?=.*[A-Z]).{8,})/;
const zeroCentoPattern = '^([0-9]|[1-9][0-9]|100)$';
const formatoData = /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/;
const formatoEmail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
const iban = /^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$/;
const formatoSwift = /^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$/;
//static codiceFiscale = /^[A-Za-z]{6}[0-9]{2}[A-Za-z]{1}[0-9]{2}[A-Za-z]{1}[0-9]{3}[A-Za-z]{1}$/;
const codiceFiscale = /([a-z]{6}|[A-Z]{6})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})(a|b|c|d|e|h|l|m|p|r|s|t|A|B|C|D|E|H|L|M|P|R|S|T)((((l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|0|1|2|3|4|5|6)(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1}))|71|70|TM|Tm|tM|tm|TL|tl|Tl|tL))([a-z]{1}|[A-Z]{1})(L|M|N|P|Q|R|S|T|U|V|\d{1})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})(l|m|n|p|q|r|s|t|u|v|L|M|N|P|Q|R|S|T|U|V|\d{1})([a-z]{1}|[A-Z]{1})/;
const partitaIva = /^[0-9]{11}$/;
const codiceFiscalePiva = '^[A-Za-z]{6}[0-9]{2}[A-Za-z]{1}[0-9]{2}[A-Za-z]{1}[0-9]{3}[A-Za-z]{1}$|^[0-9]{11}$';
const _codiceFiscalePiva = /^[A-Za-z]{6}[0-9]{2}[A-Za-z]{1}[0-9]{2}[A-Za-z]{1}[0-9]{3}[A-Za-z]{1}$|^[0-9]{11}$/;
const anno = /^[1-2][0-9]{3}$/;
const nSentenza = /^[0-9]*\/[1-2][0-9]{3}$/;
const numberPattern = /^[0-9]*$/;
const phoneNumberPattern = /^\+{0,1}[0-9]*$/;
const moneyPattern = /^([0-9]+)|((([1-9][0-9]*)|([0-9]))([,])[0-9]{2})$/;
const moneyCommaSeparated = /^\d+,\d{2}$/;
const moneyCommaSeparatedGreaterThanZero = /^\s*(?=.*[1-9])\d*(?:\,\d{1,2})?\s*$/;
const numbers = /^\d+/;
const formatoName = /^[a-zA-Zàèìòùé ']+$/;
const numRegex = /^-?\d*[.,]?\d{0,2}$/;
const validationMessages = {
    maxlength: "validation-maxlength",
    requiredInfoDecreto: "validation-requiredInfoDecreto",
    requiredMail: "validation-requiredMail",
    cfInvalidoFormalmente: "validation-cfInvalidoFormalmente",
    invalidCF: "validation-invalidCF",
    nSentenza: "validation-nSentenza",
    required: "obbligatorio",
    email: "validation-email",
    tel: "validation-tel",
    iban: "validation-iban",
    partitaIVAInvalida: "validation-partitaIVAInvalida",
    money: "validation-money",
    invalidName: "validation-invalidName",
    invalidDate: "validation-invalidDate",
    pattern: "validation-pattern",
    invalidDateFormat: "validation-invalidDateFormat",
    requiredDefinizione: "validation-requiredDefinizione",
    validationServiceFailed: "validation-validationServiceFailed",
    cfValidationPG: "validation-cfValidationPG",
    cfDifferentRichiedente: "validation-cfDifferentRichiedente",
    requiredDomicilio: "validation-requiredDomicilio",
    requiredSede: "validation-requiredSede",
    matDatepickerParse: "validation-invalidDateFormat",
    matDatepickerMax: "error-upper-bound"
};

function getErrorMessage(control) {
    const error = Object.keys(control['errors'])[0];
    return getMessageLabel(error);
}
function getDateErrorMessage(control) {
    const errors = Object.keys(control['errors']);
    if (errors.find(err => err == 'matDatepickerParse')) {
        return getMessageLabel('matDatepickerParse');
    }
    const error = Object.keys(control['errors'])[0];
    return getMessageLabel(error);
}
function getMessageLabel(messageKey) {
    const message = validationMessages[messageKey];
    if (message) {
        return message;
    }
    else {
        return messageKey;
    }
}

class BonificoSepaComponent {
    constructor() {
        this.viewSessoPF = false;
        this.validateSepaPersonaFisicaEmitter = new EventEmitter();
        this.resetEstremiPersonaFisicaSepaFormEmitter = new EventEmitter();
        this.bonificoSepaReady = new EventEmitter();
        this.personaFisicaEmitter = new EventEmitter();
        this.getErrorMessage = getErrorMessage;
        this.ibanValidators = [Validators.required, this.sepaCountriesValidator(), ibanValidator(), this.noSpacesValidator()];
        this.sepaCountries = [{ "name": "Austria", "code": "AT", "iban": "AT493200056563289974" }, { "name": "Belgium", "code": "BE", "iban": "BE65561689528896" }, { "name": "Bulgaria", "code": "BG", "iban": "BG92TTBB94006559266188" }, { "name": "Cyprus", "code": "CY", "iban": "CY52665561416772369457864437" }, { "name": "Croatia", "code": "HR", "iban": "HR5523400098663266246" }, { "name": "Denmark", "code": "DK", "iban": "DK2550515918328528" }, { "name": "Estonia", "code": "EE", "iban": "EE591286653867491786" }, { "name": "Finland", "code": "FI", "iban": "FI8479486911788598" }, { "name": "France", "code": "FR", "iban": "FR8514508000707239488738J21" }, { "name": "Germany", "code": "DE", "iban": "DE14500105174185484177" }, { "name": "Greece", "code": "GR", "iban": "GR9201494491588141549531799" }, { "name": "Ireland", "code": "IE", "iban": "IE29AIBK93115212345678" }, { "name": "Italy", "code": "IT", "iban": "IT77R0300203280648419668253" }, { "name": "Latvia", "code": "LV", "iban": "LV80BANK0000435195001" }, { "name": "Lithuania", "code": "LT", "iban": "LT275168179993645428" }, { "name": "Luxembourg", "code": "LU", "iban": "LU350106814331716425" }, { "name": "Malta", "code": "MT", "iban": "MT54WLCI12377529685589454747835" }, { "name": "Netherlands", "code": "NL", "iban": "NL13INGB6755037397" }, { "name": "Poland", "code": "PL", "iban": "PL06109024023962236263666664" }, { "name": "Portugal", "code": "PT", "iban": "PT26003506516995234369482" }, { "name": "Czech Republic", "code": "CZ", "iban": "CZ1350515343291243261222" }, { "name": "Romania", "code": "RO", "iban": "RO64RZBR2335521926768262" }, { "name": "Slovakia", "code": "SK", "iban": "SK6053419589142643828262" }, { "name": "Slovenia", "code": "SI", "iban": "SI97975426678332786" }, { "name": "Spain", "code": "ES", "iban": "ES7231904977492569944158" }, { "name": "Sweden", "code": "SE", "iban": "SE4949996195749755572136" }, { "name": "Hungary", "code": "HU", "iban": "HU42117730161111101800000000" }, { "name": "Norway", "code": "NO", "iban": "NO9386011117947" }, { "name": "Liechtenstein", "code": "LI", "iban": "LI7008800683146527484" }, { "name": "Iceland", "code": "IS", "iban": "IS140159260076545510730339" }, { "name": "Switzerland", "code": "CH", "iban": "CH4789144623328263139" }, { "name": "United Kingdom", "code": "GB", "iban": "GB09BARC20040416289669" }, { "name": "Monaco", "code": "MC", "iban": "MC2112739000407179846124F08" }, { "name": "Andorra", "code": "AD", "iban": "AD5127638574262995775744" }, { "name": "San Marino", "code": "SM", "iban": "SM86U0322509800000000270100" }, { "name": "Holy See (Vatican City State)", "code": "VA", "iban": "VA59001123000012345678" }];
        // this.initSepaForm();
    }
    ngOnInit() {
        this.initSepaForm();
        this.sepaForm.valueChanges.subscribe(() => {
            // if (this.sepaForm.valid) {
            const bonificoSepa = {
                iban: this.sepaForm.get('iban').value,
                delegato: this.sepaForm.get('existsDelegatoRiscossione').value,
                delegatoRiscossione: this.sepaForm.get('existsDelegatoRiscossione').value ? this.delegato : null,
            };
            const isFormValid = this.sepaForm.valid;
            const isFormDelegatoValid = this.sepaForm.get('existsDelegatoRiscossione').value === true ? this.isDelegatoValid : true;
            const isValid = isFormValid && isFormDelegatoValid;
            this.bonificoSepaReady.emit({ bonifico: bonificoSepa, isValid });
            //}
        });
    }
    initSepaForm() {
        var _a;
        this.sepaForm = new FormGroup({
            existsDelegatoRiscossione: new FormControl(this.bonificoSepa != null ? this.bonificoSepa.delegato : false, [Validators.required]),
            iban: new FormControl((_a = this.bonificoSepa) === null || _a === void 0 ? void 0 : _a.iban, this.ibanValidators),
        });
    }
    onValidateSepaPersonaFisica() {
        this.validateSepaPersonaFisicaEmitter.emit();
    }
    onExistsDelegatoRiscossioneChange(tipo) {
        if (!tipo.value) {
            this.resetEstremiPersonaFisicaSepaFormEmitter.emit();
        }
    }
    sepaCountriesValidator() {
        return (form) => {
            const iban = form.value;
            if (!iban || (iban === null || iban === void 0 ? void 0 : iban.length) < 2) {
                return null;
            }
            const countryCode = iban.substring(0, 2);
            if (!this.sepaCountries.some((element) => element.code === countryCode)) {
                return { ibanExtraSepa: true };
            }
            return null;
        };
    }
    onDelegatoRiscossioneReady(event) {
        this.delegato = event.persona;
        this.isDelegatoValid = event.isValid;
        this.personaFisicaEmitter.emit({ persona: event.persona, isValid: event.isValid });
    }
    convertToUppercase(value) {
        this.sepaForm.get('iban').setValue(value.toUpperCase());
    }
    noSpacesValidator() {
        return (control) => {
            const hasSpaces = /\s/.test(control.value);
            return hasSpaces ? { spacesIban: true } : null;
        };
    }
}
BonificoSepaComponent.decorators = [
    { type: Component, args: [{
                selector: "lib-bonifico-sepa",
                template: "<form [formGroup]=\"sepaForm\" [ngxsForm]=\"sepaFormPath\">\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-md-8\">\r\n\t\t\t<label id=\"existsDelegatoRiscossioneLabel\">{{ \"exists-delegato-riscossione\" | traduzione }}</label>\r\n\t\t\t<mat-radio-group class=\"radio-group\" aria-labelledby=\"existsDelegatoRiscossioneLabel\"\r\n\t\t\t\t\t\t\t\t\t\t\t formControlName=\"existsDelegatoRiscossione\"\r\n\t\t\t\t\t\t\t\t\t\t\t (change)=\"onExistsDelegatoRiscossioneChange($event)\">\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"true\">\r\n\t\t\t\t\t{{ \"si\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"false\">\r\n\t\t\t\t\t{{ \"no\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\t\t\t</mat-radio-group>\r\n\t\t\t<br/>\r\n\t\t\t<mat-hint *infoTip=\"'exists-delegato-riscossione'\"></mat-hint>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<div *ngIf=\"sepaForm.controls['existsDelegatoRiscossione'].value\" class=\"row mt-3\">\r\n\t\t<div class=\"col-12\">\r\n\t\t\t<div class=\"row mt-4\">\r\n\t\t\t\t<div class=\"col-12\">\r\n\t\t\t\t\t<lib-estremi-persona-fisica [ngxsFormPath]=\"estremiPFSepaFormPath\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[province]=\"province\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[nazioni]=\"nazioni\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[isPersonaFisicaValid]=\"isPersonaFisicaSepaValid\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[personaFisica]=\"bonificoSepa?.delegatoRiscossione\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[viewSessoPF]=\"viewSessoPF\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(validatePersonaFisicaEmitter)=\"onValidateSepaPersonaFisica()\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(personaFisicaEmitter)=\"onDelegatoRiscossioneReady($event)\">\r\n\t\t\t\t\t</lib-estremi-persona-fisica>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<lib-dati-residenza [validateAndGetResidenza]=\"validateAndGetResidenza\"></lib-dati-residenza>\r\n\t</div>\r\n\t</div>\r\n\r\n\t<div class=\"row my-4 mt-4\">\r\n\t\t<div class=\"col-md-4\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input matInput placeholder=\"{{ 'required' | traduzione }}{{ 'codice-iban' | traduzione }}\"\r\n\t\t\t\t\tformControlName=\"iban\"\r\n\t\t\t\t\t(input)=\"convertToUppercase($event.target.value)\"/>\r\n\t\t\t\t<mat-error *ngIf=\"sepaForm.controls['iban'].invalid\">\r\n\t\t\t\t\t{{ getErrorMessage(sepaForm.controls['iban']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n</form>\r\n",
                styles: [""]
            },] }
];
BonificoSepaComponent.ctorParameters = () => [];
BonificoSepaComponent.propDecorators = {
    bonificoSepa: [{ type: Input }],
    nazioni: [{ type: Input }],
    province: [{ type: Input }],
    isPersonaFisicaSepaValid: [{ type: Input }],
    sepaFormPath: [{ type: Input }],
    estremiPFSepaFormPath: [{ type: Input }],
    viewSessoPF: [{ type: Input }],
    validateAndGetResidenza: [{ type: Input }],
    validateSepaPersonaFisicaEmitter: [{ type: Output }],
    resetEstremiPersonaFisicaSepaFormEmitter: [{ type: Output }],
    bonificoSepaReady: [{ type: Output }],
    personaFisicaEmitter: [{ type: Output }]
};

function ValidateMail(control) {
    if (formatoEmail.test(control.value)) {
        return null;
    }
    return { invalidMail: true };
}
function ValidateDate(control) {
    if (new Date().getTime() < control.value) {
        return { invalidDate: true };
    }
    return null;
}
function ValidateName(control) {
    if (formatoName.test(control.value)) {
        return null;
    }
    return { invalidName: true };
}
function ValidatePassword(control) {
    if (passwordPattern.test(control.value)) {
        return null;
    }
    return { invalidPassword: true };
}
function ValidateIban(control) {
    if (iban.test(control.value)) {
        return null;
    }
    return { invalidIban: true };
}
function ValidazioneData(control) {
    if (formatoData.test(control.value)) {
        return null;
    }
    return { invalidFormatDate: true };
}
function ValidateCodiceFiscale(control) {
    if (codiceFiscale.test(control.value)) {
        return null;
    }
    return { codiceFiscaleInvalido: true };
}
function ValidateCodiceFiscalePIVA(control) {
    var _a;
    if (_codiceFiscalePiva.test(control.value) && ((_a = control.value) === null || _a === void 0 ? void 0 : _a.length) >= 11) {
        return null;
    }
    return { cfInvalidoFormalmente: true };
}
function ValidatePartitaIva(control) {
    if (partitaIva.test(control.value)) {
        return null;
    }
    return { cfInvalidoFormalmente: true };
}
function ValidateImportoFormato(valoreImporto) {
    return /^[0-9]*,[0-9]{2}$/.test(valoreImporto);
}
function ValidatoreSwift(control) {
    if (formatoSwift.test(control.value)) {
        return null;
    }
    return { invalidSwift: true };
}
function ValidatePhone(control) {
    if (!control.value || phoneNumberPattern.test(control.value)) {
        return null;
    }
    return { pattern: true };
}

class ModalitaPagamentoService {
    constructor(http, configurationService, appRef) {
        this.http = http;
        this.configurationService = configurationService;
        this.appRef = appRef;
        console.log('[ModalitaPagamentoService]');
        this.urlAnagrafe = configurationService.servicePaths.get("ANAGRAFE_MS_API_URL") + "/v1";
        console.log('[urlAnagrafe - lib]', this.urlAnagrafe);
        const lingua$ = configurationService.lingua$;
        // console.log('[lingua]', configurationService.servicePaths.get("I18N_MS_API_URL"));
        //TODO
        // const urlNazioni: string = this.paths.get_V1Nazioni();
        const urlNazioni = this.urlAnagrafe + "/nazioni";
        // console.log('[urlNazioni]', urlNazioni);
        this.nazioni$ = lingua$.pipe(switchMap(lingua => this.http.get(urlNazioni, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => appRef.tick()), shareReplay());
        //TODO
        // const urlProvince: string = this.paths.get_V1Province();
        const urlProvince = this.urlAnagrafe + '/province';
        // console.log('[urlProvince]', urlProvince);
        // TODO
        // const urlRegioni: string = this.urlAnagrafe + '/regioni';
        const urlRegioni = this.urlAnagrafe + '/regioni/nonSoppresse/';
        //TODO
        // this.province$ = this.http.get<Array<Localita>>(urlProvince);
        this.province$ = lingua$.pipe(switchMap(lingua => this.http.get(urlProvince, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => appRef.tick()), shareReplay());
        this.regioni$ = lingua$.pipe(switchMap(lingua => this.http.get(urlRegioni, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => appRef.tick()), shareReplay());
    }
    getProvince$() {
        return this.province$;
    }
    getProvincePerRegione$(regione) {
        //TODO
        // return this.configurationService.lingua$
        // 	.pipe(switchMap(lingua => this.http.get<Array<Localita>>(
        // 		this.urlAnagrafe + `/regione/${regione.sigla}/province`,
        // 		{ headers: new HttpHeaders({ 'i18n_language': lingua }) }
        // 	)));
        const url = `${this.urlAnagrafe}/regione/${regione.sigla}/province/nonSoppresse/?codiceRegione=${regione.sigla}`;
        return this.configurationService.lingua$.pipe(switchMap(lingua => this.http.get(url, { headers: new HttpHeaders({ 'i18n_language': lingua }) })), tap(_ => this.appRef.tick()), shareReplay());
    }
    getComuni$(siglaProvincia) {
        //TODO
        // const url: string = this.paths.get_V1ComuniByProvincia(siglaProvincia);
        // const url: string = `${this.urlAnagrafe}/provincia/${siglaProvincia}/comuni`
        const url = `${this.urlAnagrafe}/provincia/${siglaProvincia}/comuni/nonSoppressi`;
        return this.http.get(url).pipe(shareReplay());
    }
    getComune$(codiceCatastale) {
        const url = `${this.urlAnagrafe}/comune/codiceCatastale/${codiceCatastale}`;
        return this.http.get(url).pipe(shareReplay());
    }
    getNazioni$() {
        return this.nazioni$;
    }
    getCap$(idComune) {
        //TODO
        // const url: string = this.paths.get_V1CapByIdComune(idComune);
        const url = `${this.urlAnagrafe}/comuni/${idComune}/cap`;
        return this.http.get(url);
    }
    getRegioni$() {
        return this.regioni$;
    }
}
ModalitaPagamentoService.ɵprov = ɵɵdefineInjectable({ factory: function ModalitaPagamentoService_Factory() { return new ModalitaPagamentoService(ɵɵinject(HttpClient), ɵɵinject(ConfigurationService), ɵɵinject(ApplicationRef)); }, token: ModalitaPagamentoService, providedIn: "root" });
ModalitaPagamentoService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root',
            },] }
];
ModalitaPagamentoService.ctorParameters = () => [
    { type: HttpClient },
    { type: ConfigurationService },
    { type: ApplicationRef }
];

class EstremiPersonaFisicaComponent {
    constructor(modalitaPagamentoService) {
        this.modalitaPagamentoService = modalitaPagamentoService;
        this.viewSessoPF = false;
        this.validatePersonaFisicaEmitter = new EventEmitter();
        this.personaFisicaEmitter = new EventEmitter();
        this.maxDataNascita = new Date();
        this.subscription = new Subscription();
        this.getErrorMessage = getErrorMessage;
        this.getDateErrorMessage = getDateErrorMessage;
        // this.initPersonaFisicaForm();
        // this.setCodiceFiscaleValidators();
    }
    set _disableForm(val) {
        this.disableForm = val;
        if (this.disableForm) {
            this.estremiPersonaFisicaForm.disable();
            this.validatePersonaFisicaEmitter.emit();
        }
        else {
            this.estremiPersonaFisicaForm.enable();
        }
    }
    ngOnInit() {
        this.initPersonaFisicaForm();
        this.setFormControlsValue();
        this.setCodiceFiscaleValidators();
        // Set/Unset form controls validation on isNatoEstero Value Change
        this.subscription.add(this.estremiPersonaFisicaForm.controls['isNatoEstero'].valueChanges.subscribe(isNatoEstero => {
            if (isNatoEstero) {
                this.estremiPersonaFisicaForm.controls['provinciaNascita'].setValidators([]);
                this.estremiPersonaFisicaForm.controls['provinciaNascita'].patchValue(null);
                this.estremiPersonaFisicaForm.controls['provinciaNascita'].updateValueAndValidity();
                this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].setValidators([]);
                this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].patchValue(null);
                this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].updateValueAndValidity();
                this.estremiPersonaFisicaForm.controls['nazioneNascita'].setValidators([Validators.required]);
                this.estremiPersonaFisicaForm.controls['nazioneNascita'].updateValueAndValidity();
            }
            else {
                this.estremiPersonaFisicaForm.controls['provinciaNascita'].setValidators([Validators.required]);
                this.estremiPersonaFisicaForm.controls['provinciaNascita'].updateValueAndValidity();
                this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].setValidators([Validators.required]);
                this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].updateValueAndValidity();
                this.estremiPersonaFisicaForm.controls['nazioneNascita'].setValidators([]);
                this.estremiPersonaFisicaForm.controls['nazioneNascita'].patchValue(null);
                this.estremiPersonaFisicaForm.controls['nazioneNascita'].updateValueAndValidity();
            }
        }));
        this.getComuniOnProvinciaChange();
        this.validatePersonaFisica();
        this.personaFisicaEmit();
    }
    getComuniOnProvinciaChange() {
        this.subscription.add(this.estremiPersonaFisicaForm.controls['provinciaNascita'].valueChanges.pipe(distinctUntilChanged(), switchMap(siglaProvinciaNascita => iif(() => !!siglaProvinciaNascita, this.modalitaPagamentoService.getComuni$(siglaProvinciaNascita).pipe(take(1)), of([])))).subscribe(comuni => {
            this.comuni = comuni;
        }));
    }
    validatePersonaFisica() {
        this.subscription.add(this.estremiPersonaFisicaForm.valueChanges.pipe(debounceTime(500), filter(() => this.estremiPersonaFisicaForm.valid)).subscribe((_) => {
            this.validatePersonaFisicaEmitter.emit();
        }));
    }
    personaFisicaEmit() {
        this.subscription.add(this.estremiPersonaFisicaForm.valueChanges.pipe(debounceTime(500)).subscribe((_) => {
            const personaFisica = {
                infoAnagrafiche: {
                    codFiscale: this.estremiPersonaFisicaForm.controls['codiceFiscale'].value,
                    cognome: this.estremiPersonaFisicaForm.controls['cognome'].value,
                    nome: this.estremiPersonaFisicaForm.controls['nome'].value
                },
                infoNascita: {
                    comuneNascita: this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].value,
                    provinciaNascita: this.estremiPersonaFisicaForm.controls['provinciaNascita'].value,
                    dataNascita: this.estremiPersonaFisicaForm.controls['dataNascita'].value
                }
            };
            const isValid = this.estremiPersonaFisicaForm.valid;
            this.personaFisicaEmitter.emit({ persona: personaFisica ? personaFisica : null, isValid });
        }));
    }
    initPersonaFisicaForm() {
        this.estremiPersonaFisicaForm = new FormGroup({
            codiceFiscale: new FormControl(null),
            nome: new FormControl(null, [Validators.required, ValidateName]),
            cognome: new FormControl(null, [Validators.required, ValidateName]),
            isNatoEstero: new FormControl(false),
            provinciaNascita: new FormControl(null),
            codiceComuneNascita: new FormControl(null),
            nazioneNascita: new FormControl(null),
            dataNascita: new FormControl(null, [Validators.required]),
            sesso: new FormControl(null, this.viewSessoPF ? [Validators.required] : [])
        });
    }
    setCodiceFiscaleValidators() {
        this.estremiPersonaFisicaForm.controls['codiceFiscale'].setValidators([
            Validators.required,
            ValidateCodiceFiscalePIVA
        ]);
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    convertToUppercase(event) {
        this.estremiPersonaFisicaForm.get('codiceFiscale').setValue(event.target.value.toUpperCase());
    }
    onProvinciaChange() {
        this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].patchValue(null);
        this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].markAsTouched();
    }
    setFormControlsValue() {
        var _a;
        this.estremiPersonaFisicaForm.controls['codiceFiscale'].setValue(this.personaFisica ? this.personaFisica.infoAnagrafiche.codFiscale : null);
        this.estremiPersonaFisicaForm.controls['nome'].setValue(this.personaFisica ? this.personaFisica.infoAnagrafiche.nome : null);
        this.estremiPersonaFisicaForm.controls['cognome'].setValue(this.personaFisica ? this.personaFisica.infoAnagrafiche.cognome : null);
        this.estremiPersonaFisicaForm.controls['isNatoEstero'].setValue(this.personaFisica && this.personaFisica.infoNascita.comuneNascita.startsWith("Z") ? true : false);
        this.estremiPersonaFisicaForm.controls['provinciaNascita'].setValue(this.personaFisica && !this.personaFisica.infoNascita.comuneNascita.startsWith("Z") ? this.personaFisica.infoNascita.provinciaNascita : null);
        this.estremiPersonaFisicaForm.controls['codiceComuneNascita'].setValue(this.personaFisica && !this.personaFisica.infoNascita.comuneNascita.startsWith("Z") ? this.personaFisica.infoNascita.comuneNascita : null);
        this.estremiPersonaFisicaForm.controls['dataNascita'].setValue(this.personaFisica ? this.personaFisica.infoNascita.dataNascita : null);
        // TODO
        this.estremiPersonaFisicaForm.controls['sesso'].setValue(this.viewSessoPF ? 'M' : null);
        this.estremiPersonaFisicaForm.controls['nazioneNascita'].setValue(this.personaFisica && this.personaFisica.infoNascita.comuneNascita.startsWith("Z") ? (_a = this.personaFisica.infoNascita) === null || _a === void 0 ? void 0 : _a.comuneNascita : null);
    }
}
EstremiPersonaFisicaComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-estremi-persona-fisica',
                template: "<form [formGroup]=\"estremiPersonaFisicaForm\" [ngxsForm]=\"ngxsFormPath\">\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-12 col-lg-4 mt-2 mt-lg-0\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input formControlName=\"codiceFiscale\"\r\n\t\t\t\t\t\tmatInput\r\n\t\t\t\t\t\t[maxlength]=\"16\"\r\n\t\t\t\t\t\tplaceholder=\"{{ 'required' | traduzione }} {{ 'codice-fiscale' | traduzione }}\"\r\n\t\t\t\t\t\t(input)=\"convertToUppercase($event)\" />\r\n\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm.controls['codiceFiscale'].invalid\">\r\n\t\t\t\t\t{{ getErrorMessage(estremiPersonaFisicaForm.controls['codiceFiscale']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-12 col-lg-4 mt-2 mt-lg-0\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input formControlName=\"nome\"\r\n\t\t\t\t\t\tmatInput\r\n\t\t\t\t\t\t[maxlength]=\"100\"\r\n\t\t\t\t\t\tplaceholder=\"{{ 'required' | traduzione }} {{ 'nome' | traduzione }}\"/>\r\n\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm?.controls['nome'].invalid\">\r\n\t\t\t\t\t{{ getErrorMessage(estremiPersonaFisicaForm.controls['nome']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div class=\"col-12 col-lg-4 mt-2 mt-lg-0\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input formControlName=\"cognome\"\r\n\t\t\t\t\t\tmatInput\r\n\t\t\t\t\t\t[maxlength]=\"100\"\r\n\t\t\t\t\t\tplaceholder=\"{{ 'required' | traduzione }} {{ 'cognome' | traduzione }}\"/>\r\n\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm?.controls['cognome'].invalid\">\r\n\t\t\t\t\t{{ getErrorMessage(estremiPersonaFisicaForm.controls['cognome']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-12 pt-3 pb-2 pt-lg-2 pb-lg-2\">\r\n\t\t\t<mat-checkbox formControlName=\"isNatoEstero\"\r\n\t\t\t\t\t\t  color=\"primary\">\r\n\t\t\t\t<info-tip-label label=\"localita-nascita-estera\"></info-tip-label>\r\n\t\t\t</mat-checkbox>\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"row\">\r\n\t\t<ng-container *ngIf=\"!estremiPersonaFisicaForm?.controls['isNatoEstero']?.value else nascitaEstera\">\r\n\t\t\t<div class=\"col-12 col-lg-4 mt-2 mt-lg-0\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'provincia-nascita' | traduzione }}</mat-label>\r\n\t\t\t\t\t<mat-select [placeholder]=\"'seleziona' | traduzione\" formControlName=\"provinciaNascita\" (valueChange)=\"onProvinciaChange()\">\r\n\t\t\t\t\t\t<mat-option *ngFor=\"let provincia of province\" [value]=\"provincia.sigla\">\r\n\t\t\t\t\t\t\t{{ provincia.denominazione }}\r\n\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm.controls['provinciaNascita'].invalid\">\r\n\t\t\t\t\t\t{{ 'obbligatorio' | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"col-12 col-lg-4 mt-2 mt-lg-0\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'comune-nascita' | traduzione }}</mat-label>\r\n\t\t\t\t\t<mat-select placeholder=\"{{ 'seleziona' | traduzione }}\" formControlName=\"codiceComuneNascita\">\r\n\t\t\t\t\t\t<mat-option *ngFor=\"let comune of comuni\" [value]=\"comune.codiceCatastale\">\r\n\t\t\t\t\t\t\t{{ comune.denominazione }}\r\n\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm.controls['codiceComuneNascita'].invalid\">\r\n\t\t\t\t\t\t{{ 'obbligatorio' | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t</ng-container>\r\n\t\t<ng-template #nascitaEstera>\r\n\t\t\t<div class=\"col-12 col-lg-4 mt-2 mt-lg-0\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'nazione-nascita' | traduzione }}</mat-label>\r\n\t\t\t\t\t<mat-select [placeholder]=\"'seleziona' | traduzione\" formControlName=\"nazioneNascita\">\r\n\t\t\t\t\t\t<mat-option *ngFor=\"let nazione of nazioni\" [value]=\"nazione.codiceCatastale\">\r\n\t\t\t\t\t\t\t{{ nazione.denominazione }}\r\n\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm.controls['nazioneNascita'].invalid\">\r\n\t\t\t\t\t\t{{ 'obbligatorio' | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t</ng-template>\r\n\t\t<div class=\"col-12\" [ngClass]=\"viewSessoPF ?\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\testremiPersonaFisicaForm?.controls['isNatoEstero']?.value ? ' col-lg-4 mt-2 mt-lg-0'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: ' col-lg-2 mt-2 mt-lg-0'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: ' col-lg-4 mt-2 mt-lg-0'\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input formControlName=\"dataNascita\"\r\n\t\t\t\t\t\t[max]=\"maxDataNascita\"\r\n\t\t\t\t\t\tmatInput\r\n\t\t\t\t\t\t[matDatepicker]=\"dataNascita\"\r\n\t\t\t\t\t\t[placeholder]=\"('required' | traduzione) + ('data-nascita' | traduzione)\">\r\n\t\t\t\t<mat-datepicker-toggle matSuffix [for]=\"dataNascita\"></mat-datepicker-toggle>\r\n\t\t\t\t<mat-datepicker #dataNascita></mat-datepicker>\r\n\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm.controls['dataNascita'].invalid\">\r\n\t\t\t\t\t{{ getDateErrorMessage(estremiPersonaFisicaForm.controls['dataNascita']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-hint *infoTip=\"'formato-data'\"></mat-hint>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t\t<div *ngIf=\"viewSessoPF\" class=\"col-12 col-lg-2 mt-2 mt-lg-0\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'sesso' | traduzione }}</mat-label>\r\n\t\t\t\t<mat-select [placeholder]=\"'seleziona' | traduzione\" formControlName=\"sesso\">\r\n\t\t\t\t\t<mat-option [value]=\"null\"> {{ \"seleziona\" | traduzione }} </mat-option>\r\n\t\t\t\t\t<mat-option value=\"M\">{{ \"maschio\" | traduzione }}</mat-option>\r\n\t\t\t\t\t<mat-option value=\"F\">{{ \"femmina\" | traduzione }}</mat-option>\r\n\t\t\t\t</mat-select>\r\n\t\t\t\t<mat-error *ngIf=\"estremiPersonaFisicaForm.controls['sesso'].invalid\">\r\n\t\t\t\t\t{{ 'obbligatorio' | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-12 mt-2 mt-lg-0\">\r\n\t\t\t<mat-error *ngIf=\"!isPersonaFisicaValid && (estremiPersonaFisicaForm.dirty)\">\r\n\t\t\t\t{{'invalid-dati-anagrafici' | traduzione }}\r\n\t\t\t</mat-error>\r\n\t\t</div>\r\n\t</div>\r\n</form>\r\n\r\n",
                styles: [""]
            },] }
];
EstremiPersonaFisicaComponent.ctorParameters = () => [
    { type: ModalitaPagamentoService }
];
EstremiPersonaFisicaComponent.propDecorators = {
    ngxsFormPath: [{ type: Input }],
    province: [{ type: Input }],
    nazioni: [{ type: Input }],
    isPersonaFisicaValid: [{ type: Input }],
    personaFisica: [{ type: Input }],
    viewSessoPF: [{ type: Input }],
    validatePersonaFisicaEmitter: [{ type: Output }],
    personaFisicaEmitter: [{ type: Output }],
    _disableForm: [{ type: Input, args: ['disableForm',] }]
};

class BonificoExtraSepaComponent {
    constructor() {
        this.viewSessoPF = false;
        this.validateExtraSepaPersonaFisicaEmitter = new EventEmitter();
        this.resetEstremiPersonaFisicaExtraSepaFormEmitter = new EventEmitter();
        this.bonificoExtraSepaReady = new EventEmitter();
        this.personaFisicaEmitter = new EventEmitter();
        this.ibanValidators = [Validators.required, this.extraSepaCountriesValidator(), ibanValidator(), this.noSpacesValidator()];
        this.codiceContoValidators = [Validators.required, this.ValidateNotIban, Validators.maxLength(44)];
        this.subscription = new Subscription();
        this.getErrorMessage = getErrorMessage;
        this.sepaCountries = [{ "name": "Austria", "code": "AT", "iban": "AT493200056563289974" }, { "name": "Belgium", "code": "BE", "iban": "BE65561689528896" }, { "name": "Bulgaria", "code": "BG", "iban": "BG92TTBB94006559266188" }, { "name": "Cyprus", "code": "CY", "iban": "CY52665561416772369457864437" }, { "name": "Croatia", "code": "HR", "iban": "HR5523400098663266246" }, { "name": "Denmark", "code": "DK", "iban": "DK2550515918328528" }, { "name": "Estonia", "code": "EE", "iban": "EE591286653867491786" }, { "name": "Finland", "code": "FI", "iban": "FI8479486911788598" }, { "name": "France", "code": "FR", "iban": "FR8514508000707239488738J21" }, { "name": "Germany", "code": "DE", "iban": "DE14500105174185484177" }, { "name": "Greece", "code": "GR", "iban": "GR9201494491588141549531799" }, { "name": "Ireland", "code": "IE", "iban": "IE29AIBK93115212345678" }, { "name": "Italy", "code": "IT", "iban": "IT77R0300203280648419668253" }, { "name": "Latvia", "code": "LV", "iban": "LV80BANK0000435195001" }, { "name": "Lithuania", "code": "LT", "iban": "LT275168179993645428" }, { "name": "Luxembourg", "code": "LU", "iban": "LU350106814331716425" }, { "name": "Malta", "code": "MT", "iban": "MT54WLCI12377529685589454747835" }, { "name": "Netherlands", "code": "NL", "iban": "NL13INGB6755037397" }, { "name": "Poland", "code": "PL", "iban": "PL06109024023962236263666664" }, { "name": "Portugal", "code": "PT", "iban": "PT26003506516995234369482" }, { "name": "Czech Republic", "code": "CZ", "iban": "CZ1350515343291243261222" }, { "name": "Romania", "code": "RO", "iban": "RO64RZBR2335521926768262" }, { "name": "Slovakia", "code": "SK", "iban": "SK6053419589142643828262" }, { "name": "Slovenia", "code": "SI", "iban": "SI97975426678332786" }, { "name": "Spain", "code": "ES", "iban": "ES7231904977492569944158" }, { "name": "Sweden", "code": "SE", "iban": "SE4949996195749755572136" }, { "name": "Hungary", "code": "HU", "iban": "HU42117730161111101800000000" }, { "name": "Norway", "code": "NO", "iban": "NO9386011117947" }, { "name": "Liechtenstein", "code": "LI", "iban": "LI7008800683146527484" }, { "name": "Iceland", "code": "IS", "iban": "IS140159260076545510730339" }, { "name": "Switzerland", "code": "CH", "iban": "CH4789144623328263139" }, { "name": "United Kingdom", "code": "GB", "iban": "GB09BARC20040416289669" }, { "name": "Monaco", "code": "MC", "iban": "MC2112739000407179846124F08" }, { "name": "Andorra", "code": "AD", "iban": "AD5127638574262995775744" }, { "name": "San Marino", "code": "SM", "iban": "SM86U0322509800000000270100" }, { "name": "Holy See (Vatican City State)", "code": "VA", "iban": "VA59001123000012345678" }];
        // this.initExtraSepaForm();
    }
    ngOnInit() {
        this.initExtraSepaForm();
        this.subscription.add(this.extraSepaForm.controls['codiceContoPresent'].valueChanges.subscribe((codiceContoPresent) => {
            if (codiceContoPresent) {
                this.extraSepaForm.controls['iban'].setValidators([]);
                this.extraSepaForm.controls['iban'].patchValue(null);
                this.extraSepaForm.controls['iban'].updateValueAndValidity();
                this.extraSepaForm.controls['codiceConto'].setValidators(this.codiceContoValidators);
                this.extraSepaForm.controls['codiceConto'].updateValueAndValidity();
            }
            else {
                this.extraSepaForm.controls['codiceConto'].setValidators([]);
                this.extraSepaForm.controls['codiceConto'].patchValue(null);
                this.extraSepaForm.controls['codiceConto'].updateValueAndValidity();
                this.extraSepaForm.controls['iban'].setValidators(this.ibanValidators);
                this.extraSepaForm.controls['iban'].updateValueAndValidity();
            }
        }));
        this.subscription.add(this.extraSepaForm.controls['swiftBicPresent'].valueChanges.subscribe((swiftBicPresent) => {
            if (swiftBicPresent) {
                this.extraSepaForm.controls['swift'].setValidators([Validators.required, Validators.maxLength(11), Validators.minLength(8)]);
                this.extraSepaForm.controls['swift'].updateValueAndValidity();
                this.extraSepaForm.controls['nazione'].setValidators([]);
                this.extraSepaForm.controls['nazione'].patchValue(null);
                this.extraSepaForm.controls['nazione'].updateValueAndValidity();
                this.extraSepaForm.controls['citta'].setValidators([]);
                this.extraSepaForm.controls['citta'].patchValue(null);
                this.extraSepaForm.controls['citta'].updateValueAndValidity();
                this.extraSepaForm.controls['banca'].setValidators([]);
                this.extraSepaForm.controls['banca'].patchValue(null);
                this.extraSepaForm.controls['banca'].updateValueAndValidity();
                this.extraSepaForm.controls['indirizzo'].setValidators([]);
                this.extraSepaForm.controls['indirizzo'].patchValue(null);
                this.extraSepaForm.controls['indirizzo'].updateValueAndValidity();
                this.extraSepaForm.controls['zipCode'].setValidators([]);
                this.extraSepaForm.controls['zipCode'].patchValue(null);
                this.extraSepaForm.controls['zipCode'].updateValueAndValidity();
                this.extraSepaForm.controls['civico'].setValidators([]);
                this.extraSepaForm.controls['civico'].updateValueAndValidity();
                this.extraSepaForm.controls['civico'].patchValue(null);
            }
            else {
                this.extraSepaForm.controls['swift'].setValidators([]);
                this.extraSepaForm.controls['swift'].patchValue(null);
                this.extraSepaForm.controls['swift'].updateValueAndValidity();
                this.extraSepaForm.controls['nazione'].setValidators([Validators.required]);
                this.extraSepaForm.controls['nazione'].updateValueAndValidity();
                this.extraSepaForm.controls['citta'].setValidators([Validators.required]);
                this.extraSepaForm.controls['citta'].updateValueAndValidity();
                this.extraSepaForm.controls['banca'].setValidators([Validators.required]);
                this.extraSepaForm.controls['banca'].updateValueAndValidity();
                this.extraSepaForm.controls['indirizzo'].setValidators([Validators.required]);
                this.extraSepaForm.controls['indirizzo'].updateValueAndValidity();
                this.extraSepaForm.controls['zipCode'].setValidators([Validators.required]);
                this.extraSepaForm.controls['zipCode'].updateValueAndValidity();
                this.extraSepaForm.controls['civico'].setValidators([Validators.required]);
                this.extraSepaForm.controls['civico'].updateValueAndValidity();
            }
        }));
        this.extraSepaForm.valueChanges.subscribe(() => {
            // if (this.extraSepaForm.valid) {
            const bonificoExtraSepa = {
                swift: this.extraSepaForm.get('swift').value,
                codiceContoPresent: this.extraSepaForm.get('codiceContoPresent').value,
                codiceConto: this.extraSepaForm.get('codiceConto').value,
                iban: this.extraSepaForm.get('iban').value,
                delegato: this.extraSepaForm.get('existsDelegatoRiscossione').value,
                delegatoRiscossione: this.extraSepaForm.get('existsDelegatoRiscossione').value ? this.delegato : null,
                banca: this.extraSepaForm.get('banca').value,
                filiale: this.extraSepaForm.get('citta').value,
                indirizzo: this.extraSepaForm.get('indirizzo').value,
                swiftBicPresent: this.extraSepaForm.get('swiftBicPresent').value,
                nazione: this.extraSepaForm.get('nazione').value,
                zipCode: this.extraSepaForm.get('zipCode').value,
                codiceProvincia: 'EE',
                civico: this.extraSepaForm.get('civico').value,
            };
            const isFormValid = this.extraSepaForm.valid;
            const isFormDelegatoValid = this.extraSepaForm.get('existsDelegatoRiscossione').value === true ? this.isDelegatoValid : true;
            const isValid = isFormValid && isFormDelegatoValid;
            this.bonificoExtraSepaReady.emit({ bonifico: bonificoExtraSepa, isValid });
            //}
        });
    }
    initExtraSepaForm() {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
        this.extraSepaForm = new FormGroup({
            existsDelegatoRiscossione: new FormControl(this.bonificoExtraSepa != null ? this.bonificoExtraSepa.delegato : false, [Validators.required]),
            swift: new FormControl((_a = this.bonificoExtraSepa) === null || _a === void 0 ? void 0 : _a.swift, [Validators.required, Validators.maxLength(11), Validators.minLength(8)]),
            banca: new FormControl((_b = this.bonificoExtraSepa) === null || _b === void 0 ? void 0 : _b.banca, [Validators.required]),
            indirizzo: new FormControl((_c = this.bonificoExtraSepa) === null || _c === void 0 ? void 0 : _c.indirizzo, [Validators.required]),
            codiceContoPresent: new FormControl(this.bonificoExtraSepa != null ? this.bonificoExtraSepa.codiceContoPresent : false, [Validators.required]),
            codiceConto: new FormControl((_d = this.bonificoExtraSepa) === null || _d === void 0 ? void 0 : _d.codiceConto, this.codiceContoValidators),
            iban: new FormControl((_e = this.bonificoExtraSepa) === null || _e === void 0 ? void 0 : _e.iban, this.ibanValidators),
            swiftBicPresent: new FormControl(((_f = this.bonificoExtraSepa) === null || _f === void 0 ? void 0 : _f.swift) ? true : false, [Validators.required]),
            nazione: new FormControl((_g = this.bonificoExtraSepa) === null || _g === void 0 ? void 0 : _g.nazione, [Validators.required]),
            citta: new FormControl((_h = this.bonificoExtraSepa) === null || _h === void 0 ? void 0 : _h.filiale, [Validators.required]),
            zipCode: new FormControl((_j = this.bonificoExtraSepa) === null || _j === void 0 ? void 0 : _j.zipCode, [Validators.required]),
            civico: new FormControl((_k = this.bonificoExtraSepa) === null || _k === void 0 ? void 0 : _k.civico, [Validators.required]),
        });
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    onValidateExtraSepaPersonaFisica() {
        this.validateExtraSepaPersonaFisicaEmitter.emit();
    }
    onExistsDelegatoRiscossioneChange(tipo) {
        if (!tipo.value) {
            this.isDelegatoValid = true;
            this.resetEstremiPersonaFisicaExtraSepaFormEmitter.emit();
        }
    }
    byCode(n1, n2) {
        return (n1 === null || n1 === void 0 ? void 0 : n1.codiceCatastale) == (n2 === null || n2 === void 0 ? void 0 : n2.codiceCatastale);
    }
    ValidateNotIban(control) {
        if (!control.value) {
            return null;
        }
        const ibanRegex = /^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$/;
        if (ibanRegex.test(control.value.toString().trim())) {
            return { codiceContoSchouldNotBeIban: true };
        }
        return null;
    }
    extraSepaCountriesValidator() {
        return (form) => {
            const iban = form.value;
            if (!iban || (iban === null || iban === void 0 ? void 0 : iban.length) < 2) {
                return null;
            }
            const countryCode = iban.substring(0, 2);
            if (this.sepaCountries.some((element) => element.code === countryCode)) {
                return { ibanSepa: true };
            }
            return null;
        };
    }
    onDelegatoRiscossioneReady(event) {
        this.delegato = event.persona;
        this.isDelegatoValid = event.isValid;
        this.personaFisicaEmitter.emit({ persona: event.persona, isValid: event.isValid });
    }
    convertToUppercase(value) {
        if (this.extraSepaForm.controls['codiceContoPresent'].value) {
            this.extraSepaForm.get('codiceConto').setValue(value.toUpperCase());
        }
        else {
            this.extraSepaForm.get('iban').setValue(value.toUpperCase());
        }
    }
    noSpacesValidator() {
        return (control) => {
            const hasSpaces = /\s/.test(control.value);
            return hasSpaces ? { spacesIban: true } : null;
        };
    }
}
BonificoExtraSepaComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-bonifico-extra-sepa',
                template: "<ng-container [formGroup]=\"extraSepaForm\" [ngxsForm]=\"extraSepaFormPath\">\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-md-8\">\r\n\t\t\t<label id=\"existsDelegatoRiscossioneLabel\">{{ \"exists-delegato-riscossione\" | traduzione }}</label>\r\n\t\t\t<mat-radio-group class=\"radio-group\"\r\n\t\t\t\t\t\t\t aria-labelledby=\"existsDelegatoRiscossioneLabel\"\r\n\t\t\t\t\t\t\t formControlName=\"existsDelegatoRiscossione\"\r\n\t\t\t\t\t\t\t (change)=\"onExistsDelegatoRiscossioneChange($event)\">\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"true\">\r\n\t\t\t\t\t{{ \"si\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"false\">\r\n\t\t\t\t\t{{ \"no\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\t\t\t</mat-radio-group>\r\n\t\t\t<br /><br />\r\n\t\t\t<mat-hint *infoTip=\"'exists-delegato-riscossione'\"></mat-hint>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<div *ngIf=\"extraSepaForm.controls['existsDelegatoRiscossione'].value\" class=\"row mt-3\">\r\n\t\t<div class=\"col-12\">\r\n\t\t\t<div class=\"row mt-4\">\r\n\t\t\t\t<div class=\"col-12\">\r\n\t\t\t\t\t<lib-estremi-persona-fisica [ngxsFormPath]=\"estremiPFExtraSepaFormPath\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[province]=\"province\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[nazioni]=\"nazioni\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[isPersonaFisicaValid]=\"isPersonaFisicaExtraSepaValid\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[personaFisica]=\"bonificoExtraSepa?.delegatoRiscossione\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[viewSessoPF]=\"viewSessoPF\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(validatePersonaFisicaEmitter)=\"onValidateExtraSepaPersonaFisica()\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(personaFisicaEmitter)=\"onDelegatoRiscossioneReady($event)\">\r\n\t\t\t\t\t</lib-estremi-persona-fisica>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<lib-dati-residenza [validateAndGetResidenza]=\"validateAndGetResidenza\"></lib-dati-residenza>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<div class=\"row mt-4\">\r\n\t\t<div class=\"col-md-8\">\r\n\t\t\t<label id=\"existsBicSwiftLabel\">{{ \"exists-bic-swift\" | traduzione }}</label>\r\n\t\t\t<mat-radio-group class=\"radio-group\"\r\n\t\t\t\t\t\t\t aria-labelledby=\"existsBicSwiftLabel\"\r\n\t\t\t\t\t\t\t formControlName=\"swiftBicPresent\">\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"true\">\r\n\t\t\t\t\t{{ \"si\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"false\">\r\n\t\t\t\t\t{{ \"no\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\t\t\t</mat-radio-group>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<div *ngIf=\"extraSepaForm.controls['swiftBicPresent'].value; else noswiftBic\" class=\"row\">\r\n\t\t<div class=\"col-md-8\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input matInput placeholder=\"{{ 'required' | traduzione }}{{ 'swift' | traduzione }}\" formControlName=\"swift\" />\r\n\t\t\t\t<!-- <mat-error *ngIf=\"extraSepaForm.controls['swift'].invalid\">\r\n\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['swift']) | traduzione }}\r\n\t\t\t\t</mat-error> -->\r\n\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['swift']?.hasError('required')\">\r\n\t\t\t\t\t{{'validation-required'| traduzione}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['swift']?.hasError('minlength')\">\r\n\t\t\t\t\t{{'validation-swift-min' | traduzione}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['swift']?.hasError('maxlength')\">\r\n\t\t\t\t\t{{'validation-swift-max' | traduzione}}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<ng-template #noswiftBic>\r\n\t\t<div class=\"row my-4 mt-4\">\r\n\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'nazione' | traduzione }}</mat-label>\r\n\t\t\t\t\t<mat-select [placeholder]=\"'seleziona' | traduzione\" formControlName=\"nazione\" [compareWith]=\"byCode\">\r\n\t\t\t\t\t\t<mat-option *ngFor=\"let nazione of nazioni\" [value]=\"nazione\">\r\n\t\t\t\t\t\t\t{{ nazione.denominazione }}\r\n\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['nazione'].invalid\">\r\n\t\t\t\t\t\t{{ 'obbligatorio' | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<input matInput [maxlength]=\"70\" formControlName=\"banca\" placeholder=\"{{ 'required' | traduzione }}{{ 'banca' | traduzione }}\" />\r\n\t\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['banca'].invalid\">\r\n\t\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['banca']) | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<input matInput [maxlength]=\"35\" placeholder=\"{{ 'required' | traduzione }}{{ 'citta' | traduzione }}\" formControlName=\"citta\" />\r\n\t\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['citta'].invalid\">\r\n\t\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['citta']) | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<div class=\"row mt-4\">\r\n\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<input matInput [maxlength]=\"70\" formControlName=\"indirizzo\" placeholder=\"{{ 'required' | traduzione }}{{ 'indirizzo' | traduzione }}\" />\r\n\t\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['indirizzo'].invalid\">\r\n\t\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['indirizzo']) | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<input matInput [maxlength]=\"16\" placeholder=\"{{ 'required' | traduzione }}{{ 'civico' | traduzione }}\" formControlName=\"civico\" />\r\n\t\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['civico'].invalid\">\r\n\t\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['civico']) | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"col-md-4\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<input matInput [maxlength]=\"16\" placeholder=\"{{ 'required' | traduzione }}{{ 'cap-estero' | traduzione }}\" formControlName=\"zipCode\" />\r\n\t\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['zipCode'].invalid\">\r\n\t\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['zipCode']) | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</ng-template>\r\n\r\n\t<div class=\"row mt-4\">\r\n\t\t<div class=\"col-md-8\">\r\n\t\t\t<mat-radio-group class=\"radio-group\" aria-labelledby=\"codiceContoPresentLabel\" formControlName=\"codiceContoPresent\">\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"true\">\r\n\t\t\t\t\t{{ \"codice-conto\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\r\n\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"false\">\r\n\t\t\t\t\t{{ \"codice-iban\" | traduzione }}\r\n\t\t\t\t</mat-radio-button>\r\n\t\t\t</mat-radio-group>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<div class=\"row mt-4\">\r\n\t\t<div class=\"col-md-8\" *ngIf=\"extraSepaForm.controls['codiceContoPresent'].value; else iban\">\r\n\t\t\t<mat-form-field>\r\n\t\t\t\t<input matInput placeholder=\"{{ 'required' | traduzione }}{{ 'codice-conto' | traduzione }}\"\r\n\t\t\t\t\tformControlName=\"codiceConto\"\r\n\t\t\t\t\t(input)=\"convertToUppercase($event.target.value)\" />\r\n\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['codiceConto'].invalid\">\r\n\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['codiceConto']) | traduzione }}\r\n\t\t\t\t</mat-error>\r\n\t\t\t</mat-form-field>\r\n\t\t</div>\r\n\r\n\t\t<ng-template #iban>\r\n\t\t\t<div class=\"col-md-8\">\r\n\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t<input matInput placeholder=\"{{ 'required' | traduzione }}{{ 'codice-iban' | traduzione }}\"\r\n\t\t\t\t\t\tformControlName=\"iban\"\r\n\t\t\t\t\t\t(input)=\"convertToUppercase($event.target.value)\" />\r\n\t\t\t\t\t<mat-error *ngIf=\"extraSepaForm.controls['iban'].invalid\">\r\n\t\t\t\t\t\t{{ getErrorMessage(extraSepaForm.controls['iban']) | traduzione }}\r\n\t\t\t\t\t</mat-error>\r\n\t\t\t\t</mat-form-field>\r\n\t\t\t</div>\r\n\t\t</ng-template>\r\n\t</div>\r\n</ng-container>\r\n",
                styles: [""]
            },] }
];
BonificoExtraSepaComponent.ctorParameters = () => [];
BonificoExtraSepaComponent.propDecorators = {
    bonificoExtraSepa: [{ type: Input }],
    isPersonaFisicaExtraSepaValid: [{ type: Input }],
    nazioni: [{ type: Input }],
    province: [{ type: Input }],
    extraSepaFormPath: [{ type: Input }],
    estremiPFExtraSepaFormPath: [{ type: Input }],
    viewSessoPF: [{ type: Input }],
    validateAndGetResidenza: [{ type: Input }],
    validateExtraSepaPersonaFisicaEmitter: [{ type: Output }],
    resetEstremiPersonaFisicaExtraSepaFormEmitter: [{ type: Output }],
    bonificoExtraSepaReady: [{ type: Output }],
    personaFisicaEmitter: [{ type: Output }]
};

class VagliaBdiComponent {
    constructor(modalitaPagamentoService) {
        this.modalitaPagamentoService = modalitaPagamentoService;
        this.setComuni = new EventEmitter();
        this.getCapOptions = new EventEmitter();
        this.resetIndirizzoForm = new EventEmitter();
        this.vagliaReady = new EventEmitter();
        this.indirizzoEmitter = new EventEmitter();
        this.subscription = new Subscription();
        this.getErrorMessage = getErrorMessage;
        // this.initVagliaForm();
    }
    ngOnInit() {
        this.initVagliaForm();
        this.vagliaForm.setValidators(form => {
            return (!form.get('pec').value && !form.get('email').value) &&
                (form.get('domicilioRichiedenteCoincideConResidenza').value === false) ?
                { requiredMail: true } : null;
        });
        this.subscription.add(this.vagliaForm.controls['domicilioRichiedenteCoincideConResidenza'].valueChanges.subscribe(isDomicilio => {
            if (isDomicilio) {
                this.vagliaForm.controls['nome'].setValidators([]);
                this.vagliaForm.controls['nome'].patchValue(null);
                this.vagliaForm.controls['nome'].updateValueAndValidity();
                this.vagliaForm.controls['cognome'].setValidators([]);
                this.vagliaForm.controls['cognome'].patchValue(null);
                this.vagliaForm.controls['cognome'].updateValueAndValidity();
                this.vagliaForm.controls["email"].patchValue(null);
                this.vagliaForm.controls["pec"].patchValue(null);
                this.vagliaForm.controls["telefono"].patchValue(null);
                this.resetIndirizzoForm.emit();
            }
            else {
                this.vagliaForm.controls['nome'].setValidators([Validators.required, ValidateName]),
                    this.vagliaForm.controls['nome'].updateValueAndValidity();
                this.vagliaForm.controls['cognome'].setValidators([Validators.required, ValidateName]),
                    this.vagliaForm.controls['cognome'].updateValueAndValidity();
            }
        }));
        this.vagliaForm.valueChanges.subscribe(() => {
            // if (this.vagliaForm.valid) {
            const vaglia = {
                intestatarioStudioLegale: this.vagliaForm.get('intestatoSudioLegale').value,
                domicilioRichiedenteCoincideConResidenza: this.vagliaForm.get('domicilioRichiedenteCoincideConResidenza').value,
                nome: this.vagliaForm.get('nome').value,
                denominazione: this.vagliaForm.get('cognome').value,
                contatti: this.vagliaForm.get('domicilioRichiedenteCoincideConResidenza').value === true ? null :
                    {
                        email: this.vagliaForm.get('email').value,
                        pec: this.vagliaForm.get('pec').value,
                        telefono: this.vagliaForm.get('telefono').value,
                    },
                indirizzo: this.vagliaForm.get('domicilioRichiedenteCoincideConResidenza').value === true ? null : this.indirizzo
            };
            const isFormValid = this.vagliaForm.valid;
            const isFormIndirizzoValid = this.vagliaForm.get('domicilioRichiedenteCoincideConResidenza').value === true ? true : this.isIndirizzoValid;
            const isValid = isFormValid && isFormIndirizzoValid;
            this.vagliaReady.emit({ vaglia: vaglia, isValid });
            //}
        });
    }
    initVagliaForm() {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        this.vagliaForm = new FormGroup({
            nome: new FormControl((_a = this.vagliaBDI) === null || _a === void 0 ? void 0 : _a.nome),
            cognome: new FormControl((_b = this.vagliaBDI) === null || _b === void 0 ? void 0 : _b.denominazione),
            email: new FormControl((_d = (_c = this.vagliaBDI) === null || _c === void 0 ? void 0 : _c.contatti) === null || _d === void 0 ? void 0 : _d.email, [this.ValidateMail, Validators.maxLength(200)]),
            pec: new FormControl((_f = (_e = this.vagliaBDI) === null || _e === void 0 ? void 0 : _e.contatti) === null || _f === void 0 ? void 0 : _f.pec, [this.ValidateMail, Validators.maxLength(200)]),
            telefono: new FormControl((_h = (_g = this.vagliaBDI) === null || _g === void 0 ? void 0 : _g.contatti) === null || _h === void 0 ? void 0 : _h.telefono, [ValidatePhone]),
            intestatoSudioLegale: new FormControl(this.vagliaBDI != null ? this.vagliaBDI.intestatarioStudioLegale : false, this.isAntistatario ? [Validators.required] : null),
            domicilioRichiedenteCoincideConResidenza: new FormControl(this.vagliaBDI != null ? this.vagliaBDI.domicilioRichiedenteCoincideConResidenza : false, [Validators.required]),
        });
    }
    getComuni(siglaProvincia) {
        if (siglaProvincia) {
            this.modalitaPagamentoService.getComuni$(siglaProvincia).pipe(take(1))
                .subscribe(comuni => {
                this.setComuni.emit(comuni);
                const comune = comuni.find(comuneItem => comuneItem.codiceCatastale === this.codiceCatastale);
                this.getCapOptions.emit(comune === null || comune === void 0 ? void 0 : comune.codiceIstat);
            });
        }
        else {
            this.setComuni.emit([]);
        }
    }
    getCap(codiceCatastale) {
        var _a;
        if (codiceCatastale) {
            this.codiceCatastale = codiceCatastale;
        }
        const comune = (_a = this.comuni) === null || _a === void 0 ? void 0 : _a.find(comuneItem => comuneItem.codiceCatastale === codiceCatastale);
        this.getCapOptions.emit(comune === null || comune === void 0 ? void 0 : comune.codiceIstat);
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    ValidateMail(control) {
        if (!control.value) {
            return null;
        }
        const formatoEmail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
        if (formatoEmail.test(control.value)) {
            return null;
        }
        return { invalidMail: true };
    }
    onIndirizzoReady(event) {
        this.indirizzo = event.indirizzo;
        this.isIndirizzoValid = event.isValid;
        this.indirizzoEmitter.emit({ indirizzo: event.indirizzo, isValid: event.isValid });
    }
}
VagliaBdiComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-vaglia-bdi',
                template: "<form [formGroup]=\"vagliaForm\" [ngxsForm]=\"vagliaFormPath\">\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-12\">\r\n\t\t\t<div class=\"col-12\">\r\n\t\t\t\t<h3 class=\"h5 mb-0\">{{ \"accreditamento-bdi\" | traduzione }}</h3>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"col-md-12 my-3\">\r\n\t\t\t\t<div class=\"alert alert-primary\" role=\"alert\">\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\t{{ \"nota-bdi\" | traduzione }}\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-12\">\r\n\t\t\t\t\t<mat-radio-group class=\"radio-group\"\r\n\t\t\t\t\t\t\t\t\taria-labelledby=\"radio-group-label-1\"\r\n\t\t\t\t\t\t\t\t\tformControlName=\"domicilioRichiedenteCoincideConResidenza\">\r\n\t\t\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"true\">\r\n\t\t\t\t\t\t\t{{ \"domicilio-coincide-con-residenza\" | traduzione }}\r\n\t\t\t\t\t\t</mat-radio-button>\r\n\t\t\t\t\t\t<mat-radio-button class=\"radio-button pl-2\" [value]=\"false\">\r\n\t\t\t\t\t\t\t{{ \"domicilio-non-coincide-con-residenza\" | traduzione }}\r\n\t\t\t\t\t\t</mat-radio-button>\r\n\t\t\t\t\t</mat-radio-group>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"col-12\" *ngIf=\"!vagliaForm.controls['domicilioRichiedenteCoincideConResidenza'].value\">\r\n\t\t\t\t<div class=\"row my-2\">\r\n\t\t\t\t\t<div class=\"col-md-6\">\r\n\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t<input matInput [maxlength]=\"100\" placeholder=\"{{ 'required' | traduzione }}{{ 'nome' | traduzione }}\" formControlName=\"nome\" />\r\n\t\t\t\t\t\t\t<mat-error *ngIf=\"vagliaForm.controls['nome'].invalid\">\r\n\t\t\t\t\t\t\t\t{{ getErrorMessage(vagliaForm.controls['nome']) | traduzione }}\r\n\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"col-md-6\">\r\n\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t<input matInput [maxlength]=\"100\" placeholder=\"{{ 'required' | traduzione }}{{ 'denominazione' | traduzione }}\" formControlName=\"cognome\" />\r\n\t\t\t\t\t\t\t<mat-error *ngIf=\"vagliaForm.controls['cognome'].invalid\">\r\n\t\t\t\t\t\t\t\t{{ getErrorMessage(vagliaForm.controls['cognome']) | traduzione }}\r\n\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<lib-indirizzo-pagamento [ngxsFormPath]=\"indirizzoVagliaFormPath\"\r\n\t\t\t\t\t\t\t\t[nazioni]=\"nazioni\"\r\n\t\t\t\t\t\t\t\t[province]=\"province\"\r\n\t\t\t\t\t\t\t\t[comuni]=\"comuni\"\r\n\t\t\t\t\t\t\t\t[capOptions]=\"capOptions\"\r\n\t\t\t\t\t\t\t\t[indirizzo]=\"vagliaBDI?.indirizzo\"\r\n\t\t\t\t\t\t\t\t(selectedProvinciaEmitter)=\"getComuni($event)\"\r\n\t\t\t\t\t\t\t\t(selectedComuneEmitter)=\"getCap($event)\"\r\n\t\t\t\t\t\t\t\t(indirizzoEmitter)=\"onIndirizzoReady($event)\">\r\n\t\t\t\t>\r\n\t\t\t\t</lib-indirizzo-pagamento>\r\n\t\t\t\t<div class=\"row mt-2\">\r\n\t\t\t\t\t<div class=\"col-12 col-md-4\">\r\n\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{'email' | traduzione}}</mat-label>\r\n\t\t\t\t\t\t\t<input matInput formControlName=\"email\" />\r\n\t\t\t\t\t\t\t<mat-error *ngIf=\"vagliaForm.controls['email'].invalid\">\r\n\t\t\t\t\t\t\t\t{{ getErrorMessage(vagliaForm.controls['email']) | traduzione }}\r\n\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"col-12 col-md-4\">\r\n\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{'pec' | traduzione}}</mat-label>\r\n\t\t\t\t\t\t\t<input matInput formControlName=\"pec\" />\r\n\t\t\t\t\t\t\t<mat-error *ngIf=\"vagliaForm.controls['pec'].invalid\">\r\n\t\t\t\t\t\t\t\t{{ getErrorMessage(vagliaForm.controls['pec']) | traduzione }}\r\n\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"col-12 col-md-4\">\r\n\t\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t\t<mat-label>{{ \"telefono\" | traduzione }}</mat-label>\r\n\t\t\t\t\t\t\t<input matInput  [maxlength]=\"20\" formControlName=\"telefono\" />\r\n\t\t\t\t\t\t\t<mat-error *ngIf=\"vagliaForm.controls['telefono'].invalid\">\r\n\t\t\t\t\t\t\t\t{{ getErrorMessage(vagliaForm.controls['telefono']) | traduzione }}\r\n\t\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"col-md-12\">\r\n\t\t\t\t\t\t<mat-error *ngIf=\"vagliaForm.getError('requiredMail')\">\r\n\t\t\t\t\t\t\t{{ \"validation-requiredMail\" | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<ng-container *ngIf=\"isAntistatario\">\r\n\t\t\t\t<div class=\"col-12 mt-3\">\r\n\t\t\t\t\t<h3 class=\"h5 mb-0\">{{ \"intestatario\" | traduzione }}</h3>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-md-12 my-3\">\r\n\t\t\t\t\t<mat-radio-group class=\"radio-group\" aria-labelledby=\"radio-group-label-1\" formControlName=\"intestatoSudioLegale\">\r\n\t\t\t\t\t\t<mat-radio-button class=\"radio-button\" [value]=\"false\">{{ \"me-medesimo\" | traduzione }} </mat-radio-button>\r\n\t\t\t\t\t\t<mat-radio-button class=\"pl-3 radio-button\" [value]=\"true\">{{ \"studio-legale\" | traduzione }} </mat-radio-button>\r\n\t\t\t\t\t</mat-radio-group>\r\n\t\t\t\t</div>\r\n\t\t\t</ng-container>\r\n\t\t</div>\r\n\t</div>\r\n</form>\r\n\r\n",
                styles: [""]
            },] }
];
VagliaBdiComponent.ctorParameters = () => [
    { type: ModalitaPagamentoService }
];
VagliaBdiComponent.propDecorators = {
    vagliaBDI: [{ type: Input }],
    comuni: [{ type: Input }],
    capOptions: [{ type: Input }],
    isAntistatario: [{ type: Input }],
    nazioni: [{ type: Input }],
    province: [{ type: Input }],
    vagliaFormPath: [{ type: Input }],
    indirizzoVagliaFormPath: [{ type: Input }],
    setComuni: [{ type: Output }],
    getCapOptions: [{ type: Output }],
    resetIndirizzoForm: [{ type: Output }],
    vagliaReady: [{ type: Output }],
    indirizzoEmitter: [{ type: Output }]
};

class IndirizzoPagamentoComponent {
    constructor() {
        this.selectedProvinciaEmitter = new EventEmitter();
        this.selectedComuneEmitter = new EventEmitter();
        this.indirizzoEmitter = new EventEmitter();
        this.subscription = new Subscription();
        // this.initIndirizzoForm();
        // this.subscription.add(this.indirizzoForm.controls['isEstero'].valueChanges.subscribe(isEstero => {
        // 	this.indirizzoForm.controls['civico'].setValidators(isEstero ? [] : [Validators.required]);
        // 	this.indirizzoForm.controls['civico'].patchValue(null);
        // 	this.indirizzoForm.controls['civico'].updateValueAndValidity();
        // 	this.indirizzoForm.controls['provincia'].setValidators(isEstero ? [] : [Validators.required]);
        // 	this.indirizzoForm.controls['provincia'].patchValue(null);
        // 	this.indirizzoForm.controls['provincia'].updateValueAndValidity();
        // 	this.indirizzoForm.controls['comune'].setValidators(isEstero ? [] : [Validators.required]);
        // 	this.indirizzoForm.controls['comune'].patchValue(null);
        // 	this.indirizzoForm.controls['comune'].updateValueAndValidity();
        // 	this.indirizzoForm.controls['cap'].setValidators(isEstero ? [] : [Validators.required]);
        // 	this.indirizzoForm.controls['cap'].patchValue(null);
        // 	this.indirizzoForm.controls['cap'].updateValueAndValidity();
        // 	this.indirizzoForm.controls['nazione'].setValidators(isEstero ? [Validators.required] : []);
        // 	this.indirizzoForm.controls['nazione'].patchValue(null);
        // 	this.indirizzoForm.controls['nazione'].updateValueAndValidity();
        // }));
        // this.subscription.add(this.indirizzoForm.controls['provincia'].valueChanges.subscribe(siglaProvincia => this.selectedProvinciaEmitter.emit(siglaProvincia)));
        // this.subscription.add(this.indirizzoForm.controls['comune'].valueChanges.subscribe(codiceCatastale => this.selectedComuneEmitter.emit(codiceCatastale)));
    }
    set _disableForm(val) {
        this.disableForm = val;
        if (this.disableForm) {
            this.indirizzoForm.disable();
        }
        else {
            this.indirizzoForm.enable();
        }
    }
    ngOnInit() {
        this.initIndirizzoForm();
        this.setFormControlsValue();
        this.subscription.add(this.indirizzoForm.controls['isEstero'].valueChanges.subscribe(isEstero => {
            this.indirizzoForm.controls['civico'].setValidators(isEstero ? [] : [Validators.required]);
            this.indirizzoForm.controls['civico'].patchValue(null);
            this.indirizzoForm.controls['civico'].updateValueAndValidity();
            this.indirizzoForm.controls['provincia'].setValidators(isEstero ? [] : [Validators.required]);
            this.indirizzoForm.controls['provincia'].patchValue(null);
            this.indirizzoForm.controls['provincia'].updateValueAndValidity();
            this.indirizzoForm.controls['comune'].setValidators(isEstero ? [] : [Validators.required]);
            this.indirizzoForm.controls['comune'].patchValue(null);
            this.indirizzoForm.controls['comune'].updateValueAndValidity();
            this.indirizzoForm.controls['cap'].setValidators(isEstero ? [] : [Validators.required]);
            this.indirizzoForm.controls['cap'].patchValue(null);
            this.indirizzoForm.controls['cap'].updateValueAndValidity();
            this.indirizzoForm.controls['nazione'].setValidators(isEstero ? [Validators.required] : []);
            this.indirizzoForm.controls['nazione'].patchValue(null);
            this.indirizzoForm.controls['nazione'].updateValueAndValidity();
        }));
        this.subscription.add(this.indirizzoForm.controls['provincia'].valueChanges.subscribe(siglaProvincia => this.selectedProvinciaEmitter.emit(siglaProvincia)));
        this.subscription.add(this.indirizzoForm.controls['comune'].valueChanges.subscribe(codiceCatastale => this.selectedComuneEmitter.emit(codiceCatastale)));
        this.indirizzoEmit();
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    initIndirizzoForm() {
        this.indirizzoForm = new FormGroup({
            isEstero: new FormControl(null),
            indirizzo: new FormControl(null, [Validators.required]),
            nazione: new FormControl(null),
            civico: new FormControl(null),
            provincia: new FormControl(null),
            comune: new FormControl(null),
            cap: new FormControl(null),
        });
    }
    onProvinciaChange(siglaProvincia) {
        this.indirizzoForm.controls['comune'].patchValue(null);
        this.indirizzoForm.controls['comune'].markAsTouched();
        this.indirizzoForm.controls['cap'].patchValue(null);
        this.indirizzoForm.controls['cap'].markAsTouched();
    }
    onComuneChange(codiceCatastale) {
        this.indirizzoForm.controls['cap'].patchValue(null);
        this.indirizzoForm.controls['cap'].markAsTouched();
    }
    indirizzoEmit() {
        this.subscription.add(this.indirizzoForm.valueChanges.pipe(debounceTime(500)).subscribe((_) => {
            const indirizzo = {
                strada: {
                    civico: this.indirizzoForm.controls['civico'].value,
                    inidirizzo: this.indirizzoForm.controls['indirizzo'].value,
                    tipoToponimo: null
                },
                localita: {
                    cap: this.indirizzoForm.controls['cap'].value,
                    comune: this.indirizzoForm.controls['comune'].value,
                    nazione: this.indirizzoForm.controls['nazione'].value,
                    provincia: this.indirizzoForm.controls['provincia'].value
                }
            };
            const isValid = this.indirizzoForm.valid;
            this.indirizzoEmitter.emit({ indirizzo: indirizzo ? indirizzo : null, isValid: isValid });
        }));
    }
    setFormControlsValue() {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
        this.indirizzoForm.controls['isEstero'].setValue(this.indirizzo && ((_b = (_a = this.indirizzo) === null || _a === void 0 ? void 0 : _a.localita) === null || _b === void 0 ? void 0 : _b.comune.startsWith("Z")) ? true : false);
        this.indirizzoForm.controls['indirizzo'].setValue(this.indirizzo ? this.indirizzo.strada.inidirizzo : null);
        this.indirizzoForm.controls['nazione'].setValue(this.indirizzo ? (_d = (_c = this.indirizzo) === null || _c === void 0 ? void 0 : _c.localita) === null || _d === void 0 ? void 0 : _d.nazione : null);
        this.indirizzoForm.controls['civico'].setValue(this.indirizzo ? this.indirizzo.strada.civico : null);
        this.indirizzoForm.controls['provincia'].setValue(this.indirizzo && !((_f = (_e = this.indirizzo) === null || _e === void 0 ? void 0 : _e.localita) === null || _f === void 0 ? void 0 : _f.comune.startsWith("Z")) ? this.indirizzo.localita.provincia : null);
        this.indirizzoForm.controls['comune'].setValue(this.indirizzo && !((_h = (_g = this.indirizzo) === null || _g === void 0 ? void 0 : _g.localita) === null || _h === void 0 ? void 0 : _h.comune.startsWith("Z")) ? this.indirizzo.localita.comune : null);
        this.indirizzoForm.controls['cap'].setValue(this.indirizzo && !((_k = (_j = this.indirizzo) === null || _j === void 0 ? void 0 : _j.localita) === null || _k === void 0 ? void 0 : _k.comune.startsWith("Z")) ? this.indirizzo.localita.cap : null);
    }
}
IndirizzoPagamentoComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-indirizzo-pagamento',
                template: "<form [formGroup]=\"indirizzoForm\" [ngxsForm]=\"ngxsFormPath\">\r\n\t<div class=\"row\">\r\n\t\t<div class=\"col-12\">\r\n\t\t\t<div class=\"row align-items-center\">\r\n\t\t\t\t<div class=\"col-12 col-md-4\">\r\n\t\t\t\t\t<mat-checkbox formControlName=\"isEstero\" color=\"primary\">\r\n\t\t\t\t\t\t<info-tip-label label=\"indirizzo-estero\"></info-tip-label>\r\n\t\t\t\t\t</mat-checkbox>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-12 col-md-4\" *ngIf=\"indirizzoForm.controls['isEstero'].value\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'nazione' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"nazione\">\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let nazione of nazioni\" [value]=\"nazione.codiceCatastale\">\r\n\t\t\t\t\t\t\t\t{{ nazione.denominazione }}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"indirizzoForm.controls['nazione'].invalid\">\r\n\t\t\t\t\t\t\t{{ 'validation-required' | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-12\" [ngClass]=\"indirizzoForm.controls['isEstero'].value ? ' col-md-8': ' col-md-10'\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{'indirizzo' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<input [maxlength]=\"70\" formControlName=\"indirizzo\" matInput>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"indirizzoForm.controls['indirizzo'].invalid\">\r\n\t\t\t\t\t\t\t{{ 'validation-required' | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-12 col-md-2\" *ngIf=\"!indirizzoForm.controls['isEstero'].value\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{'civico' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<input [maxlength]=\"16\" formControlName=\"civico\" matInput>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"indirizzoForm.controls['civico'].invalid\">\r\n\t\t\t\t\t\t\t{{ 'validation-required' | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\t<div class=\"row\" *ngIf=\"!indirizzoForm.controls['isEstero'].value\">\r\n\t\t\t\t<div class=\"col-12 col-md-5\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'provincia' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"provincia\" (valueChange)=\"onProvinciaChange($event)\">\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let provincia of province\" [value]=\"provincia.sigla\">\r\n\t\t\t\t\t\t\t\t{{ provincia.denominazione }}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"indirizzoForm.controls['provincia'].invalid\">\r\n\t\t\t\t\t\t\t{{ 'validation-required' | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-12 col-md-5\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'comune' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"comune\" (valueChange)=\"onComuneChange($event)\">\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let comune of comuni\" [value]=\"comune.codiceCatastale\">\r\n\t\t\t\t\t\t\t\t{{ comune.denominazione }}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"indirizzoForm.controls['comune'].invalid\">\r\n\t\t\t\t\t\t\t{{ 'validation-required' | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"col-12 col-md-2\">\r\n\t\t\t\t\t<mat-form-field>\r\n\t\t\t\t\t\t<mat-label>{{ 'required' | traduzione }}{{ 'cap' | traduzione }}</mat-label>\r\n\t\t\t\t\t\t<mat-select formControlName=\"cap\">\r\n\t\t\t\t\t\t\t<mat-option *ngFor=\"let cap of capOptions\" [value]=\"cap\">\r\n\t\t\t\t\t\t\t\t{{ cap }}\r\n\t\t\t\t\t\t\t</mat-option>\r\n\t\t\t\t\t\t</mat-select>\r\n\t\t\t\t\t\t<mat-error *ngIf=\"indirizzoForm.controls['cap'].invalid\">\r\n\t\t\t\t\t\t\t{{ 'validation-required' | traduzione }}\r\n\t\t\t\t\t\t</mat-error>\r\n\t\t\t\t\t</mat-form-field>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</div>\r\n</form>\r\n\r\n\r\n",
                styles: [""]
            },] }
];
IndirizzoPagamentoComponent.ctorParameters = () => [];
IndirizzoPagamentoComponent.propDecorators = {
    ngxsFormPath: [{ type: Input }],
    nazioni: [{ type: Input }],
    province: [{ type: Input }],
    comuni: [{ type: Input }],
    capOptions: [{ type: Input }],
    indirizzo: [{ type: Input }],
    _disableForm: [{ type: Input, args: ['disableForm',] }],
    selectedProvinciaEmitter: [{ type: Output }],
    selectedComuneEmitter: [{ type: Output }],
    indirizzoEmitter: [{ type: Output }]
};

class DatiResidenzaComponent$1 {
    constructor() { }
    ngOnInit() {
    }
}
DatiResidenzaComponent$1.decorators = [
    { type: Component, args: [{
                selector: 'lib-dati-residenza',
                template: "<div class=\"row mt-4\">\n\t<div class=\"col-12\">\n\t\t<mat-expansion-panel class=\"panel\" [expanded]=\"true\" *ngIf=\"validateAndGetResidenza !=null && validateAndGetResidenza?.valido\">\n\t\t\t<mat-expansion-panel-header [collapsedHeight]=\"'48px'\" [expandedHeight]=\"'48px'\" class=\"custom-header\">\n\t\t\t\t<mat-panel-title>\n\t\t\t\t\t<h3 class=\"h5 mb-0\"><info-tip-label label=\"dati-residenza\"></info-tip-label></h3>\n\t\t\t\t</mat-panel-title>\n\t\t\t</mat-expansion-panel-header>\n\t\t\t<div class=\"collapse-body mt-2\">\n\t\t\t\t<ng-container>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<div class=\"col-md-4\">\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'nazione' | traduzione }}:</p>\n\t\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"nazioneToltip\"></mat-hint> -->\n\t\t\t\t\t\t\t<p>{{validateAndGetResidenza?.residenza?.nazione?.denominazione}}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div *ngIf=\"!validateAndGetResidenza?.residenza.estero\" class=\"col-md-8\">\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'regione' | traduzione }}:</p>\n\t\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"regioneToltip\"></mat-hint> -->\n\t\t\t\t\t\t\t<p>{{validateAndGetResidenza?.residenza?.regione?.denominazione}}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<div class=\"col-md-4\">\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'indirizzo' | traduzione }}:</p>\n\t\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"indirizzoToltip\"></mat-hint> -->\n\t\t\t\t\t\t\t<p>{{validateAndGetResidenza?.residenza?.indirizzo}}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div *ngIf=\"!validateAndGetResidenza?.residenza.estero\" class=\"col-md-8\">\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'civico' | traduzione }}:</p>\n\t\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"civicoToltip\"></mat-hint> -->\n\t\t\t\t\t\t\t<p>{{validateAndGetResidenza?.residenza?.civico}}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div *ngIf=\"!validateAndGetResidenza?.residenza.estero\" class=\"row\">\n\t\t\t\t\t\t<div class=\"col-md-4\">\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'provincia' | traduzione }}:</p>\n\t\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"provinciaToltip\"></mat-hint> -->\n\t\t\t\t\t\t\t<p>{{validateAndGetResidenza?.residenza?.provincia?.denominazione}}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-md-4\">\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'comune' | traduzione }}:</p>\n\t\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"comuneToltip\"></mat-hint> -->\n\t\t\t\t\t\t\t<p>{{validateAndGetResidenza?.residenza?.comune?.denominazione}}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-md-4\">\n\t\t\t\t\t\t\t<p class=\"mb-0 font-weight-bold\">{{'cap' | traduzione }}:</p>\n\t\t\t\t\t\t\t<!-- <mat-hint *infoTip=\"capToltip\"></mat-hint> -->\n\t\t\t\t\t\t\t<p>{{validateAndGetResidenza?.residenza?.cap}}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</ng-container>\n\t\t\t</div>\n\t\t</mat-expansion-panel>\n\t</div>\n</div>\n",
                styles: [""]
            },] }
];
DatiResidenzaComponent$1.ctorParameters = () => [];
DatiResidenzaComponent$1.propDecorators = {
    validateAndGetResidenza: [{ type: Input }]
};

class ModalitaPagamentoModule {
}
ModalitaPagamentoModule.decorators = [
    { type: NgModule, args: [{
                declarations: [
                    BonificoSepaComponent,
                    EstremiPersonaFisicaComponent,
                    BonificoExtraSepaComponent,
                    VagliaBdiComponent,
                    IndirizzoPagamentoComponent,
                    DatiResidenzaComponent$1
                ],
                imports: [
                    CommonModule,
                    HttpClientModule,
                    ReactiveFormsModule,
                    NgxsFormPluginModule,
                    MatFormFieldModule,
                    MatSelectModule,
                    TranslateModule,
                    MatInputModule,
                    MatRadioModule,
                    InfoTipModule,
                    MatDatepickerModule,
                    MatCheckboxModule,
                    MatExpansionModule
                ],
                exports: [
                    BonificoSepaComponent,
                    EstremiPersonaFisicaComponent,
                    BonificoExtraSepaComponent,
                    VagliaBdiComponent,
                    IndirizzoPagamentoComponent
                ],
                providers: []
            },] }
];

const modalitaPagamentoExtraSepaFormDefaults = {
    existsDelegatoRiscossione: false,
    swift: null,
    banca: null,
    indirizzo: null,
    codiceContoPresent: false,
    codiceConto: null,
    iban: null,
    swiftBicPresent: false,
    nazione: null,
    citta: null,
    zipCode: null
};

const modalitaPagamentoVagliaFormDefaults = {
    nome: null,
    cognome: null,
    email: null,
    pec: null,
    telefono: null,
    intestatoSudioLegale: false,
    domicilioRichiedenteCoincideConResidenza: false
};

class Country {
}

class ModalitaPagamentoExtraSepaForm {
}

const PG = "PG";
const PF = "PF";
const AN = "AN";
class TipoAttore {
}
const TIPOLOGIE_ATTORE = [
    { value: false, descrizione: "richiedente" },
    { value: true, descrizione: "incaricato-alla-trasmissione" },
];
class TipologiaRichiedente {
    isIncaricato() {
        return this.incaricatoTrasmissione;
    }
    isPersonaGiuridica() {
        var _a;
        return ((_a = this.tipoRicorrente) === null || _a === void 0 ? void 0 : _a.codice) == PG;
    }
    isPersonaFisica() {
        var _a;
        return ((_a = this.tipoRicorrente) === null || _a === void 0 ? void 0 : _a.codice) == PF;
    }
    isAntistatario() {
        var _a;
        return ((_a = this.tipoRicorrente) === null || _a === void 0 ? void 0 : _a.codice) == AN;
    }
}

const EMPTY_INDIRIZZO_MODEL = {
    cap: '',
    civico: '',
    comune: {
        codiceCatastale: '',
        codiceIstat: '',
        denominazione: ''
    },
    estero: false,
    id: null,
    indirizzo: '',
    nazione: {
        codiceCatastale: '',
        denominazione: '',
        sigla: '',
        id: ''
    },
    presso: '',
    provincia: {
        denominazione: '',
        sigla: ''
    },
    regione: {
        denominazione: '',
        sigla: ''
    }
};

class ModalitaPagamentoVagliaForm {
}

/*
 * Public API Surface of portal-common-component-lib
 */

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

export { AccettazioneComponent, AllegatiComponent, AllegatiModule, AltriSoggettiComponent, AltriSoggettiGiudiziarioDTO, AltriSoggettiNoEsproprioDTO, AutoritaEsproprianteDTO, AutoritaOrdinanteDTO, Azione, BonificoExtraSepaComponent, BonificoSepaComponent, BozzaDepositoDTO, ComponentOutputStatus, ComponentReducer, ComuneDTO, ConfigurationModule, ContattiComponent, ContattoDTO, CostituzioneDepositoCauzionaleDTO, CostituzioneDepositoDTO, CostituzioneDepositoEsproprioDTO, CostituzioneDepositoGiudiziarioDTO, CostituzioneDepositoNoEsproprioDTO, CostituzioneDepositoVolontarioDTO, Country, CreazioneBozzaResponse, CronologiaStatoDTO, DatiDeposito, DatiDepositoDTO, DatiDepositoGiudiziarioDTO, DatiDepositoNoEsproprioDTO, DatiOperaDTO, DatiRichiedenteDTO, DatiTribunaleComponent, DelegheComponent, DelegheService, DepositiModule, DichiarazioneDTO, DocumentazioneComponent, DocumentoDTO, DomicilioDTO, EMPTY_INDIRIZZO_MODEL, EnteRichiedenteCauzioneDTO, EstremiPersonaFisicaComponent, GenericModalComponent, GenericModalData, IdentificativoRichiestaDTO, IndirizzoComponent, IndirizzoDTO, IndirizzoPagamentoComponent, InfoAnagrafichePFDTO, InfoNascitaPFDTO, InfoTip, InfoTipLabelComponent, InfoTipModule, ListaPagamentiComponent, LocalitaDTO, MY_DATE_FORMATS, MessageService, MieDelegheDTO, ModalitaPagamentoDTO, ModalitaPagamentoExtraSepaForm, ModalitaPagamentoModule, ModalitaPagamentoVagliaForm, Modals, NaturaRichiedenteDTO, NaturaRichiedenteRequestDTO, NazioneDTO, ORGANO_CORTE_DI_APPELLO, ORGANO_TAR, PagamentiModule, PagamentoComponent, ParticellaDTO, PersonaFisicaComponent, PersonaFisicaDTO, PersonaGiuridicaComponent, PersonaGiuridicaDTO, PfComponent, PgComponent, ProprietarioDTO, ProvinciaDTO, RappresentanteDTO, RicercaPfComponent, RicercaPgComponent, RichiedenteComponent, RtsDTO, StepperNavigatorComponent, StradaDTO, TIPOLOGIE_ATTORE, TRIBUNALE, TabellaSediComponent, TerritorioService, TipiDocumentoRequestDTO, TipoAttore, TipoDocumento, TipoDocumentoDTO, TipologiaDepositoComponent, TipologiaRichiedente, TipologicaDTO, TipologicheService, TranslateModule, TranslatePipe, TranslateService, TribunaleDTO, UpperCaseDirective, UppercaseModule, Utente, UtenteService, VagliaBdiComponent, ValidateCodiceFiscale, ValidateCodiceFiscalePIVA, ValidateDate, ValidateIban, ValidateImportoFormato, ValidateMail, ValidateName, ValidatePartitaIva, ValidatePassword, ValidatePhone, ValidatoreSwift, ValidazioneData, _codiceFiscalePiva, anno, annotationsOf, bind, capPattern, coalesce, codiceFiscale, codiceFiscalePiva, codiceFiscaleServiceFactory, constructorNameOf, constructorOf, curry, formatoData, formatoEmail, formatoName, formatoSwift, fromIdAndTipo, ftor, getDateErrorMessage, getErrorMessage, given, iban, is, isDefined, isGreaterOrEqualTo, isGreaterThan, isLessOrEqualTo, isLessThan, isNotNull, isNotNullOrUndefined, isNotUndefined, isNull, isNullOrUndefined, isUndefined, lazyApply1, modalitaPagamentoExtraSepaFormDefaults, modalitaPagamentoVagliaFormDefaults, moneyCommaSeparated, moneyCommaSeparatedGreaterThanZero, moneyPattern, nSentenza, not, numRegex, numberPattern, numbers, partial1, partitaIva, passwordPattern, phoneNumberPattern, protoOf, regioneDTO, self, validationMessages, validationServiceFactory, zeroCentoPattern, ɵ0$1 as ɵ0, ɵ1, ɵ10, ɵ11, ɵ12, ɵ13, ɵ14, ɵ15, ɵ16, ɵ17, ɵ18, ɵ19, ɵ2, ɵ20, ɵ21, ɵ22, ɵ23, ɵ24, ɵ25, ɵ26, ɵ27, ɵ3, ɵ4, ɵ5, ɵ6, ɵ7, ɵ8, ɵ9, ConfigurationService as ɵa, CodiceFiscaleServiceImpl as ɵb, CodiceFiscaleService as ɵc, ValidationService as ɵd, DatiAnagraficiComponent as ɵe, DatiDomicilioComponent as ɵf, DatiResidenzaComponent as ɵg, InfoPfComponent as ɵh, InfoNascitaComponent as ɵi, IndirizzoItalianoComponent as ɵj, IndirizzoEsteroComponent as ɵk, StradaComponent as ɵl, LocalitaComponent as ɵm, CaricaDocumentiComponent as ɵn, InfoTipService as ɵo, TabellaDocumentiComponent as ɵp, VisualizzaDettagliComponent as ɵq, InfoTipWrapperComponent as ɵr, DatiPagamentoComponent as ɵs, VisualizzaDettagliComponent$1 as ɵt, FormattaImportoPipe as ɵu, TabellaCronologicaStatiComponent as ɵv, PagamentiService as ɵw, Paths as ɵx, ModalitaPagamentoService as ɵy, DatiResidenzaComponent$1 as ɵz };
//# sourceMappingURL=infordata-web-portal-common-component-lib.js.map