<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">define(['underscore','Magento_Checkout/js/model/quote','Magento_Checkout/js/model/payment/method-list','Magento_Checkout/js/action/select-payment-method'],function(_,quote,methodList,selectPaymentMethod){'use strict';var isFreePaymentMethod=function(paymentMethod){return paymentMethod.method==='free';},getGrandTotal=function(){return quote.totals()['grand_total'];};return{isFreeAvailable:false,setPaymentMethods:function(methods){var freeMethod,filteredMethods,methodIsAvailable,methodNames;freeMethod=_.find(methods,isFreePaymentMethod);this.isFreeAvailable=!!freeMethod;if(freeMethod&amp;&amp;getGrandTotal()&lt;=0){methods.splice(0,methods.length,freeMethod);selectPaymentMethod(freeMethod);}
filteredMethods=_.without(methods,freeMethod);if(filteredMethods.length===1){selectPaymentMethod(filteredMethods[0]);}else if(quote.paymentMethod()){methodIsAvailable=methods.some(function(item){return item.method===quote.paymentMethod().method;});if(!methodIsAvailable){selectPaymentMethod(null);}}
methodNames=_.pluck(methods,'method');_.map(methodList(),function(existingMethod){var existingMethodIndex=methodNames.indexOf(existingMethod.method);if(existingMethodIndex!==-1){methods[existingMethodIndex]=existingMethod;}});methodList(methods);},getAvailablePaymentMethods:function(){var allMethods=methodList().slice(),grandTotalOverZero=getGrandTotal()&gt;0;if(!this.isFreeAvailable){return allMethods;}
if(grandTotalOverZero){return _.reject(allMethods,isFreePaymentMethod);}
return _.filter(allMethods,isFreePaymentMethod);}};});</pre></body></html>