const require_built = require('../config/dist/esm/built.cjs');
const require_getMultilingualUrls = require('./getMultilingualUrls.cjs');

//#region ../packages/@intlayer/core/dist/esm/localization/getLocalizedUrl.mjs
/**
* Generate URL by prefixing the given URL with the referenced locale or adding search parameters
* based on the routing mode. Handles both absolute and relative URLs appropriately.
*
* This function gets the locales, default locale, and routing mode from the configuration if not provided.
*
* Example:
*
* ```ts
*  // prefix-no-default mode
*  getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'prefix-no-default');
*  // Returns '/fr/about' for the French locale
*  // Returns '/about' for the English locale (default)
*
*  // prefix-all mode
*  getLocalizedUrl('/about', 'en', ['en', 'fr'], 'en', 'prefix-all');
*  // Returns '/en/about' for the English locale
*  // Returns '/fr/about' for the French locale
*
*  // search-params mode
*  getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'search-params');
*  // Returns '/about?locale=fr' for the French locale
*
*  // no-prefix mode
*  getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'no-prefix');
*  // Returns '/about' for any locale
* ```
*
* @param url - The original URL string to be processed.
* @param currentLocale - The current locale.
* @param locales - Optional array of supported locales. Defaults to configured locales.
* @param defaultLocale - The default locale. Defaults to configured default locale.
* @param mode - URL routing mode for locale handling. Defaults to configured mode.
* @returns The localized URL for the current locale.
*/
const getLocalizedUrl = (url, currentLocale, locales = require_built.built_default?.internationalization?.locales, defaultLocale = require_built.built_default?.internationalization?.defaultLocale, mode = require_built.built_default?.routing?.mode) => {
	return require_getMultilingualUrls.getMultilingualUrls(url, locales, defaultLocale, mode)[currentLocale] ?? url;
};

//#endregion
exports.getLocalizedUrl = getLocalizedUrl;
//# sourceMappingURL=getLocalizedUrl.cjs.map