import { camelCase } from "es-toolkit";
import { maybeSingleValueToArray } from "./maybeSingleValueToArray";
export function getEndpointId({ namespace, path, method, sdkMethodName, operationId, isWebhook, }) {
    if (path == null) {
        return undefined;
    }
    const endpointName = method != null && path != null
        ? `${method}/${path}`
        : method != null
            ? method
            : path;
    if (endpointName == null) {
        return undefined;
    }
    return `${getPrefix(isWebhook)}${getFullyQualifiedNamespace(namespace)}.${getEndpointName(sdkMethodName, operationId, endpointName)}`;
}
function getPrefix(isWebhook) {
    return isWebhook ? "subpackage_" : "endpoint_";
}
function getFullyQualifiedNamespace(namespace) {
    return namespace != null
        ? maybeSingleValueToArray(namespace)
            ?.map((member) => camelCase(member))
            .join(".")
        : "";
}
function getEndpointName(sdkMethodName, operationId, endpointName) {
    return (camelCase(sdkMethodName ?? "") || operationId || camelCase(endpointName));
}
