import * as i0 from '@angular/core';
import { Injectable, NgModule, Pipe, InjectionToken, Inject } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { IonIntlTelInputValidators } from 'ion-intl-tel-input';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatBadgeModule } from '@angular/material/badge';
import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatChipsModule } from '@angular/material/chips';
import { MatNativeDateModule, MatOptionModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDialogModule } from '@angular/material/dialog';
import { MatDividerModule } from '@angular/material/divider';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatListModule } from '@angular/material/list';
import { MatMenuModule } from '@angular/material/menu';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatRadioModule } from '@angular/material/radio';
import { MatSelectModule } from '@angular/material/select';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatSliderModule } from '@angular/material/slider';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatSortModule } from '@angular/material/sort';
import { MatStepperModule } from '@angular/material/stepper';
import { MatTableModule } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatTreeModule } from '@angular/material/tree';
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
import { CommonModule } from '@angular/common';
import * as i1 from '@angular/platform-browser';
import * as i1$1 from '@angular/common/http';
import { Subject, BehaviorSubject, of, throwError } from 'rxjs';
import { switchMap, finalize, catchError } from 'rxjs/operators';
import * as i4 from '@angular/router';
import { __awaiter } from 'tslib';
import * as i1$2 from '@ionic/angular';
import * as _ from 'underscore';

const VALIDATOR_CEDULA = 1;
const VALIDATOR_EMAIL = 2;
const VALIDATOR_PASAPORTE = 3;
const VALIDATOR_TELEFONO = 4;

const FEATURE_RISKMATRIX = "riskMatriz";
const FEATURE_OFAC = "ofac";

const INTERCEPTOR_ADMIN = "admin";
const INTERCEPTOR_CUSTOMER = "customer";
const INTERCEPTOR_TYPE = "Itype";
var JuridicUserEnum;
(function (JuridicUserEnum) {
    JuridicUserEnum["juridicInvestor"] = "juridic_investor";
    JuridicUserEnum["juridicBusiness"] = "juridic_business";
})(JuridicUserEnum || (JuridicUserEnum = {}));
var NaturalUserEnum;
(function (NaturalUserEnum) {
    NaturalUserEnum["naturalInvestor"] = "natural_investor";
    NaturalUserEnum["naturalBusiness"] = "natural_business";
})(NaturalUserEnum || (NaturalUserEnum = {}));
const USERTYPES = [
    { value: 'investor', name: 'Inversionista' },
    { value: 'business', name: 'Empresa' }
];
const UserNaturalType = [
    { value: NaturalUserEnum.naturalInvestor, name: 'Inversionista' },
    { value: NaturalUserEnum.naturalBusiness, name: 'Empresa' }
];
const UserJuridicType = [
    { value: JuridicUserEnum.juridicInvestor, name: 'Inversionista' },
    { value: JuridicUserEnum.juridicBusiness, name: 'Empresa' }
];

const FinishPayload = {
    type: 'alert',
    title: 'Finalizar Formulario',
    message: 'Está a punto de finalizar el formulario, Desea continuar?',
    buttonOk: true,
    buttonCancel: true,
};
const CorrectionPayload = {
    type: 'alert',
    title: 'Enviar correcciones de Formulario',
    message: 'Está a punto de enviar las correcciones del formulario, Desea continuar?',
    buttonOk: true,
    buttonCancel: true,
};
const AlertTitle = 'Por favor espere...';
const AlertSubtitle = 'Este proceso puede tardar unos minutos.';

const ThemeType = {
    themeForm: "ThemeForm",
    themeAdminPanel: "ThemeAdminPanel"
};

var FormEstatusEnum;
(function (FormEstatusEnum) {
    FormEstatusEnum["notStarted"] = "NotStarted";
    FormEstatusEnum["submitted"] = "Submitted";
    FormEstatusEnum["verified"] = "Verified";
    FormEstatusEnum["expired"] = "Expired";
    FormEstatusEnum["hasIssues"] = "HasIssues";
    FormEstatusEnum["fillingInProgress"] = "FillingInProgress";
    FormEstatusEnum["inReview"] = "InReview";
    FormEstatusEnum["approved"] = "Approved";
    FormEstatusEnum["rejected"] = "Rejected";
    FormEstatusEnum["upgrade"] = "Upgrade";
})(FormEstatusEnum || (FormEstatusEnum = {}));
var ColorTypes;
(function (ColorTypes) {
    ColorTypes["primary"] = "primary";
    ColorTypes["secondary"] = "secondary";
    ColorTypes["tertiary"] = "tertiary";
    ColorTypes["success"] = "success";
    ColorTypes["warning"] = "warning";
    ColorTypes["danger"] = "danger";
    ColorTypes["light"] = "light";
    ColorTypes["medium"] = "medium";
    ColorTypes["dark"] = "dark";
})(ColorTypes || (ColorTypes = {}));

const correctionMessage = "El formato o valor es inválido";
const validation_messages = {
    'email': [
        { type: 'required', message: 'El correo es requerido' },
        { type: 'pattern', message: 'Introduzca un correo válido' },
        { type: 'email', message: 'Introduzca un correo válido' },
        { type: 'mismatched', message: (input) => { return `no coincide con el campo ${input}!`; } },
        { type: 'needCorrection', message: correctionMessage },
    ],
    'datepicker': [
        { type: 'required', message: 'La fecha es requerida' },
        { type: 'badDateFormat', message: 'La fecha no es válida' },
        { type: 'isNotOver18', message: 'La edad no puede ser menor a 18 años' },
        { type: 'isNotOver100', message: 'La edad no puede ser mayor a 100 años' },
    ],
    'passport': [
        { type: 'required', message: 'El pasaporte es requerido' },
        { type: 'pattern', message: 'El pasaporte no debe contener caracteres especiales' },
        { type: 'minlength', message: 'El pasaporte debe tener al menos 7 caracteres' },
        { type: 'needCorrection', message: correctionMessage },
    ],
    'dni': [
        { type: 'required', message: 'El id es requerido' },
        { type: 'pattern', message: 'El id no coincide con los formatos establecidos' },
        { type: 'needCorrection', message: correctionMessage },
        { type: 'badDniFormat', message: 'El valor ingresado no corresponde a una cédula panameña' },
    ],
    'username': [
        { type: 'required', message: 'El nombre de usuario es requerido' },
        { type: 'minlength', message: 'El nombre de usuario debe tener al menos 5 caracteres' },
        { type: 'maxlength', message: 'El nombre de usuario no puede tener más de 25 caracteres' },
        { type: 'pattern', message: 'Su nombre de usuario debe contener solo números y letras' },
        { type: 'validUsername', message: 'Tu nombre de usuario ya ha sido tomado' },
        { type: 'needCorrection', message: correctionMessage },
    ],
    'confirm_password': [
        { type: 'required', message: 'Se requiere confirmación de contraseña' },
        { type: 'areEqual', message: 'la contraseña no coincide' },
        { type: 'needCorrection', message: correctionMessage },
    ],
    'password': [
        { type: 'required', message: 'la contraseña es requerido' },
        { type: 'minlength', message: 'La contraseña debe tener al menos 5 caracteres' },
        { type: 'pattern', message: 'Su contraseña debe contener al menos una mayúscula, una minúscula y un número' },
        { type: 'needCorrection', message: correctionMessage },
    ],
    'terms': [
        { type: 'pattern', message: 'Debes aceptar los términos y condiciones' },
        { type: 'needCorrection', message: correctionMessage },
    ],
    'phone': [
        { type: 'required', message: 'El número de teléfono es requerido' },
        { type: 'phone', message: 'El número de teléfono ingresado no es válido' },
        { type: 'validatePhoneNumber', message: 'El número de teléfono ingresado no es válido para el país seleccionado' },
        { type: 'needCorrection', message: correctionMessage },
    ],
    'textbox': [
        { type: 'required', message: 'Campo requerido' },
        { type: 'mismatched', message: (input) => { return `no coincide con el campo ${input}!`; } },
        { type: 'needCorrection', message: correctionMessage },
    ]
};

