"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.toParties = void 0;
var _Occupation = require("../Occupation.constants");
const {
  GUEST,
  ADULT,
  CHILD
} = _Occupation.TYPE;
const toParties = function () {
  let occupations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  const parties = [];
  occupations.forEach(function () {
    let occupation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    const party = {
      adults: 0,
      children: []
    };
    occupation.forEach(_ref => {
      let {
        type,
        amount,
        ages
      } = _ref;
      party.adults += type === GUEST || type === ADULT ? amount : 0;
      if (type === CHILD) {
        party.children = [...party.children, ...ages];
      }
    });
    if (party.adults > 0) {
      parties.push(party);
    }
  });
  return parties;
};
exports.toParties = toParties;
//# sourceMappingURL=toParties.js.map