/**
 * Type Universe — Raw Bindings JSON Types & Factory Functions
 *
 * Raw JSON type shapes matching tsbindgen <Namespace>/bindings.json,
 * factory functions for TypeId creation, and primitive ↔ nominal mappings.
 */
// ═══════════════════════════════════════════════════════════════════════════
// FACTORY FUNCTIONS
// ═══════════════════════════════════════════════════════════════════════════
/**
 * Create a TypeId from components.
 */
export const makeTypeId = (stableId, clrName, assemblyName, tsName) => ({
    stableId,
    clrName,
    assemblyName,
    tsName,
});
/**
 * Parse a stableId into assemblyName and clrName.
 */
export const parseStableId = (stableId) => {
    const colonIndex = stableId.indexOf(":");
    if (colonIndex === -1)
        return undefined;
    return {
        assemblyName: stableId.slice(0, colonIndex),
        clrName: stableId.slice(colonIndex + 1),
    };
};
/**
 * Resolve the canonical stableId for a raw CLR type entry.
 *
 * tsbindgen payloads should provide `stableId` directly. Some synthetic test
 * fixtures still only provide the canonical components (`assemblyName`,
 * `clrName`). When both components are present, the canonical stableId is
 * deterministic and identical to what tsbindgen would have emitted.
 */
export const resolveRawTypeStableId = (rawType) => {
    if (typeof rawType.stableId === "string" && rawType.stableId.length > 0) {
        return rawType.stableId;
    }
    if (typeof rawType.assemblyName === "string" &&
        rawType.assemblyName.length > 0 &&
        typeof rawType.clrName === "string" &&
        rawType.clrName.length > 0) {
        return `${rawType.assemblyName}:${rawType.clrName}`;
    }
    return undefined;
};
// ═══════════════════════════════════════════════════════════════════════════
// PRIMITIVE ↔ NOMINAL MAPPINGS
// ═══════════════════════════════════════════════════════════════════════════
/**
 * Mapping from TS primitive type names to their CLR stableIds.
 *
 * This enables normalizing `primitiveType("string")` to the canonical
 * `System.String` nominal type for member lookups.
 */
export const PRIMITIVE_TO_STABLE_ID = new Map([
    ["string", "System.Private.CoreLib:System.String"],
    ["number", "System.Private.CoreLib:System.Double"],
    ["int", "System.Private.CoreLib:System.Int32"],
    ["boolean", "System.Private.CoreLib:System.Boolean"],
    ["char", "System.Private.CoreLib:System.Char"],
]);
/**
 * Mapping from CLR stableIds back to TS primitive type names.
 *
 * This enables the emitter to use primitive syntax when appropriate.
 */
export const STABLE_ID_TO_PRIMITIVE = new Map([
    ["System.Private.CoreLib:System.String", "string"],
    ["System.Private.CoreLib:System.Double", "number"],
    ["System.Private.CoreLib:System.Int32", "int"],
    ["System.Private.CoreLib:System.Boolean", "boolean"],
    ["System.Private.CoreLib:System.Char", "char"],
]);
//# sourceMappingURL=raw-bindings-types.js.map