PageSourceSearch

https://ambapress.com.au/cdn/shopifycloud/checkout-web/assets/c1/component-GooglePayButton.3YG2gYjp.js

js ambapress.com.au collected 2026-09-26 07:39:33 UTC 55,451 bytes, 1 lines download raw bytes

1import{f as ie,G as Je,T as me,l as et,e as _e,q as W,A as ne,p as Lt,h as wt,u as ee,g as Ht,S as Fe}from"./esnext-vendor.B9Da21W6.js";import{fA as fe,fz as Yt,cj as kt,g9 as tt,fd as Ut,f as at,eW as Vt,fl as Bt,fe as Ft,ga as Se,gb as xt,fD as zt,fc as Wt,bw as Zt,fG as qt,fF as $t,B as xe,S as Qt,gc as jt}from"./hydrate.DZ4YTm7p.js";import{dn as Xt,gJ as rt,gK as Ae,eD as ot,gL as Kt,b1 as Jt,aL as ea,S as Q,af as nt,a4 as Ee,T as Re,gM as Ie,a$ as Ge,gN as be,ae as te,aw as st,ax as it,cP as Le,gO as Ne,dm as ta,dl as aa,C as lt,gP as ra,b5 as oa,ag as na,v as ze,gQ as sa,gR as ia,bk as la,gS as da,b2 as dt}from"./addresses-is-address-empty.Bn2lNY_L.js";import{e as ca}from"./stopwatch.CfKlh48v.js";import{S as De,u as ua,a as ga}from"./hooks-useStableHostMethodsReferences.DObnt9s8.js";import{u as pa,W as ma}from"./WalletsSandbox-WalletSandbox.Bnd2Qnah.js";import{v as _a}from"./dist-v4.EwEgHOG0.js";import{i as ct,c as Ea}from"./graphql-PaymentSessionMutation.CAXCwUvV.js";import{f as F,g as ya,s as ha,r as va,B as Pa,P as Sa,T as ut,U as gt,V as pt,D as we,N as He,a as Aa,b as Ia,c as fa,d as Ra,e as ba,h as mt,E as _t,I as Et,i as yt,j as Te,k as Na,l as Oa,u as Da,m as Ta,n as Ca,o as Ma,p as Ga,q as La,t as We,S as Ze,v as wa}from"./wallets-deserialize-delivery-handles.BOkgrwan.js";import{a as Ha,g as Ya}from"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import{a as U,c as se,b as qe}from"./cross-border-hooks.xPE4TSQ5.js";import{a as ht}from"./PayButton-helpers.Cc_ffyKs.js";import{S as ue}from"./app.DbSrjjlA.js";import{a as ka,u as Ua}from"./hooks-useWalletsThreePageVaultedReviewEscalation.DI1pRNwr.js";import{r as $e}from"./redemption-promotions.DicFJEgz.js";import"./hooks-useReplaceShopPayInHistory.DPpLejwu.js";import"./amazon-pay-useAmazonPayPaymentLine.Ju006AId.js";import"./AddressPresenter.BIgrto4P.js";import"./hooks-useShowShopPayOptin.Br0M25ky.js";import"./MarketsProDisclaimer.BqGHM17j.js";import"./shared-buyer-consent.B_gDyRCR.js";const Va=/^[A-Z]{1,2}[0-9]{1,2}[A-Z]?$/,Ba=/^[A-Z][0-9][A-Z]$/;function Fa(e){const{countryCode:t,postalCode:a}=e;if(a==null)return e;const r=a.trim().toUpperCase();return t==="CA"&&Ba.test(r)?e.postalCode=`${r} 0Z0`:t==="GB"&&Va.test(r)&&(e.postalCode=`${r} 0ZZ`),e}function xa(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 za(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 Wa({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=_a(),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 Za=2,qa=0,$a={apiVersion:Za,apiVersionMinor:qa},vt="%";function Qa(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}
1const 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 ja(e){return St(ha(e))}function Xa(e){const t=new RegExp(`[${vt}]`,"g");return e.replace(t,'"')}function Ka(e,t){const a=Jt(e).filter(ea).map(Ha);return Ya(a).filter(o=>o.length).map(o=>({id:ja(o),label:Qa(o,t),description:o.map(It).join(", ")}))}function Ja({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?or(I):Ka(o,A),N=!!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:N,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,N=!!I?.lines?.length,v=[];I?.lines&&I.lines.forEach(c=>{v.push({label:ya(c),type:"LINE_ITEM",price:F(c.totalPrice.amount)}),ar(c,g).forEach(D=>{v.push(D)})}),t&&v.push({label:l.subtotal,type:"SUBTOTAL",price:F(t.amount)}),tr(n?.lines,g).forEach(c=>{v.push(c)});const O=Xt(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(N&&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} ${c.method.code.slice(-4).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 er(e){return Ea(e.discountDetails.discount)&&e.discountDetails.discount.presentationLevel==="LINE"}function tr(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 ar(e,t){const a=new Map;return e.lineAllocations.forEach(r=>{r.allocations.filter(er).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&&Kt.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 rr({googleAddress:e,isFirstNameRequired:t}){return Fa(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 or(e){return e.map(({totalTitle:t,totalCostAfterDiscounts:a,deliveryPromisePresentmentTitle:r,deliveryMethodHandles:o})=>({id:Pt(o),label:t,description:It({costAfterDiscounts:a,deliveryPromisePresentmentTitle:r})}))}function nr(){const{checkout:e}
1=Q(),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}=Q();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}}=Q(),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 sr({asPaymentMethod:e}){const t=nt(),a=Rt(),r=nr(),{checkout:o,i18n:n,shop:s}=Q(),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&&Ge({checkout:o})),C=et(e);return ie(()=>{const h=!C.value&&!be({availableDeliveryAddresses:u.availableDeliveryAddresses?.value,mustSelectProvidedAddress:u.mustSelectProvidedAddress?.value})&&o.isShippingRequired.value,R=h?["PAYMENT_AUTHORIZATION","SHIPPING_ADDRESS","SHIPPING_OPTION"]:["PAYMENT_AUTHORIZATION"],y=va(t,{includeShopPromotion:!1}),N=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||!N||N.length===0&&h||y.paymentDue==null||y.subtotal==null)return null;const c=o.configuration.addressSettings.nonBillingAddressSettings.value,D=Je(()=>c.isRequired("phone")),Y=!!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:N,phoneNumberRequired:D},shippingAddressRequired:h,shippingOptionRequired:h,transactionInfo:At({labels:i,i18nCurrency:n.currency,...y,hasPayableDeposit:Y,shouldWalletDecelerateForSubscriptions:g.value,discountsZeroValueUXEnabled:A})}})}const Me="GOOGLE_PAY",ir="54px",lr="FAILED_TO_OPEN_WINDOW",dr="VALIDATION_TIMEOUT";class Pe extends ue{constructor(){super(...arguments),this.name="GooglePayGenericError"}}class cr extends ue{constructor(){super(...arguments),this.name="GooglePayCreateButtonError"}}class ur extends ue{constructor(){super(...arguments),this.name="GooglePayDeveloperError"}}class gr extends ue{constructor(){super(...arguments),this.name="GooglePayUnexpectedStatusCodeError"}}class Qe extends ue{constructor(){super(...arguments),this.name="GooglePaySubmissionError"}}class pr extends ue{constructor(){super(...arguments),this.name="GooglePayInvalidError"}}function mr(e){const t=ht(U.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}}=Q(),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:U.GooglePay}}):i.counter({name:"wallet_sheet_failed",value:1,attributes:{instrument:U.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 ur(`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 dr:i.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: VALIDATION_TIMEOUT"),t(se.Failure);break;case lr: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 gr(`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 _r({paymentDataRequest:e,asPaymentMethod:t,isScrimOpen:a,containerRef:r,endpoint:o}){const n=Ut(),{negotiate:s}=at(),{observability:u,checkout:{wallets:l},client:{userAgent:i}}=Q(),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(U.GooglePay),N=Vt(U.GooglePay),v=Bt(U.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:Y=>{Y?.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{N();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:U.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,N,o,I,P,a,S,s,A,e,T,g,C,R,h,u,y,l])}function Er({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}=Q();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 N=await y.call.configure({isDark:a==="dark",environment:r?.environment,merchantInfo:o,buttonLabel:n,ariaLabel:s,paymentDataRequest:P.value,style:{borderRadius:Ft(A.current)},cardsinkConfig:C,sourceId:R.sourceId});I.current=!1,u(),N.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:Me,status:"success",isPaymentMethodFlow:S}}))):(h.leaveErrorBreadcrumb("[GooglePay] useOnConnect configuration failed",{status:N.status}),N.status===De.Error&&yr({result:N,observability:h}),E.value={status:"error"},h.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:Me,status:"error",isPaymentMethodFlow:S,reason:N.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 yr({result:{type:e,name:t,message:a},observability:r}){e==="createButton"&&r.error(new cr(a,{cause:{name:t,message:a}}),{metadata:{additionalKey:{name:t,message:a}}})}class bt extends Pa{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:U.GooglePay}}),{paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.currencyChangeError}]}})}get completionResultMapper(){return new Sa({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 Qe(`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:U.GooglePay}}),this.reportAddressRequirementMismatch({violationCode:s,wallet:U.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 Qe(`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 hr extends bt{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",Ne,...ut,...gt,...pt,"LOCALIZATION_EXTENSION_FIELD_ERROR",...we,...He,"DELIVERY_WRONG_NUMBER_OF_DELIVERY_LINES",...Aa,...Ia,...fa,...ta,"PAYMENTS_METHOD_REQUIRED","PAYMENTS_METHOD",...Ra,...ba,...aa,"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 vr extends bt{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",Ne,...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:()=>$(this.translated.genericError)},{violations:["PAYMENTS_FIRST_NAME_REQUIRED"],generateAction:()=>$(this.translated.billingAddressFirstNameMissingError)},{violations:["PAYMENTS_LAST_NAME_REQUIRED"],generateAction:()=>$(this.translated.lastNameMissingError)},{violations:["PAYMENTS_ADDRESS1_REQUIRED"],generateAction:()=>$(this.translated.billingAddressLine1MissingError)},{violations:["PAYMENTS_CITY_REQUIRED"],generateAction:()=>$(this.translated.billingAddressCityMissingError)},{violations:["PAYMENTS_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>$(this.translated.billingAddressZoneMissingError)},{violations:["PAYMENTS_POSTAL_CODE_REQUIRED"],generateAction:()=>$(this.translated.billingAddressZipMissingError)},{violations:["PAYMENTS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN"],generateAction:()=>$(this.translated.billingAddressPhoneInvalidError)},{violations:[Na],generateAction:()=>$(this.translated.billingAddressZipInvalidError)},{violations:[Oa],generateAction:()=>$(this.translated.billingAddressZoneInvalidError)},{violations:["PAYMENTS_INVALID_POSTAL_CODE_FOR_ZONE"],generateAction:()=>$(this.translated.billingZipInvalidError)},{violations:["PAYMENTS_ADDRESS1_CONTAINS_HTML_TAGS","PAYMENTS_CITY_CONTAINS_HTML_TAGS","PAYMENTS_LAST_NAME_CONTAINS_URL"],generateAction:()=>$(this.translated.billingAddressInvalid)}]}}function j(e){return{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:e}]}}function $(e){return{action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",intent:"PAYMENT_METHOD",message:e}]}}function Pr({supportsOnePage:e=!1}={}){const{i18n:t,observability:a}=Q(),{inMemoryGooglePayParts:r}=te(),o=Da(),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 hr(a,n,r,o):new vr(a,n,r,o),[a,e,n,r,o])}function Ye(){const{persistedGooglePaySignal:e}=te(),{observability:t,checkout:a}=Q(),r=Ee(),o=be({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=ra(i.value);i.value=E,u.value="",e.value={...e.value,description:void 0},o||(Se(s,void 0),l.value=oa({countryCode:n.defaultShippingDetails.country.code,zoneCode:n.defaultShippingDetails.zone.code}))},[n.defaultShippingDetails,o,e,s,u,i,l,t])}function Sr(){const{walletUsedForSubmissionSignal:e,inMemoryGooglePayParts:{paymentSheetError:t}}=te(),a=Ye();return W(()=>{t.value=void 0,e.value=void 0,a()},[t,e,a])}const Ar=1;function Ir({asPaymentMethod:e}){const{deliveryLines:t,email:a,shippingAddress:r,billingAddress:o,paymentLines:n}=Re(),{progress:s}=at(),{shop:u,checkout:l,observability:i}=Q(),E=l.configuration.addressSettings.nonBillingAddressSettings,P=na(),A=Ee(),S=A.availableDeliveryAddresses?.value,I=A.mustSelectProvidedAddress?.value,T=be({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),N=ie(()=>y.value&&Ge({checkout:l}
1)),v=fe("GOOGLE_PAY"),O=Pr({supportsOnePage:y.value||N.value}),c=Ye(),D=Ta(),Y=xt(),K=zt(),ae=Sr(),d=ka({flag:Ie,onAbort:ae,onError:ae}),{inMemoryGooglePayParts:{paymentSheetOpenPromise:m,paymentSheetError:p},persistedGooglePaySignal:G,walletUsedForSubmissionSignal:w}=te(),{trackAttempt:L,trackComplete:V}=Ua(U.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:b,cardsinkResult:B})=>new Promise(J=>{const M=performance.now();i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, attempting completion",{shippingAddressCity:b.shippingAddress?.locality??"MISSING",shippingAddressAdministrativeArea:b.shippingAddress?.administrativeArea??"MISSING",shippingAddressCountryCode:b.shippingAddress?.countryCode??"MISSING",billingAddressCity:b.paymentMethodData.info?.billingAddress?.locality??"MISSING",billingAddressAdministrativeArea:b.paymentMethodData.info?.billingAddress?.administrativeArea??"MISSING",billingAddressCountryCode:b.paymentMethodData.info?.billingAddress?.countryCode??"MISSING"}),L();const le=()=>{V({result:"failed",durationMs:performance.now()-M})},Z=b.shippingAddress,re=b.paymentMethodData.info?.billingAddress,ge=b.paymentMethodData,ye=E.value.isRequired("address2"),de=O.validatePaymentCurrency({initialCurrencyCode:G.value?.initialCurrencyCode,currentCurrencyCode:g.current.fields.subtotal?.value?.currencyCode}),_=O.validateBilling(b),z=O.validateShipping(b,x,ye);if(i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized: validation results",{paymentValidationResult:de,billingValidationResult:_,shippingValidationResult:z}),de.paymentSheetAction)return le(),ce(de.paymentSheetAction);if(_.paymentSheetAction)return le(),ce(_.paymentSheetAction);if(z.paymentSheetAction)return le(),ce(z.paymentSheetAction);if(_.shouldPersist&&re&&(o.value=Ce({googleAddress:re,isFirstNameRequired:E.value.isRequired("firstName")})),z.shouldPersist&&Z){const k=Z.iso3166AdministrativeArea;Y({postalCode:Z.postalCode,countryCode:Z.countryCode,city:Z.locality,zoneCode:k},"GOOGLE_PAY"),T||(r.value=Ce({googleAddress:Z,isFirstNameRequired:E.value.isRequired("firstName")}))}const X=A.buyerIdentity.value?.customerProfile?.email||b.email;X&&(a.value=X),D(),G.value={...G.value,description:ge.description,receiptIdForPaymentFailure:void 0};const q=n.value,{signature:Oe,signedMessage:he,protocolVersion:Nt}=b.paymentMethodData.tokenizationData.token?JSON.parse(b.paymentMethodData.tokenizationData.token):{signature:"",signedMessage:"",protocolVersion:""},Ot=k=>{if(k){if(B&&"error"in B)return i.leaveErrorBreadcrumb("[GooglePay] Cardsink deposit failed in sandbox",{error:B.error}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"failed",instrument:U.GooglePay}}),ce({action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",message:"Failed to process payment",intent:"PAYMENT_AUTHORIZATION"}]}),!1;B&&"sessionId"in B&&(i.leaveErrorBreadcrumb("[GooglePay] Using sessionId from sandbox cardsink",{sessionId:B.sessionId}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"success",instrument:U.GooglePay}}),n.value=ze(q,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{protocolVersion:"",signature:"",signedMessage:"",sessionId:B.sessionId,paymentMethodIdentifier:v.value?.paymentMethodIdentifier}}}))}return!0},Dt=()=>{const k=g.current.fields.paymentDue.value,H=k&&k.amount>0||P.value;return B?Ot(H):(H&&(n.value=ze(q,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{signature:Oe,signedMessage:he,protocolVersion:Nt,paymentMethodIdentifier:v.value?.paymentMethodIdentifier}}})),!0)};let oe=0;const Tt=Ca(g.current.fields.deliveryNext?.value),ke=async()=>{let k=!1;i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion attempt",{attemptNumber:oe}),await s("google-pay-payment-authorized",async H=>{i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion result",{result:{status:H.status,violations:("violations"in H?H.violations:[])||[],errors:("errors"in H?H.errors:[])||[]}}),H.status==="success"&&(w.value="GOOGLE_PAY"),(H.status==="denied"||H.status==="throttled"||H.status==="tooManyRequests")&&c();const pe=H,Ct=pe.status==="rejected"&&pe.violations.some(Gt=>Gt.code===Ne),{shouldRetry:Mt,retryReason:Ue,updatedDeliveryMethodHandles:Ve}=fr(pe,oe,g,Tt);if(Ve&&Se(t,Ve),Mt&&!Ct){oe++,i.counter({name:"wallet_submit_for_completion_retry",value:1,attributes:{retry_reason:Ue,retry_count:oe,status:pe.status,instrument:U.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 ce(ve)}finally{V({result:Be,durationMs:performance.now()-M,attributes:{retry_count:oe>0?oe.toString():void 0}}),i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, authorization result",{authorizationResult:Be}),y.value&&(H.status==="rejected"||H.status==="invalid")&&(p.value||(p.value={type:"recovery_notice"}),R?k=!0:f({reason:"submitForCompletion"}))}},{skipToCompletion:!0,customizeCompletion:Ma}),k&&f({reason:"submitForCompletion"})};Dt()&&(N.value?ce({action:"decelerate",effects:[()=>{p.value=void 0}]}).finally(()=>f({reason:"subscriptions"})).catch(k=>{i.leaveErrorBreadcrumb("[Google Pay] Failed to handle payment sheet action:",{err:k})}):ke());async function ce(k){if(k.effects?.forEach(H=>H()),k.action==="show_error"){i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, resolving with error",{paymentSheetAction:k}),J({transactionState:"ERROR",error:k.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,G,s,o,t,a,n,r,w,Y,i,p,D,T,y,N,f,R,L,V])}function fr(e,t,a,r){const o={shouldRetry:!1,retryReason:"",updatedDeliveryMethodHandles:void 0};if(t>=Ar)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=Ga(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 Rr({googlePayTransactionId:e}){const{deliveryLines:t,shippingAddress:a}
1=Re(),r=ft(),{checkout:o,i18n:n,observability:s,shop:u}=Q(),l=o.configuration.addressSettings.nonBillingAddressSettings,i=Ye(),{persistedGooglePaySignal:E}=te(),P=La(),A=Ee(),{value:S}=A.deliveryNext,I=A.availableDeliveryAddresses?.value,T=A.mustSelectProvidedAddress?.value,g=be({availableDeliveryAddresses:I,mustSelectProvidedAddress:T}),C=o.isShippingRequired.value&&!g,h=tt(u),R=o.configuration.layout.isOnePage.value,y=u.hasFlagEnabled(Ie),N=R||y,v=ie(()=>N&&Ge({checkout:o})),O=W(d=>d.reduce((m,p,G)=>G===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(M=>Le.has(M.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(M=>M.code===Ne))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(M=>sa.has(M.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(M=>He.includes(M.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(!ia(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 B=m==="INITIALIZE";if(p.errors.some(M=>we.includes(M.code))&&!B)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]),Y=W(({result:d,intent:m,trigger:p,resolve:G,reject:w,shippingOptionId:L,destinationCountry:V,destinationRegion:f,abortSignal:x})=>{function b(){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"),b();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"})),b();const B=da(d.negotiated.deliveryNext),J=e.value,M=Ja({...d.negotiated,labels:r,i18nCurrency:n.currency,translations:c,selectedShippingId:L,deliveryMacros:B,googlePayTransactionId:J,shouldWalletDecelerateForSubscriptions:v.value,discountsZeroValueUXEnabled:h});if(M.error=D({intent:m,trigger:p,result:d}),C&&!M.newShippingOptionParameters&&!M.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:V,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:M.newTransactionInfo?JSON.stringify(M.newTransactionInfo):"MISSING"}),G(M)}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(),b();case"invalid":return d.reasons.includes(la.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 pr("Received unhandled invalid result",{groupingHash:"GooglePayInvalidError::UnhandledInvalidResult"}),{metadata:{request:{reasons:d.reasons}}}),b();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"}}),b();default:return s.error(new Pe(`Unhandled negotiation status: ${d.status}${"error"in d&&d.error?`, ${d.error}`:""}`,{groupingHash:"GooglePayGenericError::UnhandledNegotiationStatus"})),b()}},[i,n,r,c,D,s,v,C,e,h]),K=W((d,m,p)=>m?new Promise((G,w)=>{dt(S)||Se(t,void 0);const L=p==="INITIALIZE"?d.initiallySelectedShippingOptionId:void 0,V=rr({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=V),P({abortSignal:d.abortController.signal,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:f=>({...We(f,V,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:g,availableDeliveryAddresses:I,negotiatedDelivery:S}),payment:{...f.payment,totalAmount:{any:!0},paymentLines:$e(f.payment?.paymentLines,je)}}),observability:s,walletName:U.GooglePay,onComplete:f=>Y({result:f,intent:"SHIPPING_ADDRESS",trigger:p,resolve:G,reject:w,destinationCountry:m.countryCode,destinationRegion:m.administrativeArea,...L&&{shippingOptionId:L},abortSignal:d.abortController.signal}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingAddressSelected"}).catch(f=>{Y({result:f instanceof Ze?{status:"stale"}:{status:"unexpected_error",error:f},intent:"SHIPPING_ADDRESS",trigger:p,resolve:G,reject:w,destinationCountry:m.countryCode,destinationRegion:m.administrativeArea,abortSignal:d.abortController.signal})})}):Promise.resolve({}),[l,Y,a,t,P,s,S,g,I]),ae=W((d,m,p)=>new Promise((G,w)=>{let L;try{L=wa(Xa(m))}catch{return s.error(new Pe(`Invalid shippingOptionId format: ${m}`,{groupingHash:"GooglePayGenericError::InvalidShippingOptionId"}
1)),G({error:{reason:"SHIPPING_OPTION_INVALID",message:n.translate("general.choose_delivery_strategy"),intent:"SHIPPING_OPTION"}})}Se(t,L);const V=a.value;s.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiating for handleShippingMethodSelected",{trigger:p}),P({abortSignal:d,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:f=>({...We(f,V,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:g,availableDeliveryAddresses:I,negotiatedDelivery:S}),payment:{...f.payment,totalAmount:{any:!0},paymentLines:$e(f.payment?.paymentLines,je)}}),observability:s,walletName:U.GooglePay,onComplete:f=>Y({result:f,intent:"SHIPPING_OPTION",trigger:p,resolve:G,reject:w,shippingOptionId:m,abortSignal:d}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingMethodSelected"}).catch(f=>{Y({result:f instanceof Ze?{status:"stale"}:{status:"unexpected_error",error:f},intent:"SHIPPING_OPTION",trigger:p,resolve:G,reject:w,shippingOptionId:m,abortSignal:d})})}),[Y,n,a,t,P,s,g,I,S]);return W(async({sessionData:d,intermediatePaymentData:m})=>{function p(V,f,x){return{error:{reason:V,message:f,intent:x}}}const{shippingAddress:G,shippingOptionData:w,callbackTrigger:L}=m;switch(L){case"INITIALIZE":case"SHIPPING_ADDRESS":return K(d,G,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 br="QIbE6",Nr={GooglePayButtonContainerSpinnerDisplayed:br};function Qr({asPaymentMethod:e=!1}){const t=ne(null),a=_e(null),r=ne(!1),o=ne(0),{isScrimOpen:n,closePopupWindowsAndScrim:s}=Wt({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}=Q(),C=ne({abortController:Ke(),initiallySelectedShippingOptionId:void 0}),h=_e(void 0),{inMemoryGooglePayParts:{sdkStatus:R,buttonStatus:y}}=te(),{markAsLoaded:N}=ca(),v=ne(!0),O=ne(!1),c=sr({asPaymentMethod:e}),D=ne(null),{checkoutCardsinkCallerIdentificationSignature:Y}=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:Y.value}},[g.cardsinkUrl,Y]),ae=e?P.translate("wallets.call_to_action",{walletName:""}):void 0,d=P.translate("brand.google_pay"),m=Er({endpoint:a,isTerminated:r,color:u,config:i,merchantInfo:l.value,buttonLabel:ae,ariaLabel:d,markAsLoaded:N,sdkStatus:R,sdkStatusRef:t,buttonStatus:y,paymentDataRequest:c,containerRef:D,asPaymentMethod:e,isFirstRender:v,updateSdkStatus:Xe,connectedNullPaymentDataRequest:O,cardsinkConfig:K}),p=_r({paymentDataRequest:c,asPaymentMethod:e,isScrimOpen:n,containerRef:D,endpoint:a}),G=mr(n),w=Rr({googlePayTransactionId:h}),L=Ir({asPaymentMethod:e}),V=pa(),f=ua();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 b(_,z){let X=!1;return Wa({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 B(_){try{A.log("google_pay_sandbox_lifecycle","[GooglePay] sandbox lifecycle",{stage:_,googlePayTransactionId:h.peek(),pendingHostCallbacksInComponent:o.current},{requiresKeepalive:!0})}catch{}}const J=ga({onPaymentAuthorized:_=>b("authorization").observe(()=>L(_)),onPaymentDataChanged:_=>b("shipping",_.callbackTrigger).observe(()=>w({sessionData:C.current,intermediatePaymentData:_})),onClick:async({transactionId:_}={})=>(_&&(h.value=_),dt(E)&&(C.current.initiallySelectedShippingOptionId=Pt(jt({proposedDeliveryLines:I.proposed.deliveryLines}))),await p()),onResponse:_=>{B("wallet_response_received");const z=C.current.abortController;C.current={abortController:Ke(),initiallySelectedShippingOptionId:void 0};const X=G(_);return z.abort(),X},telemetry:V,breadcrumb:_=>{if(_.message==="[GooglePay Sandbox] callback progress"||_.message==="[GooglePay Sandbox] loadPaymentData started"||_.message==="[GooglePay Sandbox] loadPaymentData resolved"){try{_.message==="[GooglePay Sandbox] callback progress"?za(_.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 M=e?ir:void 0,le=ee(xe,{inlineAlignment:"center",children:ee(Qt,{size:"large"})}),Z=!xa(T),re=et(!Z),ge=ee($t,{isOpen:n,isInvisible:re,onClick:s,children:Z&&ee(qt,{handleClose:s,walletName:P.translate("brand.google_pay")})}),ye=ee(Fe,{children:[ee(ma,{wallet:Me,onConnect:m,onTerminate:()=>{B("endpoint_terminated"),r.current=!0,a.value=null},hostMethods:J,ref:D,height:M}),ge]}),de=e&&y.value.status!=="rendered"&&y.value.status!=="error";return e?ee(Fe,{children:[de&&le,ee(xe,{className:Ht({[Nr.GooglePayButtonContainerSpinnerDisplayed]:de}),children:ye})]}):ye}function Xe(e,t,a){a.current=e,t.value=a.current}function Ke(){return new AbortController}export{Qr 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.