"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getRoomOccupationLabel = void 0;
var _locale = require("@mirai/locale");
var _constants = require("./constants");
var _getAgeRange = require("./getAgeRange");
var _getOccupationLabel = require("./getOccupationLabel");
const {
  GUEST,
  ADULT,
  CHILD,
  BABY
} = _constants.OCCUPATION_TYPE;
const getRoomOccupationLabel = function () {
  let {
    adults = 0,
    babies = 0,
    children = 0,
    dataSource = [],
    translate = _locale.translate
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  const guests = dataSource.find(_ref => {
    let {
      type
    } = _ref;
    return type === GUEST;
  }) ? adults : 0;
  if (!adults && !guests) return '';
  const {
    age: [minAdults] = []
  } = dataSource.find(_ref2 => {
    let {
      type
    } = _ref2;
    return type === ADULT;
  }) || {};
  const {
    age: [minAge, maxAge] = []
  } = dataSource.find(_ref3 => {
    let {
      type
    } = _ref3;
    return type === CHILD;
  }) || {};
  return "".concat((0, _getOccupationLabel.getOccupationLabel)({
    amount: adults || guests,
    type: adults ? ADULT : GUEST
  }, translate)).concat(children > 0 ? ", ".concat((0, _getOccupationLabel.getOccupationLabel)({
    amount: children,
    type: CHILD
  }, translate)) : '', " ").concat(minAdults !== undefined || minAge !== undefined || maxAge !== undefined ? "(".concat((0, _getAgeRange.getAgeRange)(children > 0 ? [minAge, maxAge] : [minAdults], translate), ")") : '').concat(babies > 0 ? ", ".concat((0, _getOccupationLabel.getOccupationLabel)({
    amount: babies,
    type: BABY
  }, translate)) : '').trimEnd();
};
exports.getRoomOccupationLabel = getRoomOccupationLabel;
//# sourceMappingURL=getRoomOccupationLabel.js.map