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

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

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   handleContentScriptExecutionRequest: () => (/* binding */ handleContentScriptExecutionRequest)
/* harmony export */ });
function handleContentScriptExecutionRequest(scriptKey, response) {
    switch (scriptKey) {
        // case 'peninsulaSearch': {
        //     peninsulaSearch(response);
        //     break;
        // }
        // case 'sunmarFill': {
        //     contentSunmarFill(response);
        //     break;
        // }
        // case 'amigoToursFill': {
        //     amigoToursContentFill(response);
        // }
        default: break;
    }
}


/***/ },

/***/ "./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/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/utils/chunks/common/clientUtils.ts"
/*!****************************************************!*\
  !*** ./src/app/utils/chunks/common/clientUtils.ts ***!
  \****************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   wait: () => (/* binding */ wait)
/* harmony export */ });
// тут будут лежать полезные скрипты, которые нужно копировать при добавлении кода на сайте ТО
function getTouristAge(tourist) {
    const [day, month, year] = tourist.birthday.split('.');
    const ageDiffMs = Date.now() - new Date(parseInt(year, 10), parseInt(month, 10), parseInt(day, 10)).getTime();
    const ageDate = new Date(ageDiffMs);
    return ageDate.getUTCFullYear() - 1970;
}
function wait(timeout) {
    return new Promise((resolve) => {
        setTimeout(() => resolve(), timeout);
    });
}


/***/ },

/***/ "./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/goToClaimOperatorType.ts"
/*!*******************************************************!*\
  !*** ./src/app/utils/chunks/goToClaimOperatorType.ts ***!
  \*******************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GoToClaimOperatorType: () => (/* binding */ GoToClaimOperatorType)
/* harmony export */ });
var GoToClaimOperatorType;
(function (GoToClaimOperatorType) {
    GoToClaimOperatorType[GoToClaimOperatorType["Base"] = 0] = "Base";
    GoToClaimOperatorType[GoToClaimOperatorType["Another"] = 1] = "Another";
    GoToClaimOperatorType[GoToClaimOperatorType["Accomodation"] = 2] = "Accomodation";
    GoToClaimOperatorType[GoToClaimOperatorType["Flight"] = 3] = "Flight";
})(GoToClaimOperatorType || (GoToClaimOperatorType = {}));


/***/ },

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

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   makeOperatorSenderButton: () => (/* binding */ makeOperatorSenderButton)
/* harmony export */ });
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../models */ "./src/app/models/index.ts");
/* harmony import */ var _operators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../operators */ "./src/app/operators.ts");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../constants */ "./src/app/utils/constants.ts");
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../dom */ "./src/app/utils/dom.ts");




const getErrorType = (claimIdTO, sourceId) => {
    if (!sourceId || !sourceId.length) {
        return _models__WEBPACK_IMPORTED_MODULE_0__.ErrorTypes.NO_TO_ID;
    }
    if (!claimIdTO || !claimIdTO.length) {
        return _models__WEBPACK_IMPORTED_MODULE_0__.ErrorTypes.NO_CLAIM_ID;
    }
    if (sourceId && !(parseInt(sourceId, 10) in _operators__WEBPACK_IMPORTED_MODULE_1__.OPERATORS)) {
        return _models__WEBPACK_IMPORTED_MODULE_0__.ErrorTypes.TO_NOT_SUPPORTED;
    }
    return _models__WEBPACK_IMPORTED_MODULE_0__.ErrorTypes.UNKNOWN;
};
const makeOperatorSenderButton = (sourceId, claimIdTO, type, toAlias) => {
    const style = _constants__WEBPACK_IMPORTED_MODULE_2__.claimMagnifierButtonStyles[type];
    const sendNotPossible = !sourceId.length && !toAlias || !claimIdTO.length;
    const button = (0,_dom__WEBPACK_IMPORTED_MODULE_3__.createElement)('button', style);
    button.dataset.claimTouroperatorNumber = claimIdTO;
    button.dataset.sourceId = sourceId;
    button.dataset.tooltip = `${!sendNotPossible ?
        style.title : getErrorType(claimIdTO, sourceId)}`;
    button.appendChild((0,_dom__WEBPACK_IMPORTED_MODULE_3__.createElement)('i', { className: `icon ${!sendNotPossible ? 'search' : 'ban'}` }));
    if (sendNotPossible) {
        button.classList.add('grey');
        button.style.cursor = 'not-allowed';
    }
    else {
        button.classList.add(style.activeClass);
        button.style.cursor = 'pointer';
    }
    return button;
};


