import { LIVE_API_URL, TEST_API_URL } from '../constants.mjs';
import { getHttpsUrl } from './getHttpsUrl.mjs';
import { logger } from './logger.mjs';

const getLiveApiURL = (opts)=>{
    const domain = opts?.customBaseUrl ?? opts?.endpointOptions?.apiDomain;
    if (domain) {
        const httpsUrl = getHttpsUrl(domain);
        if (httpsUrl) {
            return httpsUrl;
        } else {
            const key = opts?.customBaseUrl ? 'customBaseUrl' : 'apiDomain';
            logger.warn(`Unable to use custom API domain \`${domain}\`. ${key} should be a valid domain.`);
        }
    }
    return opts?.endpoints?.liveAPIURL ?? LIVE_API_URL;
};
const getTestApiURL = (opts)=>{
    const domain = opts?.customBaseUrl ?? opts?.endpointOptions?.testApiDomain;
    if (domain) {
        const httpsUrl = getHttpsUrl(domain);
        if (httpsUrl) {
            return httpsUrl;
        } else {
            const key = opts?.customBaseUrl ? 'customBaseUrl' : 'testApiDomain';
            logger.warn(`Unable to use custom API domain \`${domain}\`. ${key} should be a valid domain.`);
        }
    }
    return opts?.endpoints?.testAPIURL ?? TEST_API_URL;
};

export { getLiveApiURL, getTestApiURL };
//# sourceMappingURL=api.mjs.map