const ErrorMessages = {
    user: {
        create: "An error occurred while creating a user",
        read: "Error bringing user records",
        update: "An error occurred while updating a user",
        delete: "An error occurred while deleting the user"
    },
    client: {
        create: "An error occurred while creating a customer",
        read: "Error bringing customer records",
        update: "an error occurred while updating a customer",
        delete: "Error al eliminar el cliente"
    },
    setting: {
        uuidNotFound: "Organization's uuid not found"
    }
};

const SuccessMessages = {
    detailsUser: {
        changeStatus: "Status changed successfully"
    },
    user: {
        create: "User successfully created",
        update: "User updated successfully",
        delete: "Registro eliminado satisfactoriamente!",
        updateForm: "Tipo de formulario actualizado exitosamente!"
    },
    admin: {
        delete: "Administrador eliminado satisfactoriamente!",
        update: "Administrador actualizado satisfactoriamente!",
    },
    client: {
        create: "Customer successfully created",
        update: "Customer updated successfully",
        delete: "Cliente eliminado exitosamente!"
    },
    setting: {
        welcomeMessage: "Welcome message saved!",
        goodbyeMessage: "Goodbye message saved!",
        contactMessage: "Contact us message saved!",
        statusMessage: "Mensaje guardado exitosamente!"
    }
};

class QuestionBase {
    constructor(options = {}) {
        if (Array.isArray(options.value) && options.defaultAnswerId) {
            if (options.value.length && options.value[0] == null && options.inputType !== 'Radio') {
                this.defaultValue = [options.defaultAnswerId];
            }
            if (options.value.length && options.value[0] == null && options.inputType === 'Radio') {
                this.defaultValue = options.defaultAnswerId;
            }
        }
        this.value = Array.isArray(options.value) ? (options.value.length && options.value[0] != null ? options.value : this.defaultValue)
            : (options.value || options.defaultAnswerId);
        this.valueText = options.valueText || '';
        this.contractText = options.contractText || '';
        this.id = options.id || 0;
        this.key = options.uuid || '';
        this.label = options.name || '';
        this.required = !!options.required;
        this.confirmed = options.confirmed || false;
        this.order = options.order === undefined ? 1 : options.order;
        this.controlType = options.controlType || '';
        this.isReferenced = !!options.isReferenced;
        this.isHidden = !!options.isHidden;
        this.tooltipMessage = options.tooltipMessage || '';
        this.maximumLength = options.maximumLength;
        this.defaultAnswerId = options.defaultAnswerId || null;
        this.subheading = options.subheading || '';
        this.sharedKey = options.sharedKey || 'default';
        this.sharedKeyId = options.sharedKeyId || -1;
        this.subText = options.subText || '';
        this.subTextRequired = !!options.subTextRequired;
        this.supportType = options.supportType;
        this.validationId = options.validationId;
        this.isQuestion = options.isQuestion || false;
        this.isGroup = options.isGroup || false;
        this.displayType = options.displayType || 'vertical';
        this.needCorrection = options.needCorrection || false;
        this.locked = options.locked;
        this.multiple = options.multiple;
    }
}

class CheckboxQuestion extends QuestionBase {
    //   type: string;
    constructor(options = {}) {
        super(options);
        this.options = [];
        // this.type = options['type'] || '';
        this.controlType = options['inputType'] || '';
        this.options = options['options'].map((val) => { return { key: val.id, value: val.name }; }) || [];
    }
}

class DatepickerQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'datepicker';
        this.type = options['inputType'] || '';
    }
}

class DropdownQuestionNotMultiple extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'dropdownNotMultiple';
        this.options = [];
        this.options = options['options'].map((val) => { return { key: val.id, value: val.name, sectionId: val.sectionId, groupId: val.groupId, questionId: val.questionId }; }) || [];
    }
}

class DropdownQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'dropdown';
        this.options = [];
        this.options = options['options'].map((val) => { return { key: val.id, value: val.name, sectionId: val.sectionId, groupId: val.groupId, questionId: val.questionId }; }) || [];
    }
}

class QuestionFile {
}
class FileQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'file';
        this.type = options['inputType'] || '';
    }
}

class NumberQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'number';
        this.type = options['inputType'].toLowerCase() || '';
    }
}

class RadioQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'radio';
        this.options = [];
        this.options = options['options'].map((val) => { return { key: val.id, value: val.name, sectionId: val.sectionId, groupId: val.groupId, questionId: val.questionId }; }) || [];
        if (Array.isArray(options['value'])) {
            this.value = options['value'][0] ? options['value'][0] : options['defaultAnswerId'];
        }
        else {
            this.value = options['value'] ? options['value'] : options['defaultAnswerId'];
        }
    }
}

class TableQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'table';
        this.options = [];
        this.type = options['inputType'] || '';
        // this.options = options['options'].map((val)=> {return { key: val.id, value: val.name } }) || [];
        this.options = options['options'] || [];
    }
}

class TextDniQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'dni';
        this.type = options['inputType'] || '';
    }
}

class TextEmailQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'email';
        this.type = options['inputType'] || '';
    }
}

class TextPassportQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'passport';
        this.type = options['inputType'] || '';
    }
}

class TextPhoneQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'phone';
        this.type = options['inputType'] || '';
    }
}

class TextboxQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'textbox';
        this.type = options['inputType'] || '';
    }
}

