"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getSuperProps = void 0;
var _Core = require("../Core.constants");
const _excluded = ["features"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
const getSuperProps = function () {
  var _tracking$compareTrac;
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    _ref$store = _ref.store,
    store = _ref$store === void 0 ? {} : _ref$store,
    engineVersion = _ref.engineVersion;
  const _store$config = store.config,
    config = _store$config === void 0 ? {} : _store$config,
    _store$components = store.components,
    components = _store$components === void 0 ? {} : _store$components,
    _store$club = store.club,
    club = _store$club === void 0 ? {} : _store$club,
    _store$finder = store.finder,
    _store$finder2 = _store$finder === void 0 ? {} : _store$finder,
    _store$finder2$place = _store$finder2.place,
    _store$finder2$place2 = _store$finder2$place === void 0 ? {} : _store$finder2$place,
    _store$finder2$place3 = _store$finder2$place2.id,
    _store$finder2$place4 = _store$finder2$place3 === void 0 ? [] : _store$finder2$place3,
    _store$finder2$place5 = _slicedToArray(_store$finder2$place4, 1),
    placeHotelId = _store$finder2$place5[0],
    isHotel = _store$finder2$place2.isHotel,
    _store$hotel = store.hotel,
    _store$hotel2 = _store$hotel === void 0 ? {} : _store$hotel,
    _store$hotel2$feature = _store$hotel2.features,
    features = _store$hotel2$feature === void 0 ? {} : _store$hotel2$feature,
    hotel = _objectWithoutProperties(_store$hotel2, _excluded),
    id = store.id,
    type = store.type,
    _store$urlParams = store.urlParams,
    urlParams = _store$urlParams === void 0 ? {} : _store$urlParams,
    variant = store.variant;
  const _config$tracking = config.tracking,
    tracking = _config$tracking === void 0 ? {} : _config$tracking;
  const hotelId = isHotel ? placeHotelId : hotel.id;
  const _ref2 = features[hotel.id] || {},
    _ref2$country = _ref2.country,
    country = _ref2$country === void 0 ? {} : _ref2$country,
    name = _ref2.name,
    showMiraiTwin = _ref2.showMiraiTwin;
  const _ref3 = features[id] || {},
    chainName = _ref3.name;
  const props = {
    chain_id: type === _Core.TYPE.CHAIN ? "".concat(id) : 'independent',
    chain_name: type === _Core.TYPE.CHAIN ? chainName : undefined,
    engine_version: engineVersion,
    feature_3d: showMiraiTwin,
    feature_loyalty: !!(club !== null && club !== void 0 && club.active),
    feature_price_comp: !!(tracking !== null && tracking !== void 0 && (_tracking$compareTrac = tracking.compareTracking) !== null && _tracking$compareTrac !== void 0 && _tracking$compareTrac.length),
    feature_sarai: !!components.chat,
    hotel_country: country.en,
    hotel_id: hotelId,
    hotel_name: name,
    is_internal_user: urlParams.internalUser === 'true',
    active_experiments: variant ? {
      [_Core.EXPERIMENT_ID]: variant
    } : undefined
  };
  return Object.fromEntries(Object.entries(props).filter(_ref4 => {
    let _ref5 = _slicedToArray(_ref4, 2),
      value = _ref5[1];
    return value !== undefined && value !== '';
  }));
};
exports.getSuperProps = getSuperProps;
//# sourceMappingURL=getSuperProps.js.map