/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./src/app/messages/chunks/pageSelectors.ts"
/*!**************************************************!*\
  !*** ./src/app/messages/chunks/pageSelectors.ts ***!
  \**************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   PageSelectors: () => (/* binding */ PageSelectors)
/* harmony export */ });
class PageSelectors {
    constructor(params) {
        Object.keys(params).forEach((key) => {
            this[key] = params[key];
        });
    }
}


/***/ },

/***/ "./src/app/messages/index.ts"
/*!***********************************!*\
  !*** ./src/app/messages/index.ts ***!
  \***********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createErrorMessage: () => (/* binding */ createErrorMessage),
/* harmony export */   createExecuteContentScriptMessage: () => (/* binding */ createExecuteContentScriptMessage),
/* harmony export */   createGetClaimButtonMessage: () => (/* binding */ createGetClaimButtonMessage),
/* harmony export */   createGetDocumentReadyStateMessage: () => (/* binding */ createGetDocumentReadyStateMessage),
/* harmony export */   createGetElementMessage: () => (/* binding */ createGetElementMessage),
/* harmony export */   createGetPageLoginFormMessage: () => (/* binding */ createGetPageLoginFormMessage),
/* harmony export */   createGetPageSearchFormMessage: () => (/* binding */ createGetPageSearchFormMessage),
/* harmony export */   createGetTouristLinksMessage: () => (/* binding */ createGetTouristLinksMessage),
/* harmony export */   createReplaceUrlMessage: () => (/* binding */ createReplaceUrlMessage),
/* harmony export */   createStateMessage: () => (/* binding */ createStateMessage),
/* harmony export */   createTabMessage: () => (/* binding */ createTabMessage)
/* harmony export */ });
/* harmony import */ var _messageConstants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./messageConstants */ "./src/app/messages/messageConstants.ts");

function createTabMessage() {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.GET_PAGE_STATUS,
        payload: null
    };
}
function createStateMessage(inputClaimId, isClaimPage, claimNumber, sourceId, secretField, claimId, senderElementId, paymentOperationId, additionalInfo) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.STATE_MESSAGE,
        payload: {
            inputClaimId,
            isClaimPage,
            claimId,
            claimNumber,
            sourceId,
            secretField,
            senderElementId,
            paymentOperationId,
            additionalInfo,
        }
    };
}
function createGetDocumentReadyStateMessage() {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.GET_DOCUMENT_STATE
    };
}
function createGetElementMessage(payload) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.GET_ELEMENT_MESSAGE,
        payload
    };
}
function createGetTouristLinksMessage(payload) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.GET_TOURIST_LINKS,
        payload
    };
}
function createGetPageSearchFormMessage(payload) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.GET_PAGE_SEARCH_FORM,
        payload
    };
}
function createReplaceUrlMessage() {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.REPLACE_TOUR_LINK
    };
}
function createGetPageLoginFormMessage(payload) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.GET_PAGE_LOGIN_FORM,
        payload
    };
}
function createGetClaimButtonMessage(payload) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.GET_CLAIM_BUTTON,
        payload
    };
}
function createErrorMessage(error) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.ERROR_MESSAGE,
        error,
        payload: null
    };
}
function createExecuteContentScriptMessage(data) {
    return {
        type: _messageConstants__WEBPACK_IMPORTED_MODULE_0__.EXECUTE_CONTENT_SCRIPT,
        payload: data
    };
}


/***/ },

/***/ "./src/app/messages/messageConstants.ts"
/*!**********************************************!*\
  !*** ./src/app/messages/messageConstants.ts ***!
  \**********************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ERROR_MESSAGE: () => (/* binding */ ERROR_MESSAGE),
/* harmony export */   EXECUTE_CONTENT_SCRIPT: () => (/* binding */ EXECUTE_CONTENT_SCRIPT),
/* harmony export */   EXECUTE_SCRIPT: () => (/* binding */ EXECUTE_SCRIPT),
/* harmony export */   GET_CLAIM_BUTTON: () => (/* binding */ GET_CLAIM_BUTTON),
/* harmony export */   GET_DOCUMENT_STATE: () => (/* binding */ GET_DOCUMENT_STATE),
/* harmony export */   GET_ELEMENT_MESSAGE: () => (/* binding */ GET_ELEMENT_MESSAGE),
/* harmony export */   GET_IDS_MESSAGE: () => (/* binding */ GET_IDS_MESSAGE),
/* harmony export */   GET_IDS_MESSAGE_AND_STATUS: () => (/* binding */ GET_IDS_MESSAGE_AND_STATUS),
/* harmony export */   GET_PAGE_LOGIN_FORM: () => (/* binding */ GET_PAGE_LOGIN_FORM),
/* harmony export */   GET_PAGE_SEARCH_FORM: () => (/* binding */ GET_PAGE_SEARCH_FORM),
/* harmony export */   GET_PAGE_STATUS: () => (/* binding */ GET_PAGE_STATUS),
/* harmony export */   GET_TOURIST_LINKS: () => (/* binding */ GET_TOURIST_LINKS),
/* harmony export */   REPLACE_TOUR_LINK: () => (/* binding */ REPLACE_TOUR_LINK),
/* harmony export */   STATE_MESSAGE: () => (/* binding */ STATE_MESSAGE)
/* harmony export */ });
const STATE_MESSAGE = 'STATE MESSAGE';
const ERROR_MESSAGE = 'ERROR MESSAGE';
const GET_PAGE_STATUS = 'GET PAGE STATUS';
const GET_IDS_MESSAGE = 'GET IDS';
const GET_DOCUMENT_STATE = 'GET DOCUMENT STATE';
const GET_ELEMENT_MESSAGE = 'GET ELEMENT';
const GET_TOURIST_LINKS = 'GET TOURIST LINKS';
const GET_PAGE_LOGIN_FORM = 'GET PAGE LOGIN FORM';
const GET_PAGE_SEARCH_FORM = 'GET PAGE SEARCH FORM';
const GET_CLAIM_BUTTON = 'GET CLAIM BUTTON';
const GET_IDS_MESSAGE_AND_STATUS = 'GET IDS MESSAGE AND STATUS';
const EXECUTE_SCRIPT = 'EXECUTE SCRIPT';
const REPLACE_TOUR_LINK = 'REPLACE TOUR LINK';
const EXECUTE_CONTENT_SCRIPT = 'EXECUTE CONTENT SCRIPT';


/***/ },

/***/ "./src/app/models/chunks/createFillFnMessage.ts"
/*!******************************************************!*\
  !*** ./src/app/models/chunks/createFillFnMessage.ts ***!
  \******************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createFillFnMessage: () => (/* binding */ createFillFnMessage)
/* harmony export */ });
/* harmony import */ var _notificationBody__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notificationBody */ "./src/app/models/chunks/notificationBody.ts");

function createFillFnMessage({ claimId, operator, errorText }) {
    return {
        title: errorText === null
            ? _notificationBody__WEBPACK_IMPORTED_MODULE_0__.FillFnMessageTexts.DONE
            : _notificationBody__WEBPACK_IMPORTED_MODULE_0__.FillFnMessageTexts.FAIL,
        body: {
            claimId,
            operator,
            errorText
        },
        toString() {
            return this.body.errorText
                ? `
                    Ошибка: ${this.body.errorText}\n
                    Tуроператор: ${this.body.operator.title}, Заявка №${this.body.claimId}`
                : `Tуроператор: ${this.body.operator.title}, Заявка №${this.body.claimId}`;
        }
    };
}


/***/ },

/***/ "./src/app/models/chunks/createSendIdsMessage.ts"
/*!*******************************************************!*\
  !*** ./src/app/models/chunks/createSendIdsMessage.ts ***!
  \*******************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createSendIdsMessage: () => (/* binding */ createSendIdsMessage)
/* harmony export */ });
/* harmony import */ var _notificationBody__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notificationBody */ "./src/app/models/chunks/notificationBody.ts");

function createSendIdsMessage({ status, message }) {
    return {
        title: status === _notificationBody__WEBPACK_IMPORTED_MODULE_0__.SendIdsStatus.DONE
            ? _notificationBody__WEBPACK_IMPORTED_MODULE_0__.SendIdsStatusTexts.DONE
            : _notificationBody__WEBPACK_IMPORTED_MODULE_0__.SendIdsStatusTexts.FAIL,
        body: {
            status,
            message
        },
        toString() {
            return this.body.status === _notificationBody__WEBPACK_IMPORTED_MODULE_0__.SendIdsStatus.FAIL
                ? `Ошибка отправки: ${this.body.message}`
                : `Успешная отправка: ${this.body.message}`;
        }
    };
}


/***/ },

/***/ "./src/app/models/chunks/notificationBody.ts"
/*!***************************************************!*\
  !*** ./src/app/models/chunks/notificationBody.ts ***!
  \***************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   FillFnMessageTexts: () => (/* binding */ FillFnMessageTexts),
/* harmony export */   SendIdsStatus: () => (/* binding */ SendIdsStatus),
/* harmony export */   SendIdsStatusTexts: () => (/* binding */ SendIdsStatusTexts)
/* harmony export */ });
var SendIdsStatus;
(function (SendIdsStatus) {
    SendIdsStatus["DONE"] = "DONE";
    SendIdsStatus["FAIL"] = "FAIL";
})(SendIdsStatus || (SendIdsStatus = {}));
var SendIdsStatusTexts;
(function (SendIdsStatusTexts) {
    SendIdsStatusTexts["DONE"] = "\u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u044B \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043F\u0435\u0440\u0435\u0434\u0430\u043D\u044B \u043D\u0430 \u0441\u0435\u0440\u0432\u0435\u0440!";
    SendIdsStatusTexts["FAIL"] = "\u041F\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u043E\u0432 \u043D\u0435 \u0443\u0434\u0430\u043B\u0430\u0441\u044C";
})(SendIdsStatusTexts || (SendIdsStatusTexts = {}));
var FillFnMessageTexts;
(function (FillFnMessageTexts) {
    FillFnMessageTexts["DONE"] = "\u0417\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u043E \u0443\u0441\u043F\u0435\u0448\u043D\u043E!";
    FillFnMessageTexts["FAIL"] = "\u0417\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u043D\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u043E";
})(FillFnMessageTexts || (FillFnMessageTexts = {}));


/***/ },

/***/ "./src/app/models/errors.ts"
/*!**********************************!*\
  !*** ./src/app/models/errors.ts ***!
  \**********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   RequestError: () => (/* binding */ RequestError)
/* harmony export */ });
class RequestError extends Error {
    constructor(reason) {
        super(reason);
        this.name = 'RequestError';
        this.message = 'Ошибка запроса';
        this.message = `${this.message}: ${reason}`;
    }
}


/***/ },

/***/ "./src/app/models/index.ts"
/*!*********************************!*\
  !*** ./src/app/models/index.ts ***!
  \*********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ClaimConfirmationStatus: () => (/* binding */ ClaimConfirmationStatus),
/* harmony export */   EmptyScript: () => (/* binding */ EmptyScript),
/* harmony export */   ErrorTypes: () => (/* binding */ ErrorTypes),
/* harmony export */   MessageTypes: () => (/* binding */ MessageTypes),
/* harmony export */   PageStatuses: () => (/* binding */ PageStatuses),
/* harmony export */   RequestError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.RequestError),
/* harmony export */   ScriptType: () => (/* binding */ ScriptType),
/* harmony export */   SenderTypes: () => (/* binding */ SenderTypes)
/* harmony export */ });
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "./src/app/models/errors.ts");

var ScriptType;
(function (ScriptType) {
    ScriptType[ScriptType["Login"] = 0] = "Login";
    ScriptType[ScriptType["FormFill"] = 1] = "FormFill";
    ScriptType[ScriptType["VisaFill"] = 2] = "VisaFill";
    ScriptType[ScriptType["NavToBookedClaim"] = 3] = "NavToBookedClaim";
})(ScriptType || (ScriptType = {}));
const EmptyScript = {
    scriptId: '',
    tourOperatorId: '',
    sletatId: 0,
    body: '',
    createDateUtc: '',
    type: ScriptType.Login,
    isActive: false,
    version: '',
};
var ClaimConfirmationStatus;
(function (ClaimConfirmationStatus) {
    ClaimConfirmationStatus[ClaimConfirmationStatus["NOT_CONFIRMED"] = 1] = "NOT_CONFIRMED";
    ClaimConfirmationStatus[ClaimConfirmationStatus["WAITING"] = 2] = "WAITING";
    ClaimConfirmationStatus[ClaimConfirmationStatus["CONFIRMED"] = 3] = "CONFIRMED";
})(ClaimConfirmationStatus || (ClaimConfirmationStatus = {}));
var ErrorTypes;
(function (ErrorTypes) {
    ErrorTypes["NO_CLAIM_PAGE"] = "\u0412\u044B \u043D\u0435 \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u0435\u0441\u044C \u043D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0435 \u0437\u0430\u044F\u0432\u043A\u0438";
    ErrorTypes["NO_VISA_NEEDED"] = "\u041E\u0444\u043E\u0440\u043C\u043B\u0435\u043D\u0438\u0435 \u0432\u0438\u0437\u044B \u0434\u043B\u044F \u0434\u0430\u043D\u043D\u043E\u0439 \u0437\u0430\u044F\u0432\u043A\u0438 \u043D\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044F";
    ErrorTypes["NO_TO_ID"] = "\u041F\u0435\u0440\u0435\u0445\u043E\u0434 \u0432 \u041B\u041A \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u0435\u043D. \u041D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0435 \u0426\u0411 \u043D\u0435 \u0443\u043A\u0430\u0437\u0430\u043D id \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430, \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u043F\u043E\u0437\u0436\u0435.";
    ErrorTypes["NO_CLAIM_ID"] = "\u041F\u0435\u0440\u0435\u0445\u043E\u0434 \u0432 \u041B\u041A \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u0435\u043D. \u041D\u0435 \u043F\u0440\u043E\u0441\u0442\u0430\u0432\u043B\u0435\u043D \u043D\u043E\u043C\u0435\u0440 \u0437\u0430\u044F\u0432\u043A\u0438 \u0442\u0443\u0440\u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430.";
    ErrorTypes["TO_NOT_SUPPORTED"] = "\u0423\u0432\u044B, \u0424\u0438\u043B\u044F \u043F\u043E\u043A\u0430 \u0447\u0442\u043E \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043F\u0435\u0440\u0435\u0445\u043E\u0434 \u0432 \u041B\u041A \u0434\u0430\u043D\u043D\u043E\u0433\u043E \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 :(";
    ErrorTypes["TO_RESTRICTED"] = "\u0414\u0430\u043D\u043D\u044B\u0439 \u0442\u0443\u0440\u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u043D\u0435 \u043F\u0440\u0435\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u044F\u0435\u0442 \u043F\u0440\u044F\u043C\u0443\u044E \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0442\u0443\u0440, \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0432\u0440\u0443\u0447\u043D\u0443\u044E";
    ErrorTypes["CLAIM_ALREADY_BOOKED"] = "\u0414\u0430\u043D\u043D\u0430\u044F \u0437\u0430\u044F\u0432\u043A\u0430 \u0443\u0436\u0435 \u0431\u044B\u043B\u0430 \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0430 \u0438 \u0437\u0430\u0431\u0440\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u043D\u0430 \u043D\u0430 \u0441\u0430\u0439\u0442\u0435 \u0442\u0443\u0440\u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430. \u0427\u0442\u043E\u0431\u044B \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u0435\u0435, \u0432\u043E\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435\u0441\u044C \u043A\u043D\u043E\u043F\u043A\u043E\u0439 \"\u041B\u0443\u043F\u0430\"";
    ErrorTypes["UNKNOWN"] = "\u041F\u0435\u0440\u0435\u0445\u043E\u0434 \u0432 \u041B\u041A \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u0435\u043D. \u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430.";
})(ErrorTypes || (ErrorTypes = {}));
var MessageTypes;
(function (MessageTypes) {
    MessageTypes["GET_PAGE_STATUS"] = "GET PAGE STATUS";
    MessageTypes["PASS_TO_CREDS"] = "PASS TO CREDS";
    MessageTypes["ERROR"] = "ERROR";
    MessageTypes["GET_IDS"] = "GET IDS";
    MessageTypes["GET_ELEMENT"] = "GET ELEMENT";
    MessageTypes["GET_TOURIST_LINKS"] = "GET TOURIST LINKS";
    MessageTypes["GET_PAGE_LOGIN_FORM"] = "GET PAGE LOGIN FORM";
    MessageTypes["GET_PAGE_SEARCH_FORM"] = "GET PAGE SEARCH FORM";
    MessageTypes["GET_CLAIM_BUTTON"] = "GET CLAIM BUTTON";
    MessageTypes["GET_DOCUMENT_STATE"] = "GET DOCUMENT STATE";
    MessageTypes["GET_IDS_MESSAGE_AND_STATUS"] = "GET IDS MESSAGE AND STATUS";
    MessageTypes["REPLACE_TOUR_LINK"] = "REPLACE TOUR LINK";
    MessageTypes["EXECUTE_CONTENT_SCRIPT"] = "EXECUTE CONTENT SCRIPT";
})(MessageTypes || (MessageTypes = {}));
var PageStatuses;
(function (PageStatuses) {
    PageStatuses["IS_CLAIM_PAGE"] = "IS_CLAIM_PAGE";
    PageStatuses["IS_OPERATOR_SUPPORTED"] = "IS_OPERATOR_SUPPORTED";
})(PageStatuses || (PageStatuses = {}));
var SenderTypes;
(function (SenderTypes) {
    SenderTypes[SenderTypes["TAB_SENDER"] = 0] = "TAB_SENDER";
    SenderTypes[SenderTypes["EXT_SENDER"] = 1] = "EXT_SENDER";
})(SenderTypes || (SenderTypes = {}));


/***/ },

/***/ "./src/app/operators.ts"
/*!******************************!*\
  !*** ./src/app/operators.ts ***!
  \******************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   OPERATORS: () => (/* binding */ OPERATORS),
/* harmony export */   tryGetOperator: () => (/* binding */ tryGetOperator)
/* harmony export */ });
const tryGetOperator = (sletatId, toAlias) => {
    console.log(`tryGetOperator sletatId = ${sletatId}, ${toAlias}`);
    // if (sletatId) {
    //     const op = OPERATORS[sletatId];
    //     if (op) { return op; }
    // }
    // if (toAlias) {
    //     const op = OPERATORS[toAlias as string];
    //     if (op) { return op; }
    // }
    return {
        link: (operatorClaimId) => `https://online.aqua-travelgroup.com`,
        title: 'AquaTravelGroup',
        authType: 'forms',
        claimUrlAuthType: 'forms',
        credentials: {
            packet: {
                loginPath: "",
                passwordPath: "",
                submitPath: ""
            },
        },
        selectors: {},
        cookie: {
            auth: ['']
        }
    };
};
const OPERATORS = {};


/***/ },

/***/ "./src/app/services/chunks/getFillerDataByClaimId.ts"
/*!***********************************************************!*\
  !*** ./src/app/services/chunks/getFillerDataByClaimId.ts ***!
  \***********************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   getFillerDataByClaimId: () => (/* binding */ getFillerDataByClaimId)
/* harmony export */ });
/* harmony import */ var _utils_chunks_constants_urls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../utils/chunks/constants_urls */ "./src/app/utils/chunks/constants_urls.ts");

function getFillerDataByClaimId(claimId) {
    return fetch(`${_utils_chunks_constants_urls__WEBPACK_IMPORTED_MODULE_0__.lfApiUrl}/${claimId}`)
        .then(response => response.json());
}


/***/ },

/***/ "./src/app/utils/chunks/constants_urls.ts"
/*!************************************************!*\
  !*** ./src/app/utils/chunks/constants_urls.ts ***!
  \************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CB_CLAIM_FULL_PATH: () => (/* binding */ CB_CLAIM_FULL_PATH),
/* harmony export */   CB_CLAIM_ID_PARAM: () => (/* binding */ CB_CLAIM_ID_PARAM),
/* harmony export */   CB_CLAIM_PATH: () => (/* binding */ CB_CLAIM_PATH),
/* harmony export */   CB_HOSTS: () => (/* binding */ CB_HOSTS),
/* harmony export */   lfApiUrl: () => (/* binding */ lfApiUrl),
/* harmony export */   scriptsApiUrl: () => (/* binding */ scriptsApiUrl)
/* harmony export */ });
// const env: string = 'local';
// const env: string = 'dev';
const env = 'prod';
// local api: http://local-api-cbdebug.sletat.ru
// dev api: https://api-cbdebug.sletat.ru
// urls
const lfApiUrl = 'https://letsfly.sletat.ru/api/freighthub/v1/autofill';
// TODO: не забыть поменять обратно https://autofill-api.sletat.ru
const scriptsApiUrl = env === 'local' || env === 'dev' ?
    'https://autofill-api.global.sletat.ru' :
    'https://autofill-api.global.sletat.ru';
//https://autofill-api.sletat.ru;
// dev-api: cbdebug.sletat.ru
// local-api: local-booking.sletat.ru
// url parts
const CB_HOSTS = env === 'local' ?
    ['127.0.0.1:8080', 'local-booking.sletat.ru'] :
    env === 'dev' ?
        ['cbdebug.sletat.ru', 'cbdebug7.sletat.ru'] :
        ['cb.sletat.ru', 'cb-25.sletat.ru', 'cb-75.sletat.ru', 'cb-rsv.sletat.ru', 'cb.global.sletat.ru'];
const CB_CLAIM_PATH = '/Claim';
const CB_CLAIM_FULL_PATH = '/Claim/Index';
const CB_CLAIM_ID_PARAM = 'claimId';


/***/ },

/***/ "./src/app/utils/chunks/createPushNotification.ts"
/*!********************************************************!*\
  !*** ./src/app/utils/chunks/createPushNotification.ts ***!
  \********************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createPushNotification: () => (/* binding */ createPushNotification)
/* harmony export */ });
/* harmony import */ var _models_chunks_createFillFnMessage__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../models/chunks/createFillFnMessage */ "./src/app/models/chunks/createFillFnMessage.ts");
/* harmony import */ var _models_chunks_createSendIdsMessage__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../models/chunks/createSendIdsMessage */ "./src/app/models/chunks/createSendIdsMessage.ts");


function createPushNotification(options) {
    let pushMessage = { title: '', body: { toString: () => '' } };
    switch (true) {
        case (options.hasOwnProperty('claimId')):
            const { claimId, operator, errorText } = options;
            pushMessage = (0,_models_chunks_createFillFnMessage__WEBPACK_IMPORTED_MODULE_0__.createFillFnMessage)({ claimId, operator, errorText });
            break;
        case (options.hasOwnProperty('status')):
            const { status, message } = options;
            pushMessage = (0,_models_chunks_createSendIdsMessage__WEBPACK_IMPORTED_MODULE_1__.createSendIdsMessage)({ status, message });
            break;
        case (options.hasOwnProperty('notificationMessage')):
            const { notificationMessage, title } = options;
            pushMessage.body = notificationMessage;
            pushMessage.title = title;
            pushMessage.toString = () => pushMessage.body.toString();
            break;
        default:
            break;
    }
    return new Promise((resolve, reject) => {
        chrome.notifications.create({ type: 'basic', iconUrl: 'lf_icon_3232.png', title: pushMessage.title, message: pushMessage.toString() }, () => resolve());
    });
}


/***/ },

/***/ "./src/app/utils/chunks/createTab.ts"
/*!*******************************************!*\
  !*** ./src/app/utils/chunks/createTab.ts ***!
  \*******************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createNewTab: () => (/* binding */ createNewTab),
/* harmony export */   createTab: () => (/* binding */ createTab)
/* harmony export */ });
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
function createTab(_a) {
    return __awaiter(this, arguments, void 0, function* ({ active, url }) {
        var tabs = yield chrome.tabs.query({ active: true, lastFocusedWindow: true });
        const properties = {
            url: url,
            active: active,
            index: tabs && tabs.length >= 1
                ? tabs[0].index + 1
                : undefined
        };
        var tab = yield chrome.tabs.create(properties);
        return tab;
    });
}
function createNewTab(url) {
    return __awaiter(this, void 0, void 0, function* () {
        return createTab({
            active: true,
            url: url,
            windowId: chrome.windows.WINDOW_ID_CURRENT
        });
    });
}


/***/ },

/***/ "./src/app/utils/chunks/executeLoginScriptInTabV3.ts"
/*!***********************************************************!*\
  !*** ./src/app/utils/chunks/executeLoginScriptInTabV3.ts ***!
  \***********************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   executeLoginScriptInTabV3: () => (/* binding */ executeLoginScriptInTabV3),
/* harmony export */   executeReactLoginScriptInTabV3: () => (/* binding */ executeReactLoginScriptInTabV3)
/* harmony export */ });
/* harmony import */ var _executeScriptInTab__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./executeScriptInTab */ "./src/app/utils/chunks/executeScriptInTab.ts");
/* harmony import */ var _loginFormCode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./loginFormCode */ "./src/app/utils/chunks/loginFormCode.ts");
/* harmony import */ var _loginFormCodeReact__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./loginFormCodeReact */ "./src/app/utils/chunks/loginFormCodeReact.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};



function executeLoginScriptInTabV3(tab, selector) {
    return __awaiter(this, void 0, void 0, function* () {
        yield (0,_executeScriptInTab__WEBPACK_IMPORTED_MODULE_0__.executeScriptInTabV3)(tab, _loginFormCode__WEBPACK_IMPORTED_MODULE_1__.getLoginFormCode, [selector]);
    });
}
function executeReactLoginScriptInTabV3(tab, selector) {
    return __awaiter(this, void 0, void 0, function* () {
        yield (0,_executeScriptInTab__WEBPACK_IMPORTED_MODULE_0__.executeScriptInTabV3)(tab, _loginFormCodeReact__WEBPACK_IMPORTED_MODULE_2__.getReactLoginFormCode, [selector]);
    });
}


/***/ },

/***/ "./src/app/utils/chunks/executeScriptInTab.ts"
/*!****************************************************!*\
  !*** ./src/app/utils/chunks/executeScriptInTab.ts ***!
  \****************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   executeScriptInTabV3: () => (/* binding */ executeScriptInTabV3)
/* harmony export */ });
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
function executeScriptInTabV3(tab, func, args) {
    return __awaiter(this, void 0, void 0, function* () {
        // @ts-ignore
        let result = yield chrome.scripting.executeScript({
            target: { tabId: tab.id },
            func: func,
            args: args,
            // @ts-ignore
            world: 'MAIN'
        });
        return result[0];
    });
}


/***/ },

/***/ "./src/app/utils/chunks/loginFormCode.ts"
/*!***********************************************!*\
  !*** ./src/app/utils/chunks/loginFormCode.ts ***!
  \***********************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   getLoginFormCode: () => (/* binding */ getLoginFormCode)
