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