"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createExchange = createExchange;
function createExchange(messagePrefix, postMessage) {
    const messageNameToType = (name) => {
        return [messagePrefix, name].join('.');
    };
    const typedPostMessage = async (message) => {
        const type = messageNameToType(message.type);
        message = {
            ...message,
            type,
        };
        return postMessage(message);
    };
    return {
        messageNameToType,
        postMessage: typedPostMessage,
        createNamespaced: (namespace) => createExchange(messageNameToType(namespace), postMessage),
    };
}
//# sourceMappingURL=Exchange.js.map