"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMessageRendererRegistry = createMessageRendererRegistry;
exports.registerMessageRenderer = registerMessageRenderer;
exports.getMessageRenderer = getMessageRenderer;
exports.mergeMessageRendererRegistries = mergeMessageRendererRegistries;
const defaultRenderers = new WeakSet();
function createMessageRendererRegistry() {
    return {};
}
function registerMessageRenderer(registry, contentType, renderer, options) {
    const existingRenderer = registry[contentType];
    if (process.env.NODE_ENV !== 'production' &&
        existingRenderer &&
        !defaultRenderers.has(existingRenderer)) {
        // eslint-disable-next-line no-console
        console.warn(`registerMessageRenderer: overwriting existing renderer for content type "${contentType}"`);
    }
    const registeredRenderer = renderer;
    if (options === null || options === void 0 ? void 0 : options.isDefault) {
        defaultRenderers.add(registeredRenderer);
    }
    Object.assign(registry, {
        [contentType]: registeredRenderer,
    });
    return registry;
}
function getMessageRenderer(registry, contentType) {
    var _a;
    return (_a = registry[contentType]) === null || _a === void 0 ? void 0 : _a.component;
}
function mergeMessageRendererRegistries(defaultRegistry, customRegistry) {
    return Object.assign(Object.assign({}, defaultRegistry), customRegistry);
}
//# sourceMappingURL=messageTypeRegistry.js.map