const PhoneIso = [
    { country: "afganistán", iso: "af", code: "93" },
    { country: "albania", iso: "al", code: "355" },
    { country: "alemania", iso: "de", code: "49" },
    { country: "andorra", iso: "ad", code: "376" },
    { country: "angola", iso: "ao", code: "244" },
    { country: "anguila", iso: "ai", code: "1 264" },
    { country: "antártida", iso: "aq", code: "672" },
    { country: "antigua y barbuda", iso: "ag", code: "1 268" },
    { country: "arabia saudita", iso: "sa", code: "966" },
    { country: "argelia", iso: "dz", code: "213" },
    { country: "argentina", iso: "ar", code: "54" },
    { country: "armenia", iso: "am", code: "374" },
    { country: "aruba", iso: "aw", code: "297" },
    { country: "australia", iso: "au", code: "61" },
    { country: "austria", iso: "at", code: "43" },
    { country: "azerbaiyán", iso: "az", code: "994" },
    { country: "bélgica", iso: "be", code: "32" },
    { country: "bahamas", iso: "bs", code: "1 242" },
    { country: "bahrein", iso: "bh", code: "973" },
    { country: "bangladesh", iso: "bd", code: "880" },
    { country: "barbados", iso: "bb", code: "1 246" },
    { country: "belice", iso: "bz", code: "501" },
    { country: "benín", iso: "bj", code: "229" },
    { country: "bhután", iso: "bt", code: "975" },
    { country: "bielorrusia", iso: "by", code: "375" },
    { country: "birmania", iso: "mm", code: "95" },
    { country: "bolivia", iso: "bo", code: "591" },
    { country: "bosnia y herzegovina", iso: "ba", code: "387" },
    { country: "botsuana", iso: "bw", code: "267" },
    { country: "brasil", iso: "br", code: "55" },
    { country: "brunéi", iso: "bn", code: "673" },
    { country: "bulgaria", iso: "bg", code: "359" },
    { country: "burkina faso", iso: "bf", code: "226" },
    { country: "burundi", iso: "bi", code: "257" },
    { country: "cabo verde", iso: "cv", code: "238" },
    { country: "camboya", iso: "kh", code: "855" },
    { country: "camerún", iso: "cm", code: "237" },
    { country: "canadá", iso: "ca", code: "1" },
    { country: "chad", iso: "td", code: "235" },
    { country: "chile", iso: "cl", code: "56" },
    { country: "china", iso: "cn", code: "86" },
    { country: "chipre", iso: "cy", code: "357" },
    { country: "ciudad del vaticano", iso: "va", code: "39" },
    { country: "colombia", iso: "co", code: "57" },
    { country: "comoras", iso: "km", code: "269" },
    { country: "república del congo", iso: "cg", code: "242" },
    { country: "república democrática del congo", iso: "cd", code: "243" },
    { country: "corea del norte", iso: "kp", code: "850" },
    { country: "corea del sur", iso: "kr", code: "82" },
    { country: "costa de marfil", iso: "ci", code: "225" },
    { country: "costa rica", iso: "cr", code: "506" },
    { country: "croacia", iso: "hr", code: "385" },
    { country: "cuba", iso: "cu", code: "53" },
    { country: "curazao", iso: "cw", code: "5999" },
    { country: "dinamarca", iso: "dk", code: "45" },
    { country: "dominica", iso: "dm", code: "1 767" },
    { country: "ecuador", iso: "ec", code: "593" },
    { country: "egipto", iso: "eg", code: "20" },
    { country: "el salvador", iso: "sv", code: "503" },
    { country: "emiratos árabes unidos", iso: "ae", code: "971" },
    { country: "eritrea", iso: "er", code: "291" },
    { country: "eslovaquia", iso: "sk", code: "421" },
    { country: "eslovenia", iso: "si", code: "386" },
    { country: "españa", iso: "es", code: "34" },
    { country: "estados unidos de américa", iso: "us", code: "1" },
    { country: "estonia", iso: "ee", code: "372" },
    { country: "etiopía", iso: "et", code: "251" },
    { country: "filipinas", iso: "ph", code: "63" },
    { country: "finlandia", iso: "fi", code: "358" },
    { country: "fiyi", iso: "fj", code: "679" },
    { country: "francia", iso: "fr", code: "33" },
    { country: "gabón", iso: "ga", code: "241" },
    { country: "gambia", iso: "gm", code: "220" },
    { country: "georgia", iso: "ge", code: "995" },
    { country: "ghana", iso: "gh", code: "233" },
    { country: "gibraltar", iso: "gi", code: "350" },
    { country: "granada", iso: "gd", code: "1 473" },
    { country: "grecia", iso: "gr", code: "30" },
    { country: "groenlandia", iso: "gl", code: "299" },
    { country: "guadalupe", iso: "gp", code: "590" },
    { country: "guam", iso: "gu", code: "1 671" },
    { country: "guatemala", iso: "gt", code: "502" },
    { country: "guayana francesa", iso: "gf", code: "594" },
    { country: "guernsey", iso: "gg", code: "44" },
    { country: "guinea", iso: "gn", code: "224" },
    { country: "guinea ecuatorial", iso: "gq", code: "240" },
    { country: "guinea-bissau", iso: "gw", code: "245" },
    { country: "guyana", iso: "gy", code: "592" },
    { country: "haití", iso: "ht", code: "509" },
    { country: "honduras", iso: "hn", code: "504" },
    { country: "hong kong", iso: "hk", code: "852" },
    { country: "hungría", iso: "hu", code: "36" },
    { country: "india", iso: "in", code: "91" },
    { country: "indonesia", iso: "id", code: "62" },
    { country: "irán", iso: "ir", code: "98" },
    { country: "irak", iso: "iq", code: "964" },
    { country: "irlanda", iso: "ie", code: "353" },
    { country: "isla bouvet", iso: "bv", code: "" },
    { country: "isla de man", iso: "im", code: "44" },
    { country: "isla de navidad", iso: "cx", code: "61" },
    { country: "isla norfolk", iso: "nf", code: "672" },
    { country: "islandia", iso: "is", code: "354" },
    { country: "islas bermudas", iso: "bm", code: "1 441" },
    { country: "islas caimán", iso: "ky", code: "1 345" },
    { country: "islas cocos (keeling)", iso: "cc", code: "61" },
    { country: "islas cook", iso: "ck", code: "682" },
    { country: "islas de åland", iso: "ax", code: "358" },
    { country: "islas feroe", iso: "fo", code: "298" },
    { country: "islas georgias del sur y sandwich del sur", iso: "gs", code: "500" },
    { country: "islas heard y mcdonald", iso: "hm", code: "" },
    { country: "islas maldivas", iso: "mv", code: "960" },
    { country: "islas malvinas", iso: "fk", code: "500" },
    { country: "islas marianas del norte", iso: "mp", code: "1 670" },
    { country: "islas marshall", iso: "mh", code: "692" },
    { country: "islas pitcairn", iso: "pn", code: "870" },
    { country: "islas salomón", iso: "sb", code: "677" },
    { country: "islas turcas y caicos", iso: "tc", code: "1 649" },
    { country: "islas ultramarinas menores de estados unidos", iso: "um", code: "246" },
    { country: "islas vírgenes británicas", iso: "vg", code: "1 284" },
    { country: "islas vírgenes de los estados unidos", iso: "vi", code: "1 340" },
    { country: "israel", iso: "il", code: "972" },
    { country: "italia", iso: "it", code: "39" },
    { country: "jamaica", iso: "jm", code: "1 876" },
    { country: "japón", iso: "jp", code: "81" },
    { country: "jersey", iso: "je", code: "44" },
    { country: "jordania", iso: "jo", code: "962" },
    { country: "kazajistán", iso: "kz", code: "7" },
    { country: "kenia", iso: "ke", code: "254" },
    { country: "kirguistán", iso: "kg", code: "996" },
    { country: "kiribati", iso: "ki", code: "686" },
    { country: "kuwait", iso: "kw", code: "965" },
    { country: "líbano", iso: "lb", code: "961" },
    { country: "laos", iso: "la", code: "856" },
    { country: "lesoto", iso: "ls", code: "266" },
    { country: "letonia", iso: "lv", code: "371" },
    { country: "liberia", iso: "lr", code: "231" },
    { country: "libia", iso: "ly", code: "218" },
    { country: "liechtenstein", iso: "li", code: "423" },
    { country: "lituania", iso: "lt", code: "370" },
    { country: "luxemburgo", iso: "lu", code: "352" },
    { country: "méxico", iso: "mx", code: "52" },
    { country: "mónaco", iso: "mc", code: "377" },
    { country: "macao", iso: "mo", code: "853" },
    { country: "macedônia", iso: "mk", code: "389" },
    { country: "madagascar", iso: "mg", code: "261" },
    { country: "malasia", iso: "my", code: "60" },
    { country: "malawi", iso: "mw", code: "265" },
    { country: "mali", iso: "ml", code: "223" },
    { country: "malta", iso: "mt", code: "356" },
    { country: "marruecos", iso: "ma", code: "212" },
    { country: "martinica", iso: "mq", code: "596" },
    { country: "mauricio", iso: "mu", code: "230" },
    { country: "mauritania", iso: "mr", code: "222" },
    { country: "mayotte", iso: "yt", code: "262" },
    { country: "micronesia", iso: "fm", code: "691" },
    { country: "moldavia", iso: "md", code: "373" },
    { country: "mongolia", iso: "mn", code: "976" },
    { country: "montenegro", iso: "me", code: "382" },
    { country: "montserrat", iso: "ms", code: "1 664" },
    { country: "mozambique", iso: "mz", code: "258" },
    { country: "namibia", iso: "na", code: "264" },
    { country: "nauru", iso: "nr", code: "674" },
    { country: "nepal", iso: "np", code: "977" },
    { country: "nicaragua", iso: "ni", code: "505" },
    { country: "niger", iso: "ne", code: "227" },
    { country: "nigeria", iso: "ng", code: "234" },
    { country: "niue", iso: "nu", code: "683" },
    { country: "noruega", iso: "no", code: "47" },
    { country: "nueva caledonia", iso: "nc", code: "687" },
    { country: "nueva zelanda", iso: "nz", code: "64" },
    { country: "omán", iso: "om", code: "968" },
    { country: "países bajos", iso: "nl", code: "31" },
    { country: "pakistán", iso: "pk", code: "92" },
    { country: "palau", iso: "pw", code: "680" },
    { country: "palestina", iso: "ps", code: "970" },
    { country: "panamá", iso: "pa", code: "507" },
    { country: "papúa nueva guinea", iso: "pg", code: "675" },
    { country: "paraguay", iso: "py", code: "595" },
    { country: "perú", iso: "pe", code: "51" },
    { country: "polinesia francesa", iso: "pf", code: "689" },
    { country: "polonia", iso: "pl", code: "48" },
    { country: "portugal", iso: "pt", code: "351" },
    { country: "puerto rico", iso: "pr", code: "1" },
    { country: "qatar", iso: "qa", code: "974" },
    { country: "reino unido", iso: "gb", code: "44" },
    { country: "república centroafricana", iso: "cf", code: "236" },
    { country: "república checa", iso: "cz", code: "420" },
    { country: "república dominicana", iso: "do", code: "1 809" },
    { country: "república de sudán del sur", iso: "ss", code: "211" },
    { country: "reunión", iso: "re", code: "262" },
    { country: "ruanda", iso: "rw", code: "250" },
    { country: "rumanía", iso: "ro", code: "40" },
    { country: "rusia", iso: "ru", code: "7" },
    { country: "sahara occidental", iso: "eh", code: "212" },
    { country: "samoa", iso: "ws", code: "685" },
    { country: "samoa americana", iso: "as", code: "1 684" },
    { country: "san bartolomé", iso: "bl", code: "590" },
    { country: "san cristóbal y nieves", iso: "kn", code: "1 869" },
    { country: "san marino", iso: "sm", code: "378" },
    { country: "san martín (francia)", iso: "mf", code: "1 599" },
    { country: "san pedro y miquelón", iso: "pm", code: "508" },
    { country: "san vicente y las granadinas", iso: "vc", code: "1 784" },
    { country: "santa elena", iso: "sh", code: "290" },
    { country: "santa lucía", iso: "lc", code: "1 758" },
    { country: "santo tomé y príncipe", iso: "st", code: "239" },
    { country: "senegal", iso: "sn", code: "221" },
    { country: "serbia", iso: "rs", code: "381" },
    { country: "seychelles", iso: "sc", code: "248" },
    { country: "sierra leona", iso: "sl", code: "232" },
    { country: "singapur", iso: "sg", code: "65" },
    { country: "sint maarten", iso: "sx", code: "1 721" },
    { country: "siria", iso: "sy", code: "963" },
    { country: "somalia", iso: "so", code: "252" },
    { country: "sri lanka", iso: "lk", code: "94" },
    { country: "sudáfrica", iso: "za", code: "27" },
    { country: "sudán", iso: "sd", code: "249" },
    { country: "suecia", iso: "se", code: "46" },
    { country: "suiza", iso: "ch", code: "41" },
    { country: "surinám", iso: "sr", code: "597" },
    { country: "svalbard y jan mayen", iso: "sj", code: "47" },
    { country: "swazilandia", iso: "sz", code: "268" },
    { country: "tayikistán", iso: "tj", code: "992" },
    { country: "tailandia", iso: "th", code: "66" },
    { country: "taiwán", iso: "tw", code: "886" },
    { country: "tanzania", iso: "tz", code: "255" },
    { country: "territorio británico del océano índico", iso: "io", code: "246" },
    { country: "territorios australes y antárticas franceses", iso: "tf", code: "" },
    { country: "timor oriental", iso: "tl", code: "670" },
    { country: "togo", iso: "tg", code: "228" },
    { country: "tokelau", iso: "tk", code: "690" },
    { country: "tonga", iso: "to", code: "676" },
    { country: "trinidad y tobago", iso: "tt", code: "1 868" },
    { country: "tunez", iso: "tn", code: "216" },
    { country: "turkmenistán", iso: "tm", code: "993" },
    { country: "turquía", iso: "tr", code: "90" },
    { country: "tuvalu", iso: "tv", code: "688" },
    { country: "ucrania", iso: "ua", code: "380" },
    { country: "uganda", iso: "ug", code: "256" },
    { country: "uruguay", iso: "uy", code: "598" },
    { country: "uzbekistán", iso: "uz", code: "998" },
    { country: "vanuatu", iso: "vu", code: "678" },
    { country: "venezuela", iso: "ve", code: "58" },
    { country: "vietnam", iso: "vn", code: "84" },
    { country: "wallis y futuna", iso: "wf", code: "681" },
    { country: "yemen", iso: "ye", code: "967" },
    { country: "yibuti", iso: "dj", code: "253" },
    { country: "zambia", iso: "zm", code: "260" },
    { country: "zimbabue", iso: "zw", code: "263" },
];

