// eslint-disable-next-line no-restricted-imports -- heritage resolution is a frontend conversion boundary.
import { resolveHeritageTypeName } from "../type-system/internal/registry-helpers-extraction.js";
export const resolveHeritageReferenceType = (typeNode, ctx) => {
    const converted = ctx.typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(typeNode));
    const resolvedName = resolveHeritageTypeName(typeNode, ctx.checker, ctx.sourceRoot, ctx.rootNamespace);
    if (!resolvedName) {
        return converted;
    }
    if (converted.kind === "referenceType") {
        return {
            ...converted,
            name: resolvedName,
        };
    }
    const typeArguments = typeNode.typeArguments?.map((typeArgument) => ctx.typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(typeArgument)));
    return {
        kind: "referenceType",
        name: resolvedName,
        ...(typeArguments && typeArguments.length > 0 ? { typeArguments } : {}),
    };
};
//# sourceMappingURL=heritage-reference-type.js.map