"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.calcTooltips = void 0;
var _locale = require("@mirai/locale");
var _helpers = require("../../../helpers");
var _helpers2 = require("../helpers");
var _RatesExplorer = require("../RatesExplorer.l10n");
const calcTooltips = function () {
  let {
    focus,
    from,
    highlights,
    minNightsWithDeals,
    rangeMinDays = 1,
    to,
    translate = _locale.translate
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  if (!(0, _locale.isDate)(from) || focus && !(0, _locale.isDate)(focus) || to && !(0, _locale.isDate)(to)) return;
  const value = {};
  if (from && !to && (rangeMinDays > 1 || minNightsWithDeals > 1)) {
    value[(0, _locale.dateFormat)(from, {
      format: _helpers.CALENDAR_FORMAT
    })] = {
      text: translate(minNightsWithDeals ? _RatesExplorer.L10N.LABEL_MIN_NIGHTS_DEALS : _RatesExplorer.L10N.LABEL_MIN_NIGHTS, {
        value: minNightsWithDeals || rangeMinDays
      }),
      pressable: false
    };
  }
  if (to && minNightsWithDeals && (0, _helpers2.calcNightWithDeals)(from, to, highlights) < minNightsWithDeals) {
    value[(0, _locale.dateFormat)(to, {
      format: _helpers.CALENDAR_FORMAT
    })] = {
      text: translate(_RatesExplorer.L10N.LABEL_INFO_PRICES, {
        value: minNightsWithDeals
      }),
      pressable: false
    };
  } else if (!to && from && focus && focus > from) {
    const {
      days
    } = (0, _locale.dateDiff)(from, focus);
    if (days >= minNightsWithDeals || rangeMinDays) {
      value[(0, _locale.dateFormat)(focus, {
        format: _helpers.CALENDAR_FORMAT
      })] = {
        text: translate(_RatesExplorer.L10N.LABEL_NIGHTS, {
          value: days
        }),
        pressable: false
      };
    }
  }
  return value;
};
exports.calcTooltips = calcTooltips;
//# sourceMappingURL=calcTooltips.js.map