import { STYTCH_DFP_CDN_URL, STYTCH_DFP_BACKEND_URL } from '../constants.mjs';
import { getHttpsUrl } from './getHttpsUrl.mjs';
import { logger } from './logger.mjs';

const getDFPBackendURL = (opts)=>{
    const domain = opts?.dfppaUrl ?? opts?.endpointOptions?.dfppaDomain;
    if (domain) {
        const httpsUrl = getHttpsUrl(domain);
        if (httpsUrl) {
            return httpsUrl;
        } else {
            const key = opts?.dfppaUrl ? 'dfppaUrl' : 'dfppaDomain';
            logger.warn(`Unable to use custom DFPPA domain \`${domain}\`. ${key} should be a valid domain.`);
        }
    }
    return opts?.endpoints?.dfpBackendURL ?? STYTCH_DFP_BACKEND_URL;
};
const getDFPCdnURL = (opts)=>{
    const domain = opts?.dfpCdnUrl ?? opts?.endpointOptions?.dfpCdnDomain;
    if (domain) {
        const httpsUrl = getHttpsUrl(domain);
        if (httpsUrl) {
            return httpsUrl;
        } else {
            const key = opts?.dfpCdnUrl ? 'dfpCdnUrl' : 'dfpCdnDomain';
            logger.warn(`Unable to use custom DFP CDN domain \`${domain}\`. ${key} should be a valid domain.`);
        }
    }
    return STYTCH_DFP_CDN_URL;
};

export { getDFPBackendURL, getDFPCdnURL };
//# sourceMappingURL=dfp.mjs.map