/* harmony export */ });
function getLoginFormCode(pageSelectors) {
    try {
        debugger;
        console.log('getLoginFormCode');
        console.dir(pageSelectors);
        console.log(pageSelectors.packet.loginPath);
        console.log(pageSelectors.packet.passwordPath);
        console.log(pageSelectors.packet.submitPath);
        let login = document.querySelector(pageSelectors.packet.loginPath);
        let password = document.querySelector(pageSelectors.packet.passwordPath);
        let submit = document.querySelector(pageSelectors.packet.submitPath);
        console.log('getLoginFormCode 1');
        if (login !== null) {
            console.log('getLoginFormCode 2');
            login.dispatchEvent(new Event('focus'));
            login.value = `${pageSelectors.login}`;
            // on TUI site there's Knockout hook matching only on keypress event
            // so without this workaroud we couldn't post login value
            login.dispatchEvent(new Event('keypress', { bubbles: true }));
            login.dispatchEvent(new Event('input', { bubbles: true }));
            login.dispatchEvent(new Event('change', { bubbles: true }));
            login.dispatchEvent(new Event('blur', { bubbles: true }));
            password.dispatchEvent(new Event('focus', { bubbles: true }));
            password.value = `${pageSelectors.password}`;
            password.dispatchEvent(new Event('input', { bubbles: true }));
            password.dispatchEvent(new Event('keypress', { bubbles: true }));
            password.dispatchEvent(new Event('change', { bubbles: true }));
            password.dispatchEvent(new Event('blur', { bubbles: true }));
            setTimeout(function () { submit.click(); }, 500);
        }
    }
    catch (e) {
        console.warn(e);
    }
}


/***/ },

/***/ "./src/app/utils/chunks/loginFormCodeReact.ts"
/*!****************************************************!*\
  !*** ./src/app/utils/chunks/loginFormCodeReact.ts ***!
  \****************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   getReactLoginFormCode: () => (/* binding */ getReactLoginFormCode),
/* harmony export */   loginFormCodeReact: () => (/* binding */ loginFormCodeReact)
/* harmony export */ });
const loginFormCodeReact = ({ login, password, packet: { loginPath, passwordPath, submitPath } }) => `
    try {

        function SetReactValue(selector, value) {
            const element = document.querySelector(selector);
    
            if(element){
                let uiEvents = document.createEvent('UIEvents');
                uiEvents.initEvent('focus', false, false);
                element.dispatchEvent(uiEvents);
    
                let setValue = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
                setValue.call(element, value);
                let e = new Event('input', { bubbles: true, cancelable: false });
                element.dispatchEvent(e);
    
                uiEvents = document.createEvent('UIEvents');
                uiEvents.initEvent('blur', false, false);
                element.dispatchEvent(uiEvents);
            }
        }

        if (!login && !password && !submit) {
            var login;
            var password;
            var submit;
        }

        login = "${loginPath.replace(/\\'/g, '\\\'')}";
        password = "${passwordPath.replace(/\'/g, '\\\'')}";
        submit = document.querySelector("${submitPath.replace(/\'/g, '\\\'')}");

        if (login !== null) {

            SetReactValue(login, '${login}');
            SetReactValue(password, '${password}');

            submit.click();
        }


    } catch (e) {
        JSON.stringify({error: e.stack});
    }
`;
function getReactLoginFormCode(pageSelectors) {
    debugger;
    function SetReactValue(selector, value) {
        const element = document.querySelector(selector);
        if (element) {
            let uiEvents = document.createEvent('UIEvents');
            uiEvents.initEvent('focus', false, false);
            element.dispatchEvent(uiEvents);
            let setValue = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
            setValue.call(element, value);
            let e = new Event('input', { bubbles: true, cancelable: false });
            element.dispatchEvent(e);
            uiEvents = document.createEvent('UIEvents');
            uiEvents.initEvent('blur', false, false);
            element.dispatchEvent(uiEvents);
        }
    }
    try {
        if (!login && !password && !submit) {
            var login;
            var password;
            var submit;
        }
        login = pageSelectors.packet.loginPath;
        password = pageSelectors.packet.passwordPath;
        submit = document.querySelector(pageSelectors.packet.submitPath);
        if (login !== null) {
            SetReactValue(login, pageSelectors.login);
            SetReactValue(password, pageSelectors.password);
            submit.click();
        }
    }
    catch (e) {
        JSON.stringify({ error: e.stack });
    }
}


/***/ },

/***/ "./src/app/utils/chunks/removeCookies.ts"
/*!***********************************************!*\
  !*** ./src/app/utils/chunks/removeCookies.ts ***!
  \***********************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   removeCookies: () => (/* binding */ removeCookies),
/* harmony export */   removeCookiesCreateTabAndLogin: () => (/* binding */ removeCookiesCreateTabAndLogin),
/* harmony export */   removeCookiesForTouroperator: () => (/* binding */ removeCookiesForTouroperator)
/* harmony export */ });
/* harmony import */ var _messages_chunks_pageSelectors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../messages/chunks/pageSelectors */ "./src/app/messages/chunks/pageSelectors.ts");
/* harmony import */ var _createTab__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./createTab */ "./src/app/utils/chunks/createTab.ts");
/* harmony import */ var _executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./executeLoginScriptInTabV3 */ "./src/app/utils/chunks/executeLoginScriptInTabV3.ts");
/* harmony import */ var _startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./startTrackingElementInternal */ "./src/app/utils/chunks/startTrackingElementInternal.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};




function removeCookies(params) {
    return __awaiter(this, void 0, void 0, function* () {
        for (let cookieName of params.cookieNames) {
            yield chrome.cookies.remove({ url: params.url, name: cookieName });
        }
    });
}
function removeCookiesForTouroperator(operator) {
    return __awaiter(this, void 0, void 0, function* () {
        yield removeCookies({
            url: operator.link(),
            cookieNames: operator.cookie.auth
        });
    });
}
function removeCookiesCreateTabAndLogin(params) {
    return __awaiter(this, void 0, void 0, function* () {
        yield removeCookiesForTouroperator(params.operator);
        let tab = yield (0,_createTab__WEBPACK_IMPORTED_MODULE_1__.createTab)({
            active: true,
            url: params.newTabUrl
        });
        yield (0,_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_3__.startTrackingElement)(tab, params.operator.packet.loginPath);
        yield (0,_executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_2__.executeLoginScriptInTabV3)(tab, new _messages_chunks_pageSelectors__WEBPACK_IMPORTED_MODULE_0__.PageSelectors({
            login: params.login,
            password: params.password,
            packet: params.operator.packet
        }));
        return tab;
    });
}


/***/ },

/***/ "./src/app/utils/chunks/replaceUrlOnPage.ts"
/*!**************************************************!*\
  !*** ./src/app/utils/chunks/replaceUrlOnPage.ts ***!
  \**************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   replaceUrlOnPage: () => (/* binding */ replaceUrlOnPage)
/* harmony export */ });
/* harmony import */ var _messages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../messages */ "./src/app/messages/index.ts");
/* harmony import */ var _sendTabMessage__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sendTabMessage */ "./src/app/utils/chunks/sendTabMessage.ts");


function replaceUrlOnPage(tab) {
    (0,_sendTabMessage__WEBPACK_IMPORTED_MODULE_1__.sendTabMessage)(tab.id, (0,_messages__WEBPACK_IMPORTED_MODULE_0__.createReplaceUrlMessage)());
}


/***/ },

/***/ "./src/app/utils/chunks/sendTabMessage.ts"
/*!************************************************!*\
  !*** ./src/app/utils/chunks/sendTabMessage.ts ***!
  \************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   sendTabMessage: () => (/* binding */ sendTabMessage)
/* harmony export */ });
function sendTabMessage(tabId, message) {
    return new Promise((resolve, reject) => {
        chrome.tabs.sendMessage(tabId, message, (response) => {
            // console.log('RESPONSE TAB ', response);
            return resolve(response);
        });
    });
}


/***/ },

/***/ "./src/app/utils/chunks/startTrackingElementInternal.ts"
/*!**************************************************************!*\
  !*** ./src/app/utils/chunks/startTrackingElementInternal.ts ***!
  \**************************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   startTrackingElement: () => (/* binding */ startTrackingElement),
/* harmony export */   startTrackingElementDisappear: () => (/* binding */ startTrackingElementDisappear)
/* harmony export */ });
/* harmony import */ var _sendTabMessage__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sendTabMessage */ "./src/app/utils/chunks/sendTabMessage.ts");
/* harmony import */ var _messages__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../messages */ "./src/app/messages/index.ts");


// грубо говоря эта функция ждет появления selector в tab-e
function startTrackingElement(tab, selector, frame, delay = 1000, maxWaitTime = 300000) {
    return startTrackingElementInternal(response => response.element, tab, selector, frame, delay, maxWaitTime);
}
function startTrackingElementDisappear(tab, selector, frame, delay = 1000, maxWaitTime = 300000) {
    return startTrackingElementInternal(response => !response.element, tab, selector, frame, delay, maxWaitTime);
}
const startTrackingElementInternal = (conditionFunc, tab, selector, frame, delay = 1000, maxWaitTime = 300000) => {
    return new Promise((resolve, reject) => {
        const curTime = Date.now();
        const timer = setInterval(() => {
            (0,_sendTabMessage__WEBPACK_IMPORTED_MODULE_0__.sendTabMessage)(tab.id, (0,_messages__WEBPACK_IMPORTED_MODULE_1__.createGetElementMessage)({ elementSelector: selector, frame: frame }))
                .then((response) => {
                if (response && conditionFunc(response)) {
                    clearInterval(timer);
                    resolve(response);
                }
                if (Date.now() - curTime >= maxWaitTime) {
                    clearInterval(timer);
                    reject(null);
                }
            });
        }, delay);
    });
};


/***/ },

/***/ "./src/app/utils/chunks/updateListener.ts"
/*!************************************************!*\
  !*** ./src/app/utils/chunks/updateListener.ts ***!
  \************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   updateListener: () => (/* binding */ updateListener),
/* harmony export */   updateListenerOnSamePage: () => (/* binding */ updateListenerOnSamePage),
/* harmony export */   updateListenerOnSpecificNewPage: () => (/* binding */ updateListenerOnSpecificNewPage),
/* harmony export */   updateListenerOnSpecificPage: () => (/* binding */ updateListenerOnSpecificPage)
/* harmony export */ });
function updateListener(baseTabId, onUpdateFunc) {
    const updatedLiscener = (tabId, changeInfo, updatedTab) => {
        onUpdateFunc(tabId, changeInfo, updatedTab);
    };
    chrome.tabs.onUpdated.addListener(updatedLiscener);
    const removedLiscener = (tabId, removeInfo) => {
        if (tabId === baseTabId) {
            chrome.tabs.onUpdated.removeListener(updatedLiscener);
            chrome.tabs.onRemoved.removeListener(removedLiscener);
        }
    };
    chrome.tabs.onRemoved.addListener(removedLiscener);
}
function updateListenerOnSpecificPage(baseTabId, pageRegExp, onUpdateFunc) {
    const updatedLiscener = (tabId, changeInfo, updatedTab) => {
        if (changeInfo.status && changeInfo.status.toLowerCase() === 'complete'
            && tabId === baseTabId
            && updatedTab.url
            && pageRegExp.test(updatedTab.url)) {
            if (onUpdateFunc(tabId, changeInfo, updatedTab) && chrome.tabs.onUpdated.hasListener(updatedLiscener)) {
                chrome.tabs.onUpdated.removeListener(updatedLiscener);
            }
        }
    };
    chrome.tabs.onUpdated.addListener(updatedLiscener);
    const removedLiscener = (tabId, removeInfo) => {
        if (tabId === baseTabId) {
            chrome.tabs.onUpdated.removeListener(updatedLiscener);
            chrome.tabs.onRemoved.removeListener(removedLiscener);
        }
    };
    chrome.tabs.onRemoved.addListener(removedLiscener);
}
function updateListenerOnSpecificNewPage(baseTabId, pageRegExp, onUpdateFunc) {
    const updatedLiscener = (tabId, changeInfo, updatedTab) => {
        debugger;
        if (changeInfo.status && changeInfo.status.toLowerCase() === 'complete'
            && updatedTab.openerTabId
            && updatedTab.openerTabId == baseTabId
            && updatedTab.url
            && pageRegExp.test(updatedTab.url)) {
            if (onUpdateFunc(tabId, changeInfo, updatedTab) && chrome.tabs.onUpdated.hasListener(updatedLiscener)) {
                chrome.tabs.onUpdated.removeListener(updatedLiscener);
            }
        }
    };
    chrome.tabs.onUpdated.addListener(updatedLiscener);
    const removedLiscener = (tabId, removeInfo) => {
        if (tabId === baseTabId) {
            chrome.tabs.onUpdated.removeListener(updatedLiscener);
            chrome.tabs.onRemoved.removeListener(removedLiscener);
        }
    };
    chrome.tabs.onRemoved.addListener(removedLiscener);
}
function updateListenerOnSamePage(baseTabId, pageRegExp, onUpdateFunc) {
    const updatedLiscener = (tabId, changeInfo, updatedTab) => {
        debugger;
        if (changeInfo.status && changeInfo.status.toLowerCase() === 'complete'
            && updatedTab.url
            // && updatedTab.openerTabId && updatedTab.openerTabId === tabId
            && pageRegExp.test(updatedTab.url)) {
            if (onUpdateFunc(tabId, changeInfo, updatedTab) && chrome.tabs.onUpdated.hasListener(updatedLiscener)) {
                chrome.tabs.onUpdated.removeListener(updatedLiscener);
            }
        }
    };
    chrome.tabs.onUpdated.addListener(updatedLiscener);
    const removedLiscener = (tabId, removeInfo) => {
        if (tabId === baseTabId) {
            chrome.tabs.onUpdated.removeListener(updatedLiscener);
            chrome.tabs.onRemoved.removeListener(removedLiscener);
        }
    };
    chrome.tabs.onRemoved.addListener(removedLiscener);
}


/***/ },

/***/ "./src/app/utils/constants.ts"
/*!************************************!*\
  !*** ./src/app/utils/constants.ts ***!
  \************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   RU_DOMISTIC_COUNTRIES: () => (/* binding */ RU_DOMISTIC_COUNTRIES),
/* harmony export */   claimAnotherTOAliasSelector: () => (/* binding */ claimAnotherTOAliasSelector),
/* harmony export */   claimIdTOSelector: () => (/* binding */ claimIdTOSelector),
/* harmony export */   claimMagnifierButtonStyles: () => (/* binding */ claimMagnifierButtonStyles),
/* harmony export */   claimMagnifierOperatorTypes: () => (/* binding */ claimMagnifierOperatorTypes),
/* harmony export */   claimNumberSelector: () => (/* binding */ claimNumberSelector),
/* harmony export */   claimRefundFillerOperators: () => (/* binding */ claimRefundFillerOperators),
/* harmony export */   claimSecretFieldAttr: () => (/* binding */ claimSecretFieldAttr),
/* harmony export */   claimSecretFieldId: () => (/* binding */ claimSecretFieldId),
/* harmony export */   claimTOAliasSelector: () => (/* binding */ claimTOAliasSelector),
/* harmony export */   claimTransferFillerOperators: () => (/* binding */ claimTransferFillerOperators),
/* harmony export */   fileHostName: () => (/* binding */ fileHostName),
/* harmony export */   loaderImageName: () => (/* binding */ loaderImageName),
/* harmony export */   mockPrevVisasData: () => (/* binding */ mockPrevVisasData),
/* harmony export */   myAgentTicketButtonOptions: () => (/* binding */ myAgentTicketButtonOptions),
/* harmony export */   myAgentTicketTransferButtonOptions: () => (/* binding */ myAgentTicketTransferButtonOptions),
/* harmony export */   refundPaymentTOButtonOptions: () => (/* binding */ refundPaymentTOButtonOptions),
/* harmony export */   sourceAutoFillAccomodationSelector: () => (/* binding */ sourceAutoFillAccomodationSelector),
/* harmony export */   sourceAutoFillAnotherSelector: () => (/* binding */ sourceAutoFillAnotherSelector),
/* harmony export */   sourceAutoFillFlightSelector: () => (/* binding */ sourceAutoFillFlightSelector),
/* harmony export */   sourceAutoFillSelector: () => (/* binding */ sourceAutoFillSelector),
/* harmony export */   sourceAutoFillerToken: () => (/* binding */ sourceAutoFillerToken),
/* harmony export */   sourceAutoFillerTokenAccomodation: () => (/* binding */ sourceAutoFillerTokenAccomodation),
/* harmony export */   sourceAutoFillerTokenAnother: () => (/* binding */ sourceAutoFillerTokenAnother),
/* harmony export */   sourceAutoFillerTokenFlight: () => (/* binding */ sourceAutoFillerTokenFlight),
/* harmony export */   sourceIdSelector: () => (/* binding */ sourceIdSelector),
/* harmony export */   transferPaymentTOButtonOptions: () => (/* binding */ transferPaymentTOButtonOptions)
/* harmony export */ });
const RU_DOMISTIC_COUNTRIES = 'Россия,Абхазия,Беларусь,Казахстан,Армения,Киргизия';
// selectors
const sourceAutoFillSelector = 'input[data-claim="autofill-data-touroperator"]';
const sourceAutoFillAnotherSelector = 'input[data-claim="autofill-data-another-touroperator"]';
const sourceAutoFillAccomodationSelector = 'input[data-claim="autofill-data-accomodation-touroperator"]';
const sourceAutoFillFlightSelector = 'input[data-claim="autofill-data-flight-touroperator"]';
const sourceAutoFillerToken = '#AutoFillerToken';
const sourceAutoFillerTokenAnother = '#AutoFillerTokenAnother';
const sourceAutoFillerTokenAccomodation = '#AutoFillerTokenAccomodation';
const sourceAutoFillerTokenFlight = '#AutoFillerTokenFlight';
const sourceIdSelector = '[data-claim-sourceid]';
const claimNumberSelector = '[data-claim-number]';
const claimIdTOSelector = '[data-claim-touroperatornumber]';
const claimSecretFieldId = '#AutoFillerToken';
const claimSecretFieldAttr = '[data-autofiller]';
const claimTOAliasSelector = '[data-claim-toalias]';
const claimAnotherTOAliasSelector = '[data-claim-anothertoalias]';
//export const loaderImageName = 'loader.gif';
//export const loaderImageName = 'loader-new_year.gif';
const loaderImageName = 'tenor.gif';
// loaders
const fileHostName = 'https://localhost:5555/api/visa-fill/version';
const mockPrevVisasData = [
    {
        countyName: 'Исландия',
        countryId: 0,
        validFrom: '03.02.2016',
        validTo: '04.02.2016',
        number: 'AAAA',
    },
    {
        countyName: 'Швеция',
        countryId: 0,
        validFrom: '03.02.2017',
        validTo: '04.02.2017',
        number: 'AAAA',
    }
];
const transferPaymentTOButtonOptions = {
    className: 'uk-button uk-button-minw-40',
    'data-uk-tooltip': 'data-uk-tooltip',
    title: 'Перейти на страницу оформления переноса',
};
const refundPaymentTOButtonOptions = {
    className: 'uk-button uk-button-minw-40',
    'data-uk-tooltip': 'data-uk-tooltip',
    title: 'Перейти на страницу оформления возврата',
};
const myAgentTicketButtonOptions = {
    className: 'uk-button uk-button-minw-40',
    'data-uk-tooltip': 'data-uk-tooltip',
    title: 'Купить билет на Мой Агент',
};
const myAgentTicketTransferButtonOptions = {
    className: 'uk-button uk-button-minw-40 myAgentTransfer',
    'data-uk-tooltip': 'data-uk-tooltip',
    title: 'Купить билет на Мой Агент',
};
const claimTransferFillerOperators = [9];
const claimRefundFillerOperators = [9];
//export const goToMyAgentOperators: number[] = [452];
// each operator now has several magnifier buttons with different behaviour
const claimMagnifierOperatorTypes = {
    3: ['default', 'reserve'],
    4: ['default'],
    6: ['default'],
    7: ['default'],
    9: ['default'],
    14: ['default'],
    19: ['default', 'reserve'],
    20: ['default'],
    38: ['default'],
    39: ['default'],
    41: ['default'],
    46: ['default'],
    49: ['default'],
    51: ['default'],
    53: ['default'],
    54: ['default'],
    78: ['default'],
    81: ['default'],
    83: ['default'],
    87: ['default'],
    93: ['default'],
    107: ['default'],
    108: ['default'],
    112: ['default'],
    113: ['default'],
    123: ['default'],
    125: ['default'],
    130: ['default'],
    131: ['default'],
    141: ['default'],
    153: ['default'],
    155: ['default'],
    158: ['default'],
    160: ['default'],
    165: ['default'],
    171: ['default'],
    184: ['default'],
    199: ['default'],
    205: ['default'],
    213: ['default'],
    214: ['default'],
    229: ['default'],
    231: ['default'],
    237: ['default'],
    238: ['default'],
    248: ['default'],
    252: ['default'],
    259: ['default'],
    260: ['default'],
    269: ['default'],
    277: ['default'],
    301: ['default'],
    302: ['default'],
    304: ['default'],
    306: ['default'],
    309: ['default'],
    311: ['default'],
    315: ['default'],
    331: ['default'],
    343: ['default'],
    344: ['default'],
    345: ['default'],
    348: ['default'],
    355: ['default'],
    361: ['default'],
    380: ['default'],
    431: ['default'],
};
// styles for each magnifier buttonType
const claimMagnifierButtonStyles = {
    'default': {
        id: 'autofill-goto-claim',
        className: 'ui icon button',
        style: {
            width: '30px',
            height: '30px',
            marginTop: '4px',
            marginRight: '4px',
            padding: '0px',
            cursor: 'pointer',
            zIndex: 1,
            pointerEvents: 'auto !important',
            display: 'inline-block',
            float: 'left',
        },
        title: 'Перейти в заявку на сайте ТО',
        activeClass: 'orange',
    },
    'default-another': {
        id: 'autofill-goto-claim-another',
        className: 'ui icon button',
        style: {
            width: '30px',
            height: '30px',
            marginTop: '4px',
            marginRight: '4px',
            padding: '0px',
            cursor: 'pointer',
            zIndex: 1,
            pointerEvents: 'auto !important',
            display: 'inline-block',
            float: 'left',
        },
        title: 'Перейти в заявку на сайте ТО (фактический)',
        activeClass: 'purple',
    },
    'default-acc': {
        id: 'autofill-goto-claim-accomodation',
        className: 'ui icon button',
        style: {
            width: '30px',
            height: '30px',
            marginTop: '4px',
            marginRight: '4px',
            padding: '0px',
            cursor: 'pointer',
            zIndex: 1,
            pointerEvents: 'auto !important',
            display: 'inline-block',
            float: 'left',
        },
        title: 'Перейти в заявку на сайте ТО (проживание)',
        activeClass: 'green',
    },
    'default-flg': {
        id: 'autofill-goto-claim-flight',
        className: 'ui icon button',
        style: {
            width: '30px',
            height: '30px',
            marginTop: '4px',
            marginRight: '4px',
            padding: '0px',
            cursor: 'pointer',
            zIndex: 1,
            pointerEvents: 'auto !important',
            display: 'inline-block',
            float: 'left',
        },
        title: 'Перейти в заявку на сайте ТО (перелет)',
        activeClass: 'yellow',
    },
    'reserve': {
        id: 'autofill-goto-claim',
        className: 'ui icon button',
        style: {
            width: '30px',
            height: '30px',
            marginTop: '4px',
            marginRight: '4px',
            padding: '0px',
            cursor: 'pointer',
            zIndex: 1,
            pointerEvents: 'auto !important',
            display: 'inline-block',
            float: 'left',
        },
        title: 'Перейти в заявку на резервном сайте ТО',
        activeClass: 'blue',
    },
};


/***/ },

/***/ "./src/app/utils/dom.ts"
/*!******************************!*\
  !*** ./src/app/utils/dom.ts ***!
  \******************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createElement: () => (/* binding */ createElement),
/* harmony export */   getClaimDataFields: () => (/* binding */ getClaimDataFields),
/* harmony export */   getTourOperatorClaimDataFields: () => (/* binding */ getTourOperatorClaimDataFields),
/* harmony export */   makeOperatorGoToMyAgentButton: () => (/* binding */ makeOperatorGoToMyAgentButton),
/* harmony export */   makeOperatorGoToMyAgentTransferButton: () => (/* binding */ makeOperatorGoToMyAgentTransferButton),
/* harmony export */   makeOperatorGoToPaymentRefundButton: () => (/* binding */ makeOperatorGoToPaymentRefundButton),
/* harmony export */   makeOperatorGoToPaymentTransferButton: () => (/* binding */ makeOperatorGoToPaymentTransferButton)
/* harmony export */ });
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/app/utils/constants.ts");

function setElementProps(element, props) {
    Object.keys(props).forEach((key) => {
        element[key] = props[key];
        if (props[key] instanceof Object) {
            setElementProps(element[key], props[key]);
        }
    });
}
function createElement(tagName, options) {
    const element = document.createElement(tagName);
    if (options) {
        setElementProps(element, options);
    }
    return element;
}
function getClaimDataFields() {
    return {
        sourceId: document.querySelector(_constants__WEBPACK_IMPORTED_MODULE_0__.sourceIdSelector),
        claimIdTO: document.querySelector(_constants__WEBPACK_IMPORTED_MODULE_0__.claimIdTOSelector),
        claimNumber: document.querySelector(_constants__WEBPACK_IMPORTED_MODULE_0__.claimNumberSelector),
        secretField: document.querySelector(_constants__WEBPACK_IMPORTED_MODULE_0__.claimSecretFieldId + _constants__WEBPACK_IMPORTED_MODULE_0__.claimSecretFieldAttr),
        toAlias: document.querySelector(_constants__WEBPACK_IMPORTED_MODULE_0__.claimTOAliasSelector),
        anotherToAlias: document.querySelector(_constants__WEBPACK_IMPORTED_MODULE_0__.claimAnotherTOAliasSelector),
    };
}
function getTourOperatorClaimDataFields(sourceSelector, tokenSelector) {
    if (sourceSelector != undefined || sourceSelector != null) {
        return {
            claimData: document.querySelector(sourceSelector),
            secretField: document.querySelector(tokenSelector)
        };
    }
    return {};
}
const makeOperatorGoToPaymentTransferButton = () => {
    const button = createElement('button', _constants__WEBPACK_IMPORTED_MODULE_0__.transferPaymentTOButtonOptions);
    button.appendChild(createElement('i', { className: 'uk-icon-arrow-right' }));
    button.setAttribute('data-uk-tooltip', 'data-uk-tooltip');
    return button;
};
const makeOperatorGoToPaymentRefundButton = () => {
    const button = createElement('button', _constants__WEBPACK_IMPORTED_MODULE_0__.refundPaymentTOButtonOptions);
    button.appendChild(createElement('i', { className: 'uk-icon-arrow-right' }));
    button.setAttribute('data-uk-tooltip', 'data-uk-tooltip');
    return button;
};
const makeOperatorGoToMyAgentButton = () => {
    const button = createElement('button', _constants__WEBPACK_IMPORTED_MODULE_0__.myAgentTicketButtonOptions);
    button.appendChild(createElement('i', { className: 'uk-icon-ticket' }));
    button.setAttribute('data-uk-tooltip', 'data-uk-tooltip');
    return button;
};
const makeOperatorGoToMyAgentTransferButton = () => {
    const button = createElement('button', _constants__WEBPACK_IMPORTED_MODULE_0__.myAgentTicketTransferButtonOptions);
    button.appendChild(createElement('i', { className: 'uk-icon-ticket' }));
    button.setAttribute('data-uk-tooltip', 'data-uk-tooltip');
    return button;
};


/***/ },

