"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1025],{39499:function(e,t,a){a.d(t,{fH:function(){return nA}});var n=a(46231),r=a(20258),l=a(70079),o=a(35250),i=a(77874),c=a(20215),s=a(72911),u=a(2473),d=a(29107),p=a(20235),m=a(61969),y=a(36623),h=a(48959),x=a(48487),f=a(90221),b=a(55203),j=a(65163),C=a(73040),g=a(97853),w=a(89318),T=a(47515),v=a(12216),E=a(26943),A=a(87677),I=a(78594),S=a(86481),k=a(10741),O=a(18255),N=a(24458),_=a(94788),Z=a(10340),D=a(54034),P=a(64616),F=a(46611),R=a(80324),L=a(77713),B=a(50535),U=a(44419),M=a(29406),$=a(43015),Y={FAST:{title:"calculator.breakdown.paymentOptionSelect.products.fast.title",description:"calculator.breakdown.paymentOptionSelect.products.fast.description"},CHEAP:{title:"calculator.breakdown.paymentOptionSelect.products.cheap.title",description:"calculator.breakdown.paymentOptionSelect.products.cheap.description"},EASY:{title:"calculator.breakdown.paymentOptionSelect.products.easy.title",description:"calculator.breakdown.paymentOptionSelect.products.easy.description"},JUST_FAST:{title:"calculator.breakdown.paymentOptionSelect.products.just_fast.title",description:"calculator.breakdown.paymentOptionSelect.products.just_fast.description"},ADVANCED:{title:"calculator.breakdown.paymentOptionSelect.products.advanced.title",description:"calculator.breakdown.paymentOptionSelect.products.advanced.description"},BALANCE:{title:"calculator.breakdown.paymentOptionSelect.products.balance.title",description:"calculator.breakdown.paymentOptionSelect.products.balance.description"},FAST_BRL:{title:"calculator.breakdown.paymentOptionSelect.products.fast_brl.title",description:"calculator.breakdown.paymentOptionSelect.products.fast_brl.description"},STANDARD_BRL:{title:"calculator.breakdown.paymentOptionSelect.products.standard_brl.title",description:"calculator.breakdown.paymentOptionSelect.products.standard_brl.description"}},Q={BANK_TRANSFER:{title:"calculator.breakdown.paymentOptionSelect.bankTransfer",description:"calculator.breakdown.paymentOptionSelect.bankTransfer.description"},TRUSTLY:{title:"calculator.breakdown.paymentOptionSelect.trustly",description:"calculator.breakdown.paymentOptionSelect.trustly.description"},SWIFT:{title:"calculator.breakdown.paymentOptionSelect.swift",description:"calculator.breakdown.paymentOptionSelect.swift.description"},IDEAL:{title:"calculator.breakdown.paymentOptionSelect.ideal",description:"calculator.breakdown.paymentOptionSelect.ideal.description"},BALANCE:{title:"calculator.breakdown.paymentOptionSelect.balance",description:"calculator.breakdown.paymentOptionSelect.balance.description"},APPLE_PAY:{title:"calculator.breakdown.paymentOptionSelect.applePay",description:"calculator.breakdown.paymentOptionSelect.applePay.description"},BOLETO:{title:"calculator.breakdown.paymentOptionSelect.boleto"},DIRECT_DEBIT:{title:"calculator.breakdown.paymentOptionSelect.directDebit",description:"calculator.breakdown.paymentOptionSelect.directDebit.description"},POLI:{title:"calculator.breakdown.paymentOptionSelect.poli",description:"calculator.breakdown.paymentOptionSelect.poli.description"},SOFORT:{title:"calculator.breakdown.paymentOptionSelect.sofort",description:"calculator.breakdown.paymentOptionSelect.sofort.description"},BILL_PAYMENT:{title:"calculator.breakdown.paymentOptionSelect.billPayment",description:"calculator.breakdown.paymentOptionSelect.billPayment.description"},OSKO:{title:"calculator.breakdown.paymentOptionSelect.osko"},PAYNOW:{title:"calculator.breakdown.paymentOptionSelect.paynow",description:"calculator.breakdown.paymentOptionSelect.paynow.description"},FPX:{title:"calculator.breakdown.paymentOptionSelect.fpx",description:"calculator.breakdown.paymentOptionSelect.fpx.description"},PROMPT_PAY:{title:"calculator.breakdown.paymentOptionSelect.promptPay"},FAST_DIRECT_DEBIT:{title:"calculator.breakdown.paymentOptionSelect.fastdirectdebit",description:"calculator.breakdown.paymentOptionSelect.fastdirectdebit.description"},INTERAC:{title:"calculator.breakdown.paymentOptionSelect.interac",description:"calculator.breakdown.paymentOptionSelect.interac.description"},PIX:{title:"calculator.breakdown.paymentOptionSelect.pix",description:"calculator.breakdown.paymentOptionSelect.pix.description"},ALIPAY:{title:"calculator.breakdown.paymentOptionSelect.alipay"},HK_FPS_ID:{title:"calculator.breakdown.paymentOptionSelect.hk_fps_id",description:"calculator.breakdown.paymentOptionSelect.hk_fps_id.description"},PISP:{title:"calculator.breakdown.paymentOptionSelect.pisp",description:"calculator.breakdown.paymentOptionSelect.pisp.description"},BANKGIRO:{title:"calculator.breakdown.paymentOptionSelect.bankgiro",description:"calculator.breakdown.paymentOptionSelect.bankgiro.description"},INSTA_DEBIT:{title:"calculator.breakdown.paymentOptionSelect.insta_debit",description:"calculator.breakdown.paymentOptionSelect.insta_debit.description"},PAYPAL:{title:"calculator.breakdown.paymentOptionSelect.paypal",description:"calculator.breakdown.paymentOptionSelect.paypal.description"},VENMO_PUSH:{title:"calculator.breakdown.paymentOptionSelect.venmo_push",description:"calculator.breakdown.paymentOptionSelect.venmo_push.description"},CARD:{title:"calculator.breakdown.paymentOptionSelect.card",description:"calculator.breakdown.paymentOptionSelect.card.description"},DEBIT:{title:"calculator.breakdown.paymentOptionSelect.debit",description:"calculator.breakdown.paymentOptionSelect.debit.description"},MAESTRO:{title:"calculator.breakdown.paymentOptionSelect.debit"},INTERNATIONAL_DEBIT:{title:"calculator.breakdown.paymentOptionSelect.debit"},INT_DEBIT_WITH_EUROPEAN_CARD:{title:"calculator.breakdown.paymentOptionSelect.debit"},MC_BUSINESS_DEBIT:{title:"calculator.breakdown.paymentOptionSelect.debit"},MC_DEBIT_OR_PREPAID:{title:"calculator.breakdown.paymentOptionSelect.debit"},VISA_BUSINESS_DEBIT:{title:"calculator.breakdown.paymentOptionSelect.debit"},VISA_DEBIT_OR_PREPAID:{title:"calculator.breakdown.paymentOptionSelect.debit"},CREDIT:{title:"calculator.breakdown.paymentOptionSelect.credit",description:"calculator.breakdown.paymentOptionSelect.credit.description"},INTERNATIONAL_CREDIT:{title:"calculator.breakdown.paymentOptionSelect.credit"},INT_CREDIT_WITH_EUROPEAN_CARD:{title:"calculator.breakdown.paymentOptionSelect.credit"},MC_CREDIT:{title:"calculator.breakdown.paymentOptionSelect.credit"},MC_BUSINESS_CREDIT:{title:"calculator.breakdown.paymentOptionSelect.credit"},VISA_CREDIT:{title:"calculator.breakdown.paymentOptionSelect.credit"},VISA_BUSINESS_CREDIT:{title:"calculator.breakdown.paymentOptionSelect.credit"}},G={CAD:{BANK_TRANSFER:{title:"calculator.breakdown.paymentOptionSelect.bankTransfer.cad",description:"calculator.breakdown.paymentOptionSelect.bankTransfer.cad.description"},DIRECT_DEBIT:{title:"calculator.breakdown.paymentOptionSelect.directDebit.cad",description:"calculator.breakdown.paymentOptionSelect.directDebit.cad.description"},SWIFT:{description:"calculator.breakdown.paymentOptionSelect.swift.cad.description"}},USD:{BANK_TRANSFER:{title:"calculator.breakdown.paymentOptionSelect.bankTransfer.usd"},SWIFT:{title:"calculator.breakdown.paymentOptionSelect.swift.usd",description:"calculator.breakdown.paymentOptionSelect.swift.usd.description"},CREDIT:{description:"calculator.breakdown.paymentOptionSelect.credit.usd.description"},DIRECT_DEBIT:{description:"calculator.breakdown.paymentOptionSelect.directDebit.usd.description"}},GBP:{BANK_TRANSFER:{title:"calculator.breakdown.paymentOptionSelect.bankTransfer.gbp",description:"calculator.breakdown.paymentOptionSelect.bankTransfer.gbp.description"},SWIFT:{title:"calculator.breakdown.paymentOptionSelect.swift.gbp"},PISP:{title:"calculator.breakdown.paymentOptionSelect.pisp.gbp"}},AED:{BANK_TRANSFER:{description:"calculator.breakdown.paymentOptionSelect.bankTransfer.aed.description"}},HKD:{BANK_TRANSFER:{title:"calculator.breakdown.paymentOptionSelect.bankTransfer.hkd",description:"calculator.breakdown.paymentOptionSelect.bankTransfer.hkd.description"}},JPY:{CARD:{title:"calculator.breakdown.paymentOptionSelect.card.jpy"}},CHF:{SOFORT:{description:"calculator.breakdown.paymentOptionSelect.sofort.chf.description"}},SEK:{TRUSTLY:{description:"calculator.breakdown.paymentOptionSelect.trustly.sek.description"}},PLN:{TRUSTLY:{description:"calculator.breakdown.paymentOptionSelect.trustly.pln.description"}}};function W(){return"calculator.breakdown.paymentOptionSelect.methods.heading"}function V(e){let t=Y[e.toUpperCase()];return t?t.title:e.toUpperCase()}function q(e,t){let{currencySpecificPaymentMethodTranslations:a,paymentMethodTranslations:n}=K(e,t);return(null==a?void 0:a.title)||(null==n?void 0:n.title)||e.toUpperCase()}function H(e,t){let{currencySpecificPaymentMethodTranslations:a,paymentMethodTranslations:n}=K(e,t);return(null==a?void 0:a.description)||(null==n?void 0:n.description)||null}function K(e,t){let a=e.toUpperCase(),n=G[t]||null,r=Q[a]||null;return{currencySpecificPaymentMethodTranslations:(null==n?void 0:n[a])||null,paymentMethodTranslations:r}}function X({fee:e,currency:t,intl:a}){let{payIn:n,transferwise:r}=e,l=n+r;return l?z(l,t,a):{key:"calculator.breakdown.paymentOptionSelect.noFeeWithoutDash"}}function z(e,t,a){return{key:"calculator.breakdown.paymentOptionSelect.feeWithoutDash",params:{payInFee:(0,r.lb)(e,t,a.locale)}}}function J(e,t){return e.reduce((e,a)=>e||(t(a)?a:null),null)}function ee(e,t){let a;return(...n)=>{clearTimeout(a),a=setTimeout(()=>{a=void 0,e(...n)},t)}}var et=(e,t)=>{if(!e)return null;let a=e.find(e=>e.currency===t);return a?a.amount.value:null},ea=({balances:e,currency:t,balanceId:a})=>{if(!e)return null;if(!a)return et(e,t);let n=e.find(e=>(null==e?void 0:e.id)===a);return n?n.amount.value:null},en=e=>(null==e?void 0:e.payInMethod)==="BALANCE"&&(null==e?void 0:e.payInId)?Number.parseInt(e.payInId,10):null;function er(e,t){return e.reduce((e,a)=>{let r=t(a);return(0,n.EZ)((0,n.ih)({},e),{[r]:[...e[r]||[],a]})},{})}function el(e){return e?Math.round((new Date(e).getTime()-new Date().getTime())/36e5):null}var eo=e=>e.sourceCurrency===e.targetCurrency;function ei(e){return null!=e}var ec=e=>{let t="FIXED"===e.rateType,a=!!e.guaranteedTargetAmount,{guaranteedTargetRateFluctuationBuffer:n}=e;return!t&&a&&!!n&&n>0};function es(e){return"BALANCE"===e}var eu=e=>{let t=["BRL_TAX","VAT","TAX","GST","TCS"];return e.price.items.some(e=>t.includes(e.type))},ed=(e,t)=>e.preferences.find(e=>e.payInId===t)||null,ep=(e,t)=>e.preferences.find(e=>e.currencyCode===t),em=(e,t,a)=>(null==e?void 0:e.preferences.find(({payInType:e,currencyCode:n,payInId:r})=>t===e&&a===n&&!r))||null,ey=({paymentPreferences:e,selectedPayIn:t,preferenceCurrency:a})=>t.id?ed(e,t.id):em(e,t.method,a),eh="BALANCE",ex="APPLE_PAY",ef=["BANK_TRANSFER","DEBIT","CREDIT","TRUSTLY","SWIFT","IDEAL",eh,ex,"BOLETO","DIRECT_DEBIT","POLI","SOFORT","BILL_PAYMENT","OSKO","PAYNOW","FPX","PROMPT_PAY","FAST_DIRECT_DEBIT","INTERAC","PIX","ALIPAY","HK_FPS_ID","PISP","BANKGIRO","INSTA_DEBIT","PAYPAL","VENMO_PUSH"],eb={[ex]:(()=>{try{return(null==window?void 0:window.ApplePaySession)&&window.ApplePaySession.canMakePayments()&&window.ApplePaySession.supportsVersion(2)}catch(e){return!1}})()};function ej(e){return e.every(e=>!!e.payInProduct)}function eC(e){let t=e.payIn.toUpperCase(),a=ef.includes(t),n=!Object.prototype.hasOwnProperty.call(eb,t)||eb[t];return!!(a&&n)}function eg(e){let t=!e.disabled;return!!(eC(e)&&t)}function ew(e,t){let{paymentOptions:a,paymentPreferences:n}=e;if(!t)return null;if(t){let e=t.id?null==n?void 0:n.find(({id:e})=>e===t.id):null==n?void 0:n.find(({payIn:e,id:a})=>!a&&e===t.method);if(e)return a.find(({payIn:t})=>t===e.method)||null}return null}var eT=e=>e.payInId&&e.payInMethod?{method:e.payInMethod,id:e.payInId}:e.preferredPayIn?{method:e.preferredPayIn,id:e.preferredPayInId||null}:null;function ev({paymentOptions:e},t){let a=e.filter(e=>eg(e)),n=e.filter(e=>eC(e));return eE(a,t)||eE(n,t)||eE(e,t)}function eE(e,t){return J(e,e=>e.payIn===t)||e[0]}function eA(e){return J(e,e=>e.payIn===eh)}var eI=(e,t)=>t.filter(t=>(null==t?void 0:t.path)===e)[0]||null,eS=e=>{let{disabled:t,disabledReason:a}=e;return t&&a?a:null},ek=(e,t)=>{let{disabled:a,disabledReason:n}=t;return a&&n&&n.path===e?n:null},eO=(e,t,a)=>eI(e,a)||ek(e,t),eN=e=>{let{payIn:t}=e;return t===eh},e_=(e,t)=>{if(!e)return null;let a=eN(e)&&eS(e);return a&&"targetAmount"!==a.path?a:eO("sourceAmount",e,t)},eZ=e=>{if(!e)return null;let{disabled:t,disabledReason:a}=e;return t&&a&&"error.payInmethod.disabled"===a.code?a.message:null},eD=(e,t)=>e?eO("targetAmount",e,t):null,eP=({quote:e,preselectedPaymentOption:t,selectedPreferredPayIn:a,shouldShowPaymentPreferences:n})=>{if(!e)return{paymentOption:null,selectedPayIn:null};if(t)return{paymentOption:function({paymentOptions:e,id:t},a){let n=J(e,e=>e.payIn===a);if(n)return n;throw Error(`Preselected PaymentOption ${a} is not present in quote: ${t}`)}(e,t),selectedPayIn:{id:e.payInId||null,method:t}};let r=a||eT(e);if(n){let t=ew(e,r);if(t)return{paymentOption:t,selectedPayIn:{id:r.id,method:r.method,setBy:null==a?void 0:a.setBy}}}let l=ev(e,null==r?void 0:r.method),o=l.payIn!==(null==r?void 0:r.method);return{paymentOption:l,selectedPayIn:{id:null,method:l.payIn,setBy:o?void 0:null==a?void 0:a.setBy}}};function eF(e){return"DEBIT"===e.payIn||"CREDIT"===e.payIn||"APPLE_PAY"===e.payIn}var eR=(0,l.createContext)(null),eL=({context:e=null,children:t})=>(0,o.jsx)(eR.Provider,{value:e,children:t}),eB=()=>{let e=(0,l.useContext)(eR);return void 0===e&&console.warn("useProductContext must be used within a ProductContextProvider"),e};eL.displayName="ProductContextProvider";var eU=({quote:e,selectedPaymentOption:t,showFeesAsAddition:a})=>{let{formatMessage:n,locale:l}=(0,i.Z)();if(ec(e)){let i=n({id:"calculator.breakdown.guaranteedTargetRateFluctuationBuffer.title"}),s=e.guaranteedTargetRateFluctuationBuffer,u={label:i,description:(0,o.jsxs)(o.Fragment,{children:[n({id:"calculator.breakdown.guaranteedTargetRateFluctuationBuffer.popover.content"},{depositAmount:(0,r.lb)(s,t.sourceCurrency,l)}),(0,o.jsx)("br",{}),(0,o.jsx)("a",{href:"/help/articles/2448314/can-i-send-exact-amounts",target:"_blank",rel:"noopener noreferrer",children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.guaranteedTargetRateFluctuationBuffer.popover.link"})})]})};return{key:"AMOUNT_LOCK",left:(0,r.lb)(s,e.sourceCurrency,l),right:(0,o.jsx)(c.Z,{id:"calculator.breakdown.guaranteedTargetRateFluctuationBuffer.title"}),operator:a?"ADD":"SUBTRACT",explanation:u}}return null},eM=({quote:e,selectedPaymentOption:t})=>{let a=ec(e)||t.fee.discount>0,n=ej(e.paymentOptions);return eo(e)||n&&!a?null:{key:"DIVIDER"}},e$=(0,l.createContext)([]),eY={SEND_CALCULATOR_2_0:"send_calculator_2_0",SEND_CALCULATOR_FORCE_PAYMENT_METHOD_SELECTION:"send_calculator_force_payment_method_selection"},eQ=({context:e,children:t})=>(0,o.jsx)(e$.Provider,{value:e,children:t}),eG=()=>{let e=(0,l.useContext)(e$);return void 0===e&&console.warn("useFeaturesContext must be used within a FeaturesProvider"),{isFeatureEnabled:function(t){var a,n;return null!=(n=null==(a=e.find(e=>e.featureName===t))?void 0:a.enabled)&&n}}};eQ.displayName="FeaturesProvider";var eW=e=>{var{className:t="",children:a}=e,r=(0,n.S0)(e,["className","children"]);return(0,o.jsx)(s.Z,(0,n.EZ)((0,n.ih)({size:"md",type:"accent",priority:"tertiary",className:R("btn-unstyled tw-calculator-btn-unstyled p-a-0",t),style:{height:"auto",verticalAlign:"bottom"}},r),{children:a}))};function eV(e,t={}){eq((0,n.EZ)((0,n.ih)({},t),{event:`calculator-${e}`}))}function eq(e={}){var t;try{"undefined"!=typeof window&&window.dataLayer&&"function"==typeof window.dataLayer.push&&(null==(t=window.dataLayer)||t.push((0,n.ih)({},e)))}catch(e){}}var eH=({paymentOptions:e,sourceCurrency:t,selected:a,onChange:r,isEstimated:l=!1})=>{let c=(0,i.Z)(),s=function({paymentOptions:e,sourceCurrency:t,intl:a,feeWithoutDash:n}){let r=function(e){let t=e.every(e=>e.disabled);return e.filter(t?eC:eg)}(e);return ej(r)?function({availablePaymentOptions:e,sourceCurrency:t,intl:a,feeWithoutDash:n}){return{type:"group",label:a.formatMessage({id:"calculator.breakdown.paymentOptionSelect.products.heading"}),options:function({availablePaymentOptions:e,sourceCurrency:t,intl:a,feeWithoutDash:n}){let r=er(e,e=>e.payInProduct);return Object.keys(r).map(e=>{let l=r[e],o=l[0],i=X({fee:o.fee,currency:t,intl:a}),c=(n?"":"- ")+a.formatMessage({id:i.key},i.params);return{type:"option",value:{value:o.payIn,subvalues:l.map(e=>{let n=H(e.payIn,t),r=n?a.formatMessage({id:n}):null;return{payIn:e.payIn,title:a.formatMessage({id:q(e.payIn,t)}),description:r,disabled:e.disabled,disabledReason:e.disabledReason}}),label:a.formatMessage({id:V(e)}),selectedLabel:a.formatMessage({id:`${V(e)}.fee`}),note:c,secondary:a.formatMessage({id:function(e){let t=Y[e.toUpperCase()];return t?t.description:""}(e)},{currency:t})}}})}({availablePaymentOptions:e,sourceCurrency:t,intl:a,feeWithoutDash:n})}}({availablePaymentOptions:r,sourceCurrency:t,intl:a,feeWithoutDash:n}):function({availablePaymentOptions:e,sourceCurrency:t,intl:a}){return{type:"group",label:a.formatMessage({id:W()}),options:function({paymentOptions:e,sourceCurrency:t,intl:a}){return e.map(e=>(function({paymentOption:e,sourceCurrency:t,intl:a}){var n;let r=function({amount:e,currency:t,method:a,intl:n}){return e?z(e,t,n):"SWIFT"===a||"USD"===t&&"BALANCE"!==a?{key:"calculator.breakdown.paymentOptionSelect.bankFeesOnlyWithoutDash"}:{key:"calculator.breakdown.paymentOptionSelect.noExtraFeesWithoutDash"}}({amount:e.fee.payIn,currency:t,method:e.payIn,intl:a}),l=e.disabled?void 0:`- ${a.formatMessage({id:r.key},r.params)}`;return{type:"option",value:{value:e.payIn,label:a.formatMessage({id:q(e.payIn,t)}),selectedLabel:a.formatMessage({id:`${q(e.payIn,t)}.fee`}),note:l,secondary:null==(n=e.disabledReason)?void 0:n.message},disabled:e.disabled}})({paymentOption:e,sourceCurrency:t,intl:a}))}({paymentOptions:e,sourceCurrency:t,intl:a})}}({availablePaymentOptions:r,sourceCurrency:t,intl:a})}({paymentOptions:e,sourceCurrency:t,intl:c,feeWithoutDash:!1}),d=s.options.find(e=>{var t;return e.value.value===a.payIn||(null==(t=e.value.subvalues)?void 0:t.some(e=>a.payIn===e.payIn))}),{sourceAmount:p,targetCurrency:m,targetAmount:y,payIn:h,fee:x}=a;eq({event:"Quote updated",sourceCurrency:a.sourceCurrency,sourceAmount:p,targetCurrency:m,targetAmount:y,currentlySelectedPaymentMethod:h,currentlySelectedPaymentMethodFee:x&&x.total});let f=l?` ${c.formatMessage({id:"calculator.breakdown.paymentOptionSelect.fee.estimated"})}`:"";return(0,o.jsx)(o.Fragment,{children:d?(0,o.jsx)("span",{"data-tracking-id":"calculator-payment-select","data-testid":"calculator-payment-select",children:(0,o.jsx)(u.lq,{items:[s],value:(0,n.EZ)((0,n.ih)({},d.value),{label:`${d.value.selectedLabel}${f}`,note:void 0,secondary:void 0}),renderValue:e=>(0,o.jsx)(u.X5,{title:e.label,note:e.note,description:e.secondary}),renderTrigger:({content:e,className:t})=>(0,o.jsxs)(u.hf,{className:R(t,"btn-unstyled tw-calculator-payment-option-select"),children:[e,(0,o.jsx)(L.ChevronDown,{size:16})]}),onChange:({value:t})=>{let a=e.filter(e=>e.payIn===t)[0];eV("payment-option-changed",{sourceCurrency:a.sourceCurrency,targetCurrency:a.targetCurrency,sourceAmount:a.sourceAmount,targetAmount:a.targetAmount,newlySelectedPaymentMethod:a.payIn,newlySelectedPaymentMethodFee:a.fee&&a.fee.total,previouslySelectedPaymentMethod:h,previouslySelectedPaymentMethodFee:x&&x.total}),r(a,null)}})}):null})},eK=(e,t)=>{let a=t.fee.discount>0,n=0===t.fee.total;return eo(e)&&n&&!a},eX=(e,t,a)=>{let n=ej(e.paymentOptions);return t?"NONE":a&&n?"ADD":n?"SUBTRACT":"NONE"};function ez(e,t){return e?t.fee.total+t.fee.discount:t.fee.payIn}var eJ=(e,t,a,n,l)=>{var i,s;let u=ez(a,t),{feePercentage:p}=t,m=null==(s=null==(i=e.transferFlowConfig)?void 0:i.highAmount)?void 0:s.showFeePercentage;if(a&&!t.fee.discount&&m&&null!==p){let e=(0,r.rl)(p);return`${(0,r.lb)(u,t.sourceCurrency,n)} (${e})`}let y=(0,r.lb)(u,t.sourceCurrency,n);return eF(t)&&l?(0,o.jsx)(d.Z,{title:(0,o.jsx)(c.Z,{id:"calculator.breakdown.cardFee.explanation.title"}),content:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.Z,{id:"calculator.breakdown.cardFee.explanation.description.variableFee",values:{fee:y}}),"APPLE_PAY"===t.payIn?(0,o.jsxs)("span",{children:[" ",(0,o.jsx)(c.Z,{id:"calculator.breakdown.cardFee.explanation.description.applePay"})]}):null,["CREDIT","DEBIT"].includes(t.payIn)?(0,o.jsxs)("span",{children:[" ",(0,o.jsx)(c.Z,{id:"calculator.breakdown.cardFee.explanation.description.cards"})]}):null,(0,o.jsxs)("span",{children:[" ",(0,o.jsx)(c.Z,{id:"calculator.breakdown.cardFee.explanation.description.speed",values:{speed:t.formattedEstimatedDelivery}})]})]}),children:(0,o.jsx)(eW,{"data-testid":"variable-fee",children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.feeUpTo",values:{fee:y}})})}):y},e0=({quote:e,selectedPaymentOption:t,preselectedPaymentOption:a,onChangePaymentOption:n,isScheduled:r=!1,showFeesAsAddition:l=!1,shouldShowPaymentPreferences:s=!1,canShowVariableFees:u=!1})=>{let{formatMessage:d,locale:p}=(0,i.Z)(),{isFeatureEnabled:m}=eG(),y=e.paymentOptions.filter(eg),h=s||!!a||1===y.length,x=eK(e,t),f=ej(e.paymentOptions),b=eX(e,x,l),j=m(eY.SEND_CALCULATOR_2_0);return{key:"PAYMENT_METHOD",operator:b,left:x&&!j?(0,o.jsx)(c.Z,{id:"calculator.breakdown.freeFeeText"}):eJ(e,t,f,p,u),right:(()=>{let a=f?V(t.payInProduct):q(t.payIn,t.sourceCurrency),l=d({id:`${a}.fee`});return h?j?l:r?"BALANCE"===t.payIn?d({id:"calculator.breakdown.withdrawalFeeTextEstimated"}):"DIRECT_DEBIT"===t.payIn?d({id:"calculator.breakdown.paymentOptionSelect.directDebit.estimated.fee"}):`${l} ${d({id:"calculator.breakdown.paymentOptionSelect.fee.estimated"})}`:"DIRECT_DEBIT"===t.payIn&&"USD"===t.sourceCurrency?d({id:`${a}.preselected.fee`}):l:n?(0,o.jsx)(eH,{paymentOptions:e.paymentOptions,sourceCurrency:e.sourceCurrency,selected:t,isEstimated:r,onChange:n}):null})(),amount:ez(f,t)}},e1=(e,t,a)=>{let n=ej(e.paymentOptions);return"DISCOUNT"===t&&n?a?"SUBTRACT":"ADD":"NONE"},e3=(e,t,a,n)=>{let r=ej(e.paymentOptions);return"DISCOUNT"===t.type&&!r&&a&&n?(0,o.jsxs)(o.Fragment,{children:["- ",t.value.label]}):t.value.label},e2=({quote:e,selectedPaymentOption:t,isScheduled:a=!1,showFeesAsAddition:n=!1,allowSubtractionInLabels:r=!1})=>{let{formatMessage:l}=(0,i.Z)(),{isFeatureEnabled:o}=eG(),c=[ej(e.paymentOptions)?"TRANSFERWISE":null,"PAYIN"].filter(ei),s=t.price.items.filter(e=>!c.includes(e.type)),u=o(eY.SEND_CALCULATOR_2_0);return s.map(t=>({key:t.type,left:e3(e,t,n,r),right:e4(t,a,l,u),explanation:e5(t,a,l),operator:e1(e,t.type,n),amount:t.value.amount}))},e4=(e,t,a,n=!1)=>!t||n?e.label:"TRANSFERWISE"===e.type?a({id:"calculator.breakdown.transferwiseFeeTextEstimated"}):"DISCOUNT"===e.type?a({id:"calculator.breakdown.discount.estimated"}):e.label,e5=(e,t,a)=>e.explanation?e.explanation.markdown?{markdown:e.explanation.markdown,links:e.explanation.links,plaintext:e.explanation.plainText}:t&&"DISCOUNT"===e.type?{label:a({id:"calculator.breakdown.discount.popover.title.estimated"}),description:(0,o.jsxs)(o.Fragment,{children:[e.explanation.plainText?(0,o.jsxs)(o.Fragment,{children:[e.explanation.plainText,(0,o.jsx)("br",{}),(0,o.jsx)("br",{})]}):null,(0,o.jsx)(c.Z,{id:"calculator.breakdown.discount.popover.content.estimated"})]})}:{label:e.label,description:e.explanation.plainText}:void 0,e8=e=>{let t=e.price;return null!==t?t.total.value.amount:e.fee.total},e9=(e,t,a)=>{var n,l;let{feePercentage:o}=t,i=null==(l=null==(n=e.transferFlowConfig)?void 0:n.highAmount)?void 0:l.showFeePercentage,c=t.price;if(i&&null!==o){let e=(0,r.rl)(o);return`${(0,r.lb)(t.fee.total,t.sourceCurrency,a)} (${e})`}return null!==c?c.total.value.label:(0,r.lb)(t.fee.total,t.sourceCurrency,a)},e6=(e,t)=>ej(e.paymentOptions)?"NONE":t?"ADD":"SUBTRACT",e7=({quote:e,selectedPaymentOption:t,isScheduled:a=!1,showFeesAsAddition:n=!1})=>{let{locale:r,formatMessage:l}=(0,i.Z)();return!ej(e.paymentOptions)||t.fee.discount>0?{key:"TOTAL_FEES",left:(0,o.jsx)(o.Fragment,{children:e9(e,t,r)}),right:(0,o.jsx)(o.Fragment,{children:a?l({id:"calculator.breakdown.totalFeeTextEstimated"}):t.price.total.label}),operator:e6(e,n),amount:e8(t)}:null},te=()=>(0,o.jsx)(d.Z,{title:(0,o.jsx)(c.Z,{id:"calculator.breakdown.effectiveRateItem.popover.title.brl"}),content:(0,o.jsxs)("span",{children:[(0,o.jsx)(c.Z,{id:"calculator.breakdown.effectiveRateItem.popover.content.brl"})," "]}),children:(0,o.jsx)(eW,{children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.effectiveRateItem.brl"})})}),tt=({selectedPaymentOption:e})=>{let{locale:t}=(0,i.Z)();if(!function({sourceCurrency:e,targetCurrency:t}={}){return e!==t&&("BRL"===e||"BRL"===t)}({sourceCurrency:e.sourceCurrency,targetCurrency:e.targetCurrency}))return null;let a=function(e,t){if(e.targetAmount<=0||e.sourceAmount<=0)return null;if("BRL"===e.sourceCurrency){let a=e.sourceAmount/e.targetAmount,n=(0,r.uf)(a,t,6,"SignificantDigits");return`1 ${e.targetCurrency} = ${n} ${e.sourceCurrency}`}let a=e.targetAmount/e.sourceAmount,n=(0,r.uf)(a,t,6,"SignificantDigits");return`1 ${e.sourceCurrency} = ${n} ${e.targetCurrency}`}(e,t);return a?(0,o.jsxs)("div",{className:"tw-calculator-effective-rate m-t-3",children:[(0,o.jsx)(c.Z,{id:"calculator.breakdown.effectiveRateItem.prefix"})," ",(0,o.jsx)("strong",{children:a})," ",(0,o.jsx)(te,{})]}):null},ta=({quote:e,selectedPaymentOption:t,isEstimated:a,label:n})=>{let{formatMessage:l,locale:o}=(0,i.Z)(),c=e.guaranteedTargetRateFluctuationBuffer||0,s=t.sourceAmount-t.price.total.value.amount-c;return eo(e)?null:{key:"AMOUNT_CONVERTED",left:(0,r.lb)(s,t.sourceCurrency,o),right:n||l(a?{id:"calculator.breakdown.amountText.estimated"}:{id:"calculator.breakdown.amountText"}),operator:"EQUAL"}},tn={fadeIn:"Animations_fadeIn",shimmer:"Animations_shimmer",moveUp:"Animations_moveUp"},tr=class e extends Error{constructor(t,a){super(t.statusText),this.status=t.status,this.statusText=t.statusText,this.body=a,Object.setPrototypeOf(this,e.prototype)}},tl=e=>!!Object.prototype.hasOwnProperty.call(e,"body")&&!!Object.prototype.hasOwnProperty.call(e.body,"errors")&&Array.isArray(e.body.errors);function to(e){return(0,n.ih)({"Content-Type":"application/json",Accept:"application/json","X-Access-Token":"Tr4n5f3rw153","Accept-Language":e||"en"},function(){try{return{"Time-Zone":Intl.DateTimeFormat().resolvedOptions().timeZone}}catch(e){return{}}}())}async function ti(e,t,a){let r=to(t),l=null==a?void 0:a.headers;return fetch(`/gateway${e}`,(0,n.EZ)((0,n.ih)({method:"GET"},a),{headers:(0,n.ih)((0,n.ih)({},r),l)}))}async function tc(e){return e.ok?e.json():e.json().then(t=>{throw new tr(e,t)})}var ts=({profileId:e,quoteId:t})=>{let a=e?`/v3/profiles/${e}/quotes`:"/v3/quotes";return t?`${a}/${t}`:a},tu=({profileId:e,quoteId:t})=>t?`/v1/profiles/${e}/conversion-quotes/${t}`:`/v1/profiles/${e}/conversion-quotes`;async function td({targetCurrency:e,sourceCurrency:t,locale:a,theming:{theme:r,screenMode:l},sendSessionId:o}){let i=await ti(`/v1/send-sessions/${o}/default-quote`,a,{method:"PATCH",body:JSON.stringify(t?{sourceCurrency:t}:{targetCurrency:e}),credentials:"same-origin",headers:(0,n.EZ)((0,n.ih)({},to()),{"X-Visual-Context":`${r}::${l}`})});return(await tc(i)).route}async function tp(e,t){var{profile:a}=e,r=(0,n.S0)(e,["profile"]);let l=ts({profileId:a});return ty((0,n.ih)({profile:a},r),t,l)}async function tm(e,t){var{profile:a}=e,r=(0,n.S0)(e,["profile"]);let l=tu({profileId:a});return ty((0,n.ih)({profile:a},r),t,l)}async function ty(e,t,a){var{profile:r}=e,l=(0,n.S0)(e,["profile"]);let o=(0,n.ih)({},l),i=!r&&!l.user;return tc(await ti(a,t,{method:"POST",credentials:i?"omit":"same-origin",body:JSON.stringify(o)}))}async function th(e,t,a){var{profile:r}=t,l=(0,n.S0)(t,["profile"]);let o=ts({profileId:r,quoteId:null==e?void 0:e.id});return tf((0,n.ih)({},l),a,o)}async function tx(e,t,a){var{profile:r}=t,l=(0,n.S0)(t,["profile"]);let o=tu({profileId:r,quoteId:null==e?void 0:e.id});return tf((0,n.ih)({},l),a,o)}async function tf(e,t,a){var r=(0,n.S0)(e,[]);return tc(await ti(a,t,{method:"PATCH",body:JSON.stringify((0,n.ih)({},r)),credentials:"same-origin",headers:{"Content-Type":"application/merge-patch+json"}}))}async function tb(e,t,a){let r=to(),{length:l,unit:o,resolution:i}=a,c=`/rates/history?source=${encodeURIComponent(e)}&target=${encodeURIComponent(t)}&length=${l}&unit=${o}&resolution=${i}`;try{let e=await fetch(c,{headers:(0,n.EZ)((0,n.ih)({},r),{"Content-Type":"application/json",Accept:"application/json"})});if(!e.ok)throw Error();return await e.json()}catch(e){return[]}}async function tj(e){let t=Object.keys(e).map(t=>`${t}=${e[t]}`);return ti(`/v2/savings?${t.join("&")}`,void 0,{credentials:"omit"}).then(async e=>e.ok?e.json():null).catch(()=>null)}var tC=({children:e,shouldFadeIn:t})=>(0,o.jsx)("div",{className:R(t?tn.fadeIn:null),children:e}),tg="/help/articles/2448203/whats-a-guaranteed-rate",tw=({isFixedRate:e,rateExpirationTime:t,sourceAmount:a,sourceCurrency:n,hideRateExpirationTime:l})=>{let{locale:s,formatMessage:u}=(0,i.Z)();if(e){let e=(0,o.jsx)(c.Z,{id:"BRL"===n?"calculator.breakdown.fixedRateText.enabled.popover.title.brl":"calculator.breakdown.fixedRateText.enabled.popover.title"});return l?e:(0,o.jsx)(d.Z,{title:e,content:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.enabled.popover.content",values:{hours:el(t),sourceAmount:(0,r.lb)(a,n,s)}}),(0,o.jsx)("br",{}),(0,o.jsx)("a",{href:tg,target:"_blank",rel:"noopener noreferrer","aria-label":u({id:"calculator.breakdown.fixedRateText.help.link"}),children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.enabled.popover.link"})})]}),"data-test-id":"fixed-rate-enabled-text",children:(0,o.jsx)(eW,{className:"tw-calculator-rate-text",children:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{"data-tracking-id":"calculator-fixed-rate-tooltip",children:(0,o.jsx)(c.Z,{id:"BRL"===n?"calculator.breakdown.fixedRateText.enabled.brl":"calculator.breakdown.fixedRateText.enabled"})})," ",(0,o.jsx)("span",{style:{whiteSpace:"nowrap"},children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.enabled.hours",values:{hours:el(t)},"data-test-id":"fixed-rate-expiration-time"})})]})})})}return(0,o.jsx)(d.Z,{title:(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.disabled.popover.title"}),content:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.disabled.popover.content"}),(0,o.jsx)("br",{}),(0,o.jsx)("a",{href:tg,target:"_blank",rel:"noopener noreferrer",children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.disabled.popover.link"})})]}),"data-test-id":"fixed-rate-disabled-text",children:(0,o.jsx)(eW,{children:(0,o.jsx)("span",{"data-tracking-id":"calculator-fixed-rate-disabled-tooltip",children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.disabled"})})})})},tT={guaranteedRateText:"RateText_guaranteedRateText"},tv=({isFixedRate:e,rateExpirationTime:t,sourceCurrency:a,hideRateExpirationTime:n,isScheduledTransfer:r})=>{let l=el(t),i="number"==typeof l&&l<1;return r?(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:tT.guaranteedRateText,children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.fixedRateText.current.rate"})}):(0,o.jsxs)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:R("d-inline-flex align-items-center",e?tT.guaranteedRateText:null),children:[e?(0,o.jsx)(L.Lock,{}):(0,o.jsx)(L.Unlock,{}),(0,o.jsx)("span",{style:{marginLeft:"3px"},children:(0,o.jsx)(c.Z,{id:e?"BRL"===a?n?"calculator.breakdown.fixedRateText.enabled.popover.title.brl":"calculator.breakdown.fixedRateText.enabled.brl":"calculator.breakdown.fixedRateText.guaranteed":"calculator.breakdown.fixedRateText.not.guaranteed"})}),!n&&e?(0,o.jsx)("span",{style:{marginLeft:"3px"},children:(0,o.jsx)(c.Z,{id:i?"calculator.breakdown.fixedRateText.enabled.minutes":"calculator.breakdown.fixedRateText.enabled.hours",values:{hours:l,minutes:Math.round((new Date(t).getTime()-new Date().getTime())/6e4)}})}):null]})},tE={rateTextButton:"Rate_rateTextButton",rateTextContainer:"Rate_rateTextContainer",rateContainer:"Rate_rateContainer"},tA=l.lazy(async()=>Promise.all([a.e(5551),a.e(139),a.e(7789)]).then(a.bind(a,97789))),tI={length:30,unit:"day",resolution:"hourly"},tS=({sourceCurrency:e,targetCurrency:t,rate:a,desiredRate:n,quote:s,selectedPaymentOption:u,isScheduledTransfer:d,asEquation:p,showRateWithLabel:m,shouldAnimateRateText:C,trackEvent:g})=>{let[w,T]=(0,l.useState)(!1),[v,E]=(0,l.useState)(),[A,I]=(0,l.useState)(!0),[S,k]=(0,l.useState)(tI),O=(0,i.Z)(),N=(null==s?void 0:s.rateType)==="FIXED",_=(null==s?void 0:s.type)==="SPOT",Z=(0,l.useCallback)(async()=>{I(!0);try{let a=await tb(e,t,S);E(a)}catch(e){console.error(e)}finally{I(!1)}},[e,t,S]);(0,l.useEffect)(()=>{w&&Z()},[Z,w]);let D=e=>{k(e)},P=()=>{T(!0),null==g||g("Calculator - Rate Graph Modal - Started")},F=(0,r.P7)({rate:null!=n?n:a,sourceCurrency:e,targetCurrency:t,locale:O.locale}),L=p?F.equation:F.decimal,B=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:tE.rateTextContainer,children:s?(0,o.jsx)(tC,{shouldFadeIn:!!C,children:(0,o.jsx)("button",{type:"button",className:R(tE.rateTextButton,C?tn.moveUp:null),onClick:P,children:(0,o.jsx)(tv,{isFixedRate:N,rateExpirationTime:s.rateExpirationTime,sourceCurrency:e,hideRateExpirationTime:_,isScheduledTransfer:d})})}):null}),(0,o.jsx)(f.Z,{priority:"secondary",onClick:P,children:(0,o.jsx)("span",{className:"tw-calculator-breakdown-rate__value",children:L})})]});return(0,o.jsxs)(o.Fragment,{children:[m?B:(0,o.jsx)("a",{role:"button","aria-label":O.formatMessage({id:"calculator.breakdown.fixedRateText.rate.label"}),className:"btn-unstyled",tabIndex:0,onClick:P,onKeyPress:e=>{(" "===e.key||"Enter"===e.key)&&(e.preventDefault(),P())},children:(0,o.jsx)("span",{className:"tw-calculator-breakdown-rate__value",children:L})}),(0,o.jsx)(b.Z,{size:j.$.EXTRA_LARGE,body:(0,o.jsx)(l.Suspense,{fallback:(0,o.jsx)("div",{className:"d-flex justify-content-center",children:(0,o.jsx)(h.Z,{})}),children:(0,o.jsx)(tA,{sourceCurrency:e,targetCurrency:t,historicRates:null==v?void 0:v.map(({time:e,value:t})=>({time:e,rate:t})),liveRate:a,showTimePeriodSelection:"left",defaultTimePeriod:S,isLoading:A,rateDetails:s&&m?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(tv,{isFixedRate:N,rateExpirationTime:null==s?void 0:s.rateExpirationTime,sourceCurrency:e,hideRateExpirationTime:_,isScheduledTransfer:d}),(0,o.jsx)(x.Z,{type:"title-section",className:"m-y-1",children:L}),N&&u?_?(0,o.jsx)(c.Z,{id:"calculator.rateGraph.rateDetails.subtitle.guaranteed"}):(0,o.jsx)(c.Z,{id:"calculator.rateGraph.rateDetails.subtitle.guaranteed.with.time",values:{sourceAmount:(0,o.jsx)(y.Z,{amount:u.sourceAmount,currency:e}),date:(0,r.p6)(new Date(s.rateExpirationTime),O.locale,{dateStyle:"medium",timeStyle:"short"})}}):N?void 0:(0,o.jsx)(c.Z,{id:"calculator.rateGraph.rateDetails.subtitle.not.guaranteed"})]}):null,onTimePeriodSelection:e=>D(e)})}),open:w,onClose:()=>T(!1)})]})},tk=({quote:e,selectedPaymentOption:t,isScheduled:a,desiredRate:n,label:l,asEquation:s,trackEvent:u})=>{let{locale:d}=(0,i.Z)(),{sourceCurrency:p,targetCurrency:m,rate:y,rateType:h,rateExpirationTime:x}=e;if(eo(e))return null;let f=el(x),b=(0,r.P7)({rate:null!=n?n:y,sourceCurrency:p,targetCurrency:m,locale:d}).inverted;return{key:"RATE",left:(0,o.jsx)(tS,{sourceCurrency:p,targetCurrency:m,rate:y,desiredRate:n,asEquation:s,trackEvent:u}),right:l||(a?(0,o.jsx)(c.Z,{id:"calculator.breakdown.rate-estimated"}):(0,o.jsx)(tw,{isFixedRate:"FIXED"===h,rateExpirationTime:x,sourceAmount:t.sourceAmount,sourceCurrency:p,hideRateExpirationTime:"SPOT"===e.type||"number"==typeof f&&f<1})),operator:b?"DIVIDE":"MULTIPLY"}},tO=({icon:e=null,left:t,right:a=null,divider:n=!1,className:r})=>(0,o.jsxs)("li",{"data-testid":"tw-calculator-breakdown-item",className:r,children:[(0,o.jsx)("span",{className:"tw-calculator-breakdown__icon",children:e&&(0,o.jsx)("span",{children:e})}),(0,o.jsxs)("div",{className:"tw-calculator-breakdown__content",children:[(0,o.jsx)("span",{className:"tw-calculator-breakdown-item__left tw-calculator-breakdown-item__value","data-testid":"breakdown-item-left",children:t}),a&&(0,o.jsx)("span",{className:"tw-calculator-breakdown-item__right tw-calculator-breakdown-item__label","data-testid":"breakdown-item-right",children:a})]}),n&&(0,o.jsx)("hr",{className:"m-t-1 m-b-0","data-testid":"breakdown-item-divider"})]}),tN=()=>(0,o.jsx)("span",{children:"+"}),t_=()=>(0,o.jsx)("span",{children:"\xf7"}),tZ=()=>(0,o.jsx)("span",{children:"="}),tD=()=>(0,o.jsx)("span",{children:"\xd7"}),tP=()=>(0,o.jsx)("span",{children:"–"}),tF=()=>{let e=(0,i.Z)();return(0,o.jsx)("div",{className:"d-flex align-items-center tw-calculator-dynamic-charges-animation-wrapper m-t-2 m-b-5",children:(0,o.jsxs)("ul",{className:"tw-calculator-breakdown tw-calculator-dynamic-charges-animation p-x-3 flex-grow-1","aria-hidden":"true",children:[(0,o.jsxs)("div",{className:"tw-calculator-dynamic-charges-animation-our-fee tw-calculator-dynamic-charges-animation-item",children:[(0,o.jsx)(tO,{className:"tw-calculator-dynamic-charges-animation-our-fee-old p-t-0",icon:null,left:(0,o.jsx)("span",{children:(0,r.lb)(.75,"USD",e.locale)}),right:(0,o.jsx)(c.Z,{id:"calculator.breakdown.transferwiseFeeText"})}),(0,o.jsx)(tO,{className:"tw-calculator-dynamic-charges-animation-our-fee-new p-t-0",icon:null,left:(0,o.jsx)("span",{children:(0,r.lb)(.4,"USD",e.locale)}),right:(0,o.jsx)(c.Z,{id:"calculator.breakdown.transferwiseFeeText"})})]}),(0,o.jsx)(tO,{className:"tw-calculator-dynamic-charges-animation-dynamic-charges tw-calculator-dynamic-charges-animation-item p-t-0",icon:null,left:(0,o.jsx)("span",{children:(0,r.lb)(.35,"USD",e.locale)}),right:(0,o.jsx)("span",{className:"tw-calculator-dynamic-charges-link-example",children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.dynamicChargesText"})})}),(0,o.jsx)(tO,{className:"tw-calculator-dynamic-charges-animation-total-fee tw-calculator-dynamic-charges-animation-item p-t-0",icon:(0,o.jsx)(tP,{}),left:(0,o.jsx)("span",{children:(0,r.lb)(.75,"USD",e.locale)}),right:(0,o.jsx)(c.Z,{id:"calculator.breakdown.totalFeeText"})})]})})},tR="dynamic-pricing-screen-shown",tL=({open:e,onClose:t,explanation:a})=>{var n;let r=eB(),[i,u]=(0,l.useState)(!1);(0,l.useEffect)(()=>{RegExp(`(^|;) ?${tR}=([^;]*)(;|$)`,"u").test(null==document?void 0:document.cookie)||"ONBOARDING"===r||(u(!0),eV("Calculator - Dynamic Charges - Started"))},[r]),(0,l.useEffect)(()=>{e&&eV("Calculator - Dynamic Charges - Tapped")},[e]);let d=()=>{B.pR.write(`${tR}=true; expires=${function(){let e=new Date;return e.setFullYear(new Date().getFullYear()+1),e.toUTCString()}()}; path=/`,{essential:!0}),u(!1),t(),eV("Calculator - Dynamic Charges - Finished",{finishReason:"Close"})};return(0,o.jsx)(b.Z,{position:"top",size:"md",open:e||i,body:(0,o.jsxs)("div",{className:"p-x-1",children:[(0,o.jsx)(tF,{}),(0,o.jsx)(C.Z,{children:a.markdown})]}),footer:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(s.Z,{type:"primary",block:!0,className:"m-t-1 m-x-1",onClick:()=>d(),children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.priceItemWrapper.modal.continue"})}),null==(n=null==a?void 0:a.links)?void 0:n.map(e=>(0,o.jsx)(s.Z,{className:"m-x-1",block:!0,type:"link",target:"_blank",as:"a",href:e.url,onClick:()=>{eV("Calculator - Dynamic Charges - Finished",{finishReason:"Dynamic Link"})},children:e.label},e.label))]}),onClose:d})},tB=({id:e,open:t,onClose:a,explanation:n})=>{var r;return"DYNAMIC_FX_FEE"===e?(0,o.jsx)(tL,{open:t,explanation:n,onClose:a}):(0,o.jsx)(b.Z,{position:"top",open:t,body:(0,o.jsx)(C.Z,{children:n.markdown}),footer:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(s.Z,{type:"primary",block:!0,className:"m-t-1",onClick:()=>a(),children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.priceItemWrapper.modal.continue"})}),null==(r=null==n?void 0:n.links)?void 0:r.map(e=>(0,o.jsx)(s.Z,{block:!0,type:"link",as:"a",href:e.url,children:e.label},e.label))]}),onClose:a})},tU=({item:e,children:t})=>{let[a,n]=(0,l.useState)(!1);return e.explanation?"markdown"in e.explanation?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(eW,{onClick:()=>{n(!0)},children:(0,o.jsx)(o.Fragment,{children:t})}),(0,o.jsx)(tB,{id:e.key,explanation:e.explanation,open:a,onClose:()=>{n(!1)}})]}):(0,o.jsx)(d.Z,{title:e.explanation.label,content:e.explanation.description,children:(0,o.jsx)(eW,{children:(0,o.jsx)(o.Fragment,{children:t})})}):(0,o.jsx)(o.Fragment,{children:t})},tM=e=>"DIVIDER"===e.key,t$=function(e){try{(window.Rollbar||window.rollbar).error(e)}catch(e){}console.error(e)};function tY({currency:e,balances:t,intl:{formatMessage:a,locale:l}}){let o={currency:e.code.toLowerCase(),value:e.code,label:e.code,note:e.name,searchable:e.countryKeywords.join(" ")};if(t){let i=et(t,e.code);if(i)return(0,n.EZ)((0,n.ih)({},o),{note:a({id:"calculator.label.available.balance"},{amount:(0,r.dN)(i,e.code,l)})})}return o}function tQ(e,t){return J(t.filter(t3),t=>t.value===e)}function tG(e,t){var a;return(null==(a=e.find(({currencyCode:e})=>e===t))?void 0:a.targetCurrencies)||[]}function tW({currencies:e,allCurrencies:t,balances:a,intl:r}){let l=function({currencies:e,allCurrencies:t,balances:a,intl:n}){return[{header:n.formatMessage({id:"calculator.label.all.currencies"})},...function({currencies:e,allCurrencies:t,balances:a,intl:n}){return e.map(tV(t)).filter(Boolean).map(e=>tY({currency:e,balances:a,intl:n}))}({currencies:e,allCurrencies:t,balances:a,intl:n})]}({currencies:e,allCurrencies:t,balances:a,intl:r}),o=function({currencies:e,allCurrencies:t,balances:a,intl:r}){var l,o;let i=(l={currencies:e,allCurrencies:t,balances:a,intl:r},tq((0,n.EZ)((0,n.ih)({},l),{indexProperty:"recentUsageIndex"})));return i.length>0?[{header:r.formatMessage({id:"calculator.label.recent.currencies"})},...i]:[{header:r.formatMessage({id:"calculator.label.popular.currencies"})},...(o={currencies:e,allCurrencies:t,balances:a,intl:r},tq((0,n.EZ)((0,n.ih)({},o),{indexProperty:"popularityIndex"})))]}({currencies:e,allCurrencies:t,balances:a,intl:r});return 1===o.length?l.slice(1):[...o,...l]}function tV(e){return({currencyCode:t})=>{let a=e.find(e=>e.code===t);return a||t$(`Tried to get currency ${t} which we don't have config for.`),a}}function tq({currencies:e,allCurrencies:t,indexProperty:a,balances:n,intl:r}){return(function({currencies:e,allCurrencies:t,indexProperty:a}){return e.filter(e=>null!==e[a]&&void 0!==e[a]).sort((e,t)=>e[a]-t[a]).map(tV(t)).filter(Boolean)})({currencies:e,allCurrencies:t,indexProperty:a}).map(e=>tY({currency:e,balances:n,intl:r}))}var tH=({currencies:e,indexProperty:t})=>e.filter(e=>null!==e[t]&&void 0!==e[t]).sort((e,a)=>e[t]-a[t]).filter(Boolean),tK=(e,t)=>t.find(({code:t})=>t===e),tX=e=>({value:e,label:e,currency:e}),tz=(e,{sourceCurrencies:t,targetCurrencies:a})=>({sourceCurrencies:({sourceCurrencies:({sourceCurrencies:e.sourceCurrencies.filter(({currencyCode:e})=>{var a;return null==(a=null==t?void 0:t.includes(e))||a})}).sourceCurrencies.map(e=>(0,n.EZ)((0,n.ih)({},e),{targetCurrencies:e.targetCurrencies.filter(({currencyCode:e})=>{var t;return null==(t=null==a?void 0:a.includes(e))||t})}))}).sourceCurrencies.filter(({targetCurrencies:e})=>e.length>0)}),tJ=(e,t,a)=>{let n=e.sourceCurrencies.find(({currencyCode:e})=>e===t);return!!n&&!!n.targetCurrencies.find(({currencyCode:e})=>e===a)},t0=e=>[...e].sort((e,t)=>t1(e.popularityIndex)-t1(t.popularityIndex)).sort((e,t)=>t1(e.recentUsageIndex)-t1(t.recentUsageIndex)),t1=e=>void 0===e?Number.POSITIVE_INFINITY:e,t3=e=>null==e.header,t2="UPDATE_SOURCE_AMOUNT",t4="UPDATE_TARGET_AMOUNT",t5="UPDATE_SOURCE_CURRENCY",t8="UPDATE_TARGET_CURRENCY",t9="UPDATE_SOURCE_AND_TARGET_CURRENCIES",t6=(e,t)=>{let{shouldFetchNewQuote:a=!1}=t.payload;switch(t.type){case t2:return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,sourceAmount:t.payload.amount,amountType:"SOURCE"});case t4:return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,targetAmount:t.payload.amount,amountType:"TARGET"});case t5:return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,sourceCurrencyCode:t.payload.sourceCurrencyCode});case t8:return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,targetCurrencyCode:t.payload.targetCurrencyCode});case t9:return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,sourceCurrencyCode:t.payload.sourceCurrencyCode,targetCurrencyCode:t.payload.targetCurrencyCode});default:return e}},t7=e=>({updateSourceAmount:t=>e({type:t2,payload:{shouldFetchNewQuote:!0,amount:t}}),updateTargetAmount:t=>e({type:t4,payload:{shouldFetchNewQuote:!0,amount:t}}),updateSourceCurrency:(t,a=!0)=>e({type:t5,payload:{shouldFetchNewQuote:a,sourceCurrencyCode:t}}),updateTargetCurrency:(t,a=!0)=>e({type:t8,payload:{shouldFetchNewQuote:a,targetCurrencyCode:t}}),updateSourceAndTargetCurrencies:({sourceCurrencyCode:t,targetCurrencyCode:a},n=!0)=>e({type:t9,payload:{shouldFetchNewQuote:n,sourceCurrencyCode:t,targetCurrencyCode:a}})}),ae=(e,t)=>{let{sourceCurrency:a,targetCurrency:n,sourceAmount:r,targetAmount:l}=t;return{amountType:e.providedAmountType,sourceAmount:r,targetAmount:l,sourceCurrencyCode:a,targetCurrencyCode:n}},at=({quote:e,isValidQuote:t})=>{(0,l.useEffect)(()=>{if(!t&&e){let{sourceCurrency:t,targetCurrency:a}=e;t$(`Invalid quote provided with unsupported route ${t} \u203A ${a}`)}},[t,e])},aa=({quote:e,routes:t,currencies:a})=>(0,l.useMemo)(()=>(function({quote:e,routes:t,currencies:a}){if(!e)return!0;try{let{sourceCurrency:n,targetCurrency:r}=e;return function({targetCurrency:e,sourceCurrency:t,routes:a,currencies:n}){try{let r=function({routes:{sourceCurrencies:e},currencies:t,source:a,quote:n,isSendingToTargetAccount:r,intl:l}){if(r)return[tY({currency:J(t,e=>e.code===(null==n?void 0:n.targetCurrency)),intl:l})];let o=tG(e,a);return tW({currencies:o,allCurrencies:t,intl:l})}({routes:a,currencies:n,source:t,intl:{formatMessage:()=>"",locale:""}});return!!tQ(e,r)}catch(e){return!1}}({targetCurrency:r,sourceCurrency:n,routes:t,currencies:a})&&function({sourceCurrency:e,routes:t,currencies:a,lockedTargetCurrency:n}){try{let r=function({routes:{sourceCurrencies:e},currencies:t,lockedTargetCurrency:a,balances:n,intl:r}){return a?tW({currencies:e.filter(({targetCurrencies:e})=>!!J(e,e=>e.currencyCode===a)),allCurrencies:t,balances:n,intl:r}):tW({currencies:e,allCurrencies:t,balances:n,intl:r})}({routes:t,currencies:a,lockedTargetCurrency:n,intl:{formatMessage:()=>"",locale:""}});return!!tQ(e,r)}catch(e){return!1}}({sourceCurrency:n,routes:t,currencies:a})}catch(e){return!1}})({quote:e,routes:t,currencies:a}),[e,t,a]),an=class{constructor(){this.callsMade=0}async resolveLast(e){let t=this.callsMade+1;return this.callsMade+=1,new Promise((a,n)=>{e.then(e=>{t===this.callsMade&&a(e)}).catch(e=>{t===this.callsMade&&n(e)})})}},ar=class{constructor(e){this.resolver=new an,this.locale=e.locale}async create(e){return this.resolver.resolveLast(tp(e,this.locale))}async update(e,t){return this.resolver.resolveLast(th(e,t,this.locale))}async createConversionQuote(e){return this.resolver.resolveLast(tm(e,this.locale))}async updateConversionQuote(e,t){return this.resolver.resolveLast(tx(e,t,this.locale))}},al=({handleQuoteChange:e,handleQuoteFailure:t,getQuoteParams:a})=>{let{locale:n}=(0,i.Z)(),r=(0,l.useRef)(new ar({locale:n})),o=async(e,t)=>{if(null==t?void 0:t.id)try{return await r.current.update(t,e)}catch(t){if(ao(t))return r.current.create(e);throw t}return r.current.create(e)},c=async(e,t)=>{if(null==t?void 0:t.id)try{return await r.current.updateConversionQuote(t,e)}catch(t){if(ao(t))return r.current.createConversionQuote(e);throw t}return r.current.createConversionQuote(e)},s=async a=>r.current.create(a).then(e).catch(t),u=async(a,n)=>o(a,n).then(e).catch(t),d=async(a,n)=>c(a,n).then(e).catch(t),p=(0,l.useRef)(ee((e,t)=>{u(e,t)},250)),m=(0,l.useRef)(ee((e,t)=>{d(e,t)},250));return{updateQuote:(e,t)=>{u(a({currentState:e,currentQuote:t}),t)},debouncedUpdateQuote:(e,t)=>{let n=a({currentState:e,currentQuote:t});p.current(n,t)},debouncedUpdateConversionQuote:(e,t)=>{let n=a({currentState:e,currentQuote:t});m.current(n,t)},createQuote:s}};function ao(e){return tl(e)&&422===e.status&&!!J(e.body.errors,({code:e})=>"error.quote.expired"===e)}function ai({currentState:e,currentQuote:t,shouldShowPaymentPreferences:a}){let{guaranteedTargetAmountAllowed:r,targetAccount:l,contactId:o,discountCode:i,referralCode:c,profile:s,user:u,payInId:d,payInMethod:p}=null!=t?t:{},{sourceAmount:m,targetAmount:y,amountType:h,sourceCurrencyCode:x,targetCurrencyCode:f,guaranteedTargetAmount:b,expectedFulfillmentTime:j,type:C,selectedPreferredPayIn:g,preselectedPaymentOption:w}=e,T=w||(null==g?void 0:g.method)||(null==t?void 0:t.preferredPayIn),v=(null==g?void 0:g.id)||void 0;return(0,n.EZ)((0,n.ih)({},"SOURCE"===h?{sourceAmount:m}:{targetAmount:y}),{sourceCurrency:x,targetCurrency:f,guaranteedTargetAmount:!!r&&!!b,targetAccount:l,contactId:o,discountCode:i,referralCode:c,profile:s,user:u,expectedFulfillmentTime:j,type:(()=>{if(null!==C)return es(w||null)||a&&"BALANCE"===T?C&&"REGULAR"!==C?C:"SPOT":C})(),preferredPayIn:T,preferredPayInId:v,payInMethod:T,payInId:v})}var ac=({currency:e,amount:t,balanceName:a,toGroup:n,insufficientBalance:r,onClick:l})=>{(0,i.Z)();let s=()=>l(t);return(0,o.jsx)(c.Z,{id:n?r?"calculator.moneyInputs.overCurrentBalanceWithMainGroup":"calculator.moneyInputs.currentBalanceWithMainGroup":a?r?"calculator.moneyInputs.overCurrentBalanceWithName":"calculator.moneyInputs.currentBalanceWithName":r?"calculator.moneyInputs.overCurrentBalance":"calculator.moneyInputs.currentBalance",values:{money:(0,o.jsx)("a",{role:"button",tabIndex:0,onClick:s,onKeyPress:e=>{(" "===e.key||"Enter"===e.key)&&s()},children:(0,o.jsx)(y.Z,{amount:t,currency:e})}),balanceName:a?(0,o.jsx)("strong",{children:a}):void 0,strong:e=>(0,o.jsx)("strong",{children:e})}})},as=e=>(0,o.jsx)(g.Z,{type:e.insufficientBalance?"negative":"neutral",className:"m-b-0 CurrentBalanceAmountNotice_tw-current-balance-amount",children:(0,o.jsx)(ac,(0,n.ih)({},e))}),au=({type:e})=>{switch(e){case"ADD":return(0,o.jsx)(tN,{});case"SUBTRACT":return(0,o.jsx)(tP,{});case"EQUAL":return(0,o.jsx)(tZ,{});case"MULTIPLY":return(0,o.jsx)(tD,{});case"DIVIDE":return(0,o.jsx)(t_,{});default:return null}},ad=({items:e,className:t})=>(0,o.jsx)("ul",{className:R("tw-calculator-breakdown",t),children:e.map(e=>tM(e)?(0,o.jsx)("li",{"aria-hidden":"true",children:(0,o.jsx)("hr",{className:"m-t-1 m-b-0"})},e.key):(0,o.jsx)(tO,{icon:"NONE"!==e.operator?(0,o.jsx)(au,{type:e.operator}):null,left:e.left,right:(0,o.jsx)(tU,{item:e,children:e.right})},e.key))}),ap=e=>{switch(e){case"BALANCE":return L.FastFlag;case"IDEAL":return L.Ideal;case"INTERAC":return L.Interac;case"SOFORT":return L.Klarna;case"TRUSTLY":return L.Trustly;case"PIX":return L.Pix;case"VENMO_PUSH":return L.Venmo;case"PAYPAL":return L.Paypal;case"FPX":return L.Fpx;case"ACH":case"PISP":case"DIRECT_DEBIT":return L.Ach;case"BANK_TRANSFER":case"BILL_PAYMENT":case"FAST_DIRECT_DEBIT":case"SEPA_DIRECT_DEBIT":case"OSKO":case"PAYNOW":case"POLI":case"PROMPT_PAY":case"BANKGIRO":return L.Bank;case"ALIPAY":return L.Alipay;case"HK_FPS_ID":return L.BankTransfer;case"CREDIT":case"DEBIT":return L.Card;default:return L.Globe}},am={actionButton:"RateShimmer_actionButton",text:"RateShimmer_text",rateTextContainer:"RateShimmer_rateTextContainer"},ay=({showLabel:e=!0})=>(0,o.jsx)(tC,{shouldFadeIn:!0,children:(0,o.jsxs)("span",{className:"d-flex flex-column align-items-center",children:[(0,o.jsx)("div",{className:am.rateTextContainer,children:e?(0,o.jsx)("div",{className:`${am.text} ${tn.shimmer}`}):null}),(0,o.jsx)("div",{className:`${am.actionButton} ${tn.shimmer}`})]})}),ah=({fadeInElement:e,quote:t,sourceCurrency:a,targetCurrency:n,isUpdatingQuote:r,isUpdatingRate:i,rate:c,selectedPaymentOption:s,isScheduledTransfer:u,trackEvent:d})=>{let{isFeatureEnabled:p}=eG(),m=p(eY.SEND_CALCULATOR_2_0),[y,h]=(0,l.useState)(!!t),[x,f]=(0,l.useState)(!0);return((0,l.useEffect)(()=>{t&&!r&&h(!0)},[t,r]),(0,l.useEffect)(()=>{t&&!r&&x&&setTimeout(()=>{f(!1)},400)},[t,r,x]),eo({sourceCurrency:a,targetCurrency:n}))?(0,o.jsx)("div",{className:tE.rateContainer}):(0,o.jsx)("div",{className:tE.rateContainer,children:r||i?(0,o.jsx)(ay,{showLabel:y}):(0,o.jsx)(tC,{shouldFadeIn:e,children:(0,o.jsx)(tS,{sourceCurrency:a,targetCurrency:n,trackEvent:d,rate:c,quote:t,selectedPaymentOption:s,isScheduledTransfer:u,asEquation:!0,showRateWithLabel:m,shouldAnimateRateText:x})})})},ax=e=>{let t=e.capabilities.find(({action:e})=>"SEND"===e);return(null==t?void 0:t.currencies)||[]},af=e=>"PERSON"===e.legalEntityType,ab=e=>{var t;let a=e.display.title;return(null==(t=null==a?void 0:a.split(" ").filter(Boolean)[0])?void 0:t.trim())||""},aj=({quote:e,selectedPaymentOption:t})=>{var a;let n=null!=(a=e.guaranteedTargetRateFluctuationBuffer)?a:0,r=t.sourceAmount-t.price.total.value.amount-n;return(0,o.jsx)(g.Z,{type:"neutral",children:(0,o.jsx)(c.Z,{id:"calculator.amount.we.will.convert",values:{amount:(0,o.jsx)("b",{children:(0,o.jsx)(y.Z,{amount:r,currency:t.sourceCurrency})})}})})},aC=({preselectedPaymentOption:e,quote:t,onChangePaymentOption:a,selectedPaymentOption:n,isScheduled:r=!1,shouldShowPaymentPreferences:l=!1,trackEvent:i})=>{let c=ej(t.paymentOptions),s=e0({quote:t,selectedPaymentOption:n,preselectedPaymentOption:e,onChangePaymentOption:a,isScheduled:r,showFeesAsAddition:!1,shouldShowPaymentPreferences:l,canShowVariableFees:!0}),u=e2({quote:t,selectedPaymentOption:n,isScheduled:r,showFeesAsAddition:!1}),d=e7({quote:t,selectedPaymentOption:n,isScheduled:r,showFeesAsAddition:!1}),p=eU({quote:t,selectedPaymentOption:n}),m=eM({quote:t,selectedPaymentOption:n}),y=ta({quote:t,selectedPaymentOption:n,isEstimated:r}),h=tk({quote:t,selectedPaymentOption:n,isScheduled:r,trackEvent:i}),x=[...!c&&0===s.amount&&u.every(e=>tM(e)||0===e.amount)?[]:[s,...u],d,p,m,y,h].filter(ei);return(0,o.jsx)(ad,{items:x,className:"tw-calculator-breakdown--detailed"})},ag={easeUp:"CalculatorHeading_easeUp",easeDown:"CalculatorHeading_easeDown"};function aw({isRateVisible:e}){return(0,o.jsx)("header",{className:`${R(e?ag.easeDown:ag.easeUp)} m-b-2`,children:(0,o.jsx)("h2",{className:"text-xs-left text-sm-center",children:(0,o.jsx)(c.Z,{id:"tf.calculator.step.title"})})})}var aT=["USD","EUR"],av=(e,t)=>e===t?null:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.Z,{id:"calculator.moneyInputs.otherCurrency.currency.label",values:{sourceCurrency:e,targetCurrency:t}})," ",(0,o.jsx)("span",{className:"np-text-link-default",children:(0,o.jsx)(c.Z,{id:"calculator.moneyInputs.otherCurrency.currency.label.email.me"})})]}),aE=()=>(0,o.jsx)(c.Z,{id:"calculator.moneyInputs.otherCurrency.generic.label",values:{requestTheCurrencyButton:(0,o.jsx)("span",{className:"np-text-link-default",children:(0,o.jsx)(c.Z,{id:"calculator.moneyInputs.otherCurrency.generic.label.request.currency"})})}}),aA=e=>e.filter(e=>!aT.includes(e.value||"")),aI=e=>{var t,a;return`${e.code} ${null==(a=null==(t=e.countryKeywords)?void 0:t.join)?void 0:a.call(t," ")}`.toLowerCase()},aS=({currencies:e=[],sourceCurrency:t,targetCurrency:a})=>{let[n,r]=(0,l.useState)(),[o,i]=(0,l.useState)();(0,l.useEffect)(()=>{r(void 0),i(void 0)},[t,a]);let c=t=>t?e.find(e=>aI(e).includes(t.toLowerCase())&&!aT.includes(e.code)):null;return{handleSourceCurrencySearchChange:({searchQuery:e,filteredOptions:t})=>{r({searchQuery:e,filteredOptions:aA(t)})},handleTargetCurrencySearchChange:({searchQuery:e,filteredOptions:t})=>{i({searchQuery:e,filteredOptions:aA(t)})},sourceCurrencyLabel:(()=>{let{searchQuery:t,filteredOptions:r}=n||{};if((null==e?void 0:e.length)&&t&&!(null==r?void 0:r.length)){let e=c(t);if(e)return av(e.code,a)}return aE()})(),targetCurrencyLabel:(()=>{let{searchQuery:a,filteredOptions:n}=o||{};if((null==e?void 0:e.length)&&a&&!(null==n?void 0:n.length)){let e=c(a);if(e)return av(t,e.code)}return aE()})()}},ak=({locked:e,onChange:t})=>(0,o.jsx)("a",{"data-testid":`guaranteed-target-amount-${e?"locked":"unlocked"}`,className:`tw-calculator__amount-lock text-${e?"info":"muted"}`,onClick:()=>t&&t(!e),children:e?(0,o.jsx)(L.Lock,{}):(0,o.jsx)(L.Unlock,{})});function aO({children:e}){return(0,o.jsxs)("span",{className:R("d-flex align-items-center","ChevronButtonContent_chevronButtonContent"),children:[e,(0,o.jsx)(L.ChevronRight,{})]})}var aN=({paymentOption:e,onSelectPaymentMethod:t,usingPayInProducts:a})=>{let n=ap(e.payIn);return(0,o.jsx)(w.Z,{id:e.payIn,title:(0,o.jsx)(c.Z,{id:q(e.payIn,e.sourceCurrency)}),content:(0,o.jsx)(a_,{paymentOption:e,usingPayInProducts:a}),showMediaAtAllSizes:!1,showMediaCircle:!0,isContainerAligned:!0,media:(0,o.jsx)(n,{size:24}),disabled:e.disabled,onClick:()=>{t({method:e.payIn,id:null})}},e.payIn)},a_=({paymentOption:e,usingPayInProducts:t})=>{var a;if(e.disabled&&(null==(a=e.disabledReason)?void 0:a.message))return(0,o.jsx)("span",{children:e.disabledReason.message});let n=H(e.payIn,e.sourceCurrency);return(0,o.jsxs)(o.Fragment,{children:[n&&(0,o.jsx)("span",{children:(0,o.jsx)(c.Z,{id:n})}),(0,o.jsx)("span",{children:(0,o.jsx)(aZ,{paymentOption:e,usingPayInProducts:t})})]})},aZ=({paymentOption:e,usingPayInProducts:t})=>t?(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.payment.option.estimate",values:{deliveryEstimate:e.formattedEstimatedDelivery}}):(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.payment.option.amount.and.estimate",values:{amount:e.price.total.value.label,deliveryEstimate:e.formattedEstimatedDelivery}}),aD=({paymentPreference:e,paymentOption:t,onSelectPaymentMethod:a,usingPayInProducts:n})=>(0,o.jsx)(w.Z,{id:e.payInId,title:e.display.title,content:(0,o.jsx)(aP,{paymentPreference:e,paymentOption:t,usingPayInProducts:n}),media:(0,o.jsx)(aR,{paymentPreference:e}),showMediaAtAllSizes:!1,showMediaCircle:!0,isContainerAligned:!0,disabled:t.disabled,onClick:()=>{a({method:t.payIn,id:e.payInId||null})}},e.payInId),aP=({paymentPreference:e,paymentOption:t,usingPayInProducts:a})=>{var n;return t.disabled&&(null==(n=t.disabledReason)?void 0:n.message)?(0,o.jsx)("span",{children:t.disabledReason.message}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{children:e.display.description}),(0,o.jsx)("span",{children:(0,o.jsx)(aF,{paymentOption:t,usingPayInProducts:a})})]})},aF=({paymentOption:e,usingPayInProducts:t})=>t?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.Z,{id:V(e.payInProduct)}),".\xa0",(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.payment.option.estimate",values:{deliveryEstimate:e.formattedEstimatedDelivery}})]}):(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.payment.option.amount.and.estimate",values:{amount:e.price.total.value.label,deliveryEstimate:e.formattedEstimatedDelivery}}),aR=({paymentPreference:e})=>{let{avatar:t}=e.display;switch(t.type){case"IMAGE":return(0,o.jsx)(T.Z,{type:v.f.THUMBNAIL,size:j.$.MEDIUM,children:(0,o.jsx)("img",{src:t.url,alt:""})});case"FLAG":return(0,o.jsx)(U.F,{code:t.name});case"ICON":{let t=ap(e.payInType);return(0,o.jsx)(t,{size:24})}case"EMOJI":return(0,o.jsx)($.f,{size:48,balance:{currency:e.currencyCode,icon:{type:"EMOJI",value:t.name}}})}return null},aL={underhangContent:"Underhang_underhangContent",error:"Underhang_error",icon:"Underhang_icon"};function aB({children:e,icon:t,sentiment:a}){return(0,o.jsxs)("div",{className:R(aL.underhangContent,"d-flex align-items-start",{[aL.error]:"NEGATIVE"===a}),"data-testid":"active-payment-method-status",children:[t?(0,o.jsx)("div",{className:aL.icon,children:t}):null,e]})}var aU=({quote:e,paymentPreferences:t,selectedPreferredPayIn:a})=>{let{isFeatureEnabled:n}=eG(),r=n(eY.SEND_CALCULATOR_FORCE_PAYMENT_METHOD_SELECTION),[o,i]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!e)return;let n=t&&a?ey({paymentPreferences:t,selectedPayIn:a,preferenceCurrency:e.sourceCurrency}):null;i(r&&!n&&!(null==e?void 0:e.preferredPayIn))},[e,a]),{shouldForcePaymentMethodInput:o}},aM=({quote:e,selectedPaymentOption:t,selectedPreferredPayIn:a,paymentPreferences:n,onSelectPaymentMethod:r,sourceCurrency:i,currentBalanceAmount:s,onCurrentBalanceAmountClicked:u,preselectedPaymentOption:d,trackEvent:p,hasPaymentMethodInputRequiredError:y=!1})=>{let[h,f]=(0,l.useState)(!1),{shouldForcePaymentMethodInput:j}=aU({quote:e,paymentPreferences:n,selectedPreferredPayIn:a}),C=()=>{f(!0),null==p||p("Calculator - Payment Method Selection - Started")},g=()=>{f(!1),h&&(null==p||p("Calculator - Payment Method Selection - Finished"))};return((0,l.useEffect)(()=>{g()},[t]),t)?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:R("form-group m-b-0",{"has-info":!y,"has-error":y}),children:[j?(0,o.jsx)(aH,{hasError:y,onClick:C}):(0,o.jsx)(aK,{quote:e,selectedPaymentOption:t,selectedPreferredPayIn:a,paymentPreferences:n,sourceCurrency:i,currentBalanceAmount:s,preselectedPaymentOption:d,onClick:C,onCurrentBalanceAmountClicked:u}),j?(0,o.jsx)(aB,{sentiment:y?"NEGATIVE":"NEUTRAL",icon:(0,o.jsx)(E.Z,{sentiment:y?A.P.NEGATIVE:A.P.NEUTRAL,size:"sm"}),children:(0,o.jsx)("span",{children:(0,o.jsx)(c.Z,{id:y?"calculator.breakdown.paymentOptionSelect.placeholder.required.error":"calculator.breakdown.paymentOptionSelect.placeholder.required.message"})})}):null]}),(0,o.jsx)(b.Z,{body:(0,o.jsxs)("div",{className:"tw-calculator-payment-method-selection-modal-content",children:[(0,o.jsx)(x.Z,{type:m.Z.TITLE_SECTION,children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.title"})}),(null==n?void 0:n.alert)&&(0,o.jsx)(I.Z,{className:"m-t-2",children:(0,o.jsx)(S.Z,{message:n.alert.message,type:A.P.WARNING,action:n.alert.action&&{href:n.alert.action.href,text:n.alert.action.text,target:"_blank"}})}),(0,o.jsx)(a$,{quote:e,paymentPreferences:n,onSelectPaymentMethod:function(e){let t=e.id===(null==a?void 0:a.id)&&e.method===(null==a?void 0:a.method);(null==a?void 0:a.setBy)==="USER"&&t?g():r(e)}})]}),open:h,scroll:"content",onClose:g})]}):null},a$=({quote:e,paymentPreferences:t,onSelectPaymentMethod:a})=>{var n;let r=e.paymentOptions.filter(eC),l=null==(n=e.paymentPreferences)?void 0:n.filter(e=>r.find(t=>t.payIn===e.methodGroup)),i=ej(e.paymentOptions),c=!!(null==l?void 0:l.length)&&!!(null==t?void 0:t.preferences.length),s=c&&l.some(({method:e})=>"BALANCE"===e)&&!i?r.filter(e=>"BALANCE"!==e.payIn):r;return(0,o.jsxs)(o.Fragment,{children:[c?(0,o.jsx)(aY,{quotePaymentPreferences:l,paymentOptions:e.paymentOptions,paymentPreferences:null==t?void 0:t.preferences,usingPayInProducts:i,onSelectPaymentMethod:a}):null,s.length?i?(0,o.jsx)(aQ,{paymentOptions:s,onSelectPaymentMethod:a}):(0,o.jsx)(aG,{paymentOptions:s,hasPreferences:c,onSelectPaymentMethod:a}):null]})},aY=({quotePaymentPreferences:e,paymentPreferences:t,paymentOptions:a,onSelectPaymentMethod:n,usingPayInProducts:r})=>{let l=e.map(e=>{let l=a.find(t=>t.payIn===e.method),i=t.find(({payInId:t,payInType:a,currencyCode:n})=>e.id?t===e.id:a===e.methodGroup&&e.sourceCurrency===n);return i&&l?(0,o.jsx)(aD,{paymentPreference:i,paymentOption:l,usingPayInProducts:r,onSelectPaymentMethod:n},i.payInId||`preference-${i.payInType}`):null}).filter(Boolean);return l.length?(0,o.jsxs)(I.Z,{children:[(0,o.jsx)(x.Z,{children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.preferences.heading"})}),(0,o.jsx)("hr",{className:"m-y-1"}),l]}):null},aQ=({paymentOptions:e,onSelectPaymentMethod:t})=>{let a=(0,i.Z)(),n=er(e,e=>e.payInProduct);return(0,o.jsx)(o.Fragment,{children:Object.entries(n).map(([e,n])=>{let r=X({fee:n[0].fee,currency:n[0].sourceCurrency,intl:a});return(0,o.jsxs)(I.Z,{children:[(0,o.jsxs)(x.Z,{children:[(0,o.jsx)(c.Z,{id:V(e)}),(0,o.jsxs)("span",{className:"text-muted",children:["\xa0-\xa0",(0,o.jsx)(c.Z,{id:r.key,values:r.params})]})]}),(0,o.jsx)("hr",{className:"m-y-1"}),n.map(e=>(0,o.jsx)(aN,{paymentOption:e,usingPayInProducts:!0,onSelectPaymentMethod:t},e.payIn))]},e)})})},aG=({paymentOptions:e,onSelectPaymentMethod:t,hasPreferences:a})=>(0,o.jsxs)(I.Z,{children:[(0,o.jsx)(x.Z,{children:(0,o.jsx)(c.Z,{id:a?"calculator.breakdown.paymentOptionSelect.other.heading":W()})}),(0,o.jsx)("hr",{className:"m-y-1"}),e.map(e=>(0,o.jsx)(aN,{paymentOption:e,usingPayInProducts:!1,onSelectPaymentMethod:t},e.payIn))]}),aW=({selectedPreference:e,selectedPaymentOption:t})=>e?(0,o.jsx)(o.Fragment,{children:e.display.title}):(0,o.jsx)(c.Z,{id:q(t.payIn,t.sourceCurrency)}),aV=({selectedPreference:e,selectedPaymentOption:t,currentBalanceAmount:a})=>{if(e)return(0,o.jsx)(o.Fragment,{children:e.display.description});if(a)return(0,o.jsx)(c.Z,{id:"calculator.label.available.balance",values:{amount:(0,o.jsx)(y.Z,{amount:a,currency:t.sourceCurrency})}});let n=H(t.payIn,t.sourceCurrency);return n?(0,o.jsx)(c.Z,{id:n}):null},aq=({selectedPreference:e,selectedPaymentOption:t})=>{if(e)return(0,o.jsx)(aR,{paymentPreference:e});let a=ap(t.payIn);return(0,o.jsx)(a,{size:24})},aH=({hasError:e,onClick:t})=>(0,o.jsx)("div",{className:"m-t-2",children:(0,o.jsxs)("label",{className:"d-block m-b-0",children:[(0,o.jsx)("span",{className:"d-inline-block tw-calculator-active-payment-label",children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.input.label"})}),(0,o.jsx)(k.Z,{className:R("tw-calculator-active-payment-method input-group tw-calculator-active-payment-method-placeholder",{"has-error":e}),title:(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.placeholder.title"}),showMediaAtAllSizes:!0,action:(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.placeholder.select.label"}),priority:"secondary",onClick:t})]})}),aK=({quote:e,selectedPaymentOption:t,selectedPreferredPayIn:a,paymentPreferences:n,onClick:r,sourceCurrency:l,currentBalanceAmount:i,onCurrentBalanceAmountClicked:s,preselectedPaymentOption:u})=>{let{isFeatureEnabled:d}=eG(),p=d(eY.SEND_CALCULATOR_2_0),m=n&&a?ey({paymentPreferences:n,selectedPayIn:a,preferenceCurrency:l}):null,y=!!u,h=!!eZ(t),x=y||e.paymentOptions.every(({disabled:e})=>e);return(0,o.jsxs)("div",{className:"m-t-2",children:[(0,o.jsxs)("label",{className:"d-block m-b-0",children:[(0,o.jsx)("span",{className:"d-inline-block tw-calculator-active-payment-label",children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.input.label"})}),(0,o.jsx)(k.Z,{className:R("tw-calculator-active-payment-method",{"tw-calculator-active-payment-method--preselected":y,"tw-calculator-active-payment-method--error":h}),disabled:x,title:(0,o.jsx)(aW,{selectedPreference:m,selectedPaymentOption:t}),content:(p?!!(null==a?void 0:a.id)||!!(null==m?void 0:m.payInId):(null==m?void 0:m.payInId)&&"BALANCE"!==m.payInType)?(0,o.jsx)(aV,{selectedPreference:m,selectedPaymentOption:t,currentBalanceAmount:i}):void 0,showMediaAtAllSizes:!0,action:(0,o.jsx)(aO,{children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.paymentOptionSelect.change.label"})}),media:(0,o.jsx)("div",{className:"d-flex tw-calculator-active-payment-method-media",children:(0,o.jsx)(aq,{selectedPreference:m,selectedPaymentOption:t})}),priority:h?"primary":"secondary",onClick:r})]}),(0,o.jsx)(aX,{selectedPaymentOption:t,sourceCurrency:l,currentBalanceAmount:i,onCurrentBalanceAmountClicked:s})]})},aX=({selectedPaymentOption:e,sourceCurrency:t,currentBalanceAmount:a,onCurrentBalanceAmountClicked:n})=>{let{isFeatureEnabled:r}=eG(),l=r(eY.SEND_CALCULATOR_2_0),i="BALANCE"===e.payIn&&e.disabled&&!!a&&e.sourceAmount>=a;if(a&&n&&"BALANCE"===e.payIn&&!l)return(0,o.jsx)("div",{className:"m-t-1",children:(0,o.jsx)(aB,{sentiment:"NEUTRAL",icon:e.disabled?(0,o.jsx)(E.Z,{sentiment:A.P.WARNING,size:"sm"}):null,children:(0,o.jsx)("div",{className:"m-y-0 tw-current-balance-amount",children:(0,o.jsx)(ac,{currency:t,amount:a,insufficientBalance:e.sourceAmount>a,onClick:n})})})});let s=i&&l?(0,o.jsx)(c.Z,{id:"calculator.moneyInputs.overCurrentBalance.generic"}):eZ(e);return s?(0,o.jsx)("div",{className:"m-t-1",children:(0,o.jsx)(aB,{icon:(0,o.jsx)(E.Z,{sentiment:A.P.NEUTRAL,size:"sm"}),sentiment:l?"NEGATIVE":"NEUTRAL",children:(0,o.jsx)("span",{children:s})})}):null},az=()=>(0,o.jsx)(g.Z,{type:"neutral",children:(0,o.jsx)(c.Z,{id:"calculator.moneyInputs.scheduled.balance.info"})}),aJ="CalculatorDetailsShimmer_textShort",a0=({className:e})=>(0,o.jsxs)(tC,{shouldFadeIn:!0,children:[(0,o.jsxs)("div",{className:R("m-t-2",e),children:[(0,o.jsx)("div",{className:`${aJ} ${tn.shimmer}`}),(0,o.jsx)("div",{className:"CalculatorDetailsShimmer_mediaContainer",children:(0,o.jsxs)("div",{className:"media",children:[(0,o.jsx)("div",{className:"media-left",children:(0,o.jsx)("div",{className:`CalculatorDetailsShimmer_iconCircle ${tn.shimmer}`})}),(0,o.jsx)("div",{className:"media-body",children:(0,o.jsxs)("div",{className:"media",children:[(0,o.jsxs)("div",{className:"media-body",children:[(0,o.jsx)("div",{className:`CalculatorDetailsShimmer_textLong ${tn.shimmer}`}),(0,o.jsx)("div",{className:`${aJ} ${tn.shimmer}`})]}),(0,o.jsx)("div",{className:"media-right",children:(0,o.jsx)("div",{className:`CalculatorDetailsShimmer_actionButton ${tn.shimmer}`})})]})})]})})]}),(0,o.jsx)("div",{className:`m-t-3 CalculatorDetailsShimmer_textExtraLong ${tn.shimmer}`})]}),a1={footer:"ResponsiveModal_footer"},a3=({title:e,media:t,body:a,className:n,open:r,scroll:l,onClose:i,footer:c})=>(0,O.e)(N.U.MEDIUM)?(0,o.jsx)(b.Z,{className:n,body:(0,o.jsxs)(o.Fragment,{children:[t,e?(0,o.jsx)(_.Z,{type:"display-small",className:"text-xs-center m-b-5 m-t-2",children:e}):null,a]}),open:r,scroll:l,footer:c,onClose:i}):(0,o.jsxs)(Z.Z,{className:n,open:r,onClose:i,children:[t,e?(0,o.jsx)(_.Z,{type:"display-small",className:"text-xs-center m-b-5 m-t-2",children:e}):null,a,c?(0,o.jsx)(I.Z,{className:a1.footer,children:c}):null]}),a2=({className:e})=>(0,o.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:[(0,o.jsx)("mask",{id:"mask0_1784_63308",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"1",y:"1",width:"15",height:"16",children:(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.51494 6.57784C9.10714 5.92624 9.46789 5.09743 9.54109 4.21994C9.61429 3.34246 9.39589 2.46533 8.91979 1.72461L7.79816 2.44553C8.11556 2.93935 8.26114 3.5241 8.21239 4.10909C8.16356 4.69408 7.92311 5.24662 7.52824 5.68102L8.51494 6.57784ZM14.1549 3.12943L13.8936 2.05555L13.1304 2.85491L12.0565 3.1162L12.8559 3.87943L13.1172 4.95332L13.8804 4.15396L14.9543 3.89266L14.1549 3.12943ZM5.117 2.38885L5.88023 3.18821L6.95411 3.4495L6.15474 4.21273L5.89345 5.28662L5.13023 4.48725L4.05633 4.22596L4.8557 3.46273L5.117 2.38885ZM3.09972 16.2272C2.35615 16.4264 1.67574 15.746 1.87498 15.0024L4.09725 6.70878C4.24609 6.15331 4.8706 5.79231 5.45714 6.07741C6.11072 6.39511 7.50439 7.1968 9.20486 8.89729C10.9053 10.5978 11.707 11.9914 12.0247 12.645C12.3098 13.2315 11.9488 13.8561 11.3934 14.0049L3.09972 16.2272ZM3.31231 14.7898L10.617 12.8325C10.2522 12.1866 9.53817 11.1162 8.26204 9.84011C6.98593 8.56391 5.91556 7.84999 5.2696 7.48511L3.31231 14.7898ZM14.8938 10.7222L15.155 11.7961L15.9544 12.5593L14.8805 12.8206L14.1173 13.62L13.856 12.5461L13.0566 11.7828L14.1305 11.5215L14.8938 10.7222ZM11.335 7.33396C11.8872 7.33396 12.335 6.88624 12.335 6.33396C12.335 5.78167 11.8872 5.33396 11.335 5.33396C10.7827 5.33396 10.335 5.78167 10.335 6.33396C10.335 6.88624 10.7827 7.33396 11.335 7.33396ZM13.04 8.03944C12.3463 8.14804 11.6934 8.43731 11.147 8.87824L11.9842 9.91594C12.3485 9.62194 12.7838 9.42911 13.2462 9.35666C13.7087 9.28429 14.1821 9.33491 14.6188 9.50336L15.0988 8.25949C14.4438 8.00666 13.7337 7.93076 13.04 8.03944Z"})}),(0,o.jsx)("g",{mask:"url(#mask0_1784_63308)",children:(0,o.jsx)("rect",{width:"18",height:"18"})}),(0,o.jsx)("path",{d:"M2.70312 15.3L4.95312 6.75C7.20312 7.2 10.9531 11.55 11.2531 13.05L2.70312 15.3Z"})]}),a4={infoCardScrollWrap:"AdditionalInfo_infoCardScrollWrap",infoCard:"AdditionalInfo_infoCard",infoTitle:"AdditionalInfo_infoTitle"},a5=({quote:e})=>{let t=(0,o.jsx)(y.Z,{amount:e.guaranteedTargetRateFluctuationBuffer,currency:e.sourceCurrency});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:a4.infoTitle,children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.guaranteedTargetRateFluctuationBuffer.title"})}),(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.guaranteedTargetRateFluctuationBuffer.content",values:{depositAmount:t}})}),(0,o.jsx)(D.Z,{className:"p-a-0 m-t-1 m-r-1",target:"_blank",href:"/help/articles/2448314/can-i-send-exact-amounts",rel:"noreferrer",children:(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,children:(0,o.jsx)(c.Z,{id:"calculator.breakdown.guaranteedTargetRateFluctuationBuffer.popover.link"})})})]})},a8=({priceItem:e,trackEvent:t})=>{var a;if(tM(e))return null;let{explanation:n,right:r}=e;if(n&&"markdown"in n)return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:a4.infoTitle,children:r}),(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,children:n.plaintext}),null==(a=n.links)?void 0:a.map(e=>(0,o.jsx)(D.Z,{className:"p-a-0 m-t-1 m-r-1",target:"_blank",href:e.url,rel:"noreferrer",onClick:()=>{null==t||t("Calculator - Fee Breakdown Modal - Dynamic Charges Link clicked")},children:(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,children:e.label})},e.label))]})},a9=({priceItem:e})=>{let{explanation:t}=e;if(t&&"label"in t)return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:a4.infoTitle,children:t.label}),(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,children:t.description})]})},a6=({paymentOption:e})=>{let{locale:t}=(0,i.Z)();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:a4.infoTitle,children:(0,o.jsx)(c.Z,{id:"calculator.totalFees.breakdown.info.estimatedFee.title"})}),(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,children:(0,o.jsx)(c.Z,{id:"calculator.totalFees.breakdown.info.estimatedFee.scheduledTransfers.description",values:{scheduledDate:(0,r.p6)(new Date(e.estimatedDelivery),t,{dateStyle:"long"})}})})]})},a7=({paymentOption:e,paymentOptionPrice:t})=>{let{left:a}=t,n="APPLE_PAY"===e.payIn?"calculator.totalFees.breakdown.info.estimatedFee.wallets.description":"calculator.totalFees.breakdown.info.estimatedFee.cards.description";return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:a4.infoTitle,children:(0,o.jsx)(c.Z,{id:"calculator.totalFees.breakdown.info.estimatedFee.title"})}),(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,children:(0,o.jsx)(c.Z,{id:n,values:{formattedFeeAmount:a}})})]})},ne=({isScheduled:e,selectedPaymentOption:t,quote:a,pricingItems:n,paymentOptionPrice:r,trackEvent:l})=>{let i=e=>n.find(t=>(null==t?void 0:t.key)===e),c=i("DYNAMIC_FX_FEE"),s=i("BRL_TAX"),u=(null==s?void 0:s.explanation)&&"label"in s.explanation,d=eF(t),p=ec(a),m=[e?(0,o.jsx)(a6,{paymentOption:t}):null,d?(0,o.jsx)(a7,{paymentOption:t,paymentOptionPrice:r}):null,c?(0,o.jsx)(a8,{priceItem:c,trackEvent:l}):null,u?(0,o.jsx)(a9,{priceItem:s}):null,p?(0,o.jsx)(a5,{quote:a}):null].filter(ei);return m.length?(0,o.jsx)("ul",{className:`${a4.infoCardScrollWrap} d-flex flow-row list-unstyled m-t-3 m-b-0`,children:m.map((e,t)=>(0,o.jsx)("li",{className:`${a4.infoCard} p-a-2`,children:e},t))}):null},nt={dashedLine:"FeeBreakdown_dashedLine",discount:"FeeBreakdown_discount",discountConfettiIcon:"FeeBreakdown_discountConfettiIcon",note:"FeeBreakdown_note",totalFees:"FeeBreakdown_totalFees"},na=({quote:e,selectedPaymentOption:t,preselectedPaymentOption:a,isScheduled:n,trackEvent:r})=>{let l=e0({quote:e,selectedPaymentOption:t,preselectedPaymentOption:a,onChangePaymentOption:void 0,isScheduled:n,shouldShowPaymentPreferences:!0}),i=e2({quote:e,selectedPaymentOption:t,isScheduled:n,showFeesAsAddition:!0}),c=[l,...i,eU({quote:e,selectedPaymentOption:t})].filter(ei);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("dl",{role:"list",className:"p-a-0 m-b-0 m-t-3",children:[c.map(e=>(0,o.jsx)("div",{className:"d-flex justify-content-between align-items-center m-b-1",children:(0,o.jsx)(nn,{item:e})},e.key)),(0,o.jsx)("div",{className:"d-flex m-b-1",children:(0,o.jsx)("div",{className:`${nt.dashedLine} m-y-2`,children:(0,o.jsx)("hr",{className:"m-a-0"})})}),(0,o.jsx)("div",{className:"d-flex justify-content-between",children:(0,o.jsx)(nr,{selectedPaymentOption:t,quote:e})})]}),(0,o.jsx)(ne,{isScheduled:n,pricingItems:i,paymentOptionPrice:l,selectedPaymentOption:t,quote:e,trackEvent:r})]})},nn=({item:e})=>{if(tM(e))return null;let{left:t,right:a,key:n}=e;return"DISCOUNT"===n?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("dt",{children:(0,o.jsxs)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:`${nt.discount} d-flex`,children:[a,(0,o.jsx)(a2,{className:nt.discountConfettiIcon})]})}),(0,o.jsx)("dd",{className:"m-b-0",children:(0,o.jsxs)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,className:nt.discount,children:["-",t]})})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("dt",{children:(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,children:a})}),(0,o.jsx)("dd",{className:"m-b-0",children:(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,children:t})})]})},nr=({selectedPaymentOption:e,quote:t})=>{var a;let n=e.fee.total+(null!=(a=t.guaranteedTargetRateFluctuationBuffer)?a:0);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("dt",{children:(0,o.jsx)(p.Z,{type:m.Z.BODY_LARGE_BOLD,children:(0,o.jsx)(c.Z,{id:"calculator.totalFees.breakdown.totalFee.label"})})}),(0,o.jsxs)("dd",{className:"text-xs-right m-b-0",children:[(0,o.jsx)(p.Z,{type:m.Z.BODY_LARGE_BOLD,children:(0,o.jsx)(y.Z,{amount:n,currency:e.sourceCurrency})}),n>0?(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,className:nt.note,children:(0,o.jsx)(c.Z,{id:"calculator.totalFees.breakdown.totalAmountPaid.note"})}):(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT,className:nt.note,children:(0,o.jsx)(c.Z,{id:"calculator.free.transfer"})})]})]})},nl=({quote:e,selectedPaymentOption:t,isScheduled:a})=>{let[n,r]=(0,l.useState)(!1),i=e2({quote:e,selectedPaymentOption:t,isScheduled:a,showFeesAsAddition:!0}).find(e=>(null==e?void 0:e.key)==="DYNAMIC_FX_FEE");return!i||tM(i)?null:i.explanation&&"markdown"in i.explanation?(0,o.jsx)(tL,{open:n,explanation:i.explanation,onClose:()=>r(!1)}):void 0};function no(e){var{children:t}=e,a=(0,n.S0)(e,["children"]);return(0,o.jsx)(f.Z,(0,n.EZ)((0,n.ih)({},a),{children:(0,o.jsx)(aO,{children:t})}))}var ni=({selectedPaymentOption:e,quote:t,isScheduled:a,onClick:n})=>{var l;let{fee:i,feePercentage:s,sourceCurrency:u}=e,d=i.total+(null!=(l=t.guaranteedTargetRateFluctuationBuffer)?l:0);return(0,o.jsxs)("div",{className:`m-t-3 d-flex justify-content-between align-items-center ${nt.totalFees}`,children:[(0,o.jsxs)("span",{children:[(()=>{var n;let l=eF(e)||a,i=null==(n=t.transferFlowConfig.highAmount)?void 0:n.showFeePercentage,u=eu(e),d={feePercentage:(0,r.rl)(s)};return l&&i&&u?(0,o.jsx)(c.Z,{id:"calculator.includedFees.percentage.estimated.taxes.label",values:d}):l&&i?(0,o.jsx)(c.Z,{id:"calculator.includedFees.percentage.estimated.label",values:d}):l&&u?(0,o.jsx)(c.Z,{id:"calculator.includedFees.taxes.estimated.label"}):i&&u?(0,o.jsx)(c.Z,{id:"calculator.includedFees.taxes.percentage.label",values:d}):l?(0,o.jsx)(c.Z,{id:"calculator.includedFees.estimated.label"}):i?(0,o.jsx)(c.Z,{id:"calculator.includedFees.percentage.label",values:d}):u?(0,o.jsx)(c.Z,{id:"calculator.includedFees.taxes.label"}):(0,o.jsx)(c.Z,{id:"calculator.includedFees.label"})})(),i.discount>0&&(0,o.jsxs)(p.Z,{className:`${nt.discount} d-flex`,children:[(0,o.jsx)(c.Z,{id:"calculator.totalFees.discount.label",values:{amount:(0,o.jsx)(p.Z,{type:m.Z.BODY_DEFAULT_BOLD,style:{marginRight:"3px"},children:(0,o.jsx)(y.Z,{amount:i.discount,currency:u})})}}),(0,o.jsx)(a2,{className:nt.discountConfettiIcon})]})]}),(0,o.jsx)(no,{priority:"secondary",onClick:n,children:(0,o.jsx)(y.Z,{amount:d,currency:u})})]})},nc=({preselectedPaymentOption:e,quote:t,selectedPaymentOption:a,isScheduled:n=!1,trackEvent:r})=>{let[i,s]=(0,l.useState)(!1),u=eF(a)||n;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(ni,{quote:t,selectedPaymentOption:a,isScheduled:n,onClick:()=>{s(!0),null==r||r("Calculator - Fee Breakdown Modal - Started")}}),(0,o.jsx)(nl,{quote:t,selectedPaymentOption:a,isScheduled:n}),(0,o.jsx)(a3,{body:(0,o.jsxs)("div",{className:"p-t-1",children:[(0,o.jsx)(x.Z,{type:m.Z.TITLE_SECTION,children:(0,o.jsx)(c.Z,{id:u?"calculator.totalFees.breakdown.modal.header.estimated":"calculator.totalFees.breakdown.modal.header"})}),(0,o.jsx)(na,{quote:t,selectedPaymentOption:a,preselectedPaymentOption:e,isScheduled:n,trackEvent:r})]}),open:i,scroll:"content",onClose:()=>{s(!1),null==r||r("Calculator - Fee Breakdown Modal - Finished")}})]})},ns=({preselectedPaymentOption:e,sourceCurrency:t,onSourceCurrencyChange:a,sourceAmount:n,sourceInputError:r,onSourceAmountChange:s,targetCurrency:u,onTargetCurrencyChange:d,targetAmount:p,targetInputError:m,onTargetAmountChange:y,onPaymentOptionChange:h,selectedPaymentOption:x,selectedPreferredPayIn:f,guaranteedTargetAmount:b,onGuaranteedTargetAmountChange:j,quote:C,amountType:w,hideBreakdown:T,onOtherCurrencySelected:v,currentBalanceAmount:E,contact:A,onCurrentBalanceAmountClicked:I,savings:S,errors:k,children:O,currencies:N,isScheduledTransfer:_,isUpdatingQuote:Z,isUpdatingRate:D,updateQuoteParameters:L,shouldShowPaymentPreferences:B,paymentPreferences:U,routes:M,paymentOptions:$,rate:Y,trackEvent:Q,onValidateCalculatorState:G,hasPaymentMethodInputRequiredError:W,hasAmountsRequiredError:V=!1,profileType:q})=>{var H;let{isFeatureEnabled:K}=eG(),X=K(eY.SEND_CALCULATOR_2_0),[z,J]=(0,l.useState)(!1),{shouldForcePaymentMethodInput:ee}=aU({quote:C,paymentPreferences:U,selectedPreferredPayIn:f});(0,l.useEffect)(()=>{!C&&X&&J(!0)},[X,C]);let et="SOURCE"===w,ea=(0,i.Z)(),en=()=>et||!C?"calculator.targetMoneyInput.label":"calculator.targetMoneyInput.label.fixedTarget",er=({inputType:e})=>{let a="source"===e?r:m,l="source"===e?n:p,i="source"===e?t:u;return eq({["source"===e?"sourceAmount":"targetAmount"]:l,["source"===e?"sourceCurrency":"targetCurrency"]:i}),(0,o.jsx)(g.Z,{type:"negative",children:V?(0,o.jsx)(c.Z,{id:"calculator.input.error.no.amounts"}):null==a?void 0:a.message})},el=()=>{let e=eZ(x);return B&&!!e},ei=(null==f?void 0:f.method)==="BALANCE",ec=()=>{if(!_||!$||x&&"BALANCE"!==x.payIn)return!1;let e=eA($);return!(e&&e_(e,[]))},eu=e=>{if(e)return t=>{null!==t&&e(t)}},ed="tw-calculator-source",ep=!(el()||ec())&&r,em=!B&&!X&&!r&&ei&&!!E&&"function"==typeof I&&!_,ey=x&&C&&X?!!(x.fee.total+(null!=(H=C.guaranteedTargetRateFluctuationBuffer)?H:0))&&!eo({sourceCurrency:t,targetCurrency:u})&&"BUSINESS"===q:null,eh=!B&&(null==x?void 0:x.payIn)==="BALANCE"&&!!E&&x.sourceAmount>E&&"function"==typeof I&&!_,ex=ec(),ef=!B&&!!e&&!!eZ(x),eb=e=>{let{countryKeywords:t=[],name:a=""}=tK(e,N)||{};return{value:e,label:e,currency:e,note:a,searchable:t.join(" ,")}},ej=e=>{let t=tH({currencies:e,indexProperty:"recentUsageIndex"}),a=tH({currencies:e,indexProperty:"popularityIndex"});return e.length<=3?[]:t.length>0?[{header:ea.formatMessage({id:"calculator.label.recent.currencies"})},...t.map(({currencyCode:e})=>eb(e))]:a.length>0?[{header:ea.formatMessage({id:"calculator.label.popular.currencies"})},...a.map(({currencyCode:e})=>eb(e))]:[]},eC=tG(M.sourceCurrencies,t),eg=()=>{if(!A)return null;let e=af(A)?ab(A):A.display.title;return e.length>20?`${e.substring(0,17)}...`:e},{handleSourceCurrencySearchChange:ew,handleTargetCurrencySearchChange:eT,sourceCurrencyLabel:ev,targetCurrencyLabel:eE}=aS({currencies:N,sourceCurrency:t,targetCurrency:u});return(0,o.jsxs)(o.Fragment,{children:[X&&(0,o.jsx)(aw,{isRateVisible:eo({sourceCurrency:t,targetCurrency:u})}),(0,o.jsxs)("div",{"data-tracking-id":"calculator","data-testid":"calculator",className:"tw-claculator",children:[X?(0,o.jsx)(ah,{fadeInElement:z,sourceCurrency:t,targetCurrency:u,isUpdatingQuote:Z,isUpdatingRate:D,rate:Y,quote:C,selectedPaymentOption:x,isScheduledTransfer:_,trackEvent:Q}):null,(0,o.jsxs)("div",{"data-testid":"source-amount",className:R({"has-info":em||_||ey,"has-error":V||ep||eh||ef}),children:[(0,o.jsx)(P.g,{id:ed,label:_&&!et&&(null==x?void 0:x.payIn)!=="BALANCE"?(0,o.jsx)(c.Z,{id:"calculator.label.you.send.approximately"}):et?(0,o.jsx)(c.Z,{id:"calculator.label.you.send.fixedSource"}):(0,o.jsx)(c.Z,{id:"calculator.label.you.send"}),className:"m-b-0",children:(0,o.jsx)(F.Z,{id:ed,currencies:[...ej(M.sourceCurrencies),{header:ea.formatMessage({id:"calculator.label.all.currencies"})},...M.sourceCurrencies.map(({currencyCode:e})=>eb(e))],selectedCurrency:tX(t),amount:C?n:null,placeholder:C?void 0:0,customActionLabel:v?ev:null,searchPlaceholder:ea.formatMessage({id:"calculator.moneyInputs.searchPlaceholder"}),onCurrencyChange:M.sourceCurrencies.length>1?a:void 0,onAmountChange:eu(s),onSearchChange:ew,onCustomAction:v})}),!eh&&!(el()||ec())&&!!r&&er({inputType:"source"}),(em||eh)&&(0,o.jsx)(as,{currency:t,amount:E,insufficientBalance:eh,onClick:I}),ex&&(0,o.jsx)(az,{}),ey&&(0,o.jsx)(aj,{quote:C,selectedPaymentOption:x}),ef&&!es(e)&&(0,o.jsx)(g.Z,{type:"negative",children:eZ(x)})]}),T||!x||!C||X?(0,o.jsx)("div",{className:"m-t-3"}):(0,o.jsxs)(o.Fragment,{children:[B&&(0,o.jsx)(aM,{quote:C,selectedPaymentOption:x,selectedPreferredPayIn:f,paymentPreferences:U,sourceCurrency:t,currentBalanceAmount:E,preselectedPaymentOption:e,trackEvent:Q,hasPaymentMethodInputRequiredError:W,onSelectPaymentMethod:h,onCurrentBalanceAmountClicked:I}),ee?(0,o.jsx)("div",{className:"m-t-2"}):(0,o.jsx)(aC,{quote:C,selectedPaymentOption:x,preselectedPaymentOption:e,isScheduled:_,shouldShowPaymentPreferences:B,trackEvent:Q,onChangePaymentOption:e=>h({method:e.payIn,id:null})})]}),(0,o.jsxs)("div",{"data-testid":"target-amount",className:R({"has-error":V||m}),children:[(0,o.jsx)(P.g,{id:"tw-calculator-target",label:(()=>{let e=eg()||ea.formatMessage({id:"calculator.label.receiver"});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.Z,{id:en(),values:{name:e}}),et&&(null==C?void 0:C.rateType)==="FLOATING"?(0,o.jsxs)(o.Fragment,{children:[" ",(0,o.jsx)(c.Z,{id:"calculator.label.aprox"})]}):null]})})(),className:"m-b-0",children:(0,o.jsx)(F.Z,{id:"tw-calculator-target",currencies:[...ej(eC),{header:ea.formatMessage({id:"calculator.label.all.currencies"})},...eC.map(({currencyCode:e})=>eb(e))],selectedCurrency:tX(u),amount:C?p:null,placeholder:C?void 0:0,searchPlaceholder:ea.formatMessage({id:"calculator.moneyInputs.searchPlaceholder"}),addon:X?null:j?(0,o.jsx)(ak,{locked:!!b,onChange:j}):null,customActionLabel:v&&!A?eE:null,onCurrencyChange:eC.length>1?d:void 0,onAmountChange:eu(y),onSearchChange:eT,onCustomAction:v&&!A?v:void 0})}),V||m?er({inputType:"target"}):null]}),!C&&Z&&X?(0,o.jsx)(a0,{}):(0,o.jsxs)(o.Fragment,{children:[x&&C&&X?B?(0,o.jsx)(tC,{shouldFadeIn:z,children:(0,o.jsx)(aM,{quote:C,selectedPaymentOption:x,selectedPreferredPayIn:f,paymentPreferences:U,sourceCurrency:t,currentBalanceAmount:E,preselectedPaymentOption:e,trackEvent:Q,hasPaymentMethodInputRequiredError:W,onSelectPaymentMethod:h,onCurrentBalanceAmountClicked:I})}):void 0:null,x&&C&&X?ee?(0,o.jsx)("div",{className:"m-t-2"}):(0,o.jsx)(tC,{shouldFadeIn:z,children:(0,o.jsx)(nc,{selectedPaymentOption:x,quote:C,preselectedPaymentOption:e,isScheduled:_,trackEvent:Q})}):null,!T&&x&&(0,o.jsx)(tt,{selectedPaymentOption:x}),O?O({savings:S,quote:C,errors:k||null,selectedPaymentOption:x,userEnteredSourceAmount:n,userEnteredSourceCurrency:t,userEnteredTargetAmount:p,userEnteredTargetCurrency:u,isUpdatingQuote:Z,updateQuoteParameters:L,validateCalculatorState:G}):null]})]})]})},nu=()=>{let{formatMessage:e}=(0,i.Z)();return(0,o.jsx)(S.Z,{type:A.P.NEGATIVE,message:e({id:"calculator.quoteError"})})},nd=({quote:e,isValidQuote:t,balanceWithdrawal:a})=>{let[n,r]=(0,l.useState)(null),o=(0,l.useMemo)(()=>{if(!e||!t)return null;let n=a?eA(e.paymentOptions):ev(e);return{sourceCurrency:e.sourceCurrency,targetCurrency:e.targetCurrency,rate:e.rate,sendAmount:n.sourceAmount,fee:n.fee.total,type:"MOST_EXPENSIVE_QUOTE",alias:"wise",midMarketRate:e.rate}},[a,t,e]);return(0,l.useEffect)(()=>{let e=!1;return o?tj(o).then(t=>{e||(t&&t.value>0?r(t):r(null))}):r(null),()=>{e=!0}},[o]),n},np="UPDATE_SELECTED_PAYMENT_OPTION",nm="UPDATE_GUARANTEED_TARGET_AMOUNT",ny="UPDATE_RATE",nh="UPDATE_QUOTE_PARAMETERS",nx="UPDATE_QUOTE_TYPE",nf="SYNC_STATE_WITH_QUOTE",nb="ON_QUOTE_ERROR",nj="UPDATE_STATE_WITH_INITIAL_QUOTE";function nC(e,t){let{shouldFetchNewQuote:a=!1}=t.payload||{};switch(t.type){case np:return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,selectedPreferredPayIn:t.payload.payIn});case nm:{let{guaranteedTargetAmount:r}=t.payload;return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,guaranteedTargetAmount:r,amountType:"TARGET"})}case ny:{let{rate:r}=t.payload;return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a,rate:r})}case nx:{let{type:a}=t.payload;return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:e.type!==a,type:a})}case nh:{let{type:r,preferredPayIn:l,preferredPayInId:o,expectedFulfillmentTime:i}=t.payload;return(0,n.ih)((0,n.ih)({},e),function(e){let t=(0,n.ih)({},e);return Object.keys(t).forEach(e=>{void 0===t[e]&&delete t[e]}),t}({shouldFetchNewQuote:a,type:r,selectedPreferredPayIn:l?{id:o||null,method:l,setBy:"SYSTEM"}:null,expectedFulfillmentTime:i}))}case nf:{let{quote:r}=t.payload,l=ew(r,e.selectedPreferredPayIn),o=es(e.preselectedPaymentOption)?eA(r.paymentOptions):l||ev(r,r.preferredPayIn),i={shouldFetchNewQuote:a,amountType:r.providedAmountType,sourceCurrencyCode:r.sourceCurrency,targetCurrencyCode:r.targetCurrency,guaranteedTargetAmount:r.guaranteedTargetAmount,type:r.type,expectedFulfillmentTime:r.expectedFulfillmentTime,sourceAmount:o.sourceAmount,targetAmount:o.targetAmount,rate:r.rate};return r.targetAmountAllowed||(i.amountType="SOURCE"),(0,n.EZ)((0,n.ih)((0,n.ih)({},e),i),{selectedPreferredPayIn:(()=>{if(e.selectedPreferredPayIn){if(o.payIn===(null==l?void 0:l.payIn))return(0,n.EZ)((0,n.ih)({},e.selectedPreferredPayIn),{method:o.payIn});if(o.payIn!==e.selectedPreferredPayIn.method)return null}return e.selectedPreferredPayIn})()})}case nb:return(0,n.EZ)((0,n.ih)({},e),{shouldFetchNewQuote:a});case nj:return(0,n.EZ)((0,n.ih)({},e),{selectedPreferredPayIn:eT(t.payload.quote)});default:return t6(e,t)}}var ng=({quote:e,validQuote:t,selectedPaymentOption:a,preselectedPaymentOption:r,initialState:o,initialSelectedPayIn:i})=>{let[c,s]=(0,l.useReducer)(nC,function({quote:e,validQuote:t,selectedPaymentOption:a,preselectedPaymentOption:r,initialState:l,initialSelectedPayIn:o}){return e&&t&&a?function({quote:e,selectedPaymentOption:t,preselectedPaymentOption:a}){return(0,n.EZ)((0,n.ih)({},ae(e,t)),{shouldFetchNewQuote:!1,selectedPreferredPayIn:eT(e),preselectedPaymentOption:a,guaranteedTargetAmount:e.guaranteedTargetAmount||!1,expectedFulfillmentTime:e.expectedFulfillmentTime||null,type:e.type,rate:e.rate})}({quote:e,selectedPaymentOption:a,preselectedPaymentOption:r}):l?function({initialState:e,preselectedPaymentOption:t,initialSelectedPayIn:a}){return{sourceCurrencyCode:e.sourceCurrency,targetCurrencyCode:e.targetCurrency,shouldFetchNewQuote:!1,selectedPreferredPayIn:null!=a?a:null,guaranteedTargetAmount:!1,amountType:null,expectedFulfillmentTime:null,preselectedPaymentOption:t,sourceAmount:0,targetAmount:0,type:null,rate:e.rate}}({initialState:l,preselectedPaymentOption:r,initialSelectedPayIn:o}):{}}({quote:e,validQuote:t,selectedPaymentOption:a,preselectedPaymentOption:r,initialState:o,initialSelectedPayIn:i}));return(0,n.EZ)((0,n.ih)({state:c},t7(s)),{updateSelectedPaymentOption:e=>s({type:np,payload:{shouldFetchNewQuote:!0,payIn:e}}),updateGuaranteedTargetamount:e=>s({type:nm,payload:{shouldFetchNewQuote:!0,guaranteedTargetAmount:e}}),updateRate:e=>s({type:ny,payload:{shouldFetchNewQuote:!1,rate:e}}),updateQuoteType:e=>s({type:nx,payload:{shouldFetchNewQuote:!0,type:e}}),updateQuoteParameters:e=>s({type:nh,payload:(0,n.ih)({shouldFetchNewQuote:!0},e)}),syncStateWithQuote:({quote:e})=>s({type:nf,payload:{shouldFetchNewQuote:!1,quote:e}}),onQuoteError:()=>s({type:nb,payload:{shouldFetchNewQuote:!1}}),updatePreferredPayInWithInitialQuote:({quote:e})=>s({type:nj,payload:{shouldFetchNewQuote:!1,quote:e}})})},nw=({quote:e,isValidQuote:t,initialState:a,selectedPaymentOption:r,preselectedPaymentOption:o,initialSelectedPayIn:i})=>{let c=ng({quote:e,initialState:a,validQuote:t,selectedPaymentOption:r,preselectedPaymentOption:o,initialSelectedPayIn:i}),{state:s,syncStateWithQuote:u,updatePreferredPayInWithInitialQuote:d}=c,p=(0,n.S0)(c,["state","syncStateWithQuote","updatePreferredPayInWithInitialQuote"]),m=(0,l.useRef)(!1),{isFeatureEnabled:y}=eG();return(0,l.useEffect)(()=>{t&&e&&(!m.current&&y(eY.SEND_CALCULATOR_2_0)&&(d({quote:e}),m.current=!0),u({quote:e}),function({sourceAmount:e,sourceCurrency:t,transferFlowConfig:a}){var n;(null==(n=null==a?void 0:a.highAmount)?void 0:n.trackAsHighAmountSender)&&eV("High amount user detected",{sourceCurrency:t,sourceAmount:e})}(e))},[e]),(0,n.ih)({state:s,syncStateWithQuote:u},p)},nT=()=>{},nv=({initialState:e,quote:t,routes:a,currencies:r,balances:c,hideBreakdown:s=!1,onOtherCurrencySelected:u,preselectedPaymentOption:d=null,onQuoteChange:p=nT,onQuoteFailure:m=nT,onCalculatorRenderError:y=null,children:h=null,contact:x,isScheduledTransfer:f=!1,sourceAmount:b,shouldHideInputError:j=!1,shouldShowPaymentPreferences:C=!1,paymentPreferences:g=null,selectedPayIn:w=null,sendSessionId:T,onSelectedPayInChange:v,profileType:E,trackEvent:A})=>{var I,S;let k=(0,l.useMemo)(()=>t?function(e){var t;let a=(null==(t=e.transferFlowConfig)?void 0:t.hiddenPaymentOptions)||[];return(0,n.EZ)((0,n.ih)({},e),{paymentOptions:e.paymentOptions.filter(({payIn:e})=>!a.includes(e))})}(t):null,[t]),{locale:O}=(0,i.Z)(),N=(0,M.F)(),_=es(d),Z={quote:k,routes:a,currencies:r,preselectedPaymentOption:d,initialState:e},D=aa(Z),{state:P,updateSourceAmount:F,updateTargetAmount:R,updateSourceCurrency:L,updateTargetCurrency:B,updateSourceAndTargetCurrencies:U,updateSelectedPaymentOption:$,updateGuaranteedTargetamount:Y,updateQuoteType:Q,updateQuoteParameters:G,updateRate:W,onQuoteError:V}=nw((0,n.EZ)((0,n.ih)({},Z),{isValidQuote:D,selectedPaymentOption:k?ev(k,k.preferredPayIn):null,initialSelectedPayIn:w})),{errors:q,showQuoteError:H}=function({state:e,quote:t,initialState:a,isValidQuote:n,onQuoteChange:r,onQuoteFailure:o,hasCustomCalculatorErrorHandler:i}){let{shouldFetchNewQuote:c}=e,[{errors:s,showQuoteError:u},d]=(0,l.useState)({errors:[],showQuoteError:!1}),{debouncedUpdateQuote:p}=al({handleQuoteChange:e=>{r(e),d({errors:[],showQuoteError:!1})},handleQuoteFailure:e=>{let t=tl(e)?e.body.errors:[];d({errors:t,showQuoteError:!n}),o(t)},getQuoteParams:ai});return(0,l.useEffect)(()=>{n||i||d({errors:s,showQuoteError:!0})},[n,i,s]),(0,l.useEffect)(()=>{if(n&&c){let n={id:null==a?void 0:a.quoteId,profile:null==a?void 0:a.profileId};p(e,null!=t?t:n)}},[e]),{errors:s,showQuoteError:u}}((0,n.EZ)((0,n.ih)({},Z),{state:P,onQuoteChange:p,onQuoteFailure:m,isValidQuote:D,hasCustomCalculatorErrorHandler:!!y})),{shouldFetchNewQuote:K,sourceCurrencyCode:X,targetCurrencyCode:z,sourceAmount:J,targetAmount:ee,amountType:et,selectedPreferredPayIn:er,guaranteedTargetAmount:el,rate:eo}=P,{selectedPayIn:ei,paymentOption:ec}=eP({quote:k,preselectedPaymentOption:d,selectedPreferredPayIn:er,shouldShowPaymentPreferences:C}),{validateCalculatorState:eu,hasPaymentMethodInputRequiredError:ed,hasAmountsRequiredError:em}=function({quote:e,state:{selectedPreferredPayIn:t,sourceCurrencyCode:a,targetCurrencyCode:n},paymentPreferences:r,trackEvent:o}){let{shouldForcePaymentMethodInput:i}=aU({quote:e,paymentPreferences:r,selectedPreferredPayIn:t}),{hasPaymentMethodInputRequiredError:c,setHasPaymentMethodInputRequiredError:s}=function({quote:e,paymentPreferences:t,selectedPreferredPayIn:a,selectedSourceCurrency:n,selectedTargetCurrency:r}){let{shouldForcePaymentMethodInput:o}=aU({quote:e,paymentPreferences:t,selectedPreferredPayIn:a}),[i,c]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let t=!!e&&(e.sourceCurrency!==n||e.targetCurrency!==r);(!o||t)&&c(!1)},[e,o,n,r]),{hasPaymentMethodInputRequiredError:i,setHasPaymentMethodInputRequiredError:c}}({quote:e,paymentPreferences:r,selectedPreferredPayIn:t,selectedSourceCurrency:a,selectedTargetCurrency:n}),{hasAmountsRequiredError:u,setHasAmountsRequiredError:d}=function({quote:e}){let[t,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{e&&a(!1)},[e]),{hasAmountsRequiredError:t,setHasAmountsRequiredError:a}}({quote:e});return{validateCalculatorState:()=>i?(null==o||o("Calculator - Continue Without Payment Method"),s(!0),{canContinue:!1}):e?{canContinue:!0}:(null==o||o("Calculator - Continue Without Amounts"),d(!0),{canContinue:!1}),hasPaymentMethodInputRequiredError:c,hasAmountsRequiredError:u}}({quote:k,state:P,paymentPreferences:g,trackEvent:A});(0,l.useEffect)(()=>{q.length>0&&V()},[q]),(0,l.useEffect)(()=>{ei&&"USER"!==ei.setBy&&(null==v||v(ei)),C&&ey()},[null==ei?void 0:ei.method,null==ei?void 0:ei.id,null==w?void 0:w.id,null==w?void 0:w.method]);let ey=()=>{k&&"PRELIMINARY"!==k.type&&"PRELIMINARY"!==P.type&&((null==ei?void 0:ei.method)==="BALANCE"?Q("SPOT"):Q("REGULAR"))},eh=tz(a,{sourceCurrencies:d?[X]:void 0,targetCurrencies:x?ax(x):void 0}),ex=ea({balances:c,currency:X,balanceId:null!=(I=en(k))?I:Number(null==w?void 0:w.id)}),ef=nd({quote:k,isValidQuote:D,balanceWithdrawal:_}),eb=!!(J||ee),[ej,eC]=(0,l.useState)(!1),eg=async e=>{if(!eb&&e)try{eC(!0);let t=await td({sourceCurrency:"sourceCurrency"in e?e.sourceCurrency:void 0,targetCurrency:"targetCurrency"in e?e.targetCurrency:void 0,sendSessionId:T,locale:O,theming:N});W(t.rate)}catch(e){console.log(e)}finally{eC(!1)}},ew=(0,l.useCallback)(e=>{F(e),eV("sourceAmount changed",{sourceAmount:e,sourceCurrency:X,targetAmount:ee,targetCurrency:z})},[X,ee,z]),eT=(0,l.useCallback)(e=>{R(e),eV("targetAmount changed",{sourceAmount:J,sourceCurrency:X,targetAmount:e,targetCurrency:z})},[J,X,z]),eE=async({value:e})=>{var t;if(tJ(eh,e,z))L(e,eb);else{let n=null==(t=t0(tG(a.sourceCurrencies,e))[0])?void 0:t.currencyCode;if(!n)throw Error("Source currency has no valid target currencies!");U({sourceCurrencyCode:e,targetCurrencyCode:n},eb)}eb&&$(function(e,t){if(!t)return null;let a=ep(t,e);return a?{method:a.payInType,id:a.payInId||null,setBy:"SYSTEM"}:null}(e,g)),await eg({sourceCurrency:e}),eV("sourceCurrency changed",{sourceAmount:J,sourceCurrency:e,targetAmount:ee,targetCurrency:z})},eA=async({value:e})=>{B(e,eb),await eg({targetCurrency:e}),eV("targetCurrency changed",{sourceAmount:J,sourceCurrency:X,targetAmount:ee,targetCurrency:e})};return((0,l.useEffect)(()=>{!D&&y&&y()},[D]),at({quote:k,isValidQuote:D}),(0,l.useEffect)(()=>{eV("load",{sourceCurrency:X,targetCurrency:z,sourceAmount:J,targetAmount:ee})},[]),(0,l.useEffect)(()=>{b&&b!==J&&ew(b)},[b]),H)?(0,o.jsx)(nu,{}):D&&Object.keys(P).length?(0,o.jsx)(ns,{preselectedPaymentOption:d,hideBreakdown:s,sourceCurrency:X,sourceAmount:J,sourceInputError:j?null:e_(ec,q),targetCurrency:z,targetInputError:j?null:eD(ec,q),targetAmount:ee,selectedPaymentOption:ec,selectedPreferredPayIn:er,guaranteedTargetAmount:el,amountType:et,quote:k,contact:x,currentBalanceAmount:ex,savings:ef,errors:q,currencies:r,isScheduledTransfer:f,isUpdatingQuote:K,isUpdatingRate:ej,updateQuoteParameters:G,shouldShowPaymentPreferences:C,paymentPreferences:g,routes:eh,paymentOptions:null!=(S=null==k?void 0:k.paymentOptions)?S:null,trackEvent:A,rate:eo,hasPaymentMethodInputRequiredError:ed,hasAmountsRequiredError:em,profileType:E,onSourceCurrencyChange:eE,onSourceAmountChange:ew,onTargetCurrencyChange:eA,onTargetAmountChange:eT,onPaymentOptionChange:({method:e,id:t})=>{let a={method:e,id:t,setBy:"USER"};null==v||v(a),$(a)},onGuaranteedTargetAmountChange:k&&k.guaranteedTargetAmountAllowed&&!_?Y:void 0,onOtherCurrencySelected:u,onCurrentBalanceAmountClicked:ew,onValidateCalculatorState:eu,children:h}):null},nE=[],nA=e=>{var{context:t,features:a=nE}=e,r=(0,n.S0)(e,["context","features"]);return(0,o.jsx)(eQ,{context:a,children:(0,o.jsx)(eL,{context:t,children:(0,o.jsx)(nv,(0,n.ih)({},r))})})}}}]); //# sourceMappingURL=9f614e6a-0b5b4b1937a42e10.js.map