PageSourceSearch

https://www.linksys.com/cdn/shopifycloud/checkout-web/assets/c1/useAddressMutationsWithNegotiation.Bu1iJp6d.js

js linksys.com collected 2026-09-24 08:37:56 UTC 83,909 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["PostPurchaseShouldRender.qYhx4WV9.js","esnext-vendor.D7ldIee_.js","addresses-is-address-empty.-MuOhIyI.js","app.A60-IfPs.js","assets/app.Sxsz5knT.css","assets/is-address-empty.DJksNKpk.css","extensions-rpc.a_fI7Gy6.js","constants.DowbVE6J.js","hooks-useReplaceShopPayInHistory.Cz4PqGkk.js","performance-index.mu6MOGR9.js","components-RedirectionNotice.module.CqgkZHXB.js","hydrate.ByRIsqvd.js","assets/previous.ClThmeCv.css","assets/RedirectionNotice.B8v_QGNW.css","stopwatch.wWgdKLTI.js","component-Tips.B5z6E6UQ.js","Choice.Dywz6_Fr.js","hooks-useUnauthenticatedErrorModal.CzvtLqeY.js","Checkbox.Cby2hWUV.js","assets/Checkbox.SrYMuQu4.css","assets/Choice.aPApdPe_.css","NumberField.BTk3WiBo.js","assets/NumberField.CRpcZnVJ.css","Section.DIJn7eYY.js","assets/Section.CU18S7Ap.css","assets/Tips.D3S9_XMm.css","component-MsiInstallmentsSelect.BlpDspwz.js","PaymentIcon.Ddd-WnG2.js","assets/PaymentIcon.gzvCNwz_.css","PaymentLine.DhO8cHCS.js","localization-index.DBksi22x.js","assets/index.BAKORI_U.css","Theme-ThemeOverride.4AonMthy.js","assets/PaymentLine.D3bcP-mr.css","IncentiveBadge.D66zssvS.js","assets/IncentiveBadge.Dlnp55te.css","hooks-useUpdateCheckoutAddress.4zyjtqEx.js","utilities-shopCashMoney.B9eyOzz9.js","payment-usePaymentExemptionReason.Q4GfCwuW.js","shop-pay-ProgressIntercepts.wTCQvlrM.js","shop-pay-normalizeBuyerDetails.BcEhgoK7.js","context-CheckoutSheetProtocolClient.CNLSBD5p.js","hooks-useShopPayProgressIntercepts.CnlV9rdf.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","checkout-updaters-helpers.DKDxNKY0.js","Popover.BNecjV8x.js","assets/Popover.Bi1nHaU-.css"])))=>i.map(i=>d[i]);
2import{_ as at,S as $t}from"./app.A60-IfPs.js";import{d as nt,u as m,f as U,S as Kt,i as Re,h as O,a as rt,q as M,T as j,y as x,o as k,k as W,af as ks,n as Es,x as it,A as ae,p as Gt,e as ws,G as Is,r as Ns,_ as Ls,X as Ds,ad as xs}from"./esnext-vendor.D7ldIee_.js";import{n as Xe,b as pe,ak as Ge,B as ke,$ as ot,a2 as Ts,F as qt,bP as Yt,L as zt,e$ as Bs,M as Ht,eW as Rs,I as Fe,k as Q,P as Fs,gj as Us,a8 as Ct,ce as Vs,gk as vt,gl as dt,fr as Wt,z as Os,Z as $s,fc as Ks,U as Gs,gm as qs,gn as Ys,W as Qt,D as jt,go as zs,G as qe,bn as Xt,l as ee,az as Zt,dr as Hs,b8 as Ws,aB as Qs,a as Jt,S as js,bM as Xs,fl as Zs,bh as Js,bi as ea,bj as ta,gp as sa,gq as lt,gr as bt,gs as aa,gt,gu as Pt,gv as _t,gw as na,a1 as ra,fE as ia,i as oa,ff as da}from"./hydrate.ByRIsqvd.js";import{N,$ as G,O as X,ab as es,dB as la,ct as ts,an as Ue,bD as Ce,h9 as ct,i4 as ss,a4 as ut,B as Te,dO as ca,bE as ua,gy as de,i5 as ma,c1 as le,i6 as z,i7 as Ie,i8 as ha,V as fe,i9 as pa,ia as St,ib as ya,ic as fa,m as Ee,id as ye,bC as Y,dP as Ca,gu as va,ie as ba,ig as Ye,T as ga,W as Pa,Q as _a,ih as Sa,ii as Ma,dA as Aa,ij as ka,bN as Ea,aC as as,gm as wa,av as ns,ik as Ia,il as Na,gg as La,bX as Da,ae as rs,bF as xa,aS as Ve,a0 as Oe,im as Ta,io as Ba,aV as Ra,ip as mt,iq as Fa,ir as Ua,b4 as is,b_ as os,q as Va,is as Oa,it as $a,iu as Ka,iv as Ga,iw as qa,e3 as Ya,e4 as ds,bv as za,L as Ha,M as Wa,ix as Qa,r as ja,gz as Xa}from"./addresses-is-address-empty.-MuOhIyI.js";import{u as Za}from"./constants.DowbVE6J.js";import{P as ls}from"./PaymentIcon.Ddd-WnG2.js";import{a as Ja}from"./PaymentLine.DhO8cHCS.js";import{b as Mt,E as en}from"./IncentiveBadge.D66zssvS.js";import{a as tn,c as sn,b as an,u as nn}from"./hooks-useUpdateCheckoutAddress.4zyjtqEx.js";import{c as cs,u as rn}from"./payment-usePaymentExemptionReason.Q4GfCwuW.js";import{f as ht}from"./shop-pay-ProgressIntercepts.wTCQvlrM.js";import{s as on,n as dn}from"./shop-pay-normalizeBuyerDetails.BcEhgoK7.js";import{u as ln,i as cn,S as un,c as mn}from"./hooks-useShopPayProgressIntercepts.CnlV9rdf.js";import{s as hn}from"./checkout-updaters-helpers.DKDxNKY0.js";import{a as us,C as Ze}from"./Choice.Dywz6_Fr.js";import{P as pn}from"./Popover.BNecjV8x.js";const di=nt({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>at(()=>import("./PostPurchaseShouldRender.qYhx4WV9.js").then(t=>t.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))});function yn({renderInSection:t,hideHeading:e,headingLevel:s=2}){const{i18n:a,shop:{name:r,showTipPayments:n}}=N(),{tipLines:o}=G(),{tipLines:d}=X(),i=U(()=>{const u=o.value?.[0]??d.value[0];return n||!!(u&&u.amount.amount>0)}),l=a.translate("tips.description",{shop_name:r}),c=m(ke,{paddingBlockEnd:"base",children:[!e&&m(Kt,{children:[m(Xe,{level:s,children:a.translate("tips.title")}),m(pe,{blockSize:"base"})]}),m(Ge,{contentDisplay:"block",inlineSize:"100%",children:l}),m(Re,{when:i,children:[m(pe,{blockSize:"small-200"}),m(Ge,{contentDisplay:"block",inlineSize:"100%",children:a.translate("tips.custom_label")}),m(pe,{blockSize:"small-100"}),m(Ge,{contentDisplay:"block",inlineSize:"33%",children:a.translate("tips.add_tip")})]})]});return t?m(ot,{accessibilityLabel:a.translate("tips.title"),children:c}):c}function fn(t){const{observability:e}=N();O(()=>{t&&e.error(t,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})},[t,e])}const li=nt({displayName:"Tips",renderLoading:t=>m(yn,{...t}),useError:fn,load:()=>at(()=>import("./component-Tips.B5z6E6UQ.js"),__vite__mapDeps([15,1,11,2,3,4,5,7,8,12,16,17,18,19,20,21,22,23,24,25]))}),Cn=Ht("AmazonPayChangePaymentLinkButton");function ci(){const{i18n:t,observability:e}=N(),{inMemoryAmazonPayParts:{sdkStatus:s}}=es(),a=U(()=>{const i=s.value;return i.status===Ts.Available?i.sdk:void 0}),r=Za(),n=qt(void 0,Cn),{hasError:o}=Yt(la),d=t.translate("vaulted.change_button");return r.value?m(Re,{when:a,children:i=>m(zt,{onClick:()=>{try{const{checkout_session_id:c}=Bs(r.value.method.walletParams);i.Pay.changePaymentMethod({amazonCheckoutSessionId:c,isDeclined:o})}catch(c){e.error(new vn(`Error on changing buyer payment method. Details: ${c}`,{cause:c}))}},id:n,children:d})}):null}
2class vn extends Error{constructor(){super(...arguments),this.name="AmazonPayChangePaymentLinkError"}}const bn=new Map([["american_express","american_express"],["amex","amex"],["bogus","bogus"],["cartes_bancaires","cartes_bancaires"],["dankort","dankort"],["diners_club","diners_club"],["discover","discover"],["elo","elo"],["forbrugsforeningen","forbrugsforeningen"],["hypercard","hypercard"],["interac","interac"],["jcb","jcb"],["laser","laser"],["maestro","maestro"],["mastercard","mastercard"],["rupay","rupay"],["unionpay","unionpay"],["visa","visa"],["visaelectron","visaelectron"]]);function ui({brand:t,descriptor:e}){const{hasError:s}=Rs(),a=t?.toLowerCase().replace(/\s+/g,"_")??"",r=bn.get(a)??"generic";return m(Q,{direction:"inline",children:[s&&m(Kt,{children:[m(Fe,{tone:"critical",type:"alert-circle"}),m(pe,{display:"inline",inlineSize:"small-400"})]}),m(Ja,{icon:m(ls,{type:r}),details:e})]})}function gn(){const{i18n:t}=N(),e=X().purchaseOrderNumber.value;if(!e)return null;const s=`${t.translate("payment.purchase_order_number.title")} #${e}`;return m(Fs,{children:s})}const Pn=t=>m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"66 -30 151 80",...t,children:[m("path",{fill:"inherit",stroke:"inherit",strokeWidth:2,d:"M73.8-18.2c-4.4.8-7.3 4.9-6.5 9.3l7.6 43.3c.8 4.3 4.9 7.3 9.3 6.5l59.7-10.5c3.3-.6 7.4-3.3 9.1-6.1l14.4-22.5c2.4-3.7 1.5-8.9-2-11.6L144.2-26c-2.6-2-7.4-3.2-10.7-2.6 0-.1-59.7 10.4-59.7 10.4z"}),m("circle",{cx:157.2,cy:-2.9,r:3.5,fill:"inherit",stroke:"inherit",strokeWidth:2}),m("path",{fill:"inherit",stroke:"inherit",strokeWidth:2,d:"m95.9 9.1 11.5 7.4 18-24.5m31.8 5.1c23.3-7.1 31.6 22.2 57.5-13.1"})]}),_n="agRve",Sn="FiV0Z",At={NoPaymentRequiredWrapper:_n,FreeTagIcon:Sn};function mi({minimal:t,reason:e,vaulted:s}){const{i18n:a}=N(),n=Us().value.length,o=d=>{switch(d){case"giftCard":return a.translate("payment.order_covered_by_gift_cards_notice",{count:n});case"freeOrder":return a.translate("payment.free_order_notice_html");case"storeCredit":return a.translate("payment.order_covered_by_store_credit_notice");case"redeemables":return a.translate("payment.order_covered_by_redeemables_notice");case"deferred":return a.translate("payment_gateway.deferred_payment_label");default:rt(d)}};return s?m(Q,{gap:"base",children:[m(Ct,{children:o(e)}),m(gn,{})]}):t?m(en,{children:m(Mt,{children:o(e)})}):m("div",{className:At.NoPaymentRequiredWrapper,children:m(Q,{gap:"large-200",alignItems:"center",children:[m(Pn,{className:At.FreeTagIcon,focusable:"false","aria-hidden":"true"}),m(Mt,{children:m(Ct,{children:o(e)})})]})})}class Mn extends $t{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function hi(){const t=X().paymentLines;return U(()=>{const e=t.value,s=(()=>{const[r]=e.filter(i=>i.method.type==="walletsPlatformPaymentMethod");if(!r)return"";const o=r.method.walletParams.payment_preferences?.[0];if(!o)throw new Mn("Amazon Pay wallet params missing payment preferences",{groupingHash:"AmazonPay::usePaymentDetails::AmazonPayMissingPaymentPreferencesError"});return o.paymentDescriptor.replace("****","•••• ").replace(/(\((.*?)\))/,"").trim()})();return{brand:(()=>{if(!s)return;const r=s.match(/^(.+?)\s+••••/);if(!r)return s;const n=r[1];return n===void 0?s:n.trim()})(),descriptor:s}})}function An(){const t=kn(),{newCardSignal:e,hasLoadedSignal:s}=Ue(),a=e.value,r=s.value,{value:n}=G().paymentLines,o=n?.lines?.find(d=>d.method.type==="direct");return t.value&&!r&&o&&(s.value=!0,!a&&o.method.paymentMethodIdentifier&&(e.value=o.method)),e}function kn(){const t=N().checkout.configuration.layout.isOnePage.value,{paymentMethods:e}=G();return U(()=>t?!!ts(e.value).length:!1)}const En={id:"3880e4a8c616318ac48c829cc40108d16984c1d3172697b99437ce6c20b93d90",type:"mutation",name:"CreditCardCreate",source:"mutation CreditCardCreate($billingAddress:AddressInput!,$origin:String!,$sessionId:ID!,$nickname:String,$checkoutContext:CheckoutContextInput!){credit
2CardCreate(billingAddress:$billingAddress origin:$origin sessionId:$sessionId nickname:$nickname checkoutContext:$checkoutContext){creditCard{...CreditCardFragment __typename}threeDSecureAuthenticationRequest{redirectUrl verificationId __typename}userErrors{field message __typename}__typename}}fragment CreditCardFragment on CreditCard{bank brand expired expiring expiryMonth expiryYear funding id uuid lastDigits lastUsedAt name nickname preferred supportsInstallmentsInterestLoan supportsInstallmentsSplitPayLoan installmentsInterestLoanNotSupportedReason installmentsSplitPayLoanNotSupportedReason verified billingAddressValid billingAddress{addressLineComponents{additionalInformation district streetName streetNumber subdistrict __typename}fields{key value __typename}__typename}__typename}"};function wn(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},shopPay:s,source:a}=N(),r=Ce({source:a});return M(async(n,o,d,i,l=r)=>{const{data:c,error:u}=await e.mutate(En,{variables:{billingAddress:ct(n,s.user.hasFlag(ht)?t:void 0),origin:l,sessionId:o,nickname:i,checkoutContext:d}});if(u||c==null||c.creditCardCreate==null)return{status:"failed"};const{creditCardCreate:p}=c;return ss(p.userErrors)?{status:"blocked_by_autopay"}:p.userErrors.length>0?{status:"failed",errors:p.userErrors}:p.threeDSecureAuthenticationRequest?{status:"requires_redirect",threeDSecureAuthenticationRequest:p.threeDSecureAuthenticationRequest}:{status:"success",creditCard:p.creditCard?ut(p.creditCard):void 0}},[r,t,s,e])}const In={id:"76ca67a0ff58d1f46e17614ed9f8bb5a075b761270a53c607c2dea3f863acf40",type:"mutation",name:"CreditCardCompleteVerificationAndVault",source:"mutation CreditCardCompleteVerificationAndVault($verificationId:ID!,$billingAddress:AddressInput!,$origin:String,$nickname:String){creditCardCompleteVerificationAndVault(verificationId:$verificationId billingAddress:$billingAddress origin:$origin nickname:$nickname){creditCard{...CreditCardFragment __typename}userErrors{field message __typename}__typename}}fragment CreditCardFragment on CreditCard{bank brand expired expiring expiryMonth expiryYear funding id uuid lastDigits lastUsedAt name nickname preferred supportsInstallmentsInterestLoan supportsInstallmentsSplitPayLoan installmentsInterestLoanNotSupportedReason installmentsSplitPayLoanNotSupportedReason verified billingAddressValid billingAddress{addressLineComponents{additionalInformation district streetName streetNumber subdistrict __typename}fields{key value __typename}__typename}__typename}"};function Nn(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},shopPay:s,source:a}=N(),r=Ce({source:a});return M(async(n,o,d,i=r)=>{const{data:l,error:c}=await e.mutate(In,{variables:{verificationId:o,billingAddress:ct(n,s.user.hasFlag(ht)?t:void 0),origin:i,nickname:d}});if(c||l==null||l.creditCardCompleteVerificationAndVault==null)return{status:"failed"};const{creditCardCompleteVerificationAndVault:u}=l;return ss(u.userErrors)?{status:"blocked_by_autopay"}:u.userErrors.length>0?{status:"failed",errors:u.userErrors}:{status:"success",creditCard:u.creditCard?ut(u.creditCard):void 0}},[r,t,s,e])}const Ln={id:"d60ca8058fb85d0d4e3d3585e353d4317aa417ae9568973bb43da35ca94acce7",type:"mutation",name:"CreditCardDelete",source:"mutation CreditCardDelete($id:ID!,$origin:String!,$uuid:String!,$checkoutContext:CheckoutContextInput!){credit
2CardDelete(id:$id uuid:$uuid origin:$origin checkoutContext:$checkoutContext){userErrors{field message __typename}__typename}}"};function Dn(){const{graphql:{shopPayGraphql:t},source:e}=N(),s=Ce({source:e});return M(async(a,r,n,o=s)=>{const{data:d,error:i}=await t.mutate(Ln,{variables:{id:a,uuid:r,origin:o,checkoutContext:n}});if(i||d==null||d.creditCardDelete==null)return{status:"failed"};const{creditCardDelete:l}=d;return l.userErrors.length>0?{status:"failed",errors:l.userErrors}:{status:"success"}},[s,t])}function xn(t,{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:r,redirectSource:n},{cache:o=!0}={}){return t.staticQuery(on,{variables:{checkoutContextInput:{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:r},shopifyDomain:a,redirectSource:n??void 0},cache:o})}function Tn(){const{graphql:{shopPayGraphql:t},source:e,shop:{myshopifyDomain:s,id:a},shopPay:{config:r}}=N(),{checkoutSessionIdentifier:n}=e,o=Ce({source:e}),{redirectSource:d}=r;return M(async()=>{const{data:i,error:l}=await xn(t,{checkoutVersion:o,checkoutIdentifier:n??"unknown",shopifyDomain:s,shopId:Te(a),redirectSource:d},{cache:!1});return l||i==null||i.checkoutSession==null||i.checkoutSession.user==null?{status:"failed"}:dn(i)},[n,o,d,a,s,t])}const Bn={id:"0e9fd59cad63a6cd040eec702de445aa95c0d9f613f732e94dce615a476c9d59",type:"mutation",name:"CreditCardUpdate",source:"mutation CreditCardUpdate($billingAddress:AddressInput!,$id:ID!,$uuid:String!,$origin:String!,$nickname:String,$checkoutContext:CheckoutContextInput!){credit
2CardUpdate(billingAddress:$billingAddress id:$id uuid:$uuid origin:$origin nickname:$nickname checkoutContext:$checkoutContext){userErrors{field message __typename}creditCard{...CreditCardFragment __typename}__typename}}fragment CreditCardFragment on CreditCard{bank brand expired expiring expiryMonth expiryYear funding id uuid lastDigits lastUsedAt name nickname preferred supportsInstallmentsInterestLoan supportsInstallmentsSplitPayLoan installmentsInterestLoanNotSupportedReason installmentsSplitPayLoanNotSupportedReason verified billingAddressValid billingAddress{addressLineComponents{additionalInformation district streetName streetNumber subdistrict __typename}fields{key value __typename}__typename}__typename}"};function Rn(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},shopPay:s,source:a}=N(),r=Ce({source:a});return M(async(n,o,d,i,l,c=r)=>{const{data:u,error:p}=await e.mutate(Bn,{variables:{id:o,uuid:d,billingAddress:ct(n,s.user.hasFlag(ht)?t:void 0),origin:c,nickname:l,checkoutContext:i}});if(p||!u?.creditCardUpdate)return{status:"failed"};const{creditCardUpdate:h}=u;return h.userErrors.length>0?{status:"failed",errors:h.userErrors}:{status:"success",creditCard:h.creditCard?ut(h.creditCard):void 0}},[r,t,s,e])}function Fn(t){const{geolocation:e}=Vs(),{shopPay:s,checkout:a}=N(),r=s.user.phoneNumber.value,n=s.user.addresses.value,o=a.configuration.addressSettings.nonBillingAddressSettings.value,d=n[0]?.address,i=o.defaultShippingDetails.country?.code??e.country.code;return j(()=>{const l={firstName:d?.firstName,lastName:d?.lastName,phone:r,countryCode:d?.countryCode||i,zoneCode:d?.zoneCode};return ca(l,{extendedAddressMode:a.address.extendedAddressMode})},[a.address.extendedAddressMode,t,d,i,r])}const Un={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},Vn={id:"d1f468f7d6684d3133e47cef5cf1ef67ccd2bd916b53203708d85ac3175f1bd0",type:"mutation",name:"UpdateCustomerCreditCard",source:""};class On extends Error{constructor(e){super("Failed to update customer credit card payment method",e),this.name="UpdateCustomerCreditCardPaymentMethodError"}}class $n extends Error{constructor(e){super("Failed to delete customer credit card payment method",e),this.name="DeleteCustomerCreditCardPaymentMethodError"}}async function Kn({graphql:t,address:e,extendedAddressMode:s,defaultPaymentMethod:a,token:r,genericError:n}){if(!r)return{token:void 0};try{const{data:o,error:d}=await t.mutate(Vn,{variables:{customerCreditCardModificationInput:{token:r,defaultPaymentMethod:a,billingAddress:{streetAddress:ua(e,{extendedAddressMode:s})}}}});if(!o?.modifyCustomerCreditCardPaymentMethod||d)throw new On({cause:d});const{result:i,errors:l}=o.modifyCustomerCreditCardPaymentMethod;return l.length||!i?{token:void 0,error:l[0]?.localizedMessage||n}:{token:i.token}}catch{return{token:void 0,error:n}}}async function Gn({graphql:t,token:e,genericError:s}){if(!e)return{token:void 0};try{const{data:a,error:r}=await t.mutate(Un,{variables:{token:e}});if(!a?.deleteCustomerCreditCardPaymentMethod||r)throw new $n({cause:r});const{result:n,errors:o}=a.deleteCustomerCreditCardPaymentMethod;return o.length||!n?{token:void 0,error:o[0]?.localizedMessage||s}:{token:n.token}}catch{return{token:void 0,error:s}}}function K(t){return t?.paymentMethod==="CREDIT_CARD"}function pi(t){return t.paymentMethod==="IDEAL"||t.paymentMethod==="CUSTOM_ONSITE"&&t.paymentBrands?.some(e=>e.toLowerCase()==="ideal")===!0}function yi(t){return t.paymentMethod==="APPLE_PAY"}function fi(t){return t.paymentMethod==="CUSTOM_ONSITE"}function Ci(t){return t.paymentMethod==="SHOP_PAY"}function vi(t){return t.paymentMethod==="SHOP_PAY_INSTALLMENTS"}function bi(t){return t.paymentMethod==="PAYPAL"}function gi(t){return t.paymentMethod==="BANK"}function Je(t){return t.paymentMethod==="DEFERRED"}function Pi(t){return t.paymentMethod==="OFFSITE"||t.paymentMethod==="MANUAL_PAYMENT"||t.paymentMethod==="CUSTOM_MANUAL_PAYMENT"||t.paymentMethod==="PAYMENT_ON_DELIVERY"}function qn(t){return K(t)||!!t.lastUsedAt}function Yn(t){for(const e of t)if(!K(e)||!e.paymentAttributes.expired)return e;return t[0]}function zn({selected:t,paymentMethods:e,availablePaymentMethods:s}){return!!(de(t,s)||K(t)&&e.some(({method:a})=>a.paymentMethod===t.paymentMethod&&a.id===t.id))}function Hn({userEvents:t,shopId:e,checkoutSessionIdentifier:s,card:a}){t.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(Te(e),10),checkoutSessionIdentifier:s||"",paymentMethodId:parseInt(Te(a.id),10),paymentInstrumentAccessorId:-1}})}const te={markBuyerHasActed:!1,updateSelectedCardBin:!1,selectedCardFirstDigits:void 0,preserveExistingBinPrefix:!1,claimMsiBin:!1,claimedMsiBin:void 0,shouldNegotiate:!1};class Wn extends $t{constructor({managerName:e,methodName:s,identity:a,deployStage:r,isLocalDevelopment:n}){super(`${e}.${s} was called unexpectedly`,{groupingHash:`PaymentMethodManagerUnexpectedMethodCall::${e}::${s}`,metadata:{paymentMethodManager:{managerName:e,methodName:s,identity:a,deployStage:r,isLocalDevelopment:n}}}),this.name="UnexpectedPaymentMethodManagerMethodCallError"}}function ms({observability:t,managerName:e,methodName:s,identity:a,deployStage:r,isLocalDevelopment:n}){if(n||r!=="production"&&r!=="canary")return;const o=new Wn({managerName:e,methodName:s,identity:a,deployStage:r,isLocalDevelopment:n});t.error(o,{severity:"warning"})}const kt={status:"failed"};class Ne{constructor(e){this.disabledCardMethodsForInstallments=x([]),this.isEveryCardDisabled=x(!1),this.canSetCreditCardNickname=x(!1),this.addCreditCardStrategy="direct-session-payment-line",this.deps=e,this.usesCustomerAccountSelectionRule=e.identity==="customerAccount",this.newCard=e.newCard??x(void 0);const{proposal:s}=e,{proposed:a,negotiated:r}=s,{paymentMethods:n}=r.fields,o=r.fields.paymentMethodHistory??x([]);this.availablePaymentMethods=k(()=>n.value??[]),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=k(()=>ha(this.availablePaymentMethods.value)),this.selectableCustomerCreditCards=k(()=>ts(this.availablePaymentMethods.value)),this.selectablePaypalBillingAgreements=k(()=>(e.displayablePaymentMethods?.value??this.availablePaymentMethods.value).filter(i=>i.type===fe.PayPal)),this.selectableCustomerBanks=k(()=>this.availablePaymentMethods.value.filter(i=>i.type==="bank"&&i.availableInstruments.length>0)),this.nonCardKnownPaymentMethods=k(()=>pa({paymentMethodHistory:o.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value})),this.availableUserStoredPaymentMethods=k(()=>[...Be([ze({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map(i=>St(i,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})),...this.selectablePaypalBillingAgreements.value.map(ya),...Jn(this.selectableCustomerBanks.value.map(fa),this.nonCardKnownPaymentMethods.value,this.promotedMethods.value)]),this.autoselectTarget=k(()=>{const i=this.selectableCustomerCreditCards.value.find(h=>h.defaultPaymentMethod),l=i?this.availableUserStoredPaymentMethods.value.find(h=>h.id===i.token):void 0,c=er(this.availableUserStoredPaymentMethods.value);if(this.usesCustomerAccountSelectionRule){const h=!c||K(c);if(this.deps.storeVaultEnabled&&h&&l)return l}else if(i)return l;if(c)return c;const u=this.selectableCustomerCreditCards.value[0];if(u)return this.availableUserStoredPaymentMethods.value.find(h=>h.id===u.token);const p=this.availableUserStoredPaymentMethods.value.find(h=>!K(h)&&!Je(h));return p||this.availableUserStoredPaymentMethods.value.find(Je)}),this.proposedSelectedPaymentMethod=k(()=>Qn(a.paymentLines.value,this.availableUserStoredPaymentMethods.value,this.availablePaymentMethods.value,ze
2({card:this.newCard.value,billingAddress:a.billingAddress.value}))),this.selectedPaymentMethod=k(()=>this.proposedSelectedPaymentMethod.value??this.autoselectTarget.value),this.paymentMethods=k(()=>{const i=ze({card:this.newCard.value,billingAddress:a.billingAddress.value}),l=[...Be([i]),...this.customerCreditCards.value.map(u=>St(u,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled}))].map(u=>({method:u,isValidForCheckout:!0,isExpired:u.paymentAttributes.expired,isDisabled:!1,...sr({identity:this.deps.identity,storeVaultEnabled:this.deps.storeVaultEnabled,card:u})})),c=this.availableUserStoredPaymentMethods.value.filter(u=>!K(u)).map(u=>({method:u,isValidForCheckout:!0,isExpired:!1,isDisabled:!1,canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1}));return tr({cardItems:l,nonCardItems:c,autoselectTarget:this.usesCustomerAccountSelectionRule?this.autoselectTarget.value:void 0})}),this.selectedPaymentMethodItem=k(()=>{const i=this.selectedPaymentMethod.value;if(i)return this.paymentMethods.value.find(({method:l})=>l.id===i.id&&l.paymentMethod===i.paymentMethod)}),this.selectedCreditCard=k(()=>{const i=this.selectedPaymentMethod.value;return K(i)?i.paymentAttributes:void 0}),this.cardPaymentMethods=k(()=>this.paymentMethods.value.filter(i=>K(i.method))),this.activeOrExpiredCardMethods=this.cardPaymentMethods,this.isEveryCardExpired=k(()=>{const i=this.cardPaymentMethods.value;return i.length>0&&i.every(l=>l.isExpired)});const d=k(()=>{const i=Ee(this.availablePaymentMethods.value);if(!dt(i))return!1;const l=this.selectedCreditCard.value;return l?a.paymentLines.value.some(c=>l.id===z?c.method.type==="direct":c.method.type===fe.CreditCard&&c.method.token===l.id):!1});this.msi={binResolution:"client",selectedCardBin:k(()=>{const i=this.selectedCreditCard.value;if(i)return i.id===z?this.newCard.value?.creditCardFirstDigits:this.selectableCustomerCreditCards.value.find(l=>l.token===i.id)?.firstDigits}),clearInstallments:vt,expandedVisible:d,collapsedVisible:d}}async promoteSelectedPaymentMethod(e){const s=ma(e,null);return s?(this.deps.paymentMethodPromotions.promote(s),this.selectPaymentMethod(s,"buyer")):{status:"handled",effects:{...te,selectByBuyerKey:le(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,s="programmatic"){if(!e)return{status:"not-handled"};if(!K(e)){const r=de(e,this.availablePaymentMethods.value);if(!r)return{status:"not-handled"};const n=le(r);return s==="buyer"?{status:"handled",effects:{...te,selectByBuyerKey:n}}:(this.deps.setPaymentLine(n),{status:"handled",effects:te})}if(s==="buyer")return this.selectCreditCardByBuyer({paymentMethod:e});if(e.id===z)return this.deps.setPaymentLine(z),{status:"handled",effects:te};const a=this.selectableCustomerCreditCards.value.find(r=>r.token===e.paymentAttributes.id);return a?(this.deps.setPaymentLine(Ie(a)),{status:"handled",effects:te}):{status:"not-handled"}}async deleteCreditCard({id:e}){if(e===z){const{proposed:o}=this.deps.proposal;if(!this.newCard.value)return{status:"failed"};this.newCard.value=void 0,o.acceptPaymentVaulting.value=!1;const d=this.selectableCustomerCreditCards.value[0];if(d)this.deps.setPaymentLine(Ie(d));else{const i=this.autoselectTarget.value,l=i?de(i,this.availablePaymentMethods.value):void 0;l?this.deps.setPaymentLine(le(l)):o.paymentLines.value=o.paymentLines.value.filter(c=>c.method.type!=="direct")}return{status:"success",shouldResetSuggestedBillingAddress:!!d,shouldResetBillingAddressToShipping:this.deps.identity!=="businessCustomer"}}const s=this.selectedPaymentMethod.value,a=K(s)&&s.id===e,r=this.selectableCustomerCreditCards.value.find(o=>o.token!==e),n=await Gn({graphql:this.deps.graphql,token:e,genericError:this.deps.i18n.translate("customer_payment_methods.delete_customer_mandate.generic_error")});return n.token?(a&&r&&this.deps.setPaymentLine(Ie(r)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:n.error}}async updateCreditCard({id:e,billingAddress:s,defaultPaymentMethod:a=!1}){const r=await Kn({graphql:this.deps.graphql,token:e,address:s,extendedAddressMode:this.deps.extendedAddressMode,defaultPaymentMethod:a,genericError:this.deps.i18n.translate("shipping.address_form.generic_error")});return r.token?{status:"success",shouldNegotiatePaymentMethods:!0}:{status:"failed",bannerError:r.error}}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),kt}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),kt}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let s,a,r;if(e.id===z){const n=this.newCard.value;if(!n)return{status:"not-handled"};s=z,a=n,r=n.creditCardFirstDigits}else{const n=this.selectableCustomerCreditCards.value.find(o=>o.token===e.paymentAttributes.id);if(!n)return{status:"not-handled"};s=Ie(n),r=n.firstDigits,Hn({userEvents:this.deps.userEvents,shopId:this.deps.shopI
2d,checkoutSessionIdentifier:this.deps.checkoutSessionIdentifier,card:n})}return this.deps.isMsiAvailable&&(this.deps.proposal.proposed.paymentLines.value=vt(this.deps.proposal.proposed.paymentLines.value)),{status:"handled",effects:{...te,selectByBuyerKey:s,...a?{selectByBuyerPaymentMethod:a}:{},updateSelectedCardBin:!0,selectedCardFirstDigits:r,preserveExistingBinPrefix:e.id===z,claimMsiBin:this.deps.isMsiAvailable,claimedMsiBin:this.deps.isMsiAvailable?r:void 0,shouldNegotiate:!0}}}reportUnexpectedUse(e){ms({...this.deps,managerName:"CustomerPaymentMethodManager",methodName:e})}}function Qn(t,e,s,a){const r=t.some(n=>n.method.type!=="deferred"&&n.method.type!=="giftCard"&&n.method.type!=="redeemable");for(const n of t){if(n.method.type==="direct"&&a)return a;if(n.method.type==="deferred"){if(r)continue;const d=e.find(Je);if(d)return d;continue}if(jn(n)){const d=e.filter(K).find(i=>i.id===n.method.token);if(d)return d;continue}if(Xn(n)){const d=e.find(i=>i.paymentMethod==="PAYPAL"&&i.variant==="billing_agreement"&&i.vaultedToken===n.method.token);if(d)return d;continue}const o=Zn(n,e,s);if(o)return o}}function ze({card:t,billingAddress:e}
2){if(!(!t?.brand||!t.creditCardLastFourDigits))return{id:z,paymentMethod:"CREDIT_CARD",paymentAttributes:{id:z,brand:t.brand,expired:!1,expiryMonth:0,expiryYear:0,lastDigits:t.creditCardLastFourDigits,name:t.cardholderName,billingAddress:{address:e??{}}},lastUsedAt:null}}function Be(t){return t.filter(e=>e!==void 0)}function jn(t){return t.method.type===fe.CreditCard}function Xn(t){return t.method.type===fe.PayPal}function Zn(t,e,s){const a=le(t.method);return e.find(r=>{if(K(r))return!1;const n=de(r,s);return n?a===le(n):!1})}function Jn(...t){const e=[],s=new Set;for(const a of t)for(const r of a){const n=`${r.paymentMethod}:${r.id}`;s.has(n)||(s.add(n),e.push(r))}return e}function er(t){return t.reduce((e,s)=>s.lastUsedAt?e?.lastUsedAt?s.lastUsedAt>e.lastUsedAt?s:e:s:e,void 0)}function tr({cardItems:t,nonCardItems:e,autoselectTarget:s}){const a=t.find(({method:h})=>h.id===z),n=[...t.filter(({method:h})=>h.id!==z)].sort((h,v)=>ye(h.method,v.method)),o=[...e].sort((h,v)=>ye(h.method,v.method)),d=n.filter(Et),i=o.filter(Et),l=d.find(({method:h})=>K(h)&&h.paymentAttributes.defaultPaymentMethod),c=[d[0],i[0]].filter(h=>h!==void 0).sort((h,v)=>ye(h.method,v.method))[0],p=(s?[...d,...i].find(({method:h})=>h.id===s.id&&h.paymentMethod===s.paymentMethod):void 0)??l??c;return p?[...Be([a]),p,...n.filter(h=>h!==p),...o.filter(h=>h!==p)]:[...Be([a]),...n,...o]}function Et(t){return t.isValidForCheckout&&!t.isExpired&&!t.isDisabled}function sr({identity:t,storeVaultEnabled:e,card:s}){if(s.id===z)return ar;if(t==="businessCustomer")return He;const{paymentAttributes:a}=s;return e?a.expired?a.deletable?{canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!!a.defaultPaymentMethod}:He:{canEdit:!0,canDelete:!!a.deletable,canSetDefault:!0,isDefault:!!a.defaultPaymentMethod}:He}const He={canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1},ar={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},Le={status:"failed"};class nr{constructor(e){this.availablePaymentMethods=x([]),this.availableUserStoredPaymentMethods=x([]),this.paymentMethods=x([]),this.selectedPaymentMethod=x(void 0),this.selectedPaymentMethodItem=x(void 0),this.selectedCreditCard=x(void 0),this.activeOrExpiredCardMethods=x([]),this.disabledCardMethodsForInstallments=x([]),this.isEveryCardDisabled=x(!1),this.isEveryCardExpired=x(!1),this.cardPaymentMethods=x([]),this.promotedMethods=x([]),this.msi={binResolution:"client",selectedCardBin:x(void 0),clearInstallments:s=>s,expandedVisible:x(!1),collapsedVisible:x(!1)},this.newCard=x(void 0),this.canSetCreditCardNickname=x(!1),this.addCreditCardStrategy="vault-and-select",this.unexpectedUseOptions=e}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(){return this.reportUnexpectedUse("selectPaymentMethod"),{status:"not-handled"}}async promoteSelectedPaymentMethod(){return this.reportUnexpectedUse("promoteSelectedPaymentMethod"),{status:"not-handled"}}async deleteCreditCard(){return this.reportUnexpectedUse("deleteCreditCard"),Le}async updateCreditCard(){return this.reportUnexpectedUse("updateCreditCard"),Le}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),Le}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),Le}dispose(){}reportUnexpectedUse(e){ms({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function hs(t){return{id:t.id,bank:t.bank,brand:t.brand,defaultPaymentMethod:t.preferred,expired:t.expired,expiryMonth:t.expiryMonth,expiryYear:t.expiryYear,lastDigits:t.lastDigits,lastUsedAt:t.lastUsedAt,name:t.name,nickname:t.nickname,billingAddress:t.billingAddress,cvvVerification:t.verified?void 0:{type:"session-token"}}}function De(t){switch(t.paymentMethod){case"CREDIT_CARD":return{id:t.id,paymentMethod:"CREDIT_CARD",paymentAttributes:hs(t.paymentAttributes),lastUsedAt:t.lastUsedAt};case"IDEAL":return t;case"CUSTOM_ONSITE":return t;case"APPLE_PAY":return t;case"OFFSITE":return t;case"MANUAL_PAYMENT":return t;case"CUSTOM_MANUAL_PAYMENT":return t;case"PAYMENT_ON_DELIVERY":return t}}function et(t,e){switch(t.paymentMethod){case"CREDIT_CARD":return e.find(s=>
2Y(s)&&s.id===t.id);case"IDEAL":return t;case"CUSTOM_ONSITE":return t;case"APPLE_PAY":return t;case"OFFSITE":return t;case"MANUAL_PAYMENT":return t;case"CUSTOM_MANUAL_PAYMENT":return t;case"PAYMENT_ON_DELIVERY":return t;case"SHOP_PAY":case"SHOP_PAY_INSTALLMENTS":case"PAYPAL":case"BANK":case"DEFERRED":return;default:rt(t)}}const wt={id:"2bcff8985dbaa04eadb413f088e89a17952466f58df58d4f1fd47003417e8f71",type:"query",name:"CreditCardActiveSubscriptions",source:"query CreditCardActiveSubscriptions($id:ID!,$uuid:String!,$first:Int){creditCardActiveSubscriptions(id:$id,uuid:$uuid,first:$first){pageInfo{hasNextPage __typename}nodes __typename}}"},xe=Object.freeze({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null});var ps=(t=>(t.FirstName="firstName",t.LastName="lastName",t.Number="number",t.Cvv="verificationValue",t.Month="month",t.Year="year",t.Base="base",t.DebitOnly="debitOnly",t))(ps||{});const It={baseMessage:null,fieldErrors:xe,blockedByDuplicateAutopayCard:!1};function _i(){const{i18n:t,observability:e}=N(),[s,a]=W(It),r=M((l,c)=>{e.counter({name:l,value:1,attributes:{errorField:c.field.join("-"),errorMessage:c.message}})},[e]),n=M(l=>{if(!l||!l.length){a({baseMessage:t.translate("credit_card_form.generic_card_error"),fieldErrors:xe,blockedByDupl
2icateAutopayCard:!1});return}const c={...xe};let u=null;l.forEach(p=>{switch(r("save_credit_card_error",p),p.field?.[1]){case"firstName":c.name=t.translate("field_errors.credit_card_name_billing_invalid");return;case"lastName":c.name=t.translate("field_errors.credit_card_name_invalid");return;case"month":case"year":c.expiry=t.translate("field_errors.credit_card_expiry_invalid");return;case"number":c.number=t.translate("field_errors.credit_card_number_invalid");return;case"verificationValue":c.verification_value=t.translate("payment.card_fields.errors.invalid.verification_value");return;case"debitOnly":u=t.translate("payment_errors.debit_only");return;case"base":if(p.message==="credit_card_is_expired"){c.expiry=t.translate("payment_errors.card_has_expired");return}else if(p.message==="failed_to_verify_credit_card"){u=t.translate("payment.generic_incorrect_card_info");return}else if(p.message==="three_d_secure_authentication_failed"){u=t.translate("payment_errors.three_d_secure_failed_payment_method");return}else if(p.message==="billing_address_missing"){u=t.translate("payment_errors.payment_method_billing_address");return}}if(p.message==="too_many_credit_cards"){u=t.translate("credit_card_form.max_cards_reached",{max_cards:Ca});return}u=t.translate("credit_card_form.generic_card_error"),r("save_credit_card_error_unhandled",p)}
2),a({baseMessage:u,fieldErrors:c,blockedByDuplicateAutopayCard:!1})},[t,r]),o=M(()=>{e.counter({name:"save_credit_card_blocked_by_autopay",value:1}),a({baseMessage:null,fieldErrors:xe,blockedByDuplicateAutopayCard:!0})},[e]),d=M(()=>{a(It)},[]),i=M(l=>{e.counter({name:"save_credit_card_vaulting_failure",value:1,attributes:{reason:l}}),n(l==="missing_billing_address"?[{field:["creditCard","base"],message:"billing_address_missing"}]:void 0)},[e,n]);return{creditCardErrors:s,setCreditCardErrors:n,clearCreditCardErrors:d,failCardVaulting:i,blockDuplicateAutopayCard:o}}function rr(t,e){let s=t.paymentMethod.toLowerCase(),a="";switch(t.paymentMethod){case"CREDIT_CARD":t.paymentAttributes?.brand&&(s=t.paymentAttributes.brand);break;case"CUSTOM_ONSITE":{s=va(e,{paymentBrands:t.paymentBrands,paymentMethodIdentifier:t.paymentMethodIdentifier})?.name||"custom_onsite",a=t.paymentBrands?.slice().sort().join(",")??"";break}case"IDEAL":s="ideal";break;case"OFFSITE":s=t.name,a=t.paymentBrands?.slice().sort().join(",")??"";break;case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":s=t.name;break;case"APPLE_PAY":s="apple_pay";break;case"SHOP_PAY":s="shop_pay";break;case"SHOP_PAY_INSTALLMENTS":s="shopify_installments";break;case"PAYPAL":s="paypal_express";break;case"BANK":s=t.displayName||"bank";break;case"DEFERRED":s="deferred";break;default:rt(t)}return{paymentMethodName:s,paymentBrands:a}}class ir extends Error{constructor(){super(...arguments),this.name="EmptySessionIdError"}}class or extends Error{constructor(){super(...arguments),this.name="BuyerDetailsRefreshError"}}const dr="credit_card_not_found";function lr(t){return t.errors?.some(({message:e})=>e===dr)??!1}class cr{constructor(e){this.newCard=x(void 0),this.canSetCreditCardNickname=x(!0),this.addCreditCardStrategy="vault-and-select",this.deps=e;const{shopPay:s,installmentsPaymentMethodSelected:a,isApplePayAvailable:r,filteredNegotiatedPaymentMethods:n,isCreditCardDisabled:o,msiEligibilityByCardId:d,hasSellingPlan:i}=e;this.availablePaymentMethods=x(n),this.shopPayAvailableUserStoredPaymentMethods=k(()=>{const c=this.availablePaymentMethods.value;return c.length?Ia(s.user.paymentMethods.value,c):[]}),this.availableUserStoredPaymentMethods=k(()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(De)),this.promotedMethods=k(()=>s.session.promotedPaymentMethods.value.map(De)),this.selectedPaymentMethod=k(()=>{const c=s.session.selectedPaymentMethod.value;return c?De(c):void 0}),this.selectedCreditCard=k(()=>{const c=s.session.selectedPaymentMethod.value;return c&&Y(c)?hs(c.paymentAttributes):void 0}),this.shopPayPaymentMethods=k(()=>{const c=s.user.paymentMethods.value,u=this.shopPayAvailableUserStoredPaymentMethods.value,p=this.availablePaymentMethods.value,h=s.session.promotedPaymentMethods.value,v=s.user.paymentMethodHistory.value,g=c.filter(Y).map(I=>({method:I,isValidForCheckout:u.includes(I),isExpired:I.paymentAttributes.expired,isDisabled:o(I.paymentAttributes)})),_=a?[]:Na({negotiatedPaymentMethods:p,userStoredPaymentMethods:c,paymentMethodHistory:v,isApplePayAvailable:r}),b=[...g.sort((I,S)=>ye(I.method,S.method)),..._.sort((I,S)=>ye(I.method,S.method))];let f=-1,A="";for(const[I,S]of b.entries()){const T=S.method.lastUsedAt??"";T>A&&(A=T,f=I)}f>0&&b.unshift(...b.splice(f,1));const w=s.session.selectedPaymentMethod.value,L=new Set(h.map(I=>I.id));return b.filter(({method:I})=>Y(I)||w&&!Y(w)&&I.id===w.id||L.has(I.id)?!0:La(I))}),this.paymentMethods=k(()=>this.shopPayPaymentMethods.value.map(({method:c,...u})=>{const p=De(c);return{...u,method:p,canEdit:Y(c),canDelete:Y(c),canSetDefault:!1,isDefault:!1}})),this.selectedPaymentMethodItem=k(()=>{const c=this.selectedPaymentMethod.value;if(c)return this.paymentMethods.value.find(({method:u})=>u.id===c.id&&u.paymentMethod===c.paymentMethod)}),this.cardPaymentMethods=k(()=>this.paymentMethods.value.filter(c=>K(c.method))),this.activeOrExpiredCardMethods=k(()=>{const c=this.cardPaymentMethods.value,u=[];for(const p of c)a&&p.isDisabled||u.push(p);return u}),this.disabledCardMethodsForInstallments=k(()=>a?this.cardPaymentMethods.value.filter(c=>c.isDisabled):[]),this.isEveryCardDisabled=k(()=>{const c=this.cardPaymentMethods.value;if(c.length===0)return!1;const u=new Set(this.disabledCardMethodsForInstallments.value.map(h=>h.method.id)),p=c.filter(h=>h.isExpired&&!u.has(h.method.id)).length;return c.length===u.size+p}),this.isEveryCardExpired=k(()=>{const c=this.cardPaymentMethods.value;if(c.length===0)return!1;const u=new Set(this.disabledCardMethodsForInstallments.value.map(h=>h.method.id)),p=c.filter(h=>!u.has(h.method.id));return p.length===0?!1:p.every(h=>h.isExpired)});const l=k(()=>{const c=Ee(this.availablePaymentMethods.value);if(!dt(c))return!1;const u=this.selectedCreditCard.value;return!!(u&&d.value[u.id])});this.msi={binResolution:"server",selectedCardBin:k(()=>{}),clearInstallments:ba,expandedVisible:k(()=>l.value?s.session.paymentMethodOption.value?.name!=="SHOPIFY_INSTALLMENTS":!1),collapsedVisible:k(()=>l.value&&!i.value)}}canShowAsGuestCheckoutMethod(e){const{shopPay:s}=this.deps;return s.visibility.showGuestCheckoutPaymentMethods&&!(e.type==="wallet"&&(e.name==="SHOP_PAY"||e.name==="SHOPIFY_INSTALLMENTS"))}async selectPaymentMethod(e,s="programmatic"){const{shopPay:a,updateCheckoutAddress:r,shippingRequired:n}=this.deps;if(!e)return a.session.clearPaymentMethod(),{status:"handled",effects:te};const o=et(e,a.user.paymentMethods.value);if(!o)return{status:"not-handled"};if(s==="buyer"&&this.recordPaymentMethodSelected(e),K(e)){const i=this.selectCreditCard({id:e.paymentAttributes.id});return Ye(o,a.user.paymentMethods.value,de(o,this.availablePaymentMethods.value))&&this.#e(o),await i,{status:"handled",effects:te}}const d=de(o,this.availablePaymentMethods.value);return Ye(o,a.user.paymentMethods.value,d)&&this.#e(o,{buyerInitiated:s==="buyer"}),(ga(o)||Pa(o)||_a(o)||Sa(o))&&await r({billingAddress:a.session.selectedBillingAddress.value?.address,fallbackPhoneNumber:a.user.phoneNumber.value},n.value),{status:"handled",effects:te}}async promoteSelectedPaymentMethod(e){const{shopPay:s}=this.deps,a=Ma(e,s.user.paymentMethods.value);return a&&(s.session.selectPaymentMethod(a),s.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...te,selectByBuyerKey:le(e)}}}getSavedCardActiveSubscriptionsLookup(e){const s=this.deps.shopPay.user.paymentMethods.value.filter(Y).map(o=>o.paymentAttributes).find(o=>o.id===e.id);if(!s)return;const a={id:s.id,uuid:s.uuid,first:3},r=ks(wt,a),{shopPayGraphql:n}=this.deps;return{key:r,read(){return n.read(r)?.creditCardActiveSubscriptions?.nodes},async load(){const{data:o}=await n.staticQuery(wt,{variables:a});return o?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:s}=this.deps,a=s.user.paymentMethods.value.filter(Y).map(o=>o.paymentAttributes).find(o=>o.id===e);if(!a)return;const{updateCheckoutAddress:r,fallbackPhoneNumber:n}=this.deps;s.session.selectPaymentMethod({id:a.id,lastUsedAt:a.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:a}),this.clearShopPayPaymentLines(),await r({billingAddress:a.billingAddress.address,fallbackPhoneNumber:n})}async deleteCreditCard({id:e}){return this.deleteCreditCardById({id:e})}async updateCreditCard({id:e,billingAddress:s,nickname:a}){const{shopPay:r,updateCreditCard:n,checkoutContext:o,markShopCashStatesStale:d,observability:i}=this.deps,l=r.user.paymentMethods.value.filter(Y).map(u=>u.paymentAttributes).find(u=>u.id===e);if(!l)return{status:"failed"};const c=await n(s,e,l.uuid,o,a);if(c.status==="success"&&c.creditCard){const{creditCard:u}=c;r.user.updateCreditCard(e,u),this.selectCreditCard({id:u.id}).catch(p=>{i.error(p)})}if(d(),c.status!=="success"){const u=Aa();return hn({addressErrors:u,shopPayErrors:c.errors,i18n:this.deps.i18n,observability:i,userEvents:this.deps.userEvents,source:this.deps.source,configuration:this.deps.checkout.configuration,shop:this.deps.shop,addressContext:"payment-method",submittedAddress:s}),{status:"failed",addressErrors:Object.fromEntries(Object.entries(u).map(([h,v])=>[h,v.value]))}}return{status:"success"}}async addCreditCard({sessionId:e,billingAddress:s,nickname:a,debitOnly:r=!1,isBlocking:n=!1}){const{createCreditCard:o,checkoutContext:d,markShopCashStatesStale:i,observability:l}=this.deps;if(e==="")return l.error(new ir("ShopPayPaymentMethodManager: addCreditCard called with empty sessionId")),{status:"failed"};const c=await o(s,e,d,a),u=await this.handleNewCardResponse(c,r,n);return i(),u}async completeCreditCardVerificationAndVault({verificationId:e,billingAddress:s,nickname:a,debitOnly:r=!1,isBlocking:n=!1}){const{completeCreditCardVerification:o,markShopCashStatesStale:d}=this.deps,i=await o(s,e,a),l=await this.handleNewCardResponse(i,r,n);return d(),l}dispose(){}async deleteCreditCardById({id:e,uuid:s}){const{shopPay:a,deleteCreditCard:r,updateCheckoutAddress:n,emptyAddress:o,fallbackPhoneNumber:d,checkoutContext:i,markShopCashStatesStale:l}=this.deps,c=s??a.user.paymentMethods.value.filter(Y).map(b=>b.paymentAttributes).find(b=>b.id===e)?.uuid;if(!c)return{status:"failed"};const u=a.session.selectedPaymentMethod.value,p=u&&Y(u)?u.paymentAttributes.uuid:void 0,h=await r(e,c,i);if(h.status!=="success"&&!lr(h))return{status:"failed"};const v=a.user.paymentMethods.value.filter(Y).map(b=>b.paymentAttributes).filter(b=>b.uuid!==c);if(a.user.removeCreditCard(e),l(),p!==c)return{status:"success"};const g=ka(v);if(g)a.session.selectPaymentMethod({id:g.id,lastUsedAt:g.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:g}),this.clearShopPayPaymentLines();else{const b=this.paymentMethods.value.find(({method:f,isValidForCheckout:A,isDisabled:w,isExpired:L})=>A&&!w&&!L&&qn(f))?.method;if(b){const f=et(b,a.user.paymentMethods.value);f&&this.#e(f)}else a.session.clearPaymentMethod(),this.clearShopPayPaymentLines(),a.session.unstable_updateSelectedBillingAddress(a.session.selectedShippingAddress.value)}const _=g?g.billingAddress.address:a.session.selectedBillingAddress.value?.address;return await n({billingAddress:_??o.value,fallbackPhoneNumber:d}),{status:"success"}}recordPaymentMethodSelected(e){const{observability:s,userEvents:a,source:r,checkout:n,shop:o}=this.deps,d=e.paymentMethod.toLowerCase(),{paymentMethodName:i,paymentBrands:l}=rr(e,this.availablePaymentMethods.value);s.counter({name:"payment_method_selected",value:1,attributes:{payment_method_type:d,payment_method_name:i,payment_brands:l,location:"shop_pay_payment_selector",is_mobile:Ea()}}),a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...as(r,n,o),action:"payment_method_selected",paymentMethodName:i}})}async handleNewCardResponse(e,s,a){const{shopPay:r,markShopCashStatesStale:n}=this.deps;
2if(e.status==="success"&&e.creditCard){if(s&&e.creditCard.funding!=="debit")return await this.deleteCreditCardById({id:e.creditCard.id,uuid:e.creditCard.uuid}),{status:"failed",errors:[{field:["",ps.DebitOnly],message:""}]};await this.refreshPaymentMethodsFromBuyerDetails()||r.user.addCreditCard(e.creditCard),a?await this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}):this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}).catch(d=>{this.deps.observability.error(d)}),n()}return e}async refreshPaymentMethodsFromBuyerDetails(){const{shopPay:e,refreshBuyerDetails:s,paymentRequiredMethod:a,observability:r}=this.deps;try{const n=await s();return n.status!=="success"?!1:(e.updatePaymentMethodsFromBuyerDetails(n,{negotiatedPaymentMethods:this.availablePaymentMethods.value,paymentRequiredMethod:a}),!0)}catch(n){return r.error(n instanceof Error?n:new or("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const s=Wt(this.deps.proposedPaymentLines.value)!==void 0,a=this.selectCreditCard({id:e});if(s)return a;const{shopPay:r}=this.deps,n=r.session.selectedPaymentMethod.value;n&&Y(n)&&n.paymentAttributes.id===e&&Ye(n,r.user.paymentMethods.value,de(n,this.availablePaymentMethods.value))&&this.#e(n),await a}#e(e,{buyerInitiated:s=!1}={}){const{shopPay:a,setPaymentLine:r,observability:n}=this.deps;Es(()=>{a.session.selectPaymentMethod(e);const o=wa({paymentMethod:e,negotiatedPaymentMethods:this.availablePaymentMethods.value,observability:n});if(o!==void 0){if(s){r(o,void 0,{buyerInitiated:!0});return}r(o)}})}clearShopPayPaymentLines(){const{proposedPaymentLines:e}=this.deps;e.value=e.value.filter(s=>!ns([s],"SHOP_PAY"))}}function Si({enableAutoSelect:t=!0}={}){const{source:e,environment:s,checkout:a,shop:r,i18n:n,observability:o,userEvents:d,shopPay:i,graphql:{coreGraphql:l,shopPayGraphql:c}}=N(),u=a.identity.current.value,p=s.devMode!=null,h=wn(),v=Nn(),g=Dn(),_=Tn(),b=Rn(),f=Ce({source:e}),A=Fn(),w=X(),{paymentLines:L}=w,I=An(),S=it(cs),T=i.user.phoneNumber.value,F=G(),R=tn(),B=i.session.isInstallmentsSelected.value,D=sn({isApplePayAvailable:R.value}),P=Da(),{creditCardDisabled:q}=ln(),ce=rn(),{updateCheckoutAddress:ie}=an(),[,ne]=nn({allowPreselect:!1}),ue=Ee(F.paymentMethods.value??[]),Z=dt(ue),ve=rs(),{eligibilityByCardId:be}=xa(un),ge=M(()=>{S&&(S.cashbackState.stale.value=!0)},[S]),Pe=j(()=>({checkoutIdentifier:e.checkoutSessionIdentifier??"",checkoutVersion:f,shopId:Te(r.id),shopifyDomain:r.myshopifyDomain}),[e.checkoutSessionIdentifier,r.id,r.myshopifyDomain,f]),$=j(()=>{const _e=()=>new cr({shopPay:i,negotiatedPaymentMethods:F.paymentMethods,installmentsPaymentMethodSelected:B,isApplePayAvailable:R.value,filteredNegotiatedPaymentMethods:D.value,isCreditCardDisabled:q,setPaymentLine:ne,updateCheckoutAddress:ie,shippingRequired:a.isShippingRequired,i18n:n,observability:o,userEvents:d,source:e,checkout:a,shop:r,createCreditCard:h,deleteCreditCard:g,updateCreditCard:b,completeCreditCardVerification:v,refreshBuyerDetails:_,markShopCashStatesStale:ge,shopPayGraphql:c,emptyAddress:A,proposedPaymentLines:L,checkoutContext:Pe,fallbackPhoneNumber:T,paymentRequiredMethod:ce.value,msiEligibilityByCardId:be,hasSellingPlan:ve});return u==="shopPay"?_e():u==="customerAccount"||u==="businessCustomer"?new Ne({proposal:a.proposal,newCard:I,displayablePaymentMethods:P,paymentMethodPromotions:a.paymentMethodPromotions,setPaymentLine:ne,isMsiAvailable:Z,shopId:r.id,checkoutSessionIdentifier:e.checkoutSessionIdentifier,storeVaultEnabled:r.storeVaultEnabled,storeVaultGuestCvvVerificationEnabled:r.storeVaultGuestCvvVerificationEnabled,graphql:l,extendedAddressMode:a.address.extendedAddressMode,i18n:n,observability:o,userEvents:d,identity:u,deployStage:s.deployStage,isLocalDevelopment:p}):new nr({observability:o,identity:u,deployStage:s.deployStage,isLocalDevelopment:p})},[u,s.deployStage,p,i,F.paymentMethods,B,R.value,D.value,P,q,Z,ne,ie,a,o,d,e,r,n,l,c,h,g,_,b,v,ge,A,L,I,Pe,T,ce.value,be,ve]);O(()=>()=>$.dispose(),[$]);const me=$.selectedPaymentMethod.value,he=$.paymentMethods.value,we=$.availablePaymentMethods.value,y=$.availableUserStoredPaymentMethods.value,C=L.value.some(_e=>_e.method.type==="direct");O(()=>{if(!t||u!=="shopPay"||me&&zn({selected:me,paymentMethods:he,availablePaymentMethods:we})||C)return;const _e=he.filter(({isValidForCheckout:Me})=>Me).sort((Me,As)=>ye(Me.method,As.method)).map(({method:Me})=>Me),Se=Yn(_e);Se&&K(Se)&&Se.paymentAttributes.expired&&d.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...as(e,a,r),action:"final_payment_method_expired_after_merchant_filter"}});
2const ft=Se?et(Se,i.user.paymentMethods.value):void 0;ft?i.session.selectPaymentMethod(ft):i.session.clearPaymentMethod()},[t,we,y,a,u,d,he,me,r,i.session,i.user.paymentMethods.value,e,C]);const{buyerHasActedSignal:E,newCardSignal:V}=Ue(),H=E.value,J=!!V.value,re=$ instanceof Ne?$.autoselectTarget.value:void 0,oe=$ instanceof Ne?$.proposedSelectedPaymentMethod.value:void 0,pt=L.value[0],Ke=pt?.method.type,yt=cn(pt);return O(()=>{t&&(u!=="customerAccount"&&u!=="businessCustomer"||H||$ instanceof Ne&&re&&(J||yt||oe&&oe.paymentMethod===re.paymentMethod&&oe.id===re.id||(Ke&&o.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodType:Ke,replacingPaymentMethodType:re.paymentMethod}),$.selectPaymentMethod(re,"programmatic").catch(()=>{}))))},[t,u,H,J,$,re,oe,yt,Ke,o]),$}function Mi(){const{shop:t,checkout:e,observability:s}=N(),a=e.wallets.activeSession.value,r=e.latestReceipt.value,{persistedPayPalSignal:n}=es(),o=e.identity.current.value==="payPal",d=r?.id,i=Os().value,l=i!==void 0,c=Ve(),u=n.value,{negotiate:p}=Oe(),h=$s(),v=Yt(new Set(Ta))?.hasError&&d!==u?.receiptIdForClearedToken,g=Ks("PAYPAL_EXPRESS").value?.merchantId?.trim(),_=i?.method.walletContent?.merchantId?.trim(),f=t.hasFlagEnabled(Ba)&&g&&_&&_!==g,A=u?.billingAgreementStatus&&Ra({checkout:e})&&u.billingAgreementStatus==="NOTREQUESTED"&&!i?.method.walletContent?.isVaultWithPurchaseOrder,w=i?.method.walletContent?.isVaultWithPurchaseOrder===!0&&c.value?.amount===0;O(()=>{function L(){const S={...n.value,receiptIdForClearedToken:v?d:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};n.value=S}function I(){let S;v?S="SubmitForCompletion Error":f?S="Gateway Mismatch":w?S="Zero Payment Due":S="Subscription Added",s.counter({name:"paypal_token_cleared",value:1,attributes:{clearReason:S}}),s.log("paypal_token_cleared","Clearing PayPal token due to error",{clearReason:S})}l&&((v||f||A||w)&&(I(),L()),(async()=>(w||v&&!o&&!a)&&(h(),await p({silenceViolations:["non-stock"]})))())},[v,l,f,d,s,n,A,w,o,h,p,a])}function ur(t){const e=G().paymentMethods;return U(()=>{const a=!!t.value?.balance?.amount,r=!!e.value?.find(n=>n.type==="redeemable"&&n.redemptionSource==="STORE_CREDIT");return!!(a&&r)})}var se=(t=>(t.Init="init",t.Loading="loading",t.Success="success",t.Error="error",t.Stale="stale",t))(se||{});function ys(t,e){return t.filter(s=>!fs(s,e))}function mr(t,e){return t.some(s=>fs(s,e))}function hr({firstOrderTotal:t,storeCreditAccount:e}){if(!t||!e||t.currencyCode!==e.balance.currencyCode)return;const s=e.balance.amount-t.amount;if(!(s<=0))return{amount:s,currencyCode:e.balance.currencyCode}}function fs(t,e){return mt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function pr(t){const e=G().paymentLines;return U(()=>{const s=t.value;return!s||!e.value?.lines?!1:mr(e.value.lines,s)})}function yr(){const{shop:{currencyCode:t}}=N(),s=G().buyerIdentity;return U(()=>{const a=s.value,r=a?.presentmentCurrency||t;return(a?.customerProfile?.__typename==="CustomerProfile"||a?.customerProfile?.__typename==="BusinessCustomerProfile"?a.customerProfile.storeCreditAccounts:[]).find(o=>o.balance.currencyCode===r)})}function Ai(){const t=G().paymentLines;return U(()=>t.value?.lines.filter(e=>mt(e))||[])}const fr=new Set(["Image","Banner","s-image","s-banner"]);function Cr({options:t,paymentMethodExtension:e}){const s=e[0]?.extension;if(!s)return null;const a=s.appId.split("/").pop(),r=a&&!Fa.includes(a);return m(Gs,{options:t,customizations:e,transformComponents:r?vr:void 0})}const vr=qs(fr);function br(){const t=G().allViolations,e=U(()=>(t.value??[]).filter(a=>!!(Ys(a)||Ua(a)))),s=U(()=>{const[a]=e.value;return a?a.localizedMessage||a.nonLocalizedMessage:null});return m(Re,{when:s,children:a=>m(Qt,{tone:"critical",errorType:jt.DiscountError,children:a})})}function gr({amount:t,maskedIdentifier:e,remove:s}){const{i18n:a}=N(),r=a.formatCurrency(t.amount,{currency:t.currencyCode,form:"short"}),n=e.slice(-4).toUpperCase(),o=a.translate("payment.gift_card_wrapper.gift_card_label",{identifier:zs(n)}),d=a.translate("order_summary.gift_card_ending",{last_characters:n||""});return m(ke,{borderRadius:"base",background:"base",border:"base",blockAlignment:"center",padding:"small-200",children:m(qe,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",children:[m(qe,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[m(ls,{type:"gift-card"}),m(Xt,{children:[m(ee,{accessibilityVisibility:"hidden",children:o}),m(ee,{accessibilityVisibility:"exclusive",children:d})]})]}),m(qe,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-100",alignItems:"center",alignContent:"center",children:[m(ee,{type:"strong",children:r}),m(Zt,{onClick:()=>s(),accessibilityLabel:a.translate("general.remove_item",{label:d}),children:m(Fe,{type:"x",size:"small"})})]})]})})}const Nt="gift_card_option";function ki({afterAppliedRedeemablesChange:t,autoSelect:e=!1,showHeading:s=!0}){const{i18n:a}=N(),{paymentMethod:r,paymentLines:n,submit:o,remove:d,removeAll:i}=Hs(),l=Ws("Checkout::GiftCard::Render",r?.uiExtension?[r?.uiExtension]:[]),{value:c}=Ve(),u=c?.amount||0,[p,h]=W([]),[v,g]=W(!1),_=u===0&&n?.length===0,b=async S=>{h(S),S.length===0&&n.length>0&&(await i())?.status==="success"&&t?.()};O(()=>{_?h([]):(n?.length>0||e)&&h([Nt])},[e,n?.length,_]);const f=M(async(S,T)=>{const F=await o(S,T);
2return F?.status==="success"&&(g(!1),t?.()),F},[t,o]),A=j(()=>({paymentMethodIdentifier:r?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:f}),[r?.paymentMethodIdentifier,f]),w=S=>{const{cost:T,method:F}=S;if(!T||F.redemptionSource!=="CUSTOM")return null;const R=F.redemptionContent?.redemptionAttributes.reduce((B,D)=>`${B},${D.key}:${D.value}`,"");return m(gr,{maskedIdentifier:F.redemptionContent?.maskedIdentifier||"",amount:{amount:T.amount,currencyCode:T.currencyCode},remove:async()=>{(await d(F))?.status==="success"&&t?.()}},R)},L=()=>{if(u===0||!l.length||!r)return null;const S=m(Cr,{paymentMethodExtension:l,options:A});return!n||n.length===0?S:v?m(ke,{children:[m(pe,{blockSize:"small-500"}),m(Q,{gap:"base",children:[m(Xe,{level:3,children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")}),S]})]}):m(ke,{children:[m(pe,{blockSize:"small-500"}),m(zt,{textDecoration:"none",onClick:()=>g(!0),children:m(Q,{direction:"inline",alignItems:"center",gap:"small-400",children:[m(Fe,{type:"plus"}),m(ee,{children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]})},I=!!n?.length||!!l.length&&!!r;return m(Qs,{id:"3p-gift-card-field",open:I,duration:"slow",children:m(ot,{accessibilityLabel:a.translate("payment.gift_card_wrapper.heading"),children:m(Q,{gap:"base",children:[s&&m(Xe,{level:2,children:a.translate("payment.gift_card_wrapper.heading")}),m(us,{name:"gift_card_option_list",values:p,multiple:!0,onChange:b,variant:"block",children:m(Ze,{value:Nt,disabled:_,selectedContent:m(Q,{gap:"base",children:[n?.length>0?m(Q,{gap:"small-300",children:n.map(w)}):null,m(br,{}),L()]}),children:a.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const We="StoreCreditRedemptionCheckbox",Qe="StoreCreditSubscriptionRenewalsCheckbox";function $e(t,e){return mt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function Pr(t,e){if(!(t.status!=="success"&&t.status!=="error"))return t.negotiated?.paymentLines?.lines.find(s=>$e(s,e))?.cost}function _r({paymentLines:t,storeCreditAccount:e,cost:s}){return t.map(a=>$e(a,e)?{...a,cost:s}:a)}function Lt({amountDueAtCheckout:t,storeCreditAccount:e}){if(Cs({amountDueAtCheckout:t,storeCreditAccount:e})&&t!=null)return{amount:Math.min(t.amount,e.balance.amount),currencyCode:t.currencyCode}}function Cs({amountDueAtCheckout:t,storeCreditAccount:e}){return t==null||t.currencyCode===e.balance.currencyCode}function Dt({paymentLines:t,storeCreditAccount:e,cost:s}){let a=!1;const r=t.map(n=>{if(!$e(n,e))return n;if(s==null){if(n.cost==null)return n;const{cost:o,...d}=n;return a=!0,d}return n.cost?.amount===s.amount&&n.cost.currencyCode===s.currencyCode?n:(a=!0,{...n,cost:s})});return a?r:t}function vs(t){const{negotiate:e}=Oe();return M(async()=>new Promise(s=>{e({include:["paymentLines"],silenceViolations:["non-store-credit"],runListenersOnError:!0,force:!0,onComplete(a){t.value=a.status==="success"?se.Success:se.Error,s(a)}})}),[e,t])}function Sr(t,e){const s=X(),a=vs(e);return M(async()=>{if(!t)return e.value=se.Error,Promise.resolve();e.value=se.Loading;const r=ys(s.paymentLines.value,t);return s.paymentLines.value=r,a()},[t,e,s.paymentLines,a])}function Mr(t,e){const{i18n:s,shop:a}=N(),r=X(),n=vs(e),o=G().paymentLines,d=Ve(),i=is(),l=rs(),c=os(),u=G().paymentFlexibilityPaymentTermsTemplate,p=Va(a),h=G().isImmediateAmountReducedForRedeemables,v=M(()=>p&&Oa({hasSellingPlan:l.value,hasFixedSellingPlan:c.value,paymentTermsTemplateType:u.value?.type}),[p,l,c,u]),g=ae(!1);return Gt(()=>{if(!v())return;const _=d.value??i.value,b=r.paymentLines.value;if(!t||!g.current)return;const f=o.value?.lines.find(w=>$e(w,t))?.cost;if(h?.value){if(f){const w=Dt({paymentLines:b,storeCreditAccount:t,cost:f});w!==b&&(r.paymentLines.value=w)}return}if(f&&f.amount>0){g.current=!1;return}const A=Dt({paymentLines:b,storeCreditAccount:t,cost:Lt({amountDueAtCheckout:_,storeCreditAccount:t})});
2A!==b&&(r.paymentLines.value=A)}),M(async()=>{if(!t)return e.value=se.Error,Promise.resolve(null);e.value=se.Loading;const _=ys(r.paymentLines.value,t),b=d.value??i.value,f=v(),A=f?Lt({amountDueAtCheckout:b,storeCreditAccount:t}):void 0;if(g.current=A!=null,f&&!Cs({amountDueAtCheckout:b,storeCreditAccount:t}))return e.value=se.Error,Jt({content:s.translate("store_credit_errors.generic_error")}),Promise.resolve(null);r.paymentLines.value=[..._,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:t.id}},...A&&{cost:A}}];const w=await n(),L=f&&Pr(w,t);return L&&L.amount>0&&(g.current=!1,r.paymentLines.value=_r({paymentLines:r.paymentLines.value,storeCreditAccount:t,cost:L})),w},[i,n,d,r.paymentLines,e,v,t,s])}function Ar(t){const e=is(),s=$a();return U(()=>{if(s.value)return hr({firstOrderTotal:e.value,storeCreditAccount:t.value})})}function Ei({afterAppliedRedeemablesChange:t}){const{i18n:e,shop:s}=N(),a=s.hasFlagEnabled(Ka),r=Ve(),n=X(),o=Ga(),d=os(),i=yr(),l=pr(i),c=ws(se.Init),u=ur(i),p=Ar(i),h=U(()=>a&&p.value!=null),v=U(()=>o.value||d.value),g=U(()=>{if(o.value)return e.translate("payment.store_credit.buying_gift_card");if(d.value)return e.translate("payment.store_credit.no_fixed_selling_plans")});Gt(()=>{(!u.value||!h.value||v.value)&&Is(()=>{n.useStoreCreditForSubscriptionRenewals.value&&(n.useStoreCreditForSubscriptionRenewals.value=!1)})});const _=Mr(i.value,c),b=Sr(i.value,c),f=U(()=>c.value===se.Loading),A=U(()=>f.value||v.value),w=U(()=>A.value||r.value?.amount===0&&!l.value),L=A,I=U(()=>{const D=[],P=h.value&&n.useStoreCreditForSubscriptionRenewals.value;return(l.value||P)&&D.push(We),P&&D.push(Qe),D}),S=M(async D=>{const P=a&&D.includes(Qe),q=D.includes(We)||P;if(n.useStoreCreditForSubscriptionRenewals.value=P,q!==l.peek()){if((q?await _():await b())?.status!=="success"){n.useStoreCreditForSubscriptionRenewals.value=!1;return}t?.()}},[_,b,l,n.useStoreCreditForSubscriptionRenewals,a,t]),T=i.value;if(!u.value||!T)return null;const F=h.value?p.value:void 0,R=T.balance,B=g.value;return m(ot,{accessibilityLabel:e.translate("payment.store_credit.label"),children:m(us,{name:"store_credit_redemption",values:I.value,multiple:!0,onChange:S,variant:"block",children:[m(Ze,{value:We,disabled:w.value,secondaryContent:m(ee,{type:"strong",children:e.formatCurrency(R.amount,{currency:R.currencyCode})}),details:B&&m(ee,{children:B}),children:m(Q,{direction:"inline",gap:"base",alignItems:"center",children:[m(ee,{children:e.translate("payment.store_credit.apply_label")}),m(Re,{when:f,children:m(js,{})})]})}),F&&m(Ze,{value:Qe,disabled:L.value,details:m(Q,{gap:"small-500",children:[m(ee,{children:e.translate("payment.store_credit.remaining_for_subscription_charges_description",{amount:e.formatCurrency(F.amount,{currency:F.currencyCode})})}),B&&m(ee,{children:B})]}),children:m(ee,{children:e.translate("payment.store_credit.use_remaining_for_subscription_charges_label")})})]})})}function wi(){const{i18n:t}=N(),{hasViolations:e}=Xs(qa);return e?m(Qt,{errorType:jt.PaymentError,tone:"critical",children:t.translate("store_credit_errors.generic_error")}):null}const kr="YVGTZ",Er="zyVks",wr="U4h7p",je={Row:kr,Name:Er,Digits:wr};function Ii({name:t,digits:e,icon:s}){return m(Q,{className:je.Row,direction:"inline",columnGap:"none",rowGap:"small-200",alignItems:"center",inlineSize:"100%",children:[m("span",{className:je.Name,children:m(Xt,{children:t})}),m("span",{className:je.Digits,children:e}),s]})}const Ir=new Map([["american_express","American Express"],["cartes_bancaires","Cartes Bancaires"],["diners_club","Diners Club"],["discover","Discover"],["elo","Elo"],["jcb","JCB"],["master","Mastercard"],["masterdebit","Mastercard"],["unionpay","UnionPay"],["visa","Visa"],["visadebit","Visa"],["maestro","Maestro"]]);function Nr(t){const e=Ir.get(t.toLowerCase());if(e)return e;const s=t.toUpperCase();return Ya(s)?ds(s):t}function Ni(t){return t?t.nickname&&t.nickname.trim().length>0?t.nickname:t.bank&&t.bank.trim().length>0?t.bank:Nr(t.brand):""}function Lr(){const{paymentLines:t}=X();return U(()=>Wt(t.value))}function Dr({isSelected:t,hasMsiPlan:e,isStale:s,binPrefix:a,canEditBin:r,supportedInstallmentsCount:n,isNegotiating:o}){if(!t||!e&&!s)return"hidden";if(a){if(a.length<8&&r)return"prompt"}else{if(r)return"prompt";if(n===0)return"hidden"}return o||s?"loading":"dropdown"}function xt({id:t,variant:e}){const{i18n:s}=N(),a=e==="prompt"?s.translate("msi_installments.enter_card_details_prompt"):s.translate("msi_installments.loading_installments");return O(()=>{if(e==="loading")return Jt({content:a})},[a,e]),m(ta,{id:t,name:"msiInstallments",label:s.translate("msi_installments.payment_plan_label"),value:e,disabled:e==="loading",onCh
2ange:()=>{},children:m(ea,{value:e,children:a})})}function xr({paymentMethod:t,isSelected:e,canEditBin:s=!0,isVaultedContext:a=!1,id:r="msiInstallmentsSelect"}){const{bankIdNumberSignal:n,installmentMonthsSignal:o,lastNegotiatedBinSignal:d}=Ue(),{paymentLines:i}=X(),l=Lr();O(()=>{o.value=l.value},[l.value,o]);const c=s&&!a,u=t.installmentPlans?.find(_=>_.type==="MSI"),p=u?.supportedInstallments??[],h=za(n.value),v=!a&&h!==void 0&&d.value!==void 0&&h!==d.value;O(()=>{if(!l.value)return;(!e||!u||!h&&!c&&p.length===0)&&(i.value=Js(i.value,void 0))},[l.value,e,u,h,c,p.length,i]);const g=Dr({isSelected:!!e,hasMsiPlan:!!u,isStale:v,binPrefix:h,canEditBin:c,supportedInstallmentsCount:p.length,isNegotiating:!1});return g==="hidden"?null:g==="prompt"?m(xt,{id:r,variant:"prompt"}):m(xt,{id:r,variant:"loading"})}const Tt=nt({displayName:"MsiInstallmentsSelect",useError:Zs("MsiInstallmentsSelect"),load:()=>Ns(async()=>({default:(await at(async()=>{const{MsiInstallmentsSelect:t}=await import("./component-MsiInstallmentsSelect.BlpDspwz.js");return{MsiInstallmentsSelect:t}},__vite__mapDeps([26,1,11,2,3,4,5,7,8,12,27,28,29,17,30,31,32,33,34,16,18,19,20,35,36,37,38,39,40,41,42,43,44,45,46]))).MsiInstallmentsSelect})),renderLoading:t=>m(xr,{...t})}),Bt=new Map,Ae=class Ae{constructor(e=[],s=[],a,r=!1){this.sdkQueue=e,this.initQueue=s,this.sdk=a,this.scriptLoaded=r,this.setupGeneration=0,this.currentSetupId=0}async load(e){let s=Bt.get(e.source);s instanceof Promise||(s=sa(e,!0),Bt.set(e.source,s)),await s,this.initQueue.pop()?.(),this.initQueue=[],this.scriptLoaded=!0}async setup(e,s,a){return Rt(()=>{if(this.sdk)return;if(this.setupPromise&&this.setupForm===e)return this.setupPromise;const r=window.CardFields;if(!r)throw new lt("Attempted to init Cardfields before it is ready");const n=++this.currentSetupId;return this.setupForm=e,a(),this.setupPromise=(async()=>{try{for(let o=0;o<Ae.MAX_SETUP_ATTEMPTS;o++){const d=this.setupGeneration,i=await r.setup(e,s);if(n!==this.currentSetupId){try{i.teardown()}catch{}return}if(d!==this.setupGeneration){try{i.teardown()}catch{}continue}this.sdk=i;for(const l of this.sdkQueue)await l();this.sdkQueue=[];return}throw new bt(`CardFields setup failed: ${Ae.MAX_SETUP_ATTEMPTS} consecutive teardowns raced setup.`)}finally{this.currentSetupId===n&&(this.setupPromise=void 0,this.setupForm=void 0)}})(),this.setupPromise},this.scriptLoaded,this.initQueue)}async teardown(){this.setupGeneration++,this.setupPromise=void 0,this.setupForm=void 0,this.sdk?.teardown(),this.sdk=void 0,this.sdkQueue=[],this.initQueue=[]}on(e,s,a){return this.scheduleSDK(r=>a?r.on(a,e,s):r.on(e,s))}off(e,s,a){return this.scheduleSDK(r=>a?r.off(a,e,s):r.off(e,s))}setStyles({field:e,styles:s}){return e?this.scheduleSDK(a=>a.setStyles(e,s)):this.scheduleSDK(a=>a.setStyles(s))}setFocus(e){return this.scheduleSDK(s=>s.setFocus(e))}setTranslation(e,s){return this.scheduleSDK(a=>a.setTranslation(e,s))}setPlaceholderContent(e,s){return this.scheduleSDK(a=>a.setPlaceholderContent(e,s))}setValue(e,s){return this.scheduleSDK(a=>a.setValue(e,s))}setTooltip(e,s){return this.scheduleSDK(a=>a.setTooltip(e,s))}vaultCard(e){return this.scheduleSDK(s=>s.vaultCard(e))}vaultCardMultipleTimes(e,s){return this.scheduleSDK(a=>a.vaultCardMultipleTimes(e,s))}setErrors(e){return this.scheduleSDK(s=>s.setErrors(e))}clearField(e){return this.scheduleSDK(s=>s.clearField(e))}loadFonts(e){return this.scheduleSDK(s=>s.loadFonts(e))}getFieldFrame(e){return this.scheduleSDK(s=>s._getFieldFrame(e))}scheduleSDK(e){return Rt(()=>{if(!this.sdk)throw new bt("The CardFields SDK has not been set up.");return e(this.sdk)},!!this.sdk,this.sdkQueue)}};Ae.MAX_SETUP_ATTEMPTS=3;let tt=Ae;function Rt(t,e,s){if(e){const a=t();return a instanceof Promise?a:new Promise(r=>{r(a)})}return new Promise((a,r)=>{s.push(async()=>{try{const n=t();n instanceof Promise?a(await n):a(n)}catch(n){r(n)}})})}const bs=Ds(void 0),Ft={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function Tr({children:t,value:e,sdkScriptAttributes:s,blurValidationEnabled:a=!0,blurValidationFieldDenylist:r,onError:n,onSetFieldErrors:o,onLoadSuccess:d}){const i=j(()=>new tt,[]),[l,c]=W(!0),[u,p]=W({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null,sdk:null}),h=ae(),[v,g]=W(),[_,b]=W(),[f,A]=W({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),[w,L]=W(""),[I,S]=W([]),[T,F]=W(Ft),R=ae(T);O(()=>{R.current=T},[T]);const B=ae(),D=M(y=>{h.current=y instanceof aa?y.diagnostics:void 0,p({sdk:y.message}),n?.(y),c(!1)},[n,p,c]),P=M(async y=>{try{return await y()}catch(C){if(C instanceof Error){let E=null;if(C.name===gt.name)E=new gt(C.message);else if(C.name===Pt.name){const V="httpStatus"in C&&typeof C.httpStatus=="number"?C.httpStatus:void 0;E=new Pt(C.message,V)}else C.name===_t.hostedFieldsName&&(E=new _t(C.message));if(E)return D(E),"";D(C)}throw C}},[D]),q=M(async(y,C={propagateErrors:!0})=>{const{sdk:E,...V}=y;await P(()=>i.setErrors(V)),p(H=>{const J={...H,...y};return C.propagateErrors&&o?.(J),J})},[i,o,P]),ce=M((y,C)=>{const E={},V=B.current;C?(y||(!f?.expiry&&C.includes("expiry")&&(E.expiry=V?.expiry),!f?.number&&C.includes("number")&&(E.number=V?.number_blank),!f?.name&&C.includes("name")&&(E.name=V?.name)),(y||C.includes("verification_value"))&&!f?.verification_value&&(E.verification_value=V?.verification_value)):(y||(f?.expiry||(E.expiry=V?.expiry),f?.number||(E.number=V?.number_blank),f?.name||(E.name=V?.name)),f?.verification_value||(E.verification_value=V?.verification_value));const H={...u,...E};return q(H),{isValid:!Object.values(H).some(Boolean)}},[u,f?.expiry,f?.name,f?.number,f?.verification_value,q]);O(()=>{async function y(){try{if(!s)throw new lt("Provider: hostedFieldsUrl must be provided");await i.load(s)}catch(C){C instanceof Error&&D(C)}}y()},[s,i,D]);const ie=M(({cardType:y,bin:C,networks:E})=>{g(y),L(C),S(E)},[]),ne=M(({targetName:y})=>{b(y)},[]),ue=M(async y=>{const{isValueValid:C,targetName:E,isValueEmpty:V}=y,H=B.current,J=R.current[E],re=!!r?.has(E);if(a&&!re&&H&&J){const oe={[E]:C?null:H[E]};E==="number"&&V&&(oe[E]=H.number_blank),await q(oe,{propagateErrors:!1})}b(void 0)},[q,a,r]),Z=M(async y=>{const{targetName:C,isValueEmpty:E,isTab:V}=y;if(!V){A(J=>({...J,[C]:!E}
2)),F(J=>({...J,[C]:!0}));const H={[C]:null};await q(H)}},[q]),ve=M(y=>{A(C=>({...C,[y]:!0}))},[]),be=Br(),ge=M(()=>{be.current&&(A({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),S([]))},[A,be]),Pe=M(()=>{P(()=>i.on("cardtype",ie)),P(()=>i.on("focus",ne)),P(()=>i.on("blur",ue)),P(()=>i.on("keyup",Z)),P(()=>i.on("change",Z)),P(()=>i.on("input",Z))},[P,i,ie,ne,ue,Z]),$=M(()=>{P(()=>i.off("cardtype",ie)),P(()=>i.off("focus",ne)),P(()=>i.off("blur",ue)),P(()=>i.off("keyup",Z)),P(()=>i.off("change",Z)),P(()=>i.off("input",Z))},[P,i,ie,ne,ue,Z]),me=M(()=>{F(Ft)},[]),he=j(()=>({loadFonts:y=>P(()=>i.loadFonts(y)),setErrors:y=>q(y,{propagateErrors:!1}),setStyles:(...y)=>P(()=>i.setStyles(...y)),setFocus:(...y)=>P(()=>i.setFocus(...y)),setTooltip:(...y)=>P(()=>i.setTooltip(...y)),setTranslation:(...y)=>P(()=>i.setTranslation(...y)),setPlaceholderContent:(...y)=>P(()=>i.setPlaceholderContent(...y)),setValue:(y,C)=>P(()=>(typeof C=="string"&&C.trim().length>0&&A(E=>({...E,[y]:!0})),i.setValue(y,C))),setup:async(y,C,E=()=>{})=>{c(!0),await P(()=>i.setup(y,C,E)),d?.(),c(!1),B.current=C.errorMessages},teardown:()=>P(()=>i.teardown()),clearField:y=>P(()=>(A(C=>({...C,[y]:!1})),i.clearField(y))),vaultCard:(...y)=>P(()=>i.vaultCard(...y)),vaultCardMultipleTimes:(y,C)=>P(()=>i.vaultCardMultipleTimes(y,C)),getCardField:y=>i.getFieldFrame(y)}),[i,q,P,d]);O(()=>()=>{o?.({})},[o]);const we=j(()=>e??{sdk:he,errors:u,sdkLoadDiagnostics:h.current,cardBrand:v,bankIdNumber:w,networks:I,focusedField:_,filled:f,loading:l,validate:ce,subscribe:Pe,unsubscribe:$,resetTouched:me,emptyFields:ge,setFilled:ve,touched:T},[he,v,w,I,u,f,_,l,e,ce,Pe,$,me,ge,ve,T]);return m(bs.Provider,{value:we,children:t})}function Br(){const t=ae(!0);return Ls(()=>()=>{t.current=!1},[]),t}const gs=()=>{const t=it(bs);if(t==null)throw new lt("No cardfields found in context");return t},st=6,Ps=t=>t.toUpperCase(),Ut=t=>t.toLowerCase();function Rr(t){return!!t?.some(e=>e.type==="direct"&&e.paymentBrands.includes("BOGUS"))}function Li({paymentMethods:t,hasBogusGateway:e=Rr(t),paymentLines:s,storeVaultGuestCvvVerificationEnabled:a=!1,selectedCardRequiresProposalLineCvv:r=!1,selectedCardBrand:n,hasAmexCvvOnlyField:o=Fr({paymentLines:s,storeVaultGuestCvvVerificationEnabled:a,selectedCardRequiresProposalLineCvv:r,selectedCardBrand:n})}){return e?new Set(["number"]):o?new Set(["verification_value"]):new Set}function Fr({paymentLines:t,storeVaultGuestCvvVerificationEnabled:e=!1,selectedCardRequiresProposalLineCvv:s=!1,selectedCardBrand:a}){return!!(s&&a?.toUpperCase()==="AMEX"||e&&t?.some(({method:r})=>r.type===fe.CreditCard&&r.brand==="AMEX"))}function Di(t){return t.replace(/([\d.]+)rem/g,(e,s)=>`${Number(s)*10/14}rem`)}function xi(){const{paymentMethods:t}=G();return U(()=>{const e=t.value?.filter(s=>s.type===fe.CreditCard&&!!s.expired);return e?e.length:0})}function Ti(){const{i18n:t}=N();return{getAccessibilityLabel:s=>{const a=s.type==="direct"?s.creditCardLastFourDigits:s.displayLastDigits;return`${ds(s.brand)} ${t.translate("payment.saved_credit_card_info")} ${a}`}}}function _s(t){return t?t.map(e=>Ps(e)):[]}function Ur({displayName:t,paymentBrands:e,paymentMethodIdentifier:s,selectableBrands:a,networkSelectionSupported:r}){const{bankIdNumber:n,networks:o,cardBrand:d}=gs(),{userEvents:i,source:{checkoutSessionIdentifier:l}}=N(),[c,u]=W(!1),[p,h]=W(""),v=j(()=>_s(o||(d&&(n?.length??0)>=st?[d]:void 0)),[o,d,n]);O(()=>{if(!n||n.length===0||!l)return;const g={checkoutToken:l,paymentMethodIdentifier:s,displayName:t||"",supportedBrands:e.join(","),detectedBrands:v.join(","),cardIsCobadged:v.length>1,shownBrands:a.join(","),networkSelectorShown:a.length>1&&r};c||(i.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...g,eventName:"first_digit_entered"}}),u(!0));const _=n.length>=st&&v.length>0,b=g.shownBrands!==p;_&&b&&(h(g.shownBrands),i.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...g,eventName:"brand_shown_to_buyer"}}))},[s,t,e,v,a,n,i,l,r,p,c,u])}const Ss=Ha("CreditCardNetworkContext");function Vr({children:t,paymentMethod:e,publishesCardNetworkDetection:s=!1}){const{checkout:a,source:r,observability:n,userEvents:o}=N(),d=xs(),i=e?le(e):d,l=a.cardNetworkSelection.forMethod(i),{bankIdNumber:c,touched:u,...p}=gs(),{networks:h,sdk:v,filled:g}=p,_=j(()=>_s(h),[h]),b=c?.replace(/\s/g,"").length??0,f=b>
2=st&&p.cardBrand?Ps(p.cardBrand):void 0,A=j(()=>_.filter(R=>e?.paymentBrands.includes(R)),[_,e]),w=!!e?.supportsNetworkSelection;O(()=>{s&&l.setDetectedState({networkSelectionEnabled:w,availableNetworks:A,cardBrand:f,numberFilled:!!g.number,bankIdNumberLength:b})},[s,l,w,A,f,g.number,b]);const L=l.selectableBrands.value;Ur({displayName:e?.name,paymentBrands:e?.paymentBrands??[],paymentMethodIdentifier:e?.paymentMethodIdentifier??"",selectableBrands:L,networkSelectionSupported:e?.supportsNetworkSelection??!1});const I=M(R=>{const B=l.selectedSavedCreditCardBrand.value,D=typeof R=="function"?R(B):R;l.setSelectedSavedCreditCardBrand(D)},[l]),S=M(async()=>{const R=l.selectedNetwork.value,B=R?{selected_network:Ut(R)}:void 0,D=await v.vaultCard(B);return Vt(o,{checkoutSessionIdentifier:r.checkoutSessionIdentifier??"",selectedNetwork:B?.selected_network,detectedNetworks:h}),D||n.log("credit_card_network_context_no_session_id_returned","No session id returned when vaulting card with selected network",{selectedNetwork:B?.selected_network}),D},[l,v,r,h,n,o]),T=M(async R=>{const B=l.selectedNetwork.value,D=B?{selected_network:Ut(B)}:void 0,P=await v.vaultCardMultipleTimes(R,D);return Vt(o,{checkoutSessionIdentifier:r.checkoutSessionIdentifier??"",selectedNetwork:D?.selected_network,detectedNetworks:h}),P},[l,v,o,r,h]),F=j(()=>({activePaymentBrand:l.activeBrand.value,binLength:l.bankIdNumberLength.value,paymentMethod:e,detectedNetworks:_,selectableBrands:L,selectedNetwork:l.selectedNetwork.value,selectedSavedCreditCardBrand:l.selectedSavedCreditCardBrand.value,setSelectedNetwork:l.setSelectedNetwork,setSelectedSavedCreditCardBrand:I,vaultCardWithSelectedNetwork:S,vaultCardMultipleTimesWithSelectedNetwork:T}),[l.activeBrand.value,l.bankIdNumberLength.value,l.setSelectedNetwork,l.selectedNetwork.value,l.selectedSavedCreditCardBrand.value,e,_,L,I,S,T]);return m(Ss.Provider,{value:F,children:t})}function Bi(){return Wa(Ss)}function Vt(t,{checkoutSessionIdentifier:e,selectedNetwork:s,detectedNetworks:a}){s&&t.monorailEvent({schemaId:"checkout_credit_card_network_selection/1.0",payload:{checkoutToken:e,selectedNetwork:s,supportedNetworks:a?.join(",")??""}})}const Or=["CardFieldsFetchFailureError"];function $r({children:t,publishesCardNetworkDetection:e,directPaymentMethodConfig:s,...a}){const r=ae(na()),{value:n}=G().paymentMethods,o=s??Ee(n??[]),{observability:d}=N(),i=M(l=>{if(Or.includes(l.name)){d.log("default_card_fields_provider_unactionable_error","Unactionable error in card fields provider",{error:l});return}d.error(l)},[d]);return m(Tr,{...a,onError:i,sdkScriptAttributes:r.current,children:m(Vr,{paymentMethod:o,publishesCardNetworkDetection:e,children:t})})}function Kr({enabled:t,selectedCardId:e}){const{checkout:{identity:s}}=N(),{paymentLines:a}=X(),{negotiate:r}=Oe(),n=mn(),o=ae(void 0);O(()=>{if(s.current.value!=="shopPay")return;if(!t||!e){o.current=void 0,a.value=Qa(a.value);return}if(o.current===e)return;o.current=e;const i=ns(a.value,"SHOP_PAY")?.method.walletContent?.creditCardInstallments;a.value=ja(a.value,n({msiEligibleCard:!0,creditCardInstallments:i})),r({include:[]}).catch(()=>{o.current=void 0})},[t,s.current.value,e])}function Ri(t){const{shopPay:e}=N(),{value:s}=G().paymentMethods,{paymentLines:a}=X(),{bankIdNumberSignal:r,installmentMonthsSignal:n}=Ue(),{binResolution:o,clearInstallments:d,selectedCardBin:i,expandedVisible:l,collapsedVisible:c}=t.msi,u=l.value,p=c.value,h=o==="server"?t.selectedCreditCard.value?.id:void 0;Kr({enabled:p&&!e.session.isLoading.value,selectedCardId:h});const v=ae(u);O(()=>{v.current&&!u&&(a.value=d(a.value),n.value=void 0),v.current=u},[u,d,a,n]);const g=ae(p);O(()=>{g.current&&!p&&(a.value=d(a.value),n.value=void 0),g.current=p},[p,d,a,n]);const _=i.value,b=t.selectedCreditCard.value?.id;O(()=>{if(o!=="client")return;const L=r.peek();r.value=b===z&&Xa(L,_)?L:_},[o,r,_,b]);const f=Ee(s??[]),A=f&&u?Ot({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-expanded"}):void 0,w=f&&p?Gr(Ot({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-summary"})):void 0;return{expandedSlot:A,collapsedSlot:w}}function Ot({paymentMethod:t,binResolution:e,id:s}){return e==="server"?m(Tt,{paymentMethod:t,isSelected:!0,isVaultedContext:!0,id:s}):m(Tt,{paymentMethod:t,isSelected:!0,canEditBin:!1,id:s})}function Gr(t){return m(ke,{paddingInlineStart:"large-100",children:m($r,{onSetFieldErrors:()=>{},children:t})})}function Ms({addressType:t="shipping"}={}){const{checkout:e}=N();return M(a=>e.identity.current.value==="shopPay"&&!a?.trim()&&(t==="billing"?!e.isShippingRequired.value:!0),[e,t])}function Fi({addressType:t="shipping"}={}){const{checkout:{validation:e},i18n:s,shopPay:a}=N(),r=Ms({addressType:t}),n=M(()=>{const d=e.missingFields.phone.isValid.value;if(!d){const i=e.missingFields.phone.input.value;e.missingFields.phone.error.value=i?s.translate("field_errors.shipping_line_phone_invalid"):s.translate("field_errors.phone_blank")}return d},[e,s]);return{isMissingPhone:a.user.hasFlow.value&&r(a?.user.phoneNumber.value),assertMissingPhone:n}}function Ui({addressType:t="shipping"}={}){const e=X(),s=Ms({addressType:t}),a=t==="billing"?e.billingAddress.value:e.shippingAddress.value;return{isMissingFirstName:s(a.firstName)}}const qr=Ht("OverlayMoreOptionsButton");function Vi({accessibilityLabel:t,options:e,positionArea:s}){const a=ra({base:!0,medium:!1}),{closeOverlay:r}=ia(),n=qt(void 0,qr);return e.length===0?null:m(Zt,{accessibilityLabel:t,overlay:m(pn,{connector:a?"none":"arrow",id:n,padding:"none",positionArea:s,children:m(Q,{gap:"small-200",padding:"small-100 base",alignItems:"center",children:e.map(({label:o,accessibilityLabel:d,destructive:i,href:l,onClick:c})=>{const u=`${o}-${d}`;return m(oa,{inlineSize:"fill",variant:"plain",onClick:()=>{c?.(),r(n)},href:l,accessibilityLabel:d,inlineAlignment:"start",textDecoration:"none",tone
2:i?"critical":void 0,children:o},u)})})}),children:m(Fe,{type:"menu-vertical",size:"small"})})}function Oi(t){const{checkout:{addressManager:e},observability:s}=N(),a=e[t].value,r=Yr(t);return j(()=>{function n(d,i){return async(...l)=>{const c=await d(...l);return c&&r(i)?.(),c}}return{selectAddress:n(t==="shipping"?(d,i)=>(s.log("shipping_address_select_invoked","[useAddressMutationsWithNegotiation] selectAddress invoked for a shipping address",{address_id:d,source:i?.source??"unknown"}),a.selectAddress(d)):d=>a.selectAddress(d),"select"),createAddress:n(a.createAddress,"create"),updateAddress:n(a.updateAddress,"update"),deleteAddress:n(a.deleteAddress,"delete")}},[a,r,s,t])}function Yr(t){const e=da(),{checkout:{identity:s}}=N(),a=it(cs),{negotiate:r}=Oe(),n=s.current;return M(o=>{const d=n.value;if((d==="customerAccount"||d==="guest")&&t==="shipping")return()=>{e?.dispatch("addressReplaced")};if(d==="shopPay")return async()=>{const i=t==="shipping"?["shippingAddress"]:["billingAddress"];await r({include:i,silenceViolations:["non-stock"],fieldsToResolve:i}),a&&["create","update"].includes(o)&&(a.cashbackState.stale.value=!0)};if(t==="billing"&&d==="businessCustomer")return()=>{r({fieldsToResolve:["billingAddress"]})}},[n,t,e,a,r])}export{pr as $,fi as A,Pi as B,Je as C,$r as D,Bi as E,Fn as F,ki as G,Fr as H,Ps as I,Di as J,Ti as K,kn as L,Vi as M,mi as N,Tt as O,Cr as P,An as Q,Kn as R,wi as S,li as T,Gn as U,Ii as V,Hn as W,xi as X,hi as Y,ui as Z,ci as _,Lr as a,hr as a0,se as a1,Mr as a2,Sr as a3,We as a4,Qe as a5,gn as a6,Ei as b,Si as c,Ri as d,di as e,Li as f,Dr as g,yr as h,ur as i,Ai as j,Fi as k,Ui as l,Oi as m,_i as n,Rr as o,gs as p,Ni as q,K as r,bi as s,Ci as t,Mi as u,vi as v,gi as w,pi as x,rr as y,yi as z};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.