import { CLIENTSIDE_SERVICES_IFRAME_URL } from '../../../core/src/constants.mjs';
import { getDFPCdnURL, getDFPBackendURL } from '../../../core/src/utils/dfp.mjs';
import { getLiveApiURL, getTestApiURL } from '../../../core/src/utils/api.mjs';
import { isTestPublicToken } from '../../../core/src/utils/index.mjs';

const buildFinalConfig = (clientName, opts = {})=>{
    const { cookieOptions, keepSessionAlive } = opts;
    return {
        cookieOptions,
        keepSessionAlive,
        endpoints: {
            testAPIURL: getTestApiURL(opts),
            liveAPIURL: getLiveApiURL(opts),
            dfpBackendURL: getDFPBackendURL(opts),
            dfpCdnURL: getDFPCdnURL(opts),
            clientsideServicesIframeURL: opts?.endpoints?.clientsideServicesIframeURL ?? CLIENTSIDE_SERVICES_IFRAME_URL
        }
    };
};
/**
 * rawOptions should be the original object passed into the client, not the output from buildFinalConfig
 */ const hasCustomApiEndpoint = (token, rawOptions = {})=>{
    // endpointOptions is deprecated, but we still need to account for it
    const { customBaseUrl, endpointOptions } = rawOptions;
    return isTestPublicToken(token) ? !!(customBaseUrl || endpointOptions?.testApiDomain) : !!(customBaseUrl || endpointOptions?.apiDomain);
};

export { buildFinalConfig, hasCustomApiEndpoint };
//# sourceMappingURL=config.mjs.map