/***/ },

/***/ "./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/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/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/page.ts"
/*!*******************************!*\
  !*** ./src/app/utils/page.ts ***!
  \*******************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   isClaimCheckSupported: () => (/* binding */ isClaimCheckSupported),
/* harmony export */   isClaimPage: () => (/* binding */ isClaimPage),
/* harmony export */   isOperatorSupported: () => (/* binding */ isOperatorSupported)
/* harmony export */ });
/* harmony import */ var _operators__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../operators */ "./src/app/operators.ts");
/* harmony import */ var _chunks_constants_urls__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./chunks/constants_urls */ "./src/app/utils/chunks/constants_urls.ts");


function isClaimPage({ host, pathname, search }) {
    return Boolean(_chunks_constants_urls__WEBPACK_IMPORTED_MODULE_1__.CB_HOSTS.indexOf(host.toLowerCase()) !== -1 &&
        (pathname.toLowerCase() === _chunks_constants_urls__WEBPACK_IMPORTED_MODULE_1__.CB_CLAIM_PATH.toLowerCase() ||
            pathname.toLowerCase() === _chunks_constants_urls__WEBPACK_IMPORTED_MODULE_1__.CB_CLAIM_FULL_PATH.toLowerCase()) &&
        search.toLowerCase().indexOf(_chunks_constants_urls__WEBPACK_IMPORTED_MODULE_1__.CB_CLAIM_ID_PARAM.toLowerCase()) >= 0);
}
function isOperatorSupported(sourceId) {
    return sourceId in _operators__WEBPACK_IMPORTED_MODULE_0__.OPERATORS;
}
function isClaimCheckSupported(claimNumber, tourOperatorId) {
    return tourOperatorId in _operators__WEBPACK_IMPORTED_MODULE_0__.OPERATORS
        && claimNumber.length > 0
        && _operators__WEBPACK_IMPORTED_MODULE_0__.OPERATORS[tourOperatorId].hasOwnProperty('link');
}


/***/ },

/***/ "./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) ? '' : '&'}`;
    }, '');
}


/***/ }

/******/ 	});
/************************************************************************/
/******/ 	// 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/content.ts ***!
  \****************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _utils_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils/dom */ "./src/app/utils/dom.ts");
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./models */ "./src/app/models/index.ts");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/app/utils/index.ts");
/* harmony import */ var _utils_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils/constants */ "./src/app/utils/constants.ts");
/* harmony import */ var _utils_chunks_makeOperatorSenderButton__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils/chunks/makeOperatorSenderButton */ "./src/app/utils/chunks/makeOperatorSenderButton.ts");
/* harmony import */ var _utils_page__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils/page */ "./src/app/utils/page.ts");
/* harmony import */ var _utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils/chunks/goToClaimOperatorType */ "./src/app/utils/chunks/goToClaimOperatorType.ts");
/* harmony import */ var _utils_chunks_common_clientUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils/chunks/common/clientUtils */ "./src/app/utils/chunks/common/clientUtils.ts");
/* harmony import */ var _contentScripts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./contentScripts */ "./src/app/contentScripts.ts");










