"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getOccupation = void 0;
var _helpers = require("../../../helpers");
const ADULT = _helpers.OCCUPATION_TYPE.ADULT,
  CHILD = _helpers.OCCUPATION_TYPE.CHILD,
  GUEST = _helpers.OCCUPATION_TYPE.GUEST;
const getOccupation = propGuests => {
  const _ref = Array.isArray(propGuests) ? {
      adults: propGuests.reduce(function (total) {
        let _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
          _ref2$amount = _ref2.amount,
          amount = _ref2$amount === void 0 ? 0 : _ref2$amount,
          type = _ref2.type;
        return total + (type === ADULT ? amount : 0);
      }, 0),
      children: propGuests.flat().reduce(function (total) {
        let _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
          _ref3$amount = _ref3.amount,
          amount = _ref3$amount === void 0 ? 0 : _ref3$amount,
          type = _ref3.type;
        return total + (type === CHILD ? amount : 0);
      }, 0),
      guests: propGuests.reduce(function (total) {
        let _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
          _ref4$amount = _ref4.amount,
          amount = _ref4$amount === void 0 ? 0 : _ref4$amount,
          type = _ref4.type;
        return total + (type === GUEST ? amount : 0);
      }, 0)
    } : {
      adults: propGuests !== null && propGuests !== void 0 ? propGuests : 0
    },
    _ref$adults = _ref.adults,
    adults = _ref$adults === void 0 ? 0 : _ref$adults,
    _ref$children = _ref.children,
    children = _ref$children === void 0 ? 0 : _ref$children,
    _ref$guests = _ref.guests,
    guests = _ref$guests === void 0 ? 0 : _ref$guests;
  return {
    adults,
    children,
    guests
  };
};
exports.getOccupation = getOccupation;
//# sourceMappingURL=getOccupation.js.map