"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHubLocaleAssetUrl = getHubLocaleAssetUrl;
const get_portal_url_1 = require("./get-portal-url");
const hub_cdn_urlmap_1 = require("./hub-cdn-urlmap");
const ArcGISContext_1 = require("../ArcGISContext");
// TODO: should this take IHubRequestOptions as well as a portal?
// if so, address when we tackle https://github.com/Esri/hub.js/issues/321
/**
 * Given a Portal object, return the full Hub locale asset url
 * Used for fetching translations
 * @param {Object} portal Portal Self
 */
function getHubLocaleAssetUrl(portal) {
    if (portal.isPortal) {
        // Enterprise - use Site app as source for assets
        const baseUrl = (0, get_portal_url_1.getPortalUrl)(portal);
        return `${baseUrl}${ArcGISContext_1.ENTERPRISE_SITES_PATH}`;
    }
    else {
        // AGO - Convert portalHostname into CDN url
        const index = portal.portalHostname.split(".")[0];
        const base = hub_cdn_urlmap_1.HUB_CDN_URLMAP[index] || hub_cdn_urlmap_1.HUB_CDN_URLMAP.www;
        return `${base}/opendata-ui/assets`;
    }
}
//# sourceMappingURL=get-hub-locale-asset-url.js.map