(function(){'use strict';var _regenCounts={};var MAX_RETRIES=3;var api={validate:function(data){if(!PrimeBridge.validator)return data;var errors=PrimeBridge.validator.validate(data);if(!errors){if(data.paymentMethod&&data.type&&data.paymentMethodFields){var pmErrors=PrimeBridge.validator.validatePaymentMethod(data.paymentMethod.id,data.type,data.paymentMethodFields);if(pmErrors){errors=[pmErrors];}}if(data.country&&!errors){var cErrors=PrimeBridge.validator.validateCountry(data.country);if(cErrors){if(!errors)errors=[];errors.push(cErrors);}}}return errors;},guard:function(data){var txnId=data.txnId||'unknown';_regenCounts[txnId]=(_regenCounts[txnId]||0)+1;if(_regenCounts[txnId]>MAX_RETRIES){console.warn('[EventGuard] Max retries for '+txnId+' — releasing as-is');return data;}var errors=this.validate(data);if(!errors)return data;console.warn('[EventGuard] ⛔ Event rejected:',errors);if(PrimeBridge.generator){var newData=PrimeBridge.generator.composeEvent(data.type);if(newData&&newData.txnId){newData.txnId=data.txnId;}return this.guard(newData||data);}return data;},wrapCompose:function(originalFn){var self=this;return function(){var args=arguments;var result=originalFn.apply(this,args);if(!result)return result;return self.guard(result);};}};window.PrimeBridge=window.PrimeBridge||{};PrimeBridge.eventGuard=api;})();