1import{k as e,M as t,T as a,s as r,o,q as n,g as s,p as i,h as l,u as d,m as u,S as c}from"./2c1ab0fe.qpvfywqb.js";import{fI as g,fH as p,cF as m,g6 as y,g7 as _,g8 as h,fp as v,v as E,k as P,g9 as b,ga as A,aN as I,gb as f,fN as S,fM as R,b as N,c as C,gc as O}from"./164ad2e3.DcJn775M.js";import{dg as T,ga as D,gb as M,da as G,ef as w,gc as L,aA as k,aw as H,e as Y,c8 as U,aW as B,gd as F,aa as V,aK as x,aL as j,S as z,ge as Z,df as q,de as W,gf as $,gg as Q,aZ as K,ab as X,d0 as J,gh as ee,gi as te,gj as ae,bb as re,gk as oe,aX as ne}from"./4b4bc88f.DkycdxSK.js";import{c as se}from"./71ae3d5c.ChDO3fdz.js";import{g as ie,u as le}from"./cb8fcd45.D3zibvVj.js";import{u as de,a as ue}from"./3a819064.WIoncAIO.js";import{u as ce,W as ge}from"./8536083a.IvjmFsYB.js";import{v as pe}from"./2210eadb.DF0gIp_2.js";import{a as me,b as ye}from"./f67abd2c.CNaB0QaR.js";import{f as _e,g as he,s as ve,r as Ee,B as Pe,P as be,T as Ae,U as Ie,V as fe,D as Se,N as Re,a as Ne,b as Ce,c as Oe,d as Te,e as De,h as Me,E as Ge,I as we,i as Le,j as ke,k as He,l as Ye,u as Ue,m as Be,n as Fe,o as Ve,p as xe,q as je,t as ze,S as Ze,v as qe}from"./13b13169.Cb1_vpIS.js";import{a as We,g as $e}from"./e12db40c.DhbHW8sF.js";import{a as Qe,c as Ke,b as Xe}from"./78ab3dd0.DsAxQUAi.js";import{b as Je}from"./ed9f2238.Brwxl8Yi.js";import{S as et}from"./app.DH8n-1bp.js";import{u as tt,b as at}from"./89e2d30a.C7YQuTRu.js";import{g as rt,a as ot,u as nt}from"./33464469.-7QSUaH-.js";import{S as st}from"./ee2bb050.DwFu9ie-.js";import{r as it}from"./d25d1b95.CoPrVoCi.js";import"./d0bb51ec.CWfbNPnY.js";import"./9dba8418.4R19B40l.js";import"./60a453ce.DBFo6PRx.js";import"./1d34c07e.h4dJAaCz.js";import"./22345fd4.Bc95vVsB.js";import"./cdfd59e6.C61oFvbb.js";import"./7fc410e0.Bp5sUnag.js";import"./17e57de1.lSRGFmhc.js";import"./ca3e798e.XLlup-KR.js";const lt=/^[A-Z]{1,2}[0-9]{1,2}[A-Z]?$/,dt=/^[A-Z][0-9][A-Z]$/,ut={apiVersion:2,apiVersionMinor:0};function ct(e,t){const a=e.find(e=>"ONE_TIME_PURCHASE"===e.deliveryLine.type),r=e.find(e=>"SUBSCRIPTION"===e.deliveryLine.type);let o="";if(r){if("PICK_UP"===r.methodType||"LOCAL"===r.methodType)return r.title;o=r.title}const n=[a?.title??"",o].filter(Boolean),[s,i]=n;return void 0===s?"":void 0===i?s:2===n.length?t.combineTwoShippingTitles(s,i):t.combineMultipleShippingTitles(n)}function gt(e){return pt(JSON.stringify(e))}function pt(e){return e.replace(/["']/g,"%")}function mt({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:i,labels:l,i18nCurrency:d,checkoutTotal:u,deferredTotal:c,hasPayableDeposit:g,googlePayTransactionId:p,merchandiseLines:m,shouldWalletDecelerateForSubscriptions:y=!1,discountsZeroValueUXEnabled:_=!1}){const h=e?_e(e.amount):"0",v=g&&u&&c,E=v?_e(u.amount):void 0,P=v?_e(c.amount.amount):void 0,b=Boolean(m?.lines?.length),A=[];m?.lines&&m.lines.forEach(e=>{A.push({label:he(e),type:"LINE_ITEM",price:_e(e.totalPrice.amount)}),function(e,t){const a=new Map;return e.lineAllocations.forEach(e=>{e.allocations.filter(yt).forEach(e=>{const{title:t}=e.discountDetails;a.set(t,(a.get(t)??0)+e.amount.amount)})}),Array.from(a).filter(([,e])=>!t||0!==e).map(([e,t])=>({label:e,type:"LINE_ITEM",price:0===t?_e(t):M(_e(t))}))}(e,_).forEach(e=>{A.push(e)})}),t&&A.push({label:l.subtotal,type:"SUBTOTAL",price:_e(t.amount)}),function(e,t){return e?e.flatMap(e=>{if(!me(e))return[];if(!D(e))return[];const a=e.amount?.amount;if(void 0===a)return[];if(t&&0===a)return[];const r=_e(a);return[{label:e.title,type:"LINE_ITEM",price:0===a?r:M(r)}]}):[]}(n?.lines,_).forEach(e=>{A.push(e)});const I=T(o).reduce((e,t)=>e+t.method.cost.amount,0);return A.push({label:l.shipping,type:"LINE_ITEM",price:_e(I)}),a&&"available_total"===a?.status&&0!==a?.totalDuty.amount&&A.push({label:l.duties,type:"LINE_ITEM",price:_e(a.totalDuty.amount)}),r&&"available_total"===r.status&&0!==r.totalTax.amount&&A.push({label:l.taxes,type:"LINE_ITEM",price:_e(r.totalTax.amount)}),n?.lines.forEach(e=>{if(me(e)){if(b&&"LINE"===e.discount.presentationLevel&&"delivery"!==e.sourceTerm)return;if(D(e))return;const t=e.amount?.amount;t&&A.push({label:e.title,type:"LINE_ITEM",price:M(_e(t))})}}),i?.lines.filter(e=>
1"giftCard"===e.method.type).forEach(e=>{e.cost&&A.push({label:`${l.giftCard} ${G(e.method).toUpperCase()}`,type:"LINE_ITEM",price:M(_e(e.cost.amount))})}),s?.forEach(e=>{A.push({label:l.tip,type:"LINE_ITEM",price:_e(e.amount.amount)})}),E&&A.push({label:l.deposit,type:"LINE_ITEM",price:E}),P&&A.push({label:l.totalDueLater,type:"LINE_ITEM",price:P}),{totalPrice:E||h,currencyCode:t?.currencyCode||d,totalPriceStatus:"ESTIMATED",totalPriceLabel:E?l.totalDueToday:l.total,displayItems:A,...p&&{transactionId:p},...y&&{checkoutOption:"CONTINUE_TO_REVIEW"}}}function yt(e){return ye(e.discountDetails.discount)&&"LINE"===e.discountDetails.discount.presentationLevel}function _t({googleAddress:e,isFirstNameRequired:t}){let a=e.iso3166AdministrativeArea||void 0,r=e.locality||void 0,o=e.countryCode;"AE"===e.countryCode&&(r=e.administrativeArea),e.countryCode&&L.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[a,...r]=(e.name||"").split(" ");0===r.length?(n.lastName=a,t&&(n.firstName=n.lastName)):(n.firstName=a,n.lastName=r.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 ht({costAfterDiscounts:e,deliveryPromisePresentmentTitle:t}){const{short:a}=t||{};return`${a?`(${a}) `:""}${_e(e.amount)} ${e.currencyCode}`}function vt(e,t){e.log("google_pay_authorization_decelerated","Google Pay authorization decelerated",t)}function Et(){const{i18n:e}=Y();return a(()=>({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 Pt(){const{shop:{name:t,myshopifyDomain:a}}=Y(),r=g("GOOGLE_PAY");return e(()=>{const e=r.value;return void 0===e?void 0:{merchantName:t,merchantId:e.merchantId,merchantOrigin:a,authJwt:e.authJwt}})}const bt="GOOGLE_PAY";class At extends et{constructor(){super(...arguments),this.name="GooglePayGenericError"}}class It extends et{constructor(){super(...arguments),this.name="GooglePayCreateButtonError"}}class ft extends et{constructor(){super(...arguments),this.name="GooglePayDeveloperError"}}class St extends et{constructor(){super(...arguments),this.name="GooglePayUnexpectedStatusCodeError"}}class Rt extends et{constructor(){super(...arguments),this.name="GooglePaySubmissionError"}}class Nt extends et{constructor(){super(...arguments),this.name="GooglePayInvalidError"}}class Ct extends et{constructor(){super(...arguments),this.name="GooglePayNegotiationError"}}function Ot({currentPage:e,plan:t},a){const r=new Set;if(!e)return r;const o=t.greenPath.findIndex(t=>_(t,e));for(const n of t.greenPath.slice(0,o+1))for(const e of h(n,a))r.add(e);return r}class Tt extends Pe{constructor(e,t,a){super(),this.observability=e,this.translated=t,this.reportAddressRequirementMismatch=a}get negotiationResultMapper(){return null}validatePaymentCurrency({initialCurrencyCode:e,currentCurrencyCode:t}){return null==e||null==t?(this.observability.leaveErrorBreadcrumb("[GooglePay] validatePaymentCurrency skipped currency comparison, missing currency code",{initialCurrencyCode:e,currentCurrencyCode:t}),{}):e===t?(this.observability.log("google_pay_validate_payment_currency_succeeded","[GooglePay] validatePaymentCurrency succeeded, currency codes match",{currencyCode:t}),{}):(this.observability.leaveErrorBreadcrumb("[GooglePay] validatePaymentCurrency blocking submission, currency change",{initialCurrencyCode:e,currentCurrencyCode:t}),this.observability.counter({name:"wallet_action_generator_handled_error",value:1,attributes:{violationCode:"CURRENCY_CHANGE",WalletName:Qe.GooglePay}}),{paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.currencyChangeError}]}})}get completionResultMapper(){return new be({success:({result:e})=>"receipt"in e?{action:"submit"}:{action:"abort"},rejected:({result:e,violationActions:t,options:a})=>{const r=e.violations??[];
1this.getUnhandledErrors(r,t).forEach(e=>{this.observability.error(new Rt(`submitForCompletion in ${this.isRedesign()?"redesign":"3-page"} Google Pay failed due to unhandled error ${e.code}`,{groupingHash:`GooglePaySubmissionError::SubmitForCompletion::UnhandledError::${e.code}`}),{severity:"error"})});const{firstPaymentSheetAction:o,violationCode:n}=this.getMergedPaymentSheetAction({resultViolations:r,violationActions:t});return n&&this.observability.counter({name:"wallet_action_generator_handled_error",value:1,attributes:{violationCode:n,WalletName:Qe.GooglePay}}),this.reportAddressRequirementMismatch({violationCode:n,wallet:Qe.GooglePay,asPaymentMethod:Boolean(a?.asPaymentMethod),outcome:this.isRedesign()?"decelerate":o?.action??"abort"}),this.logCompletionDeceleration({asPaymentMethod:Boolean(a?.asPaymentMethod),layout:a?.layout,violationCode:n??r.at(0)?.code??"unknown",violations:r.map(e=>e.code).join(",")}),o||{action:"abort"}},invalid:({result:e,options:t})=>{const a={reasons:JSON.stringify(e.reasons),action:"invalid"};return this.observability.counter({name:"WalletsPlatform_google_pay_payment_sheet_unexpected_action",value:1,attributes:a}),this.logCompletionDeceleration({asPaymentMethod:Boolean(t?.asPaymentMethod),layout:t?.layout,violationCode:e.reasons.at(0)??"unknown",violations:e.reasons.join(",")}),{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}]})},e=>this.mapUnhandledStatus(e),(e,t)=>this.getCompletionViolationActions(e,t))}logCompletionDeceleration(e){this.isRedesign()&&vt(this.observability,{reason:"submitForCompletion",...e})}mapUnhandledStatus(e){return this.observability.error(new Rt(`Unhandled completion status: ${e.status}`,{groupingHash:`GooglePaySubmissionError::UnhandledCompletionStatus::${e.status}`})),{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.genericError}]}}}class Dt extends Tt{constructor(e,t,a,r){super(e,t,r),this.inMemoryGooglePayParts=a}validateBilling(e){const t=e.paymentMethodData.info?.billingAddress;return t?{shouldPersist:!0}:this.genericPaymentMethodError()}validateShipping(e,t){const a=e.shippingAddress;return t?a?{shouldPersist:!0}:this.genericPaymentMethodError():{shouldPersist:!1}}isRedesign(){return!0}getCompletionViolationActions(e,t){return[{violations:[...z,"MERCHANDISE_NOT_APPLICABLE",Z,...Ae,...Ie,...fe,"LOCALIZATION_EXTENSION_FIELD_ERROR",...Se,...Re,"DELIVERY_WRONG_NUMBER_OF_DELIVERY_LINES",...Ne,...Ce,...Oe,...q,"PAYMENTS_METHOD_REQUIRED","PAYMENTS_METHOD",...Te,...De,...W,"PAYMENTS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN","BUYER_IDENTITY_MISSING_CONTACT_METHOD",...Me,"BUYER_IDENTITY_EMAIL_REQUIRED",...Ge,...we,...$],generateAction:()=>({action:"abort"})},{violations:[...Le,"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(t,"DELIVERY_ZONE_NOT_FOUND")]})},{violations:["DELIVERY_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>({action:"abort",effects:[()=>this.logZoneCompletionFailure(t,"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(e,t){const{shippingZone:a,shippingCountry:r}=ke(e);this.observability.log("redesign_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:t,shippingZone:a,shippingCountry:r,result:e})}}class Mt extends Tt{constructor(e,t,a,r){super(e,t,r),this.inMemoryGooglePayParts=a}validateBilling(e){const t=e.paymentMethodData.info?.billingAddress;return t?{shouldPersist:!0}:{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_METHOD",message:this.translated.genericError}]}}}validateShipping(e,t,a){const r=e.shippingAddress;return t?r?a&&!r.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(e,t){return[{violations:[...z,"MERCHANDISE_NOT_APPLICABLE",Z,...Ae,...Ie,...fe,"LOCALIZATION_EXTENSION_FIELD_ERROR","DELIVERY_WRONG_NUMBER_OF_DELIVERY_LINES","DELIVERY_STRATEGY_CONDITIONS_NOT_SATISFIED",...we,...$],generateAction:()=>({action:"abort"})},{violations:[...Le,"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:Se,generateAction:()=>({action:"abort",effects:[()=>{this.inMemoryGooglePayParts.paymentSheetError.value={type:"unusable_partial_address"}}]})},{violations:Re,generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:"SHIPPING_ADDRESS",message:this.translated.addressUnserviceableError}]})},{violations:["DELIVERY_FIRST_NAME_REQUIRED"],generateAction:()=>Gt(this.translated.firstNameMissingError)},{violations:["DELIVERY_LAST_NAME_REQUIRED"],generateAction:()=>Gt(this.translated.lastNameMissingError)},{violations:["DELIVERY_ADDRESS1_REQUIRED"],generateAction:()=>Gt(this.translated.addressLine1MissingError)},{violations:["DELIVERY_ADDRESS2_REQUIRED"],generateAction:()=>Gt(this.translated.addressLine2MissingError)},{violations:["DELIVERY_PHONE_NUMBER_REQUIRED","DELIVERY_OPTIONS_PHONE_NUMBER_REQUIRED"],generateAction:()=>Gt(this.translated.phoneMissingError)},{violations:["DELIVERY_POSTAL_CODE_REQUIRED"],generateAction:()=>Gt(this.translated.zipMissingError)},{violations:["DELIVERY_CITY_REQUIRED"],generateAction:()=>Gt(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:e,shippingCountry:a}=ke(t);this.observability.log("three_page_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:"DELIVERY_ZONE_REQUIRED_FOR_COUNTRY",shippingZone:e,shippingCountry:a,result:t})}]})},{violations:["DELIVERY_ZONE_NOT_FOUND"],generateAction:()=>{const{shippingZone:e,shippingCountry:a}=ke(t);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:e,shippingCountry:a,result:t})}]}}},{violations:[...Ge,"BUYER_IDENTITY_EMAIL_REQUIRED"],generateAction:()=>Gt(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:()=>Gt(this.translated.addressInvalid)},{violations:[...Me,"DELIVERY_OPTIONS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN","DELIVERY_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN"],generateAction:()=>Gt(this.translated.phoneInvalidError)},{violations:["DELIVERY_INVALID_POSTAL_CODE_FOR_ZONE","DELIVERY_INVALID_POSTAL_CODE_FOR_COUNTRY"],generateAction:()=>
1Gt(this.translated.zipInvalidError)},{violations:["PAYMENTS_METHOD_REQUIRED","PAYMENTS_METHOD"],generateAction:()=>wt(this.translated.genericError)},{violations:["PAYMENTS_FIRST_NAME_REQUIRED"],generateAction:()=>wt(this.translated.billingAddressFirstNameMissingError)},{violations:["PAYMENTS_LAST_NAME_REQUIRED"],generateAction:()=>wt(this.translated.lastNameMissingError)},{violations:["PAYMENTS_ADDRESS1_REQUIRED"],generateAction:()=>wt(this.translated.billingAddressLine1MissingError)},{violations:["PAYMENTS_CITY_REQUIRED"],generateAction:()=>wt(this.translated.billingAddressCityMissingError)},{violations:["PAYMENTS_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>wt(this.translated.billingAddressZoneMissingError)},{violations:["PAYMENTS_POSTAL_CODE_REQUIRED"],generateAction:()=>wt(this.translated.billingAddressZipMissingError)},{violations:["PAYMENTS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN"],generateAction:()=>wt(this.translated.billingAddressPhoneInvalidError)},{violations:[He],generateAction:()=>wt(this.translated.billingAddressZipInvalidError)},{violations:[Ye],generateAction:()=>wt(this.translated.billingAddressZoneInvalidError)},{violations:["PAYMENTS_INVALID_POSTAL_CODE_FOR_ZONE"],generateAction:()=>wt(this.translated.billingZipInvalidError)},{violations:["PAYMENTS_ADDRESS1_CONTAINS_HTML_TAGS","PAYMENTS_CITY_CONTAINS_HTML_TAGS","PAYMENTS_LAST_NAME_CONTAINS_URL"],generateAction:()=>wt(this.translated.billingAddressInvalid)}]}}function Gt(e){return{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:e}]}}function wt(e){return{action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",intent:"PAYMENT_METHOD",message:e}]}}function Lt(){const{persistedGooglePaySignal:e}=V(),{observability:t,checkout:a}=Y(),r=F({availableDeliveryAddresses:a.negotiator.current.fields.availableDeliveryAddresses?.value,mustSelectProvidedAddress:a.negotiator.current.fields.mustSelectProvidedAddress?.value}),o=a.configuration.addressSettings.nonBillingAddressSettings.value,{deliveryLines:s,email:i,shippingAddress:l,paymentLines:d}=a.negotiator.parts;return n(()=>{t.leaveErrorBreadcrumb("[GooglePay] useClearGooglePayProposedState clearing proposed state");const a=Q(d.value);d.value=a,i.value="",e.value={...e.value,description:void 0},r||(b(s,void 0),l.value=K({countryCode:o.defaultShippingDetails.country.code,zoneCode:o.defaultShippingDetails.zone.code}))},[o.defaultShippingDetails,r,e,s,i,d,l,t])}const kt={paymentMethod:{walletPaymentMethod:{name:"GOOGLE_PAY",walletContent:{googlePayWalletContent:{signature:"",signedMessage:"",protocolVersion:""}}}},amount:{any:!0}};function Ht({googlePayTransactionId:t}){const r=Et(),{checkout:o,i18n:s,observability:i,shop:l}=Y(),{deliveryLines:d,shippingAddress:u}=o.negotiator.parts,c=o.configuration.addressSettings.nonBillingAddressSettings,g=Lt(),{persistedGooglePaySignal:p}=V(),m=je(),{value:_}=o.negotiator.current.fields.deliveryNext,h=o.negotiator.current.fields.availableDeliveryAddresses?.value,v=o.negotiator.current.fields.mustSelectProvidedAddress?.value,E=F({availableDeliveryAddresses:h,mustSelectProvidedAddress:v}),P=o.isShippingRequired.value&&!E,A=y(l),I=o.configuration.layout.isOnePage.value,f=l.hasFlagEnabled(U),S=I||f,R=e(()=>S&&B({checkout:o})),N=n(e=>e.reduce((t,a,r)=>r===e.length-1?s.translate("shipping.shipping_method_combinations.combination",{rest:t,current:a}):s.translate("shipping.shipping_method_combinations.with_separator",{rest:t,current:a}),""),[s]),C=a(()=>({businessDays:e=>s.translate("shipping.estimated_delivery_date",{count:e}),businessDaysRange:(e,t)=>
1s.translate("shipping.estimated_delivery_date_range",{minimum:e,maximum:t}),subscriptionsOnlyShippingTitle:s.translate("shipping.subscription_shipping"),combineTwoShippingTitles:(e,t)=>s.translate("shipping.shipping_method_combinations.combination",{rest:e,current:t}),combineMultipleShippingTitles:N}),[s,N]),O=n(({intent:e,trigger:t,result:a})=>{if(a.errors.some(e=>z.has(e.code)))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, stock problems"),{reason:"OTHER_ERROR",intent:e,message:s.translate("wallets.errors.detour.stock_problems",{walletName:s.translate("brand.google_pay")})};if(a.errors.some(e=>e.code===Z))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, price mismatch"),{reason:"OTHER_ERROR",intent:e,message:s.translate("wallets.errors.detour.price_change",{walletName:s.translate("brand.google_pay")})};if(a.errors.some(e=>te.has(e.code)))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, delivery zone not found",{zoneCode:a.negotiated.shippingAddress?.zoneCode,countryCode:a.negotiated.shippingAddress?.countryCode}),{reason:"SHIPPING_ADDRESS_INVALID",intent:e,message:s.translate("wallets.errors.invalid.zone")};if(a.errors.some(e=>Re.includes(e.code)))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, no delivery strategy",{zoneCode:a.negotiated.shippingAddress?.zoneCode,countryCode:a.negotiated.shippingAddress?.countryCode}),{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:e,message:s.translate("wallets.errors.unsupported.address")};if(!ae(a.negotiated.paymentMethods,"GOOGLE_PAY"))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, google pay unavailable"),{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:e,message:s.translate("wallets.errors.unsupported.wallet_is_unavailable",{walletName:s.translate("brand.google_pay")})};const r=p.value;if(r?.initialCurrencyCode!==a.negotiated.subtotal?.currencyCode)return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, currency change",{beforeCurrencyCode:r?.initialCurrencyCode,afterCurrencyCode:a.negotiated.subtotal?.currencyCode}),{reason:"OTHER_ERROR",intent:e,message:s.translate("wallets.errors.detour.currency_change",{walletName:s.translate("brand.google_pay")})};const o="INITIALIZE"===t;return a.errors.some(e=>Se.includes(e.code))&&!o?(i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, delivery line changed"),{reason:"SHIPPING_OPTION_INVA
1LID",intent:e,message:s.translate("wallets.errors.outdated.shipping_method")}):void 0},[p,s,i]),T=n(({result:e,intent:a,trigger:o,resolve:n,reject:l,shippingOptionId:d,destinationCountry:u,destinationRegion:c,abortSignal:p})=>{function m(){return l({reason:"OTHER_ERROR",message:s.translate("wallets.errors.generic",{walletName:s.translate("brand.google_pay")}),intent:a})}if(p.aborted)return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged result arrived after the session was aborted"),m();switch(i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged received negotiation result",{status:e.status,intent:a,trigger:o}),e.status){case"success":{if(null==e.negotiated.paymentDue)return i.error(new At("Missing negotiated paymentDue",{groupingHash:"GooglePayGenericError::MissingNegotiatedPaymentDue"})),m();const l=oe(e.negotiated.deliveryNext),g=t.value,p=function({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:i,checkoutTotal:l,deferredTotal:d,labels:u,i18nCurrency:c,translations:g,selectedShippingId:p,deliveryMacros:m,paymentFlexibilityPaymentTermsTemplate:y,googlePayTransactionId:_,merchandiseLines:h,shouldWalletDecelerateForSubscriptions:v=!1,discountsZeroValueUXEnabled:E=!1}){const P=m?.length?function(e){return e.map(({totalTitle:e,totalCostAfterDiscounts:t,deliveryPromisePresentmentTitle:a,deliveryMethodHandles:r})=>({id:gt(r),label:e,description:ht({costAfterDiscounts:t,deliveryPromisePresentmentTitle:a})}))}(m):function(e,t){const a=k(e).filter(H).map(We);return $e(a).filter(e=>e.length).map(e=>{return{id:(a=e,pt(ve(a))),label:ct(e,t),description:e.map(ht).join(", ")};var a})}(o,g),b=mt({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:i,labels:u,i18nCurrency:c,checkoutTotal:l,deferredTotal:d,hasPayableDeposit:Boolean(w({deferredTotal:d,checkoutTotal:l,paymentFlexibilityPaymentTermsTemplate:y})?.amount),googlePayTransactionId:_,merchandiseLines:h,shouldWalletDecelerateForSubscriptions:v,discountsZeroValueUXEnabled:E}),A=P.find(e=>e.id===p)?.id??P[0]?.id;return{...P.length>0?{newShippingOptionParameters:{shippingOptions:P,defaultSelectedOptionId:A}}:{},newTransactionInfo:b}}({...e.negotiated,labels:r,i18nCurrency:s.currency,translations:C,selectedShippingId:d,deliveryMacros:l,googlePayTransactionId:g,shouldWalletDecelerateForSubscriptions:R.value,discountsZeroValueUXEnabled:A});if(p.error=O({intent:a,trigger:o,result:e}),P&&!p.newShippingOptionParameters&&!p.error){const t=e.negotiated.deliveryNext&&"unavailable"!==e.negotiated.deliveryNext.status?e.negotiated.deliveryNext.lines:[],r={wallet:"google_pay",intent:a,trigger:o,googlePayTransactionId:g,destinationCountry:u,destinationRegion:c,deliveryNextStatus:e.negotiated.deliveryNext?.status,deliveryLineCount:t.length,deliveryLineStatuses:t.map(e=>e.status).join(",")};i.log("google_pay_missing_shipping_options","wallet_missing_shipping_options",r),i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged resolved with no shipping options and no error",r)}return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged handleNegotiationResult",{result:e.status,intent:a,trigger:o,transactionInfo:p.newTransactionInfo?JSON.stringify(p.newTransactionInfo):"MISSING"}),n(p)}case"throttled":return g(),l({reason:"OTHER_ERROR",message:s.translate("wallets.errors.detour.queue",{walletName:s.translate("brand.google_pay")}),intent:a});case"tooManyRequests":case"denied":case"alreadyCompleted":return g(),m();case"invalid":return e.reasons.includes(re.SubmittedForCompletion)?(i.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"invalid",intent:a,trigger:o,reasons:e.reasons}),i.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"invalid"}}
1)):i.error(new Nt("Received unhandled invalid result",{groupingHash:"GooglePayInvalidError::UnhandledInvalidResult"}),{metadata:{request:{reasons:e.reasons}}}),m();case"stale":return i.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"stale",intent:a,trigger:o}),i.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"stale"}}),m();case"fetch_failed":return i.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"fetch_failed",intent:a,trigger:o,fetchFailureReason:e.reason,isActionable:e.isActionable,networkError:e.networkError??!1}),i.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"fetch_failed"}}),m();case"unexpected_error":return i.error(new Ct("Negotiation threw during the Google Pay session",{groupingHash:"GooglePayNegotiationError::NegotiationThrew",cause:e.error}),{metadata:{request:{intent:a,trigger:o,error:String(e.error)}}}),m();default:return i.error(new At(`Unhandled negotiation status: ${e.status}`,{groupingHash:"GooglePayGenericError::UnhandledNegotiationStatus"}),{metadata:{request:{intent:a,trigger:o,violations:e.violations.map(e=>e.code)}}}),m()}},[g,s,r,C,O,i,R,P,t,A]),D=n((e,t,a)=>t?new Promise((r,o)=>{ne(_)||b(d,void 0);const n="INITIALIZE"===a?e.initiallySelectedShippingOptionId:void 0,s=function({googleAddress:e,isFirstNameRequired:t}){return function(e){const{countryCode:t,postalCode:a}=e;if(null==a)return e;const r=a.trim().toUpperCase();return"CA"===t&&dt.test(r)?e.postalCode=`${r} 0Z0`:"GB"===t&<.test(r)&&(e.postalCode=`${r} 0ZZ`),e}(_t({googleAddress:e,isFirstNameRequired:t}))}({googleAddress:t,isFirstNameRequired:c.value.isRequired("firstName")});i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiating for handleShippingAddressSelected",{trigger:a,city:t.locality,administrativeArea:t.administrativeArea,countryCode:t.countryCode}),E||(u.value=s),m({abortSignal:e.abortController.signal,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:e=>({...ze(e,s,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:E,availableDeliveryAddresses:h,negotiatedDelivery:_}),payment:{...e.payment,totalAmount:{any:!0},paymentLines:it(e.payment?.paymentLines,kt)}}),observability:i,walletName:Qe.GooglePay,onComplete:s=>T({result:s,intent:"SHIPPING_ADDRESS",trigger:a,resolve:r,reject:o,destinationCountry:t.countryCode,destinationRegion:t.administrativeArea,...n&&{shippingOptionId:n},abortSignal:e.abortController.signal}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingAddressSelected"}).catch(n=>{T({result:n instanceof Ze?{status:"stale"}:{status:"unexpected_error",error:n},intent:"SHIPPING_ADDRESS",trigger:a,resolve:r,reject:o,destinationCountry:t.countryCode,destinationRegion:t.administrativeArea,abortSignal:e.abortController.signal})})}):Promise.resolve({}),[c,T,u,d,m,i,_,E,h]),M=n((e,t,a)=>new Promise((r,o)=>{let n;try{n=qe(function(e){const t=new RegExp("[%]","g");return e.replace(t,'"')}(t))}catch{return i.error(new At(`Invalid shippingOptionId format: ${t}`,{groupingHash:"GooglePayGenericError::InvalidShippingOptionId"}
1)),r({error:{reason:"SHIPPING_OPTION_INVALID",message:s.translate("general.choose_delivery_strategy"),intent:"SHIPPING_OPTION"}})}b(d,n);const l=u.value;i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiating for handleShippingMethodSelected",{trigger:a}),m({abortSignal:e,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:e=>({...ze(e,l,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:E,availableDeliveryAddresses:h,negotiatedDelivery:_}),payment:{...e.payment,totalAmount:{any:!0},paymentLines:it(e.payment?.paymentLines,kt)}}),observability:i,walletName:Qe.GooglePay,onComplete:n=>T({result:n,intent:"SHIPPING_OPTION",trigger:a,resolve:r,reject:o,shippingOptionId:t,abortSignal:e}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingMethodSelected"}).catch(n=>{T({result:n instanceof Ze?{status:"stale"}:{status:"unexpected_error",error:n},intent:"SHIPPING_OPTION",trigger:a,resolve:r,reject:o,shippingOptionId:t,abortSignal:e})})}),[T,s,u,d,m,i,E,h,_]);return n(async({sessionData:e,intermediatePaymentData:t})=>{function a(e,t,a){return{error:{reason:e,message:t,intent:a}}}const{shippingAddress:r,shippingOptionData:o,callbackTrigger:n}=t;switch(n){case"INITIALIZE":case"SHIPPING_ADDRESS":return D(e,r,n);case"SHIPPING_OPTION":return o?.id?M(e.abortController.signal,o.id,n):a("SHIPPING_OPTION_INVA
1LID",s.translate("general.choose_delivery_strategy"),"SHIPPING_OPTION");default:return i.error(new At(`Could not recognize the intent: ${n}`,{groupingHash:"GooglePayGenericError::CannotRecognizeIntent"})),i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged could not recognize the intent",{callbackTrigger:n}),a("OTHER_ERROR",s.translate("wallets.errors.generic",{walletName:s.translate("brand.google_pay")}),"SHIPPING_ADDRESS")}},[D,M,i,s])}function Yt({asPaymentMethod:_=!1}){const h=s(null),T=o(null),D=s(!1),M=s(0),{isScrimOpen:G,closePopupWindowsAndScrim:L}=le({endpoint:T,invokingWallet:"GOOGLE_PAY"}),k=f(),H=Pt(),z=g("GOOGLE_PAY").value,{i18n:q,observability:W,checkout:{wallets:$,proposal:Q,negotiator:K},client:{userAgent:te},shop:ae}=Y(),{value:re}=K.current.fields.deliveryNext,oe=s({abortController:Bt(),initiallySelectedShippingOptionId:void 0}),me=o(void 0),{inMemoryGooglePayParts:{sdkStatus:ye,buttonStatus:_e}}=V(),{markAsLoaded:he}=se(),ve=s(!0),Pe=s(!1),be=function({asPaymentMethod:a}){const o=Pt(),n=function(){const{checkout:a}=Y(),r=g("GOOGLE_PAY");return e(()=>{const e=r.value;if(void 0===e)return[];const o=a.configuration.addressSettings.nonBillingAddressSettings.value,n=t(()=>o.isRequired("phone")),{allowedAuthMethods:s,allowedCardNetworks:i,gateway:l,gatewayMerchantId:d}=e;return[{type:"CARD",parameters:{allowedAuthMethods:s,allowedCardNetworks:i,billingAddressRequired:!0,billingAddressParameters:{format:"FULL-ISO3166",phoneNumberRequired:n}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:l??"",gatewayMerchantId:d??""}}}]})}(),{checkout:s,i18n:i,shop:l}=Y(),d=s.negotiator,u=p(),c=Et(),{locationAddress:_}=s.negotiator.parts,h=m(),v=y(l),E=s.configuration.layout.isOnePage.value,P=l.hasFlagEnabled(U),b=E||P,A=e(()=>b&&B({checkout:s})),I=r(a);return e(()=>{const e=!I.value&&!F({availableDeliveryAddresses:s.negotiator.current.fields.availableDeliveryAddresses?.value,mustSelectProvidedAddress:s.negotiator.current.fields.mustSelectProvidedAddress?.value})&&s.isShippingRequired.value,a=e?["PAYMENT_AUTHORIZATION","SHIPPING_ADDRESS","SHIPPING_OPTION"]:["PAYMENT_AUTHORIZATION"],r=Ee(d,{includeShopPromotion:!1}),g=h.value&&_.fields.countryCode.value?[_.fields.countryCode.value]:l.shippingCountries?.map(e=>e.value),p=n.value,m=o.value;if(0===p.length||!m||!g||0===g.length&&e||null==r.paymentDue||null==r.subtotal)return null;const y=s.configuration.addressSettings.nonBillingAddressSettings.value,E=t(()=>y.isRequired("phone")),P=Boolean(w({deferredTotal:r.deferredTotal,checkoutTotal:r.checkoutTotal,paymentFlexibilityPaymentTermsTemplate:r.paymentFlexibilityPaymentTermsTemplate})?.amount);return{...ut,allowedPaymentMethods:p,merchantInfo:m,callbackIntents:a,emailRequired:u.value,shippingAddressParameters:{format:"FULL-ISO3166",allowedCountryCodes:g,phoneNumberRequired:E},shippingAddressRequired:e,shippingOptionRequired:e,transactionInfo:mt({labels:c,i18nCurrency:i.currency,...r,hasPayableDeposit:P,shouldWalletDecelerateForSubscriptions:A.value,discountsZeroValueUXEnabled:v})}})}({asPaymentMethod:_}),Ae=s(null),{checkoutCardsinkCallerIdentificationSignature:Ie}=Q.negotiated.fields,fe=a(()=>{if(!ae.cardsinkUrl)return;const e=window.location.host;return{isLocalDev:e.endsWith("checkout.my.shop.dev")||e.endsWith("checkout.shop.dev"),cardsinkUrl:ae.cardsinkUrl,callerIdentificationJwt:Ie.value}},[ae.cardsinkUrl,Ie]),Se=_?q.translate("wallets.call_to_action",{walletName:""}):void 0,Re=q.translate("brand.google_pay"),Ne=function({endpoint:e,isTerminated:t,color:a,config:r,merchantInfo:o,buttonLabel:s,ariaLabel:i,markAsLoaded:l,sdkStatus:d,sdkStatusRef:u,buttonStatus:c,paymentDataRequest:g,containerRef:p,asPaymentMethod:m,isFirstRender:y,updateSdkStatus:_,connectedNullPaymentDataRequest:h,cardsinkConfig:v}){const{observability:E,source:P}=Y();return n(async n=>{if(t.current)return void E.leaveErrorBreadcrumb("[GooglePay] useOnConnect skipped - sandbox already terminated");E.leaveErrorBreadcrumb("[GooglePay] useOnConnect starting configuration"),g.value||(h.current=!0),e.value=n;const b=await n.call.configure({isDark:"dark"===a,environment:r?.environment,merchantInfo:o,buttonLabel:s,ariaLabel:i,paymentDataRequest:g.value,style:{borderRadius:ie(p.current)},cardsinkConfig:v,sourceId:P.sourceId});y.current=!1,l(),b.status===st.Success?(E.leaveErrorBreadcrumb("[GooglePay] useOnConnect configuration successful"),_({status:"available"},d,u),"error"!==c.value.status&&(c.value={status:"rendered"},E.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:bt,status:"success",isPaymentMethodFlow:m}}))):(E.leaveErrorBreadcrumb("[GooglePay] useOnConnect configuration failed",{status:b.status}),b.status===st.Error&&function({result:{type:e,name:t,message:a},observability:r}){"createButton"===e&&r.error(new It(a,{cause:{name:t,message:a}}),{metadata:{additionalKey:{name:t,message:a}}})}({result:b,observability:E}),c.value={status:"error"},E.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:bt,status:"error",isPaymentMethodFlow:m,reason:b.status===st.ScriptLoadError?"script_load_error":"sandbox_error"}}),_({status:"error"},d,u))},[e,t,a,r?.environment,o,s,i,l,d,u,c,g,p,E,m,y,_,h,v,P.sourceId])}({endpoint:T,isTerminated:D,color:k,config:z,merchantInfo:H.value,buttonLabel:Se,ariaLabel:Re,markAsLoaded:he,sdkStatus:ye,sdkStatusRef:h,buttonStatus:_e,paymentDataRequest:be,containerRef:Ae,asPaymentMethod:_,isFirstRender:ve,updateSdkStatus:Ut,connectedNullPaymentDataRequest:Pe,cardsinkConfig:fe}),Ce=function({paymentDataRequest:e,asPaymentMethod:t,isScrimOpen:a,containerRef:r,endpoint:s}){const i=v(),{negotiate:l}=E(),d=P(),{observability:u,checkout:{wallets:c,proposal:g},client:{userAgent:p}}
1=Y(),m=x(p)?.name,y="Safari"===m,_=j(p),h=o(!1),b=o(!1),{inMemoryGooglePayParts:{paymentSheetError:A,paymentSheetOpenPromise:I,paymentSheetOpenPromiseResolve:f,sdkStatus:S},persistedGooglePaySignal:R}=V(),N=Je(Qe.GooglePay),C=tt(Qe.GooglePay),O=at(Qe.GooglePay);return n(async()=>{i(r);try{if(t){if(h.value)return;h.value=!0,y&&(s.value?.call.updateValidationLock({status:"success"}),a.value=!0),await new Promise((e,t)=>{const a=d.value,r=g.negotiated.value;l({negotiationStage:"completion",silenceViolations:rt({journey:a,negotiated:r,fieldsToValidate:[...Ot(a,r)]}),runListenersOnError:!0,onComplete:a=>{"success"===a?.status?e():t()}})})}if(a.value=!0,c.activeSession.value)return u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - active session exists"),a.value=!1,void s.value?.call.updateValidationLock({status:"failure"});const r=S.value;if("available"!==r?.status)return u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - SDK not available",{sdkStatus:r?.status}),a.value=!1,void s.value?.call.updateValidationLock({status:"failure"});c.setActiveSession({newValue:"GOOGLE_PAY",asPaymentMethod:t});try{C();const r=e.value;if(null===r||null==r.callbackIntents||0===r.callbackIntents.length)return u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - invalid payment data request",{paymentDataRequest:null===r?"null":"invalid"}),c.clearActiveSession({invokingWallet:"GOOGLE_PAY"}),A.value={type:"config_missing_required_fields"},a.value=!1,void s.value?.call.updateValidationLock({status:"failure"});O(),N(Ke.Success,t?Xe.PaymentMethod:Xe.Express),u.counter({name:"wallet_sheet_clicked",value:1,attributes:{instrument:Qe.GooglePay}}),b.value||(u.counter({name:"wallet_attempt_to_open_payment_sheet",value:1,attributes:{os:_,browser:m}}),b.value=!0),R.value={initialCurrencyCode:r.transactionInfo.currencyCode,receiptIdForPaymentFailure:R.value?.receiptIdForPaymentFailure},u.log("handle_click_button_clicked","Google Pay button clicked",{allowedAuthMethods:r.allowedPaymentMethods.map(e=>e.parameters.allowedAuthMethods)}),I.value=new Promise(e=>{f.value=e}),s.value?.call.updateValidationLock({status:"success"})}catch(o){throw c.clearActiveSession({invokingWallet:"GOOGLE_PAY"}),a.value=!1,o}}catch(o){u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick error handling",{error:o}),y&&t?(s.value?.call.closePopupWindows(),a.value=!1):t&&y||(a.value=!1),s.value?.call.updateValidationLock({status:"failure"})}finally{h.value&&(h.value=!1)}},[t,m,r,i,O,C,s,b,y,a,h,d,l,_,e,A,I,f,R,g,S,u,N,c])}({paymentDataRequest:be,asPaymentMethod:_,isScrimOpen:G,containerRef:Ae,endpoint:T}),Oe=function(e){const t=Je(Qe.GooglePay),a=o(!1),{persistedGooglePaySignal:r,inMemoryGooglePayParts:{sdkStatus:s,buttonStatus:i,paymentSheetError:l,paymentSheetOpenPromiseResolve:d,paymentSheetOpenPromise:u}}=V(),{observability:c,checkout:{wallets:g},client:{userAgent:p}}=Y(),m=x(p)?.name,y=j(p);return n(o=>{c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler onResponse",{response:o}),e.value=!1;const{response:n,error:p}=o;if(n)d.value?.(void 0);else if(p){switch("CANCELED"===p.name?c.counter({name:"wallet_sheet_cancelled",value:1,attributes:{instrument:Qe.GooglePay}}):c.counter({name:"wallet_sheet_failed",value:1,attributes:{instrument:Qe.GooglePay}}),p.name){case"CANCELED":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: CANCELED"),t(Ke.Cancelled);break;case"DEVELOPER_ERROR":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: DEVELOPER_ERROR",{errorMessage:p.message}),t(Ke.Failure),l.value={type:"invalid_config"},c.error(new ft(`loadPaymentData failed: ${p.message}`,{groupingHash:"GooglePayDeveloperError::LoadPaymentDataFailed"}));break;case"BUYER_ACCOUNT_ERROR":case"MERCHANT_ACCOUNT_ERROR":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: ACCOUNT_ERROR",{errorType:p.name,errorMessage:p.message}),t(Ke.Failure),i.value={status:"error"},s.value={status:"error"},c.log("google_pay_response_handler_session_unavailable","Google Pay is unavailable for this session",{reason:p.name});break;case"INTERNAL_ERROR":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: INTERNAL_ERROR",{errorMessage:p.message}),t(Ke.Failure),l.value={type:"unexpected_terminal_error"},c.log("google_pay_response_handler_internal_error","Google Pay internal server error occurred",{errorMessage:p.message});break;case"VALIDATION_TIMEOUT":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: VALIDATION_TIMEOUT"),t(Ke.Failure);break;case"FAILED_TO_OPEN_WINDOW":a.value||(c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: FAILED_TO_OPEN_WINDOW"),t(Ke.Failure),c.counter({name:"wallet_failed_to_open_window",value:1,attributes:{os:y,browser:m}}),a.value=!0);break;default:c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: UNEXPECTED_STATUS",{errorName:p.name,errorMessage:p.message}),c.error(new St(`loadPaymentData failed with unexpected status code: [${p.name}] ${p.message}`,{groupingHash:`GooglePayUnexpectedStatusCodeError::UnexpectedStatus::${p.name}`}))}d.value?.(void 0)}c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler cleanup complete"),"GOOGLE_PAY"===g.activeSession.value?.wallet?g.clearActiveSession({invokingWallet:"GOOG
1LE_PAY"}):c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler cleanup complete, but activeSession is not Google Pay",{activeSession:g.activeSession.value}),u.value=void 0,r.value={initialCurrencyCode:void 0}},[m,y,u,r,d,c,t,l,i,s,a,e,g])}(G),Te=Ht({googlePayTransactionId:me}),De=function({asPaymentMethod:t}){const{progress:r}=E(),{shop:o,checkout:s,observability:i}=Y(),{deliveryLines:l,email:d,shippingAddress:u,billingAddress:c,paymentLines:p}=s.negotiator.parts,m=s.configuration.addressSettings.nonBillingAddressSettings,y=X(),_=s.negotiator.current.fields.availableDeliveryAddresses?.value,h=s.negotiator.current.fields.mustSelectProvidedAddress?.value,v=F({availableDeliveryAddresses:_,mustSelectProvidedAddress:h}),P=s.negotiator,f=s.configuration.layout.isOnePage.value,S=s.configuration.layout.baseName,R=o.hasFlagEnabled(U),N=!f&&R,C=e(()=>s.configuration.layout.isOnePage.value||R),O=e(()=>C.value&&B({checkout:s})),T=g("GOOGLE_PAY"),D=function({supportsOnePage:e=!1}={}){const{i18n:t,observability:r}=Y(),{inMemoryGooglePayParts:o}=V(),n=Ue(),s=a(()=>({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 a(()=>e?new Dt(r,s,o,n):new Mt(r,s,o,n),[r,e,s,o,n])}({supportsOnePage:C.value||O.value}),M=Lt(),G=Be(),w=A(),L=I(),k=function(){const{walletUsedForSubmissionSignal:e,inMemoryGooglePayParts:{paymentSheetError:t}}=V(),a=Lt();return n(()=>{t.value=void 0,e.value=void 0,a()},[t,e,a])}(),H=ot({flag:U,onAbort:k,onError:k}),{inMemoryGooglePayParts:{paymentSheetOpenPromise:x,paymentSheetError:j},persistedGooglePaySignal:z,walletUsedForSubmissionSignal:q}=V(),{trackAttempt:W,trackComplete:$}=nt(Qe.GooglePay),Q=n(async({reason:e})=>{N?await H({wallet:"GOOGLE_PAY",reason:e,asPaymentMethod:!1,announceSubscriptionReviewLayoutSwitch:"subscriptions"===e}):(s.wallets.setEscalatedWallet("GOOGLE_PAY"),L?.dispatch("addressReplaced"))},[H,N,L,s.wallets]);return n(({isShippingRequired:e,paymentData:a,cardsinkResult:n})=>new Promise(g=>{const _=performance.now();i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, attempting completion",{shippingAddressCity:a.shippingAddress?.locality??"MISSING",shippingAddressAdministrativeArea:a.shippingAddress?.administrativeArea??"MISSING",shippingAddressCountryCode:a.shippingAddress?.countryCode??"MISSING",billingAddressCity:a.paymentMethodData.info?.billingAddress?.locality??"MISSING",billingAddressAdministrativeArea:a.paymentMethodData.info?.billingAddress?.administrativeArea??"MISSING",billingAddressCountryCode:a.paymentMethodData.info?.billingAddress?.countryCode??"MISSING"}),W();const h=()=>{$({result:"failed",durationMs:performance.now()-_})},E=a.shippingAddress,A=a.paymentMethodData.info?.billingAddress,I=a.paymentMethodData,f=m.value.isRequired("address2"),R=D.validatePaymentCurrency({initialCurrencyCode:z.value?.initialCurrencyCode,currentCurrencyCode:P.current.fields.subtotal?.value?.currencyCode}
1),L=D.validateBilling(a),k=D.validateShipping(a,e,f);if(i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized: validation results",{paymentValidationResult:R,billingValidationResult:L,shippingValidationResult:k}),R.paymentSheetAction)return h(),ae(R.paymentSheetAction);if(L.paymentSheetAction)return h(),ae(L.paymentSheetAction);if(k.paymentSheetAction)return h(),ae(k.paymentSheetAction);const H={};if(L.shouldPersist&&A&&(c.value=_t({googleAddress:A,isFirstNameRequired:m.value.isRequired("firstName")}),H.billing=A.address1),k.shouldPersist&&E){const e=E.iso3166AdministrativeArea;w({postalCode:E.postalCode,countryCode:E.countryCode,city:E.locality,zoneCode:e},"GOOGLE_PAY"),v||(u.value=_t({googleAddress:E,isFirstNameRequired:m.value.isRequired("firstName")}),H.shipping=E.address1)}const Y=s.negotiator.current.fields.buyerIdentity.value?.customerProfile?.email||a.email;Y&&(d.value=Y),G(),z.value={...z.value,description:I.description,receiptIdForPaymentFailure:void 0};const U=p.value,{signature:B,signedMessage:F,protocolVersion:V}=a.paymentMethodData.tokenizationData.token?JSON.parse(a.paymentMethodData.tokenizationData.token):{signature:"",signedMessage:"",protocolVersion:""};let K=0;const X=Fe(P.current.fields.deliveryNext?.value),te=async()=>{let e=!1;i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion attempt",{attemptNumber:K}),await r("google-pay-payment-authorized",async a=>{i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion result",{result:{status:a.status,violations:("violations"in a?a.violations:[])||[],errors:("errors"in a?a.errors:[])||[]}}),"success"===a.status&&(q.value="GOOGLE_PAY"),"denied"!==a.status&&"throttled"!==a.status&&"tooManyRequests"!==a.status||M();const r=a,o="rejected"===r.status&&r.violations.some(e=>e.code===Z),{shouldRetry:n,retryReason:s,updatedDeliveryMethodHandles:d}=function(e,t,a,r){const o={shouldRetry:!1,retryReason:"",updatedDeliveryMethodHandles:void 0};if(t>=1)return o;if("stale"===e.status)return{shouldRetry:!0,retryReason:"stale",updatedDeliveryMethodHandles:void 0};if("fetch_failed"===e.status)return{shouldRetry:!0,retryReason:"fetch_failed",updatedDeliveryMethodHandles:void 0};if("rejected"===e.status&&e.violations?.length){const t=xe(e,a.current.fields.deliveryNext?.peek(),r);if(t)return{shouldRetry:!0,retryReason:"delivery_option_mismatch",updatedDeliveryMethodHandles:t}}return o}(r,K,P,X);if(d&&b(l,d),n&&!o)return K++,i.counter({name:"wallet_submit_for_completion_retry",value:1,attributes:{retry_reason:s,retry_count:K,status:r.status,instrument:Qe.GooglePay}}),i.log("payment_authorized_completion_retried",`GooglePay::usePaymentAuthorized: Retrying ${s} completion`,{attemptNumber:K}),void te();const u=D.completionResultMapper.mapResultToPaymentSheetAction(r,{options:{asPaymentMethod:t,layout:S}});i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment sheet action mapper result",{paymentSheetAction:u});const c="show_error"===u.action||"abort"===u.action?"failed":"success";try{await ae(u)}finally{$({result:c,durationMs:performance.now()-_,attributes:{retry_count:K>0?K.toString():void 0}}),i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, authorization result",{authorizationResult:c}),!C.value||"rejected"!==a.status&&"invalid"!==a.status||(j.value||(j.value={type:"recovery_notice"}),N?e=!0:Q({reason:"submitForCompletion"}))}},{skipToCompletion:!0,customizeCompletion:Ve,walletStreetLines:o.hasFlagEnabled(ee)?H:void 0}),e&&Q({reason:"submitForCompletion"})};async function ae(e){if(e.effects?.forEach(e=>e()),"show_error"===e.action)return i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, resolving with error",{paymentSheetAction:e}),void g({transactionState:"ERROR",error:e.errors?.[0]});i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, resolving with success"),g({transactionState:"SUCCESS"}),await x.value}(()=>{const e=P.current.fields.paymentDue.value,t=e&&e.amount>0||y.value;return n?(e=>{if(e){if(n&&"error"in n)return i.leaveErrorBreadcrumb("[GooglePay] Cardsink deposit failed in sandbox",{error:n.error}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"failed",instrument:Qe.GooglePay}}),ae({action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",message:"Failed to process payment",intent:"PAYMENT_AUTHORIZATION"}]}),!1;
1n&&"sessionId"in n&&(i.leaveErrorBreadcrumb("[GooglePay] Using sessionId from sandbox cardsink",{sessionId:n.sessionId}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"success",instrument:Qe.GooglePay}}),p.value=J(U,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{protocolVersion:"",signature:"",signedMessage:"",sessionId:n.sessionId,paymentMethodIdentifier:T.value?.paymentMethodIdentifier}}}))}return!0})(t):(t&&(p.value=J(U,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{signature:B,signedMessage:F,protocolVersion:V,paymentMethodIdentifier:T.value?.paymentMethodIdentifier}}})),!0)})()&&(O.value?(vt(i,{reason:"subscriptions",asPaymentMethod:t,layout:S}),ae({action:"decelerate",effects:[()=>{j.value=void 0}]}).finally(()=>Q({reason:"subscriptions"})).catch(e=>{i.leaveErrorBreadcrumb("[Google Pay] Failed to handle payment sheet action:",{err:e})})):te())}),[m,t,M,T,s.negotiator.current.fields,y,P,x,D,z,r,c,l,d,p,u,q,o,w,i,j,G,v,C,O,Q,N,W,$,S])}({asPaymentMethod:_}),Me=ce(),Ge=de();function we(e){W.log("google_pay_callback_timing","[GooglePay] callback progress",e,{requiresKeepalive:!0});const{scope:t,callback:a,outcome:r,durationMs:o}=e;if("progress"===r)return;const n={scope:t,callback:a,outcome:r};W.counter({name:"google_pay_callback_events",value:1,attributes:n}),"resolved"!==r&&"rejected"!==r||W.histogram({name:"google_pay_callback_duration",value:o,unit:"ms",attributes:n})}function Le(e,t){let a=!1;return function({log:e,stage:t,...a}){try{let r=function(t){try{"resolved"!==t&&"rejected"!==t||clearTimeout(i),e({...a,callbackId:o,stage:s,outcome:t,durationMs:performance.now()-n,visibilityState:document.visibilityState})}catch{}};const o=pe(),n=performance.now();let s=t;const i=setTimeout(()=>r("pending"),25e3);return r("started"),{stage(e){s!==e&&(s=e,r("progress"))},observe(e){try{return e().then(e=>(r("resolved"),e),e=>{throw r("rejected"),e})}catch(t){throw r("rejected"),t}}}}catch{return{stage(){},observe:e=>e()}}}({scope:"host",callback:e,stage:"checkout",trigger:t,googlePayTransactionId:me.peek(),log:e=>{"started"===e.outcome?(a=!0,M.current++):!a||"resolved"!==e.outcome&&"rejected"!==e.outcome||(a=!1,M.current--),we(e)}})}function ke(e){try{W.log("google_pay_sandbox_lifecycle","[GooglePay] sandbox lifecycle",{stage:e,googlePayTransactionId:me.peek(),pendingHostCallbacksInComponent:M.current},{requiresKeepalive:!0})}catch{}}const He=ue({onPaymentAuthorized:e=>Le("authorization").observe(()=>De(e)),onPaymentDataChanged:e=>Le("shipping",e.callbackTrigger).observe(()=>Te({sessionData:oe.current,intermediatePaymentData:e})),onClick:async({transactionId:e}={})=>(e&&(me.value=e),ne(re)&&(oe.current.initiallySelectedShippingOptionId=gt(O({proposedDeliveryLines:Q.proposed.deliveryLines}))),await Ce()),onResponse:e=>{ke("wallet_response_received");const t=oe.current.abortController;oe.current={abortController:Bt(),initiallySelectedShippingOptionId:void 0};const a=Oe(e);return t.abort(),a},telemetry:Me,breadcrumb:e=>{var t;if("[GooglePay Sandbox] callback progress"!==e.message&&"[GooglePay Sandbox] loadPaymentData started"!==e.message&&"[GooglePay Sandbox] loadPaymentData resolved"!==e.message)Ge(e);else try{"[GooglePay Sandbox] callback progress"===e.message?(t=e.attributes,"host"!==t?.scope&&"sandbox"!==t?.scope||"shipping"!==t.callback&&"authorization"!==t.callback||"checkout"!==t.stage&&"cardsink"!==t.stage&&"host_rpc"!==t.stage||"started"!==t.outcome&&"progress"!==t.outcome&&"pending"!==t.outcome&&"resolved"!==t.outcome&&"rejected"!==t.outcome||"string"!=typeof t.callbackId||"number"!=typeof t.durationMs||!Number.isFinite(t.durationMs)||"visible"!==t.visibilityState&&"hidden"!==t.visibilityState||void 0!==t.googlePayTransactionId&&"string"!=typeof t.googlePayTransactionId||void 0!==t.trigger&&"string"!=typeof t.trigger||we(e.attributes)):W.log("google_pay_sheet_progress",e.message,e.attributes,{requiresKeepalive:!0})}catch{}}});i(()=>{const e=!ve.current||Pe.current;T.value&&be.value&&e&&(Pe.current=!1,T.value.call.updatePaymentDataRequest(be.value))}),l(()=>(Ut({status:"loading"},ye,h),()=>{const e=ye.value,t=_e.value;e===h.current&&"error"!==t.status&&(ye.value={status:"idle"},_e.value={status:"not_rendered"},"GOOGLE_PAY"===$.activeSession.value?.wallet&&$.clearActiveSession({invokingWallet:"GOOG
1LE_PAY"}))}),[]);const Ye=_?"54px":void 0,je=d(N,{inlineAlignment:"center",children:d(C,{size:"large"})}),ze=!function(e=window.navigator.userAgent){return/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+(?: Mobile)? Safari\/537\.36$/.test(e)||/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+ Safari\/537\.36 Edg\/[\d.]+$/.test(e)||/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+(?: Mobile)? Safari\/537\.36 Vivaldi\/[\d.]+$/.test(e)}(te),Ze=r(!ze),qe=d(R,{isOpen:G,isInvisible:Ze,onClick:L,children:ze&&d(S,{handleClose:L,walletName:q.translate("brand.google_pay")})}),We=d(c,{children:[d(ge,{wallet:bt,onConnect:Ne,onTerminate:()=>{ke("endpoint_terminated"),D.current=!0,T.value=null},hostMethods:He,ref:Ae,height:Ye}),qe]}),$e=_&&"rendered"!==_e.value.status&&"error"!==_e.value.status;return _?d(c,{children:[$e&&je,d(N,{className:u($e&&"QIbE6"),children:We})]}):We}function Ut(e,t,a){a.current=e,t.value=a.current}function Bt(){return new AbortController}export{Yt 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.