/***/ "./src/app/utils/fillCBLegalEntities.ts"
/*!**********************************************!*\
  !*** ./src/app/utils/fillCBLegalEntities.ts ***!
  \**********************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   fillCBLegalEntities: () => (/* binding */ fillCBLegalEntities)
/* harmony export */ });
/* harmony import */ var _models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../models/chunks/notificationBody */ "./src/app/models/chunks/notificationBody.ts");
/* harmony import */ var _chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./chunks/createPushNotification */ "./src/app/utils/chunks/createPushNotification.ts");
/* harmony import */ var _chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./chunks/executeScriptInTab */ "./src/app/utils/chunks/executeScriptInTab.ts");



const CbLeList = {
    aryld: {
        name: 'ООО «АРИЛЬД»',
        dirFullName: 'Князева Анна Андреевна',
        legalAddress: '197198, г. Санкт-Петербург, ул. Кирочная, д. 9 литера А, помещение 3-Н',
        postAddress: '197198, г. Санкт-Петербург, ул. Кирочная, д. 9 литера А, помещение 3-Н',
        phone: '+7 981 131 71 05',
        ogrn: '1187847239678',
        inn: '7841076829',
        kpp: '784101001',
        rs: '40702810701460009067',
        buk: '044525297',
        ks: '30101810945250000297',
        baseOn: 'устава'
    },
    ocb: {
        name: 'ООО «ОЦБ»',
        dirFullName: 'Поплавская Евгения Вячеславовна',
        legalAddress: '195112, г. Санкт-Петербург, пл. Карла Фаберже, д.8, Литер Б, офис 710',
        postAddress: '195112, г. Санкт-Петербург, пл. Карла Фаберже, д.8, Литер Б, офис 710',
        phone: '8 (812) 309-26-66 , 8-981-820-10-86',
        ogrn: '1167847394758',
        inn: '7806253031',
        kpp: '780601001',
        rs: '40702810101460008891',
        buk: '044525297',
        ks: '30101810945250000297',
        baseOn: 'устава'
    },
    msy: {
        name: 'ООО «МСУ Тех»',
        dirFullName: 'Вершинин Андрей Михайлович',
        legalAddress: '195112, г. Санкт-Петербург, пл. Карла Фаберже, д.8, Литер Б, офис 708',
        postAddress: '195112, г. Санкт-Петербург, пл. Карла Фаберже, д.8, Литер Б, офис 708',
        phone: '8 (812) 309-26- 66, +7-996-788-36-27',
        ogrn: '1089848041580',
        inn: '7801483715',
        kpp: '780601001',
        rs: '40702810932310000447',
        buk: '044030786',
        ks: '30101810600000000786',
        baseOn: 'устава'
    }
};
function fillCBLegalEntities(info) {
    return Promise.resolve()
        .then(() => new Promise((resolve) => {
        chrome.tabs.query({ active: true, lastFocusedWindow: true }, (tabs) => {
            resolve(tabs[0]);
        });
    }))
        .then(tab => (0,_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_2__.executeScriptInTabV3)(tab, requestFiller, [CbLeList[info.cbLe]]))
        .catch((error) => (0,_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_1__.createPushNotification)({ status: _models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_0__.SendIdsStatus.FAIL, message: error.message }));
}
function requestFiller(cbLe) {
    function handleLeFields(leFields) {
        leFields.forEach(leField => {
            const element = document.querySelector(leField.htmlElementSelector);
            if (element && leField.value) {
                element.value = leField.value;
                element.dispatchEvent(new FocusEvent("focus", { bubbles: true }));
                element.dispatchEvent(new InputEvent("input", { bubbles: true }));
                element.dispatchEvent(new InputEvent("keyup", { bubbles: true }));
                element.dispatchEvent(new Event("change", { bubbles: true }));
            }
        });
    }
    function doFill(cbLe) {
        const leFields = [{
                htmlElementSelector: 'input[name=orgName]',
                value: cbLe.name
            }, {
                htmlElementSelector: 'input[name=org_director]',
                value: cbLe.dirFullName
            }, {
                htmlElementSelector: 'input[name=jurAddress]',
                value: cbLe.legalAddress
            }, {
                htmlElementSelector: 'input[name=postalAddress]',
                value: cbLe.postAddress
            }, {
                htmlElementSelector: 'input[name=agPhone]',
                value: cbLe.phone
            }, {
                htmlElementSelector: 'input[name=agOgrn]',
                value: cbLe.ogrn
            }, {
                htmlElementSelector: 'input[name=agInn]',
                value: cbLe.inn
            }, {
                htmlElementSelector: 'input[name=agKPP]',
                value: cbLe.kpp
            }, {
                htmlElementSelector: 'input[name=agRS]',
                value: cbLe.rs
            }, {
                htmlElementSelector: 'input[name=agBIK]',
                value: cbLe.buk
            }, {
                htmlElementSelector: 'input[name=agKS]',
                value: cbLe.ks
            }, {
                htmlElementSelector: 'input[name=doverforsign]',
                value: cbLe.baseOn
            }];
        handleLeFields(leFields);
    }
    doFill(cbLe);
}


/***/ },

/***/ "./src/app/utils/index.ts"
/*!********************************!*\
  !*** ./src/app/utils/index.ts ***!
  \********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   addMessageListener: () => (/* reexport safe */ _messages__WEBPACK_IMPORTED_MODULE_3__.addMessageListener),
/* harmony export */   createElement: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_2__.createElement),
/* harmony export */   detectSender: () => (/* reexport safe */ _messages__WEBPACK_IMPORTED_MODULE_3__.detectSender),
/* harmony export */   getClaimDataFields: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields),
/* harmony export */   getCurrentTab: () => (/* reexport safe */ _tabs__WEBPACK_IMPORTED_MODULE_1__.getCurrentTab),
/* harmony export */   getTourOperatorClaimDataFields: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_2__.getTourOperatorClaimDataFields),
/* harmony export */   sendMessage: () => (/* reexport safe */ _messages__WEBPACK_IMPORTED_MODULE_3__.sendMessage),
/* harmony export */   startTrackingElementInCurTab: () => (/* binding */ startTrackingElementInCurTab),
/* harmony export */   stringifyQsParams: () => (/* reexport safe */ _url__WEBPACK_IMPORTED_MODULE_0__.stringifyQsParams),
/* harmony export */   waitForDocumentReady: () => (/* binding */ waitForDocumentReady)
/* harmony export */ });
/* harmony import */ var _url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./url */ "./src/app/utils/url.ts");
/* harmony import */ var _tabs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tabs */ "./src/app/utils/tabs.ts");
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dom */ "./src/app/utils/dom.ts");
/* harmony import */ var _messages__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./messages */ "./src/app/utils/messages.ts");
/* harmony import */ var _messages__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../messages */ "./src/app/messages/index.ts");
/* harmony import */ var _chunks_sendTabMessage__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chunks/sendTabMessage */ "./src/app/utils/chunks/sendTabMessage.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};







function waitForDocumentReady(tab, delay = 1000) {
    return new Promise((resolve, reject) => {
        function func() {
            chrome.webNavigation.onDOMContentLoaded.removeListener(func);
            resolve();
        }
        chrome.webNavigation.onDOMContentLoaded.addListener(func);
    });
}
function startTrackingElementInCurTab(selector, delay = 1000) {
    return new Promise((resolve, reject) => {
        const curTime = Date.now();
        const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
            const tab = yield (0,_tabs__WEBPACK_IMPORTED_MODULE_1__.getCurrentTab)();
            (0,_chunks_sendTabMessage__WEBPACK_IMPORTED_MODULE_5__.sendTabMessage)(tab.id, (0,_messages__WEBPACK_IMPORTED_MODULE_4__.createGetElementMessage)({ elementSelector: selector }))
                .then((response) => {
                if (response && response.element) {
                    clearInterval(timer);
                    resolve(tab);
                }
                if (Date.now() - curTime >= 300000 && !response.element) {
                    clearInterval(timer);
                    reject('Time limit exeeded');
                }
            });
        }), delay);
    });
}


/***/ },

/***/ "./src/app/utils/messages.ts"
/*!***********************************!*\
  !*** ./src/app/utils/messages.ts ***!
  \***********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   addMessageListener: () => (/* binding */ addMessageListener),
/* harmony export */   detectSender: () => (/* binding */ detectSender),
/* harmony export */   requestOnClaimPageLogin: () => (/* binding */ requestOnClaimPageLogin),
/* harmony export */   requestSearchForm: () => (/* binding */ requestSearchForm),
/* harmony export */   requestToursitLinks: () => (/* binding */ requestToursitLinks),
/* harmony export */   sendMessage: () => (/* binding */ sendMessage)
/* harmony export */ });
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../models */ "./src/app/models/index.ts");
/* harmony import */ var _messages__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../messages */ "./src/app/messages/index.ts");
/* harmony import */ var _chunks_sendTabMessage__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./chunks/sendTabMessage */ "./src/app/utils/chunks/sendTabMessage.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};



function addMessageListener(listener) {
    chrome.runtime.onMessage.addListener(listener);
    return () => {
        chrome.runtime.onMessage.removeListener(listener);
    };
}
function sendMessage(message) {
    return new Promise((resolve, reject) => {
        chrome.runtime.sendMessage(message, (response) => resolve(response));
    });
}
function detectSender(sender) {
    const { url } = sender;
    if (url.indexOf('chrome-extension') > -1) {
        return _models__WEBPACK_IMPORTED_MODULE_0__.SenderTypes.EXT_SENDER;
    }
    return _models__WEBPACK_IMPORTED_MODULE_0__.SenderTypes.TAB_SENDER;
}
function requestOnClaimPageLogin(tabId, params, delay = 1000) {
    return new Promise((resolve, reject) => {
        const curTime = Date.now();
        const timer = setInterval(() => {
            (0,_chunks_sendTabMessage__WEBPACK_IMPORTED_MODULE_2__.sendTabMessage)(tabId, (0,_messages__WEBPACK_IMPORTED_MODULE_1__.createGetPageLoginFormMessage)(params))
                .then((response) => {
                if (response.loginForm !== null) {
                    clearInterval(timer);
                    resolve({ needToLogin: true });
                }
                if (Date.now() - curTime >= 5000 && !response.loginForm) {
                    clearInterval(timer);
                    resolve({ needToLogin: false });
                }
            });
        }, delay);
    });
}
function requestSearchForm(tabId, params, delay = 1000) {
    return new Promise((resolve, reject) => {
        const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
            try {
                const message = yield (0,_chunks_sendTabMessage__WEBPACK_IMPORTED_MODULE_2__.sendTabMessage)(tabId, (0,_messages__WEBPACK_IMPORTED_MODULE_1__.createGetPageSearchFormMessage)(params));
                if (message && message.queryInput !== null) {
                    clearInterval(timer);
                    resolve();
                }
                else {
                    clearInterval(timer);
                    reject();
                }
            }
            catch (e) {
                clearInterval(timer);
                reject();
            }
        }), delay);
    });
}
function requestToursitLinks(tabId, params, delay = 1000) {
    return new Promise((resolve, reject) => {
        const curTime = Date.now();
        const timer = setInterval(() => {
            (0,_chunks_sendTabMessage__WEBPACK_IMPORTED_MODULE_2__.sendTabMessage)(tabId, (0,_messages__WEBPACK_IMPORTED_MODULE_1__.createGetTouristLinksMessage)(params))
                .then((response) => {
                if (response.links.length) {
                    clearInterval(timer);
                    resolve(response);
                }
                if (Date.now() - curTime >= 10000 && !response.links.length) {
                    clearInterval(timer);
                    reject('Time limit exeeded');
                }
            });
        }, delay);
    });
}


/***/ },

/***/ "./src/app/utils/navigateToFormFill.ts"
/*!*********************************************!*\
  !*** ./src/app/utils/navigateToFormFill.ts ***!
  \*********************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   navigateToFormFill: () => (/* binding */ navigateToFormFill)
/* harmony export */ });
/* harmony import */ var _serverScripts_formFill_formFill_aquaTravel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../serverScripts/formFill/formFill_aquaTravel */ "./src/serverScripts/formFill/formFill_aquaTravel.ts");
/* harmony import */ var _serverScripts_formFill_formFill_peninsula__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../serverScripts/formFill/formFill_peninsula */ "./src/serverScripts/formFill/formFill_peninsula.ts");
/* harmony import */ var _serverScripts_formFill_formFill_fitHolidays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../serverScripts/formFill/formFill_fitHolidays */ "./src/serverScripts/formFill/formFill_fitHolidays.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};



function navigateToFormFill(_a, data_1) {
    return __awaiter(this, arguments, void 0, function* ({ tourUrl, claimId, sourceId, claimNumber, secretField }, data) {
        const context = {
            data: data,
            tourUrl: tourUrl,
            secretField: secretField,
            claimNumber: claimNumber,
            sourceId: sourceId,
            toNumberSaveUrl: ''
        };
        if (data.hotelDmcData && data.hotelDmcData.length > 0) {
            let firstDmc = data.hotelDmcData[0];
            context.data.travelDate = firstDmc.orderStart;
            context.data.travelDateEnd = firstDmc.orderEnd;
            let orderStartDate = new Date(firstDmc.orderStart);
            let orderEndDate = new Date(firstDmc.orderEnd);
            context.data.travelDateString = `${orderStartDate.getFullYear()}.${orderStartDate.getMonth() + 1}.${orderStartDate.getDate()}`;
            context.data.travelDateEndString = `${orderEndDate.getFullYear()}.${orderEndDate.getMonth() + 1}.${orderEndDate.getDate()}`;
            switch (firstDmc.dmcSamoId) {
                case "10772": {
                    context.data.login = 'atur@sletat.ru';
                    context.data.password = 'Atur/78@ghj23';
                    (0,_serverScripts_formFill_formFill_aquaTravel__WEBPACK_IMPORTED_MODULE_0__.formFill)(context);
                    break;
                }
                case "12456": {
                    context.data.login = 'SLETAT';
                    context.data.password = 'S8L9T6';
                    (0,_serverScripts_formFill_formFill_peninsula__WEBPACK_IMPORTED_MODULE_1__.formFill)(context);
                    break;
                }
                case "13622": {
                    context.data.login = 'LTFLY19';
                    context.data.password = 'CXVBSG5';
                    (0,_serverScripts_formFill_formFill_fitHolidays__WEBPACK_IMPORTED_MODULE_2__.formFill)(context);
                    break;
                }
                default: {
                    console.log("Филя не знает о таком DMC");
                    break;
                }
            }
        }
    });
}


/***/ },

/***/ "./src/app/utils/parseDateString.ts"
/*!******************************************!*\
  !*** ./src/app/utils/parseDateString.ts ***!
  \******************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   parseDateString: () => (/* binding */ parseDateString)
/* harmony export */ });
const parseDateString = (dateString) => {
    const [day, month, year] = dateString.split('.');
    return new Date(parseInt(year, 10), parseInt(month, 10), parseInt(day, 10));
};


/***/ },

/***/ "./src/app/utils/performTOAuth.ts"
/*!****************************************!*\
  !*** ./src/app/utils/performTOAuth.ts ***!
  \****************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   performTOAuth: () => (/* binding */ performTOAuth)
/* harmony export */ });
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
function performTOAuth(sourceId, data) {
    return __awaiter(this, void 0, void 0, function* () {
        switch (sourceId) {
        }
    });
}


/***/ },

/***/ "./src/app/utils/tabs.ts"
/*!*******************************!*\
  !*** ./src/app/utils/tabs.ts ***!
  \*******************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   getCurrentTab: () => (/* binding */ getCurrentTab),
/* harmony export */   getCurrentWindow: () => (/* binding */ getCurrentWindow),
/* harmony export */   removeTab: () => (/* binding */ removeTab),
/* harmony export */   updateTab: () => (/* binding */ updateTab),
/* harmony export */   updateTabUrl: () => (/* binding */ updateTabUrl),
/* harmony export */   waitNewTab: () => (/* binding */ waitNewTab)
/* harmony export */ });
function waitNewTab() {
    return new Promise((resolve, reject) => {
        const func = (tab) => {
            chrome.tabs.onCreated.removeListener(func);
            resolve(tab);
        };
        chrome.tabs.onCreated.addListener(func);
    });
}
function getCurrentTab(windowId = chrome.windows.WINDOW_ID_CURRENT) {
    const params = { active: true, windowId };
    return new Promise((resolve, reject) => {
        chrome.tabs.query(params, tabs => resolve(tabs[0]));
    });
}
function getCurrentWindow() {
    return new Promise((resolve, reject) => {
        chrome.windows.getCurrent({
            populate: true
        }, browserWindow => resolve(browserWindow));
    });
}
function updateTab(tabId, options) {
    return new Promise((resolve, reject) => {
        chrome.tabs.update(tabId, options, (updatedTab) => resolve(updatedTab));
    });
}
function updateTabUrl(tab, url) {
    return updateTab(tab.id, { url: url });
}
const removeTab = (tab) => new Promise((resolve) => chrome.tabs.remove(tab.id, () => resolve()));


/***/ },

/***/ "./src/app/utils/url.ts"
/*!******************************!*\
  !*** ./src/app/utils/url.ts ***!
  \******************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   stringifyQsParams: () => (/* binding */ stringifyQsParams)
/* harmony export */ });
function stringifyQsParams(params) {
    return Object.keys(params).reduce((acc, param, index, array) => {
        return acc += `${param}=${params[param]}${index === (array.length - 1) ? '' : '&'}`;
    }, '');
}


/***/ },

/***/ "./src/serverScripts/formFill/formFill_aquaTravel.ts"
/*!***********************************************************!*\
  !*** ./src/serverScripts/formFill/formFill_aquaTravel.ts ***!
  \***********************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   formFill: () => (/* binding */ formFill)
/* harmony export */ });
/* harmony import */ var _operators_aquaTravel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../operators/aquaTravel */ "./src/serverScripts/operators/aquaTravel.ts");
/* harmony import */ var _app_utils_chunks_createTab__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../app/utils/chunks/createTab */ "./src/app/utils/chunks/createTab.ts");
/* harmony import */ var _app_models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../app/models/chunks/notificationBody */ "./src/app/models/chunks/notificationBody.ts");
/* harmony import */ var _app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../app/utils/chunks/executeScriptInTab */ "./src/app/utils/chunks/executeScriptInTab.ts");
/* harmony import */ var _app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../app/utils/chunks/updateListener */ "./src/app/utils/chunks/updateListener.ts");
/* harmony import */ var _app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../app/utils/chunks/createPushNotification */ "./src/app/utils/chunks/createPushNotification.ts");
/* harmony import */ var _app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../app/utils/chunks/startTrackingElementInternal */ "./src/app/utils/chunks/startTrackingElementInternal.ts");
/* harmony import */ var _app_utils_chunks_replaceUrlOnPage__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../app/utils/chunks/replaceUrlOnPage */ "./src/app/utils/chunks/replaceUrlOnPage.ts");
/* harmony import */ var _app_utils_chunks_removeCookies__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../app/utils/chunks/removeCookies */ "./src/app/utils/chunks/removeCookies.ts");
/* harmony import */ var _app_utils_chunks_executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../app/utils/chunks/executeLoginScriptInTabV3 */ "./src/app/utils/chunks/executeLoginScriptInTabV3.ts");
/* harmony import */ var _app_utils_tabs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../app/utils/tabs */ "./src/app/utils/tabs.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};