class QuestionControlService {
    constructor() { }
    toFormGroup(questions, group) {
        this.form = new FormGroup({});
        //Viejo
        if (questions) {
            questions.forEach(question => {
                if (question.key) {
                    this.getFormQuestion(question, question.key, group.isEnabled);
                }
                else {
                    this.getFormQuestion(question, undefined, group.isEnabled);
                }
            });
        }
        return this.form;
    }
    getFormQuestion(question, keyName, isEnable) {
        const RegExpEmail = '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$';
        const RegExpDni = '^(PE|E|N|[23456789](?:AV|PI)?|1[0123]?(?:AV|PI)?)-(\d{1,4})-(\d{1,6})$';
        const RegExpPassport = '^[A-Za-z0-9_.]+$';
        const VALIDATOR_FECHA_NACIMIENTO = 6;
        if (question.required && isEnable) {
            if (question.validationId === VALIDATOR_TELEFONO) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : this.cellPhoneFormat(question)));
            }
            if (question.validationId === null || question.validationId === undefined) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, [Validators.required, IonIntlTelInputValidators.phone]));
            }
            if (question.validationId === VALIDATOR_FECHA_NACIMIENTO) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, [Validators.required]));
            }
            if (question.validationId === VALIDATOR_CEDULA) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, Validators.compose([Validators.required, Validators.pattern(RegExpDni)])));
            }
            if (question.validationId === VALIDATOR_EMAIL) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, Validators.compose([Validators.pattern(RegExpEmail), Validators.required])));
            }
            if (question.validationId === VALIDATOR_PASAPORTE) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, Validators.compose([
                    Validators.required,
                    Validators.pattern(RegExpPassport),
                    Validators.minLength(7)
                ])));
            }
            if (![VALIDATOR_FECHA_NACIMIENTO, VALIDATOR_TELEFONO, VALIDATOR_CEDULA, VALIDATOR_EMAIL, VALIDATOR_PASAPORTE].includes(question.validationId)) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, [Validators.required]));
            }
        }
        else {
            if (question.validationId === null || question.validationId === undefined) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value));
            }
            if (question.validationId === VALIDATOR_FECHA_NACIMIENTO) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, [Validators.required]));
            }
            if (question.validationId === VALIDATOR_TELEFONO) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : this.cellPhoneFormat(question), IonIntlTelInputValidators.phone));
            }
            if (question.validationId === VALIDATOR_CEDULA) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, Validators.pattern(RegExpDni)));
            }
            if (question.validationId === VALIDATOR_EMAIL) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, Validators.pattern(RegExpEmail)));
            }
            if (question.validationId === VALIDATOR_PASAPORTE) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, Validators.compose([
                    Validators.pattern(RegExpPassport),
                    Validators.minLength(7)
                ])));
            }
            if (![VALIDATOR_FECHA_NACIMIENTO, VALIDATOR_TELEFONO, VALIDATOR_CEDULA, VALIDATOR_EMAIL, VALIDATOR_PASAPORTE].includes(question.validationId)) {
                this.form.addControl(keyName, new FormControl(question.value === undefined ? '' : question.value, [Validators.required]));
            }
        }
    }
    cellPhoneFormat(question) {
        if (!question.value) {
            return;
        }
        const code = question.value.split(' ')[0].replace('+', '');
        const phone = PhoneIso.find((phone) => (phone.code == code));
        if (!phone) {
            return;
        }
        var a = question.value.split(' ');
        var b = a.splice(1);
        var nationalNumber = b.join(' ');
        return {
            dialCode: question.value.split(' ')[0],
            internationalNumber: question.value,
            nationalNumber: nationalNumber,
            isoCode: phone.iso
        };
    }
}
QuestionControlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionControlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
QuestionControlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionControlService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionControlService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return []; } });

