"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getRoomDataSource = void 0;
var _getOccupationDataSource = require("./getOccupationDataSource");
var _getRoomSelectionData = require("./getRoomSelectionData");
var _helpers = require("../../helpers");
const getRoomDataSource = function () {
  let {
    configDataSource = [],
    details = [],
    occupation = [],
    translate = () => {}
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  return (0, _getRoomSelectionData.getRoomSelectionData)({
    details,
    occupation
  }).map((_ref, index) => {
    let {
      detail = {},
      room,
      roomOccupation = {}
    } = _ref;
    const {
      image,
      items: [{
        summary: plan = ''
      } = {}] = [],
      occupation: value = {},
      rate = '',
      type = ''
    } = detail;
    const roomDataSource = (0, _getOccupationDataSource.getOccupationDataSource)({
      configDataSource,
      occupation: roomOccupation ? [roomOccupation] : []
    });
    return {
      image,
      id: room.id,
      index,
      room,
      occupation: (0, _helpers.getRoomOccupationLabel)({
        adults: value.adults,
        children: value.children,
        dataSource: roomDataSource,
        translate
      }),
      plan,
      rate: rate.replace("".concat(type, ":"), '').trim(),
      title: type
    };
  });
};
exports.getRoomDataSource = getRoomDataSource;
//# sourceMappingURL=getRoomDataSource.js.map