"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getCaption = void 0;
var _locale = require("@mirai/locale");
var _helpers = require("../../../../helpers");
var _ModalExtras = require("../ModalExtras.constants");
var _ModalExtras2 = require("../ModalExtras.l10n");
const {
  GUEST,
  RANGE,
  ROOM,
  UNIT
} = _ModalExtras.EXTRA_TYPE;
const {
  NIGHTLY,
  ONCE
} = _ModalExtras.FREQUENCY;
const getCaption = function () {
  let {
    accommodationType,
    amount,
    frequency,
    guestType,
    inputGuests = false,
    type,
    valueAmount: guests = 0,
    valueNights: nights = 0
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  let translate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _locale.translate;
  const labelAccommodation = (0, _helpers.getAccommodationLabel)({
    plural: true,
    type: accommodationType
  }, translate).toLowerCase();
  const labelGuest = (0, _helpers.getGuestLabel)({
    plural: guests > 1,
    type: guestType
  }, translate);
  const labelNights = translate(_ModalExtras2.L10N.LABEL_NIGHT_COUNT, {
    value: nights
  });
  let result = '';
  if (type === UNIT && frequency === NIGHTLY) {
    result = translate(_ModalExtras2.L10N.LABEL_FOR_TYPE_EXTRA, {
      value: labelNights
    });
  } else if (type === ROOM && frequency === NIGHTLY && !inputGuests) result = translate(_ModalExtras2.L10N.LABEL_FOR_TYPE_EXTRA, {
    value: "".concat(labelNights).concat(amount > 1 ? ", ".concat(amount, " ").concat(labelAccommodation) : '')
  });else if (type === ROOM && frequency === ONCE) {
    result = amount > 1 ? translate(_ModalExtras2.L10N.LABEL_FOR_TYPE_EXTRA, {
      value: "".concat(amount, " ").concat(labelAccommodation)
    }) : '';
  } else if ([GUEST, RANGE].includes(type) && frequency === ONCE) {
    result = translate(_ModalExtras2.L10N.LABEL_FOR_TYPE_EXTRA, {
      value: "".concat(guests, " ").concat(labelGuest)
    });
  } else if (type === GUEST && frequency === NIGHTLY) {
    result = translate(_ModalExtras2.L10N.LABEL_FOR_TYPE_EXTRA, {
      value: "".concat(guests, "  ").concat(labelGuest, ",  ").concat(labelNights)
    });
  }
  return result;
};
exports.getCaption = getCaption;
//# sourceMappingURL=getCaption.js.map