import AdapterValidationError from "../../domain/errors/AdapterValidationError.js";
function isConstructor(value) {
    return typeof value === 'function';
}
function requireConstructor(moduleNamespace, exportName) {
    const candidate = moduleNamespace[exportName];
    if (!isConstructor(candidate)) {
        throw new AdapterValidationError(`@git-stunts/git-cas export "${exportName}" is missing or not a constructor`);
    }
    return candidate;
}
/**
 * Loads the git-cas constructors behind one validated adapter boundary.
 *
 * Several adapters need the default `ContentAddressableStore` export plus the
 * `CborCodec` constructor. Centralizing the lookup avoids repeating ad hoc
 * dynamic-import casts across the adapter layer.
 */
export async function loadGitCasConstructors() {
    const moduleNamespace = await import(
    /* webpackIgnore: true */ '@git-stunts/git-cas');
    return {
        ContentAddressableStore: requireConstructor(moduleNamespace, 'default'),
        CborCodecCtor: requireConstructor(moduleNamespace, 'CborCodec'),
    };
}
