'use strict';
import { createError } from '../../../../fd-toolbox/errors/errors.js';
import { metaErrorMessages } from '../../constants/meta-error-messages-constants.js';

var __defProp=Object['defineProperty'],__name=(_0x599542,_0x5683a5)=>__defProp(_0x599542,'name',{'value':_0x5683a5,'configurable':!![]});const messageConsumers=new Map();function registerConsumer(_0x38bdd6,_0x3f3362){const _0x1304aa=messageConsumers['get'](_0x38bdd6)??[];_0x1304aa['push'](_0x3f3362),messageConsumers['set'](_0x38bdd6,_0x1304aa);}__name(registerConsumer,'registerConsumer');function clearConsumers(_0x2068c3){messageConsumers['set'](_0x2068c3,[]);}__name(clearConsumers,'clearConsumers');async function publishMessage(_0x225a24){try{const _0x242b91=getConsumers(_0x225a24),_0x246b2f={'message':_0x225a24};for(const _0x37b393 of _0x242b91){try{await _0x37b393['consume'](_0x246b2f);}catch{throw createError(metaErrorMessages['messageConsumerError']['replace']('{0}',_0x37b393['constructor']['name']));}}}catch{throw createError(metaErrorMessages['messageServicePublishError']);}}__name(publishMessage,'publishMessage');function getConsumers(_0xd82091){const _0x4f4a92=_0xd82091['constructor']['name'];return messageConsumers['get'](_0x4f4a92)??[];}__name(getConsumers,'getConsumers');

export { clearConsumers, publishMessage, registerConsumer };
