"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.bookingResponse = void 0;
var _helpers = require("../helpers");
var _legacy = require("../helpers/legacy");
const PURCHASE = 'purchase';
const bookingResponse = function () {
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    _ref$instances = _ref.instances,
    instances = _ref$instances === void 0 ? [] : _ref$instances,
    _ref$response = _ref.response,
    _ref$response2 = _ref$response === void 0 ? {} : _ref$response,
    _ref$response2$tracki = _ref$response2.tracking,
    tracking = _ref$response2$tracki === void 0 ? {} : _ref$response2$tracki;
  // ! -- TODO: use of tracking should be a temporary approach ---------------------------------------------------------
  const _tracking$guestData = tracking.guestData,
    _tracking$guestData2 = _tracking$guestData === void 0 ? {} : _tracking$guestData,
    email = _tracking$guestData2.email,
    _tracking$hotelInfo = tracking.hotelInfo,
    _tracking$hotelInfo2 = _tracking$hotelInfo === void 0 ? {} : _tracking$hotelInfo,
    _tracking$hotelInfo2$ = _tracking$hotelInfo2.currency,
    hotelCurrency = _tracking$hotelInfo2$ === void 0 ? {} : _tracking$hotelInfo2$,
    totalPriceWithoutTaxes = tracking.totalPriceWithoutTaxes;
  const value = {
    event_label: PURCHASE,
    event_category: PURCHASE,
    revenue_value: (0, _legacy.formatPrice)(totalPriceWithoutTaxes, hotelCurrency),
    currency: hotelCurrency.code
  };
  instances.forEach(function () {
    let _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
      _ref2$idBing = _ref2.idBing,
      idBing = _ref2$idBing === void 0 ? '' : _ref2$idBing;
    const uetq = "uetq_".concat(idBing);
    window[uetq] = window[uetq] || [];
    window[uetq].push('set', {
      pid: {
        em: (0, _helpers.SHA256)(email)
      }
    });
    window[uetq].push('event', PURCHASE, value);
  });
  return value;
};
exports.bookingResponse = bookingResponse;
//# sourceMappingURL=bookingResponse.js.map