"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getAccommodationType = void 0;
var _constants = require("./constants");
const {
  APARTMENT,
  ACCOMMODATION,
  PITCH,
  ROOM,
  VILLA
} = _constants.ACCOMMODATION_TYPE;
const DEFAULT_PLACE = 'ROOMS';
const PLACE_INDIVIDUAL = {
  APARTMENTS: APARTMENT,
  LODGINGS: ACCOMMODATION,
  PLOTS: PITCH,
  ROOMS: ROOM,
  VILLA: VILLA
};
const getAccommodationType = function () {
  let {
    dataSource,
    hotels = [],
    individual = DEFAULT_PLACE
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  let result;
  if (dataSource) {
    const types = Object.entries(dataSource).filter(_ref => {
      let [id] = _ref;
      return hotels.length === 0 || hotels.includes(id);
    }).map(_ref2 => {
      let [, {
        lodgingDenomination: type
      }] = _ref2;
      return type;
    }) || [];
    if (types.includes(ROOM)) result = ROOM;else if (types.includes(ACCOMMODATION)) result = ACCOMMODATION;else if (types.includes(APARTMENT)) result = APARTMENT;else if (types.includes(PITCH)) result = PITCH;else if (types.includes(VILLA)) result = VILLA;
  }
  return result || PLACE_INDIVIDUAL[individual];
};
exports.getAccommodationType = getAccommodationType;
//# sourceMappingURL=getAccommodationType.js.map