import{W as e}from"./provider-constants-fc252349.js";import{i as r}from"./aliasFilter-2aa038b5.js";import{e as t}from"./extractQuote-96a6b874.js";const n=(e,r,t)=>{if(e===r)return!0;const n=Math.max(Math.abs(e),Math.abs(r));return Math.abs((e-r)/n)<=t};var a;function o(r){return r&&r.provider.alias===e}function u(e){return e.slice().sort((e,r)=>r.receiveAmount.value===e.receiveAmount.value?function(e,r){return o(e)?-1:o(r)?1:e.provider.alias.localeCompare(r.provider.alias)}(e,r):r.receiveAmount.value-e.receiveAmount.value)}function s(e){return{alias:e.provider.alias,name:e.provider.name,logo:e.provider.logoUrl,partner:e.provider.partner,fees:e.fees.total.value,rate:e.rate,receivedAmount:e.receiveAmount.value}}!function(e){e.HIDDEN="HIDDEN",e.MARKETED="MARKETED"}(a||(a={}));const i=new Set(["CVE","IDR","ISK","BIF","CLP","DJF","GNF","ISK","JPY","KMF","KRW","PYG","RWF","UGX","UYI","VND","VUV","XAF","XOF","XPF"]),c=e=>i.has(e),l=e=>{const r=e.paymentOptions.filter(e=>!e.disabled).find(e=>"BANK_TRANSFER"===e.payIn);return r||e.paymentOptions[0]};function v(e,r,t,a,o){const u=c(e)?.5:0,s=(i=o*(r-a)-u,Math.floor(100*i)/100);var i;const l=n(t,s,1e-5);return parseFloat(((!l&&!(t>s)?s-t:0)/o).toFixed(2))}function m(e,n){var o;const u=null===(o=e.providers.find(e=>r(e.alias)))||void 0===o?void 0:o.quotes[0].rate;return{quotes:e.providers.map(o=>{const s=n&&r(o.alias)?function(e){const r=l(e);return{fee:r.fee.total+r.fee.discount,rate:e.rate,receivedAmount:r.targetAmount,dateCollected:new Date}}(n):t(o.quotes,e.targetCurrency),i=n?n.rate:u;return function(e,r,t,n){const o=v(e.targetCurrency,e.sendAmount,t.receivedAmount,t.fee,n),u=function(e,r,t){const n=[];return e>0&&n.push({type:a.MARKETED,amount:{value:e,currency:t}}),r>0&&n.push({type:a.HIDDEN,amount:{value:r,currency:t}}),n}(t.fee,o,e.sourceCurrency);return{provider:{alias:r.alias,name:r.name,logoUrl:r.logo,partner:r.partner},route:{sourceCurrency:e.sourceCurrency,targetCurrency:e.targetCurrency},rate:t.rate,fees:{breakdown:u,total:{value:t.fee+o,currency:e.sourceCurrency}},receiveAmount:{value:t.receivedAmount,currency:e.targetCurrency},sendAmount:{value:e.sendAmount,currency:e.sourceCurrency},deliveryEstimation:t.deliveryEstimation}}(e,o,s,i)})}}export{a as F,s as a,o as i,n,u as s,m as t};
//# sourceMappingURL=transformQuotesResponseV2-3494db02.js.map