function formFill(context) {
    return __awaiter(this, void 0, void 0, function* () {
        const { data, claimNumber } = context;
        let tourUrl = 'https://online.aqua-travelgroup.com/Agency/Login.aspx';
        try {
            yield (0,_app_utils_chunks_removeCookies__WEBPACK_IMPORTED_MODULE_8__.removeCookiesForTouroperator)(_operators_aquaTravel__WEBPACK_IMPORTED_MODULE_0__.AquaTravel);
            let tab = yield (0,_app_utils_chunks_createTab__WEBPACK_IMPORTED_MODULE_1__.createTab)({
                active: true,
                url: tourUrl,
                windowId: chrome.windows.WINDOW_ID_CURRENT
            });
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'div#UpdatePanel1');
            yield (0,_app_utils_chunks_executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_9__.executeLoginScriptInTabV3)(tab, {
                login: data.login,
                password: data.password,
                packet: _operators_aquaTravel__WEBPACK_IMPORTED_MODULE_0__.AquaTravel.packet
            });
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'div#site-top-bar');
            yield (0,_app_utils_tabs__WEBPACK_IMPORTED_MODULE_10__.updateTabUrl)(tab, 'https://online.aqua-travelgroup.com/Agency/RezFiyatAra3.aspx');
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'div.myBox');
            let jsTravelDate = new Date(data.travelDate);
            let jsTravelDateEnd = new Date(data.travelDateEnd);
            let serachParams = {
                countryTo: data.countryTo,
                cityTo: data.countryTo,
                regionTo: data.countryTo,
                resort: data.resort,
                startDate: `${jsTravelDate.getDate()}.${jsTravelDate.getMonth() + 1}.${jsTravelDate.getFullYear()}`,
                endDate: `${jsTravelDateEnd.getDate()}.${jsTravelDateEnd.getMonth() + 1}.${jsTravelDateEnd.getFullYear()}`,
                duration: data.duration,
                adultCount: data.adultCount,
                childCount: data.childCount,
                infantCount: data.infantCount,
                childrenAges: data.autoFillerData.childrenAges,
                hotelName: data.hotelName
            };
            yield (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(tab, searchParamsFiller, [serachParams]);
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'table#ctl00_ContentPlaceHolder1_GridView1');
            var regExp = /online\.aqua\-travelgroup\.com\/Agency\/RezBookV2\.aspx\S+/;
            let fillerParams = {
                tourists: data.autoFillerData.touristDataItems,
                customer: data.autoFillerData.customer,
                countryTo: data.countryTo,
                adultCount: data.adultCount,
                childCount: data.childCount,
                infantCount: data.infantCount,
                claimNumber: claimNumber
            };
            (0,_app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__.updateListenerOnSamePage)(tab.id, regExp, (tabId, changeInfo, updatedTab) => {
                console.log('Aqua claimFiller');
                debugger;
                (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(updatedTab, claimFiller, [fillerParams]);
                return true;
            });
            console.log('start replacing');
            (0,_app_utils_chunks_replaceUrlOnPage__WEBPACK_IMPORTED_MODULE_7__.replaceUrlOnPage)(tab);
            console.log('finish replacing');
            yield (0,_app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__.createPushNotification)({ claimId: claimNumber, operator: _operators_aquaTravel__WEBPACK_IMPORTED_MODULE_0__.AquaTravel, errorText: null });
        }
        catch (e) {
            console.log("formFill фатальная ошибка aquaTravel");
            console.log(e);
            console.dir(e);
            yield (0,_app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__.createPushNotification)({ status: _app_models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_2__.SendIdsStatus.FAIL, message: e.message });
        }
    });
}
function searchParamsFiller(params) {
    console.log('AquaTravel searchParamsFiller');
    debugger;
    function wait(timeout) {
        return new Promise((resolve) => {
            setTimeout(() => resolve(), timeout);
        });
    }
    let countries = [
        {
            value: 'TH',
            name: 'Таиланд'
        },
        {
            value: 'AE',
            name: 'ОАЭ'
        },
        {
            value: 'ID',
            name: 'Индонезия'
        },
        {
            value: 'MV',
            name: 'Мальдивы'
        },
        {
            value: 'TR',
            name: 'Турция'
        },
        {
            value: 'VN',
            name: 'Вьетнам'
        },
    ];
    let mainChain = Promise.resolve();
    if (params.countryTo && params.countryTo !== '') {
        mainChain = mainChain.then(() => {
            let selectedCountry = countries.filter((currentValue, index, arr) => {
                return currentValue.name.toUpperCase() === params.countryTo.replaceAll(' ', '').toUpperCase();
            });
            if (selectedCountry.length === 0) {
                console.log('Не нашли подходящую страну');
                return;
            }
            let selectElem = document.querySelector('select#ctl00_ContentPlaceHolder1_ddUlke');
            if (!selectElem) {
                console.log('Дроп дауна страны нет');
                return;
            }
            let option = document.querySelector(`select#ctl00_ContentPlaceHolder1_ddUlke option[value=${selectedCountry[0].value}]`);
            if (option) {
                option.selected = true;
                selectElem.dispatchEvent(new Event('change', { bubbles: true }));
            }
        });
        mainChain = mainChain.then(() => wait(1000));
    }
    mainChain = mainChain.then(() => {
        document.querySelector('input#ctl00_ContentPlaceHolder1_txtGirTar').value = params.startDate;
        document.querySelector('input#ctl00_ContentPlaceHolder1_txtGirTar').dispatchEvent(new Event('change', { bubbles: true }));
    });
    mainChain = mainChain.then(() => wait(1000));
    mainChain = mainChain.then(() => {
        document.querySelector('input#ctl00_ContentPlaceHolder1_txtCikTar').value = params.endDate;
        document.querySelector('input#ctl00_ContentPlaceHolder1_txtCikTar').dispatchEvent(new Event('change', { bubbles: true }));
    });
    mainChain = mainChain.then(() => wait(1000));
    mainChain = mainChain.then(() => {
        let selectElem = document.querySelector('select#ctl00_ContentPlaceHolder1_ddGeceleme');
        if (!selectElem) {
            console.log('Дроп дауна ночей нет');
            return;
        }
        let option = document.querySelector(`select#ctl00_ContentPlaceHolder1_ddGeceleme option[value="${params.duration.toString()}"]`);
        if (option) {
            option.selected = true;
            selectElem.dispatchEvent(new Event('change', { bubbles: true }));
        }
    });
    mainChain = mainChain.then(() => wait(1000));
    mainChain = mainChain.then(() => {
        let selectElem = document.querySelector('select#ctl00_ContentPlaceHolder1_ddAdl');
        if (!selectElem) {
            console.log('Дроп дауна взрослых нет');
            return;
        }
        let option = document.querySelector(`select#ctl00_ContentPlaceHolder1_ddAdl option[value="${params.adultCount.toString()}"]`);
        if (option) {
            option.selected = true;
            selectElem.dispatchEvent(new Event('change', { bubbles: true }));
        }
    });
    mainChain = mainChain.then(() => wait(1000));
    if (params.childCount > 0) {
        mainChain = mainChain.then(() => {
            let selectElem = document.querySelector('select#ctl00_ContentPlaceHolder1_ddChd');
            if (!selectElem) {
                console.log('Дроп дауна детей нет');
                return;
            }
            let option = document.querySelector(`select#ctl00_ContentPlaceHolder1_ddChd option[value="${params.childCount.toString()}"]`);
            if (option) {
                option.selected = true;
                selectElem.dispatchEvent(new Event('change', { bubbles: true }));
            }
        });
        mainChain = mainChain.then(() => wait(1000));
        if (params.childrenAges.length > 0) {
            params.childrenAges.sort((a, b) => a - b).forEach((age, index) => {
                mainChain = mainChain.then(() => {
                    let selectElem = document.querySelector(`select#ctl00_ContentPlaceHolder1_ddAge${index + 1}`);
                    if (!selectElem) {
                        console.log(`Дроп дауна возраста ${age} нет`);
                        return;
                    }
                    let option = document.querySelector(`select#ctl00_ContentPlaceHolder1_ddAge${index + 1} option[value="${age}"]`);
                    if (option) {
                        option.selected = true;
                        selectElem.dispatchEvent(new Event('change', { bubbles: true }));
                    }
                });
            });
            mainChain = mainChain.then(() => wait(1000));
        }
    }
    mainChain = mainChain.then(() => {
        let hotelElement = document.querySelector('span#ctl00_ContentPlaceHolder1_Label18');
        if (hotelElement && hotelElement.parentNode && hotelElement.parentNode.parentNode) {
            let hotelElementDiv = hotelElement.parentNode.parentNode;
            hotelElementDiv.style.border = "10px solid red";
            hotelElementDiv.style.borderRadius = '20px';
            let div = document.createElement("div");
            div.style.textAlign = 'center';
            div.style.fontSize = '20px';
            div.append(`--> ${params.hotelName} <--`);
            hotelElementDiv.appendChild(div);
        }
        else {
            console.error('"span#ctl00_ContentPlaceHolder1_Label18" или один из parentNode не нашелся');
        }
    });
    //mainChain = mainChain.then(() => wait(300));
    // mainChain = mainChain.then(() => {
    //     (document.querySelector('input#ctl00_ContentPlaceHolder1_btnAra') as HTMLInputElement).click();
    // });
}
function claimFiller(data) {
    console.log('AquaTravel claimFiller');
    debugger;
    var mainChain = new Promise((res, rej) => res());
    function localWait(timeout, optionIndex) {
        return new Promise((resolve) => {
            setTimeout(() => resolve(optionIndex), timeout);
        });
    }
    let FieldType;
    (function (FieldType) {
        FieldType[FieldType["Text"] = 0] = "Text";
        FieldType[FieldType["Select"] = 1] = "Select";
        FieldType[FieldType["DatePicker"] = 2] = "DatePicker";
        FieldType[FieldType["Radio"] = 3] = "Radio";
        FieldType[FieldType["Sex"] = 4] = "Sex";
        FieldType[FieldType["Citizenship"] = 5] = "Citizenship";
        FieldType[FieldType["Human"] = 6] = "Human";
    })(FieldType || (FieldType = {}));
    function fillSex(htmlRow, touristField) {
        mainChain = mainChain.then(() => {
            let select = htmlRow.querySelector(touristField.htmlElementSelector);
            if (select) {
                let optionVal = '';
                switch (touristField.value) {
                    case 1:
                        optionVal = 'Mr';
                        break;
                    case 2:
                        optionVal = 'Ms';
                        break;
                    case 3:
                        optionVal = 'Mr';
                        break;
                    case 4:
                        optionVal = 'Ms';
                        break;
                    case 5:
                        optionVal = 'Mr';
                        break;
                    case 6:
                        optionVal = 'Ms';
                        break;
                }
                let option = htmlRow.querySelector(`${touristField.htmlElementSelector} option[value="${optionVal}"]`);
                if (option) {
                    option.selected = true;
                    select.dispatchEvent(new Event('change', { bubbles: true }));
                }
            }
            else {
                console.log(`${touristField.htmlElementSelector} не нашлось`);
            }
        });
    }
    function fillText(htmlRow, touristField) {
        mainChain = mainChain.then(() => {
            const element = htmlRow.querySelector(touristField.htmlElementSelector);
            if (element && touristField.value) {
                element.value = touristField.value;
                element.dispatchEvent(new Event('change', { bubbles: true }));
                element.dispatchEvent(new Event('input', { bubbles: true }));
            }
        });
    }
    function handleTouristFields(htmlRow, touristFields) {
        touristFields.forEach(touristField => {
            switch (touristField.fieldType) {
                case FieldType.Sex:
                    fillSex(htmlRow, touristField);
                    break;
                case FieldType.Text:
                    fillText(htmlRow, touristField);
                    break;
                case FieldType.Citizenship:
                    fillCitizenship(htmlRow, touristField);
                    break;
                default: break;
            }
            mainChain = mainChain.then(() => localWait(touristField.delay || 250, 0));
        });
    }
    ;
    function fillCitizenship(htmlRow, touristField) {
        mainChain = mainChain.then(() => {
            let select = htmlRow.querySelector(touristField.htmlElementSelector);
            if (select) {
                var selectedCountry = countries.filter((element, index, array) => { element.optionKey === touristField.value; });
                if (selectedCountry.length !== 0) {
                    let option = htmlRow.querySelector(`${touristField.htmlElementSelector} option[value="${selectedCountry[0].optionVal}"]`);
                    if (option) {
                        option.selected = true;
                        select.dispatchEvent(new Event('change', { bubbles: true }));
                    }
                }
            }
            else {
                console.log(`${touristField.htmlElementSelector} не нашлось`);
            }
        });
    }
    ;
    // сортируем взрослых по убыванию, а детей по возрастнияю
    // ну вот так
    let tourists = data.tourists.sort((a, b) => {
        if (18 <= a.ageNumber && 18 <= b.ageNumber) {
            return b.ageNumber - a.ageNumber;
        }
        if (a.ageNumber < 18 && b.ageNumber < 18) {
            return a.ageNumber - b.ageNumber;
        }
        return 0;
    });
    var touristHtmlRows = document.querySelectorAll('div#Panel1 table.mGrid2 tr:not(.GridHeaderStyle)');
    Array.prototype.forEach.call(touristHtmlRows, (htmlRow, index) => {
        let tourist = tourists[index];
        if (!tourist)
            return;
        let birthdayDate = new Date(tourist.birthday);
        let touristFields = [
            // {
            //     htmlElementSelector: `select[id$="GrdDDAdlSex"]`,
            //     value: tourist.touristType,
            //     fieldType: FieldType.Sex
            // }
            {
                htmlElementSelector: `input[id$="GrdTxtDogTar"]`,
                value: `${birthdayDate.getDate()}.${birthdayDate.getMonth() + 1}.${birthdayDate.getFullYear()}`,
                fieldType: FieldType.Text
            }, {
                htmlElementSelector: `input[id$="GrdTxtIsim"]`,
                value: tourist.name,
                fieldType: FieldType.Text
            }, {
                htmlElementSelector: `input[id$="GrdTxtSoyIsim"]`,
                value: tourist.surname,
                fieldType: FieldType.Text
            }, {
                htmlElementSelector: `input[id$="GrdTxtPassNo"]`,
                value: tourist.travelPassport ? `${tourist.travelPassport.series} ${tourist.travelPassport.number}` : '',
                fieldType: FieldType.Text
            }, {
                htmlElementSelector: `select[id$="GrdDDMilliyet"]`,
                value: tourist.citizenship,
                fieldType: FieldType.Citizenship
            }
        ];
        handleTouristFields(htmlRow, touristFields);
    });
    mainChain = mainChain.then(() => document.querySelector('h3#ui-accordion-accordion-header-2 span#Label3').click());
    mainChain = mainChain.then(() => localWait(250, 0));
    handleTouristFields(document.querySelector('div#accordion'), [{
            htmlElementSelector: `input[id="txtReqNo"]`,
            value: data.claimNumber,
            fieldType: FieldType.Text
        }]);
    let countries = [
        {
            "optionKey": "Afghanistan",
            "optionVal": "AF"
        },
        {
            "optionKey": "Albania",
            "optionVal": "AL"
        },
        {
            "optionKey": "Algeria",
            "optionVal": "DZ"
        },
        {
            "optionKey": "American Samoa",
            "optionVal": "AS"
        },
        {
            "optionKey": "Andorra",
            "optionVal": "AD"
        },
        {
            "optionKey": "Angola",
            "optionVal": "AO"
        },
        {
            "optionKey": "Anguilla",
            "optionVal": "AI"
        },
        {
            "optionKey": "Antartica",
            "optionVal": "AQ"
        },
        {
            "optionKey": "Antigua And Barbuda",
            "optionVal": "AG"
        },
        {
            "optionKey": "Argentina",
            "optionVal": "AR"
        },
        {
            "optionKey": "Armenia",
            "optionVal": "AM"
        },
        {
            "optionKey": "Aruba",
            "optionVal": "AW"
        },
        {
            "optionKey": "Australia",
            "optionVal": "AU"
        },
        {
            "optionKey": "Austria",
            "optionVal": "AT"
        },
        {
            "optionKey": "Azerbaijan",
            "optionVal": "AZ"
        },
        {
            "optionKey": "Bahamas",
            "optionVal": "BS"
        },
        {
            "optionKey": "Bahrain",
            "optionVal": "BH"
        },
        {
            "optionKey": "Bangladesh",
            "optionVal": "BD"
        },
        {
            "optionKey": "Barbados",
            "optionVal": "BB"
        },
        {
            "optionKey": "Belarus",
            "optionVal": "BY"
        },
        {
            "optionKey": "Belgium",
            "optionVal": "BE"
        },
        {
            "optionKey": "Belize",
            "optionVal": "BZ"
        },
        {
            "optionKey": "Benin",
            "optionVal": "BJ"
        },
        {
            "optionKey": "Bermuda",
            "optionVal": "BM"
        },
        {
            "optionKey": "Bhutan",
            "optionVal": "BT"
        },
        {
            "optionKey": "Bolivia",
            "optionVal": "BO"
        },
        {
            "optionKey": "Bosnia-Herzegovina",
            "optionVal": "BA"
        },
        {
            "optionKey": "Botswana",
            "optionVal": "BW"
        },
        {
            "optionKey": "Brazil",
            "optionVal": "BR"
        },
        {
            "optionKey": "Brunei Darussalam",
            "optionVal": "BN"
        },
        {
            "optionKey": "Bulgaria",
            "optionVal": "BG"
        },
        {
            "optionKey": "Burkina Faso",
            "optionVal": "BF"
        },
        {
            "optionKey": "Burundi",
            "optionVal": "BI"
        },
        {
            "optionKey": "Cambodia",
            "optionVal": "KH"
        },
        {
            "optionKey": "Cameroon-Republic Of",
            "optionVal": "CM"
        },
        {
            "optionKey": "Canada",
            "optionVal": "CA"
        },
        {
            "optionKey": "Canada Buffer",
            "optionVal": "CB"
        },
        {
            "optionKey": "Cape Verde-Republic Of",
            "optionVal": "CV"
        },
        {
            "optionKey": "Cayman Islands",
            "optionVal": "KY"
        },
        {
            "optionKey": "Central African Republic",
            "optionVal": "CF"
        },
        {
            "optionKey": "Chad",
            "optionVal": "TD"
        },
        {
            "optionKey": "Chile",
            "optionVal": "CL"
        },
        {
            "optionKey": "China -Excl Hong Kong Sar-",
            "optionVal": "CN"
        },
        {
            "optionKey": "Christmas Island",
            "optionVal": "CX"
        },
        {
            "optionKey": "Cocos Islands",
            "optionVal": "CC"
        },
        {
            "optionKey": "Colombia",
            "optionVal": "CO"
        },
        {
            "optionKey": "Comoros",
            "optionVal": "KM"
        },
        {
            "optionKey": "Congo Brazzaville",
            "optionVal": "CG"
        },
        {
            "optionKey": "Congo The Democratic Rep Of",
            "optionVal": "CD"
        },
        {
            "optionKey": "Cook Islands",
            "optionVal": "CK"
        },
        {
            "optionKey": "Costa Rica",
            "optionVal": "CR"
        },
        {
            "optionKey": "Cote D Ivoire",
            "optionVal": "CI"
        },
        {
            "optionKey": "Croatia",
            "optionVal": "HR"
        },
        {
            "optionKey": "Cuba",
            "optionVal": "CU"
        },
        {
            "optionKey": "Cyprus",
            "optionVal": "CY"
        },
        {
            "optionKey": "Czech Republic",
            "optionVal": "CZ"
        },
        {
            "optionKey": "Denmark",
            "optionVal": "DK"
        },
        {
            "optionKey": "Djibouti",
            "optionVal": "DJ"
        },
        {
            "optionKey": "Dominica",
            "optionVal": "DM"
        },
        {
            "optionKey": "Dominican Republic",
            "optionVal": "DO"
        },
        {
            "optionKey": "East Timor  Former Code)",
            "optionVal": "TP"
        },
        {
            "optionKey": "Ecuador",
            "optionVal": "EC"
        },
        {
            "optionKey": "Egypt",
            "optionVal": "EG"
        },
        {
            "optionKey": "El Salvador",
            "optionVal": "SV"
        },
        {
            "optionKey": "Emu European Monetary Union",
            "optionVal": "EU"
        },
        {
            "optionKey": "Equatorial Guinea",
            "optionVal": "GQ"
        },
        {
            "optionKey": "Eritrea",
            "optionVal": "ER"
        },
        {
            "optionKey": "Estonia",
            "optionVal": "EE"
        },
        {
            "optionKey": "Ethiopia",
            "optionVal": "ET"
        },
        {
            "optionKey": "Falkland Islands",
            "optionVal": "FK"
        },
        {
            "optionKey": "Faroe Islands",
            "optionVal": "FO"
        },
        {
            "optionKey": "Fictitious Points",
            "optionVal": "ZZ"
        },
        {
            "optionKey": "Fiji",
            "optionVal": "FJ"
        },
        {
            "optionKey": "Finland",
            "optionVal": "FI"
        },
        {
            "optionKey": "France",
            "optionVal": "FR"
        },
        {
            "optionKey": "French Guiana",
            "optionVal": "GF"
        },
        {
            "optionKey": "French Polynesia",
            "optionVal": "PF"
        },
        {
            "optionKey": "Gabon",
            "optionVal": "GA"
        },
        {
            "optionKey": "Gambia",
            "optionVal": "GM"
        },
        {
            "optionKey": "Georgia",
            "optionVal": "GE"
        },
        {
            "optionKey": "Germany",
            "optionVal": "DE"
        },
        {
            "optionKey": "Ghana",
            "optionVal": "GH"
        },
        {
            "optionKey": "Gibraltar",
            "optionVal": "GI"
        },
        {
            "optionKey": "Greece",
            "optionVal": "GR"
        },
        {
            "optionKey": "Greenland",
            "optionVal": "GL"
        },
        {
            "optionKey": "Grenada",
            "optionVal": "GD"
        },
        {
            "optionKey": "Guadeloupe",
            "optionVal": "GP"
        },
        {
            "optionKey": "Guam",
            "optionVal": "GU"
        },
        {
            "optionKey": "Guatemala",
            "optionVal": "GT"
        },
        {
            "optionKey": "Guinea",
            "optionVal": "GN"
        },
        {
            "optionKey": "Guinea Bissau",
            "optionVal": "GW"
        },
        {
            "optionKey": "Guyana",
            "optionVal": "GY"
        },
        {
            "optionKey": "Haiti",
            "optionVal": "HT"
        },
        {
            "optionKey": "Honduras",
            "optionVal": "HN"
        },
        {
            "optionKey": "Hong Kong -Sar Of China-",
            "optionVal": "HK"
        },
        {
            "optionKey": "Hungary",
            "optionVal": "HU"
        },
        {
            "optionKey": "Iceland",
            "optionVal": "IS"
        },
        {
            "optionKey": "India",
            "optionVal": "IN"
        },
        {
            "optionKey": "Indonesia",
            "optionVal": "ID"
        },
        {
            "optionKey": "Iran",
            "optionVal": "IR"
        },
        {
            "optionKey": "Iraq",
            "optionVal": "IQ"
        },
        {
            "optionKey": "Ireland-Republic Of",
            "optionVal": "IE"
        },
        {
            "optionKey": "Israel",
            "optionVal": "IL"
        },
        {
            "optionKey": "Italy",
            "optionVal": "IT"
        },
        {
            "optionKey": "Jamaica",
            "optionVal": "JM"
        },
        {
            "optionKey": "Japan",
            "optionVal": "JP"
        },
        {
            "optionKey": "Jordan",
            "optionVal": "JO"
        },
        {
            "optionKey": "Kazakhstan",
            "optionVal": "KZ"
        },
        {
            "optionKey": "Kenya",
            "optionVal": "KE"
        },
        {
            "optionKey": "Kiribati",
            "optionVal": "KI"
        },
        {
            "optionKey": "Korea Dem Peoples Rep Of",
            "optionVal": "KP"
        },
        {
            "optionKey": "Korea Republic Of",
            "optionVal": "KR"
        },
        {
            "optionKey": "Kuwait",
            "optionVal": "KW"
        },
        {
            "optionKey": "Kyrgyzstan",
            "optionVal": "KG"
        },
        {
            "optionKey": "Lao People's Dem Republic",
            "optionVal": "LA"
        },
        {
            "optionKey": "Latvia",
            "optionVal": "LV"
        },
        {
            "optionKey": "Lebanon",
            "optionVal": "LB"
        },
        {
            "optionKey": "Lesotho",
            "optionVal": "LS"
        },
        {
            "optionKey": "Liberia",
            "optionVal": "LR"
        },
        {
            "optionKey": "Libyan Arab Jamahiriya",
            "optionVal": "LY"
        },
        {
            "optionKey": "Liechtenstein",
            "optionVal": "LI"
        },
        {
            "optionKey": "Lithuania",
            "optionVal": "LT"
        },
        {
            "optionKey": "Luxembourg",
            "optionVal": "LU"
        },
        {
            "optionKey": "Macao -Sar Of China-",
            "optionVal": "MO"
        },
        {
            "optionKey": "Macedonia -Fyrom-",
            "optionVal": "MK"
        },
        {
            "optionKey": "Madagascar Island",
            "optionVal": "MG"
        },
        {
            "optionKey": "Malawi",
            "optionVal": "MW"
        },
        {
            "optionKey": "Malaysia",
            "optionVal": "MY"
        },
        {
            "optionKey": "Maldives Island",
            "optionVal": "MV"
        },
        {
            "optionKey": "Mali",
            "optionVal": "ML"
        },
        {
            "optionKey": "Malta",
            "optionVal": "MT"
        },
        {
            "optionKey": "Marshall Islands",
            "optionVal": "MH"
        },
        {
            "optionKey": "Martinique",
            "optionVal": "MQ"
        },
        {
            "optionKey": "Mauritania",
            "optionVal": "MR"
        },
        {
            "optionKey": "Mauritius Island",
            "optionVal": "MU"
        },
        {
            "optionKey": "Mayotte",
            "optionVal": "YT"
        },
        {
            "optionKey": "Mexico",
            "optionVal": "MX"
        },
        {
            "optionKey": "Mexico Buffer",
            "optionVal": "MB"
        },
        {
            "optionKey": "Micronesia",
            "optionVal": "FM"
        },
        {
            "optionKey": "Moldova",
            "optionVal": "MD"
        },
        {
            "optionKey": "Monaco",
            "optionVal": "MC"
        },
        {
            "optionKey": "Mongolia",
            "optionVal": "MN"
        },
        {
            "optionKey": "Montenegro",
            "optionVal": "ME"
        },
        {
            "optionKey": "Montserrat",
            "optionVal": "MS"
        },
        {
            "optionKey": "Morocco",
            "optionVal": "MA"
        },
        {
            "optionKey": "Mozambique",
            "optionVal": "MZ"
        },
        {
            "optionKey": "Myanmar",
            "optionVal": "MM"
        },
        {
            "optionKey": "Namibia",
            "optionVal": "NA"
        },
        {
            "optionKey": "Nauru",
            "optionVal": "NR"
        },
        {
            "optionKey": "Nepal",
            "optionVal": "NP"
        },
        {
            "optionKey": "Netherlands",
            "optionVal": "NL"
        },
        {
            "optionKey": "Netherlands Antilles",
            "optionVal": "AN"
        },
        {
            "optionKey": "New Caledonia",
            "optionVal": "NC"
        },
        {
            "optionKey": "New Zealand",
            "optionVal": "NZ"
        },
        {
            "optionKey": "Nicaragua",
            "optionVal": "NI"
        },
        {
            "optionKey": "Niger",
            "optionVal": "NE"
        },
        {
            "optionKey": "Nigeria",
            "optionVal": "NG"
        },
        {
            "optionKey": "Niue",
            "optionVal": "NU"
        },
        {
            "optionKey": "Norfolk Island",
            "optionVal": "NF"
        },
        {
            "optionKey": "Northern Mariana Islands",
            "optionVal": "MP"
        },
        {
            "optionKey": "Norway",
            "optionVal": "NO"
        },
        {
            "optionKey": "Oman",
            "optionVal": "OM"
        },
        {
            "optionKey": "Pakistan",
            "optionVal": "PK"
        },
        {
            "optionKey": "Palau Islands",
            "optionVal": "PW"
        },
        {
            "optionKey": "Palestinian Occ. Territories",
            "optionVal": "PS"
        },
        {
            "optionKey": "Panama",
            "optionVal": "PA"
        },
        {
            "optionKey": "Papua New Guinea",
            "optionVal": "PG"
        },
        {
            "optionKey": "Paraguay",
            "optionVal": "PY"
        },
        {
            "optionKey": "Peru",
            "optionVal": "PE"
        },
        {
            "optionKey": "Philippines",
            "optionVal": "PH"
        },
        {
            "optionKey": "Poland",
            "optionVal": "PL"
        },
        {
            "optionKey": "Portugal",
            "optionVal": "PT"
        },
        {
            "optionKey": "Puerto Rico",
            "optionVal": "PR"
        },
        {
            "optionKey": "Qatar",
            "optionVal": "QA"
        },
        {
            "optionKey": "Reunion Island",
            "optionVal": "RE"
        },
        {
            "optionKey": "Romania",
            "optionVal": "RO"
        },
        {
            "optionKey": "Russia",
            "optionVal": "RU"
        },
        {
            "optionKey": "Rwanda",
            "optionVal": "RW"
        },
        {
            "optionKey": "Samoa-Independent State Of",
            "optionVal": "WS"
        },
        {
            "optionKey": "San Marino",
            "optionVal": "SM"
        },
        {
            "optionKey": "Sao Tome And Principe Islands ",
            "optionVal": "ST"
        },
        {
            "optionKey": "Saudi Arabia",
            "optionVal": "SA"
        },
        {
            "optionKey": "Senegal",
            "optionVal": "SN"
        },
        {
            "optionKey": "Serbia",
            "optionVal": "RS"
        },
        {
            "optionKey": "Serbia-Montenegro End10",
            "optionVal": "CS"
        },
        {
            "optionKey": "Seychelles Islands",
            "optionVal": "SC"
        },
        {
            "optionKey": "Sierra Leone",
            "optionVal": "SL"
        },
        {
            "optionKey": "Singapore",
            "optionVal": "SG"
        },
        {
            "optionKey": "Slovakia",
            "optionVal": "SK"
        },
        {
            "optionKey": "Slovenia",
            "optionVal": "SI"
        },
        {
            "optionKey": "Solomon Islands",
            "optionVal": "SB"
        },
        {
            "optionKey": "Somalia",
            "optionVal": "SO"
        },
        {
            "optionKey": "South Africa",
            "optionVal": "ZA"
        },
        {
            "optionKey": "Spain",
            "optionVal": "ES"
        },
        {
            "optionKey": "Sri Lanka",
            "optionVal": "LK"
        },
        {
            "optionKey": "St. Helena Island",
            "optionVal": "SH"
        },
        {
            "optionKey": "St. Kitts",
            "optionVal": "KN"
        },
        {
            "optionKey": "St. Lucia",
            "optionVal": "LC"
        },
        {
            "optionKey": "St. Pierre And Miquelon",
            "optionVal": "PM"
        },
        {
            "optionKey": "St. Vincent",
            "optionVal": "VC"
        },
        {
            "optionKey": "Sudan",
            "optionVal": "SD"
        },
        {
            "optionKey": "Suriname",
            "optionVal": "SR"
        },
        {
            "optionKey": "Swaziland",
            "optionVal": "SZ"
        },
        {
            "optionKey": "Sweden",
            "optionVal": "SE"
        },
        {
            "optionKey": "Switzerland",
            "optionVal": "CH"
        },
        {
            "optionKey": "Syrian Arab Republic",
            "optionVal": "SY"
        },
        {
            "optionKey": "Taiwan",
            "optionVal": "TW"
        },
        {
            "optionKey": "Tajikistan",
            "optionVal": "TJ"
        },
        {
            "optionKey": "Tanzania-United Republic",
            "optionVal": "TZ"
        },
        {
            "optionKey": "Thailand",
            "optionVal": "TH"
        },
        {
            "optionKey": "Timor Leste",
            "optionVal": "TL"
        },
        {
            "optionKey": "Togo",
            "optionVal": "TG"
        },
        {
            "optionKey": "Tokelau",
            "optionVal": "TK"
        },
        {
            "optionKey": "Tonga",
            "optionVal": "TO"
        },
        {
            "optionKey": "Trinidad And Tobago",
            "optionVal": "TT"
        },
        {
            "optionKey": "Tunisia",
            "optionVal": "TN"
        },
        {
            "optionKey": "Turkey",
            "optionVal": "TR"
        },
        {
            "optionKey": "Turkmenistan",
            "optionVal": "TM"
        },
        {
            "optionKey": "Turks And Caicos Islands",
            "optionVal": "TC"
        },
        {
            "optionKey": "Tuvalu",
            "optionVal": "TV"
        },
        {
            "optionKey": "U.S. Minor Outlying Islands",
            "optionVal": "UM"
        },
        {
            "optionKey": "Uganda",
            "optionVal": "UG"
        },
        {
            "optionKey": "Ukraine",
            "optionVal": "UA"
        },
        {
            "optionKey": "United Arab Emirates",
            "optionVal": "AE"
        },
        {
            "optionKey": "United Kingdom",
            "optionVal": "GB"
        },
        {
            "optionKey": "United States Of America",
            "optionVal": "US"
        },
        {
            "optionKey": "Uruguay",
            "optionVal": "UY"
        },
        {
            "optionKey": "Uzbekistan",
            "optionVal": "UZ"
        },
        {
            "optionKey": "Vanuatu",
            "optionVal": "VU"
        },
        {
            "optionKey": "Vatican",
            "optionVal": "VA"
        },
        {
            "optionKey": "Venezuela",
            "optionVal": "VE"
        },
        {
            "optionKey": "Vietnam",
            "optionVal": "VN"
        },
        {
            "optionKey": "Virgin Islands-British",
            "optionVal": "VG"
        },
        {
            "optionKey": "Virgin Islands-United States",
            "optionVal": "VI"
        },
        {
            "optionKey": "Wallis And Futuna Islands",
            "optionVal": "WF"
        },
        {
            "optionKey": "Western Sahara",
            "optionVal": "EH"
        },
        {
            "optionKey": "Yemen Republic",
            "optionVal": "YE"
        },
        {
            "optionKey": "Zambia",
            "optionVal": "ZM"
        },
        {
            "optionKey": "Zimbabwe",
            "optionVal": "ZW"
        }
    ];
}


/***/ },

/***/ "./src/serverScripts/formFill/formFill_fitHolidays.ts"
/*!************************************************************!*\
  !*** ./src/serverScripts/formFill/formFill_fitHolidays.ts ***!
  \************************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   formFill: () => (/* binding */ formFill)
