Loading
function(e,t,n){"use strict";n.d(t,{n:()=>S,N:()=>_});var l=n(627968),i=n(64700),s=n(17928),r=n(637141),a=n(606267),o=n(176095),u=n(826469),c=n(351906),d=n(120700),m=n(944355),h=n(211159),p=n(186460);let f=new Set([d.C.ORB_CHECKOUT]);function g(e){let{onGiftCardRedeemed:t}=e,n=(0,h.t4)(e=>e.unifiedCheckoutFlow);return null!=n&&f.has(n)?null:(0,l.jsx)(m.Z4,{className:p.K,onComplete:t})}var E=n(364995),A=n(655857),C=n(165272),x=n(327105),I=n(375708);function _(e){let{setPaymentSourceId:t,paymentSourceId:n,label:r,additionalPaymentSourceDropdownProps:u,disabled:d,location:p,onPaymentSourceAdd:f,subscriptionPaymentSourceId:C,hideCurrencySelect:x,resolveInternalState:_,renderCustomPaymentSourceSelectorContent:S}=e,{setPaymentSourceId:y,paymentSourceId:v}=function(e){let{setPaymentSourceId:t,paymentSourceId:n}=(0,h.t4)(e=>({setPaymentSourceId:e.setPaymentSourceId,paymentSourceId:e.paymentSourceId})),{setPaymentSourceId:l,paymentSourceId:s}=i.useMemo(()=>({setPaymentSourceId:void 0!==e.setPaymentSourceId?e.setPaymentSourceId:t,paymentSourceId:void 0!==e.paymentSourceId?e.paymentSourceId:n}),[e.setPaymentSourceId,e.paymentSourceId,t,n]);return{setPaymentSourceId:l,paymentSourceId:s}}({setPaymentSourceId:t,paymentSourceId:n}),[T,N]=i.useState(!1),{giftCardsEnabled:j,giftCardCheckboxProps:b,walletCoversSubtotal:R,basePaymentSourceDropdownProps:P,isSubscriptionPaidByWallet:L,hidePersonalInformation:M}=function(e){let{paymentSourceId:t,setPaymentSourceId:n,location:l,subscriptionPaymentSourceId:r,pendingGiftCardWalletSelection:u,setPendingGiftCardWalletSelection:d}=e,{hasInvoiceOrderContextLoaded:m,checkoutPaymentSources:p}=(0,E.t)(),f=(0,h.t4)(e=>e.checkoutInvoiceError),{dropdownPaymentSources:g,giftCardsEnabled:A,dropdownPaymentSourceId:C,handleDropdownPaymentSourceChange:x,giftCardCheckboxProps:I,walletCoversSubtotal:_,isSubscriptionPaidByWallet:S,giftCardWallet:y,isGiftCardCreditsChecked:v,isWalletBalanceLoaded:T,handleGiftCardCreditsToggle:N}=(0,a.Y0)({checkoutPaymentSources:p,paymentSourceId:t,setPaymentSourceId:n,location:l??"BaseStatefulPaymentSourceSelector",isReady:m,subscriptionPaymentSourceId:r});!function(e){let{giftCardWallet:t,isWalletBalanceLoaded:n,walletCoversSubtotal:l,isGiftCardCreditsChecked:r,subscriptionPaymentSourceId:a,handleGiftCardCreditsToggle:u,pendingGiftCardWalletSelection:c,setPendingGiftCardWalletSelection:d}=e,m=(0,s.bG)([o.A],()=>null!=t&&o.A.getIsFetching(t.id),[t]),h=i.useRef(!1);i.useEffect(()=>{if(!c){h.current=!1;return}if(null!=t){if(m){h.current=!0;return}if(n){if(null!=a&&a!==t.id||r)return void d(!1);if(l){u(!0),d(!1);return}h.current&&d(!1)}}},[c,t,m,n,l,r,a,u,d])}({giftCardWallet:y,isWalletBalanceLoaded:T,walletCoversSubtotal:_,isGiftCardCreditsChecked:v,subscriptionPaymentSourceId:r,handleGiftCardCreditsToggle:N,pendingGiftCardWalletSelection:u,setPendingGiftCardWalletSelection:d});let j=i.useMemo(()=>{let e=g.find(e=>e.isDefault);return null!=e?e.id:void 0},[g]),b=(0,s.bG)([c.A],()=>c.A.hidePersonalInformation??!1);return{giftCardsEnabled:A,giftCardCheckboxProps:I,walletCoversSubtotal:_,basePaymentSourceDropdownProps:i.useMemo(()=>({selectedPaymentSourceId:C,paymentSources:g,defaultPaymentSourceId:j,hidePersonalInformation:b,onChange:x,dropdownLoading:!m&&null==f}),[C,g,j,b,x,m,f]),isSubscriptionPaidByWallet:S,hidePersonalInformation:b}}({paymentSourceId:v,setPaymentSourceId:y,location:p,subscriptionPaymentSourceId:C,pendingGiftCardWalletSelection:T,setPendingGiftCardWalletSelection:N}),{priceOptions:O,setCurrency:w}=(0,h.t4)(e=>({priceOptions:e.checkoutPriceOptions,setCurrency:e.setCheckoutCurrency})),{dropdownCurrencies:k,displayCurrency:D}=(0,A.Jn)(),U=i.useCallback(()=>N(!0),[]),{giftCardCheckboxProps:G,disabled:F}=i.useMemo(()=>{let e=d??!1;return null!=_?_({giftCardCheckboxProps:b,disabled:e},{isSubscriptionPaidByWallet:L}):{giftCardCheckboxProps:b,disabled:e}},[_,b,d,L]),V=null!=G&&!0===G.locked,B=i.useMemo(()=>{if(null!=S)return S({isSubscriptionPaidByWallet:L,selectedSource:P.paymentSources.find(e=>e.id===P.selectedPaymentSourceId),hidePersonalInformation:M})},[S,L,P,M]),H=i.useMemo(()=>{if(!x)return{label:I.intl.string(I.t["/AAR02"]),selectedCurrency:O.currency??D,currencies:k,onChange:w,disabled:F}},[x,O.currency,D,k,w,F]),W=i.useMemo(()=>({...P,...u,onPaymentSourceAdd:f}),[P,f,u]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(m.nL,{label:r,giftCardsEnabled:j,giftCardCheckboxProps:G,paymentSourceDropdownProps:W,showCheckboxAboveDropdown:R||V,disabled:F,currencySelectProps:H,customSelectorContent:B}),j?(0,l.jsx)(g,{onGiftCardRedeemed:U}):null]})}function S(e){let{premiumSubscriptionPaymentSourceId:t,...n}=e,{disableSourceChangeTooltipText:s,hasLockedPaymentSource:a}=i.useMemo(()=>null!=t?{hasLockedPaymentSource:!0,disableSourceChangeTooltipText:I.intl.string(x.default.UdSuwf)}:{hasLockedPaymentSource:!1,disableSourceChangeTooltipText:void 0},[t]),o=i.useCallback((e,t)=>{let{isSubscriptionPaidByWallet:n,selectorDisabled:l}=t;if(null==e)return null;let i=a&&n,r=a?s:void 0,o=!i&&(e.disabled||l),u=r??e.disabledTooltip;return{...e,disabled:o,disabledTooltip:u,locked:i,showDisabledInfoIcon:null==r}},[a,s]),c=i.useCallback((e,t)=>{let{isSubscriptionPaidByWallet:n}=t,l=e.disabled||a&&!n;return{giftCardCheckboxProps:o(e.giftCardCheckboxProps,{isSubscriptionPaidByWallet:n,selectorDisabled:l}),disabled:l}},[a,o]),d=i.useCallback(e=>{let{isSubscriptionPaidByWallet:t,selectedSource:n,hidePersonalInformation:i}=e;if(!a||t||null==s||null==n)return null;let o=n instanceof u.A?n.source:n,{brand:c,label:d}=(0,r.Sm)(o,i);return(0,l.jsx)(C.S,{label:d??"",icon:c??void 0,tooltipText:s})},[a,s]);return(0,l.jsx)(_,{...n,resolveInternalState:c,renderCustomPaymentSourceSelectorContent:d,subscriptionPaymentSourceId:t})}}