PageSourceSearch

https://www.gridconnect.com/cdn/shopifycloud/checkout-web/assets/c1/f7742f92.B6soxB5Q.js

js gridconnect.com collected 2026-10-02 02:49:21 UTC 55,844 bytes, 1 lines download raw bytes

1import{g as ie,f as Je,T as me,m as et,e as _e,q as W,A as ne,p as Lt,h as wt,u as ee,i as Ht,S as Fe}from"./2c1ab0fe.BqEHHmaW.js";import{fP as fe,fO as Yt,ck as kt,gi as tt,fr as Ut,h as at,f2 as Vt,fA as Bt,gj as Se,gk as Ft,ao as xt,gl as zt,fU as Wt,fT as Zt,B as xe,S as qt,gm as Qt}from"./164ad2e3.BA-GikTU.js";import{dh as $t,gz as rt,gA as Ae,ci as jt,en as ot,gB as Xt,aE as Kt,aB as Jt,O as $,a7 as nt,P as Ee,Q as Re,gC as Ie,aZ as Me,gD as Ne,a6 as te,am as st,an as it,cR as Le,gE as be,dg as ea,df as ta,C as lt,gF as aa,b1 as ra,a8 as oa,u as ze,gG as na,gH as sa,bi as ia,gI as la,a_ as dt}from"./4c290a1e.FJVsH4yi.js";import{d as da}from"./ca5e9c49.COugV1Xp.js";import{g as ca,e as ua}from"./cb8fcd45.D99hrDC6.js";import{S as De,u as ga,a as pa}from"./3a819064.Xmk2TvaB.js";import{u as ma,W as _a}from"./8536083a.K1vafffH.js";import{v as Ea}from"./2210eadb.EwEgHOG0.js";import{i as ct,d as ya}from"./65f3d4da.BdKZt11Z.js";import{f as F,g as ha,s as va,r as Pa,B as Sa,P as Aa,T as ut,U as gt,V as pt,D as we,N as He,a as Ia,b as fa,c as Ra,d as Na,e as ba,h as mt,E as _t,I as Et,i as yt,j as Te,k as Oa,l as Da,u as Ta,m as Ca,n as Ga,o as Ma,p as La,q as wa,t as We,S as Ze,v as Ha}from"./13b13169.JaoLU_DX.js";import{a as Ya,g as ka}from"./0a7dffce.BHf0S_6c.js";import{d as ht,b as V,e as se,c as qe}from"./ed9f2238.ChGZ5py3.js";import{S as le}from"./app.D2gvVyTR.js";import{a as Ua,u as Va}from"./bea9843a.Cd2v6kJc.js";import{r as Qe}from"./e477f96c.CCUKKy0S.js";import"./60a453ce.BClq-svk.js";import"./bb728e1c.uhKc-SJ5.js";import"./ac5a19ff.BHoedVx2.js";import"./53bbdad9.6B8LHIua.js";import"./f78726c8.D1GQbjRB.js";const Ba=/^[A-Z]{1,2}[0-9]{1,2}[A-Z]?$/,Fa=/^[A-Z][0-9][A-Z]$/;function xa(e){const{countryCode:t,postalCode:a}=e;if(a==null)return e;const r=a.trim().toUpperCase();return t==="CA"&&Fa.test(r)?e.postalCode=`${r} 0Z0`:t==="GB"&&Ba.test(r)&&(e.postalCode=`${r} 0ZZ`),e}function za(e=window.navigator.userAgent){const t=/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+(?: Mobile)? Safari\/537\.36$/,a=/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+ Safari\/537\.36 Edg\/[\d.]+$/,r=/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+(?: Mobile)? Safari\/537\.36 Vivaldi\/[\d.]+$/;return t.test(e)||a.test(e)||r.test(e)}function Wa(e){return(e?.scope==="host"||e?.scope==="sandbox")&&(e.callback==="shipping"||e.callback==="authorization")&&(e.stage==="checkout"||e.stage==="cardsink"||e.stage==="host_rpc")&&(e.outcome==="started"||e.outcome==="progress"||e.outcome==="pending"||e.outcome==="resolved"||e.outcome==="rejected")&&typeof e.callbackId=="string"&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&(e.visibilityState==="visible"||e.visibilityState==="hidden")&&(e.googlePayTransactionId===void 0||typeof e.googlePayTransactionId=="string")&&(e.trigger===void 0||typeof e.trigger=="string")}function Za({log:e,stage:t,...a}){try{let r=function(l){try{(l==="resolved"||l==="rejected")&&clearTimeout(u),e({...a,callbackId:o,stage:s,outcome:l,durationMs:performance.now()-n,visibilityState:document.visibilityState})}catch{}};const o=Ea(),n=performance.now();let s=t;const u=setTimeout(()=>r("pending"),25e3);return r("started"),{stage(l){s!==l&&(s=l,r("progress"))},observe(l){try{return l().then(i=>(r("resolved"),i),i=>{throw r("rejected"),i})}catch(i){throw r("rejected"),i}}}}catch{return{stage(){},observe:r=>r()}}}const qa=2,Qa=0,$a={apiVersion:qa,apiVersionMinor:Qa},vt="%";function ja(e,t){const a=e.find(i=>i.deliveryLine.type==="ONE_TIME_PURCHASE"),r=e.find(i=>i.deliveryLine.type==="SUBSCRIPTION");let o="";if(r){if(r.methodType==="PICK_UP"||r.methodType==="LOCAL")return r.title;o=r.title}const s=[a?.title??"",o].filter(Boolean),[u,l]=s;return u===void 0?"":l===void 0?u:s.length===2?t.combineTwoShippingTitles(u,l):t.combineMultipleShippingTitles(s)}function Pt(e){return St(JSON.stringify(e))}function St(e){return e.replace(/["']/g,vt)}function Xa(e){return St(va(e))}function Ka(e){const t=new RegExp(`[${vt}]`,"g");return e.replace(t,'"')}function Ja(e,t){const a=Kt(e).filter(Jt).map(Ya);return ka(a).filter(o=>o.length).map(o=>({id:Xa(o),label:ja(o,t),description:o.map(It).join(", ")}))}function er({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:u,checkoutTotal:l,deferredTotal:i,labels:E,i18nCurrency:P,translations:A,selectedShippingId:S,deliveryMacros:I,paymentFlexibilityPaymentTermsTemplate:T,googlePayTransactionId:g,merchandiseLines:C,shouldWalletDecelerateForSubscriptions:h=!1,discountsZeroValueUXEnabled:R=!1}){const y=I?.length?nr(I):Ja(o,A),b=!!ot({deferredTotal:i,checkoutTotal:l,paymentFlexibilityPaymentTermsTemplate:T})?.amount,v=At({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:u,labels:E,i18nCurrency:P,checkoutTotal:l,deferredTotal:i,hasPayableDeposit:b,googlePayTransactionId:g,merchandiseLines:C,shouldWalletDecelerateForSubscriptions:h,discountsZeroValueUXEnabled:R}),O=y.find(c=>c.id===S)?.id??y[0]?.id;return{...y.length>0?{newShippingOptionParameters:{shippingOptions:y,defaultSelectedOptionId:O}}:{},newTransactionInfo:v}}function At({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:u,labels:l,i18nCurrency:i,checkoutTotal:E,deferredTotal:P,hasPayableDeposit:A,googlePayTransactionId:S,merchandiseLines:I,shouldWalletDecelerateForSubscriptions:T=!1,discountsZeroValueUXEnabled:g=!1}){const C=e?F(e.amount):"0",h=A&&E&&P,R=h?F(E.amount):void 0,y=h?F(P.amount.amount):void 0,b=!!I?.lines?.length,v=[];
1I?.lines&&I.lines.forEach(c=>{v.push({label:ha(c),type:"LINE_ITEM",price:F(c.totalPrice.amount)}),rr(c,g).forEach(D=>{v.push(D)})}),t&&v.push({label:l.subtotal,type:"SUBTOTAL",price:F(t.amount)}),ar(n?.lines,g).forEach(c=>{v.push(c)});const O=$t(o).reduce((c,D)=>c+D.method.cost.amount,0);return v.push({label:l.shipping,type:"LINE_ITEM",price:F(O)}),a&&a?.status==="available_total"&&a?.totalDuty.amount!==0&&v.push({label:l.duties,type:"LINE_ITEM",price:F(a.totalDuty.amount)}),r&&r.status==="available_total"&&r.totalTax.amount!==0&&v.push({label:l.taxes,type:"LINE_ITEM",price:F(r.totalTax.amount)}),n?.lines.forEach(c=>{if(ct(c)){if(b&&c.discount.presentationLevel==="LINE"&&c.sourceTerm!=="delivery"||rt(c))return;const D=c.amount?.amount;D&&v.push({label:c.title,type:"LINE_ITEM",price:Ae(F(D))})}}),u?.lines.filter(c=>c.method.type==="giftCard").forEach(c=>{c.cost&&v.push({label:`${l.giftCard} ${jt(c.method).toUpperCase()}`,type:"LINE_ITEM",price:Ae(F(c.cost.amount))})}),s?.forEach(c=>{v.push({label:l.tip,type:"LINE_ITEM",price:F(c.amount.amount)})}),R&&v.push({label:l.deposit,type:"LINE_ITEM",price:R}),y&&v.push({label:l.totalDueLater,type:"LINE_ITEM",price:y}),{totalPrice:R||C,currencyCode:t?.currencyCode||i,totalPriceStatus:"ESTIMATED",totalPriceLabel:R?l.totalDueToday:l.total,displayItems:v,...S&&{transactionId:S},...T&&{checkoutOption:"CONTINUE_TO_REVIEW"}}}function tr(e){return ya(e.discountDetails.discount)&&e.discountDetails.discount.presentationLevel==="LINE"}function ar(e,t){return e?e.flatMap(a=>{if(!ct(a))return[];if(!rt(a))return[];const r=a.amount?.amount;if(r===void 0)return[];if(t&&r===0)return[];const o=F(r);return[{label:a.title,type:"LINE_ITEM",price:r===0?o:Ae(o)}]}):[]}function rr(e,t){const a=new Map;return e.lineAllocations.forEach(r=>{r.allocations.filter(tr).forEach(o=>{const{title:n}=o.discountDetails;a.set(n,(a.get(n)??0)+o.amount.amount)})}),Array.from(a).filter(([,r])=>!t||r!==0).map(([r,o])=>({label:r,type:"LINE_ITEM",price:o===0?F(o):Ae(F(o))}))}function Ce({googleAddress:e,isFirstNameRequired:t}){let a=e.iso3166AdministrativeArea||void 0,r=e.locality||void 0,o=e.countryCode;e.countryCode==="AE"&&(r=e.administrativeArea),e.countryCode&&Xt.includes(e.countryCode)&&(a=e.countryCode,o="US");const n={city:r,postalCode:e.postalCode||void 0,zoneCode:a,countryCode:o};if("name"in e){const[s,...u]=(e.name||"").split(" ");u.length===0?(n.lastName=s,t&&(n.firstName=n.lastName)):(n.firstName=s,n.lastName=u.join(" "))}return"address1"in e&&(n.address1=e.address1),"address2"in e&&(n.address2=e.address2),"phoneNumber"in e&&(n.phone=e.phoneNumber),n}function or({googleAddress:e,isFirstNameRequired:t}){return xa(Ce({googleAddress:e,isFirstNameRequired:t}))}function It({costAfterDiscounts:e,deliveryPromisePresentmentTitle:t}){const{short:a}=t||{},r=F(e.amount);return`${a?`(${a}) `:""}${r} ${e.currencyCode}`}function nr(e){return e.map(({totalTitle:t,totalCostAfterDiscounts:a,deliveryPromisePresentmentTitle:r,deliveryMethodHandles:o})=>({id:Pt(o),label:t,description:It({costAfterDiscounts:a,deliveryPromisePresentmentTitle:r})}))}function sr(){const{checkout:e}=$(),t=fe("GOOGLE_PAY");return ie(()=>{const a=t.value;if(a===void 0)return[];const r=e.configuration.addressSettings.nonBillingAddressSettings.value,o=Je(()=>r.isRequired("phone")),{allowedAuthMethods:n,allowedCardNetworks:s,gateway:u,gatewayMerchantId:l}=a;return[{type:"CARD",parameters:{allowedAuthMethods:n,allowedCardNetworks:s,billingAddressRequired:!0,billingAddressParameters:{format:"FULL-ISO3166",phoneNumberRequired:o}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:u??"",gatewayMerchantId:l??""}}}]})}function ft(){const{i18n:e}=$();return me(()=>({total:e.translate("order_summary.total_label"),subtotal:e.translate("order_summary.subtotal_label"),shipping:e.translate("order_summary.shipping_label"),duties:e.translate("order_summary.duties_label"),taxes:e.translate("order_summary.estimated_taxes_label"),giftCard:e.translate("order_summary.gift_card_label"),tip:e.translate("order_summary.tip_label"),deposit:e.translate("order_summary.deposit_label"),totalDueToday:e.translate("order_summary.total_due_today_label"),totalDueLater:e.translate("order_summary.total_due_later_label")}),[e])}function Rt(){const{shop:{name:e,myshopifyDomain:t}}
1=$(),a=fe("GOOGLE_PAY");return ie(()=>{const r=a.value;return r===void 0?void 0:{merchantName:e,merchantId:r.merchantId,merchantOrigin:t,authJwt:r.authJwt}})}function ir({asPaymentMethod:e}){const t=nt(),a=Rt(),r=sr(),{checkout:o,i18n:n,shop:s}=$(),u=Ee(),l=Yt(),i=ft(),{locationAddress:E}=Re(),P=kt(),A=tt(s),S=o.configuration.layout.isOnePage.value,I=s.hasFlagEnabled(Ie),T=S||I,g=ie(()=>T&&Me({checkout:o})),C=et(e);return ie(()=>{const h=!C.value&&!Ne({availableDeliveryAddresses:u.availableDeliveryAddresses?.value,mustSelectProvidedAddress:u.mustSelectProvidedAddress?.value})&&o.isShippingRequired.value,R=h?["PAYMENT_AUTHORIZATION","SHIPPING_ADDRESS","SHIPPING_OPTION"]:["PAYMENT_AUTHORIZATION"],y=Pa(t,{includeShopPromotion:!1}),b=P.value&&E.fields.countryCode.value?[E.fields.countryCode.value]:s.shippingCountries?.map(K=>K.value),v=r.value,O=a.value;if(v.length===0||!O||!b||b.length===0&&h||y.paymentDue==null||y.subtotal==null)return null;const c=o.configuration.addressSettings.nonBillingAddressSettings.value,D=Je(()=>c.isRequired("phone")),k=!!ot({deferredTotal:y.deferredTotal,checkoutTotal:y.checkoutTotal,paymentFlexibilityPaymentTermsTemplate:y.paymentFlexibilityPaymentTermsTemplate})?.amount;return{...$a,allowedPaymentMethods:v,merchantInfo:O,callbackIntents:R,emailRequired:l.value,shippingAddressParameters:{format:"FULL-ISO3166",allowedCountryCodes:b,phoneNumberRequired:D},shippingAddressRequired:h,shippingOptionRequired:h,transactionInfo:At({labels:i,i18nCurrency:n.currency,...y,hasPayableDeposit:k,shouldWalletDecelerateForSubscriptions:g.value,discountsZeroValueUXEnabled:A})}})}const Ge="GOOGLE_PAY",lr="54px",dr="FAILED_TO_OPEN_WINDOW",cr="VALIDATION_TIMEOUT";class Pe extends le{constructor(){super(...arguments),this.name="GooglePayGenericError"}}class ur extends le{constructor(){super(...arguments),this.name="GooglePayCreateButtonError"}}class gr extends le{constructor(){super(...arguments),this.name="GooglePayDeveloperError"}}class pr extends le{constructor(){super(...arguments),this.name="GooglePayUnexpectedStatusCodeError"}}class $e extends le{constructor(){super(...arguments),this.name="GooglePaySubmissionError"}}class mr extends le{constructor(){super(...arguments),this.name="GooglePayInvalidError"}}class _r extends le{constructor(){super(...arguments),this.name="GooglePayNegotiationError"}}function Er(e){const t=ht(V.GooglePay),a=_e(!1),{persistedGooglePaySignal:r,inMemoryGooglePayParts:{sdkStatus:o,buttonStatus:n,paymentSheetError:s,paymentSheetOpenPromiseResolve:u,paymentSheetOpenPromise:l}}=te(),{observability:i,checkout:{wallets:E},client:{userAgent:P}}=$(),A=st(P),S=it(P);return W(I=>{i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler onResponse",{response:I}),e.value=!1;const{response:T,error:g}=I;if(T)u.value?.(void 0);else if(g){switch(g.name==="CANCELED"?i.counter({name:"wallet_sheet_cancelled",value:1,attributes:{instrument:V.GooglePay}}):i.counter({name:"wallet_sheet_failed",value:1,attributes:{instrument:V.GooglePay}}),g.name){case"CANCELED":i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: CANCELED"),t(se.Cancelled);break;case"DEVELOPER_ERROR":i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: DEVELOPER_ERROR",{errorMessage:g.message}),t(se.Failure),s.value={type:"invalid_config"},i.error(new gr(`loadPaymentData failed: ${g.message}`,{groupingHash:"GooglePayDeveloperError::LoadPaymentDataFailed"}));break;case"BUYER_ACCOUNT_ERROR":case"MERCHANT_ACCOUNT_ERROR":i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: ACCOUNT_ERROR",{errorType:g.name,errorMessage:g.message}),t(se.Failure),n.value={status:"error"},o.value={status:"error"},i.log("google_pay_response_handler_session_unavailable","Google Pay is unavailable for this session",{reason:g.name});break;case"INTERNAL_ERROR":i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: INTERNAL_ERROR",{errorMessage:g.message}),t(se.Failure),s.value={type:"unexpected_terminal_error"},i.log("google_pay_response_handler_internal_error","Google Pay internal server error occurred",{errorMessage:g.message});break;case cr:i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: VALIDATION_TIMEOUT"),t(se.Failure);break;case dr:a.value||(i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: FAILED_TO_OPEN_WINDOW"),t(se.Failure),i.counter({name:"wallet_failed_to_open_window",value:1,attributes:{os:S,browser:A.name}}),a.value=!0);break;default:i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: UNEXPECTED_STATUS",{errorName:g.name,errorMessage:g.message}),i.error(new pr(`loadPaymentData failed with unexpected status code: [${g.name}] ${g.message}`,{groupingHash:`GooglePayUnexpectedStatusCodeError::UnexpectedStatus::${g.name}`}));break}u.value?.(void 0)}i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler cleanup complete"),E.activeSession.value?.wallet==="GOOGLE_PAY"?E.clearActiveSession({invokingWallet:"GOOG
1LE_PAY"}):i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler cleanup complete, but activeSession is not Google Pay",{activeSession:E.activeSession.value}),l.value=void 0,r.value={initialCurrencyCode:void 0}},[A,S,l,r,u,i,t,s,n,o,a,e,E])}function yr({paymentDataRequest:e,asPaymentMethod:t,isScrimOpen:a,containerRef:r,endpoint:o}){const n=Ut(),{negotiate:s}=at(),{observability:u,checkout:{wallets:l},client:{userAgent:i}}=$(),E=st(i),P=E.name==="Safari",A=it(i),S=_e(!1),I=_e(!1),{inMemoryGooglePayParts:{paymentSheetError:T,paymentSheetOpenPromise:g,paymentSheetOpenPromiseResolve:C,sdkStatus:h},persistedGooglePaySignal:R}=te(),y=ht(V.GooglePay),b=Vt(V.GooglePay),v=Bt(V.GooglePay);return W(async()=>{n(r);try{if(t){if(S.value)return;S.value=!0,P&&(o.value?.call.updateValidationLock({status:"success"}),a.value=!0),await new Promise((c,D)=>{s({negotiationStage:"completion",runListenersOnError:!0,onComplete:k=>{k?.status==="success"?c():D()}})})}if(a.value=!0,l.activeSession.value){u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - active session exists"),a.value=!1,o.value?.call.updateValidationLock({status:"failure"});return}const O=h.value;if(O?.status!=="available"){u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - SDK not available",{sdkStatus:O?.status}),a.value=!1,o.value?.call.updateValidationLock({status:"failure"});return}l.setActiveSession({newValue:"GOOGLE_PAY",asPaymentMethod:t});try{b();const c=e.value;if(c===null||c.callbackIntents==null||c.callbackIntents.length===0){u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - invalid payment data request",{paymentDataRequest:c===null?"null":"invalid"}),l.clearActiveSession({invokingWallet:"GOOGLE_PAY"}),T.value={type:"config_missing_required_fields"},a.value=!1,o.value?.call.updateValidationLock({status:"failure"});return}v(),y(se.Success,t?qe.PaymentMethod:qe.Express),u.counter({name:"wallet_sheet_clicked",value:1,attributes:{instrument:V.GooglePay}}),I.value||(u.counter({name:"wallet_attempt_to_open_payment_sheet",value:1,attributes:{os:A,browser:E.name}}),I.value=!0),R.value={initialCurrencyCode:c.transactionInfo.currencyCode,receiptIdForPaymentFailure:R.value?.receiptIdForPaymentFailure},u.log("handle_click_button_clicked","Google Pay button clicked",{allowedAuthMethods:c.allowedPaymentMethods.map(D=>D.parameters.allowedAuthMethods)}),g.value=new Promise(D=>{C.value=D}),o.value?.call.updateValidationLock({status:"success"})}catch(c){throw l.clearActiveSession({invokingWallet:"GOOGLE_PAY"}),a.value=!1,c}}catch(O){u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick error handling",{error:O}),P&&t?(o.value?.call.closePopupWindows(),a.value=!1):(!t||!P)&&(a.value=!1),o.value?.call.updateValidationLock({status:"failure"})}finally{S.value&&(S.value=!1)}},[t,E,r,n,v,b,o,I,P,a,S,s,A,e,T,g,C,R,h,u,y,l])}function hr({endpoint:e,isTerminated:t,color:a,config:r,merchantInfo:o,buttonLabel:n,ariaLabel:s,markAsLoaded:u,sdkStatus:l,sdkStatusRef:i,buttonStatus:E,paymentDataRequest:P,containerRef:A,asPaymentMethod:S,isFirstRender:I,updateSdkStatus:T,connectedNullPaymentDataRequest:g,cardsinkConfig:C}){const{observability:h,source:R}=$();return W(async y=>{if(t.current){h.leaveErrorBreadcrumb("[GooglePay] useOnConnect skipped - sandbox already terminated");return}h.leaveErrorBreadcrumb("[GooglePay] useOnConnect starting configuration"),P.value||(g.current=!0),e.value=y;const b=await y.call.configure({isDark:a==="dark",environment:r?.environment,merchantInfo:o,buttonLabel:n,ariaLabel:s,paymentDataRequest:P.value,style:{borderRadius:ca(A.current)},cardsinkConfig:C,sourceId:R.sourceId});I.current=!1,u(),b.status===De.Success?(h.leaveErrorBreadcrumb("[GooglePay] useOnConnect configuration successful"),T({status:"available"},l,i),E.value.status!=="error"&&(E.value={status:"rendered"},h.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:Ge,status:"success",isPaymentMethodFlow:S}}))):(h.leaveErrorBreadcrumb("[GooglePay] useOnConnect configuration failed",{status:b.status}),b.status===De.Error&&vr({result:b,observability:h}),E.value={status:"error"},h.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:Ge,status:"error",isPaymentMethodFlow:S,reason:b.status===De.ScriptLoadError?"script_load_error":"sandbox_error"}}),T({status:"error"},l,i))}
1,[e,t,a,r?.environment,o,n,s,u,l,i,E,P,A,h,S,I,T,g,C,R.sourceId])}function vr({result:{type:e,name:t,message:a},observability:r}){e==="createButton"&&r.error(new ur(a,{cause:{name:t,message:a}}),{metadata:{additionalKey:{name:t,message:a}}})}class Nt extends Sa{constructor(t,a,r){super(),this.observability=t,this.translated=a,this.reportAddressRequirementMismatch=r}get negotiationResultMapper(){return null}validatePaymentCurrency({initialCurrencyCode:t,currentCurrencyCode:a}){return t==null||a==null?(this.observability.leaveErrorBreadcrumb("[GooglePay] validatePaymentCurrency skipped currency comparison, missing currency code",{initialCurrencyCode:t,currentCurrencyCode:a}),{}):t===a?(this.observability.log("google_pay_validate_payment_currency_succeeded","[GooglePay] validatePaymentCurrency succeeded, currency codes match",{currencyCode:a}),{}):(this.observability.leaveErrorBreadcrumb("[GooglePay] validatePaymentCurrency blocking submission, currency change",{initialCurrencyCode:t,currentCurrencyCode:a}),this.observability.counter({name:"wallet_action_generator_handled_error",value:1,attributes:{violationCode:"CURRENCY_CHANGE",WalletName:V.GooglePay}}),{paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.currencyChangeError}]}})}get completionResultMapper(){return new Aa({success:({result:t})=>"receipt"in t?{action:"submit"}:{action:"abort"},rejected:({result:t,violationActions:a,options:r})=>{const o=t.violations??[];this.getUnhandledErrors(o,a).forEach(u=>{this.observability.error(new $e(`submitForCompletion in ${this.isRedesign()?"redesign":"3-page"} Google Pay failed due to unhandled error ${u.code}`,{groupingHash:`GooglePaySubmissionError::SubmitForCompletion::UnhandledError::${u.code}`}),{severity:"error"})});const{firstPaymentSheetAction:n,violationCode:s}=this.getMergedPaymentSheetAction({resultViolations:o,violationActions:a});return s&&this.observability.counter({name:"wallet_action_generator_handled_error",value:1,attributes:{violationCode:s,WalletName:V.GooglePay}}),this.reportAddressRequirementMismatch({violationCode:s,wallet:V.GooglePay,asPaymentMethod:!!r?.asPaymentMethod,outcome:this.isRedesign()?"decelerate":n?.action??"abort"}),n||{action:"abort"}},invalid:({result:t})=>{const a={reasons:JSON.stringify(t.reasons),action:"invalid"};return this.observability.counter({name:"WalletsPlatform_google_pay_payment_sheet_unexpected_action",value:1,attributes:a}),{action:"abort"}},denied:()=>({action:"abort"}),throttled:()=>({action:"abort"}),tooManyRequests:()=>({action:"abort"}),alreadyCompleted:()=>({action:"abort"}),fetch_failed:()=>(this.observability.counter({name:"WalletsPlatform_google_pay_payment_sheet_unexpected_action",attributes:{action:"fetch_failed"},value:1}),{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.genericError}]})},t=>this.mapUnhandledStatus(t),(t,a)=>this.getCompletionViolationActions(t,a))}mapUnhandledStatus(t){return this.observability.error(new $e(`Unhandled completion status: ${t.status}`,{groupingHash:`GooglePaySubmissionError::UnhandledCompletionStatus::${t.status}`})),{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.genericError}]}}}class Pr extends Nt{constructor(t,a,r,o){super(t,a,o),this.inMemoryGooglePayParts=r}validateBilling(t){return t.paymentMethodData.info?.billingAddress?{shouldPersist:!0}:this.genericPaymentMethodError()}validateShipping(t,a){const r=t.shippingAddress;return a?r?{shouldPersist:!0}:this.genericPaymentMethodError():{shouldPersist:!1}}isRedesign(){return!0}getCompletionViolationActions(t,a){return[{violations:[...Le,"MERCHANDISE_NOT_APPLICABLE",be,...ut,...gt,...pt,"LOCALIZATION_EXTENSION_FIELD_ERROR",...we,...He,"DELIVERY_WRONG_NUMBER_OF_DELIVERY_LINES",...Ia,...fa,...Ra,...ea,"PAYMENTS_METHOD_REQUIRED","PAYMENTS_METHOD",...Na,...ba,...ta,"PAYMENTS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN","BUYER_IDENTITY_MISSING_CONTACT_METHOD",...mt,"BUYER_IDENTITY_EMAIL_REQUIRED",..._t,...Et,...lt],generateAction:()=>({action:"abort"})},{violations:[...yt,"BUYER_IDENTITY_CONTACT_INFO_DOES_NOT_MATCH_CUSTOMER_PROFILE"],generateAction:()=>({action:"abort",effects:[()=>{this.inMemoryGooglePayParts.paymentSheetError.value={type:"unexpected_terminal_error"}}]})},{violations:["DELIVERY_ZONE_NOT_FOUND"],generateAction:()=>({action:"abort",effects:[()=>this.logZoneCompletionFailure(a,"DELIVERY_ZONE_NOT_FOUND")]})},{violations:["DELIVERY_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>({action:"abort",effects:[()=>this.logZoneCompletionFailure(a,"DELIVERY_ZONE_REQUIRED_FOR_COUNTRY")]})}]}genericPaymentMethodError(){return{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_METHOD",message:this.translated.genericError}]}}}logZoneCompletionFailure(t,a){const{shippingZone:r,shippingCountry:o}=Te(t);this.observability.log("redesign_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:a,shippingZone:r,shippingCountry:o,result:t})}}class Sr extends Nt{constructor(t,a,r,o){super(t,a,o),this.inMemoryGooglePayParts=r}validateBilling(t){return t.paymentMethodData.info?.billingAddress?{shouldPersist:!0}:{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_METHOD",message:this.translated.genericError}]}}}validateShipping(t,a,r){const o=t.shippingAddress;return a?o?r&&!o.address2?{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.translated.addressLine2MissingError}]}}:{shouldPersist:!0}:{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_METHOD",message:this.translated.genericError}]}}:{shouldPersist:!1}}isRedesign(){return!1}getCompletionViolationActions(t,a){return[{violations:[...Le,"MERCHANDISE_NOT_APPLICABLE",be,...ut,...gt,...pt,"LOCALIZATION_EXTENSION_FIELD_ERROR","DELIVERY_WRONG_NUMBER_OF_DELIVERY_LINES","DELIVERY_STRATEGY_CONDITIONS_NOT_SATISFIED",...Et,...lt],generateAction:()=>({action:"abort"})},{violations:[...yt,"BUYER_IDENTITY_MISSING_CONTACT_METHOD","BUYER_IDENTITY_CONTACT_INFO_DOES_NOT_MATCH_CUSTOMER_PROFILE"],generateAction:()=>({action:"abort",effects:[()=>{this.inMemoryGooglePayParts.paymentSheetError.value={type:"unexpected_terminal_error"}}]})},{violations:we,generateAction:()=>({action:"abort",effects:[()=>{this.inMemoryGooglePayParts.paymentSheetError.value={type:"unusable_partial_address"}}]})},{violations:He,generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:"SHIPPING_ADDRESS",message:this.translated.addressUnserviceableError}]})},{violations:["DELIVERY_FIRST_NAME_REQUIRED"],generateAction:()=>j(this.translated.firstNameMissingError)},{violations:["DELIVERY_LAST_NAME_REQUIRED"],generateAction:()=>j(this.translated.lastNameMissingError)},{violations:["DELIVERY_ADDRESS1_REQUIRED"],generateAction:()=>j(this.translated.addressLine1MissingError)},{violations:["DELIVERY_ADDRESS2_REQUIRED"],generateAction:()=>j(this.translated.addressLine2MissingError)},{violations:["DELIVERY_PHONE_NUMBER_REQUIRED","DELIVERY_OPTIONS_PHONE_NUMBER_REQUIRED"],generateAction:()=>j(this.translated.phoneMissingError)},{violations:["DELIVERY_POSTAL_CODE_REQUIRED"],generateAction:()=>j(this.translated.zipMissingError)},{violations:["DELIVERY_CITY_REQUIRED"],generateAction:()=>j(this.translated.cityMissingError)},{violations:["DELIVERY_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.translated.zoneMissingError}],effects:[()=>{const{shippingZone:r,shippingCountry:o}=Te(a);this.observability.log("three_page_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:"DELIVERY_ZONE_REQUIRED_FOR_COUNTRY",shippingZone:r,shippingCountry:o,result:a})}]})},{violations:["DELIVERY_ZONE_NOT_FOUND"],generateAction:()=>{const{shippingZone:r,shippingCountry:o}=Te(a);return{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_OPTION",message:this.translated.zoneInvalidError}],effects:[()=>{this.observability.log("three_page_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:"DELIVERY_ZONE_NOT_FOUND",shippingZone:r,shippingCountry:o,result:a})}]}}},{violations:[..._t,"BUYER_IDENTITY_EMAIL_REQUIRED"],generateAction:()=>j(this.translated.emailInvalidError)},{violations:["DELIVERY_COMPANY_REQUIRED","DELIVERY_ADDRESS1_CONTAINS_EMOJIS","DELIVERY_ADDRESS1_CONTAINS_HTML_TAGS","DELIVERY_ADDRESS1_CONTAINS_MATHEMATICAL_SYMBOLS","DELIVERY_LAST_NAME_CONTAINS_URL"],generateAction:()=>j(this.translated.addressInvalid)},{violations:[...mt,"DELIVERY_OPTIONS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN","DELIVERY_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN"],generateAction:()=>j(this.translated.phoneInvalidError)},{violations:["DELIVERY_INVALID_POSTAL_CODE_FOR_ZONE","DELIVERY_INVALID_POSTAL_CODE_FOR_COUNTRY"],generateAction:()=>
1j(this.translated.zipInvalidError)},{violations:["PAYMENTS_METHOD_REQUIRED","PAYMENTS_METHOD"],generateAction:()=>Q(this.translated.genericError)},{violations:["PAYMENTS_FIRST_NAME_REQUIRED"],generateAction:()=>Q(this.translated.billingAddressFirstNameMissingError)},{violations:["PAYMENTS_LAST_NAME_REQUIRED"],generateAction:()=>Q(this.translated.lastNameMissingError)},{violations:["PAYMENTS_ADDRESS1_REQUIRED"],generateAction:()=>Q(this.translated.billingAddressLine1MissingError)},{violations:["PAYMENTS_CITY_REQUIRED"],generateAction:()=>Q(this.translated.billingAddressCityMissingError)},{violations:["PAYMENTS_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>Q(this.translated.billingAddressZoneMissingError)},{violations:["PAYMENTS_POSTAL_CODE_REQUIRED"],generateAction:()=>Q(this.translated.billingAddressZipMissingError)},{violations:["PAYMENTS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN"],generateAction:()=>Q(this.translated.billingAddressPhoneInvalidError)},{violations:[Oa],generateAction:()=>Q(this.translated.billingAddressZipInvalidError)},{violations:[Da],generateAction:()=>Q(this.translated.billingAddressZoneInvalidError)},{violations:["PAYMENTS_INVALID_POSTAL_CODE_FOR_ZONE"],generateAction:()=>Q(this.translated.billingZipInvalidError)},{violations:["PAYMENTS_ADDRESS1_CONTAINS_HTML_TAGS","PAYMENTS_CITY_CONTAINS_HTML_TAGS","PAYMENTS_LAST_NAME_CONTAINS_URL"],generateAction:()=>Q(this.translated.billingAddressInvalid)}]}}function j(e){return{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:e}]}}function Q(e){return{action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",intent:"PAYMENT_METHOD",message:e}]}}function Ar({supportsOnePage:e=!1}={}){const{i18n:t,observability:a}=$(),{inMemoryGooglePayParts:r}=te(),o=Ta(),n=me(()=>({genericError:t.translate("wallets.errors.generic",{walletName:t.translate("brand.google_pay")}),shippingMethodError:t.translate("wallets.errors.outdated.shipping_method"),currencyChangeError:t.translate("wallets.errors.detour.currency_change",{walletName:t.translate("brand.google_pay")}),addressUnserviceableError:t.translate("wallets.errors.unsupported.address"),addressInvalid:t.translate("wallets.errors.invalid.shipping_address"),phoneInvalidError:t.translate("wallets.errors.invalid.phone"),zipInvalidError:t.translate("wallets.errors.invalid.postal_code"),zoneInvalidError:t.translate("wallets.errors.invalid.zone"),firstNameMissingError:t.translate("wallets.errors.missing.first_name"),lastNameMissingError:t.translate("wallets.errors.missing.last_name"),addressLine1MissingError:t.translate("wallets.errors.missing.address1"),addressLine2MissingError:t.translate("wallets.errors.missing.address2"),zipMissingError:t.translate("wallets.errors.missing.zip"),zoneMissingError:t.translate("wallets.errors.missing.province"),cityMissingError:t.translate("wallets.errors.missing.city"),emailInvalidError:t.translate("wallets.errors.invalid.email"),phoneMissingError:t.translate("wallets.errors.missing.phone"),billingAddressInvalid:t.translate("wallets.errors.invalid.billing_address"),billingAddressPhoneInvalidError:t.translate("wallets.errors.invalid.billing_phone"),billingAddressZipInvalidError:t.translate("wallets.errors.invalid.billing_zip"),billingAddressZoneInvalidError:t.translate("wallets.errors.invalid.billing_zone"),billingZipInvalidError:t.translate("wallets.errors.invalid.billing_zip"),billingAddressLine1MissingError:t.translate("wallets.errors.missing.billing_address1"),billingAddressFirstNameMissingError:t.translate("wallets.errors.missing.billing_first_name"),billingAddressCityMissingError:t.translate("wallets.errors.missing.billing_city"),billingAddressZipMissingError:t.translate("wallets.errors.missing.billing_zip"),billingAddressZoneMissingError:t.translate("wallets.errors.missing.billing_province")}),[t]);return me(()=>e?new Pr(a,n,r,o):new Sr(a,n,r,o),[a,e,n,r,o])}function Ye(){const{persistedGooglePaySignal:e}=te(),{observability:t,checkout:a}=$(),r=Ee(),o=Ne({availableDeliveryAddresses:r.availableDeliveryAddresses?.value,mustSelectProvidedAddress:r.mustSelectProvidedAddress?.value}),n=a.configuration.addressSettings.nonBillingAddressSettings.value,{deliveryLines:s,email:u,shippingAddress:l,paymentLines:i}=Re();return W(()=>{t.leaveErrorBreadcrumb("[GooglePay] useClearGooglePayProposedState clearing proposed state");const E=aa(i.value);i.value=E,u.value="",e.value={...e.value,description:void 0},o||(Se(s,void 0),l.value=ra({countryCode:n.defaultShippingDetails.country.code,zoneCode:n.defaultShippingDetails.zone.code}))},[n.defaultShippingDetails,o,e,s,u,i,l,t])}function Ir(){const{walletUsedForSubmissionSignal:e,inMemoryGooglePayParts:{paymentSheetError:t}}=te(),a=Ye();return W(()=>{t.value=void 0,e.value=void 0,a()},[t,e,a])}const fr=1;function Rr({asPaymentMethod:e}){const{deliveryLines:t,email:a,shippingAddress:r,billingAddress:o,paymentLines:n}=Re(),{progress:s}=at(),{shop:u,checkout:l,observability:i}=$(),E=l.configuration.addressSettings.nonBillingAddressSettings,P=oa(),A=Ee(),S=A.availableDeliveryAddresses?.value,I=A.mustSelectProvidedAddress?.value,T=Ne({availableDeliveryAddresses:S,mustSelectProvidedAddress:I}),g=nt(),C=l.configuration.layout.isOnePage.value,h=u.hasFlagEnabled(Ie),R=!C&&h,y=ie(()=>l.configuration.layout.isOnePage.value||h),b=ie(()=>y.value&&Me({checkout:l}
1)),v=fe("GOOGLE_PAY"),O=Ar({supportsOnePage:y.value||b.value}),c=Ye(),D=Ca(),k=Ft(),K=xt(),ae=Ir(),d=Ua({flag:Ie,onAbort:ae,onError:ae}),{inMemoryGooglePayParts:{paymentSheetOpenPromise:m,paymentSheetError:p},persistedGooglePaySignal:M,walletUsedForSubmissionSignal:w}=te(),{trackAttempt:L,trackComplete:B}=Va(V.GooglePay),f=W(async({reason:x})=>{R?await d({wallet:"GOOGLE_PAY",reason:x,asPaymentMethod:!1,announceSubscriptionReviewLayoutSwitch:x==="subscriptions"}):(l.wallets.setEscalatedWallet("GOOGLE_PAY"),K?.dispatch("addressReplaced"))},[d,R,K,l.wallets]);return W(({isShippingRequired:x,paymentData:N,cardsinkResult:H})=>new Promise(J=>{const G=performance.now();i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, attempting completion",{shippingAddressCity:N.shippingAddress?.locality??"MISSING",shippingAddressAdministrativeArea:N.shippingAddress?.administrativeArea??"MISSING",shippingAddressCountryCode:N.shippingAddress?.countryCode??"MISSING",billingAddressCity:N.paymentMethodData.info?.billingAddress?.locality??"MISSING",billingAddressAdministrativeArea:N.paymentMethodData.info?.billingAddress?.administrativeArea??"MISSING",billingAddressCountryCode:N.paymentMethodData.info?.billingAddress?.countryCode??"MISSING"}),L();const de=()=>{B({result:"failed",durationMs:performance.now()-G})},Z=N.shippingAddress,re=N.paymentMethodData.info?.billingAddress,ge=N.paymentMethodData,ye=E.value.isRequired("address2"),ce=O.validatePaymentCurrency({initialCurrencyCode:M.value?.initialCurrencyCode,currentCurrencyCode:g.current.fields.subtotal?.value?.currencyCode}),_=O.validateBilling(N),z=O.validateShipping(N,x,ye);if(i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized: validation results",{paymentValidationResult:ce,billingValidationResult:_,shippingValidationResult:z}),ce.paymentSheetAction)return de(),ue(ce.paymentSheetAction);if(_.paymentSheetAction)return de(),ue(_.paymentSheetAction);if(z.paymentSheetAction)return de(),ue(z.paymentSheetAction);if(_.shouldPersist&&re&&(o.value=Ce({googleAddress:re,isFirstNameRequired:E.value.isRequired("firstName")})),z.shouldPersist&&Z){const U=Z.iso3166AdministrativeArea;k({postalCode:Z.postalCode,countryCode:Z.countryCode,city:Z.locality,zoneCode:U},"GOOGLE_PAY"),T||(r.value=Ce({googleAddress:Z,isFirstNameRequired:E.value.isRequired("firstName")}))}const X=A.buyerIdentity.value?.customerProfile?.email||N.email;X&&(a.value=X),D(),M.value={...M.value,description:ge.description,receiptIdForPaymentFailure:void 0};const q=n.value,{signature:Oe,signedMessage:he,protocolVersion:bt}=N.paymentMethodData.tokenizationData.token?JSON.parse(N.paymentMethodData.tokenizationData.token):{signature:"",signedMessage:"",protocolVersion:""},Ot=U=>{if(U){if(H&&"error"in H)return i.leaveErrorBreadcrumb("[GooglePay] Cardsink deposit failed in sandbox",{error:H.error}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"failed",instrument:V.GooglePay}}),ue({action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",message:"Failed to process payment",intent:"PAYMENT_AUTHORIZATION"}]}),!1;H&&"sessionId"in H&&(i.leaveErrorBreadcrumb("[GooglePay] Using sessionId from sandbox cardsink",{sessionId:H.sessionId}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"success",instrument:V.GooglePay}}),n.value=ze(q,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{protocolVersion:"",signature:"",signedMessage:"",sessionId:H.sessionId,paymentMethodIdentifier:v.value?.paymentMethodIdentifier}}}))}return!0},Dt=()=>{const U=g.current.fields.paymentDue.value,Y=U&&U.amount>0||P.value;return H?Ot(Y):(Y&&(n.value=ze(q,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{signature:Oe,signedMessage:he,protocolVersion:bt,paymentMethodIdentifier:v.value?.paymentMethodIdentifier}}})),!0)};let oe=0;const Tt=Ga(g.current.fields.deliveryNext?.value),ke=async()=>{let U=!1;i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion attempt",{attemptNumber:oe}),await s("google-pay-payment-authorized",async Y=>{i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion result",{result:{status:Y.status,violations:("violations"in Y?Y.violations:[])||[],errors:("errors"in Y?Y.errors:[])||[]}}),Y.status==="success"&&(w.value="GOOGLE_PAY"),(Y.status==="denied"||Y.status==="throttled"||Y.status==="tooManyRequests")&&c();const pe=Y,Ct=pe.status==="rejected"&&pe.violations.some(Mt=>Mt.code===be),{shouldRetry:Gt,retryReason:Ue,updatedDeliveryMethodHandles:Ve}=Nr(pe,oe,g,Tt);if(Ve&&Se(t,Ve),Gt&&!Ct){oe++,i.counter({name:"wallet_submit_for_completion_retry",value:1,attributes:{retry_reason:Ue,retry_count:oe,status:pe.status,instrument:V.GooglePay}}),i.log("payment_authorized_completion_retried",`GooglePay::usePaymentAuthorized: Retrying ${Ue} completion`,{attemptNumber:oe}),ke();return}const ve=O.completionResultMapper.mapResultToPaymentSheetAction(pe,{options:{asPaymentMethod:e}});i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment sheet action mapper result",{paymentSheetAction:ve});const Be=ve.action==="show_error"||ve.action==="abort"?"failed":"success";try{await ue(ve)}finally{B({result:Be,durationMs:performance.now()-G,attributes:{retry_count:oe>0?oe.toString():void 0}}),i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, authorization result",{authorizationResult:Be}),y.value&&(Y.status==="rejected"||Y.status==="invalid")&&(p.value||(p.value={type:"recovery_notice"}),R?U=!0:f({reason:"submitForCompletion"}))}},{skipToCompletion:!0,customizeCompletion:Ma}),U&&f({reason:"submitForCompletion"})};Dt()&&(b.value?ue({action:"decelerate",effects:[()=>{p.value=void 0}]}).finally(()=>f({reason:"subscriptions"})).catch(U=>{i.leaveErrorBreadcrumb("[Google Pay] Failed to handle payment sheet action:",{err:U})}):ke());async function ue(U){if(U.effects?.forEach(Y=>Y()),U.action==="show_error"){i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, resolving with error",{paymentSheetAction:U}),J({transactionState:"ERROR",error:U.errors?.[0]});return}else i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, resolving with success"),J({transactionState:"SUCCESS"}),await m.value}}),[E,e,c,v,A,P,g,m,O,M,s,o,t,a,n,r,w,k,i,p,D,T,y,b,f,R,L,B])}function Nr(e,t,a,r){const o={shouldRetry:!1,retryReason:"",updatedDeliveryMethodHandles:void 0};if(t>=fr)return o;if(e.status==="stale")return{shouldRetry:!0,retryReason:"stale",updatedDeliveryMethodHandles:void 0};if(e.status==="fetch_failed")return{shouldRetry:!0,retryReason:"fetch_failed",updatedDeliveryMethodHandles:void 0};if(e.status==="rejected"&&e.violations?.length){const n=La(e,a.current.fields.deliveryNext?.peek(),r);if(n)return{shouldRetry:!0,retryReason:"delivery_option_mismatch",updatedDeliveryMethodHandles:n}}return o}const je={paymentMethod:{walletPaymentMethod:{name:"GOOGLE_PAY",walletContent:{googlePayWalletContent:{signature:"",signedMessage:"",protocolVersion:""}}}},amount:{any:!0}};function br({googlePayTransactionId:e}){const{deliveryLines:t,shippingAddress:a}
1=Re(),r=ft(),{checkout:o,i18n:n,observability:s,shop:u}=$(),l=o.configuration.addressSettings.nonBillingAddressSettings,i=Ye(),{persistedGooglePaySignal:E}=te(),P=wa(),A=Ee(),{value:S}=A.deliveryNext,I=A.availableDeliveryAddresses?.value,T=A.mustSelectProvidedAddress?.value,g=Ne({availableDeliveryAddresses:I,mustSelectProvidedAddress:T}),C=o.isShippingRequired.value&&!g,h=tt(u),R=o.configuration.layout.isOnePage.value,y=u.hasFlagEnabled(Ie),b=R||y,v=ie(()=>b&&Me({checkout:o})),O=W(d=>d.reduce((m,p,M)=>M===d.length-1?n.translate("shipping.shipping_method_combinations.combination",{rest:m,current:p}):n.translate("shipping.shipping_method_combinations.with_separator",{rest:m,current:p}),""),[n]),c=me(()=>({businessDays:d=>n.translate("shipping.estimated_delivery_date",{count:d}),businessDaysRange:(d,m)=>n.translate("shipping.estimated_delivery_date_range",{minimum:d,maximum:m}),subscriptionsOnlyShippingTitle:n.translate("shipping.subscription_shipping"),combineTwoShippingTitles:(d,m)=>n.translate("shipping.shipping_method_combinations.combination",{rest:d,current:m}),combineMultipleShippingTitles:O}),[n,O]),D=W(({intent:d,trigger:m,result:p})=>{if(p.errors.some(G=>Le.has(G.code)))return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, stock problems"),{reason:"OTHER_ERROR",intent:d,message:n.translate("wallets.errors.detour.stock_problems",{walletName:n.translate("brand.google_pay")})};if(p.errors.some(G=>G.code===be))return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, price mismatch"),{reason:"OTHER_ERROR",intent:d,message:n.translate("wallets.errors.detour.price_change",{walletName:n.translate("brand.google_pay")})};if(p.errors.some(G=>na.has(G.code)))return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, delivery zone not found",{zoneCode:p.negotiated.shippingAddress?.zoneCode,countryCode:p.negotiated.shippingAddress?.countryCode}),{reason:"SHIPPING_ADDRESS_INVALID",intent:d,message:n.translate("wallets.errors.invalid.zone")};if(p.errors.some(G=>He.includes(G.code)))return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, no delivery strategy",{zoneCode:p.negotiated.shippingAddress?.zoneCode,countryCode:p.negotiated.shippingAddress?.countryCode}),{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:d,message:n.translate("wallets.errors.unsupported.address")};if(!sa(p.negotiated.paymentMethods,"GOOGLE_PAY"))return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, google pay unavailable"),{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:d,message:n.translate("wallets.errors.unsupported.wallet_is_unavailable",{walletName:n.translate("brand.google_pay")})};const x=E.value;if(x?.initialCurrencyCode!==p.negotiated.subtotal?.currencyCode)return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, currency change",{beforeCurrencyCode:x?.initialCurrencyCode,afterCurrencyCode:p.negotiated.subtotal?.currencyCode}),{reason:"OTHER_ERROR",intent:d,message:n.translate("wallets.errors.detour.currency_change",{walletName:n.translate("brand.google_pay")})};const H=m==="INITIALIZE";if(p.errors.some(G=>we.includes(G.code))&&!H)return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, delivery line changed"),{reason:"SHIPPING_OPTION_INVA
1LID",intent:d,message:n.translate("wallets.errors.outdated.shipping_method")}},[E,n,s]),k=W(({result:d,intent:m,trigger:p,resolve:M,reject:w,shippingOptionId:L,destinationCountry:B,destinationRegion:f,abortSignal:x})=>{function N(){return w({reason:"OTHER_ERROR",message:n.translate("wallets.errors.generic",{walletName:n.translate("brand.google_pay")}),intent:m})}if(x.aborted)return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged result arrived after the session was aborted"),N();switch(s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged received negotiation result",{status:d.status,intent:m,trigger:p}),d.status){case"success":{if(d.negotiated.paymentDue==null)return s.error(new Pe("Missing negotiated paymentDue",{groupingHash:"GooglePayGenericError::MissingNegotiatedPaymentDue"})),N();const H=la(d.negotiated.deliveryNext),J=e.value,G=er({...d.negotiated,labels:r,i18nCurrency:n.currency,translations:c,selectedShippingId:L,deliveryMacros:H,googlePayTransactionId:J,shouldWalletDecelerateForSubscriptions:v.value,discountsZeroValueUXEnabled:h});if(G.error=D({intent:m,trigger:p,result:d}),C&&!G.newShippingOptionParameters&&!G.error){const Z=d.negotiated.deliveryNext&&d.negotiated.deliveryNext.status!=="unavailable"?d.negotiated.deliveryNext.lines:[],re={wallet:"google_pay",intent:m,trigger:p,googlePayTransactionId:J,destinationCountry:B,destinationRegion:f,deliveryNextStatus:d.negotiated.deliveryNext?.status,deliveryLineCount:Z.length,deliveryLineStatuses:Z.map(ge=>ge.status).join(",")};s.log("google_pay_missing_shipping_options","wallet_missing_shipping_options",re),s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged resolved with no shipping options and no error",re)}return s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged handleNegotiationResult",{result:d.status,intent:m,trigger:p,transactionInfo:G.newTransactionInfo?JSON.stringify(G.newTransactionInfo):"MISSING"}),M(G)}case"throttled":return i(),w({reason:"OTHER_ERROR",message:n.translate("wallets.errors.detour.queue",{walletName:n.translate("brand.google_pay")}),intent:m});case"tooManyRequests":case"denied":case"alreadyCompleted":return i(),N();case"invalid":return d.reasons.includes(ia.SubmittedForCompletion)?(s.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"invalid",intent:m,trigger:p,reasons:d.reasons}),s.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"invalid"}}
1)):s.error(new mr("Received unhandled invalid result",{groupingHash:"GooglePayInvalidError::UnhandledInvalidResult"}),{metadata:{request:{reasons:d.reasons}}}),N();case"stale":return s.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"stale",intent:m,trigger:p}),s.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"stale"}}),N();case"fetch_failed":return s.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"fetch_failed",intent:m,trigger:p,fetchFailureReason:d.reason,isActionable:d.isActionable,networkError:d.networkError??!1}),s.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"fetch_failed"}}),N();case"unexpected_error":return s.error(new _r("Negotiation threw during the Google Pay session",{groupingHash:"GooglePayNegotiationError::NegotiationThrew",cause:d.error}),{metadata:{request:{intent:m,trigger:p,error:String(d.error)}}}),N();default:return s.error(new Pe(`Unhandled negotiation status: ${d.status}`,{groupingHash:"GooglePayGenericError::UnhandledNegotiationStatus"}),{metadata:{request:{intent:m,trigger:p,violations:d.violations.map(H=>H.code)}}}),N()}},[i,n,r,c,D,s,v,C,e,h]),K=W((d,m,p)=>m?new Promise((M,w)=>{dt(S)||Se(t,void 0);const L=p==="INITIALIZE"?d.initiallySelectedShippingOptionId:void 0,B=or({googleAddress:m,isFirstNameRequired:l.value.isRequired("firstName")});s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiating for handleShippingAddressSelected",{trigger:p,city:m.locality,administrativeArea:m.administrativeArea,countryCode:m.countryCode}),g||(a.value=B),P({abortSignal:d.abortController.signal,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:f=>({...We(f,B,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:g,availableDeliveryAddresses:I,negotiatedDelivery:S}),payment:{...f.payment,totalAmount:{any:!0},paymentLines:Qe(f.payment?.paymentLines,je)}}),observability:s,walletName:V.GooglePay,onComplete:f=>k({result:f,intent:"SHIPPING_ADDRESS",trigger:p,resolve:M,reject:w,destinationCountry:m.countryCode,destinationRegion:m.administrativeArea,...L&&{shippingOptionId:L},abortSignal:d.abortController.signal}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingAddressSelected"}).catch(f=>{k({result:f instanceof Ze?{status:"stale"}:{status:"unexpected_error",error:f},intent:"SHIPPING_ADDRESS",trigger:p,resolve:M,reject:w,destinationCountry:m.countryCode,destinationRegion:m.administrativeArea,abortSignal:d.abortController.signal})})}):Promise.resolve({}),[l,k,a,t,P,s,S,g,I]),ae=W((d,m,p)=>new Promise((M,w)=>{let L;try{L=Ha(Ka(m))}catch{return s.error(new Pe(`Invalid shippingOptionId format: ${m}`,{groupingHash:"GooglePayGenericError::InvalidShippingOptionId"}
1)),M({error:{reason:"SHIPPING_OPTION_INVALID",message:n.translate("general.choose_delivery_strategy"),intent:"SHIPPING_OPTION"}})}Se(t,L);const B=a.value;s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiating for handleShippingMethodSelected",{trigger:p}),P({abortSignal:d,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:f=>({...We(f,B,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:g,availableDeliveryAddresses:I,negotiatedDelivery:S}),payment:{...f.payment,totalAmount:{any:!0},paymentLines:Qe(f.payment?.paymentLines,je)}}),observability:s,walletName:V.GooglePay,onComplete:f=>k({result:f,intent:"SHIPPING_OPTION",trigger:p,resolve:M,reject:w,shippingOptionId:m,abortSignal:d}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingMethodSelected"}).catch(f=>{k({result:f instanceof Ze?{status:"stale"}:{status:"unexpected_error",error:f},intent:"SHIPPING_OPTION",trigger:p,resolve:M,reject:w,shippingOptionId:m,abortSignal:d})})}),[k,n,a,t,P,s,g,I,S]);return W(async({sessionData:d,intermediatePaymentData:m})=>{function p(B,f,x){return{error:{reason:B,message:f,intent:x}}}const{shippingAddress:M,shippingOptionData:w,callbackTrigger:L}=m;switch(L){case"INITIALIZE":case"SHIPPING_ADDRESS":return K(d,M,L);case"SHIPPING_OPTION":return w?.id?ae(d.abortController.signal,w.id,L):p("SHIPPING_OPTION_INVA
1LID",n.translate("general.choose_delivery_strategy"),"SHIPPING_OPTION");default:return s.error(new Pe(`Could not recognize the intent: ${L}`,{groupingHash:"GooglePayGenericError::CannotRecognizeIntent"})),s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged could not recognize the intent",{callbackTrigger:L}),p("OTHER_ERROR",n.translate("wallets.errors.generic",{walletName:n.translate("brand.google_pay")}),"SHIPPING_ADDRESS")}},[K,ae,s,n])}const Or="QIbE6",Dr={GooglePayButtonContainerSpinnerDisplayed:Or};function jr({asPaymentMethod:e=!1}){const t=ne(null),a=_e(null),r=ne(!1),o=ne(0),{isScrimOpen:n,closePopupWindowsAndScrim:s}=ua({endpoint:a,invokingWallet:"GOOGLE_PAY"}),u=zt(),l=Rt(),i=fe("GOOGLE_PAY").value,{value:E}=Ee().deliveryNext,{i18n:P,observability:A,checkout:{wallets:S,proposal:I},client:{userAgent:T},shop:g}=$(),C=ne({abortController:Ke(),initiallySelectedShippingOptionId:void 0}),h=_e(void 0),{inMemoryGooglePayParts:{sdkStatus:R,buttonStatus:y}}=te(),{markAsLoaded:b}=da(),v=ne(!0),O=ne(!1),c=ir({asPaymentMethod:e}),D=ne(null),{checkoutCardsinkCallerIdentificationSignature:k}=I.negotiated.fields,K=me(()=>{if(!g.cardsinkUrl)return;const _=window.location.host;return{isLocalDev:_.endsWith("checkout.my.shop.dev")||_.endsWith("checkout.shop.dev"),cardsinkUrl:g.cardsinkUrl,callerIdentificationJwt:k.value}},[g.cardsinkUrl,k]),ae=e?P.translate("wallets.call_to_action",{walletName:""}):void 0,d=P.translate("brand.google_pay"),m=hr({endpoint:a,isTerminated:r,color:u,config:i,merchantInfo:l.value,buttonLabel:ae,ariaLabel:d,markAsLoaded:b,sdkStatus:R,sdkStatusRef:t,buttonStatus:y,paymentDataRequest:c,containerRef:D,asPaymentMethod:e,isFirstRender:v,updateSdkStatus:Xe,connectedNullPaymentDataRequest:O,cardsinkConfig:K}),p=yr({paymentDataRequest:c,asPaymentMethod:e,isScrimOpen:n,containerRef:D,endpoint:a}),M=Er(n),w=br({googlePayTransactionId:h}),L=Rr({asPaymentMethod:e}),B=ma(),f=ga();function x(_){A.log("google_pay_callback_timing","[GooglePay] callback progress",_,{requiresKeepalive:!0});const{scope:z,callback:X,outcome:q,durationMs:Oe}=_;if(q==="progress")return;const he={scope:z,callback:X,outcome:q};A.counter({name:"google_pay_callback_events",value:1,attributes:he}),(q==="resolved"||q==="rejected")&&A.histogram({name:"google_pay_callback_duration",value:Oe,unit:"ms",attributes:he})}function N(_,z){let X=!1;return Za({scope:"host",callback:_,stage:"checkout",trigger:z,googlePayTransactionId:h.peek(),log:q=>{q.outcome==="started"?(X=!0,o.current++):X&&(q.outcome==="resolved"||q.outcome==="rejected")&&(X=!1,o.current--),x(q)}})}function H(_){try{A.log("google_pay_sandbox_lifecycle","[GooglePay] sandbox lifecycle",{stage:_,googlePayTransactionId:h.peek(),pendingHostCallbacksInComponent:o.current},{requiresKeepalive:!0})}catch{}}const J=pa({onPaymentAuthorized:_=>N("authorization").observe(()=>L(_)),onPaymentDataChanged:_=>N("shipping",_.callbackTrigger).observe(()=>w({sessionData:C.current,intermediatePaymentData:_})),onClick:async({transactionId:_}={})=>(_&&(h.value=_),dt(E)&&(C.current.initiallySelectedShippingOptionId=Pt(Qt({proposedDeliveryLines:I.proposed.deliveryLines}))),await p()),onResponse:_=>{H("wallet_response_received");const z=C.current.abortController;C.current={abortController:Ke(),initiallySelectedShippingOptionId:void 0};const X=M(_);return z.abort(),X},telemetry:B,breadcrumb:_=>{if(_.message==="[GooglePay Sandbox] callback progress"||_.message==="[GooglePay Sandbox] loadPaymentData started"||_.message==="[GooglePay Sandbox] loadPaymentData resolved"){try{_.message==="[GooglePay Sandbox] callback progress"?Wa(_.attributes)&&x(_.attributes):A.log("google_pay_sheet_progress",_.message,_.attributes,{requiresKeepalive:!0})}catch{}return}f(_)}});Lt(()=>{const _=!v.current||O.current;a.value&&c.value&&_&&(O.current=!1,a.value.call.updatePaymentDataRequest(c.value))}),wt(()=>(Xe({status:"loading"},R,t),()=>{const _=R.value,z=y.value;_===t.current&&z.status!=="error"&&(R.value={status:"idle"},y.value={status:"not_rendered"},S.activeSession.value?.wallet==="GOOGLE_PAY"&&S.clearActiveSession({invokingWallet:"GOOG
1LE_PAY"}))}),[]);const G=e?lr:void 0,de=ee(xe,{inlineAlignment:"center",children:ee(qt,{size:"large"})}),Z=!za(T),re=et(!Z),ge=ee(Zt,{isOpen:n,isInvisible:re,onClick:s,children:Z&&ee(Wt,{handleClose:s,walletName:P.translate("brand.google_pay")})}),ye=ee(Fe,{children:[ee(_a,{wallet:Ge,onConnect:m,onTerminate:()=>{H("endpoint_terminated"),r.current=!0,a.value=null},hostMethods:J,ref:D,height:G}),ge]}),ce=e&&y.value.status!=="rendered"&&y.value.status!=="error";return e?ee(Fe,{children:[ce&&de,ee(xe,{className:Ht({[Dr.GooglePayButtonContainerSpinnerDisplayed]:ce}),children:ye})]}):ye}function Xe(e,t,a){a.current=e,t.value=a.current}function Ke(){return new AbortController}export{jr as default};

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.