"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.parseCommon = void 0;
var _locale = require("@mirai/locale");
var _helpers = require("../../../../../components/helpers");
var _Core = require("../../../../../Core.constants");
const parseCommon = function () {
  let {
    calendar = [],
    id,
    occupation = [],
    promocode = '',
    type
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  const {
    adults = 0,
    children = 0
  } = (0, _helpers.getOccupationTotals)({
    occupation
  });
  return {
    chainId: type === _Core.TYPE.CHAIN ? id : undefined,
    checkin: (0, _locale.dateFormat)(calendar[0], {
      format: 'DD/MM/YYYY'
    }),
    checkout: (0, _locale.dateFormat)(calendar[1], {
      format: 'DD/MM/YYYY'
    }),
    coupon: promocode,
    hotelId: type === _Core.TYPE.HOTEL ? id : undefined,
    occupation: adults + children
  };
};
exports.parseCommon = parseCommon;
//# sourceMappingURL=parseCommon.js.map