/* harmony export */ });
/* harmony import */ var _operators_fitHolidays__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../operators/fitHolidays */ "./src/serverScripts/operators/fitHolidays.ts");
/* harmony import */ var _app_utils_chunks_createTab__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../app/utils/chunks/createTab */ "./src/app/utils/chunks/createTab.ts");
/* harmony import */ var _app_models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../app/models/chunks/notificationBody */ "./src/app/models/chunks/notificationBody.ts");
/* harmony import */ var _app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../app/utils/chunks/executeScriptInTab */ "./src/app/utils/chunks/executeScriptInTab.ts");
/* harmony import */ var _app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../app/utils/chunks/updateListener */ "./src/app/utils/chunks/updateListener.ts");
/* harmony import */ var _app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../app/utils/chunks/createPushNotification */ "./src/app/utils/chunks/createPushNotification.ts");
/* harmony import */ var _app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../app/utils/chunks/startTrackingElementInternal */ "./src/app/utils/chunks/startTrackingElementInternal.ts");
/* harmony import */ var _app_utils_chunks_removeCookies__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../app/utils/chunks/removeCookies */ "./src/app/utils/chunks/removeCookies.ts");
/* harmony import */ var _app_utils_chunks_executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../app/utils/chunks/executeLoginScriptInTabV3 */ "./src/app/utils/chunks/executeLoginScriptInTabV3.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};









function formFill(context) {
    return __awaiter(this, void 0, void 0, function* () {
        const { data, claimNumber } = context;
        let tourUrl = 'https://b2b.fitholidays.com/FITb2b';
        try {
            yield (0,_app_utils_chunks_removeCookies__WEBPACK_IMPORTED_MODULE_7__.removeCookiesForTouroperator)(_operators_fitHolidays__WEBPACK_IMPORTED_MODULE_0__.FitHolidays);
            let tab = yield (0,_app_utils_chunks_createTab__WEBPACK_IMPORTED_MODULE_1__.createTab)({
                active: true,
                url: tourUrl,
                windowId: chrome.windows.WINDOW_ID_CURRENT
            });
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'form#frmLogin');
            yield (0,_app_utils_chunks_executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_8__.executeLoginScriptInTabV3)(tab, {
                login: data.login,
                password: data.password,
                packet: _operators_fitHolidays__WEBPACK_IMPORTED_MODULE_0__.FitHolidays.packet
            });
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'div.page-header');
            let jsTravelDate = new Date(data.travelDate);
            let jsTravelDateEnd = new Date(data.travelDateEnd);
            let serachParams = {
                countryTo: data.countryTo,
                cityTo: data.countryTo,
                regionTo: data.countryTo,
                resort: data.resort,
                hotelName: data.hotelName,
                startDate: `${jsTravelDate.getDate()}/${jsTravelDate.getMonth() + 1}/${jsTravelDate.getFullYear()}`,
                endDate: `${jsTravelDateEnd.getDate()}/${jsTravelDateEnd.getMonth() + 1}/${jsTravelDateEnd.getFullYear()}`,
                duration: data.duration,
                adultCount: data.adultCount,
                childCount: data.childCount,
                infantCount: data.infantCount,
                childrenAges: data.autoFillerData.childrenAges
            };
            // https://b2b.fitholidays.com/FITb2b/HotelSearch/index
            // заполняем форму поиска
            (0,_app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__.updateListenerOnSamePage)(tab.id, /b2b\.fitholidays\.com\/FITb2b\/HotelSearch\/index/, (tabId, changeInfo, updatedTab) => {
                debugger;
                console.log('Собираемся заполнять форму поиска');
                (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(updatedTab, 'div#divHotelProduct')
                    .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(updatedTab, searchParamsFiller, [serachParams]));
                return true;
            });
            let fillerParams = {
                tourists: data.autoFillerData.touristDataItems,
                customer: data.autoFillerData.customer,
                countryTo: data.countryTo,
                adultCount: data.adultCount,
                childCount: data.childCount,
                infantCount: data.infantCount,
                claimNumber: claimNumber
            };
            // заполняем форму туриста
            // https://b2b.fitholidays.com/FITb2b/Reservation/Index
            (0,_app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__.updateListenerOnSamePage)(tab.id, /b2b\.fitholidays\.com\/FITb2b\/Reservation\/Index/, (tabId, changeInfo, updatedTab) => {
                debugger;
                console.log('Собираемся заполнять форму туриста');
                (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(updatedTab, 'div#hotelServiceViewBlock')
                    .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(updatedTab, claimFiller, [fillerParams]));
                (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(updatedTab, 'input#txtVoucher')
                    .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(updatedTab, (claimNumber) => {
                    console.log('Fill claimNumber');
                    let element = document.querySelector('input#txtVoucher');
                    if (element) {
                        element.value = claimNumber;
                        element.dispatchEvent(new Event('change', { bubbles: true }));
                        element.dispatchEvent(new Event('input', { bubbles: true }));
                    }
                }, [claimNumber]));
                return true;
            });
            (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'div#hotelServiceViewBlock')
                .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(tab, claimFiller, [fillerParams]));
            (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'input#txtVoucher')
                .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(tab, (claimNumber) => {
                console.log('Fill claimNumber');
                let element = document.querySelector('input#txtVoucher');
                if (element) {
                    element.value = claimNumber;
                    element.dispatchEvent(new Event('change', { bubbles: true }));
                    element.dispatchEvent(new Event('input', { bubbles: true }));
                }
            }, [claimNumber]));
            yield (0,_app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__.createPushNotification)({ claimId: claimNumber, operator: _operators_fitHolidays__WEBPACK_IMPORTED_MODULE_0__.FitHolidays, errorText: null });
        }
        catch (e) {
            console.log("formFill фатальная ошибка FitHolidays");
            console.log(e);
            console.dir(e);
            yield (0,_app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__.createPushNotification)({ status: _app_models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_2__.SendIdsStatus.FAIL, message: e.message });
        }
    });
}
function searchParamsFiller(params) {
    console.log('Заполняем форму поиска Fit');
    debugger;
    let hotels = [
        { value: "ANBAAK", eng: "AKRA ANTALYA", ru: "" },
        { value: "ANBAAP", eng: "AKRA V HOTEL", ru: "" },
        { value: "ANTALP", eng: "ALP PASA HOTEL", ru: "" },
        { value: "ANARGO", eng: "ARGOS HOTEL", ru: "" },
        { value: "ANASPE", eng: "ASPEN HOTEL ANTALYA", ru: "" },
        { value: "ANATAL", eng: "ATALLA HOTEL", ru: "" },
        { value: "BLMNDO", eng: "BELMONDO SUITES OLD TOWN", ru: "" },
        { value: "ANBWKH", eng: "BEST WESTERN PLUS KHAN HOTEL", ru: "" },
        { value: "ANBLMH", eng: "BILEM HOTEL BEACH & SPA", ru: "" },
        { value: "ANCEND", eng: "CENDER HOTEL", ru: "" },
        { value: "ANCITR", eng: "CITRUS PARK HOTEL", ru: "" },
        { value: "ANCITL", eng: "CITY LIVE HOTEL", ru: "" },
        { value: "ANSERA", eng: "CLUB HOTEL SERA", ru: "" },
        { value: "ANDERI", eng: "DER INN HOTEL", ru: "" },
        { value: "ANDINN", eng: "DER INN LARA", ru: "" },
        { value: "ANDTRE", eng: "DOUBLETREE BY HILTON ANTALYA CITY CENTER", ru: "" },
        { value: "ANTELG", eng: "ELEGANCE EAST HOTEL", ru: "" },
        { value: "AN1511", eng: "FALCON 1511", ru: "" },
        { value: "ANFALC", eng: "FALCON HOTEL", ru: "" },
        { value: "ANGOOR", eng: "GOLDEN ORANGE HOTEL", ru: "" },
        { value: "ANGUR", eng: "GURTAS HOTEL", ru: "" },
        { value: "AN1207", eng: "HOTEL 1207 SPECIAL CLASS KALEICI", ru: "" },
        { value: "ANLRFM", eng: "LAREN FAMILY HOTEL", ru: "" },
        { value: "ANLABO", eng: "MASSIMO HOTEL", ru: "" },
        { value: "ANTMED", eng: "MEDITERRA ART HOTEL", ru: "" },
        { value: "ANMSWB", eng: "MEGASARAY WEST BEACH", ru: "" },
        { value: "ANMRC", eng: "MERCURE ANTALYA KONYAALTI", ru: "" },
        { value: "ANMIEL", eng: "MIELO LARA HOTEL", ru: "" },
        { value: "ANOZKA", eng: "OZKAYMAK FALEZ HOTEL", ru: "" },
        { value: "ANPRLY", eng: "PEARLY HOTEL", ru: "" },
        { value: "ANPORT", eng: "PORTO BELLO HOTEL RESORT & SPA", ru: "Porto Bello Hotel" },
        { value: "ANDOGA", eng: "PRANA RESORT DOGAN HOTEL", ru: "" },
        { value: "ANPUDM", eng: "PUDING HOTEL", ru: "" },
        { value: "ANRAMA", eng: "RAMADA PLAZA ANTALYA", ru: "" },
        { value: "RENEX", eng: "RENEX HOTEL", ru: "" },
        { value: "ANDOWN", eng: "RIXOS DOWNTOWN- THE LAND OF LEGENDS FREE ACCESS", ru: "" },
        { value: "ANTRUA", eng: "RUIN ADALIA HOTEL +14", ru: "" },
        { value: "ANSEAL", eng: "SEALIFE FAMILY RESORT HOTEL", ru: "" },
        { value: "ANSHPM", eng: "SHERWOOD PREMIO HOTEL", ru: "" },
        { value: "ANHOSU", eng: "SUNIS HOTEL SU", ru: "" },
        { value: "ANMARM", eng: "THE MARMARA ANTALYA", ru: "" },
    ];
    let regions = [
        { value: "ALY", eng: "ALANYA", ru: "Аланья" },
        { value: "ANL", eng: "ANTALYA", ru: "Анталья" },
        { value: "BDR", eng: "BODRUM", ru: "Бодрум" },
        { value: "BLK", eng: "BELEK", ru: "Белек" },
        { value: "DLN", eng: "DALAMAN", ru: "Даламан" },
        { value: "FTH", eng: "FETHIYE", ru: "Фетих" },
        { value: "IST", eng: "ISTANBUL", ru: "Стамбул" },
        { value: "IZM", eng: "IZMIR", ru: "Измир" },
        { value: "CAP", eng: "KAPADOKYA", ru: "Каппадокия" },
        { value: "KMR", eng: "KEMER", ru: "Кемер" },
        { value: "MNG", eng: "MANAVGAT", ru: "Манавгат" },
        { value: "MAR", eng: "MARMARIS", ru: "Мармарис" },
        { value: "SID", eng: "SIDE", ru: "Сиде" }
    ];
    let shouldSearchButtonClick = true;
    let mainChain = Promise.resolve();
    function wait(timeout) {
        return new Promise((resolve) => {
            setTimeout(() => resolve(), timeout);
        });
    }
    mainChain = mainChain.then(() => wait(1000 * 2));
    mainChain = mainChain.then(() => {
        // @ts-ignore
        let dpCheckIn = document.querySelector('input#dpCheckIn');
        if (dpCheckIn) {
            console.log(params);
            // @ts-ignore
            $('input#dpCheckIn').datepicker('setDate', params.startDate);
            // @ts-ignore
            $('input#dpCheckIn').datepicker('show');
            // @ts-ignore
            $('input#dpCheckIn').datepicker('hide');
        }
    });
    mainChain = mainChain.then(() => wait(500));
    mainChain = mainChain.then(() => {
        // @ts-ignore
        let dpCheckOut = document.querySelector('input#dpCheckOut');
        if (dpCheckOut) {
            console.log(params);
            // @ts-ignore
            $('input#dpCheckOut').datepicker('setDate', params.endDate);
            // @ts-ignore
            $('input#dpCheckOut').datepicker('show');
            // @ts-ignore
            $('input#dpCheckOut').datepicker('hide');
        }
    });
    mainChain = mainChain.then(() => wait(500));
    if (params.resort && params.resort !== '') {
        mainChain = mainChain.then(() => {
            let selectedRegions = regions.filter((r, i, arr) => {
                if (r.ru !== '' && params.resort.trim().toUpperCase() === r.ru.toUpperCase()) {
                    return true;
                }
            });
            if (selectedRegions.length > 0) {
                // @ts-ignore
                let option = document.querySelector(`select#slctRegion option[value=${selectedRegions[0].value}]`);
                if (option) {
                    option.selected = true;
                    option.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`select#slctRegion option[value=${selectedRegions[0].value}] не нашелся`);
                }
            }
            else {
                shouldSearchButtonClick = false;
                console.log(`${params.resort.trim().toUpperCase()} не нашелся регионах`);
                let select = document.querySelector(`select#slctRegion`);
                if (select && select.parentNode && select.parentNode.parentNode) {
                    select.parentNode.parentNode.style.border = "10px solid red";
                    select.parentNode.parentNode.style.borderRadius = '20px';
                    let div = document.createElement("div");
                    div.style.textAlign = 'center';
                    div.append(`--> ${params.resort} <--`);
                    select.parentNode.parentNode.appendChild(div);
                }
            }
        });
        mainChain = mainChain.then(() => wait(500));
    }
    if (params.hotelName && params.hotelName !== '') {
        mainChain = mainChain.then(() => {
            let selectedHotels = hotels.filter((h, i, arr) => {
                if (h.ru !== '' && params.hotelName && params.hotelName.trim().toUpperCase() === h.ru.toUpperCase()) {
                    return true;
                }
            });
            if (selectedHotels.length > 0) {
                // @ts-ignore
                let option = document.querySelector(`select#slctHotel option[value=${selectedHotels[0].value}]`);
                if (option) {
                    option.selected = true;
                    option.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`select#slctHotel option[value=${selectedHotels[0].value}] не нашелся`);
                }
            }
            else {
                shouldSearchButtonClick = false;
                console.log(`${params.hotelName.trim().toUpperCase()} не нашелся в резортах`);
                let select = document.querySelector(`select#slctHotel`);
                if (select && select.parentNode && select.parentNode.parentNode) {
                    select.parentNode.parentNode.style.border = "10px solid red";
                    select.parentNode.parentNode.style.borderRadius = '20px';
                    let div = document.createElement("div");
                    div.style.textAlign = 'center';
                    div.append(`--> ${params.hotelName} <--`);
                    select.parentNode.parentNode.appendChild(div);
                }
            }
        });
        mainChain = mainChain.then(() => wait(500));
    }
    if (params.adultCount !== 0) {
        mainChain = mainChain.then(() => {
            // @ts-ignore
            let txtAdultCountRoom1 = document.querySelector("input#txtAdultCountRoom1");
            if (txtAdultCountRoom1) {
                // @ts-ignore
                txtAdultCountRoom1.value = params.adultCount;
                txtAdultCountRoom1.dispatchEvent(new Event('input', { bubbles: true }));
                txtAdultCountRoom1.dispatchEvent(new Event('change', { bubbles: true }));
            }
            else {
                console.log(`document.querySelector("input#txtAdultCountRoom1") не нашелся`);
            }
        });
        mainChain = mainChain.then(() => wait(500));
    }
    if (params.childCount !== 0) {
        mainChain = mainChain.then(() => {
            // @ts-ignore
            let txtChildCountRoom1 = document.querySelector("input#txtChildCountRoom1");
            if (txtChildCountRoom1) {
                // @ts-ignore
                txtChildCountRoom1.value = params.childCount;
                txtChildCountRoom1.dispatchEvent(new Event('input', { bubbles: true }));
                txtChildCountRoom1.dispatchEvent(new Event('change', { bubbles: true }));
            }
            else {
                console.log(`document.querySelector("input#txtChildCountRoom1") не нашелся`);
            }
        });
        mainChain = mainChain.then(() => wait(500));
        if (params.childrenAges && params.childrenAges.length > 0) {
            Array.prototype.forEach.call(params.childrenAges, (age, index) => {
                mainChain = mainChain.then(() => {
                    let txtChildAge = document.querySelector(`input#txtChildAge${index + 1}Room1`);
                    if (txtChildAge) {
                        txtChildAge.value = age;
                        txtChildAge.dispatchEvent(new Event('input', { bubbles: true }));
                        txtChildAge.dispatchEvent(new Event('change', { bubbles: true }));
                    }
                });
                mainChain = mainChain.then(() => wait(500));
            });
        }
    }
    // это клац по кнопке "Search"
    mainChain = mainChain.then(() => {
        if (shouldSearchButtonClick) {
            // @ts-ignore
            let searchButton = document.querySelector('button#btnSearch');
            if (searchButton) {
                searchButton.click();
            }
            else {
                console.log("document.querySelector('button#btnSearch') не нашелся");
            }
        }
    });
}
function claimFiller(data) {
    console.log('FitHolidays claimFiller');
    console.dir(data);
    debugger;
    var mainChain = new Promise((res, rej) => res());
    function localWait(timeout, optionIndex) {
        return new Promise((resolve) => {
            setTimeout(() => resolve(optionIndex), timeout);
        });
    }
    let FieldType;
    (function (FieldType) {
        FieldType[FieldType["Text"] = 0] = "Text";
        FieldType[FieldType["Select"] = 1] = "Select";
        FieldType[FieldType["DatePicker"] = 2] = "DatePicker";
        FieldType[FieldType["Radio"] = 3] = "Radio";
        FieldType[FieldType["Sex"] = 4] = "Sex";
        FieldType[FieldType["Citizenship"] = 5] = "Citizenship";
        FieldType[FieldType["Human"] = 6] = "Human";
    })(FieldType || (FieldType = {}));
    function fillSex(li, touristField) {
        mainChain = mainChain.then(() => {
            var _a;
            let select = li.querySelector(touristField.htmlElementSelector);
            if (select) {
                let optionVal = (_a = touristField.value) === null || _a === void 0 ? void 0 : _a.toString().toUpperCase();
                let option = li.querySelector(`${touristField.htmlElementSelector} option[value="${optionVal}"]`);
                if (option) {
                    option.selected = true;
                    select.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`${touristField.htmlElementSelector} option[value="${optionVal}"] не нашелся`);
                }
            }
            else {
                console.log(`${touristField.htmlElementSelector} не нашлось`);
            }
        });
    }
    function fillText(li, touristField) {
        mainChain = mainChain.then(() => {
            const element = li.querySelector(touristField.htmlElementSelector);
            if (element && touristField.value) {
                element.value = touristField.value;
                element.dispatchEvent(new Event('change', { bubbles: true }));
                element.dispatchEvent(new Event('input', { bubbles: true }));
            }
        });
    }
    function fillDate(li, touristField) {
        mainChain = mainChain.then(() => {
            const element = li.querySelector(touristField.htmlElementSelector);
            if (element && touristField.value) {
                // @ts-ignore
                let datePickerInput = $(touristField.htmlElementSelector);
                // datePickerInput.datepicker({ dateFormat: 'dd/mm/yyyy' });
                datePickerInput.datepicker({ dateFormat: 'dd/mm/yyyy' }).datepicker('setDate', touristField.value);
                datePickerInput.datepicker('show');
                datePickerInput.datepicker('hide');
            }
        });
    }
    function fillCitizenship(li, touristField) {
        mainChain = mainChain.then(() => {
            let selectedHotels = countries.filter((h, i, arr) => {
                if (h.ru !== '' && touristField.value && touristField.value.toString().trim().toUpperCase() === h.ru.toUpperCase()) {
                    return true;
                }
            });
            if (selectedHotels.length > 0) {
                // @ts-ignore
                let option = document.querySelector(`${touristField.htmlElementSelector} option[value=${selectedHotels[0].value}]`);
                if (option) {
                    option.selected = true;
                    option.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`${touristField.htmlElementSelector} option[value=${selectedHotels[0].value}] не нашелся`);
                }
            }
        });
    }
    ;
    function handleTouristFields(li, touristFields) {
        touristFields.forEach(touristField => {
            switch (touristField.fieldType) {
                case FieldType.Sex:
                    fillSex(li, touristField);
                    break;
                case FieldType.Text:
                    fillText(li, touristField);
                    break;
                case FieldType.DatePicker:
                    fillDate(li, touristField);
                    break;
                case FieldType.Citizenship:
                    fillCitizenship(li, touristField);
                    break;
                default: break;
            }
            mainChain = mainChain.then(() => localWait(touristField.delay || 250, 0));
        });
    }
    ;
    var hTMLLIElements = document.querySelectorAll('ul#customer-list1 li.list-group-item');
    Array.prototype.forEach.call(hTMLLIElements, (hTMLLIElement, index) => {
        var _a, _b;
        let tourist = data.tourists[index];
        if (!tourist)
            return;
        let birthdayDate = new Date(tourist.birthday);
        let touristFields = [
            {
                htmlElementSelector: `select#slctCustomerTitle${index + 1}`,
                value: tourist.sex,
                fieldType: FieldType.Sex
            },
            {
                htmlElementSelector: `input#txtCustomerName${index + 1}`,
                value: `${tourist.surname} ${tourist.name} ${tourist.middlename ? tourist.middlename : ''}`,
                fieldType: FieldType.Text
            },
            {
                htmlElementSelector: `input#dpCustomerBirthDate${index + 1}`,
                value: new Date(tourist.birthday),
                fieldType: FieldType.DatePicker
            },
            {
                htmlElementSelector: `select#slctCustomerNationality${index + 1}`,
                value: tourist.citizenship,
                fieldType: FieldType.Citizenship
            },
            {
                htmlElementSelector: `input#txtCustomerPassportNo${index + 1}`,
                value: `${(_a = tourist.travelPassport) === null || _a === void 0 ? void 0 : _a.series}`,
                fieldType: FieldType.Text
            },
            {
                htmlElementSelector: `input#txtCustomerIdentityNo${index + 1}`,
                value: `${(_b = tourist.travelPassport) === null || _b === void 0 ? void 0 : _b.number}`,
                fieldType: FieldType.Text
            }
        ];
        handleTouristFields(hTMLLIElement, touristFields);
    });
    let countries = [
        {
            "value": "",
            "eng": "Nationality",
            "ru": ""
        },
        {
            "value": "AF",
            "eng": "AFGHANISTAN              ",
            "ru": "Афганистан"
        },
        {
            "value": "AX",
            "eng": "ALAND ISLANDS            ",
            "ru": ""
        },
        {
            "value": "AL",
            "eng": "ALBANIA",
            "ru": ""
        },
        {
            "value": "DZ",
            "eng": "ALGERIA",
            "ru": ""
        },
        {
            "value": "AD",
            "eng": "ANDORRA",
            "ru": ""
        },
        {
            "value": "AO",
            "eng": "ANGOLA                   ",
            "ru": ""
        },
        {
            "value": "AI",
            "eng": "ANGUILLA                 ",
            "ru": ""
        },
        {
            "value": "AG",
            "eng": "ANTIGUA AND BARBUDA      ",
            "ru": ""
        },
        {
            "value": "AR",
            "eng": "ARGENTINA                ",
            "ru": ""
        },
        {
            "value": "AM",
            "eng": "ARMENIA                  ",
            "ru": "Армения"
        },
        {
            "value": "AU",
            "eng": "AUSTRALIA",
            "ru": ""
        },
        {
            "value": "AT",
            "eng": "AUSTRIA",
            "ru": ""
        },
        {
            "value": "AZ",
            "eng": "AZERBAIJAN",
            "ru": "Азербайджан"
        },
        {
            "value": "BS",
            "eng": "BAHAMAS                  ",
            "ru": ""
        },
        {
            "value": "BH",
            "eng": "BAHRAIN",
            "ru": "Бахрейн"
        },
        {
            "value": "BD",
            "eng": "BANGLADESH",
            "ru": ""
        },
        {
            "value": "BB",
            "eng": "BARBADOS                 ",
            "ru": ""
        },
        {
            "value": "BY",
            "eng": "BELARUS",
            "ru": "Беларусь"
        },
        {
            "value": "BE",
            "eng": "BELGIUM",
            "ru": ""
        },
        {
            "value": "BZ",
            "eng": "BELIZE                   ",
            "ru": ""
        },
        {
            "value": "BJ",
            "eng": "BENIN                    ",
            "ru": ""
        },
        {
            "value": "BM",
            "eng": "BERMUDA                  ",
            "ru": ""
        },
        {
            "value": "BT",
            "eng": "BHUTAN                   ",
            "ru": ""
        },
        {
            "value": "BO",
            "eng": "BOLIVIA, PLURINATIONAL ST",
            "ru": ""
        },
        {
            "value": "BQ",
            "eng": "BONAIRE, SAINT EUSTATIUS ",
            "ru": ""
        },
        {
            "value": "BA",
            "eng": "BOSNIA AND HERZEGOVINA",
            "ru": ""
        },
        {
            "value": "BW",
            "eng": "BOTSWANA                 ",
            "ru": ""
        },
        {
            "value": "BV",
            "eng": "BOUVET ISLAND            ",
            "ru": ""
        },
        {
            "value": "BR",
            "eng": "BRAZIL",
            "ru": ""
        },
        {
            "value": "IO",
            "eng": "BRITISH INDIAN OCEAN TERR",
            "ru": ""
        },
        {
            "value": "BN",
            "eng": "BRUNEI DARUSSALAM        ",
            "ru": ""
        },
        {
            "value": "BG",
            "eng": "BULGARIA",
            "ru": ""
        },
        {
            "value": "BF",
            "eng": "BURKINA FASO             ",
            "ru": ""
        },
        {
            "value": "BI",
            "eng": "BURUNDI                  ",
            "ru": ""
        },
        {
            "value": "KH",
            "eng": "CAMBODIA                 ",
            "ru": ""
        },
        {
            "value": "CM",
            "eng": "CAMEROON                 ",
            "ru": ""
        },
        {
            "value": "CA",
            "eng": "CANADA",
            "ru": "Канада"
        },
        {
            "value": "CV",
            "eng": "CAPE VERDE               ",
            "ru": ""
        },
        {
            "value": "KY",
            "eng": "CAYMAN ISLANDS           ",
            "ru": ""
        },
        {
            "value": "CF",
            "eng": "CENTRAL AFRICAN REPUBLIC ",
            "ru": ""
        },
        {
            "value": "TD",
            "eng": "CHAD                     ",
            "ru": ""
        },
        {
            "value": "CL",
            "eng": "CHILE                    ",
            "ru": ""
        },
        {
            "value": "CN",
            "eng": "CHINA",
            "ru": "Китай"
        },
        {
            "value": "CX",
            "eng": "CHRISTMAS ISLAND         ",
            "ru": ""
        },
        {
            "value": "CC",
            "eng": "COCOS (KEELING) ISLANDS  ",
            "ru": ""
        },
        {
            "value": "CO",
            "eng": "COLOMBIA                 ",
            "ru": ""
        },
        {
            "value": "KM",
            "eng": "COMOROS                  ",
            "ru": ""
        },
        {
            "value": "CG",
            "eng": "CONGO                    ",
            "ru": ""
        },
        {
            "value": "CD",
            "eng": "CONGO, THE DEMOCRATIC REP",
            "ru": ""
        },
        {
            "value": "CK",
            "eng": "COOK ISLANDS             ",
            "ru": ""
        },
        {
            "value": "CR",
            "eng": "COSTA RICA               ",
            "ru": ""
        },
        {
            "value": "HR",
            "eng": "CROATIA",
            "ru": ""
        },
        {
            "value": "CU",
            "eng": "CUBA",
            "ru": ""
        },
        {
            "value": "CW",
            "eng": "CURACAO                  ",
            "ru": ""
        },
        {
            "value": "CY",
            "eng": "CYPRUS",
            "ru": ""
        },
        {
            "value": "CZ",
            "eng": "CZECH REPUBLIC",
            "ru": ""
        },
        {
            "value": "DK",
            "eng": "DENMARK",
            "ru": ""
        },
        {
            "value": "DJ",
            "eng": "DJIBOUTI                 ",
            "ru": ""
        },
        {
            "value": "DM",
            "eng": "DOMINICA                 ",
            "ru": ""
        },
        {
            "value": "DO",
            "eng": "DOMINICAN REPUBLIC       ",
            "ru": ""
        },
        {
            "value": "EC",
            "eng": "ECUADOR",
            "ru": ""
        },
        {
            "value": "EG",
            "eng": "EGYPT",
            "ru": "Египет"
        },
        {
            "value": "SV",
            "eng": "EL SALVADOR              ",
            "ru": ""
        },
        {
            "value": "GQ",
            "eng": "EQUATORIAL GUINEA        ",
            "ru": ""
        },
        {
            "value": "ER",
            "eng": "ERITREA                  ",
            "ru": ""
        },
        {
            "value": "EE",
            "eng": "ESTONIA",
            "ru": "Эстония"
        },
        {
            "value": "ET",
            "eng": "ETHIOPIA                 ",
            "ru": ""
        },
        {
            "value": "EU",
            "eng": "EUROPE",
            "ru": ""
        },
        {
            "value": "FK",
            "eng": "FALKLAND ISLANDS (MALVINA",
            "ru": ""
        },
        {
            "value": "FO",
            "eng": "FAROE ISLANDS            ",
            "ru": ""
        },
        {
            "value": "FJ",
            "eng": "FIJI                     ",
            "ru": ""
        },
        {
            "value": "FI",
            "eng": "FINLAND",
            "ru": "Финляндия"
        },
        {
            "value": "FR",
            "eng": "FRANCE",
            "ru": "Франция"
        },
        {
            "value": "GF",
            "eng": "FRENCH GUIANA            ",
            "ru": ""
        },
        {
            "value": "PF",
            "eng": "FRENCH POLYNESIA         ",
            "ru": ""
        },
        {
            "value": "TF",
            "eng": "FRENCH SOUTHERN TERRITORI",
            "ru": ""
        },
        {
            "value": "GA",
            "eng": "GABON                    ",
            "ru": ""
        },
        {
            "value": "GM",
            "eng": "GAMBIA                   ",
            "ru": ""
        },
        {
            "value": "GE",
            "eng": "GEORGIA",
            "ru": "Грузия"
        },
        {
            "value": "DE",
            "eng": "GERMANY",
            "ru": "Германия"
        },
        {
            "value": "GH",
            "eng": "GHANA                    ",
            "ru": ""
        },
        {
            "value": "GI",
            "eng": "GIBRALTAR                ",
            "ru": ""
        },
        {
            "value": "GR",
            "eng": "GREECE",
            "ru": ""
        },
        {
            "value": "GL",
            "eng": "GREENLAND                ",
            "ru": ""
        },
        {
            "value": "GD",
            "eng": "GRENADA                  ",
            "ru": ""
        },
        {
            "value": "GP",
            "eng": "GUADELOUPE               ",
            "ru": ""
        },
        {
            "value": "GU",
            "eng": "GUAM                     ",
            "ru": ""
        },
        {
            "value": "GT",
            "eng": "GUATEMALA                ",
            "ru": "Гватемала"
        },
        {
            "value": "GG",
            "eng": "GUERNSEY                 ",
            "ru": ""
        },
        {
            "value": "GN",
            "eng": "GUINEA                   ",
            "ru": ""
        },
        {
            "value": "GW",
            "eng": "GUINEA-BISSAU            ",
            "ru": ""
        },
        {
            "value": "GY",
            "eng": "GUYANA                   ",
            "ru": ""
        },
        {
            "value": "HT",
            "eng": "HAITI                    ",
            "ru": ""
        },
        {
            "value": "HM",
            "eng": "HEARD ISLAND AND MCDONALD",
            "ru": ""
        },
        {
            "value": "VA",
            "eng": "HOLY SEE (VATICAN CITY ST",
            "ru": ""
        },
        {
            "value": "HN",
            "eng": "HONDURAS                 ",
            "ru": ""
        },
        {
            "value": "HK",
            "eng": "HONG KONG                ",
            "ru": ""
        },
        {
            "value": "HU",
            "eng": "HUNGARY",
            "ru": ""
        },
        {
            "value": "IS",
            "eng": "ICELAND",
            "ru": ""
        },
        {
            "value": "IN",
            "eng": "INDIA",
            "ru": "Индия"
        },
        {
            "value": "ID",
            "eng": "INDONESIA                ",
            "ru": "Индонезия"
        },
        {
            "value": "IR",
            "eng": "IRAN",
            "ru": "Иран"
        },
        {
            "value": "IQ",
            "eng": "IRAQ",
            "ru": ""
        },
        {
            "value": "IE",
            "eng": "IRELAND",
            "ru": "Ирландия"
        },
        {
            "value": "IM",
            "eng": "ISLE OF MAN              ",
            "ru": ""
        },
        {
            "value": "IL",
            "eng": "ISRAEL",
            "ru": "Израиль"
        },
        {
            "value": "IT",
            "eng": "ITALY",
            "ru": "Италия"
        },
        {
            "value": "CI",
            "eng": "IVORY COAST",
            "ru": ""
        },
        {
            "value": "JM",
            "eng": "JAMAICA                  ",
            "ru": ""
        },
        {
            "value": "JP",
            "eng": "JAPAN",
            "ru": "Япония"
        },
        {
            "value": "JE",
            "eng": "JERSEY                   ",
            "ru": ""
        },
        {
            "value": "JO",
            "eng": "JORDAN",
            "ru": "Иордания"
        },
        {
            "value": "KZ",
            "eng": "KAZAKHSTAN",
            "ru": "Казахстан"
        },
        {
            "value": "KE",
            "eng": "KENYA                    ",
            "ru": ""
        },
        {
            "value": "KI",
            "eng": "KIRIBATI                 ",
            "ru": ""
        },
        {
            "value": "KR",
            "eng": "KOREA",
            "ru": ""
        },
        {
            "value": "KP",
            "eng": "KOREA, DEMOCRATIC PEOPLE'",
            "ru": ""
        },
        {
            "value": "KS",
            "eng": "KOSOVA",
            "ru": ""
        },
        {
            "value": "XK",
            "eng": "KOSOVO",
            "ru": ""
        },
        {
            "value": "KW",
            "eng": "KUWAIT",
            "ru": ""
        },
        {
            "value": "KG",
            "eng": "KYRGYZSTAN",
            "ru": "Киргизия"
        },
        {
            "value": "LA",
            "eng": "LAO PEOPLE'S DEMOCRATIC R",
            "ru": ""
        },
        {
            "value": "LV",
            "eng": "LATVIA",
            "ru": "Латвия"
        },
        {
            "value": "LB",
            "eng": "LEBANON",
            "ru": ""
        },
        {
            "value": "LS",
            "eng": "LESOTHO                  ",
            "ru": ""
        },
        {
            "value": "LR",
            "eng": "LIBERIA                  ",
            "ru": ""
        },
        {
            "value": "LY",
            "eng": "LIBYA",
            "ru": ""
        },
        {
            "value": "LI",
            "eng": "LIECHTENSTEIN            ",
            "ru": ""
        },
        {
            "value": "LT",
            "eng": "LITHUANIA",
            "ru": "Литва"
        },
        {
            "value": "LU",
            "eng": "LUXEMBOURG",
            "ru": ""
        },
        {
            "value": "MO",
            "eng": "MACAO                    ",
            "ru": ""
        },
        {
            "value": "MK",
            "eng": "MACEDONIA",
            "ru": "Македония"
        },
        {
            "value": "MG",
            "eng": "MADAGASCAR               ",
            "ru": ""
        },
        {
            "value": "MW",
            "eng": "MALAWI                   ",
            "ru": ""
        },
        {
            "value": "MY",
            "eng": "MALAYSIA",
            "ru": ""
        },
        {
            "value": "MV",
            "eng": "MALDIVES                 ",
            "ru": ""
        },
        {
            "value": "ML",
            "eng": "MALI                     ",
            "ru": ""
        },
        {
            "value": "MT",
            "eng": "MALTA",
            "ru": ""
        },
        {
            "value": "MH",
            "eng": "MARSHALL ISLANDS         ",
            "ru": ""
        },
        {
            "value": "MQ",
            "eng": "MARTINIQUE               ",
            "ru": ""
        },
        {
            "value": "MR",
            "eng": "MAURITANIA               ",
            "ru": ""
        },
        {
            "value": "MU",
            "eng": "MAURITIUS",
            "ru": ""
        },
        {
            "value": "YT",
            "eng": "MAYOTTE                  ",
            "ru": ""
        },
        {
            "value": "AS",
            "eng": "MERICAN SAMOA            ",
            "ru": ""
        },
        {
            "value": "MX",
            "eng": "MEXICO                   ",
            "ru": ""
        },
        {
            "value": "FM",
            "eng": "MICRONESIA, FEDERATED STA",
            "ru": ""
        },
        {
            "value": "MD",
            "eng": "MOLDOVA",
            "ru": "Молдова"
        },
        {
            "value": "MC",
            "eng": "MONACO                   ",
            "ru": ""
        },
        {
            "value": "MN",
            "eng": "MONGOLIA                 ",
            "ru": "Монголия"
        },
        {
            "value": "ME",
            "eng": "MONTENEGRO",
            "ru": ""
        },
        {
            "value": "MS",
            "eng": "MONTSERRAT               ",
            "ru": ""
        },
        {
            "value": "MA",
            "eng": "MOROCCO",
            "ru": ""
        },
        {
            "value": "MZ",
            "eng": "MOZAMBIQUE               ",
            "ru": ""
        },
        {
            "value": "MM",
            "eng": "MYANMAR                  ",
            "ru": ""
        },
        {
            "value": "NA",
            "eng": "NAMIBIA                  ",
            "ru": ""
        },
        {
            "value": "NR",
            "eng": "NAURU                    ",
            "ru": ""
        },
        {
            "value": "NP",
            "eng": "NEPAL                    ",
            "ru": ""
        },
        {
            "value": "NL",
            "eng": "NETHERLANDS",
            "ru": ""
        },
        {
            "value": "NC",
            "eng": "NEW CALEDONIA            ",
            "ru": ""
        },
        {
            "value": "NZ",
            "eng": "NEW ZEALAND              ",
            "ru": ""
        },
        {
            "value": "NI",
            "eng": "NICARAGUA                ",
            "ru": ""
        },
        {
            "value": "NE",
            "eng": "NIGER                    ",
            "ru": ""
        },
        {
            "value": "NG",
            "eng": "NIGERIA",
            "ru": ""
        },
        {
            "value": "NU",
            "eng": "NIUE                     ",
            "ru": ""
        },
        {
            "value": "NF",
            "eng": "NORFOLK ISLAND           ",
            "ru": ""
        },
        {
            "value": "NY",
            "eng": "NORTHERN CYPRUS",
            "ru": ""
        },
        {
            "value": "MP",
            "eng": "NORTHERN MARIANA ISLANDS ",
            "ru": ""
        },
        {
            "value": "NO",
            "eng": "NORWAY                   ",
            "ru": ""
        },
        {
            "value": "AQ",
            "eng": "NTARCTICA                ",
            "ru": ""
        },
        {
            "value": "OM",
            "eng": "OMAN                     ",
            "ru": ""
        },
        {
            "value": "OTH",
            "eng": "OTHERS",
            "ru": ""
        },
        {
            "value": "PK",
            "eng": "PAKISTAN",
            "ru": "Пакистан"
        },
        {
            "value": "PW",
            "eng": "PALAU                    ",
            "ru": ""
        },
        {
            "value": "PS",
            "eng": "PALESTINE",
            "ru": ""
        },
        {
            "value": "PA",
            "eng": "PANAMA                   ",
            "ru": ""
        },
        {
            "value": "PG",
            "eng": "PAPUA NEW GUINEA         ",
            "ru": ""
        },
        {
            "value": "PY",
            "eng": "PARAGUAY                 ",
            "ru": ""
        },
        {
            "value": "PE",
            "eng": "PERU                     ",
            "ru": ""
        },
        {
            "value": "PH",
            "eng": "PHILIPPINES              ",
            "ru": "Филиппины"
        },
        {
            "value": "PN",
            "eng": "PITCAIRN                 ",
            "ru": ""
        },
        {
            "value": "PL",
            "eng": "POLAND",
            "ru": "Польша"
        },
        {
            "value": "PT",
            "eng": "PORTUGAL",
            "ru": ""
        },
        {
            "value": "PR",
            "eng": "PUERTO RICO              ",
            "ru": ""
        },
        {
            "value": "QA",
            "eng": "QATAR",
            "ru": ""
        },
        {
            "value": "RE",
            "eng": "REUNION",
            "ru": ""
        },
        {
            "value": "RO",
            "eng": "ROMANIA",
            "ru": "Румыния"
        },
        {
            "value": "AW",
            "eng": "RUBA                     ",
            "ru": ""
        },
        {
            "value": "RU",
            "eng": "RUSSIA",
            "ru": "Россия"
        },
        {
            "value": "RW",
            "eng": "RWANDA                   ",
            "ru": ""
        },
        {
            "value": "BL",
            "eng": "SAINT BARTHELEMY         ",
            "ru": ""
        },
        {
            "value": "SH",
            "eng": "SAINT HELENA, ASCENSION A",
            "ru": ""
        },
        {
            "value": "KN",
            "eng": "SAINT KITTS AND NEVIS    ",
            "ru": "Сент-Китс и Невис"
        },
        {
            "value": "LC",
            "eng": "SAINT LUCIA              ",
            "ru": ""
        },
        {
            "value": "MF",
            "eng": "SAINT MARTIN (FRENCH PART",
            "ru": ""
        },
        {
            "value": "PM",
            "eng": "SAINT PIERRE AND MIQUELON",
            "ru": ""
        },
        {
            "value": "VC",
            "eng": "SAINT VINCENT AND THE GRE",
            "ru": ""
        },
        {
            "value": "WS",
            "eng": "SAMOA                    ",
            "ru": ""
        },
        {
            "value": "SM",
            "eng": "SAN MARINO               ",
            "ru": ""
        },
        {
            "value": "ST",
            "eng": "SAO TOME AND PRINCIPE    ",
            "ru": ""
        },
        {
            "value": "SA",
            "eng": "SAUDI ARABIA",
            "ru": "Саудовская Аравия"
        },
        {
            "value": "SN",
            "eng": "SENEGAL                  ",
            "ru": ""
        },
        {
            "value": "RS",
            "eng": "SERBIA",
            "ru": "Сербия"
        },
        {
            "value": "SC",
            "eng": "SEYCHELLES               ",
            "ru": ""
        },
        {
            "value": "SL",
            "eng": "SIERRA LEONE",
            "ru": ""
        },
        {
            "value": "SG",
            "eng": "SINGAPORE                ",
            "ru": ""
        },
        {
            "value": "SX",
            "eng": "SINT MAARTEN (DUTCH PART)",
            "ru": ""
        },
        {
            "value": "SK",
            "eng": "SLOVAKIA",
            "ru": "Славакия"
        },
        {
            "value": "SI",
            "eng": "SLOVENIA",
            "ru": ""
        },
        {
            "value": "SB",
            "eng": "SOLOMON ISLANDS          ",
            "ru": ""
        },
        {
            "value": "SO",
            "eng": "SOMALIA                  ",
            "ru": ""
        },
        {
            "value": "ZA",
            "eng": "SOUTH AFRICA",
            "ru": "ЮАР"
        },
        {
            "value": "GS",
            "eng": "SOUTH GEORGIA AND THE SOU",
            "ru": ""
        },
        {
            "value": "ES",
            "eng": "SPAIN",
            "ru": "Испания"
        },
        {
            "value": "LK",
            "eng": "SRI LANKA                ",
            "ru": ""
        },
        {
            "value": "SD",
            "eng": "SUDAN",
            "ru": ""
        },
        {
            "value": "SR",
            "eng": "SURINAME",
            "ru": ""
        },
        {
            "value": "SJ",
            "eng": "SVALBARD AND JAN MAYEN   ",
            "ru": ""
        },
        {
            "value": "SZ",
            "eng": "SWAZILAND                ",
            "ru": ""
        },
        {
            "value": "SE",
            "eng": "SWEDEN",
            "ru": "Швеция"
        },
        {
            "value": "CH",
            "eng": "SWITZERLAND",
            "ru": ""
        },
        {
            "value": "SY",
            "eng": "SYRIAN ARAB REPUBLIC     ",
            "ru": ""
        },
        {
            "value": "TW",
            "eng": "TAIWAN, PROVINCE OF CHINA",
            "ru": ""
        },
        {
            "value": "TJ",
            "eng": "TAJIKISTAN",
            "ru": "Таджикистан"
        },
        {
            "value": "TZ",
            "eng": "TANZANIA, UNITED REPUBLIC",
            "ru": ""
        },
        {
            "value": "TH",
            "eng": "THAILAND",
            "ru": ""
        },
        {
            "value": "TL",
            "eng": "TIMOR-LESTE              ",
            "ru": ""
        },
        {
            "value": "TG",
            "eng": "TOGO                     ",
            "ru": ""
        },
        {
            "value": "TK",
            "eng": "TOKELAU                  ",
            "ru": ""
        },
        {
            "value": "TO",
            "eng": "TONGA                    ",
            "ru": ""
        },
        {
            "value": "TT",
            "eng": "TRINIDAD AND TOBAGO      ",
            "ru": ""
        },
        {
            "value": "TN",
            "eng": "TUNISIA",
            "ru": "Тунис"
        },
        {
            "value": "TR",
            "eng": "TURKEY",
            "ru": "Турция"
        },
        {
            "value": "TM",
            "eng": "TURKMENISTAN",
            "ru": "Туркменистан"
        },
        {
            "value": "TC",
            "eng": "TURKS AND CAICOS ISLANDS",
            "ru": ""
        },
        {
            "value": "TV",
            "eng": "TUVALU                   ",
            "ru": ""
        },
        {
            "value": "UG",
            "eng": "UGANDA                   ",
            "ru": ""
        },
        {
            "value": "UA",
            "eng": "UKRAINE",
            "ru": "Украина"
        },
        {
            "value": "AE",
            "eng": "UNITED ARAB EMIRATES",
            "ru": "ОАЭ"
        },
        {
            "value": "GB",
            "eng": "UNITED KINGDOM",
            "ru": ""
        },
        {
            "value": "UM",
            "eng": "UNITED STATES MINOR OUTLY",
            "ru": ""
        },
        {
            "value": "US",
            "eng": "UNITED STATES OF AMERICA",
            "ru": "США"
        },
        {
            "value": "UY",
            "eng": "URUGUAY                  ",
            "ru": ""
        },
        {
            "value": "RU2",
            "eng": "USSR",
            "ru": ""
        },
        {
            "value": "UZ",
            "eng": "UZBEKISTAN",
            "ru": "Узбекистан"
        },
        {
            "value": "VU",
            "eng": "VANUATU                  ",
            "ru": ""
        },
        {
            "value": "VE",
            "eng": "VENEZUELA",
            "ru": ""
        },
        {
            "value": "VN",
            "eng": "VIET NAM                 ",
            "ru": ""
        },
        {
            "value": "VG",
            "eng": "VIRGIN ISLANDS, BRITISH  ",
            "ru": ""
        },
        {
            "value": "VI",
            "eng": "VIRGIN ISLANDS, U.S.     ",
            "ru": ""
        },
        {
            "value": "WF",
            "eng": "WALLIS AND FUTUNA        ",
            "ru": ""
        },
        {
            "value": "EH",
            "eng": "WESTERN SAHARA           ",
            "ru": ""
        },
        {
            "value": "YE",
            "eng": "YEMEN                    ",
            "ru": ""
        },
        {
            "value": "ZM",
            "eng": "ZAMBIA                   ",
            "ru": "Замбия"
        },
        {
            "value": "ZW",
            "eng": "ZIMBABWE                 ",
            "ru": ""
        }
    ];
}