class GroupBase {
    constructor(options = {}) {
        this.id = options.id || 0;
        this.key = options.uuid || '';
        this.order = options.order === undefined ? 1 : options.order;
        this.sectionId = options.sectionId;
        this.title = options.title || '';
        this.subheading = options.subheading || '';
        this.questions = options.questions;
        this.isEnabled = !!options.isEnabled;
        this.isReferenced = !!options.isReferenced;
    }
}

class Group extends GroupBase {
    constructor(options = {}) {
        super(options);
    }
}

class DDMaterialModule {
}
DDMaterialModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: DDMaterialModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
DDMaterialModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: DDMaterialModule, exports: [MatGridListModule,
        MatToolbarModule,
        MatSidenavModule,
        MatIconModule,
        MatListModule,
        MatCardModule,
        MatFormFieldModule,
        MatInputModule,
        MatButtonModule,
        MatStepperModule,
        MatRadioModule,
        MatButtonToggleModule,
        MatBottomSheetModule,
        MatDatepickerModule,
        MatNativeDateModule,
        MatOptionModule,
        MatSelectModule,
        MatMenuModule,
        MatCheckboxModule,
        MatExpansionModule,
        MatSliderModule,
        MatTabsModule,
        MatTableModule,
        MatSortModule,
        MatPaginatorModule,
        MatChipsModule,
        MatDialogModule,
        MatProgressBarModule,
        MatProgressSpinnerModule,
        MatTooltipModule,
        MatSlideToggleModule,
        MatSnackBarModule,
        MatTreeModule,
        MatBadgeModule,
        MatAutocompleteModule,
        MatDividerModule] });
DDMaterialModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: DDMaterialModule, imports: [MatGridListModule,
        MatToolbarModule,
        MatSidenavModule,
        MatIconModule,
        MatListModule,
        MatCardModule,
        MatFormFieldModule,
        MatInputModule,
        MatButtonModule,
        MatStepperModule,
        MatRadioModule,
        MatButtonToggleModule,
        MatBottomSheetModule,
        MatDatepickerModule,
        MatNativeDateModule,
        MatOptionModule,
        MatSelectModule,
        MatMenuModule,
        MatCheckboxModule,
        MatExpansionModule,
        MatSliderModule,
        MatTabsModule,
        MatTableModule,
        MatSortModule,
        MatPaginatorModule,
        MatChipsModule,
        MatDialogModule,
        MatProgressBarModule,
        MatProgressSpinnerModule,
        MatTooltipModule,
        MatSlideToggleModule,
        MatSnackBarModule,
        MatTreeModule,
        MatBadgeModule,
        MatAutocompleteModule,
        MatDividerModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: DDMaterialModule, decorators: [{
            type: NgModule,
            args: [{
                    exports: [
                        MatGridListModule,
                        MatToolbarModule,
                        MatSidenavModule,
                        MatIconModule,
                        MatListModule,
                        MatCardModule,
                        MatFormFieldModule,
                        MatInputModule,
                        MatButtonModule,
                        MatStepperModule,
                        MatRadioModule,
                        MatButtonToggleModule,
                        MatBottomSheetModule,
                        MatDatepickerModule,
                        MatNativeDateModule,
                        MatOptionModule,
                        MatSelectModule,
                        MatMenuModule,
                        MatCheckboxModule,
                        MatExpansionModule,
                        MatSliderModule,
                        MatTabsModule,
                        MatTableModule,
                        MatSortModule,
                        MatPaginatorModule,
                        MatChipsModule,
                        MatDialogModule,
                        MatProgressBarModule,
                        MatProgressSpinnerModule,
                        MatTooltipModule,
                        MatSlideToggleModule,
                        MatSnackBarModule,
                        MatTreeModule,
                        MatBadgeModule,
                        MatAutocompleteModule,
                        MatDividerModule
                    ]
                }]
        }] });

class SafePipe {
    constructor(sanitizer) {
        this.sanitizer = sanitizer;
    }
    transform(value, type) {
        switch (type) {
            case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
            case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
            case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
            case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
            case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
            default: throw new Error(`Invalid safe type specified: ${type}`);
        }
    }
}
SafePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SafePipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
SafePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SafePipe, name: "safe" });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SafePipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'safe'
                }]
        }], ctorParameters: function () { return [{ type: i1.DomSanitizer }]; } });

class PipeModule {
}
PipeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: PipeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
PipeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: PipeModule, declarations: [SafePipe], imports: [CommonModule], exports: [SafePipe] });
PipeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: PipeModule, imports: [[
            CommonModule
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: PipeModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [SafePipe],
                    imports: [
                        CommonModule
                    ],
                    exports: [
                        SafePipe
                    ]
                }]
        }] });

class KYCEventConfig {
}
let ENVIRONMENT_TOKEN = new InjectionToken('environment');
let FINISH_EVENT_KYC = new InjectionToken('KYCEventConfig');

class AuthApiService {
    constructor(http, environment) {
        this.http = http;
        this.environment = environment;
    }
    authorize(token) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/kyc-token/authorize/${token}`);
    }
}
AuthApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthApiService, deps: [{ token: i1$1.HttpClient }, { token: ENVIRONMENT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
AuthApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthApiService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthApiService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () {
        return [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [ENVIRONMENT_TOKEN]
                    }] }];
    } });

class OrganizationApiService {
    constructor(http, environment) {
        this.http = http;
        this.environment = environment;
    }
    getOrganizationByUuid(uuid) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/organizations/${uuid}`);
    }
}
OrganizationApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OrganizationApiService, deps: [{ token: i1$1.HttpClient }, { token: ENVIRONMENT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
OrganizationApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OrganizationApiService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OrganizationApiService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () {
        return [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [ENVIRONMENT_TOKEN]
                    }] }];
    } });

class QuestionApiService {
    constructor(http, environment) {
        this.http = http;
        this.environment = environment;
        this.url = "assets/data";
        this.errorValidatorDniApi = new Subject();
    }
    getSurvey(id) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/survey/${id}`);
    }
    saveFile(file) {
        return this.http.post(`${this.environment.ddcheckApiUrl}/attachments/upload`, file);
    }
    surveyCheck(id) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/survey/${id}/check`);
    }
    surveyComplete(id, body) {
        return this.http.post(`${this.environment.ddcheckApiUrl}/survey/${id}/complete`, body);
    }
    getStepperList(id) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/survey/${id}/history`);
    }
    getSection(surveyId, sectionId) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/survey/${surveyId}/sections/${sectionId}/questions`);
    }
    getSectionList(id) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/survey/${id}/start`);
    }
    getSurveyComplete(id) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/survey/${id}/sumary`);
    }
    saveQuestions(surveyId, sectionId, form) {
        return this.http.post(`${this.environment.ddcheckApiUrl}/survey/${surveyId}/sections/${sectionId}/questions`, form);
    }
    currentEnd(surveyId) {
        return this.http.post(`${this.environment.ddcheckApiUrl}/survey/${surveyId}/end-edit`, {});
    }
    getIp() {
        return this.http.get(`https://api.ipify.org/?format=json`);
    }
    errorDni(v) {
        this.errorValidatorDniApi.next(v);
    }
    errorDniValue() {
        return this.errorValidatorDniApi.asObservable();
    }
}
QuestionApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionApiService, deps: [{ token: i1$1.HttpClient }, { token: ENVIRONMENT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
QuestionApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionApiService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionApiService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () {
        return [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [ENVIRONMENT_TOKEN]
                    }] }];
    } });

