"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendQueryParamsToManifestURL = void 0;
const extractURLFromManifest_1 = require("./extractURLFromManifest");
/** Appends query params to dapp URL or live app URL that might contain existing search params. */
function appendQueryParamsToManifestURL(manifest, queryString = {}) {
    const url = (0, extractURLFromManifest_1.extractURLFromManifest)(manifest);
    if (!url) {
        return undefined;
    }
    const searchParams = new URLSearchParams(url.search);
    // Append the new query strings to the existing ones
    Object.entries(queryString).forEach(([key, value]) => {
        if (Array.isArray(value)) {
            value.forEach(item => searchParams.append(key, item));
        }
        else {
            searchParams.append(key, value);
        }
    });
    url.search = searchParams.toString();
    return url;
}
exports.appendQueryParamsToManifestURL = appendQueryParamsToManifestURL;
//# sourceMappingURL=appendQueryParamsToManifestURL.js.map