/***/ },

/***/ "./src/serverScripts/formFill/formFill_peninsula.ts"
/*!**********************************************************!*\
  !*** ./src/serverScripts/formFill/formFill_peninsula.ts ***!
  \**********************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   formFill: () => (/* binding */ formFill)
/* harmony export */ });
/* harmony import */ var _operators_peninsula__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../operators/peninsula */ "./src/serverScripts/operators/peninsula.ts");
/* harmony import */ var _app_utils_chunks_createTab__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../app/utils/chunks/createTab */ "./src/app/utils/chunks/createTab.ts");
/* harmony import */ var _app_models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../app/models/chunks/notificationBody */ "./src/app/models/chunks/notificationBody.ts");
/* harmony import */ var _app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../app/utils/chunks/executeScriptInTab */ "./src/app/utils/chunks/executeScriptInTab.ts");
/* harmony import */ var _app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../app/utils/chunks/updateListener */ "./src/app/utils/chunks/updateListener.ts");
/* harmony import */ var _app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../app/utils/chunks/createPushNotification */ "./src/app/utils/chunks/createPushNotification.ts");
/* harmony import */ var _app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../app/utils/chunks/startTrackingElementInternal */ "./src/app/utils/chunks/startTrackingElementInternal.ts");
/* harmony import */ var _app_utils_chunks_removeCookies__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../app/utils/chunks/removeCookies */ "./src/app/utils/chunks/removeCookies.ts");
/* harmony import */ var _app_utils_chunks_executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../app/utils/chunks/executeLoginScriptInTabV3 */ "./src/app/utils/chunks/executeLoginScriptInTabV3.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};









