"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getCurrency = void 0;
var _locale = require("@mirai/locale");
var _fetchCurrency = require("./fetchCurrency");
var _replaceUrlParams = require("../components/helpers/replaceUrlParams");
var _Core = require("../Core.constants");
const getCurrency = async function () {
  let {
    id,
    instance = {},
    isRates,
    type,
    urlParams = {}
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  let currency = urlParams.currency || instance.currency || (type === _Core.TYPE.HOTEL ? await (0, _fetchCurrency.fetchCurrency)(id) : _locale.DEFAULT_CURRENCY);
  if (!_locale.CURRENCIES.includes(currency)) {
    currency = _locale.DEFAULT_CURRENCY;
    isRates && (0, _replaceUrlParams.replaceUrlParams)({
      currency
    });
  }
  return currency;
};
exports.getCurrency = getCurrency;
//# sourceMappingURL=getCurrency.js.map