"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCdnAssetUrl = getCdnAssetUrl;
const get_portal_url_1 = require("./get-portal-url");
const ArcGISContext_1 = require("../ArcGISContext");
/**
 * Returns an env-specific CDN asset URL for the given `assetPath` and `requestOptions`.
 * @param assetPath The CDN asset's path
 * @param requestOptions An IRequestOptions object
 */
function getCdnAssetUrl(assetPath, requestOptions) {
    const portalUrl = (0, get_portal_url_1.getPortalUrl)(requestOptions);
    let baseUrl;
    if (/(devext|mapsdevext)\.arcgis\.com/.test(portalUrl)) {
        baseUrl = "https://hubdevcdn.arcgis.com/opendata-ui/assets";
    }
    else if (/(qaext|mapsqa)\.arcgis\.com/.test(portalUrl)) {
        baseUrl = "https://hubqacdn.arcgis.com/opendata-ui/assets";
    }
    else if (/(www|maps)\.arcgis\.com/.test(portalUrl)) {
        baseUrl = "https://hubcdn.arcgis.com/opendata-ui/assets";
    }
    else {
        baseUrl = `${portalUrl}${ArcGISContext_1.ENTERPRISE_SITES_PATH}`;
    }
    const delimiter = assetPath.startsWith("/") ? "" : "/";
    return [baseUrl, assetPath].join(delimiter);
}
//# sourceMappingURL=get-cdn-asset-url.js.map