function formFill(context) {
    return __awaiter(this, void 0, void 0, function* () {
        const { data, claimNumber } = context;
        let tourUrl = 'http://b2b.peninsula.com.tr/b2b';
        try {
            yield (0,_app_utils_chunks_removeCookies__WEBPACK_IMPORTED_MODULE_7__.removeCookiesForTouroperator)(_operators_peninsula__WEBPACK_IMPORTED_MODULE_0__.Peninsula);
            let tab = yield (0,_app_utils_chunks_createTab__WEBPACK_IMPORTED_MODULE_1__.createTab)({
                active: true,
                url: tourUrl,
                windowId: chrome.windows.WINDOW_ID_CURRENT
            });
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'form#frmLogin');
            yield (0,_app_utils_chunks_executeLoginScriptInTabV3__WEBPACK_IMPORTED_MODULE_8__.executeLoginScriptInTabV3)(tab, {
                login: data.login,
                password: data.password,
                packet: _operators_peninsula__WEBPACK_IMPORTED_MODULE_0__.Peninsula.packet
            });
            yield (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'div.page-header');
            let jsTravelDate = new Date(data.travelDate);
            let jsTravelDateEnd = new Date(data.travelDateEnd);
            let serachParams = {
                countryTo: data.countryTo,
                cityTo: data.countryTo,
                regionTo: data.countryTo,
                resort: data.resort,
                hotelName: data.hotelName,
                startDate: `${jsTravelDate.getDate()}/${jsTravelDate.getMonth() + 1}/${jsTravelDate.getFullYear()}`,
                endDate: `${jsTravelDateEnd.getDate()}/${jsTravelDateEnd.getMonth() + 1}/${jsTravelDateEnd.getFullYear()}`,
                duration: data.duration,
                adultCount: data.adultCount,
                childCount: data.childCount,
                infantCount: data.infantCount,
                childrenAges: data.autoFillerData.childrenAges
            };
            // заполняем форму поиска
            (0,_app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__.updateListenerOnSamePage)(tab.id, /b2b\.peninsula\.com\.tr\/b2b\/HotelSearch\/index/, (tabId, changeInfo, updatedTab) => {
                debugger;
                console.log('Собираемся заполнять форму поиска');
                (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(updatedTab, 'div#divHotelProduct')
                    .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(updatedTab, searchParamsFiller, [serachParams]));
                return true;
            });
            let fillerParams = {
                tourists: data.autoFillerData.touristDataItems,
                customer: data.autoFillerData.customer,
                countryTo: data.countryTo,
                adultCount: data.adultCount,
                childCount: data.childCount,
                infantCount: data.infantCount,
                claimNumber: claimNumber
            };
            // заполняем форму туриста
            // https://b2b.peninsula.com.tr/b2b/Reservation/Index
            (0,_app_utils_chunks_updateListener__WEBPACK_IMPORTED_MODULE_4__.updateListenerOnSamePage)(tab.id, /b2b\.peninsula\.com\.tr\/b2b\/Reservation\/Index/, (tabId, changeInfo, updatedTab) => {
                debugger;
                console.log('Собираемся заполнять форму туриста');
                (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(updatedTab, 'div#hotelServiceViewBlock')
                    .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(updatedTab, claimFiller, [fillerParams]));
                (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(updatedTab, 'input#txtVoucher')
                    .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(updatedTab, (claimNumber) => {
                    console.log('Fill claimNumber');
                    let element = document.querySelector('input#txtVoucher');
                    if (element) {
                        element.value = claimNumber;
                        element.dispatchEvent(new Event('change', { bubbles: true }));
                        element.dispatchEvent(new Event('input', { bubbles: true }));
                    }
                }, [claimNumber]));
                return true;
            });
            (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'div#hotelServiceViewBlock')
                .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(tab, claimFiller, [fillerParams]));
            (0,_app_utils_chunks_startTrackingElementInternal__WEBPACK_IMPORTED_MODULE_6__.startTrackingElement)(tab, 'input#txtVoucher')
                .then(() => (0,_app_utils_chunks_executeScriptInTab__WEBPACK_IMPORTED_MODULE_3__.executeScriptInTabV3)(tab, (claimNumber) => {
                console.log('Fill claimNumber');
                let element = document.querySelector('input#txtVoucher');
                if (element) {
                    element.value = claimNumber;
                    element.dispatchEvent(new Event('change', { bubbles: true }));
                    element.dispatchEvent(new Event('input', { bubbles: true }));
                }
            }, [claimNumber]));
            yield (0,_app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__.createPushNotification)({ claimId: claimNumber, operator: _operators_peninsula__WEBPACK_IMPORTED_MODULE_0__.Peninsula, errorText: null });
        }
        catch (e) {
            console.log("formFill фатальная ошибка Peninsula");
            console.log(e);
            console.dir(e);
            yield (0,_app_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__.createPushNotification)({ status: _app_models_chunks_notificationBody__WEBPACK_IMPORTED_MODULE_2__.SendIdsStatus.FAIL, message: e.message });
        }
    });
}
function searchParamsFiller(params) {
    let hotels = [
        { value: "ANBAAK", eng: "AKRA ANTALYA", ru: "" },
        { value: "ANBAAP", eng: "AKRA V HOTEL", ru: "" },
        { value: "ANTALP", eng: "ALP PASA HOTEL", ru: "" },
        { value: "ANARGO", eng: "ARGOS HOTEL", ru: "" },
        { value: "ANASPE", eng: "ASPEN HOTEL ANTALYA", ru: "" },
        { value: "ANATAL", eng: "ATALLA HOTEL", ru: "" },
        { value: "BLMNDO", eng: "BELMONDO SUITES OLD TOWN", ru: "" },
        { value: "ANBWKH", eng: "BEST WESTERN PLUS KHAN HOTEL", ru: "" },
        { value: "ANBLMH", eng: "BILEM HOTEL BEACH & SPA", ru: "" },
        { value: "ANCEND", eng: "CENDER HOTEL", ru: "" },
        { value: "ANCITR", eng: "CITRUS PARK HOTEL", ru: "" },
        { value: "ANCITL", eng: "CITY LIVE HOTEL", ru: "" },
        { value: "ANSERA", eng: "CLUB HOTEL SERA", ru: "" },
        { value: "ANDERI", eng: "DER INN HOTEL", ru: "" },
        { value: "ANDINN", eng: "DER INN LARA", ru: "" },
        { value: "ANDTRE", eng: "DOUBLETREE BY HILTON ANTALYA CITY CENTER", ru: "" },
        { value: "ANTELG", eng: "ELEGANCE EAST HOTEL", ru: "" },
        { value: "AN1511", eng: "FALCON 1511", ru: "" },
        { value: "ANFALC", eng: "FALCON HOTEL", ru: "" },
        { value: "ANGOOR", eng: "GOLDEN ORANGE HOTEL", ru: "" },
        { value: "ANGUR", eng: "GURTAS HOTEL", ru: "" },
        { value: "AN1207", eng: "HOTEL 1207 SPECIAL CLASS KALEICI", ru: "" },
        { value: "ANLRFM", eng: "LAREN FAMILY HOTEL", ru: "" },
        { value: "ANLABO", eng: "MASSIMO HOTEL", ru: "" },
        { value: "ANTMED", eng: "MEDITERRA ART HOTEL", ru: "" },
        { value: "ANMSWB", eng: "MEGASARAY WEST BEACH", ru: "" },
        { value: "ANMRC", eng: "MERCURE ANTALYA KONYAALTI", ru: "" },
        { value: "ANMIEL", eng: "MIELO LARA HOTEL", ru: "" },
        { value: "ANOZKA", eng: "OZKAYMAK FALEZ HOTEL", ru: "" },
        { value: "ANPRLY", eng: "PEARLY HOTEL", ru: "" },
        { value: "ANPORT", eng: "PORTO BELLO HOTEL RESORT & SPA", ru: "Porto Bello Hotel" },
        { value: "ANDOGA", eng: "PRANA RESORT DOGAN HOTEL", ru: "" },
        { value: "ANPUDM", eng: "PUDING HOTEL", ru: "" },
        { value: "ANRAMA", eng: "RAMADA PLAZA ANTALYA", ru: "" },
        { value: "RENEX", eng: "RENEX HOTEL", ru: "" },
        { value: "ANDOWN", eng: "RIXOS DOWNTOWN- THE LAND OF LEGENDS FREE ACCESS", ru: "" },
        { value: "ANTRUA", eng: "RUIN ADALIA HOTEL +14", ru: "" },
        { value: "ANSEAL", eng: "SEALIFE FAMILY RESORT HOTEL", ru: "" },
        { value: "ANSHPM", eng: "SHERWOOD PREMIO HOTEL", ru: "" },
        { value: "ANHOSU", eng: "SUNIS HOTEL SU", ru: "" },
        { value: "ANMARM", eng: "THE MARMARA ANTALYA", ru: "" },
    ];
    let regions = [
        { value: "ALY", eng: "ALANYA", ru: "Аланья" },
        { value: "ANT", eng: "ANTALYA", ru: "Анталья" },
        { value: "AYT", eng: "ANTALYA AIRPORT", ru: "" },
        { value: "BAF", eng: "BAFRA", ru: "" },
        { value: "BDR", eng: "BODRUM", ru: "Бодрум" },
        { value: "BLK", eng: "BELEK", ru: "Белек" },
        { value: "CSM", eng: "CESME", ru: "" },
        { value: "DAL", eng: "DALAMAN", ru: "Даламан" },
        { value: "DDM", eng: "DIDIM", ru: "" },
        { value: "DLY", eng: "DALYAN", ru: "" },
        { value: "FAM", eng: "FAMAGUSTA", ru: "" },
        { value: "FTY", eng: "FETHIYE", ru: "Фетих" },
        { value: "IST", eng: "ISTANBUL", ru: "Стамбул" },
        { value: "IZM", eng: "IZMIR", ru: "Измир" },
        { value: "KAP", eng: "KAPADOKYA", ru: "Каппадокия" },
        { value: "KAS", eng: "KAS", ru: "" },
        { value: "KMR", eng: "KEMER", ru: "Кемер" },
        { value: "KSD", eng: "KUSADASI", ru: "" },
        { value: "KYA", eng: "ANTALYA KONYAALTI", ru: "" },
        { value: "KYR", eng: "KYRENIA", ru: "" },
        { value: "LRK", eng: "LARA-KUNDU", ru: "" },
        { value: "MNG", eng: "MANAVGAT", ru: "Манавгат" },
        { value: "MRM", eng: "MARMARIS", ru: "Мармарис" },
        { value: "NIC", eng: "NICOSIA", ru: "" },
        { value: "OZD", eng: "OZDERE", ru: "" },
        { value: "SDE", eng: "SIDE", ru: "Сиде" },
        { value: "SFH", eng: "SEFERIHISAR", ru: "" },
        { value: "SRG", eng: "SARIGERME", ru: "" },
    ];
    debugger;
    let shouldSearchButtonClick = true;
    let mainChain = Promise.resolve();
    function wait(timeout) {
        return new Promise((resolve) => {
            setTimeout(() => resolve(), timeout);
        });
    }
    mainChain = mainChain.then(() => wait(1000 * 2));
    mainChain = mainChain.then(() => {
        // @ts-ignore
        let dpCheckIn = document.querySelector('input#dpCheckIn');
        if (dpCheckIn) {
            console.log(params);
            // @ts-ignore
            $('input#dpCheckIn').datepicker('setDate', params.startDate);
            // @ts-ignore
            $('input#dpCheckIn').datepicker('show');
            // @ts-ignore
            $('input#dpCheckIn').datepicker('hide');
        }
    });
    mainChain = mainChain.then(() => wait(500));
    mainChain = mainChain.then(() => {
        // @ts-ignore
        let dpCheckOut = document.querySelector('input#dpCheckOut');
        if (dpCheckOut) {
            console.log(params);
            // @ts-ignore
            $('input#dpCheckOut').datepicker('setDate', params.endDate);
            // @ts-ignore
            $('input#dpCheckOut').datepicker('show');
            // @ts-ignore
            $('input#dpCheckOut').datepicker('hide');
        }
    });
    mainChain = mainChain.then(() => wait(500));
    if (params.resort && params.resort !== '') {
        mainChain = mainChain.then(() => {
            let selectedRegions = regions.filter((r, i, arr) => {
                if (r.ru !== '' && params.resort.trim().toUpperCase() === r.ru.toUpperCase()) {
                    return true;
                }
            });
            if (selectedRegions.length > 0) {
                // @ts-ignore
                let option = document.querySelector(`select#slctRegion option[value=${selectedRegions[0].value}]`);
                if (option) {
                    option.selected = true;
                    option.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`select#slctRegion option[value=${selectedRegions[0].value}] не нашелся`);
                }
            }
            else {
                shouldSearchButtonClick = false;
                console.log(`${params.resort.trim().toUpperCase()} не нашелся регионах`);
                let select = document.querySelector(`select#slctRegion`);
                if (select && select.parentNode && select.parentNode.parentNode) {
                    select.parentNode.parentNode.style.border = "10px solid red";
                    select.parentNode.parentNode.style.borderRadius = '20px';
                    let div = document.createElement("div");
                    div.style.textAlign = 'center';
                    div.append(`--> ${params.resort} <--`);
                    select.parentNode.parentNode.appendChild(div);
                }
            }
        });
        mainChain = mainChain.then(() => wait(500));
    }
    if (params.hotelName && params.hotelName !== '') {
        mainChain = mainChain.then(() => {
            let selectedHotels = hotels.filter((h, i, arr) => {
                if (h.ru !== '' && params.hotelName && params.hotelName.trim().toUpperCase() === h.ru.toUpperCase()) {
                    return true;
                }
            });
            if (selectedHotels.length > 0) {
                // @ts-ignore
                let option = document.querySelector(`select#slctHotel option[value=${selectedHotels[0].value}]`);
                if (option) {
                    option.selected = true;
                    option.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`select#slctHotel option[value=${selectedHotels[0].value}] не нашелся`);
                }
            }
            else {
                shouldSearchButtonClick = false;
                console.log(`${params.hotelName.trim().toUpperCase()} не нашелся в резортах`);
                let select = document.querySelector(`select#slctHotel`);
                if (select && select.parentNode && select.parentNode.parentNode) {
                    select.parentNode.parentNode.style.border = "10px solid red";
                    select.parentNode.parentNode.style.borderRadius = '20px';
                    let div = document.createElement("div");
                    div.style.textAlign = 'center';
                    div.append(`--> ${params.hotelName} <--`);
                    select.parentNode.parentNode.appendChild(div);
                }
            }
        });
        mainChain = mainChain.then(() => wait(500));
    }
    if (params.adultCount !== 0) {
        mainChain = mainChain.then(() => {
            // @ts-ignore
            let txtAdultCountRoom1 = document.querySelector("input#txtAdultCountRoom1");
            if (txtAdultCountRoom1) {
                // @ts-ignore
                txtAdultCountRoom1.value = params.adultCount;
                txtAdultCountRoom1.dispatchEvent(new Event('input', { bubbles: true }));
                txtAdultCountRoom1.dispatchEvent(new Event('change', { bubbles: true }));
            }
            else {
                console.log(`document.querySelector("input#txtAdultCountRoom1") не нашелся`);
            }
        });
        mainChain = mainChain.then(() => wait(500));
    }
    if (params.childCount !== 0) {
        mainChain = mainChain.then(() => {
            // @ts-ignore
            let txtChildCountRoom1 = document.querySelector("input#txtChildCountRoom1");
            if (txtChildCountRoom1) {
                // @ts-ignore
                txtChildCountRoom1.value = params.childCount;
                txtChildCountRoom1.dispatchEvent(new Event('input', { bubbles: true }));
                txtChildCountRoom1.dispatchEvent(new Event('change', { bubbles: true }));
            }
            else {
                console.log(`document.querySelector("input#txtChildCountRoom1") не нашелся`);
            }
        });
        mainChain = mainChain.then(() => wait(500));
        if (params.childrenAges && params.childrenAges.length > 0) {
            Array.prototype.forEach.call(params.childrenAges, (age, index) => {
                mainChain = mainChain.then(() => {
                    let txtChildAge = document.querySelector(`input#txtChildAge${index + 1}Room1`);
                    if (txtChildAge) {
                        txtChildAge.value = age;
                        txtChildAge.dispatchEvent(new Event('input', { bubbles: true }));
                        txtChildAge.dispatchEvent(new Event('change', { bubbles: true }));
                    }
                });
                mainChain = mainChain.then(() => wait(500));
            });
        }
    }
    // это клац по кнопке "Search"
    mainChain = mainChain.then(() => {
        if (shouldSearchButtonClick) {
            console.log(`shouldSearchButtonClick = ${shouldSearchButtonClick}`);
            // @ts-ignore
            let searchButton = document.querySelector('button#btnSearch');
            if (searchButton) {
                searchButton.click();
            }
            else {
                console.log("document.querySelector('button#btnSearch') не нашелся");
            }
        }
    });
}
function claimFiller(data) {
    console.log('Peninsula claimFiller');
    console.dir(data);
    debugger;
    var mainChain = new Promise((res, rej) => res());
    function localWait(timeout, optionIndex) {
        return new Promise((resolve) => {
            setTimeout(() => resolve(optionIndex), timeout);
        });
    }
    let FieldType;
    (function (FieldType) {
        FieldType[FieldType["Text"] = 0] = "Text";
        FieldType[FieldType["Select"] = 1] = "Select";
        FieldType[FieldType["DatePicker"] = 2] = "DatePicker";
        FieldType[FieldType["Radio"] = 3] = "Radio";
        FieldType[FieldType["Sex"] = 4] = "Sex";
        FieldType[FieldType["Citizenship"] = 5] = "Citizenship";
        FieldType[FieldType["Human"] = 6] = "Human";
    })(FieldType || (FieldType = {}));
    function fillSex(li, touristField) {
        mainChain = mainChain.then(() => {
            var _a;
            let select = li.querySelector(touristField.htmlElementSelector);
            if (select) {
                let optionVal = (_a = touristField.value) === null || _a === void 0 ? void 0 : _a.toString().toUpperCase();
                let option = li.querySelector(`${touristField.htmlElementSelector} option[value="${optionVal}"]`);
                if (option) {
                    option.selected = true;
                    select.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`${touristField.htmlElementSelector} option[value="${optionVal}"] не нашелся`);
                }
            }
            else {
                console.log(`${touristField.htmlElementSelector} не нашлось`);
            }
        });
    }
    function fillText(li, touristField) {
        mainChain = mainChain.then(() => {
            const element = li.querySelector(touristField.htmlElementSelector);
            if (element && touristField.value) {
                element.value = touristField.value;
                element.dispatchEvent(new Event('change', { bubbles: true }));
                element.dispatchEvent(new Event('input', { bubbles: true }));
            }
        });
    }
    function fillDate(li, touristField) {
        mainChain = mainChain.then(() => {
            const element = li.querySelector(touristField.htmlElementSelector);
            if (element && touristField.value) {
                // @ts-ignore
                let datePickerInput = $(touristField.htmlElementSelector);
                // datePickerInput.datepicker({ dateFormat: 'dd/mm/yyyy' });
                datePickerInput.datepicker({ dateFormat: 'dd/mm/yyyy' }).datepicker('setDate', touristField.value);
                datePickerInput.datepicker('show');
                datePickerInput.datepicker('hide');
            }
        });
    }
    function fillCitizenship(li, touristField) {
        mainChain = mainChain.then(() => {
            let selectedHotels = countries.filter((h, i, arr) => {
                if (h.ru !== '' && touristField.value && touristField.value.toString().trim().toUpperCase() === h.ru.toUpperCase()) {
                    return true;
                }
            });
            if (selectedHotels.length > 0) {
                // @ts-ignore
                let option = document.querySelector(`${touristField.htmlElementSelector} option[value=${selectedHotels[0].value}]`);
                if (option) {
                    option.selected = true;
                    option.dispatchEvent(new Event('change', { bubbles: true }));
                }
                else {
                    console.log(`${touristField.htmlElementSelector} option[value=${selectedHotels[0].value}] не нашелся`);
                }
            }
        });
    }
    ;
    function handleTouristFields(li, touristFields) {
        touristFields.forEach(touristField => {
            switch (touristField.fieldType) {
                case FieldType.Sex:
                    fillSex(li, touristField);
                    break;
                case FieldType.Text:
                    fillText(li, touristField);
                    break;
                case FieldType.DatePicker:
                    fillDate(li, touristField);
                    break;
                case FieldType.Citizenship:
                    fillCitizenship(li, touristField);
                    break;
                default: break;
            }
            mainChain = mainChain.then(() => localWait(touristField.delay || 250, 0));
        });
    }
    ;
    var hTMLLIElements = document.querySelectorAll('ul#customer-list1 li.list-group-item');
    Array.prototype.forEach.call(hTMLLIElements, (hTMLLIElement, index) => {
        var _a, _b;
        let tourist = data.tourists[index];
        if (!tourist)
            return;
        let birthdayDate = new Date(tourist.birthday);
        let touristFields = [
            {
                htmlElementSelector: `select#slctCustomerTitle${index + 1}`,
                value: tourist.sex,
                fieldType: FieldType.Sex
            },
            {
                htmlElementSelector: `input#txtCustomerName${index + 1}`,
                value: `${tourist.surname} ${tourist.name} ${tourist.middlename ? tourist.middlename : ''}`,
                fieldType: FieldType.Text
            },
            {
                htmlElementSelector: `input#dpCustomerBirthDate${index + 1}`,
                value: new Date(tourist.birthday),
                fieldType: FieldType.DatePicker
            },
            {
                htmlElementSelector: `select#slctCustomerNationality${index + 1}`,
                value: tourist.citizenship,
                fieldType: FieldType.Citizenship
            },
            {
                htmlElementSelector: `input#txtCustomerPassportNo${index + 1}`,
                value: `${(_a = tourist.travelPassport) === null || _a === void 0 ? void 0 : _a.series}`,
                fieldType: FieldType.Text
            },
            {
                htmlElementSelector: `input#txtCustomerIdentityNo${index + 1}`,
                value: `${(_b = tourist.travelPassport) === null || _b === void 0 ? void 0 : _b.number}`,
                fieldType: FieldType.Text
            }
        ];
        handleTouristFields(hTMLLIElement, touristFields);
    });
    let countries = [
        {
            "value": "",
            "eng": "Nationality",
            "ru": ""
        },
        {
            "value": "AF",
            "eng": "AFGHANISTAN              ",
            "ru": "Афганистан"
        },
        {
            "value": "AX",
            "eng": "ALAND ISLANDS            ",
            "ru": ""
        },
        {
            "value": "AL",
            "eng": "ALBANIA",
            "ru": ""
        },
        {
            "value": "DZ",
            "eng": "ALGERIA",
            "ru": ""
        },
        {
            "value": "AD",
            "eng": "ANDORRA",
            "ru": ""
        },
        {
            "value": "AO",
            "eng": "ANGOLA                   ",
            "ru": ""
        },
        {
            "value": "AI",
            "eng": "ANGUILLA                 ",
            "ru": ""
        },
        {
            "value": "AG",
            "eng": "ANTIGUA AND BARBUDA      ",
            "ru": ""
        },
        {
            "value": "AR",
            "eng": "ARGENTINA                ",
            "ru": ""
        },
        {
            "value": "AM",
            "eng": "ARMENIA                  ",
            "ru": "Армения"
        },
        {
            "value": "AU",
            "eng": "AUSTRALIA",
            "ru": ""
        },
        {
            "value": "AT",
            "eng": "AUSTRIA",
            "ru": ""
        },
        {
            "value": "AZ",
            "eng": "AZERBAIJAN",
            "ru": "Азербайджан"
        },
        {
            "value": "BS",
            "eng": "BAHAMAS                  ",
            "ru": ""
        },
        {
            "value": "BH",
            "eng": "BAHRAIN",
            "ru": "Бахрейн"
        },
        {
            "value": "BD",
            "eng": "BANGLADESH",
            "ru": ""
        },
        {
            "value": "BB",
            "eng": "BARBADOS                 ",
            "ru": ""
        },
        {
            "value": "BY",
            "eng": "BELARUS",
            "ru": "Беларусь"
        },
        {
            "value": "BE",
            "eng": "BELGIUM",
            "ru": ""
        },
        {
            "value": "BZ",
            "eng": "BELIZE                   ",
            "ru": ""
        },
        {
            "value": "BJ",
            "eng": "BENIN                    ",
            "ru": ""
        },
        {
            "value": "BM",
            "eng": "BERMUDA                  ",
            "ru": ""
        },
        {
            "value": "BT",
            "eng": "BHUTAN                   ",
            "ru": ""
        },
        {
            "value": "BO",
            "eng": "BOLIVIA, PLURINATIONAL ST",
            "ru": ""
        },
        {
            "value": "BQ",
            "eng": "BONAIRE, SAINT EUSTATIUS ",
            "ru": ""
        },
        {
            "value": "BA",
            "eng": "BOSNIA AND HERZEGOVINA",
            "ru": ""
        },
        {
            "value": "BW",
            "eng": "BOTSWANA                 ",
            "ru": ""
        },
        {
            "value": "BV",
            "eng": "BOUVET ISLAND            ",
            "ru": ""
        },
        {
            "value": "BR",
            "eng": "BRAZIL",
            "ru": ""
        },
        {
            "value": "IO",
            "eng": "BRITISH INDIAN OCEAN TERR",
            "ru": ""
        },
        {
            "value": "BN",
            "eng": "BRUNEI DARUSSALAM        ",
            "ru": ""
        },
        {
            "value": "BG",
            "eng": "BULGARIA",
            "ru": ""
        },
        {
            "value": "BF",
            "eng": "BURKINA FASO             ",
            "ru": ""
        },
        {
            "value": "BI",
            "eng": "BURUNDI                  ",
            "ru": ""
        },
        {
            "value": "KH",
            "eng": "CAMBODIA                 ",
            "ru": ""
        },
        {
            "value": "CM",
            "eng": "CAMEROON                 ",
            "ru": ""
        },
        {
            "value": "CA",
            "eng": "CANADA",
            "ru": "Канада"
        },
        {
            "value": "CV",
            "eng": "CAPE VERDE               ",
            "ru": ""
        },
        {
            "value": "KY",
            "eng": "CAYMAN ISLANDS           ",
            "ru": ""
        },
        {
            "value": "CF",
            "eng": "CENTRAL AFRICAN REPUBLIC ",
            "ru": ""
        },
        {
            "value": "TD",
            "eng": "CHAD                     ",
            "ru": ""
        },
        {
            "value": "CL",
            "eng": "CHILE                    ",
            "ru": ""
        },
        {
            "value": "CN",
            "eng": "CHINA",
            "ru": "Китай"
        },
        {
            "value": "CX",
            "eng": "CHRISTMAS ISLAND         ",
            "ru": ""
        },
        {
            "value": "CC",
            "eng": "COCOS (KEELING) ISLANDS  ",
            "ru": ""
        },
        {
            "value": "CO",
            "eng": "COLOMBIA                 ",
            "ru": ""
        },
        {
            "value": "KM",
            "eng": "COMOROS                  ",
            "ru": ""
        },
        {
            "value": "CG",
            "eng": "CONGO                    ",
            "ru": ""
        },
        {
            "value": "CD",
            "eng": "CONGO, THE DEMOCRATIC REP",
            "ru": ""
        },
        {
            "value": "CK",
            "eng": "COOK ISLANDS             ",
            "ru": ""
        },
        {
            "value": "CR",
            "eng": "COSTA RICA               ",
            "ru": ""
        },
        {
            "value": "HR",
            "eng": "CROATIA",
            "ru": ""
        },
        {
            "value": "CU",
            "eng": "CUBA",
            "ru": ""
        },
        {
            "value": "CW",
            "eng": "CURACAO                  ",
            "ru": ""
        },
        {
            "value": "CY",
            "eng": "CYPRUS",
            "ru": ""
        },
        {
            "value": "CZ",
            "eng": "CZECH REPUBLIC",
            "ru": ""
        },
        {
            "value": "DK",
            "eng": "DENMARK",
            "ru": ""
        },
        {
            "value": "DJ",
            "eng": "DJIBOUTI                 ",
            "ru": ""
        },
        {
            "value": "DM",
            "eng": "DOMINICA                 ",
            "ru": ""
        },
        {
            "value": "DO",
            "eng": "DOMINICAN REPUBLIC       ",
            "ru": ""
        },
        {
            "value": "EC",
            "eng": "ECUADOR",
            "ru": ""
        },
        {
            "value": "EG",
            "eng": "EGYPT",
            "ru": "Египет"
        },
        {
            "value": "SV",
            "eng": "EL SALVADOR              ",
            "ru": ""
        },
        {
            "value": "GQ",
            "eng": "EQUATORIAL GUINEA        ",
            "ru": ""
        },
        {
            "value": "ER",
            "eng": "ERITREA                  ",
            "ru": ""
        },
        {
            "value": "EE",
            "eng": "ESTONIA",
            "ru": "Эстония"
        },
        {
            "value": "ET",
            "eng": "ETHIOPIA                 ",
            "ru": ""
        },
        {
            "value": "EU",
            "eng": "EUROPE",
            "ru": ""
        },
        {
            "value": "FK",
            "eng": "FALKLAND ISLANDS (MALVINA",
            "ru": ""
        },
        {
            "value": "FO",
            "eng": "FAROE ISLANDS            ",
            "ru": ""
        },
        {
            "value": "FJ",
            "eng": "FIJI                     ",
            "ru": ""
        },
        {
            "value": "FI",
            "eng": "FINLAND",
            "ru": "Финляндия"
        },
        {
            "value": "FR",
            "eng": "FRANCE",
            "ru": "Франция"
        },
        {
            "value": "GF",
            "eng": "FRENCH GUIANA            ",
            "ru": ""
        },
        {
            "value": "PF",
            "eng": "FRENCH POLYNESIA         ",
            "ru": ""
        },
        {
            "value": "TF",
            "eng": "FRENCH SOUTHERN TERRITORI",
            "ru": ""
        },
        {
            "value": "GA",
            "eng": "GABON                    ",
            "ru": ""
        },
        {
            "value": "GM",
            "eng": "GAMBIA                   ",
            "ru": ""
        },
        {
            "value": "GE",
            "eng": "GEORGIA",
            "ru": "Грузия"
        },
        {
            "value": "DE",
            "eng": "GERMANY",
            "ru": "Германия"
        },
        {
            "value": "GH",
            "eng": "GHANA                    ",
            "ru": ""
        },
        {
            "value": "GI",
            "eng": "GIBRALTAR                ",
            "ru": ""
        },
        {
            "value": "GR",
            "eng": "GREECE",
            "ru": ""
        },
        {
            "value": "GL",
            "eng": "GREENLAND                ",
            "ru": ""
        },
        {
            "value": "GD",
            "eng": "GRENADA                  ",
            "ru": ""
        },
        {
            "value": "GP",
            "eng": "GUADELOUPE               ",
            "ru": ""
        },
        {
            "value": "GU",
            "eng": "GUAM                     ",
            "ru": ""
        },
        {
            "value": "GT",
            "eng": "GUATEMALA                ",
            "ru": "Гватемала"
        },
        {
            "value": "GG",
            "eng": "GUERNSEY                 ",
            "ru": ""
        },
        {
            "value": "GN",
            "eng": "GUINEA                   ",
            "ru": ""
        },
        {
            "value": "GW",
            "eng": "GUINEA-BISSAU            ",
            "ru": ""
        },
        {
            "value": "GY",
            "eng": "GUYANA                   ",
            "ru": ""
        },
        {
            "value": "HT",
            "eng": "HAITI                    ",
            "ru": ""
        },
        {
            "value": "HM",
            "eng": "HEARD ISLAND AND MCDONALD",
            "ru": ""
        },
        {
            "value": "VA",
            "eng": "HOLY SEE (VATICAN CITY ST",
            "ru": ""
        },
        {
            "value": "HN",
            "eng": "HONDURAS                 ",
            "ru": ""
        },
        {
            "value": "HK",
            "eng": "HONG KONG                ",
            "ru": ""
        },
        {
            "value": "HU",
            "eng": "HUNGARY",
            "ru": ""
        },
        {
            "value": "IS",
            "eng": "ICELAND",
            "ru": ""
        },
        {
            "value": "IN",
            "eng": "INDIA",
            "ru": "Индия"
        },
        {
            "value": "ID",
            "eng": "INDONESIA                ",
            "ru": "Индонезия"
        },
        {
            "value": "IR",
            "eng": "IRAN",
            "ru": "Иран"
        },
        {
            "value": "IQ",
            "eng": "IRAQ",
            "ru": ""
        },
        {
            "value": "IE",
            "eng": "IRELAND",
            "ru": "Ирландия"
        },
        {
            "value": "IM",
            "eng": "ISLE OF MAN              ",
            "ru": ""
        },
        {
            "value": "IL",
            "eng": "ISRAEL",
            "ru": "Израиль"
        },
        {
            "value": "IT",
            "eng": "ITALY",
            "ru": "Италия"
        },
        {
            "value": "CI",
            "eng": "IVORY COAST",
            "ru": ""
        },
        {
            "value": "JM",
            "eng": "JAMAICA                  ",
            "ru": ""
        },
        {
            "value": "JP",
            "eng": "JAPAN",
            "ru": "Япония"
        },
        {
            "value": "JE",
            "eng": "JERSEY                   ",
            "ru": ""
        },
        {
            "value": "JO",
            "eng": "JORDAN",
            "ru": "Иордания"
        },
        {
            "value": "KZ",
            "eng": "KAZAKHSTAN",
            "ru": "Казахстан"
        },
        {
            "value": "KE",
            "eng": "KENYA                    ",
            "ru": ""
        },
        {
            "value": "KI",
            "eng": "KIRIBATI                 ",
            "ru": ""
        },
        {
            "value": "KR",
            "eng": "KOREA",
            "ru": ""
        },
        {
            "value": "KP",
            "eng": "KOREA, DEMOCRATIC PEOPLE'",
            "ru": ""
        },
        {
            "value": "KS",
            "eng": "KOSOVA",
            "ru": ""
        },
        {
            "value": "XK",
            "eng": "KOSOVO",
            "ru": ""
        },
        {
            "value": "KW",
            "eng": "KUWAIT",
            "ru": ""
        },
        {
            "value": "KG",
            "eng": "KYRGYZSTAN",
            "ru": "Киргизия"
        },
        {
            "value": "LA",
            "eng": "LAO PEOPLE'S DEMOCRATIC R",
            "ru": ""
        },
        {
            "value": "LV",
            "eng": "LATVIA",
            "ru": "Латвия"
        },
        {
            "value": "LB",
            "eng": "LEBANON",
            "ru": ""
        },
        {
            "value": "LS",
            "eng": "LESOTHO                  ",
            "ru": ""
        },
        {
            "value": "LR",
            "eng": "LIBERIA                  ",
            "ru": ""
        },
        {
            "value": "LY",
            "eng": "LIBYA",
            "ru": ""
        },
        {
            "value": "LI",
            "eng": "LIECHTENSTEIN            ",
            "ru": ""
        },
        {
            "value": "LT",
            "eng": "LITHUANIA",
            "ru": "Литва"
        },
        {
            "value": "LU",
            "eng": "LUXEMBOURG",
            "ru": ""
        },
        {
            "value": "MO",
            "eng": "MACAO                    ",
            "ru": ""
        },
        {
            "value": "MK",
            "eng": "MACEDONIA",
            "ru": "Македония"
        },
        {
            "value": "MG",
            "eng": "MADAGASCAR               ",
            "ru": ""
        },
        {
            "value": "MW",
            "eng": "MALAWI                   ",
            "ru": ""
        },
        {
            "value": "MY",
            "eng": "MALAYSIA",
            "ru": ""
        },
        {
            "value": "MV",
            "eng": "MALDIVES                 ",
            "ru": ""
        },
        {
            "value": "ML",
            "eng": "MALI                     ",
            "ru": ""
        },
        {
            "value": "MT",
            "eng": "MALTA",
            "ru": ""
        },
        {
            "value": "MH",
            "eng": "MARSHALL ISLANDS         ",
            "ru": ""
        },
        {
            "value": "MQ",
            "eng": "MARTINIQUE               ",
            "ru": ""
        },
        {
            "value": "MR",
            "eng": "MAURITANIA               ",
            "ru": ""
        },
        {
            "value": "MU",
            "eng": "MAURITIUS",
            "ru": ""
        },
        {
            "value": "YT",
            "eng": "MAYOTTE                  ",
            "ru": ""
        },
        {
            "value": "AS",
            "eng": "MERICAN SAMOA            ",
            "ru": ""
        },
        {
            "value": "MX",
            "eng": "MEXICO                   ",
            "ru": ""
        },
        {
            "value": "FM",
            "eng": "MICRONESIA, FEDERATED STA",
            "ru": ""
        },
        {
            "value": "MD",
            "eng": "MOLDOVA",
            "ru": "Молдова"
        },
        {
            "value": "MC",
            "eng": "MONACO                   ",
            "ru": ""
        },
        {
            "value": "MN",
            "eng": "MONGOLIA                 ",
            "ru": "Монголия"
        },
        {
            "value": "ME",
            "eng": "MONTENEGRO",
            "ru": ""
        },
        {
            "value": "MS",
            "eng": "MONTSERRAT               ",
            "ru": ""
        },
        {
            "value": "MA",
            "eng": "MOROCCO",
            "ru": ""
        },
        {
            "value": "MZ",
            "eng": "MOZAMBIQUE               ",
            "ru": ""
        },
        {
            "value": "MM",
            "eng": "MYANMAR                  ",
            "ru": ""
        },
        {
            "value": "NA",
            "eng": "NAMIBIA                  ",
            "ru": ""
        },
        {
            "value": "NR",
            "eng": "NAURU                    ",
            "ru": ""
        },
        {
            "value": "NP",
            "eng": "NEPAL                    ",
            "ru": ""
        },
        {
            "value": "NL",
            "eng": "NETHERLANDS",
            "ru": ""
        },
        {
            "value": "NC",
            "eng": "NEW CALEDONIA            ",
            "ru": ""
        },
        {
            "value": "NZ",
            "eng": "NEW ZEALAND              ",
            "ru": ""
        },
        {
            "value": "NI",
            "eng": "NICARAGUA                ",
            "ru": ""
        },
        {
            "value": "NE",
            "eng": "NIGER                    ",
            "ru": ""
        },
        {
            "value": "NG",
            "eng": "NIGERIA",
            "ru": ""
        },
        {
            "value": "NU",
            "eng": "NIUE                     ",
            "ru": ""
        },
        {
            "value": "NF",
            "eng": "NORFOLK ISLAND           ",
            "ru": ""
        },
        {
            "value": "NY",
            "eng": "NORTHERN CYPRUS",
            "ru": ""
        },
        {
            "value": "MP",
            "eng": "NORTHERN MARIANA ISLANDS ",
            "ru": ""
        },
        {
            "value": "NO",
            "eng": "NORWAY                   ",
            "ru": ""
        },
        {
            "value": "AQ",
            "eng": "NTARCTICA                ",
            "ru": ""
        },
        {
            "value": "OM",
            "eng": "OMAN                     ",
            "ru": ""
        },
        {
            "value": "OTH",
            "eng": "OTHERS",
            "ru": ""
        },
        {
            "value": "PK",
            "eng": "PAKISTAN",
            "ru": "Пакистан"
        },
        {
            "value": "PW",
            "eng": "PALAU                    ",
            "ru": ""
        },
        {
            "value": "PS",
            "eng": "PALESTINE",
            "ru": ""
        },
        {
            "value": "PA",
            "eng": "PANAMA                   ",
            "ru": ""
        },
        {
            "value": "PG",
            "eng": "PAPUA NEW GUINEA         ",
            "ru": ""
        },
        {
            "value": "PY",
            "eng": "PARAGUAY                 ",
            "ru": ""
        },
        {
            "value": "PE",
            "eng": "PERU                     ",
            "ru": ""
        },
        {
            "value": "PH",
            "eng": "PHILIPPINES              ",
            "ru": "Филиппины"
        },
        {
            "value": "PN",
            "eng": "PITCAIRN                 ",
            "ru": ""
        },
        {
            "value": "PL",
            "eng": "POLAND",
            "ru": "Польша"
        },
        {
            "value": "PT",
            "eng": "PORTUGAL",
            "ru": ""
        },
        {
            "value": "PR",
            "eng": "PUERTO RICO              ",
            "ru": ""
        },
        {
            "value": "QA",
            "eng": "QATAR",
            "ru": ""
        },
        {
            "value": "RE",
            "eng": "REUNION",
            "ru": ""
        },
        {
            "value": "RO",
            "eng": "ROMANIA",
            "ru": "Румыния"
        },
        {
            "value": "AW",
            "eng": "RUBA                     ",
            "ru": ""
        },
        {
            "value": "RU",
            "eng": "RUSSIA",
            "ru": "Россия"
        },
        {
            "value": "RW",
            "eng": "RWANDA                   ",
            "ru": ""
        },
        {
            "value": "BL",
            "eng": "SAINT BARTHELEMY         ",
            "ru": ""
        },
        {
            "value": "SH",
            "eng": "SAINT HELENA, ASCENSION A",
            "ru": ""
        },
        {
            "value": "KN",
            "eng": "SAINT KITTS AND NEVIS    ",
            "ru": "Сент-Китс и Невис"
        },
        {
            "value": "LC",
            "eng": "SAINT LUCIA              ",
            "ru": ""
        },
        {
            "value": "MF",
            "eng": "SAINT MARTIN (FRENCH PART",
            "ru": ""
        },
        {
            "value": "PM",
            "eng": "SAINT PIERRE AND MIQUELON",
            "ru": ""
        },
        {
            "value": "VC",
            "eng": "SAINT VINCENT AND THE GRE",
            "ru": ""
        },
        {
            "value": "WS",
            "eng": "SAMOA                    ",
            "ru": ""
        },
        {
            "value": "SM",
            "eng": "SAN MARINO               ",
            "ru": ""
        },
        {
            "value": "ST",
            "eng": "SAO TOME AND PRINCIPE    ",
            "ru": ""
        },
        {
            "value": "SA",
            "eng": "SAUDI ARABIA",
            "ru": "Саудовская Аравия"
        },
        {
            "value": "SN",
            "eng": "SENEGAL                  ",
            "ru": ""
        },
        {
            "value": "RS",
            "eng": "SERBIA",
            "ru": "Сербия"
        },
        {
            "value": "SC",
            "eng": "SEYCHELLES               ",
            "ru": ""
        },
        {
            "value": "SL",
            "eng": "SIERRA LEONE",
            "ru": ""
        },
        {
            "value": "SG",
            "eng": "SINGAPORE                ",
            "ru": ""
        },
        {
            "value": "SX",
            "eng": "SINT MAARTEN (DUTCH PART)",
            "ru": ""
        },
        {
            "value": "SK",
            "eng": "SLOVAKIA",
            "ru": "Славакия"
        },
        {
            "value": "SI",
            "eng": "SLOVENIA",
            "ru": ""
        },
        {
            "value": "SB",
            "eng": "SOLOMON ISLANDS          ",
            "ru": ""
        },
        {
            "value": "SO",
            "eng": "SOMALIA                  ",
            "ru": ""
        },
        {
            "value": "ZA",
            "eng": "SOUTH AFRICA",
            "ru": "ЮАР"
        },
        {
            "value": "GS",
            "eng": "SOUTH GEORGIA AND THE SOU",
            "ru": ""
        },
        {
            "value": "ES",
            "eng": "SPAIN",
            "ru": "Испания"
        },
        {
            "value": "LK",
            "eng": "SRI LANKA                ",
            "ru": ""
        },
        {
            "value": "SD",
            "eng": "SUDAN",
            "ru": ""
        },
        {
            "value": "SR",
            "eng": "SURINAME",
            "ru": ""
        },
        {
            "value": "SJ",
            "eng": "SVALBARD AND JAN MAYEN   ",
            "ru": ""
        },
        {
            "value": "SZ",
            "eng": "SWAZILAND                ",
            "ru": ""
        },
        {
            "value": "SE",
            "eng": "SWEDEN",
            "ru": "Швеция"
        },
        {
            "value": "CH",
            "eng": "SWITZERLAND",
            "ru": ""
        },
        {
            "value": "SY",
            "eng": "SYRIAN ARAB REPUBLIC     ",
            "ru": ""
        },
        {
            "value": "TW",
            "eng": "TAIWAN, PROVINCE OF CHINA",
            "ru": ""
        },
        {
            "value": "TJ",
            "eng": "TAJIKISTAN",
            "ru": "Таджикистан"
        },
        {
            "value": "TZ",
            "eng": "TANZANIA, UNITED REPUBLIC",
            "ru": ""
        },
        {
            "value": "TH",
            "eng": "THAILAND",
            "ru": ""
        },
        {
            "value": "TL",
            "eng": "TIMOR-LESTE              ",
            "ru": ""
        },
        {
            "value": "TG",
            "eng": "TOGO                     ",
            "ru": ""
        },
        {
            "value": "TK",
            "eng": "TOKELAU                  ",
            "ru": ""
        },
        {
            "value": "TO",
            "eng": "TONGA                    ",
            "ru": ""
        },
        {
            "value": "TT",
            "eng": "TRINIDAD AND TOBAGO      ",
            "ru": ""
        },
        {
            "value": "TN",
            "eng": "TUNISIA",
            "ru": "Тунис"
        },
        {
            "value": "TR",
            "eng": "TURKEY",
            "ru": "Турция"
        },
        {
            "value": "TM",
            "eng": "TURKMENISTAN",
            "ru": "Туркменистан"
        },
        {
            "value": "TC",
            "eng": "TURKS AND CAICOS ISLANDS",
            "ru": ""
        },
        {
            "value": "TV",
            "eng": "TUVALU                   ",
            "ru": ""
        },
        {
            "value": "UG",
            "eng": "UGANDA                   ",
            "ru": ""
        },
        {
            "value": "UA",
            "eng": "UKRAINE",
            "ru": "Украина"
        },
        {
            "value": "AE",
            "eng": "UNITED ARAB EMIRATES",
            "ru": "ОАЭ"
        },
        {
            "value": "GB",
            "eng": "UNITED KINGDOM",
            "ru": ""
        },
        {
            "value": "UM",
            "eng": "UNITED STATES MINOR OUTLY",
            "ru": ""
        },
        {
            "value": "US",
            "eng": "UNITED STATES OF AMERICA",
            "ru": "США"
        },
        {
            "value": "UY",
            "eng": "URUGUAY                  ",
            "ru": ""
        },
        {
            "value": "RU2",
            "eng": "USSR",
            "ru": ""
        },
        {
            "value": "UZ",
            "eng": "UZBEKISTAN",
            "ru": "Узбекистан"
        },
        {
            "value": "VU",
            "eng": "VANUATU                  ",
            "ru": ""
        },
        {
            "value": "VE",
            "eng": "VENEZUELA",
            "ru": ""
        },
        {
            "value": "VN",
            "eng": "VIET NAM                 ",
            "ru": ""
        },
        {
            "value": "VG",
            "eng": "VIRGIN ISLANDS, BRITISH  ",
            "ru": ""
        },
        {
            "value": "VI",
            "eng": "VIRGIN ISLANDS, U.S.     ",
            "ru": ""
        },
        {
            "value": "WF",
            "eng": "WALLIS AND FUTUNA        ",
            "ru": ""
        },
        {
            "value": "EH",
            "eng": "WESTERN SAHARA           ",
            "ru": ""
        },
        {
            "value": "YE",
            "eng": "YEMEN                    ",
            "ru": ""
        },
        {
            "value": "ZM",
            "eng": "ZAMBIA                   ",
            "ru": "Замбия"
        },
        {
            "value": "ZW",
            "eng": "ZIMBABWE                 ",
            "ru": ""
        }
    ];
}


