PageSourceSearch

https://damiva.com/cdn/shopifycloud/checkout-web/assets/c1/6bfea526.DhpjKDX-.js

js damiva.com collected 2026-10-08 01:40:30 UTC 82,580 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["c0b4c58b.BA39Lz6R.js","2c1ab0fe.B2yRRyAW.js","4b4bc88f.JFrEI7LU.js","app.C_W8kcQ4.js","assets/app.CcGlIMpn.css","assets/wallet-prefilled-guest-return.BJvF0-q4.css","633ac094.DhijtGPP.js","24fcbaf6.DBFCdxRc.js","ca3e798e.j1SNghYW.js","e77d135d.Dz0RetrO.js","60a453ce.aSs2kW8G.js","ca5e9c49.DCsOjSbY.js","164ad2e3.-hfWY9cN.js","d0bb51ec.CiN57OqX.js","f67abd2c.Boj0gJpa.js","e12db40c.ZpKYxNRe.js","9dba8418.BqWu-Ch9.js","assets/hydrate.BVNsrfvu.css","5ef0d995.gXIjgSI_.js","82de4790.DJFcD_Yf.js","ac5a19ff.BhdcadwW.js","598fef4e.C__a6xIj.js","assets/PaymentIcon.gzvCNwz_.css","e77f7fe0.B1UY2cg5.js","22345fd4.CQJ0n-1P.js","4b1c22b7.BOiV_1od.js","assets/PaymentLine.DT05kVlY.css","a422df8c.p_hgP_ap.js","efa0389a.DgBvBH2e.js","assets/Choice.CrYuHUmO.css","assets/EmptyState.BEvzDDvy.css","cc6ff67d.C_qUEjhN.js","08a3b809.DE8GX3m3.js","d25d1b95.DkedqTWK.js","bf513f9c.BITc5iYn.js","e39bc11c.DZRk2vl_.js","7a8217fd.C2rM5fX2.js","8599b02a.C02H2K0N.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","cf29e63b.CWl11nWq.js","6a7f8a66.BX03a5Em.js","33d2e4fc.Cd6g6AsB.js","assets/NumberField.CRpcZnVJ.css","dae24aab.xiAL8T3Q.js","assets/Tips.CxDIiA6F.css"])))=>i.map(i=>d[i]);
2import{_ as e,S as t}from"./app.C_W8kcQ4.js";import{i as a,k as s,u as r,w as n,S as i,G as o,z as d,q as l,y as c,I as u,a2 as m,n as h,T as p,x as y,h as f,g as v,p as b,o as C,L as g,j as _,_ as M,X as P,ak as S}from"./2c1ab0fe.B2yRRyAW.js";import{aM as k,r as A,bD as E,L as w,fA as I,s as x,fv as L,a1 as D,d as N,S as B,f as T,gK as F,I as V,gL as U,cB as R,gM as O,a7 as $,v as Y,ak as q,fK as j,U as z,gN as G,gO as K,a9 as H,aa as Q,gP as W,ab as X,bP as J,j as Z,aH as ee,b as te,dc as ae,br as se,i as re,H as ne,aU as ie,A as oe,c as de,bY as le,eY as ce,bH as ue,bI as me,bJ as he,gQ as pe,gR as ye,gS as fe,gT as ve,gU as be,gV as Ce,gW as ge,gX as _e,au as Me}from"./164ad2e3.-hfWY9cN.js";import{c as Pe,a6 as Se,cy as ke,dn as Ae,fY as Ee,fS as we,br as Ie,hu as xe,hv as Le,bv as De,hw as Ne,bh as Be,hx as Te,hy as Fe,bP as Ve,cx as Ue,hz as Re,bJ as Oe,aJ as $e,fL as Ye,O as qe,hp as je,hA as ze,ho as Ge,fF as Ke,hq as He,U as Qe,aA as We,gp as Xe,hB as Je,a3 as Ze,v as et,dm as tt,a9 as at,hC as st,hn as rt,hD as nt,hE as it,L as ot,hF as dt,hG as lt,hH as ct,hI as ut,hJ as mt,aI as ht,bM as pt,ab as yt,c2 as ft,aO as vt,hK as bt,hL as Ct,aQ as gt,hM as _t,hN as Mt,hO as Pt,hP as St,aM as kt,dl as At,hQ as Et,_ as wt,hR as It,hS as xt,hT as Lt,hU as Dt,dV as Nt,dW as Bt,be as Tt,aj as Ft,u as Vt,hV as Ut,cV as Rt,bf as Ot}from"./4b4bc88f.JFrEI7LU.js";import{u as $t,g as Yt}from"./ac5a19ff.BhdcadwW.js";import{P as qt}from"./598fef4e.C__a6xIj.js";import{a as jt}from"./e77f7fe0.B1UY2cg5.js";import{b as zt,E as Gt}from"./a422df8c.p_hgP_ap.js";import{a as Kt,c as Ht,b as Qt,u as Wt}from"./cc6ff67d.C_qUEjhN.js";import{S as Xt,u as Jt}from"./bf513f9c.BITc5iYn.js";import{s as Zt,n as ea}from"./e39bc11c.DZRk2vl_.js";import{u as ta,i as aa,S as sa,c as ra}from"./7a8217fd.C2rM5fX2.js";import{s as na}from"./cf29e63b.CWl11nWq.js";import{a as ia,b as oa}from"./efa0389a.DgBvBH2e.js";import{s as da}from"./d25d1b95.DkedqTWK.js";const la=a({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>e(()=>import("./c0b4c58b.BA39Lz6R.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))}),ca=x("AmazonPayChangePaymentLinkButton");function ua(){const{i18n:e,observability:t}=Pe(),{inMemoryAmazonPayParts:{sdkStatus:a}}=Se(),i=s(()=>{const e=a.value;return e.status===k.Available?e.sdk:void 0}),o=$t(),d=A(void 0,ca),{hasError:l}=E(ke),c=e.translate("vaulted.change_button");return o.value?r(n,{when:i,children:e=>r(w,{onClick:()=>{try{const{checkout_session_id:t}=I(o.value.method.walletParams);e.Pay.changePaymentMethod({amazonCheckoutSessionId:t,isDeclined:l})}catch(a){t.error(new ma(`Error on changing buyer payment method. Details: ${a}`,{cause:a}))}},id:d,children:c})}):null}
2class ma extends Error{constructor(){super(...arguments),this.name="AmazonPayChangePaymentLinkError"}}const ha=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 pa({brand:e,descriptor:t}){const{hasError:a}=L(),s=e?.toLowerCase().replace(/\s+/g,"_")??"",n=ha.get(s)??"generic";return r(B,{direction:"inline",children:[a&&r(i,{children:[r(D,{tone:"critical",type:"alert-circle"}),r(N,{display:"inline",inlineSize:"small-400"})]}),r(jt,{icon:r(qt,{type:n}),details:t})]})}function ya(){const{i18n:e,checkout:{negotiator:t}}=Pe(),a=t.parts.purchaseOrderNumber.value;if(!a)return null;const s=`${e.translate("payment.purchase_order_number.title")} #${a}`;return r(T,{children:s})}const fa=e=>r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"66 -30 151 80",...e,children:[r("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"}),r("circle",{cx:157.2,cy:-2.9,r:3.5,fill:"inherit",stroke:"inherit",strokeWidth:2}),r("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"})]});function va({minimal:e,reason:t,vaulted:a}){const{i18n:s}=Pe(),n=F().value.length,i=e=>{switch(e){case"giftCard":return s.translate("payment.order_covered_by_gift_cards_notice",{count:n});case"freeOrder":return s.translate("payment.free_order_notice_html");case"storeCredit":return s.translate("payment.order_covered_by_store_credit_notice");case"redeemables":return s.translate("payment.order_covered_by_redeemables_notice");case"deferred":return s.translate("payment_gateway.deferred_payment_label");default:o(e)}};return a?r(B,{gap:"base",children:[r(V,{children:i(t)}),r(ya,{})]}):e?r(Gt,{children:r(zt,{children:i(t)})}):r("div",{className:"agRve",children:r(B,{gap:"large-200",alignItems:"center",children:[r(fa,{className:"FiV0Z",focusable:"false","aria-hidden":"true"}),r(zt,{children:r(V,{children:i(t)})})]})})}class ba extends t{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function Ca(){const{checkout:{negotiator:e}}=Pe(),t=e.parts.paymentLines;return s(()=>{const e=t.value,a=(()=>{const[t]=e.filter(e=>"walletsPlatformPaymentMethod"===e.method.type);if(!t)return"";const a=t.method.walletParams,s=a.payment_preferences?.[0];if(!s)throw new ba("Amazon Pay wallet params missing payment preferences",{groupingHash:"AmazonPay::usePaymentDetails::AmazonPayMissingPaymentPreferencesError"});return s.paymentDescriptor.replace("****","•••• ").replace(/(\((.*?)\))/,"").trim()})();return{brand:(()=>{if(!a)return;const e=a.match(/^(.+?)\s+••••/);if(!e)return a;const t=e[1];return void 0===t?a:t.trim()})(),descriptor:a}})}const ga={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}}"},_a=Object.freeze({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null});var Ma=(e=>(e.FirstName="firstName",e.LastName="lastName",e.Number="number",e.Cvv="verificationValue",e.Month="month",e.Year="year",e.Base="base",e.DebitOnly="debitOnly",e))(Ma||{});
2const Pa={baseMessage:null,fieldErrors:_a,blockedByDuplicateAutopayCard:!1};function Sa(){const{i18n:e,observability:t}=Pe(),[a,s]=d(Pa),r=l((e,a)=>{t.counter({name:e,value:1,attributes:{errorField:a.field.join("-"),errorMessage:a.message}})},[t]),n=l(t=>{if(!t||!t.length)return void s({baseMessage:e.translate("credit_card_form.generic_card_error"),fieldErrors:_a,blockedByDuplicateAutopayCard:!1});const a={..._a};let n=null;t.forEach(t=>{switch(r("save_credit_card_error",t),t.field?.[1]){case"firstName":return void(a.name=e.translate("field_errors.credit_card_name_billing_invalid"));case"lastName":return void(a.name=e.translate("field_errors.credit_card_name_invalid"));case"month":case"year":return void(a.expiry=e.translate("field_errors.credit_card_expiry_invalid"));case"number":return void(a.number=e.translate("field_errors.credit_card_number_invalid"));case"verificationValue":return void(a.verification_value=e.translate("payment.card_fields.errors.invalid.verification_value"));case"debitOnly":return void(n=e.translate("payment_errors.debit_only"));case"base":if("credit_card_is_expired"===t.message)return void(a.expiry=e.translate("payment_errors.card_has_expired"));if("failed_to_verify_credit_card"===t.message)return void(n=e.translate("payment.generic_incorrect_card_info"));if("three_d_secure_authentication_failed"===t.message)return void(n=e.translate("payment_errors.three_d_secure_failed_payment_method"));if("billing_address_missing"===t.message)return void(n=e.translate("payment_errors.payment_method_billing_address"))}"too_many_credit_cards"!==t.message?(n=e.translate("credit_card_form.generic_card_error"),r("save_credit_card_error_unhandled",t)):n=e.translate("credit_card_form.max_cards_reached",{max_cards:Ae})}
2),s({baseMessage:n,fieldErrors:a,blockedByDuplicateAutopayCard:!1})},[e,r]),i=l(()=>{t.counter({name:"save_credit_card_blocked_by_autopay",value:1}),s({baseMessage:null,fieldErrors:_a,blockedByDuplicateAutopayCard:!0})},[t]),o=l(()=>{s(Pa)},[]),c=l(e=>{t.counter({name:"save_credit_card_vaulting_failure",value:1,attributes:{reason:e}}),n("missing_billing_address"===e?[{field:["creditCard","base"],message:"billing_address_missing"}]:void 0)},[t,n]);return{creditCardErrors:a,setCreditCardErrors:n,clearCreditCardErrors:o,failCardVaulting:c,blockDuplicateAutopayCard:i}}function ka(e){return"CREDIT_CARD"===e?.paymentMethod}function Aa(e){return"IDEAL"===e.paymentMethod||"CUSTOM_ONSITE"===e.paymentMethod&&!0===e.paymentBrands?.some(e=>"ideal"===e.toLowerCase())}function Ea(e){return"APPLE_PAY"===e.paymentMethod}function wa(e){return"CUSTOM_ONSITE"===e.paymentMethod}function Ia(e){return"SHOP_PAY"===e.paymentMethod}function xa(e){return"SHOP_PAY_INSTALLMENTS"===e.paymentMethod}function La(e){return"PAYPAL"===e.paymentMethod}function Da(e){return"BANK"===e.paymentMethod}function Na(e){return"DEFERRED"===e.paymentMethod}function Ba(e){return"OFFSITE"===e.paymentMethod||"MANUAL_PAYMENT"===e.paymentMethod||"CUSTOM_MANUAL_PAYMENT"===e.paymentMethod||"PAYMENT_ON_DELIVERY"===e.paymentMethod}function Ta(e,t){let a=e.paymentMethod.toLowerCase(),s="";switch(e.paymentMethod){case"CREDIT_CARD":e.paymentAttributes?.brand&&(a=e.paymentAttributes.brand);break;case"CUSTOM_ONSITE":{const r=we(t,{paymentBrands:e.paymentBrands,paymentMethodIdentifier:e.paymentMethodIdentifier});a=r?.name||"custom_onsite",s=e.paymentBrands?.slice().sort().join(",")??"";break}case"IDEAL":a="ideal";break;case"OFFSITE":a=e.name,s=e.paymentBrands?.slice().sort().join(",")??"";break;case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":a=e.name;break;case"APPLE_PAY":a="apple_pay";break;case"SHOP_PAY":a="shop_pay";break;case"SHOP_PAY_INSTALLMENTS":a="shopify_installments";break;case"PAYPAL":a="paypal_express";break;case"BANK":a=e.displayName||"bank";break;case"DEFERRED":a="deferred";break;default:o(e)}return{paymentMethodName:a,paymentBrands:s}}const Fa={markBuyerHasActed:!1,updateSelectedCardBin:!1,selectedCardFirstDigits:void 0,preserveExistingBinPrefix:!1,claimMsiBin:!1,claimedMsiBin:void 0,shouldNegotiate:!1};function Va(e){return{id:e.id,bank:e.bank,brand:e.brand,defaultPaymentMethod:e.preferred,expired:e.expired,expiryMonth:e.expiryMonth,expiryYear:e.expiryYear,lastDigits:e.lastDigits,lastUsedAt:e.lastUsedAt,name:e.name,nickname:e.nickname,billingAddress:e.billingAddress,cvvVerification:e.verified?void 0:{type:"session-token"}}}function Ua(e){switch(e.paymentMethod){case"CREDIT_CARD":return{id:e.id,paymentMethod:"CREDIT_CARD",paymentAttributes:Va(e.paymentAttributes),lastUsedAt:e.lastUsedAt};case"IDEAL":case"CUSTOM_ONSITE":case"APPLE_PAY":case"OFFSITE":case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":return e}}function Ra(e,t){switch(e.paymentMethod){case"CREDIT_CARD":return t.find(t=>Ie(t)&&t.id===e.id);case"IDEAL":case"CUSTOM_ONSITE":case"APPLE_PAY":case"OFFSITE":case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":return e;case"SHOP_PAY":case"SHOP_PAY_INSTALLMENTS":case"PAYPAL":case"BANK":case"DEFERRED":return;default:o(e)}}class Oa extends Error{constructor(){super(...arguments),this.name="EmptySessionIdError"}}class $a extends Error{constructor(){super(...arguments),this.name="BuyerDetailsRefreshError"}}class Ya{constructor(e){this.newCard=c(void 0),this.canSetCreditCardNickname=c(!0),this.addCreditCardStrategy="vault-and-select",this.deps=e;const{shopPay:t,installmentsPaymentMethodSelected:a,isApplePayAvailable:s,filteredNegotiatedPaymentMethods:r,isCreditCardDisabled:n,msiEligibilityByCardId:i,hasSellingPlan:o}=e;this.availablePaymentMethods=c(r),this.shopPayAvailableUserStoredPaymentMethods=u(()=>{const e=this.availablePaymentMethods.value;return e.length?je(t.user.paymentMethods.value,e):[]}),this.availableUserStoredPaymentMethods=u(()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(Ua)),this.promotedMethods=u(()=>t.session.promotedPaymentMethods.value.map(Ua)),this.selectedPaymentMethod=u(()=>{const e=t.session.selectedPaymentMethod.value;return e?Ua(e):void 0}),this.selectedCreditCard=u(()=>{const e=t.session.selectedPaymentMethod.value;return e&&Ie(e)?Va(e.paymentAttributes):void 0}),this.shopPayPaymentMethods=u(()=>{const e=t.user.paymentMethods.value,r=this.shopPayAvailableUserStoredPaymentMethods.value,i=this.availablePaymentMethods.value,o=t.session.promotedPaymentMethods.value,d=t.user.paymentMethodHistory.value,l=e.filter(Ie).map(e=>({method:e,isValidForCheckout:r.includes(e),isExpired:e.paymentAttributes.expired,isDisabled:n(e.paymentAttributes)})),c=a?[]:ze({negotiatedPaymentMethods:i,userStoredPaymentMethods:e,paymentMethodHistory:d,isApplePayAvailable:s}),u=[...l.sort((e,t)=>
2Ge(e.method,t.method)),...c.sort((e,t)=>Ge(e.method,t.method))];let m=-1,h="";for(const[t,a]of u.entries()){const e=a.method.lastUsedAt??"";e>h&&(h=e,m=t)}m>0&&u.unshift(...u.splice(m,1));const p=t.session.selectedPaymentMethod.value,y=new Set(o.map(e=>e.id));return u.filter(({method:e})=>!!Ie(e)||!(!p||Ie(p)||e.id!==p.id)||!!y.has(e.id)||Ke(e))}),this.paymentMethods=u(()=>this.shopPayPaymentMethods.value.map(({method:e,...t})=>({...t,method:Ua(e),canEdit:Ie(e),canDelete:Ie(e),canSetDefault:!1,isDefault:!1}))),this.selectedPaymentMethodItem=u(()=>{const e=this.selectedPaymentMethod.value;if(e)return this.paymentMethods.value.find(({method:t})=>t.id===e.id&&t.paymentMethod===e.paymentMethod)}),this.cardPaymentMethods=u(()=>this.paymentMethods.value.filter(e=>ka(e.method))),this.activeOrExpiredCardMethods=u(()=>{const e=this.cardPaymentMethods.value,t=[];for(const s of e)a&&s.isDisabled||t.push(s);return t}),this.disabledCardMethodsForInstallments=u(()=>a?this.cardPaymentMethods.value.filter(e=>e.isDisabled):[]),this.isEveryCardDisabled=u(()=>{const e=this.cardPaymentMethods.value;if(0===e.length)return!1;const t=new Set(this.disabledCardMethodsForInstallments.value.map(e=>e.method.id)),a=e.filter(e=>e.isExpired&&!t.has(e.method.id)).length;return e.length===t.size+a}),this.isEveryCardExpired=u(()=>{const e=this.cardPaymentMethods.value;if(0===e.length)return!1;const t=new Set(this.disabledCardMethodsForInstallments.value.map(e=>e.method.id)),a=e.filter(e=>!t.has(e.method.id));return 0!==a.length&&a.every(e=>e.isExpired)});const d=u(()=>{const e=He(this.availablePaymentMethods.value);if(!U(e))return!1;const t=this.selectedCreditCard.value;return Boolean(t&&i.value[t.id])});this.msi={binResolution:"server",selectedCardBin:u(()=>{}),clearInstallments:xe,expandedVisible:u(()=>!!d.value&&"SHOPIFY_INSTALLMENTS"!==t.session.paymentMethodOption.value?.name),collapsedVisible:u(()=>d.value&&!o.value)}}canShowAsGuestCheckoutMethod(e){const{shopPay:t}=this.deps;return t.visibility.showGuestCheckoutPaymentMethods&&!("wallet"===e.type&&("SHOP_PAY"===e.name||"SHOPIFY_INSTALLMENTS"===e.name))}async selectPaymentMethod(e,t="programmatic",a){const{shopPay:s,updateCheckoutAddress:r,shippingRequired:n}=this.deps;if(!e)return s.session.clearPaymentMethod(),{status:"handled",effects:Fa};const i=Ra(e,s.user.paymentMethods.value);if(!i)return{status:"not-handled"};if("buyer"===t&&this.recordPaymentMethodSelected(e),ka(e)){const t=this.selectCreditCard({id:e.paymentAttributes.id});return Le(i,s.user.paymentMethods.value,Ee(i,this.availablePaymentMethods.value))&&this.#e(i,a),await t,{status:"handled",effects:Fa}}const o=Ee(i,this.availablePaymentMethods.value);return Le(i,s.user.paymentMethods.value,o)&&this.#e(i,"buyer"===t?{...a,buyerInitiated:!0}:a),(De(i)||Ne(i)||Be(i)||Te(i))&&await r({billingAddress:s.session.selectedBillingAddress.value?.address,fallbackPhoneNumber:s.user.phoneNumber.value},n.value),{status:"handled",effects:Fa}}async promoteSelectedPaymentMethod(e){const{shopPay:t}=this.deps,a=Fe(e,t.user.paymentMethods.value);return a&&(t.session.selectPaymentMethod(a),t.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...Fa,selectByBuyerKey:Ve(e)}}}getSavedCardActiveSubscriptionsLookup(e){const t=this.deps.shopPay.user.paymentMethods.value.filter(Ie).map(e=>e.paymentAttributes).find(t=>t.id===e.id);if(!t)return;const a={id:t.id,uuid:t.uuid,first:3},s=m(ga,a),{shopPayGraphql:r}=this.deps;return{key:s,read(){const e=r.read(s);return e?.creditCardActiveSubscriptions?.nodes},async load(){const{data:e}=await r.staticQuery(ga,{variables:a});return e?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:t}=this.deps,a=t.user.paymentMethods.value.filter(Ie).map(e=>e.paymentAttributes).find(t=>t.id===e);if(!a)return;const{updateCheckoutAddress:s,fallbackPhoneNumber:r}=this.deps;t.session.selectPaymentMethod({id:a.id,lastUsedAt:a.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:a}),this.clearShopPayPaymentLines(),await s({billingAddress:a.billingAddress.address,fallbackPhoneNumber:r})}async deleteCreditCard({id:e}){return this.deleteCreditCardById({id:e})}async updateCreditCard({id:e,billingAddress:t,nickname:a}){const{shopPay:s,updateCreditCard:r,checkoutContext:n,markShopCashStatesStale:i,observability:o}=this.deps,d=s.user.paymentMethods.value.filter(Ie).map(e=>e.paymentAttributes).find(t=>
2t.id===e);if(!d)return{status:"failed"};const l=await r(t,e,d.uuid,n,a);if("success"===l.status&&l.creditCard){const{creditCard:t}=l;s.user.updateCreditCard(e,t),this.selectCreditCard({id:t.id}).catch(e=>{o.error(e)})}if(i(),"success"!==l.status){const e=Ue();return na({addressErrors:e,shopPayErrors:l.errors,i18n:this.deps.i18n,observability:o,userEvents:this.deps.userEvents,source:this.deps.source,configuration:this.deps.checkout.configuration,shop:this.deps.shop,addressContext:"payment-method",submittedAddress:t}),{status:"failed",addressErrors:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.value]))}}return{status:"success"}}async addCreditCard({sessionId:e,billingAddress:t,nickname:a,debitOnly:s=!1,isBlocking:r=!1}){const{createCreditCard:n,checkoutContext:i,markShopCashStatesStale:o,observability:d}=this.deps;if(""===e)return d.error(new Oa("ShopPayPaymentMethodManager: addCreditCard called with empty sessionId")),{status:"failed"};const l=await n(t,e,i,a),c=await this.handleNewCardResponse(l,s,r);return o(),c}async completeCreditCardVerificationAndVault({verificationId:e,billingAddress:t,nickname:a,debitOnly:s=!1,isBlocking:r=!1}){const{completeCreditCardVerification:n,markShopCashStatesStale:i}=this.deps,o=await n(t,e,a),d=await this.handleNewCardResponse(o,s,r);return i(),d}dispose(){}async deleteCreditCardById({id:e,uuid:t}){const{shopPay:a,deleteCreditCard:s,updateCheckoutAddress:r,emptyAddress:n,fallbackPhoneNumber:i,checkoutContext:o,markShopCashStatesStale:d}=this.deps,l=t??a.user.paymentMethods.value.filter(Ie).map(e=>e.paymentAttributes).find(t=>t.id===e)?.uuid;if(!l)return{status:"failed"};const c=a.session.selectedPaymentMethod.value,u=c&&Ie(c)?c.paymentAttributes.uuid:void 0,m=await s(e,l,o);if("success"!==m.status&&!function(e){return e.errors?.some(({message:e})=>"credit_card_not_found"===e)??!1}(m))return{status:"failed"};const h=a.user.paymentMethods.value.filter(Ie).map(e=>e.paymentAttributes).filter(e=>e.uuid!==l);if(a.user.removeCreditCard(e),d(),u!==l)return{status:"success"};const p=Re(h);if(p)a.session.selectPaymentMethod({id:p.id,lastUsedAt:p.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:p}),this.clearShopPayPaymentLines();else{const e=this.paymentMethods.value.find(({method:e,isValidForCheckout:t,isDisabled:a,isExpired:s})=>t&&!a&&!s&&function(e){return ka(e)||Boolean(e.lastUsedAt)}(e))?.method;if(e){const t=Ra(e,a.user.paymentMethods.value);t&&this.#e(t)}else a.session.clearPaymentMethod(),this.clearShopPayPaymentLines(),a.session.unstable_updateSelectedBillingAddress(a.session.selectedShippingAddress.value)}const y=p?p.billingAddress.address:a.session.selectedBillingAddress.value?.address;return await r({billingAddress:y??n.value,fallbackPhoneNumber:i}),{status:"success"}}recordPaymentMethodSelected(e){const{observability:t,userEvents:a,source:s,checkout:r,shop:n}=this.deps,i=e.paymentMethod.toLowerCase(),{paymentMethodName:o,paymentBrands:d}=Ta(e,this.availablePaymentMethods.value);t.counter({name:"payment_method_selected",value:1,attributes:{payment_method_type:i,payment_method_name:o,payment_brands:d,location:"shop_pay_payment_selector",is_mobile:Oe()}}),a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...$e(s,r,n),action:"payment_method_selected",paymentMethodName:o}})}async handleNewCardResponse(e,t,a){const{shopPay:s,markShopCashStatesStale:r}=this.deps;if("success"===e.status&&e.creditCard){if(t&&"debit"!==e.creditCard.funding)return await this.deleteCreditCardById({id:e.creditCard.id,uuid:e.creditCard.uuid}),{status:"failed",errors:[{field:["",Ma.DebitOnly],message:""}]};await this.refreshPaymentMethodsFromBuyerDetails()||s.user.addCreditCard(e.creditCard),a?await this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}):this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}).catch(e=>{this.deps.observability.error(e)}),r()}return e}async refreshPaymentMethodsFromBuyerDetails(){const{shopPay:e,refreshBuyerDetails:t,paymentRequiredMethod:a,observability:s}=this.deps;try{const s=await t();return"success"===s.status&&(e.updatePaymentMethodsFromBuyerDetails(s,{negotiatedPaymentMethods:this.availablePaymentMethods.value,paymentRequiredMethod:a}),!0)}catch(r){return s.error(r instanceof Error?r:new $a("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const t=void 0!==Yt(this.deps.proposedPaymentLines.value),a=this.selectCreditCard({id:e});if(t)return a;const{shopPay:s}=this.deps,r=s.session.selectedPaymentMethod.value;r&&Ie(r)&&r.paymentAttributes.id===e&&Le(r,s.user.paymentMethods.value,Ee(r,this.availablePaymentMethods.value))&&this.#e(r),await a}#e(e,t){const{shopPay:a,setPaymentLine:s,observability:r}=this.deps;h(()=>{a.session.selectPaymentMethod(e);const n=Ye({paymentMethod:e,negotiatedPaymentMethods:this.availablePaymentMethods.value,observability:r});void 0!==n&&(t?s(n,void 0,t):s(n))})}clearShopPayPaymentLines(){const{proposedPaymentLines:e}=this.deps;e.value=e.value.filter(e=>!qe([e],"SHOP_PAY"))}}function qa(){const e=ja(),{checkout:{negotiator:t}}=Pe(),{value:a}=t.current.fields.paymentLines,{newCardSignal:s,hasLoadedSignal:r}=t.context,n=s.value,i=r.value,o=a?.lines?.find(e=>"direct"===e.method.type);return e.value&&!i&&o&&(r.value=!0,!n&&o.method.paymentMethodIdentifier&&(s.value=o.method)),s}function ja(){const{checkout:{configuration:e,negotiator:t}}=Pe(),a=e.layout.isOnePage.value,{paymentMethods:r}=t.current.fields;return s(()=>!!a&&Boolean(Qe(r.value).length))}const za={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}"},Ga={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}"},Ka={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}}"};const Ha={id:"0e9fd59cad63a6cd040eec702de445aa95c0d9f613f732e94dce615a476c9d59",type:"mutation",name:"CreditCardUpdate",source:"mutation CreditCardUpdate($billingAddress:AddressInput!,$id:ID!,$uuid:String!,$origin:String!,$nickname:String,$checkoutContext:CheckoutContextInput!){creditCardUpdate(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 Qa(e){const{geolocation:t}=R(),{shopPay:a,checkout:s}=Pe(),r=a.user.phoneNumber.value,n=a.user.addresses.value,i=s.configuration.addressSettings.nonBillingAddressSettings.value,o=n[0]?.address,d=i.defaultShippingDetails.country?.code??t.country.code;return p(()=>tt({firstName:o?.firstName,lastName:o?.lastName,phone:r,countryCode:o?.countryCode||d,zoneCode:o?.zoneCode},{extendedAddressMode:s.address.extendedAddressMode}),[s.address.extendedAddressMode,e,o,d,r])}const Wa={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},Xa={id:"d1f468f7d6684d3133e47cef5cf1ef67ccd2bd916b53203708d85ac3175f1bd0",type:"mutation",name:"UpdateCustomerCreditCard",source:""};
2class Ja extends Error{constructor(e){super("Failed to update customer credit card payment method",e),this.name="UpdateCustomerCreditCardPaymentMethodError"}}class Za extends Error{constructor(e){super("Failed to delete customer credit card payment method",e),this.name="DeleteCustomerCreditCardPaymentMethodError"}}async function es({graphql:e,address:t,extendedAddressMode:a,defaultPaymentMethod:s,token:r,genericError:n}){if(!r)return{token:void 0};try{const{data:i,error:o}=await e.mutate(Xa,{variables:{customerCreditCardModificationInput:{token:r,defaultPaymentMethod:s,billingAddress:{streetAddress:at(t,{extendedAddressMode:a})}}}});if(!i?.modifyCustomerCreditCardPaymentMethod||o)throw new Ja({cause:o});const{result:d,errors:l}=i.modifyCustomerCreditCardPaymentMethod;return l.length||!d?{token:void 0,error:l[0]?.localizedMessage||n}:{token:d.token}}catch{return{token:void 0,error:n}}}async function ts({graphql:e,token:t,genericError:a}){if(!t)return{token:void 0};try{const{data:s,error:r}=await e.mutate(Wa,{variables:{token:t}});if(!s?.deleteCustomerCreditCardPaymentMethod||r)throw new Za({cause:r});const{result:n,errors:i}=s.deleteCustomerCreditCardPaymentMethod;return i.length||!n?{token:void 0,error:i[0]?.localizedMessage||a}:{token:n.token}}catch{return{token:void 0,error:a}}}function as({userEvents:e,shopId:t,checkoutSessionIdentifier:a,card:s}){e.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(et(t),10),checkoutSessionIdentifier:a||"",paymentMethodId:parseInt(et(s.id),10),paymentInstrumentAccessorId:-1}})}class ss extends t{constructor({managerName:e,methodName:t,identity:a,deployStage:s,isLocalDevelopment:r}){super(`${e}.${t} was called unexpectedly`,{groupingHash:`PaymentMethodManagerUnexpectedMethodCall::${e}::${t}`,metadata:{paymentMethodManager:{managerName:e,methodName:t,identity:a,deployStage:s,isLocalDevelopment:r}}}),this.name="UnexpectedPaymentMethodManagerMethodCallError"}}function rs({observability:e,managerName:t,methodName:a,identity:s,deployStage:r,isLocalDevelopment:n}){if(n||"production"!==r&&"canary"!==r)return;const i=new ss({managerName:t,methodName:a,identity:s,deployStage:r,isLocalDevelopment:n});e.error(i,{severity:"warning"})}const ns={status:"failed"};class is{constructor(e){this.disabledCardMethodsForInstallments=c([]),this.isEveryCardDisabled=c(!1),this.canSetCreditCardNickname=c(!1),this.addCreditCardStrategy="direct-session-payment-line",this.deps=e,this.usesCustomerAccountSelectionRule="customerAccount"===e.identity,this.newCard=e.newCard??c(void 0);const{proposal:t}=e,{proposed:a,negotiated:s}=t,{paymentMethods:r}=s.fields,n=s.fields.paymentMethodHistory??c([]);this.availablePaymentMethods=u(()=>r.value??[]),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=u(()=>it(this.availablePaymentMethods.value)),this.selectableCustomerCreditCards=u(()=>Qe(this.availablePaymentMethods.value)),this.selectablePaypalBillingAgreements=u(()=>(e.displayablePaymentMethods?.value??this.availablePaymentMethods.value).filter(e=>e.type===ot.PayPal)),this.selectableCustomerBanks=u(()=>this.availablePaymentMethods.value.filter(e=>"bank"===e.type&&e.availableInstruments.length>0)),this.nonCardKnownPaymentMethods=u(()=>dt({paymentMethodHistory:n.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value})),this.availableUserStoredPaymentMethods=u(()=>[...ds([os({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map(e=>lt(e,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})),...this.selectablePaypalBillingAgreements.value.map(ct),...ms(this.selectableCustomerBanks.value.map(ut),this.nonCardKnownPaymentMethods.value,this.promotedMethods.value)]),this.autoselectTarget=u(()=>{const e=this.selectableCustomerCreditCards.value.find(e=>e.defaultPaymentMethod),t=e?this.availableUserStoredPaymentMethods.value.find(t=>t.id===e.token):void 0,a=this.availableUserStoredPaymentMethods.value.reduce((e,t)=>t.lastUsedAt?e?.lastUsedAt?t.lastUsedAt>e.lastUsedAt?t:e:t:e,void 0);if(this.usesCustomerAccountSelectionRule){const e=!a||ka(a);if(this.deps.storeVaultEnabled&&e&&t)return t}else if(e)return t;if(a)return a;const s=this.selectableCustomerCreditCards.value[0];if(s)return this.availableUserStoredPaymentMethods.value.find(e=>e.id===s.token);return this.availableUserStoredPaymentMethods.value.find(e=>!ka(e)&&!Na(e))||this.availableUserStoredPaymentMethods.value.find(Na)}),this.proposedSelectedPaymentMethod=u(()=>function(e,t,a,s){const r=e.some(e=>"deferred"!==e.method.type&&"giftCard"!==e.method.type&&"redeemable"!==e.method.type);for(const n of e){if("direct"===n.method.type&&s)return s;if("deferred"===n.method.type){if(r)continue;const e=t.find(Na);if(e)return e;continue}if(ls(n)){const e=t.filter(ka).find(e=>e.id===n.method.token);if(e)return e;continue}if(cs(n)){const e=t.find(e=>"PAYPAL"===e.paymentMethod&&"billing_agreement"===e.variant&&e.vaultedToken===n.method.token);if(e)return e;continue}const e=us(n,t,a);if(e)return e}}(a.paymentLines.value,this.availableUserStoredPaymentMethods.value,this.availablePaymentMethods.value,os({card:this.newCard.value,billingAddress:a.billingAddress.value}))),this.selectedPaymentMethod=u(()=>this.proposedSelectedPaymentMethod.value??this.autoselectTarget.value),this.paymentMethods=u(()=>function({cardItems:e,nonCardItems:t,autoselectTarget:a}){const s=e.find(({method:e})=>e.id===rt),r=[...e.filter(({method:e})=>e.id!==rt)].sort((e,t)=>
2Ge(e.method,t.method)),n=[...t].sort((e,t)=>Ge(e.method,t.method)),i=r.filter(hs),o=n.filter(hs),d=i.find(({method:e})=>ka(e)&&e.paymentAttributes.defaultPaymentMethod),l=[i[0],o[0]].filter(e=>void 0!==e).sort((e,t)=>Ge(e.method,t.method))[0],c=(a?[...i,...o].find(({method:e})=>e.id===a.id&&e.paymentMethod===a.paymentMethod):void 0)??d??l;return c?[...ds([s]),c,...r.filter(e=>e!==c),...n.filter(e=>e!==c)]:[...ds([s]),...r,...n]}({cardItems:[...ds([os({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.customerCreditCards.value.map(e=>lt(e,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled}))].map(e=>({method:e,isValidForCheckout:!0,isExpired:e.paymentAttributes.expired,isDisabled:!1,...ps({identity:this.deps.identity,storeVaultEnabled:this.deps.storeVaultEnabled,card:e})})),nonCardItems:this.availableUserStoredPaymentMethods.value.filter(e=>!ka(e)).map(e=>({method:e,isValidForCheckout:!0,isExpired:!1,isDisabled:!1,canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1})),autoselectTarget:this.usesCustomerAccountSelectionRule?this.autoselectTarget.value:void 0})),this.selectedPaymentMethodItem=u(()=>{const e=this.selectedPaymentMethod.value;if(e)return this.paymentMethods.value.find(({method:t})=>t.id===e.id&&t.paymentMethod===e.paymentMethod)}),this.selectedCreditCard=u(()=>{const e=this.selectedPaymentMethod.value;return ka(e)?e.paymentAttributes:void 0}),this.cardPaymentMethods=u(()=>this.paymentMethods.value.filter(e=>ka(e.method))),this.activeOrExpiredCardMethods=this.cardPaymentMethods,this.isEveryCardExpired=u(()=>{const e=this.cardPaymentMethods.value;return e.length>0&&e.every(e=>e.isExpired)});const i=u(()=>{const e=He(this.availablePaymentMethods.value);if(!U(e))return!1;const t=this.selectedCreditCard.value;return!!t&&a.paymentLines.value.some(e=>t.id===rt?"direct"===e.method.type:e.method.type===ot.CreditCard&&e.method.token===t.id)});this.msi={binResolution:"client",selectedCardBin:u(()=>{const e=this.selectedCreditCard.value;if(e)return e.id===rt?this.newCard.value?.creditCardFirstDigits:this.selectableCustomerCreditCards.value.find(t=>t.token===e.id)?.firstDigits}),clearInstallments:O,expandedVisible:i,collapsedVisible:i}}async promoteSelectedPaymentMethod(e){const t=st(e,null);return t?(this.deps.paymentMethodPromotions.promote(t),this.selectPaymentMethod(t,"buyer")):{status:"handled",effects:{...Fa,selectByBuyerKey:Ve(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,t="programmatic"){if(!e)return{status:"not-handled"};if(!ka(e)){const a=Ee(e,this.availablePaymentMethods.value);if(!a)return{status:"not-handled"};const s=Ve(a);return"buyer"===t?{status:"handled",effects:{...Fa,selectByBuyerKey:s}}:(this.deps.setPaymentLine(s),{status:"handled",effects:Fa})}if("buyer"===t)return this.selectCreditCardByBuyer({paymentMethod:e});if(e.id===rt)return this.deps.setPaymentLine(rt),{status:"handled",effects:Fa};const a=this.selectableCustomerCreditCards.value.find(t=>t.token===e.paymentAttributes.id);return a?(this.deps.setPaymentLine(nt(a)),{status:"handled",effects:Fa}):{status:"not-handled"}}async deleteCreditCard({id:e}){if(e===rt){const{proposed:e}=this.deps.proposal;if(!this.newCard.value)return{status:"failed"};this.newCard.value=void 0,e.acceptPaymentVaulting.value=!1;const t=this.selectableCustomerCreditCards.value[0];if(t)this.deps.setPaymentLine(nt(t));else{const t=this.autoselectTarget.value,a=t?Ee(t,this.availablePaymentMethods.value):void 0;a?this.deps.setPaymentLine(Ve(a)):e.paymentLines.value=e.paymentLines.value.filter(e=>"direct"!==e.method.type)}return{status:"success",shouldResetSuggestedBillingAddress:Boolean(t),shouldResetBillingAddressToShipping:"businessCustomer"!==this.deps.identity}}const t=this.selectedPaymentMethod.value,a=ka(t)&&t.id===e,s=this.selectableCustomerCreditCards.value.find(t=>t.token!==e),r=await ts({graphql:this.deps.graphql,token:e,genericError:this.deps.i18n.translate("customer_payment_methods.delete_customer_mandate.generic_error")});return r.token?(a&&s&&this.deps.setPaymentLine(nt(s)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:r.error}}async updateCreditCard({id:e,billingAddress:t,defaultPaymentMethod:a=!1}){const s=await es({graphql:this.deps.graphql,token:e,address:t,extendedAddressMode:this.deps.extendedAddressMode,defaultPaymentMethod:a,genericError:this.deps.i18n.translate("shipping.address_form.generic_error")});return s.token?{status:"success",shouldNegotiatePaymentMethods:!0}:{status:"failed",bannerError:s.error}}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),ns}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),ns}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let t,a,s;if(e.id===rt){const e=this.newCard.value;if(!e)return{status:"not-handled"};t=rt,a=e,s=e.creditCardFirstDigits}else{const a=this.selectableCustomerCreditCards.value.find(t=>t.token===e.paymentAttributes.id);if(!a)return{status:"not-handled"};t=nt(a),s=a.firstDigits,as({userEvents:this.deps.userEvents,shopId:this.deps.shopI
2d,checkoutSessionIdentifier:this.deps.checkoutSessionIdentifier,card:a})}return this.deps.isMsiAvailable&&(this.deps.proposal.proposed.paymentLines.value=O(this.deps.proposal.proposed.paymentLines.value)),{status:"handled",effects:{...Fa,selectByBuyerKey:t,...a?{selectByBuyerPaymentMethod:a}:{},updateSelectedCardBin:!0,selectedCardFirstDigits:s,preserveExistingBinPrefix:e.id===rt,claimMsiBin:this.deps.isMsiAvailable,claimedMsiBin:this.deps.isMsiAvailable?s:void 0,shouldNegotiate:!0}}}reportUnexpectedUse(e){rs({...this.deps,managerName:"CustomerPaymentMethodManager",methodName:e})}}function os({card:e,billingAddress:t}){if(e?.brand&&e.creditCardLastFourDigits)return{id:rt,paymentMethod:"CREDIT_CARD",paymentAttributes:{id:rt,brand:e.brand,expired:!1,expiryMonth:0,expiryYear:0,lastDigits:e.creditCardLastFourDigits,name:e.cardholderName,billingAddress:{address:t??{}}},lastUsedAt:null}}function ds(e){return e.filter(e=>void 0!==e)}function ls(e){return e.method.type===ot.CreditCard}function cs(e){return e.method.type===ot.PayPal}function us(e,t,a){const s=Ve(e.method);return t.find(e=>{if(ka(e))return!1;const t=Ee(e,a);return!!t&&s===Ve(t)})}function ms(...e){const t=[],a=new Set;for(const s of e)for(const e of s){const s=`${e.paymentMethod}:${e.id}`;a.has(s)||(a.add(s),t.push(e))}return t}function hs(e){return e.isValidForCheckout&&!e.isExpired&&!e.isDisabled}function ps({identity:e,storeVaultEnabled:t,card:a}){if(a.id===rt)return fs;if("businessCustomer"===e)return ys;const{paymentAttributes:s}=a;return t?s.expired?s.deletable?{canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:Boolean(s.defaultPaymentMethod)}:ys:{canEdit:!0,canDelete:Boolean(s.deletable),canSetDefault:!0,isDefault:Boolean(s.defaultPaymentMethod)}:ys}const ys={canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1},fs={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},vs={status:"failed"};class bs{constructor(e){this.availablePaymentMethods=c([]),this.availableUserStoredPaymentMethods=c([]),this.paymentMethods=c([]),this.selectedPaymentMethod=c(void 0),this.selectedPaymentMethodItem=c(void 0),this.selectedCreditCard=c(void 0),this.activeOrExpiredCardMethods=c([]),this.disabledCardMethodsForInstallments=c([]),this.isEveryCardDisabled=c(!1),this.isEveryCardExpired=c(!1),this.cardPaymentMethods=c([]),this.promotedMethods=c([]),this.msi={binResolution:"client",selectedCardBin:c(void 0),clearInstallments:e=>e,expandedVisible:c(!1),collapsedVisible:c(!1)},this.newCard=c(void 0),this.canSetCreditCardNickname=c(!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"),vs}async updateCreditCard(){return this.reportUnexpectedUse("updateCreditCard"),vs}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),vs}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),vs}dispose(){}reportUnexpectedUse(e){rs({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function Cs({enableAutoSelect:e=!0}={}){const{source:t,environment:a,checkout:s,shop:r,i18n:n,observability:i,userEvents:o,shopPay:d,graphql:{coreGraphql:c,shopPayGraphql:u}}=Pe(),m=s.identity.current.value,h=r.hasFlagEnabled(mt),v=r.hasFlagEnabled(ht),b=null!=a.devMode,C=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=We({source:a});return l(async(a,r,n,i,o=s)=>{const{data:d,error:l}=await t.mutate(za,{variables:{billingAddress:Xe(a,e),origin:o,sessionId:r,nickname:i,checkoutContext:n}});if(l||null==d||null==d.creditCardCreate)return{status:"failed"};const{creditCardCreate:c}=d;return Je(c.userErrors)?{status:"blocked_by_autopay"}:c.userErrors.length>0?{status:"failed",errors:c.userErrors}:c.threeDSecureAuthenticationRequest?{status:"requires_redirect",threeDSecureAuthenticationRequest:c.threeDSecureAuthenticationRequest}
2:{status:"success",creditCard:c.creditCard?Ze(c.creditCard):void 0}},[s,e,t])}(),g=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=We({source:a});return l(async(a,r,n,i=s)=>{const{data:o,error:d}=await t.mutate(Ga,{variables:{verificationId:r,billingAddress:Xe(a,e),origin:i,nickname:n}});if(d||null==o||null==o.creditCardCompleteVerificationAndVault)return{status:"failed"};const{creditCardCompleteVerificationAndVault:l}=o;return Je(l.userErrors)?{status:"blocked_by_autopay"}:l.userErrors.length>0?{status:"failed",errors:l.userErrors}:{status:"success",creditCard:l.creditCard?Ze(l.creditCard):void 0}},[s,e,t])}(),_=function(){const{graphql:{shopPayGraphql:e},source:t}=Pe(),a=We({source:t});return l(async(t,s,r,n=a)=>{const{data:i,error:o}=await e.mutate(Ka,{variables:{id:t,uuid:s,origin:n,checkoutContext:r}});if(o||null==i||null==i.creditCardDelete)return{status:"failed"};const{creditCardDelete:d}=i;return d.userErrors.length>0?{status:"failed",errors:d.userErrors}:{status:"success"}},[a,e])}(),M=function(){const{graphql:{shopPayGraphql:e},source:t,shop:{myshopifyDomain:a,id:s},shopPay:{config:r}}=Pe(),{checkoutSessionIdentifier:n}=t,i=We({source:t}),{redirectSource:o}=r;return l(async()=>{const{data:t,error:r}=await function(e,{checkoutVersion:t,checkoutIdentifier:a,shopifyDomain:s,shopId:r,redirectSource:n},{cache:i=!0}={}){return e.staticQuery(Zt,{variables:{checkoutContextInput:{checkoutVersion:t,checkoutIdentifier:a,shopifyDomain:s,shopId:r},shopifyDomain:s,redirectSource:n??void 0},cache:i})}(e,{checkoutVersion:i,checkoutIdentifier:n??"unknown",shopifyDomain:a,shopId:et(s),redirectSource:o},{cache:!1});return r||null==t||null==t.checkoutSession||null==t.checkoutSession.user?{status:"failed"}:ea(t)},[n,i,o,s,a,e])}(),P=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=We({source:a});return l(async(a,r,n,i,o,d=s)=>{const{data:l,error:c}=await t.mutate(Ha,{variables:{id:r,uuid:n,billingAddress:Xe(a,e),origin:d,nickname:o,checkoutContext:i}});
2if(c||!l?.creditCardUpdate)return{status:"failed"};const{creditCardUpdate:u}=l;return u.userErrors.length>0?{status:"failed",errors:u.userErrors}:{status:"success",creditCard:u.creditCard?Ze(u.creditCard):void 0}},[s,e,t])}(),S=We({source:t}),k=Qa(),{paymentLines:A}=s.negotiator.parts,E=qa(),{buyerHasActedSignal:w,newCardSignal:I}=s.negotiator.context,x=y(Xt),L=d.user.phoneNumber.value,D=Kt(),N=d.session.isInstallmentsSelected.value,B=Ht({isApplePayAvailable:D.value}),T=pt(),{creditCardDisabled:F}=ta(),V=Jt(),{updateCheckoutAddress:R}=Qt(),[,O]=Wt({allowPreselect:!1}),$=He(s.negotiator.current.fields.paymentMethods.value??[]),Y=U($),q=yt(),{eligibilityByCardId:j}=ft(sa),z=l(()=>{x&&(x.cashbackState.stale.value=!0)},[x]),G=p(()=>({checkoutIdentifier:t.checkoutSessionIdentifier??"",checkoutVersion:S,shopId:et(r.id),shopifyDomain:r.myshopifyDomain}),[t.checkoutSessionIdentifier,r.id,r.myshopifyDomain,S]),K=p(()=>"shopPay"===m?new Ya({shopPay:d,negotiatedPaymentMethods:s.negotiator.current.fields.paymentMethods,installmentsPaymentMethodSelected:N,isApplePayAvailable:D.value,filteredNegotiatedPaymentMethods:B.value,isCreditCardDisabled:F,setPaymentLine:O,updateCheckoutAddress:R,shippingRequired:s.isShippingRequired,i18n:n,observability:i,userEvents:o,source:t,checkout:s,shop:r,createCreditCard:C,deleteCreditCard:_,updateCreditCard:P,completeCreditCardVerification:g,refreshBuyerDetails:M,markShopCashStatesStale:z,shopPayGraphql:u,emptyAddress:k,proposedPaymentLines:A,checkoutContext:G,fallbackPhoneNumber:L,paymentRequiredMethod:V.value,msiEligibilityByCardId:j,hasSellingPlan:q}):"customerAccount"===m||"businessCustomer"===m?new is({proposal:s.proposal,newCard:E,displayablePaymentMethods:T,paymentMethodPromotions:s.paymentMethodPromotions,setPaymentLine:O,isMsiAvailable:Y,shopId:r.id,checkoutSessionIdentifier:t.checkoutSessionIdentifier,storeVaultEnabled:r.storeVaultEnabled,storeVaultGuestCvvVerificationEnabled:r.storeVaultGuestCvvVerificationEnabled,graphql:c,extendedAddressMode:s.address.extendedAddressMode,i18n:n,observability:i,userEvents:o,identity:m,deployStage:a.deployStage,isLocalDevelopment:b}):new bs({observability:i,identity:m,deployStage:a.deployStage,isLocalDevelopment:b}),[m,a.deployStage,b,d,N,D.value,B.value,T,F,Y,O,R,s,i,o,t,r,n,c,u,C,_,M,P,g,z,k,A,E,G,L,V.value,j,q]);f(()=>()=>K.dispose(),[K]);const H=K.selectedPaymentMethod.value,Q=K.paymentMethods.value,W=K.availablePaymentMethods.value,X=K.availableUserStoredPaymentMethods.value,J=A.value.some(e=>"direct"===e.method.type);f(()=>{if(!e)return;if("shopPay"!==m)return;if(K.selectedPaymentMethod.peek()!==H||K.paymentMethods.peek()!==Q)return;if(H&&function({selected:e,paymentMethods:t,availablePaymentMethods:a}){return Boolean(Ee(e,a)||ka(e)&&t.some(({method:t})=>t.paymentMethod===e.paymentMethod&&t.id===e.id))}({selected:H,paymentMethods:Q,availablePaymentMethods:W}))return;if(J)return;const a=Q.filter(({isValidForCheckout:e})=>e).sort((e,t)=>Ge(e.method,t.method)).map(({method:e})=>e),n=function(e){for(const t of e){if(!ka(t))return t;if(!t.paymentAttributes.expired)return t}return e[0]}(a);n&&ka(n)&&n.paymentAttributes.expired&&o.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...$e(t,s,r),action:"final_payment_method_expired_after_merchant_filter"}});const l=n?Ra(n,d.user.paymentMethods.value):void 0;if(l)d.session.selectPaymentMethod(l);else{const e=h?"unavailable":"explicit",s=d.session.clearPaymentMethod(e),r=d.user.creditCards.peek().length;s&&r>0&&(i.log("shop_pay_payment_method_auto_cleared","[usePaymentMethodManager] No listed payment method was valid for checkout, so the Shop Pay selection was cleared",{checkout_session_identifier:t.checkoutSessionIdentifier,source_type:t.type,clear_reason:e,held_card_count:r,listed_method_count:Q.length,valid_for_checkout_count:a.length,negotiated_direct_present:Boolean($)}),v&&i.counter({name:"shop_pay_payment_method_auto_cleared",value:1,attributes:{source_type:t.type,clear_reason:e,negotiated_direct_present:Boolean($)}}))}},[e,W,X,s,m,$,i,o,K,Q,h,v,H,r,d.session,d.user.creditCards,d.user.paymentMethods.value,t,J]);const Z=w.value,ee=Boolean(I.value),te=K instanceof is?K.autoselectTarget.value:void 0,ae=K instanceof is?K.proposedSelectedPaymentMethod.value:void 0,se=A.value[0],re=se?.method.type,ne=aa(se);return f(()=>{e&&("customerAccount"!==m&&"businessCustomer"!==m||Z||K instanceof is&&te&&(ee||ne||ae&&ae.paymentMethod===te.paymentMethod&&ae.id===te.id||(re&&i.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodT
2ype:re,replacingPaymentMethodType:te.paymentMethod}),K.selectPaymentMethod(te,"programmatic").catch(()=>{}))))},[e,m,Z,ee,K,te,ae,ne,re,i]),K}function gs(){const{shop:e,checkout:t,observability:a}=Pe(),s=t.wallets.activeSession.value,r=t.latestReceipt.value,{persistedPayPalSignal:n}=Se(),i="payPal"===t.identity.current.value,o=r?.id,d=$().value,l=void 0!==d,c=vt(),u=n.value,{negotiate:m}=Y(),h=q(),p=E(new Set(bt))?.hasError&&o!==u?.receiptIdForClearedToken,y=j("PAYPAL_EXPRESS").value?.merchantId?.trim(),v=d?.method.walletContent?.merchantId?.trim(),b=e.hasFlagEnabled(Ct)&&y&&v&&v!==y,C=u?.billingAgreementStatus&&gt({checkout:t})&&"NOTREQUESTED"===u.billingAgreementStatus&&!d?.method.walletContent?.isVaultWithPurchaseOrder,g=!0===d?.method.walletContent?.isVaultWithPurchaseOrder&&0===c.value?.amount;f(()=>{l&&((p||b||C||g)&&(function(){let e;e=p?"SubmitForCompletion Error":b?"Gateway Mismatch":g?"Zero Payment Due":"Subscription Added",a.counter({name:"paypal_token_cleared",value:1,attributes:{clearReason:e}}),a.log("paypal_token_cleared","Clearing PayPal token due to error",{clearReason:e})}(),function(){const e={...n.value,receiptIdForClearedToken:p?o:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};n.value=e}()),(async()=>{(g||p&&!i&&!s)&&(h(),await m({silenceViolations:["non-stock"]}))})())},[p,l,b,o,a,n,C,g,i,h,m,s])}function _s(e){const{checkout:{negotiator:t}}=Pe(),a=t.current.fields.paymentMethods;return s(()=>{const t=e.value,s=Boolean(t?.balance?.amount),r=Boolean(a.value?.find(e=>"redeemable"===e.type&&"STORE_CREDIT"===e.redemptionSource));return Boolean(s&&r)})}var Ms=(e=>(e.Init="init",e.Loading="loading",e.Success="success",e.Error="error",e.Stale="stale",e))(Ms||{});function Ps(e,t){return e.filter(e=>!As(e,t))}function Ss(e,t){return e.some(e=>As(e,t))}function ks({firstOrderTotal:e,storeCreditAccount:t,includeExhausted:a=!1}){if(!e||!t)return;if(e.currencyCode!==t.balance.currencyCode)return;const s=t.balance.amount-e.amount;return s<=0&&!a?void 0:{amount:Math.max(s,0),currencyCode:t.balance.currencyCode}}function As(e,t){return _t(e)&&e.method.redemptionContent&&"storeCreditAccountId"in e.method.redemptionContent&&e.method.redemptionContent.storeCreditAccountId===t.id}function Es(e){const{checkout:{negotiator:t}}=Pe(),a=t.current.fields.paymentLines;return s(()=>{const t=e.value;return!(!t||!a.value?.lines)&&Ss(a.value.lines,t)})}function ws(){const{shop:{currencyCode:e},checkout:{negotiator:t}}=Pe(),{buyerIdentity:a}=t.current.fields;return s(()=>{const t=a.value,s=t?.presentmentCurrency||e;return("CustomerProfile"===t?.customerProfile?.__typename||"BusinessCustomerProfile"===t?.customerProfile?.__typename?t.customerProfile.storeCreditAccounts:[]).find(e=>e.balance.currencyCode===s)})}function Is(){const{checkout:{negotiator:e}}=Pe(),t=e.current.fields.paymentLines;return s(()=>t.value?.lines.filter(e=>_t(e))||[])}function xs({options:e,paymentMethodExtension:t}){const a=t[0]?.extension;if(!a)return null;const s=a.appId.split("/").pop(),n=s&&!Mt.includes(s);return r(z,{options:e,customizations:t,transformComponents:n?Ls:void 0})}const Ls=G(new Set(["Image","Banner","s-image","s-banner"]));function Ds(){const{checkout:{negotiator:e}}=Pe(),t=e.current.fields.allViolations,a=s(()=>(t.value??[]).filter(e=>!!K(e)||!!Pt(e))),i=s(()=>{const[e]=a.value;return e?e.localizedMessage||e.nonLocalizedMessage:null});return r(n,{when:i,children:e=>r(H,{tone:"critical",errorType:Q.DiscountError,children:e})})}function Ns({amount:e,maskedIdentifier:t,remove:a}){const{i18n:s}=Pe(),n=s.formatCurrency(e.amount,{currency:e.currencyCode,form:"short"}),i=t.slice(-4).toUpperCase(),o=s.translate("payment.gift_card_wrapper.gift_card_label",{identifier:W(i)}),d=s.translate("order_summary.gift_card_ending",{last_characters:i||""});return r(te,{borderRadius:"base",background:"base",border:"base",blockAlignment:"center",padding:"small-200",children:r(X,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",children:[r(X,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[r(qt,{type:"gift-card"}),r(J,{children:[r(Z,{accessibilityVisibility:"hidden",children:o}),r(Z,{accessibilityVisibility:"exclusive",children:d})]})]}),r(X,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-100",alignItems:"center",alignContent:"center",children:[r(Z,{type:"strong",children:n}),r(ee,{onClick:()=>a(),accessibilityLabel:s.translate("general.remove_item",{label:d}),children:r(D,{type:"x",size:"small"})})]})]})})}const Bs="gift_card_option";function Ts({afterAppliedRedeemablesChange:e,autoSelect:t=!1,showHeading:a=!0}){const{i18n:s}=Pe(),{paymentMethod:n,paymentLines:i,submit:o,remove:c,removeAll:u}=ae(),m=se("Checkout::GiftCard::Render",n?.uiExtension?[n?.uiExtension]:[]),{value:h}=vt(),y=h?.amount||0,[v,b]=d([]),[C,g]=d(!1),_=0===y&&0===i?.length;f(()=>{_?b([]):(i?.length>0||t)&&b([Bs])},[t,i?.length,_]);const M=l(async(t,a)=>{const s=await o(t,a);return"success"===s?.status&&(g(!1),e?.()),s},[e,o]),P=p(()=>({paymentMethodIdentifier:n?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:M}),[n?.paymentMethodIdentifier,M]),S=Boolean(i?.length)||Boolean(m.length)&&Boolean(n);return r(ie,{id:"3p-gift-card-field",open:S,duration:"slow",children:r(re,{accessibilityLabel:s.translate("payment.gift_card_wrapper.heading"),children:r(B,{gap:"base",children:[a&&r(ne,{level:2,children:s.translate("payment.gift_card_wrapper.heading")}),r(ia,{name:"gift_card_option_list",values:v,multiple:!0,onChange:async t=>{if(b(t),0===t.length&&i.length>0){const t=await u();"success"===t?.status&&e?.()}},variant:"block",children:r(oa,{value:Bs,disabled:_,selectedContent:r(B,{gap:"base",children:[i?.length>0?r(B,{gap:"small-300",children:i.map(t=>{const{cost:a,method:s}=t;if(!a||"CUSTOM"!==s.redemptionSource)return null;const n=s.redemptionContent?.redemptionAttributes.reduce((e,t)=>
2`${e},${t.key}:${t.value}`,"");return r(Ns,{maskedIdentifier:s.redemptionContent?.maskedIdentifier||"",amount:{amount:a.amount,currencyCode:a.currencyCode},remove:async()=>{const t=await c(s);"success"===t?.status&&e?.()}},n)})}):null,r(Ds,{}),(()=>{if(0===y||!m.length||!n)return null;const e=r(xs,{paymentMethodExtension:m,options:P});return i&&0!==i.length?r(te,C?{children:[r(N,{blockSize:"small-500"}),r(B,{gap:"base",children:[r(ne,{level:3,children:s.translate("payment.gift_card_wrapper.apply_another_gift_card_label")}),e]})]}:{children:[r(N,{blockSize:"small-500"}),r(w,{textDecoration:"none",onClick:()=>g(!0),children:r(B,{direction:"inline",alignItems:"center",gap:"small-400",children:[r(D,{type:"plus"}),r(Z,{children:s.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]}):e})()]}),children:s.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const Fs="StoreCreditRedemptionCheckbox",Vs="StoreCreditSubscriptionRenewalsCheckbox";function Us(e,t){return _t(e)&&e.method.redemptionContent&&"storeCreditAccountId"in e.method.redemptionContent&&e.method.redemptionContent.storeCreditAccountId===t.id}function Rs({amountDueAtCheckout:e,storeCreditAccount:t}){if(Os({amountDueAtCheckout:e,storeCreditAccount:t})&&null!=e)return{amount:Math.min(e.amount,t.balance.amount),currencyCode:e.currencyCode}}function Os({amountDueAtCheckout:e,storeCreditAccount:t}){return null==e||e.currencyCode===t.balance.currencyCode}function $s({paymentLines:e,storeCreditAccount:t,cost:a}){let s=!1;const r=e.map(e=>{if(!Us(e,t))return e;if(null==a){if(null==e.cost)return e;const{cost:t,...a}=e;return s=!0,a}return e.cost?.amount===a.amount&&e.cost.currencyCode===a.currencyCode?e:(s=!0,{...e,cost:a})});return s?r:e}function Ys(e,t,a){if("success"!==e.status&&"error"!==e.status)return!1;const s=e.negotiated?.paymentLines?.lines;return null==s?"success"===e.status:Ss(s,t)===a}function qs(e){const{negotiate:t}=Y();return l(async()=>new Promise(a=>{t({fieldsToResolve:["paymentLines"],silenceViolations:["non-store-credit",...wt(["paymentLines"])],runListenersOnError:!0,force:!0,onComplete(t){e.value="success"===t.status?Ms.Success:Ms.Error,a(t)}})}),[t,e])}function js(e,t){const{checkout:{negotiator:a}}=Pe(),s=qs(t);return l(async()=>{if(!e)return t.value=Ms.Error,{result:null,landed:!1};t.value=Ms.Loading;const r=a.parts.paymentLines.value,n=r.findIndex(t=>Us(t,e)),i=r[n];a.parts.paymentLines.value=Ps(r,e);const o=await s(),d=Ys(o,e,!1);if(i&&!d){const t=Ps(a.parts.paymentLines.value,e);a.parts.paymentLines.value=[...t.slice(0,n),i,...t.slice(n)]}return{result:o,landed:d}},[e,t,a.parts.paymentLines,s])}function zs(e,t){const{i18n:a,shop:s,checkout:{negotiator:r}}=Pe(),n=qs(t),i=r.current.fields.paymentLines,o=vt(),d=St(),c=yt(),u=kt(),m=r.current.fields.paymentFlexibilityPaymentTermsTemplate,h=At(s),p=r.current.fields.isImmediateAmountReducedForRedeemables,y=l(()=>h&&Et({hasSellingPlan:c.value,hasFixedSellingPlan:u.value,paymentTermsTemplateType:m.value?.type}),[h,c,u,m]),f=v(!1);return b(()=>{if(!y())return;const t=o.value??d.value,a=r.parts.paymentLines.value;if(!e||!f.current)return;const s=i.value?.lines.find(t=>Us(t,e))?.cost;if(p?.value){if(s){const t=$s({paymentLines:a,storeCreditAccount:e,cost:s});t!==a&&(r.parts.paymentLines.value=t)}return}if(s&&s.amount>0)return void(f.current=!1);const n=$s({paymentLines:a,storeCreditAccount:e,cost:Rs({amountDueAtCheckout:t,storeCreditAccount:e})});n!==a&&(r.parts.paymentLines.value=n)}),l(async()=>{if(!e)return t.value=Ms.Error,{result:null,landed:!1};t.value=Ms.Loading;const s=Ps(r.parts.paymentLines.value,e),i=o.value??d.value,l=y(),c=l?Rs({amountDueAtCheckout:i,storeCreditAccount:e}):void 0;if(f.current=null!=c,l&&!Os({amountDueAtCheckout:i,storeCreditAccount:e}))return t.value=Ms.Error,oe({content:a.translate("store_credit_errors.generic_error")}),{result:null,landed:!1};r.parts.paymentLines.value=[...s,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:e.id}},...c&&{cost:c}}];const u=await n();if(!Ys(u,e,!0))return f.current=!1,r.parts.paymentLines.value=Ps(r.parts.paymentLines.value,e),{result:u,landed:!1};const m=l&&function(e,t){if("success"===e.status||"error"===e.status)return e.negotiated?.paymentLines?.lines.find(e=>Us(e,t))?.cost}(u,e);return m&&m.amount>0&&(f.current=!1,r.parts.paymentLines.value=function({paymentLines:e,storeCreditAccount:t,cost:a}){return e.map(e=>Us(e,t)?{...e,cost:a}:e)}({paymentLines:r.parts.paymentLines.value,storeCreditAccount:e,cost:m})),{result:u,landed:!0}},[d,n,o,r.parts.paymentLines,t,y,e,a])}function Gs({afterAppliedRedeemablesChange:e}){const{i18n:t,shop:a,webMcp:i,checkout:{negotiator:o}}=Pe(),d=a.hasFlagEnabled(It),c=vt(),u=Lt(),m=kt(),h=ws(),p=Es(h),y=C(Ms.Init),v=_s(h),_=function(e){const{shop:t}=Pe(),a=t.hasFlagEnabled(It),r=St(),n=xt();return s(()=>
2{if(n.value)return ks({firstOrderTotal:r.value,storeCreditAccount:e.value,includeExhausted:a})})}(h),M=s(()=>d&&null!=_.value),P=s(()=>u.value||m.value),S=s(()=>u.value?t.translate("payment.store_credit.buying_gift_card"):m.value?t.translate("payment.store_credit.no_fixed_selling_plans"):void 0);b(()=>{(!v.value||!M.value||P.value)&&g(()=>{o.parts.useStoreCreditForSubscriptionRenewals.value&&(o.parts.useStoreCreditForSubscriptionRenewals.value=!1)})});const k=zs(h.value,y),A=js(h.value,y),E=s(()=>y.value===Ms.Loading),w=s(()=>E.value||P.value),I=s(()=>w.value||0===c.value?.amount&&!p.value),x=w,L=s(()=>{const e=[],t=M.value&&o.parts.useStoreCreditForSubscriptionRenewals.value;return(p.value||t)&&e.push(Fs),t&&e.push(Vs),e}),D=l(async t=>{const a=p.peek(),s=t.includes(Fs),r=d&&!(a&&!s)&&t.includes(Vs),n=s||r,i=o.parts.useStoreCreditForSubscriptionRenewals.peek();if(o.parts.useStoreCreditForSubscriptionRenewals.value=r,n!==a){const{landed:t}=n?await k():await A();if(!t)return void(o.parts.useStoreCreditForSubscriptionRenewals.value=!n&&i);e?.()}},[k,A,p,o.parts.useStoreCreditForSubscriptionRenewals,d,e]),N=s(()=>v.value&&Boolean(h.value)),T=s(()=>L.value.includes(Fs)),F=l(e=>D(e?[...new Set([...L.peek(),Fs])]:[]),[L,D]);f(()=>i?.unstable_provideStoreCreditController({available:N,redeeming:T,applied:p,settling:E,hasGiftCard:u,hasFixedSellingPlan:m,paymentDue:c,setRedeeming:F}),[i,N,T,p,E,u,m,c,F]);const V=h.value;if(!N.value||!V)return null;const U=M.value?_.value:void 0,R=V.balance,O=S.value,$=U&&U.amount>0?t.translate("payment.store_credit.remaining_for_subscription_charges_description",{amount:t.formatCurrency(U.amount,{currency:U.currencyCode})}):void 0;return r(re,{accessibilityLabel:t.translate("payment.store_credit.label"),children:r(ia,{name:"store_credit_redemption",values:L.value,multiple:!0,onChange:D,variant:"block",children:[r(oa,{value:Fs,disabled:I.value,secondaryContent:r(Z,{type:"strong",children:t.formatCurrency(R.amount,{currency:R.currencyCode})}),details:O&&r(Z,{children:O}),children:r(B,{direction:"inline",gap:"base",alignItems:"center",children:[r(Z,{children:t.translate("payment.store_credit.apply_label")}),r(n,{when:E,children:r(de,{})})]})}),U&&r(oa,{value:Vs,disabled:x.value,details:($||O)&&r(B,{gap:"small-500",children:[$&&r(Z,{children:$}),O&&r(Z,{children:O})]}),children:r(Z,{children:t.translate("payment.store_credit.use_remaining_for_subscription_charges_label")})})]})})}function Ks(){const{i18n:e}=Pe(),{hasViolations:t}=le(Dt);return t?r(H,{errorType:Q.PaymentError,tone:"critical",children:e.translate("store_credit_errors.generic_error")}):null}function Hs({name:e,digits:t,icon:a}){return r(B,{className:"YVGTZ",direction:"inline",columnGap:"none",rowGap:"small-200",alignItems:"center",inlineSize:"100%",children:[r("span",{className:"zyVks",children:r(J,{children:e})}),r("span",{className:"U4h7p",children:t}),a]})}const Qs=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 Ws(e){return e?e.nickname&&e.nickname.trim().length>0?e.nickname:e.bank&&e.bank.trim().length>0?e.bank:function(e){const t=Qs.get(e.toLowerCase());if(t)return t;const a=e.toUpperCase();return Nt(a)?Bt(a):e}(e.brand):""}function Xs(){const{checkout:{negotiator:e}}=Pe(),{paymentLines:t}=e.parts;return s(()=>Yt(t.value))}function Js({isSelected:e,hasMsiPlan:t,isStale:a,binPrefix:s,canEditBin:r,supportedInstallmentsCount:n,isNegotiating:i}){if(!e||!t&&!a)return"hidden";if(s){if(s.length<8&&r)return"prompt"}else{if(r)return"prompt";if(0===n)return"hidden"}return i||a?"loading":"dropdown"}function Zs({id:e,variant:t}){const{i18n:a}=Pe(),s="prompt"===t?a.translate("msi_installments.enter_card_details_prompt"):a.translate("msi_installments.loading_installments");return f(()=>{if("loading"===t)return oe({content:s})},[s,t]),r(he,{id:e,name:"msiInstallments",label:a.translate("msi_installments.payment_plan_label"),value:t,disabled:"loading"===t,onChange:()=>{},children:r(me,{value:t,children:s})})}function er({paymentMethod:e,isSelected:t,canEditBin:a=!0,isVaultedContext:s=!1,id:n="msiInstallmentsSelect"}){const{checkout:{negotiator:i}}=Pe(),{bankIdNumberSignal:o,installmentMonthsSignal:d,lastNegotiatedBinSignal:l}=i.context,{paymentLines:c}=i.parts,u=Xs();f(()=>{d.value=u.value},[u.value,d]);const m=a&&!s,h=e.installmentPlans?.find(e=>"MSI"===e.type),p=h?.supportedInstallments??[],y=Tt(o.value),v=!s&&void 0!==y&&void 0!==l.value&&y!==l.value;f(()=>{u.value&&(!t||!h||!y&&!m&&0===p.length)&&(c.value=ue(c.value,void 0))},[u.value,t,h,y,m,p.length,c]);const b=Js({isSelected:Boolean(t),hasMsiPlan:Boolean(h),isStale:v,binPrefix:y,canEditBin:m,supportedInstallmentsCount:p.length,isNegotiating:!1});return"hidden"===b?null:r(Zs,"prompt"===b?{id:n,variant:"prompt"}:{id:n,variant:"loading"})}const tr=a({displayName:"MsiInstallmentsSelect",useError:ce("MsiInstallmentsSelect"),load:()=>_(async()=>({default:(await e(async()=>{const{MsiInstallmentsSelect:e}=await(import("./82de4790.DJFcD_Yf.js"));return{MsiInstallmentsSelect:e}},__vite__mapDeps([19,1,12,2,3,4,5,13,14,10,15,16,17,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39]))).MsiInstallmentsSelect})),renderLoading:e=>r(er,{...e})}),ar=new Map,sr=class e{constructor(e=[],t=[],a,s=!1){this.sdkQueue=e,this.initQueue=t,this.sdk=a,this.scriptLoaded=s,this.setupGeneration=0,this.currentSetupId=0}async load(e){let t=ar.get(e.source);t instanceof Promise||(t=pe(e,!0),ar.set(e.source,t)),await t;const a=this.initQueue.pop();a?.(),this.initQueue=[],this.scriptLoaded=!0}async setup(t,a,s){return nr(()=>{if(this.sdk)return;if(this.setupPromise&&this.setupForm===t)return this.setupPromise;const r=window.CardFields;if(!r)throw new ye("Attempted to init Cardfields before it is ready");const n=++this.currentSetupId;return this.setupForm=t,s(),this.setupPromise=(async()=>{try{for(let s=0;s<e.MAX_SETUP_ATTEMPTS;s++){const e=this.setupGeneration,s=await r.setup(t,a);if(n!==this.currentSetupId){try{s.teardown()}catch{}return}if(e===this.setupGeneration){this.sdk=s;for(const e of this.sdkQueue)await e();return void(this.sdkQueue=[])}try{s.teardown()}catch{}}throw new fe(`CardFields setup failed: ${e.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,t,a){return this.scheduleSDK(s=>a?s.on(a,e,t):s.on(e,t))}off(e,t,a){return this.scheduleSDK(s=>a?s.off(a,e,t):s.off(e,t))}setStyles({field:e,styles:t}){return e?this.scheduleSDK(a=>a.setStyles(e,t)):this.scheduleSDK(e=>e.setStyles(t))}setFocus(e){return this.scheduleSDK(t=>t.setFocus(e))}setTranslation(e,t){return this.scheduleSDK(a=>a.setTranslation(e,t))}setPlaceholderContent(e,t){return this.scheduleSDK(a=>a.setPlaceholderContent(e,t))}setValue(e,t){return this.scheduleSDK(a=>a.setValue(e,t))}setTooltip(e,t){return this.scheduleSDK(a=>a.setTooltip(e,t))}vaultCard(e){return this.scheduleSDK(t=>t.vaultCard(e))}vaultCardMultipleTimes(e,t){return this.scheduleSDK(a=>a.vaultCardMultipleTimes(e,t))}setErrors(e){return this.scheduleSDK(t=>t.setErrors(e))}clearField(e){return this.scheduleSDK(t=>t.clearField(e))}loadFonts(e){return this.scheduleSDK(t=>t.loadFonts(e))}getFieldFrame(e){return this.scheduleSDK(t=>t._getFieldFrame(e))}scheduleSDK(e){return nr(()=>{if(!this.sdk)throw new fe("The CardFields SDK has not been set up.");return e(this.sdk)},Boolean(this.sdk),this.sdkQueue)}};sr.MAX_SETUP_ATTEMPTS=3;let rr=sr;function nr(e,t,a){if(t){const t=e();return t instanceof Promise?t:new Promise(e=>{e(t)})}return new Promise((t,s)=>{a.push(async()=>{try{const a=e();t(a instanceof Promise?await a:a)}catch(a){s(a)}})})}const ir=P(void 0),or={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function dr({children:e,value:t,sdkScriptAttributes:a,blurValidationEnabled:s=!0,blurValidationFieldDenylist:n,onError:i,onSetFieldErrors:o,onLoadSuccess:c}){const u=p(()=>new rr,[]),[m,h]=d(!0),[y,b]=d({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null,sdk:null}),C=v(),[g,_]=d(),[P,S]=d(),[k,A]=d({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),[E,w]=d(""),[I,x]=d([]),[L,D]=d(or),N=v(L);f(()=>{N.current=L},[L]);const B=v(),T=l(e=>{C.current=e instanceof ve?e.diagnostics:void 0,b({sdk:e.message}),i?.(e),h(!1)},[i,b,h]),F=l(async e=>{try{return await e()}catch(t){if(t instanceof Error){let e=null;if(t.name===be.name)e=new be(t.message);else if(t.name===Ce.name){const a="httpStatus"in t&&"number"==typeof t.httpStatus?t.httpStatus:void 0;e=new Ce(t.message,a)}else t.name===ge.hostedFieldsName&&(e=new ge(t.message));if(e)return T(e),"";T(t)}
2throw t}},[T]),V=l(async(e,t={propagateErrors:!0})=>{const{sdk:a,...s}=e;await F(()=>u.setErrors(s)),b(a=>{const s={...a,...e};return t.propagateErrors&&o?.(s),s})},[u,o,F]),U=l((e,t)=>{const a={},s=B.current;t?(e||(!k?.expiry&&t.includes("expiry")&&(a.expiry=s?.expiry),!k?.number&&t.includes("number")&&(a.number=s?.number_blank),!k?.name&&t.includes("name")&&(a.name=s?.name)),!e&&!t.includes("verification_value")||k?.verification_value||(a.verification_value=s?.verification_value)):(e||(k?.expiry||(a.expiry=s?.expiry),k?.number||(a.number=s?.number_blank),k?.name||(a.name=s?.name)),k?.verification_value||(a.verification_value=s?.verification_value));const r={...y,...a};return V(r),{isValid:!Object.values(r).some(Boolean)}},[y,k?.expiry,k?.name,k?.number,k?.verification_value,V]);f(()=>{!async function(){try{if(!a)throw new ye("Provider: hostedFieldsUrl must be provided");await u.load(a)}catch(e){e instanceof Error&&T(e)}}()},[a,u,T]);const R=l(({cardType:e,bin:t,networks:a})=>{_(e),w(t),x(a)},[]),O=l(({targetName:e})=>{S(e)},[]),$=l(async e=>{const{isValueValid:t,targetName:a,isValueEmpty:r}=e,i=B.current,o=N.current[a],d=Boolean(n?.has(a));if(s&&!d&&i&&o){const e={[a]:t?null:i[a]};"number"===a&&r&&(e[a]=i.number_blank),await V(e,{propagateErrors:!1})}S(void 0)},[V,s,n]),Y=l(async e=>{const{targetName:t,isValueEmpty:a,isTab:s}=e;if(!s){A(e=>({...e,[t]:!a})),D(e=>({...e,[t]:!0}));const e={[t]:null};await V(e)}},[V]),q=l(e=>{A(t=>({...t,[e]:!0}))},[]),j=function(){const e=v(!0);return M(()=>()=>{e.current=!1},[]),e}(),z=l(()=>{j.current&&(A({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),x([]))},[A,j]),G=l(()=>{F(()=>u.on("cardtype",R)),F(()=>u.on("focus",O)),F(()=>u.on("blur",$)),F(()=>u.on("keyup",Y)),F(()=>u.on("change",Y)),F(()=>u.on("input",Y))},[F,u,R,O,$,Y]),K=l(()=>{F(()=>u.off("cardtype",R)),F(()=>u.off("focus",O)),F(()=>u.off("blur",$)),F(()=>u.off("keyup",Y)),F(()=>u.off("change",Y)),F(()=>u.off("input",Y))},[F,u,R,O,$,Y]),H=l(()=>{D(or)},[]),Q=p(()=>({loadFonts:e=>F(()=>u.loadFonts(e)),setErrors:e=>V(e,{propagateErrors:!1}),setStyles:(...e)=>F(()=>u.setStyles(...e)),setFocus:(...e)=>F(()=>u.setFocus(...e)),setTooltip:(...e)=>F(()=>u.setTooltip(...e)),setTranslation:(...e)=>F(()=>u.setTranslation(...e)),setPlaceholderContent:(...e)=>F(()=>u.setPlaceholderContent(...e)),setValue:(e,t)=>F(()=>("string"==typeof t&&t.trim().length>0&&A(t=>({...t,[e]:!0})),u.setValue(e,t))),setup:async(e,t,a=()=>{})=>{h(!0),await F(()=>u.setup(e,t,a)),c?.(),h(!1),B.current=t.errorMessages},teardown:()=>F(()=>u.teardown()),clearField:e=>F(()=>(A(t=>({...t,[e]:!1})),u.clearField(e))),vaultCard:(...e)=>F(()=>u.vaultCard(...e)),vaultCardMultipleTimes:(e,t)=>F(()=>u.vaultCardMultipleTimes(e,t)),getCardField:e=>u.getFieldFrame(e)}),[u,V,F,c]);f(()=>()=>{o?.({})},[o]);const W=p(()=>t??{sdk:Q,errors:y,sdkLoadDiagnostics:C.current,cardBrand:g,bankIdNumber:E,networks:I,focusedField:P,filled:k,loading:m,validate:U,subscribe:G,unsubscribe:K,resetTouched:H,emptyFields:z,setFilled:q,touched:L},[Q,g,E,I,y,k,P,m,t,U,G,K,H,z,q,L]);return r(ir.Provider,{value:W,children:e})}const lr=()=>{const e=y(ir);if(null==e)throw new ye("No cardfields found in context");return e},cr=e=>e.toUpperCase(),ur=e=>e.toLowerCase();function mr(e){return Boolean(e?.some(e=>"direct"===e.type&&e.paymentBrands.includes("BOGUS")))}function hr({paymentMethods:e,hasBogusGateway:t=mr(e),paymentLines:a,storeVaultGuestCvvVerificationEnabled:s=!1,selectedCardRequiresProposalLineCvv:r=!1,selectedCardBrand:n,hasAmexCvvOnlyField:i=pr({paymentLines:a,storeVaultGuestCvvVerificationEnabled:s,selectedCardRequiresProposalLineCvv:r,selectedCardBrand:n})}){return t?new Set(["number"]):i?new Set(["verification_value"]):new Set}function pr({paymentLines:e,storeVaultGuestCvvVerificationEnabled:t=!1,selectedCardRequiresProposalLineCvv:a=!1,selectedCardBrand:s}){return Boolean(a&&"AMEX"===s?.toUpperCase()||t&&e?.some(({method:e})=>e.type===ot.CreditCard&&"AMEX"===e.brand))}function yr(e){return e.replace(/([\d.]+)rem/g,(e,t)=>10*Number(t)/14+"rem")}function fr(){const{checkout:{negotiator:e}}=Pe(),{paymentMethods:t}=e.current.fields;return s(()=>{const e=t.value?.filter(e=>e.type===ot.CreditCard&&Boolean(e.expired));return e?e.length:0})}function vr(){const{i18n:e}=Pe();return{getAccessibilityLabel:t=>{const a="direct"===t.type?t.creditCardLastFourDigits:t.displayLastDigits;return`${Bt(t.brand)} ${e.translate("payment.saved_credit_card_info")} ${a}`}}}function br(e){return e?e.map(e=>cr(e)):[]}const Cr=Ft("CreditCardNetworkContext");function gr({children:e,paymentMethod:t,publishesCardNetworkDetection:a=!1}){const{checkout:s,source:n,observability:i,userEvents:o}=Pe(),c=S(),u=t?Ve(t):c,m=s.cardNetworkSelection.forMethod(u),{bankIdNumber:h,touched:y,...v}=lr(),{networks:b,sdk:C,filled:g}=v,_=p(()=>br(b),[b]),M=h?.replace(/\s/g,"").length??0,P=M>=6&&v.cardBrand?cr(v.cardBrand):void 0,k=p(()=>_.filter(e=>t?.paymentBrands.includes(e)),[_,t]),A=Boolean(t?.supportsNetworkSelection);f(()=>{a&&m.setDetectedState({networkSelectionEnabled:A,availableNetworks:k,cardBrand:P,numberFilled:Bo
2olean(g.number),bankIdNumberLength:M})},[a,m,A,k,P,g.number,M]);const E=m.selectableBrands.value;!function({displayName:e,paymentBrands:t,paymentMethodIdentifier:a,selectableBrands:s,networkSelectionSupported:r}){const{bankIdNumber:n,networks:i,cardBrand:o}=lr(),{userEvents:l,source:{checkoutSessionIdentifier:c}}=Pe(),[u,m]=d(!1),[h,y]=d(""),v=p(()=>br(i||(o&&(n?.length??0)>=6?[o]:void 0)),[i,o,n]);f(()=>{if(!n||0===n.length||!c)return;const i={checkoutToken:c,paymentMethodIdentifier:a,displayName:e||"",supportedBrands:t.join(","),detectedBrands:v.join(","),cardIsCobadged:v.length>1,shownBrands:s.join(","),networkSelectorShown:s.length>1&&r};u||(l.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...i,eventName:"first_digit_entered"}}),m(!0)),n.length>=6&&v.length>0&&i.shownBrands!==h&&(y(i.shownBrands),l.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...i,eventName:"brand_shown_to_buyer"}}))},[a,e,t,v,s,n,l,c,r,h,u,m])}({displayName:t?.name,paymentBrands:t?.paymentBrands??[],paymentMethodIdentifier:t?.paymentMethodIdentifier??"",selectableBrands:E,networkSelectionSupported:t?.supportsNetworkSelection??!1});const w=l(e=>{const t=m.selectedSavedCreditCardBrand.value,a="function"==typeof e?e(t):e;m.setSelectedSavedCreditCardBrand(a)},[m]),I=l(async()=>{const e=m.selectedNetwork.value,t=e?{selected_network:ur(e)}:void 0,a=await C.vaultCard(t);return Mr(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:t?.selected_network,detectedNetworks:b}),a||i.log("credit_card_network_context_no_session_id_returned","No session id returned when vaulting card with selected network",{selectedNetwork:t?.selected_network}),a},[m,C,n,b,i,o]),x=l(async e=>{const t=m.selectedNetwork.value,a=t?{selected_network:ur(t)}:void 0,s=await C.vaultCardMultipleTimes(e,a);return Mr(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:a?.selected_network,detectedNetworks:b}),s},[m,C,o,n,b]),L=p(()=>({activePaymentBrand:m.activeBrand.value,binLength:m.bankIdNumberLength.value,paymentMethod:t,detectedNetworks:_,selectableBrands:E,selectedNetwork:m.selectedNetwork.value,selectedSavedCreditCardBrand:m.selectedSavedCreditCardBrand.value,setSelectedNetwork:m.setSelectedNetwork,setSelectedSavedCreditCardBrand:w,vaultCardWithSelectedNetwork:I,vaultCardMultipleTimesWithSelectedNetwork:x}),[m.activeBrand.value,m.bankIdNumberLength.value,m.setSelectedNetwork,m.selectedNetwork.value,m.selectedSavedCreditCardBrand.value,t,_,E,w,I,x]);return r(Cr.Provider,{value:L,children:e})}function _r(){return Vt(Cr)}function Mr(e,{checkoutSessionIdentifier:t,selectedNetwork:a,detectedNetworks:s}){a&&e.monorailEvent({schemaId:"checkout_credit_card_network_selection/1.0",payload:{checkoutToken:t,selectedNetwork:a,supportedNetworks:s?.join(",")??""}})}const Pr=["CardFieldsFetchFailureError"];function Sr({children:e,publishesCardNetworkDetection:t,directPaymentMethodConfig:a,...s}){const n=v(_e()),{observability:i,checkout:{negotiator:o}}=Pe(),{value:d}=o.current.fields.paymentMethods,c=a??He(d??[]),u=l(e=>{Pr.includes(e.name)?i.log("default_card_fields_provider_unactionable_error","Unactionable error in card fields provider",{error:e}):i.error(e)},[i]);return r(dr,{...s,onError:u,sdkScriptAttributes:n.current,children:r(gr,{paymentMethod:c,publishesCardNetworkDetection:t,children:e})})}function kr(e){const{shopPay:t,checkout:{negotiator:a}}=Pe(),{value:s}=a.current.fields.paymentMethods,{paymentLines:n}=a.parts,{bankIdNumberSignal:i,installmentMonthsSignal:o}=a.context,{binResolution:d,clearInstallments:l,selectedCardBin:c,expandedVisible:u,collapsedVisible:m}=e.msi,h=u.value,p=m.value,y="server"===d?e.selectedCreditCard.value?.id:void 0;!function({enabled:e,selectedCardId:t}){const{checkout:{identity:a,negotiator:s}}=Pe(),{paymentLines:r}=s.parts,{negotiate:n}=Y(),i=ra(),o=v(void 0);f(()=>{if("shopPay"!==a.current.value)return;if(!e||!t)return o.current=void 0,void(r.value=Ut(r.value));if(o.current===t)return;o.current=t;const s=qe(r.value,"SHOP_PAY"),d=s?.method.walletContent?.credit
2CardInstallments;r.value=Rt(r.value,i({msiEligibleCard:!0,creditCardInstallments:d})),n({silenceViolations:[...Ot]}).catch(()=>{o.current=void 0})},[e,a.current.value,t])}({enabled:p&&!t.session.isLoading.value,selectedCardId:y});const b=v(h);f(()=>{b.current&&!h&&(n.value=l(n.value),o.value=void 0),b.current=h},[h,l,n,o]);const C=v(p);f(()=>{C.current&&!p&&(n.value=l(n.value),o.value=void 0),C.current=p},[p,l,n,o]);const g=c.value,_=e.selectedCreditCard.value?.id;f(()=>{if("client"!==d)return;const e=i.peek();i.value=_===rt&&da(e,g)?e:g},[d,i,g,_]);const M=He(s??[]);var P;return{expandedSlot:M&&h?Ar({paymentMethod:M,binResolution:d,id:"msiInstallmentsSelect-expanded"}):void 0,collapsedSlot:M&&p?(P=Ar({paymentMethod:M,binResolution:d,id:"msiInstallmentsSelect-summary"}),r(te,{paddingInlineStart:"large-100",children:r(Sr,{onSetFieldErrors:()=>{},children:P})})):void 0}}function Ar({paymentMethod:e,binResolution:t,id:a}){return r(tr,"server"===t?{paymentMethod:e,isSelected:!0,isVaultedContext:!0,id:a}:{paymentMethod:e,isSelected:!0,canEditBin:!1,id:a})}function Er(e,t,a){return!!e&&(0===a.size||[...t].some(e=>!a.has(e.code)))}function wr({renderInSection:e,hideHeading:t,headingLevel:a=2}){const{i18n:o,shop:{name:d,showTipPayments:l},checkout:{negotiator:c}}=Pe(),{tipLines:u}=c.current.fields,{tipLines:m}=c.parts,h=s(()=>{const e=u.value?.[0]??m.value[0];return l||Boolean(e&&e.amount.amount>0)}),p=o.translate("tips.description",{shop_name:d}),y=r(te,{paddingBlockEnd:"base",children:[!t&&r(i,{children:[r(ne,{level:a,children:o.translate("tips.title")}),r(N,{blockSize:"base"})]}),r(Me,{contentDisplay:"block",inlineSize:"100%",children:p}),r(n,{when:h,children:[r(N,{blockSize:"small-200"}),r(Me,{contentDisplay:"block",inlineSize:"100%",children:o.translate("tips.custom_label")}),r(N,{blockSize:"small-100"}),r(Me,{contentDisplay:"block",inlineSize:"33%",children:o.translate("tips.add_tip")})]})]});return e?r(re,{accessibilityLabel:o.translate("tips.title"),children:y}):y}const Ir=a({displayName:"Tipping",renderLoading:e=>r(wr,{...e}),useError:function(e){const{observability:t}=Pe();f(()=>{e&&t.error(e,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})},[e,t])},load:()=>e(()=>import("./6a7f8a66.BX03a5Em.js"),__vite__mapDeps([40,1,12,2,3,4,5,13,14,10,15,16,17,28,24,29,41,42,43,44]))});export{zs as $,Na as A,_r as B,Qa as C,Sr as D,pr as E,cr as F,Ts as G,yr as H,vr as I,ja as J,qa as K,es as L,tr as M,va as N,ts as O,xs as P,as as Q,fr as R,Ks as S,Ir as T,Ca as U,Hs as V,pa as W,ua as X,Es as Y,ks as Z,Ms as _,Xs as a,js as a0,Fs as a1,Vs as a2,ya as a3,Ya as a4,ws as b,_s as c,Is as d,Gs as e,Cs as f,Js as g,kr as h,la as i,hr as j,Sa as k,mr as l,lr as m,Ws as n,ka as o,La as p,Ia as q,xa as r,Da as s,Er as t,gs as u,Aa as v,Ta as w,Ea as x,wa as y,Ba 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.