class SettingsApiService {
    constructor(http, environment) {
        this.http = http;
        this.environment = environment;
    }
    getMessage(orgUuid, surveyUuid) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/organizations/${orgUuid}/survey/${surveyUuid}/get-message`);
    }
    getWelcomeMessage(uuid) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/organizations/${uuid}/get-wellcome-message`);
    }
    getGoodbyeMessage(uuid) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/organizations/${uuid}/get-completion-message`);
    }
    getContactMessage(uuid) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/organizations/${uuid}/get-contact-message`);
    }
    getStatusMessage(uuid) {
        return this.http.get(`${this.environment.ddcheckApiUrl}/organizations/${uuid}/get-email-message`); //get-statusemail-message`
    }
    postWelcomeMessage(uuid, body) {
        return this.http.put(`${this.environment.apiUrl}/organizations/${uuid}/update-wellcome-message`, body);
    }
    postGoodbyeMessage(uuid, body) {
        return this.http.put(`${this.environment.apiUrl}/organizations/${uuid}/update-completion-message`, body);
    }
    postContactMessage(uuid, body) {
        return this.http.put(`${this.environment.apiUrl}/organizations/${uuid}/update-contact-message`, body);
    }
    postStatusMessage(uuid, body) {
        return this.http.put(`${this.environment.apiUrl}/organizations/${uuid}/update-email-message`, body); ///update-statusemail-message`
    }
}
SettingsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SettingsApiService, deps: [{ token: i1$1.HttpClient }, { token: ENVIRONMENT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
SettingsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SettingsApiService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SettingsApiService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () {
        return [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [ENVIRONMENT_TOKEN]
                    }] }];
    } });

class MembershipApiService {
    constructor(http, environment) {
        this.http = http;
        this.environment = environment;
    }
    getPlanData() {
        return this.http.get(`${this.environment.forteszaMembershipApi}/membership-plan`);
    }
    getUserData(email) {
        const body = { email: email };
        return this.http.post(`${this.environment.forteszaMembershipApi}/user/membership`, body);
    }
    verifyTdc(body) {
        return this.http.post(`${this.environment.forteszaApiUrl}/api/admin/membership-plan`, body);
    }
    getMembership(body) {
        return this.http.post(`${this.environment.forteszaMembershipApi}/link/membership`, body);
    }
}
MembershipApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MembershipApiService, deps: [{ token: i1$1.HttpClient }, { token: ENVIRONMENT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
MembershipApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MembershipApiService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MembershipApiService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () {
        return [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [ENVIRONMENT_TOKEN]
                    }] }];
    } });

class StorageService {
    // session_token  : almacena el token del link enviado por correo
    // session_access : almacena el token de autorizacion emitido por el servicio despues de mandar el session_token
    constructor() { }
    setItem(key, value) {
        let promise = new Promise((resolve, reject) => {
            localStorage.setItem(key, value);
            resolve(true);
        });
        return promise;
    }
    getItem(key) {
        const session = localStorage.getItem(key);
        return session ? session : null;
    }
    removeItem(key) {
        localStorage.removeItem(key);
    }
}
StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: StorageService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: StorageService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return []; } });

class alertService {
    constructor(toastController, _alertController, loadingController) {
        this.toastController = toastController;
        this._alertController = _alertController;
        this.loadingController = loadingController;
    }
    toast(text, color = ColorTypes.danger) {
        return __awaiter(this, void 0, void 0, function* () {
            const toast = yield this.toastController.create({
                message: text,
                duration: 2000,
                color
            });
            toast.present();
        });
    }
    presentAlertConfirm(title, text) {
        return __awaiter(this, void 0, void 0, function* () {
            const promise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
                const alert = yield this._alertController.create({
                    cssClass: 'my-custom-class',
                    header: title,
                    message: text,
                    buttons: [
                        {
                            text: 'Cancel',
                            role: 'cancel',
                            cssClass: 'secondary',
                            id: 'cancel-button',
                            handler: (blah) => {
                                resolve(false);
                            }
                        }, {
                            text: 'Okay',
                            id: 'confirm-button',
                            handler: () => {
                                resolve(true);
                            }
                        }
                    ]
                });
                yield alert.present();
            }));
            return promise;
        });
    }
    /**
     * startLoading
     */
    startLoading(title = '', subtitle = '') {
        return __awaiter(this, void 0, void 0, function* () {
            this.loading = yield this.loadingController.create({
                message: '<div>' +
                    '<ion-img src="./assets/img/loading.gif" alt="loading..."></ion-img>' +
                    (title ? ('<h4 class="ion-text-center"><strong>' + title + '</strong></h4>') : '') +
                    (subtitle ? ('<h6 class="ion-text-center">' + subtitle + '</h6>') : '') +
                    '</div>',
                cssClass: 'my-custom-class-loading',
                spinner: null,
                backdropDismiss: true
            });
            return yield this.loading.present();
        });
    }
    /**
     * stopLoading
     */
    stopLoading() {
        return __awaiter(this, void 0, void 0, function* () {
            const loader = yield this.loadingController.getTop();
            // if loader present then dismiss
            if (loader !== undefined) {
                yield this.loadingController.dismiss().then((response) => { }).catch((error) => { });
            }
        });
    }
}
alertService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: alertService, deps: [{ token: i1$2.ToastController }, { token: i1$2.AlertController }, { token: i1$2.LoadingController }], target: i0.ɵɵFactoryTarget.Injectable });
alertService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: alertService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: alertService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }], ctorParameters: function () { return [{ type: i1$2.ToastController }, { type: i1$2.AlertController }, { type: i1$2.LoadingController }]; } });

class ThemeManagerService {
    constructor(storage, organizationService) {
        this.storage = storage;
        this.organizationService = organizationService;
        this._loading = new BehaviorSubject(false);
        this._theme = new Subject();
        let typeCustomer = this.storage.getItem(INTERCEPTOR_TYPE);
        if (typeCustomer) {
            let organizationUuid = this.storage.getItem("organization_uuid");
            if (organizationUuid) {
                if (typeCustomer == INTERCEPTOR_ADMIN) {
                    this.loadTheme(organizationUuid, ThemeType.themeAdminPanel);
                }
                if (typeCustomer == INTERCEPTOR_CUSTOMER) {
                    this.loadTheme(organizationUuid, ThemeType.themeForm);
                }
            }
        }
    }
    getLoading() {
        return this._loading.asObservable();
    }
    getTheme() {
        return this._theme.asObservable();
    }
    loadTheme(uuidOrganization, themeType) {
        of("")
            .pipe(switchMap(_ => {
            let value = this.storage.getItem(themeType);
            if (value) {
                return of(JSON.parse(value));
            }
            else {
                this._loading.next(true);
                return this.organizationService.getOrganizationByUuid(uuidOrganization)
                    .pipe(finalize(() => this._loading.next(false)));
            }
        })).subscribe((data) => {
            this.storage.setItem(themeType, JSON.stringify(data));
            // this.changeTheme(data.settings.colorPalette);
            this._theme.next(data);
        }, err => {
        });
    }
}
ThemeManagerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ThemeManagerService, deps: [{ token: StorageService }, { token: OrganizationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
ThemeManagerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ThemeManagerService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ThemeManagerService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return [{ type: StorageService }, { type: OrganizationApiService }]; } });

class AuthService {
    constructor(_authService, storage, _questService, router, loadingController, themeManager, environment) {
        this._authService = _authService;
        this.storage = storage;
        this._questService = _questService;
        this.router = router;
        this.loadingController = loadingController;
        this.themeManager = themeManager;
        this.environment = environment;
        this._loading = new BehaviorSubject(true);
        this._surveyData = new BehaviorSubject([]);
    }
    getLoading() {
        return this._loading.asObservable();
    }
    getAuthentication() {
        return this._surveyData.asObservable();
    }
    logout() {
        this.finishSurvey();
    }
    finishSurvey() {
        this.storage.removeItem(INTERCEPTOR_TYPE);
        this.storage.removeItem("kyc_uuid");
        this.storage.removeItem("kyc_status");
        this.storage.removeItem("session_customer");
        this.removeTheme();
    }
    removeTheme() {
        this.storage.removeItem(ThemeType.themeForm);
    }
    isAuthenticatedLink(token) {
        this.loadingController.startLoading();
        this.finishSurvey();
        this._authService
            .authorize(token)
            .pipe(finalize(() => {
            this._loading.next(false);
            this.loadingController.stopLoading();
            setTimeout(() => { this.loadingController.stopLoading(); }, 500);
        }))
            .subscribe((res) => {
            this.storage.setItem('session_customer', res.access_token);
            this.storage.setItem('kyc_uuid', res.kyc_uuid);
            this.storage.setItem('organization_uuid', res.organization_uuid);
            this.storage.setItem('kyc_status', res.kyc_status);
            this.storage.setItem(INTERCEPTOR_TYPE, INTERCEPTOR_CUSTOMER);
            this.themeManager.loadTheme(res.organization_uuid, ThemeType.themeForm);
            let status = ["verified", "approved"];
            if (status.includes(res.kyc_status.toLowerCase())) {
                this._questService.getSurvey(res.kyc_uuid).subscribe((res) => {
                    this.router.navigate([`${this.environment.questionRoute}/` + res.uuid]);
                });
            }
            else {
                this.router.navigate([`${this.environment.welcomeRoute}/` + res.kyc_uuid]);
            }
        });
    }
}
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthService, deps: [{ token: AuthApiService }, { token: StorageService }, { token: QuestionApiService }, { token: i4.Router }, { token: alertService }, { token: ThemeManagerService }, { token: ENVIRONMENT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () {
        return [{ type: AuthApiService }, { type: StorageService }, { type: QuestionApiService }, { type: i4.Router }, { type: alertService }, { type: ThemeManagerService }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [ENVIRONMENT_TOKEN]
                    }] }];
    } });