/***/ },

/***/ "./src/serverScripts/operators/aquaTravel.ts"
/*!***************************************************!*\
  !*** ./src/serverScripts/operators/aquaTravel.ts ***!
  \***************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AquaTravel: () => (/* binding */ AquaTravel)
/* harmony export */ });
const AquaTravel = {
    link: (operatorClaimId) => 'https://online.aqua-travelgroup.com',
    title: 'Aqua Travel',
    authType: 'forms',
    claimUrlAuthType: 'forms',
    packet: {
        loginPath: "input#txtUserCode",
        passwordPath: "input#txtPass",
        submitPath: "input#BtnLogin"
    },
    selectors: {},
    cookie: {
        auth: ['ASP.NET_SessionId']
    }
};


/***/ },

/***/ "./src/serverScripts/operators/fitHolidays.ts"
/*!****************************************************!*\
  !*** ./src/serverScripts/operators/fitHolidays.ts ***!
  \****************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   FitHolidays: () => (/* binding */ FitHolidays)
/* harmony export */ });
const FitHolidays = {
    link: (operatorClaimId) => 'https://b2b.fitholidays.com',
    title: 'Fit Holidays',
    authType: 'forms',
    claimUrlAuthType: 'forms',
    packet: {
        loginPath: "form#frmLogin input#txtUserCode",
        passwordPath: "form#frmLogin input#txtPassword",
        submitPath: "form#frmLogin button#btnLogin"
    },
    selectors: {},
    cookie: {
        auth: ['ASP.NET_SessionId']
    }
};


/***/ },

/***/ "./src/serverScripts/operators/peninsula.ts"
/*!**************************************************!*\
  !*** ./src/serverScripts/operators/peninsula.ts ***!
  \**************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   Peninsula: () => (/* binding */ Peninsula)
/* harmony export */ });
const Peninsula = {
    link: (operatorClaimId) => 'http://b2b.peninsula.com.tr',
    title: 'Peninsula Tours',
    authType: 'forms',
    claimUrlAuthType: 'forms',
    packet: {
        loginPath: "form#frmLogin input#txtUserCode",
        passwordPath: "form#frmLogin input#txtPassword",
        submitPath: "form#frmLogin button#btnLogin"
    },
    selectors: {},
    cookie: {
        auth: ['ASP.NET_SessionId']
    }
};


/***/ }

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		if (!(moduleId in __webpack_modules__)) {
/******/ 			delete __webpack_module_cache__[moduleId];
/******/ 			var e = new Error("Cannot find module '" + moduleId + "'");
/******/ 			e.code = 'MODULE_NOT_FOUND';
/******/ 			throw e;
/******/ 		}
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	(() => {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = (exports) => {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	})();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
/*!*************************************!*\
  !*** ./src/app/backgroundWorker.ts ***!
  \*************************************/
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   fillVisaFormsInCurrentTab: () => (/* binding */ fillVisaFormsInCurrentTab),
/* harmony export */   navigateToClaimPaymentTransferForm: () => (/* binding */ navigateToClaimPaymentTransferForm),
/* harmony export */   navigateToClaimRefundTransgerForm: () => (/* binding */ navigateToClaimRefundTransgerForm)
/* harmony export */ });
/* harmony import */ var _messages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./messages */ "./src/app/messages/index.ts");
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./models */ "./src/app/models/index.ts");
/* harmony import */ var _operators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./operators */ "./src/app/operators.ts");
/* harmony import */ var _services_chunks_getFillerDataByClaimId__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./services/chunks/getFillerDataByClaimId */ "./src/app/services/chunks/getFillerDataByClaimId.ts");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ "./src/app/utils/index.ts");
/* harmony import */ var _utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils/chunks/createPushNotification */ "./src/app/utils/chunks/createPushNotification.ts");
/* harmony import */ var _utils_fillCBLegalEntities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils/fillCBLegalEntities */ "./src/app/utils/fillCBLegalEntities.ts");
/* harmony import */ var _utils_parseDateString__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils/parseDateString */ "./src/app/utils/parseDateString.ts");
/* harmony import */ var _utils_performTOAuth__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils/performTOAuth */ "./src/app/utils/performTOAuth.ts");
/* harmony import */ var _utils_navigateToFormFill__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils/navigateToFormFill */ "./src/app/utils/navigateToFormFill.ts");
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};










(0,_utils__WEBPACK_IMPORTED_MODULE_4__.addMessageListener)((request, sender, sendResponse) => __awaiter(void 0, void 0, void 0, function* () {
    const messageSender = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.detectSender)(sender);
    const operator = _operators__WEBPACK_IMPORTED_MODULE_2__.OPERATORS[request.payload.sourceId];
    //const dateFormat = 'DD.MM.YYYY';
    const defaultDate = '01.01.1900';
    const orderFunc = (t1, t2) => (0,_utils_parseDateString__WEBPACK_IMPORTED_MODULE_7__.parseDateString)(t1.birthday || defaultDate).getTime() -
        (0,_utils_parseDateString__WEBPACK_IMPORTED_MODULE_7__.parseDateString)(t2.birthday || defaultDate).getTime();
    if (request.payload.senderElementId === 'fillCbLe') {
        (0,_utils_fillCBLegalEntities__WEBPACK_IMPORTED_MODULE_6__.fillCBLegalEntities)(request.payload.additionalInfo);
    }
    if (request.payload.senderElementId === 'authBt') {
        return yield (0,_utils_performTOAuth__WEBPACK_IMPORTED_MODULE_8__.performTOAuth)(request.payload.sourceId, request.payload.additionalInfo);
    }
    else {
        switch (messageSender) {
            case _models__WEBPACK_IMPORTED_MODULE_1__.SenderTypes.TAB_SENDER: break;
            // switch (request.payload.senderElementId) {}
            // break;
            case _models__WEBPACK_IMPORTED_MODULE_1__.SenderTypes.EXT_SENDER:
                return (0,_services_chunks_getFillerDataByClaimId__WEBPACK_IMPORTED_MODULE_3__.getFillerDataByClaimId)(request.payload.inputClaimId)
                    .then((data) => {
                    data.autoFillerData.touristDataItems = data.autoFillerData.touristDataItems
                        ? data.autoFillerData.touristDataItems.sort(orderFunc)
                        : data.autoFillerData.touristDataItems;
                    switch (request.payload.senderElementId) {
                        case 'transferBt':
                            return (0,_utils_navigateToFormFill__WEBPACK_IMPORTED_MODULE_9__.navigateToFormFill)({
                                tourUrl: data.autoFillerData.tourUrl,
                                claimId: request.payload.claimId,
                                sourceId: request.payload.sourceId,
                                claimNumber: data.claimNumber,
                                secretField: request.payload.secretField
                            }, data)
                                // .then(() => {
                                //     return createPushNotification(
                                //         {
                                //             claimId: request.payload.claimNumber as string,
                                //             operator,
                                //             errorText: null
                                //         }
                                //     );
                                // })
                                .catch((message) => {
                                console.log(message);
                                return (0,_utils_chunks_createPushNotification__WEBPACK_IMPORTED_MODULE_5__.createPushNotification)({
                                    claimId: request.payload.claimNumber,
                                    operator,
                                    errorText: message.error
                                });
                            });
                        case 'visafillBt':
                        // data.autoFillerData = mockFillerData.autoFillerData;
                        // return fillVisaFormsInCurrentTab(
                        //     {
                        //         tourUrl: data.autoFillerData.tourUrl,
                        //         claimId: (request.payload.claimId as string),
                        //         sourceId: request.payload.sourceId,
                        //         claimNumber: request.payload.claimNumber as string,
                        //         secretField: request.payload.secretField
                        //     }, data
                        // );
                        default: break;
                    }
                })
                    .catch((error) => {
                    return (0,_utils__WEBPACK_IMPORTED_MODULE_4__.sendMessage)((0,_messages__WEBPACK_IMPORTED_MODULE_0__.createErrorMessage)(error.message));
                });
        }
    }
}));
function fillVisaFormsInCurrentTab({ tourUrl, claimId, sourceId, claimNumber, secretField }, data) {
    // return getScriptFromApi(sourceId, ScriptType.VisaFill)
    //     .then((script: IScript | null) => {
    //         /************************************************/
    //         let execError: any = null;
    //         const visaFillArgs: IVisaFillArgs = {
    //             data: data,
    //             claimNumber: claimNumber,
    //             sourceId: sourceId
    //         };
    //         // ----------------------------------------------
    //         // для тестирования
    //         // try {
    //         //     visaFillScript(visaFillArgs);
    //         // } catch (error) {
    //         //     console.dir(error);
    //         //     execError = error;
    //         // }
    //         // ----------------------------------------------
    //         // ----------------------------------------------
    //         // боевой
    //         if (script && script.body) {
    //             const visaFill = new Function('visaFillArgs', script.body);
    //             try {
    //                 visaFill(visaFillArgs);
    //             } catch (error) {
    //                 // createPushNotification({
    //                 //     title: 'Провальный провал',
    //                 //     notificationMessage: 'При выполнении серверного скрипта произошла ошибка'
    //                 // });
    //                 console.log('Провальный провал VisaFill');
    //                 console.dir(error);
    //                 execError = error;
    //             }
    //         } else {
    //             console.log(`Скрипт типа VisaFill для sletaId = ${sourceId} не был обнаружен`);
    //             execError = 'Печалька, нет скрипта';
    //         }
    //         // ----------------------------------------------
    //         if (!execError) {
    //             // createPushNotification({
    //             //     title: 'Успешный успех',
    //             //     notificationMessage: 'Выполнено при помощи серверного скрипта'
    //             // });
    //             throw new Error('Выполнено при помощи серверного скрипта');
    //         }
    //         /************************************************/
    //         return Promise.resolve();
    //     })
    //     .then(() => {
    //         // chrome.tabs.query({active: true, currentWindow: true}, (tabs: chrome.tabs.Tab[]) => {
    //         //     const currentTab = tabs[0];
    //         //     switch (sourceId) {
    //         //         case 3:
    //         //             return pegasVisa(currentTab, data , claimNumber, sourceId);
    //         //         case 6:
    //         //             return coralVisa(currentTab, data.autoFillerData, claimNumber, sourceId);
    //         //         case 7:
    //         //             return bgVisa(currentTab, data, claimNumber, sourceId);
    //         //         case 9:
    //         //             return intVisa(currentTab, data.autoFillerData, claimNumber, sourceId);
    //         //         case 19:
    //         //             return anexVisa(currentTab, data, claimNumber, sourceId);
    //         //         case 20:
    //         //             return icsVisa(currentTab, data.autoFillerData, claimNumber, sourceId);
    //         //         case 51:
    //         //             return ambotisVisa(currentTab, data.autoFillerData, claimNumber, sourceId);
    //         //         case 54:
    //         //             return coralVisa(currentTab, data.autoFillerData, claimNumber, sourceId);
    //         //         case 171:
    //         //             return amigosVisa(currentTab, data.autoFillerData, claimNumber, sourceId);
    //         //         case 380:
    //         //             return tuiVisa(currentTab, data.autoFillerData, claimNumber, sourceId);
    //         //         default: break;
    //         //     }
    //         // });
    //     });
}
const navigateToClaimRefundTransgerForm = ({ tourUrl, claimId, sourceId, claimNumber, secretField }, Creditans, claimRefundDetails) => new Promise(resolve => {
    // const operator = OPERATORS[sourceId];
    // return createTabAndDeleteCookies(operator, tourUrl, Creditans)
    //     .then((data: {tab: chrome.tabs.Tab, navigate_url: string}) => {
    //         switch (sourceId) {
    //             case 9:  return intClaimRefund(data.tab, claimId, sourceId, data.navigate_url, claimRefundDetails);
    //         }
    //     });
});
const navigateToClaimPaymentTransferForm = ({ tourUrl, claimId, sourceId, claimNumber, secretField }, Creditans, claimTransferDetails) => new Promise(resolve => {
    const operator = _operators__WEBPACK_IMPORTED_MODULE_2__.OPERATORS[sourceId];
    // return createTabAndDeleteCookies(operator, tourUrl, Creditans)
    //     .then((data: {tab: chrome.tabs.Tab, navigate_url: string}) => {
    //         switch (sourceId) {
    //             case 9: return intClaimTransfer(data.tab, claimId, sourceId, data.navigate_url, claimTransferDetails);
    //         }
    //     });
});

})();

/******/ })()
;
//# sourceMappingURL=backgroundWorker.js.map