"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 = _ModalExtras.EXTRA_TYPE.GUEST,
  RANGE = _ModalExtras.EXTRA_TYPE.RANGE,
  ROOM = _ModalExtras.EXTRA_TYPE.ROOM,
  UNIT = _ModalExtras.EXTRA_TYPE.UNIT;
const NIGHTLY = _ModalExtras.FREQUENCY.NIGHTLY,
  ONCE = _ModalExtras.FREQUENCY.ONCE;
const getCaption = function () {
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    accommodationType = _ref.accommodationType,
    amount = _ref.amount,
    frequency = _ref.frequency,
    guestType = _ref.guestType,
    _ref$inputGuests = _ref.inputGuests,
    inputGuests = _ref$inputGuests === void 0 ? false : _ref$inputGuests,
    type = _ref.type,
    _ref$valueAmount = _ref.valueAmount,
    guests = _ref$valueAmount === void 0 ? 0 : _ref$valueAmount,
    _ref$valueNights = _ref.valueNights,
    nights = _ref$valueNights === void 0 ? 0 : _ref$valueNights;
  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