let DOMLoaded = false;
function waitForDomLoaded() {
    return new Promise((resolve, reject) => {
        const timerId = setInterval(() => {
            if (DOMLoaded) {
                clearInterval(timerId);
                resolve();
            }
        }, 1000);
    });
}
(0,_utils__WEBPACK_IMPORTED_MODULE_2__.addMessageListener)((message, sender, sendResponse) => {
    switch (message.type) {
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_PAGE_STATUS:
            // Здесь пришлось убрать обертку так как не получалось отправить респонс
            // обратно в попап, чтобы обновить стейт
            if (DOMLoaded) {
                if (!(0,_utils_page__WEBPACK_IMPORTED_MODULE_5__.isClaimPage)(window.location)) {
                    sendResponse({ isClaimPage: false });
                    return;
                }
                const { sourceId, claimIdTO, claimNumber, secretField, toAlias } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
                if (!sourceId) {
                    return;
                }
                sendResponse({
                    isClaimPage: (0,_utils_page__WEBPACK_IMPORTED_MODULE_5__.isClaimPage)(window.location),
                    claimId: claimIdTO.dataset.claimTouroperatornumber,
                    claimNumber: claimNumber.dataset.claimNumber,
                    sourceId: parseInt(sourceId.dataset.claimSourceid, 10),
                    isOperatorSupported: (0,_utils_page__WEBPACK_IMPORTED_MODULE_5__.isOperatorSupported)(parseInt(sourceId.dataset.claimSourceid, 10)),
                    secretField: encodeURIComponent(secretField.dataset.autofiller)
                });
                return;
            }
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_IDS:
            if (message && message.payload && message.payload.claimNo && message.payload.claimNo !== '') {
                let claimNoElement = document.querySelector(message.payload.claimNo);
                sendResponse({
                    claimNo: (claimNoElement && claimNoElement.innerHTML) || '',
                    claimNoValue: (claimNoElement && claimNoElement.value) || '',
                    claimNumber: message.payload.claimNumber,
                    claimNoElement: claimNoElement
                });
            }
            else {
                sendResponse({
                    claimNo: '',
                    claimNumber: message.payload.claimNumber,
                    claimNoElement: null
                });
            }
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_IDS_MESSAGE_AND_STATUS:
            if (message && message.payload
                && message.payload.claimNo && message.payload.claimNo !== ''
                && message.payload.statusSelector && message.payload.statusSelector !== '') {
                let claimNoElement = document.querySelector(message.payload.claimNo);
                let claimStatusElement = document.querySelector(message.payload.statusSelector);
                sendResponse({
                    claimNo: (claimNoElement && claimNoElement.innerHTML) || '',
                    claimNumber: message.payload.claimNumber,
                    claimNoElement: claimNoElement,
                    claimStatus: (claimStatusElement && claimNoElement.innerHTML) || '',
                    claimStatusElement: claimStatusElement
                });
            }
            else {
                sendResponse({
                    claimNo: '',
                    claimNumber: message.payload.claimNumber,
                    claimNoElement: null,
                    claimStatus: null,
                    claimStatusElement: null
                });
            }
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_ELEMENT:
            const frame = message.payload.frame
                ? window.top.document.querySelector(message.payload.frame).contentWindow.document
                : null;
            let element = frame
                ? frame.querySelector(message.payload.elementSelector)
                : window.top.document.querySelector(message.payload.elementSelector);
            // console.log('GET_ELEMENT');
            // console.dir(element);
            sendResponse({
                element: element,
                innerHTML: element && element.innerHTML ? element.innerHTML : ''
            });
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.EXECUTE_CONTENT_SCRIPT:
            (0,_contentScripts__WEBPACK_IMPORTED_MODULE_8__.handleContentScriptExecutionRequest)(message.payload.scriptKey, message.payload);
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_DOCUMENT_STATE:
            sendResponse({ documentState: document.readyState });
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_TOURIST_LINKS:
            switch (message.payload.operatorId) {
                case 3:
                    const touristBlock = document.querySelector(message.payload.touristBlock);
                    sendResponse({ links: Array.prototype.map.call(touristBlock.querySelectorAll('tbody tr:not(:first-child)'), (row) => ({ href: row.querySelector('.link-popup.person_popup_link').href })) });
                    break;
                case 9:
                case 229:
                    sendResponse({ links: document.querySelector(message.payload.touristBlock).innerHTML });
                    break;
            }
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_PAGE_LOGIN_FORM:
            sendResponse({ loginForm: document.querySelector(message.payload.formPath) || null });
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_CLAIM_BUTTON:
            sendResponse({ claimButton: document.querySelector(message.payload.claimButton).innerHTML || null });
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.GET_PAGE_SEARCH_FORM:
            sendResponse({ queryInput: document.querySelector(message.payload.queryInput) || null });
            break;
        case _models__WEBPACK_IMPORTED_MODULE_1__.MessageTypes.REPLACE_TOUR_LINK:
            console.log('constent: start replacing');
            window.NewWindow = (a, b, w, h, f) => { window.open(a, '_blank'); };
            console.log('constent: end replacing');
            break;
        default:
            break;
    }
});
const createButton = (options) => {
    var buttonTarget; // = new HTMLElement; 
    console.log(`createButton ${options.buttonTargetSelector}`);
    buttonTarget = document.getElementById(options.buttonTargetSelector);
    const { claimData, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getTourOperatorClaimDataFields)(options.sourceAutoFillSelector, options.sourceAutoFillerToken);
    console.dir(claimData);
    const senderButton = (0,_utils_chunks_makeOperatorSenderButton__WEBPACK_IMPORTED_MODULE_4__.makeOperatorSenderButton)(claimData.dataset.claimSourceid, claimData.dataset.claimTouroperatornumber, options.type, claimData.dataset.claimToalias);
    buttonTarget.appendChild(senderButton);
    senderButton.addEventListener('click', () => {
        senderButton.innerHTML = `<i class="clock icon"></i>`;
        senderButton.setAttribute('disabled', 'disabled');
        (0,_utils_chunks_common_clientUtils__WEBPACK_IMPORTED_MODULE_7__.wait)(10 * 1000)
            .then(() => {
            senderButton.removeAttribute('disabled');
            senderButton.innerHTML = `<i class="icon search"></i>`;
            senderButton.style.backgroundColor = null;
        });
        if (!claimData.dataset.claimTouroperatornumber.length) {
            return;
        }
        // sendMessage(createStateMessage(
        //     isClaimPage(window.location),
        //     (claimData as HTMLElement).dataset.claimNumber as string,
        //     parseInt((claimData as HTMLElement).dataset.claimSourceid as string, 10),
        //     encodeURIComponent((secretField as HTMLElement).dataset.autofiller as string),
        //     (claimData as HTMLElement).dataset.claimTouroperatornumber as string,
        //     'magnifier',
        //     undefined,
        //     {
        //         magnifierType: options.type,
        //     }
        // ));
    });
};
const createOperatorSenderButton = (type, operatorType) => new Promise(resolve => {
    switch (operatorType) {
        case _utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Base: {
            console.log('GoToClaimOperatorType.Base');
            createButton({
                type: type,
                buttonTargetSelector: 'AutoFiller-GoToOperatorPage',
                sourceAutoFillSelector: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillSelector,
                sourceAutoFillerToken: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillerToken
            });
        }
        case _utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Another: {
            createButton({
                type: type + '-another',
                buttonTargetSelector: 'AutoFiller-GoAnotherToOperatorPage',
                sourceAutoFillSelector: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillAnotherSelector,
                sourceAutoFillerToken: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillerTokenAnother
            });
        }
        case _utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Accomodation: {
            createButton({
                type: type + '-acc',
                buttonTargetSelector: 'AutoFiller-GoAccomodationToOperatorPage',
                sourceAutoFillSelector: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillAccomodationSelector,
                sourceAutoFillerToken: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillerTokenAccomodation
            });
        }
        case _utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Accomodation: {
            createButton({
                type: type + '-flg',
                buttonTargetSelector: 'AutoFiller-GoFlightToOperatorPage',
                sourceAutoFillSelector: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillFlightSelector,
                sourceAutoFillerToken: _utils_constants__WEBPACK_IMPORTED_MODULE_3__.sourceAutoFillerTokenFlight
            });
        }
    }
    resolve();
});
// creates all magnifier buttons for operator
const createOperatorSenderButtons = (operatorType = _utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Base) => {
    const { sourceId, claimIdTO, claimNumber, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
    console.log('createOperatorSenderButtons');
    if (!sourceId) {
        return Promise.reject('Unable to create operator magnifier buttons');
    }
    const operatorId = parseInt(sourceId.dataset.claimSourceid, 10);
    return Promise.all((_utils_constants__WEBPACK_IMPORTED_MODULE_3__.claimMagnifierOperatorTypes[operatorId] || ['default']).map((type) => createOperatorSenderButton(type, operatorType)));
};
const createButtonsByMarkers = (markerSelector, supportingSourcesIds, tabSelector, contentSelector, factoryMethod, postCreation) => new Promise((resolve) => {
    const { sourceId, claimIdTO, claimNumber, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
    if (!sourceId) {
        return Promise.reject('Unable to buttons');
    }
    const sourceIdNum = parseInt(sourceId.dataset.claimSourceid, 10);
    if (supportingSourcesIds && supportingSourcesIds.indexOf(sourceIdNum) === -1) {
        return;
    }
    const tab = document.querySelector(tabSelector);
    const waitForFrameClaimContent = (exists) => new Promise(resolve => {
        let interval = 0;
        const checkIfContentExists = () => {
            const container = document.querySelector(contentSelector);
            if (exists && container) {
                clearInterval(interval);
                resolve(interval);
            }
            if (!exists && !container) {
                clearInterval(interval);
                resolve(interval);
            }
        };
        let timer = setInterval(checkIfContentExists, 100);
    });
    const createBt = (target) => {
        const bt = factoryMethod();
        target.appendChild(bt);
        postCreation(bt, target);
    };
    let interval = -1;
    const createButtons = (targets) => {
        Array.prototype.forEach.call(targets, (target) => {
            if (!target.querySelector('button')) {
                createBt(target);
            }
        });
        clearInterval(interval);
        let timer = setInterval(checkBts, 100);
    };
    const checkBts = () => {
        const targets = document.querySelectorAll(markerSelector);
        Array.prototype.forEach.call(targets, (target) => {
            if (!target.querySelector('button')) {
                createBt(target);
            }
        });
    };
    const targets = document.querySelectorAll(markerSelector);
    createButtons(targets);
    resolve();
});
const createButtonsByMarkersMyAgent = (getTargets, supportingSourcesIds, tabSelector, contentSelector, factoryMethod, postCreation) => new Promise((resolve) => {
    const { sourceId, claimIdTO, claimNumber, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
    if (!sourceId) {
        return Promise.reject('Unable to buttons');
    }
    const sourceIdNum = parseInt(sourceId.dataset.claimSourceid, 10);
    if (supportingSourcesIds && supportingSourcesIds.indexOf(sourceIdNum) === -1) {
        return;
    }
    const tab = document.querySelector(tabSelector);
    const waitForFrameClaimContent = (exists) => new Promise(resolve => {
        let interval = 0;
        const checkIfContentExists = () => {
            const container = document.querySelector(contentSelector);
            if (exists && container) {
                clearInterval(interval);
                resolve(interval);
            }
            if (!exists && !container) {
                clearInterval(interval);
                resolve(interval);
            }
        };
        let timer = setInterval(checkIfContentExists, 100);
    });
    const createBt = (target) => {
        const bt = factoryMethod();
        target.appendChild(bt);
        postCreation(bt, target);
    };
    let interval = -1;
    const createButtons = (targets) => {
        Array.prototype.forEach.call(targets, (target) => {
            if (!target.querySelector('button.myAgentTransfer')) {
                createBt(target);
            }
        });
        clearInterval(interval);
        let timer = setInterval(checkBts, 100);
    };
    const checkBts = () => {
        const targets = getTargets();
        Array.prototype.forEach.call(targets, (target) => {
            if (!target.querySelector('button')) {
                createBt(target);
            }
        });
    };
    const targets = getTargets();
    createButtons(targets);
    resolve();
});
const createOperatorGoToPaymentTransferButtons = () => {
    const { sourceId, claimIdTO, claimNumber, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
    const sourceIdNum = parseInt(sourceId.dataset.claimSourceid, 10);
    return createButtonsByMarkers('.AutoFiller-GoToPaymentTransfer', _utils_constants__WEBPACK_IMPORTED_MODULE_3__.claimTransferFillerOperators, '#PageControlClaimMain_T1T', '#GridClaimTransfer_DXDataRow0', _utils_dom__WEBPACK_IMPORTED_MODULE_0__.makeOperatorGoToPaymentTransferButton, (bt, target) => {
        bt.addEventListener('click', () => {
            // sendMessage(createStateMessage(
            //     isClaimPage(window.location),
            //     (claimNumber as HTMLElement).dataset.claimNumber as string,
            //     sourceIdNum,
            //     encodeURIComponent((secretField as HTMLElement).dataset.autofiller as string),
            //     (claimIdTO as HTMLElement).dataset.claimTouroperatornumber as string,
            //     'goToPaymentTransferBt',
            //     target.getAttribute('data-autofiller'),
            // ));
        });
    });
};
const createOperatorGoToMyAgentButtons = () => {
    const { sourceId, claimIdTO, claimNumber, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
    const sourceIdNum = parseInt(sourceId.dataset.claimSourceid, 10);
    return createButtonsByMarkers('.AutoFiller-GoToMyAgentBotton', null, '#PageControlClaimMain_T1T', '#GridClaimRefund_DXDataRow0', _utils_dom__WEBPACK_IMPORTED_MODULE_0__.makeOperatorGoToMyAgentButton, (bt, target) => {
        bt.addEventListener('click', () => {
            // sendMessage(createStateMessage(
            //     isClaimPage(window.location),
            //     (claimNumber as HTMLElement).dataset.claimNumber as string,
            //     sourceIdNum,
            //     encodeURIComponent((secretField as HTMLElement).dataset.autofiller as string),
            //     (claimIdTO as HTMLElement).dataset.claimTouroperatornumber as string,
            //     'goToMyAgent',
            //     target.getAttribute('data-autofiller'),
            // ));
        });
    });
};
const createOperatorGoToMyAgentTransferButtons = (link) => {
    const { sourceId, claimIdTO, claimNumber, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
    const sourceIdNum = parseInt(sourceId.dataset.claimSourceid, 10);
    return createButtonsByMarkersMyAgent(() => {
        var tds = link.parentNode.parentNode.getElementsByTagName('td');
        var lastTd = tds[tds.length - 1];
        return lastTd.querySelectorAll('div');
    }, null, '#PageControlClaimMain_T1T', '#GridClaimRefund_DXDataRow0', _utils_dom__WEBPACK_IMPORTED_MODULE_0__.makeOperatorGoToMyAgentTransferButton, (bt, target) => {
        bt.addEventListener('click', () => {
            // sendMessage(createStateMessage(
            //     isClaimPage(window.location),
            //     (claimNumber as HTMLElement).dataset.claimNumber as string,
            //     sourceIdNum,
            //     encodeURIComponent((secretField as HTMLElement).dataset.autofiller as string),
            //     (claimIdTO as HTMLElement).dataset.claimTouroperatornumber as string,
            //     'goToMyAgent',
            //     target.getAttribute('data-autofiller'),
            //     {
            //         id: link.dataset.id, url: link.dataset.url
            //     }
            // ));
        });
    });
};
const createOperatorGoToPaymentRefundButtons = () => {
    const { sourceId, claimIdTO, claimNumber, secretField } = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getClaimDataFields)();
    const sourceIdNum = parseInt(sourceId.dataset.claimSourceid, 10);
    return createButtonsByMarkers('.AutoFiller-GoToPaymentRefund', _utils_constants__WEBPACK_IMPORTED_MODULE_3__.claimRefundFillerOperators, '#PageControlClaimMain_T1T', '#GridClaimRefund_DXDataRow0', _utils_dom__WEBPACK_IMPORTED_MODULE_0__.makeOperatorGoToPaymentRefundButton, (bt, target) => {
        bt.addEventListener('click', () => {
            // sendMessage(createStateMessage(
            //     isClaimPage(window.location),
            //     (claimNumber as HTMLElement).dataset.claimNumber as string,
            //     sourceIdNum,
            //     encodeURIComponent((secretField as HTMLElement).dataset.autofiller as string),
            //     (claimIdTO as HTMLElement).dataset.claimTouroperatornumber as string,
            //     'goToPaymentRefundBt',
            //     target.getAttribute('data-autofiller'),
            // ));
        });
    });
};
waitForDomLoaded()
    .then(() => {
    const curTime = Date.now();
    //console.log('waitForDomLoaded = true');
    const timer = setInterval(() => {
        //console.log("document.querySelector('div#AutoFiller-GoToOperatorPage')");
        const autoFillDiv = document.querySelector('div#AutoFiller-GoToOperatorPage');
        if (autoFillDiv
            && autoFillDiv.innerHTML !== null
            && typeof (autoFillDiv.innerHTML) !== 'undefined'
            && autoFillDiv.innerHTML.trim() === '') {
            return Promise.resolve()
                .then(() => createOperatorSenderButtons(_utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Base))
                .catch(() => { });
        }
        const autoFillAnotherDiv = document.querySelector('div#AutoFiller-GoAnotherToOperatorPage');
        if (autoFillAnotherDiv
            && autoFillAnotherDiv.innerHTML !== null
            && typeof (autoFillAnotherDiv.innerHTML) !== 'undefined'
            && autoFillAnotherDiv.innerHTML.trim() === '') {
            return Promise.resolve()
                .then(() => createOperatorSenderButtons(_utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Another))
                .catch(() => { });
        }
        const autoFillAccomodationDiv = document.querySelector('div#AutoFiller-GoAccomodationToOperatorPage');
        if (autoFillAccomodationDiv
            && autoFillAccomodationDiv.innerHTML !== null
            && typeof (autoFillAccomodationDiv.innerHTML) !== 'undefined'
            && autoFillAccomodationDiv.innerHTML.trim() === '') {
            return Promise.resolve()
                .then(() => createOperatorSenderButtons(_utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Accomodation))
                .catch(() => { });
        }
        const autoFillFlightDiv = document.querySelector('div#AutoFiller-GoFlightToOperatorPage');
        if (autoFillFlightDiv
            && autoFillFlightDiv.innerHTML !== null
            && typeof (autoFillFlightDiv.innerHTML) !== 'undefined'
            && autoFillFlightDiv.innerHTML.trim() === '') {
            return Promise.resolve()
                .then(() => createOperatorSenderButtons(_utils_chunks_goToClaimOperatorType__WEBPACK_IMPORTED_MODULE_6__.GoToClaimOperatorType.Flight))
                .catch(() => { });
        }
        if (Date.now() - curTime >= 1 * 60 * 60 * 1000) {
            clearInterval(timer);
        }
    }, 2 * 1000);
    return Promise.resolve();
})
    .then(() => {
    const curTime = Date.now();
    const timer = setInterval(() => {
        const autoFillAnotherDiv = document.querySelector('div.AutoFiller-GoToMyAgentBotton');
        if (autoFillAnotherDiv
            && autoFillAnotherDiv.innerHTML !== null
            && typeof (autoFillAnotherDiv.innerHTML) !== 'undefined'
            && autoFillAnotherDiv.innerHTML.trim() === '') {
            return Promise.resolve()
                .then(() => createOperatorGoToMyAgentButtons())
                .catch(() => { });
        }
        if (Date.now() - curTime >= 10 * 60 * 60 * 1000) {
            clearInterval(timer);
        }
    }, 2 * 1000);
    return Promise.resolve();
})
    .then(() => {
    const curTime = Date.now();
    const timer = setInterval(() => {
        const autoFilltransferUrls = document.querySelectorAll('a[data-type="МойАгент-ЖД"], a[data-type="МойАгент-АВИА"], a[data-type="Fly"]');
        let allButtonsPromises = [];
        if (autoFilltransferUrls.length > 0) {
            for (let i = 0; i < autoFilltransferUrls.length; i++) {
                let autoFilltransferUrl = autoFilltransferUrls[i];
                allButtonsPromises.push(createOperatorGoToMyAgentTransferButtons(autoFilltransferUrl));
            }
            return Promise.all(allButtonsPromises);
        }
        if (Date.now() - curTime >= 10 * 60 * 60 * 1000) {
            clearInterval(timer);
        }
    }, 2 * 1000);
    return Promise.resolve();
})
    .then(() => createOperatorGoToPaymentTransferButtons())
    .then(() => createOperatorGoToPaymentRefundButtons())
    .catch(() => { });
document.addEventListener('DOMContentLoaded', () => {
    DOMLoaded = true;
});

})();

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