class CountryQuestion extends QuestionBase {
    constructor(options = {}) {
        super(options);
        this.controlType = 'country';
        this.options = [];
        this.options = options['options'].map((val) => { return { key: val.id, value: val.name }; }) || [];
    }
}

class QuestionsManagerService {
    constructor(_questionApi, loadingController) {
        this._questionApi = _questionApi;
        this.loadingController = loadingController;
        this.preguntas = [];
        this._loading = new BehaviorSubject(false);
        this._isSurveyComplete = new BehaviorSubject(false);
        this._loadingVersions = new BehaviorSubject(false);
        this._loadingQuestionSave = new BehaviorSubject(false);
        this._surveyData = new BehaviorSubject([]); //datos del formulario completado
        this._sectionsList = new BehaviorSubject([]); //lista de secciones nuevas
        this._surveyVersionList = new BehaviorSubject([]); //lista las versiones de un formularo
        this._stepperList = new Subject(); //listado de stepper
        this._sectionData = new BehaviorSubject([]); //data de la seccion
    }
    getLoading() {
        return this._loading.asObservable();
    }
    getSection() {
        return this._sectionData.asObservable();
    }
    getLoadingVersions() {
        return this._loadingVersions.asObservable();
    }
    getLoadingQuestionSave() {
        return this._loadingQuestionSave.asObservable();
    }
    getSurveyVersionList() {
        return this._surveyVersionList.asObservable();
    }
    getStepper() {
        return this._stepperList.asObservable();
    }
    getSectionList(id) {
        this.loadSectionList(id);
        return this._sectionsList.asObservable();
    }
    getSurveyComplete() {
        return this._isSurveyComplete.asObservable();
    }
    getSurveyCompleteData() {
        return this._surveyData.asObservable();
    }
    loadSectionList(id) {
        this._loading.next(true);
        this._questionApi
            .getSectionList(id)
            .pipe(finalize(() => this._loading.next(false)))
            .subscribe((res) => {
            res['sections'] = res.sections.map((element) => {
                element['groups'] = element.groups.map((group) => {
                    group = new Group(group);
                    const quest = JSON.parse(JSON.stringify(this.ReorderQuestions(group.questions)));
                    group['questions'] = quest;
                    return group;
                });
                return element;
            });
            const response = res;
            return this._sectionsList.next(response);
        });
    }
    loadSurveyComplete(surveyId) {
        this._loading.next(true);
        this._isSurveyComplete.next(true);
        this._questionApi
            .getSurveyComplete(surveyId)
            .pipe(finalize(() => this._loading.next(false)))
            .subscribe((res) => {
            this._surveyData.next(res);
        });
    }
    currentEnd(surveyId) {
        this._loading.next(true);
        this._questionApi.currentEnd(surveyId).subscribe((res) => {
            this.loadSurveyComplete(surveyId);
        });
    }
    loadStepper(surveyId, stopLoadSection = false) {
        this._questionApi.getStepperList(surveyId)
            .pipe(finalize(() => {
        })).subscribe((res) => {
            if (stopLoadSection) {
                this._stepperList.next(Object.assign(Object.assign({}, res), { stopLoadSection }));
            }
            else {
                this._stepperList.next(res);
            }
        });
    }
    loadSection(surveyId, sectionId) {
        this._loading.next(true);
        this.loadingController.startLoading();
        this._questionApi.getSection(surveyId, sectionId)
            .subscribe((res) => {
            const section = res;
            if (section.groups && section.groups.length > 0) {
                section['groups'] = section.groups.map((gr) => {
                    gr = new Group(gr);
                    const quest = JSON.parse(JSON.stringify(this.ReorderQuestions(gr.questions)));
                    gr['questions'] = quest;
                    return gr;
                });
            }
            this._sectionData.next(section);
            this._isSurveyComplete.next(false);
            // this.loadStepper(surveyId, true);
        });
    }
    stopMainLoading() {
        this._loading.next(false);
        // this.loadingController.stopLoading();
        // setTimeout(() => { this.loadingController.stopLoading(); }, 500);
        this.cleanLoading();
    }
    cleanLoading() {
        this.loadingController.stopLoading();
        const element = document.getElementsByTagName('ion-loading');
        const myInterval = setInterval(() => {
            console.log('myInterval');
            if (element.length) {
                this.loadingController.stopLoading();
            }
            else {
                clearInterval(myInterval);
            }
        }, 1000);
    }
    loadSectionOnResume(surveyId, sectionId) {
        this._loading.next(true);
        this._questionApi.getSection(surveyId, sectionId).subscribe((res) => {
            this.loadStepper(surveyId);
        });
    }
    saveQuestion(form, surveyId, sectionId, title, subtitle) {
        // this.loadingController.startLoading(title, subtitle);
        this._loadingQuestionSave.next(true);
        return this._questionApi
            .saveQuestions(surveyId, sectionId, form)
            .pipe(finalize(() => {
            // this._loading.next(false);
            this._loadingQuestionSave.next(false);
            this.loadingController.stopLoading();
            setTimeout(() => { this.loadingController.stopLoading(); }, 500);
        }), catchError((error) => {
            var _a;
            this._questionApi.errorDni((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.documentFail);
            return this.handleError(error);
        }));
    }
    handleError(error) {
        //En espera de más estatus
        switch (error.status) {
            case 466: //Alpaca
                this._loadingQuestionSave.next(false);
                this.loadingController.stopLoading();
                break;
            default: //400
                this._loadingQuestionSave.next(false);
                this.loadingController.stopLoading();
                break;
        }
        return throwError(() => new Error('Error'));
    }
    saveQuestionForm(form, surveyId, sectionId, isResume = false) {
        this.saveQuestion(form, surveyId, sectionId).subscribe((res) => {
            if (isResume) {
                this.currentEnd(surveyId);
            }
            else {
                this.loadStepper(surveyId);
            }
        }, (error) => {
        });
    }
    ReorderQuestions(questions) {
        this.preguntas = [];
        questions.map((data) => {
            switch (data.inputType) {
                case 'Text': {
                    if (data.validationId === null) {
                        this.preguntas.push(new TextboxQuestion(data));
                    }
                    else {
                        if (data.validationId === VALIDATOR_CEDULA) {
                            this.preguntas.push(new TextDniQuestion(data));
                        }
                        if (data.validationId === VALIDATOR_EMAIL) {
                            this.preguntas.push(new TextEmailQuestion(data));
                        }
                        if (data.validationId === VALIDATOR_PASAPORTE) {
                            this.preguntas.push(new TextPassportQuestion(data));
                        }
                        if (data.validationId === VALIDATOR_TELEFONO) {
                            this.preguntas.push(new TextPhoneQuestion(data));
                        }
                    }
                    break;
                }
                case 'Number':
                    this.preguntas.push(new NumberQuestion(data));
                    break;
                case 'Country':
                    this.preguntas.push(new CountryQuestion(data));
                    break;
                case 'Profession':
                case 'Activity':
                case 'Bank':
                case 'Select': {
                    this.preguntas.push(new DropdownQuestion(data));
                    break;
                }
                case 'Radio':
                    this.preguntas.push(new RadioQuestion(data));
                    break;
                case 'Fecha':
                    this.preguntas.push(new DatepickerQuestion(data));
                    break;
                case 'Check':
                    this.preguntas.push(new CheckboxQuestion(data));
                    break;
                case 'Toggle':
                    this.preguntas.push(new CheckboxQuestion(data));
                    break;
                case 'File':
                    this.preguntas.push(new FileQuestion(data));
                    break;
                case 'Table':
                    this.preguntas.push(new TableQuestion(data));
                    break;
                default:
                    break;
            }
        });
        return this.preguntas.sort((a, b) => a.order - b.order);
    }
}
QuestionsManagerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionsManagerService, deps: [{ token: QuestionApiService }, { token: alertService }], target: i0.ɵɵFactoryTarget.Injectable });
QuestionsManagerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionsManagerService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: QuestionsManagerService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }], ctorParameters: function () { return [{ type: QuestionApiService }, { type: alertService }]; } });

