"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiPrefix = apiPrefix;
exports.apiVersion = apiVersion;
exports.apiRoute = apiRoute;
exports.apiPath = apiPath;
exports.versionedApiRoute = versionedApiRoute;
exports.versionedApiPath = versionedApiPath;
exports.docsRoute = docsRoute;
exports.docsPath = docsPath;
exports.docsJsonPath = docsJsonPath;
exports.docsYamlPath = docsYamlPath;
exports.consoleLoginPath = consoleLoginPath;
exports.sandboxPath = sandboxPath;
exports.joinPath = joinPath;
const DEFAULT_API_PREFIX = 'api';
const DEFAULT_API_VERSION = '1';
function apiPrefix(config) {
    return normalizePath(config.get('API_PREFIX') ?? DEFAULT_API_PREFIX);
}
function apiVersion(config) {
    return normalizeVersion(config.get('API_VERSION') ?? DEFAULT_API_VERSION);
}
function apiRoute(config, ...parts) {
    return joinPath(apiPrefix(config), ...parts);
}
function apiPath(config, ...parts) {
    return `/${apiRoute(config, ...parts)}`;
}
function versionedApiRoute(config, ...parts) {
    return apiRoute(config, `v${apiVersion(config)}`, ...parts);
}
function versionedApiPath(config, ...parts) {
    return `/${versionedApiRoute(config, ...parts)}`;
}
function docsRoute(config) {
    return apiRoute(config, 'docs');
}
function docsPath(config) {
    return apiPath(config, 'docs');
}
function docsJsonPath(config) {
    return apiPath(config, 'docs-json');
}
function docsYamlPath(config) {
    return apiPath(config, 'docs-yaml');
}
function consoleLoginPath(config) {
    return versionedApiPath(config, 'console', 'login');
}
function sandboxPath(config) {
    return versionedApiPath(config, 'sandbox');
}
function joinPath(...parts) {
    return parts.map((part) => normalizePath(part)).filter(Boolean).join('/');
}
function normalizePath(value) {
    return value
        .trim()
        .replace(/\\/g, '/')
        .replace(/^\/+|\/+$/g, '')
        .replace(/\/+/g, '/');
}
function normalizeVersion(value) {
    return value.trim().replace(/^v/i, '') || DEFAULT_API_VERSION;
}
//# sourceMappingURL=api-paths.js.map