class SettingsManagerService {
    constructor(_settingApi, _storage) {
        this._settingApi = _settingApi;
        this._storage = _storage;
        this.loading = { goodbye: false, welcome: false, contact: false, status: false };
        this._settingLoading = new BehaviorSubject(this.loading);
    }
    getLoadingSettings() {
        return this._settingLoading.asObservable();
    }
    loadMessage(orgUuid, surveyUuid) {
        const message = new Subject();
        this.loading.welcome = true;
        // this._settingApi
        this._settingApi.getMessage(orgUuid, surveyUuid)
            .pipe(finalize(() => { this.loading.welcome = false; }))
            .subscribe((res) => {
            message.next(res);
            this._settingLoading.next(this.loading);
        });
        return message.asObservable();
    }
    loadWelcomeMessage(uuid) {
        const message = new Subject();
        this.loading.welcome = true;
        // this._settingApi
        this._settingApi.getWelcomeMessage(uuid)
            .pipe(finalize(() => { this.loading.welcome = false; }))
            .subscribe((res) => {
            message.next(res);
            this._settingLoading.next(this.loading);
        });
        return message.asObservable();
    }
    loadGoodbyeMessage(uuid) {
        const message = new Subject();
        this.loading.goodbye = true;
        this._settingApi.getGoodbyeMessage(uuid)
            .pipe(finalize(() => { this.loading.goodbye = false; }))
            .subscribe((res) => {
            message.next(res);
            this._settingLoading.next(this.loading);
        });
        return message.asObservable();
    }
    loadContactMessage(uuid) {
        const message = new Subject();
        this.loading.contact = true;
        this._settingApi.getContactMessage(uuid)
            .pipe(finalize(() => { this.loading.contact = false; }))
            .subscribe((res) => {
            message.next(res);
            this._settingLoading.next(this.loading);
        });
        return message.asObservable();
    }
    loadStatusMessage(uuid) {
        const statusMessages = new Subject();
        this.loading.status = true;
        this._settingApi.getStatusMessage(uuid)
            .pipe(finalize(() => { this.loading.status = false; }))
            .subscribe((res) => {
            statusMessages.next(res);
            this._settingLoading.next(this.loading);
        });
        return statusMessages.asObservable();
    }
    getOrganizationUUID() {
        let promise = new Promise((resolve, reject) => {
            // let data =  this._storage.getItem("theme"); //obtengo del localstorage el objeto theme, para extraer el uuid de la empresa logueada
            let data = this._storage.getItem("organization_uuid"); //obtengo del localstorage el objeto theme, para extraer el uuid de la empresa logueada      
            data ? resolve(data) : reject(ErrorMessages.setting.uuidNotFound);
        });
        return promise;
    }
}
SettingsManagerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SettingsManagerService, deps: [{ token: SettingsApiService }, { token: StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
SettingsManagerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SettingsManagerService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: SettingsManagerService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return [{ type: SettingsApiService }, { type: StorageService }]; } });

class MembershipManagerService {
    constructor(_membershipApi, _storage) {
        this._membershipApi = _membershipApi;
        this._storage = _storage;
        this._loading = new BehaviorSubject(false);
        this._planData = new BehaviorSubject([]);
        this._userData = new Subject();
    }
    getLoading() {
        return this._loading.asObservable();
    }
    getPlanData() {
        return this._planData.asObservable();
    }
    getUserData() {
        return this._userData.asObservable();
    }
    loadPlanData() {
        this._loading.next(true);
        this._membershipApi
            .getPlanData()
            .pipe(finalize(() => this._loading.next(false)))
            .subscribe((res) => {
            if (res && res.data)
                this._planData.next(res.data);
        });
    }
    verifyTdc(body) {
        this._loading.next(true);
        this._membershipApi
            .verifyTdc(body)
            .pipe(finalize(() => this._loading.next(false)))
            .subscribe((res) => {
        });
    }
    loadUserData(email) {
        this._membershipApi
            .getUserData(email)
            .subscribe((res) => {
            this._userData.next(res.data);
        });
    }
}
MembershipManagerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MembershipManagerService, deps: [{ token: MembershipApiService }, { token: StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
MembershipManagerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MembershipManagerService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MembershipManagerService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return [{ type: MembershipApiService }, { type: StorageService }]; } });

class PagerService {
    getPager(totalItems, currentPage = 1, pageSize = 1) {
        // calculate total pages
        let totalPages = Math.ceil(totalItems / pageSize);
        let startPage, endPage;
        if (totalPages <= 3) {
            // less than 3 total pages so show all
            startPage = 1;
            endPage = totalPages;
        }
        else {
            // more than 3 total pages so calculate start and end pages         
            if (currentPage < 2) {
                startPage = 1;
                endPage = 3;
            }
            else if (currentPage + 1 >= totalPages) {
                startPage = totalPages - 2;
                endPage = totalPages;
            }
            else {
                startPage = currentPage - 1;
                endPage = currentPage + 1;
            }
        }
        // calculate start and end item indexes
        let startIndex = (currentPage - 1) * pageSize;
        let endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);
        // create an array of pages to ng-repeat in the pager control
        let pages = _.range(startPage, endPage + 1);
        // return object with all pager properties required by the view
        return {
            totalItems: totalItems,
            currentPage: currentPage,
            pageSize: pageSize,
            totalPages: totalPages,
            startPage: startPage,
            endPage: endPage,
            startIndex: startIndex,
            endIndex: endIndex,
            pages: pages
        };
    }
}
PagerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: PagerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
PagerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: PagerService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: PagerService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

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

export { AlertSubtitle, AlertTitle, AuthApiService, AuthService, CheckboxQuestion, ColorTypes, CorrectionPayload, DDMaterialModule, DatepickerQuestion, DropdownQuestion, DropdownQuestionNotMultiple, ENVIRONMENT_TOKEN, ErrorMessages, FEATURE_OFAC, FEATURE_RISKMATRIX, FINISH_EVENT_KYC, FileQuestion, FinishPayload, FormEstatusEnum, Group, GroupBase, INTERCEPTOR_ADMIN, INTERCEPTOR_CUSTOMER, INTERCEPTOR_TYPE, JuridicUserEnum, KYCEventConfig, MembershipApiService, MembershipManagerService, NaturalUserEnum, NumberQuestion, OrganizationApiService, PagerService, PipeModule, QuestionApiService, QuestionBase, QuestionControlService, QuestionFile, QuestionsManagerService, RadioQuestion, SafePipe, SettingsApiService, SettingsManagerService, StorageService, SuccessMessages, TableQuestion, TextDniQuestion, TextEmailQuestion, TextPassportQuestion, TextPhoneQuestion, TextboxQuestion, ThemeManagerService, ThemeType, USERTYPES, UserJuridicType, UserNaturalType, VALIDATOR_CEDULA, VALIDATOR_EMAIL, VALIDATOR_PASAPORTE, VALIDATOR_TELEFONO, alertService, validation_messages };
//# sourceMappingURL=ddcheck-ionic-src-lib-common.mjs.map
