PageSourceSearch

https://guniaa.com/cdn/shopifycloud/checkout-web/assets/c1/2b0dcdd4.CsR6tq5F.js

js guniaa.com collected 2026-10-01 15:03:04 UTC 92,708 bytes, 1 lines download raw bytes

1import{i3 as Wn,dd as Yn,aD as Qn,d as it,i4 as Ht,ge as zn,cm as B,hW as kt,br as Et,i5 as jn,hZ as Wt,V as Ge,i6 as $n,eL as ae,i7 as Kn,X as Jn,bq as Xn,v as Yt,u as Zn,gD as eo,en as Qt,w as to,a$ as zt,i8 as jt,j as $t,eF as Kt,i9 as Jt,aH as no,ia as oo,S as so,ib as io,ic as ro,b0 as ao,p as lo,bM as uo,h6 as co,fX as mo,n as po,q as ho,G as yo,id as ut,ie as fo,ig as Rt,ih as go,ii as Xt,ij as vo,ik as bo,il as So,eG as _o,im as Ao,io as Io,ip as Mo,eH as To,iq as ot,as as De,eI as Co,ir as Po,em as ko,is as Eo,it as Ro,iu as Fo,iv as Lo,iw as xo,ix as Do,aa as No,iy as wo,iz as Oo,iA as Bo,iB as Uo,iC as Go,iD as Vo,iE as ct,iF as qo,cQ as Ho,iG as Wo,bi as Yo,iH as Qo,iI as Zt,iJ as zo,iK as en,iL as J,iM as tn,e2 as jo,cR as $o}from"./4c290a1e.CvCmFIo_.js";import{h8 as Ko,h9 as Jo,ha as Xo,hb as Zo,hc as es,hd as nn,he as on,hf as rt,hg as ts,hh as ns,hi as os,hj as ss,hk as is,hl as rs,hm as as,hn as ds,ho as ls,hp as us}from"./164ad2e3.BcELPLd1.js";import{h as cs,i as ms}from"./cb8fcd45.c_ESjgQZ.js";import{c as sn,a as rn,V as at,r as ps,ah as hs,H as ys,M as fs,L as gs}from"./2c1ab0fe.DYQSH7bT.js";import{s as vs,g as Ne,a as Ue,d as Ve,b as Ft}from"./f78726c8.CLlB5yjH.js";import{g as bs,a as Ss}from"./0b8657b8.IcKXrEvA.js";import{a as _s}from"./65f3d4da.CPQqj7Ry.js";import{s as As,i as Is}from"./aea3fb03.DlSWgrqP.js";import{t as Ms,d as an,a as Ts,b as Cs,s as Ps,c as ks,e as Es,f as Rs,g as Fs,h as Ls,i as xs,j as Ds,m as Ns,k as ws,l as Os,p as Bs,n as Us,o as Gs}from"./acc74f72.CpPliRmM.js";import{S as mt,h as Vs}from"./app.Bvc4uxd4.js";import{d as dn}from"./b8733b27.Cz-rwMFn.js";import{g as qs}from"./bff2ff9b.Dejs-bBN.js";import{t as ln,a as Lt,b as Hs,d as Ws,s as Ys,f as Qs,g as zs,i as js,r as $s,o as Ks}from"./2255f8fa.5G6AzL6d.js";import"./60a453ce.BJZuodLH.js";import"./0a7dffce.BF-zuF6E.js";import"./bb728e1c.D4AahLMP.js";function Js({buyerEditedAddress:e,shopUserSecureData:t,shopPayVerificationTrigger:o,customerProfile:n}){if(e)return;if(!!t&&o==null)return"SHOP_PAY";if(n)return"CUSTOMER"}function un(e=[]){return new Set([...(e??[]).map(({stableId:t})=>t),...(e??[]).flatMap(({lineComponents:t})=>t.map(({stableId:o})=>o))])}class xt extends Error{constructor(){super(...arguments),this.name="UnknownMerchandiseTypeError"}}function Xs(e){let t=null;const o=()=>(t===null&&(t=new Map(e.lines.map(n=>[n.stableId,n]))),t);return{merchandiseLines:e.lines.map(n=>({...dt(n,o),lineComponentsSource:n.lineComponentsSource,lineComponents:n.lineComponents.map(s=>dt(s,o))}))}}function Zs(e){switch(e.typename){case"ContextualizedProductVariantMerchandise":case"ProductVariantMerchandise":return{productVariantReference:{id:e.id,variantId:e.variantId,properties:Dt(e.properties),sellingPlanId:e.sellingPlan?.id??null,sellingPlanDigest:e.sellingPlan?.digest??null}};case"SourceProvidedMerchandise":if(!Wn(e))throw new xt("Source-provided merchandise is missing the fields only the server can supply");return{sourceProvidedMerchandise:{title:e.title,subtitle:e.subtitle??void 0,price:{value:{amount:e.itemPrice.amount.toFixed(2),currencyCode:e.itemPrice.currencyCode}},giftCard:e.giftCard,productType:e.productType,sku:e.sku,variantId:e.variantId??void 0,productIdV2:e.productId??void 0,properties:Dt(e.properties),requiresShipping:e.requiresShipping,vendor:e.vendor??void 0,taxCode:e.taxCode??void 0,taxable:e.taxable??!0,taxesIncluded:e.taxesIncluded,optionalIdentifier:e.optionalIdentifier??void 0,weight:e.weight?{value:e.weight.value,unit:e.weight.unit}:void 0}};default:throw new xt(`Unrecognized merchandise type: ${e.typename}`)}}function Dt(e){return e.map(t=>{switch(t.sourceType){case"MerchandisePropertyValueNull":return{name:t.name,value:t.value};case"MerchandisePropertyValueString":return{name:t.name,value:{string:t.value}};case"MerchandisePropertyValueInt":return{name:t.name,value:{integer:t.value}};case"MerchandisePropertyValueFloat":return{name:t.name,value:{float:t.value}};case"MerchandisePropertyValueBoolean":return{name:t.name,value:{boolean:t.value}};case"MerchandisePropertyValueJson":return{name:t.name,value:{json:JSON.parse(t.value)}};default:rn(t)}})}function ei(e){if(!e)return{any:!0};const{currencyCode:t}=e;return{value:{amount:e.amount.toFixed(sn(t)),currencyCode:t}}}function dt(e,t){const o={stableId:e.stableId,merchandise:Zs(e),quantity:{items:{value:e.quantity}},expectedTotalPrice:ei(e.totalPrice)};if("parentRelationship"in e&&e.parentRelationship?.parent){const n=t().get(e.parentRelationship.parent.stableId);n&&(o.parent=dt(n,t))}return o}function ti(e){if(e)return{total:{amount:e.total.amount.toString(),currencyCode:e.total.currencyCode}}}function ni(e){if(!(!e||e.length===0))return{availableRedeemables:e.map(bs)}}function oi(e){if(e)return{provider:e.provider,challenge:e.challenge,token:e.token}}function si(e){const t=e.find(o=>o.peek().type==="ONE_TIME_PURCHASE");if(t)return t.peek().deliveryMethodOptions}function ii({shippingAddress:e,proposedDeliveryLines:t,externalDeliveryIds:o,destinationChanged:n,isSubmitForCompletion:s,isPointOfSale:i,isPointOfSaleShipToHome:r,negotiatedDelivery:d,filteredMerchandiseStableIds:a,locationAddress:l,geolocationCoordinates:p,retailLocationId:u,isShippingRequired:y,availableDeliveryAddresses:I,isConstrainedAddress:g,extendedAddressMode:S,marketDrivenShippingEnabled:M,stableIdToShopId:c,remoteShopsConfigMap:f}){const P=d?.status==="filled"?d.lines.map(({type:_})=>_):[],C=t.sort((_,m)=>{const h=_.peek().type,T=m.peek().type;return P.indexOf(h)-P.indexOf(T)}
1),D=si(C),E=d?.status==="filled"&&d.sourceIsBuyerProposal,A=C.map(_=>{const m=_.peek(),h=d?.status==="filled"&&d?.lines.find(({type:T,id:k})=>T===m.type&&(!k||k===m.id))||void 0;return{proposedDeliveryLine:m,negotiatedDeliveryLine:h}}),F=A.map(({proposedDeliveryLine:_,negotiatedDeliveryLine:m})=>{const h=ri({proposedDeliveryLine:_,filteredMerchandiseStableIds:a,marketDrivenShippingEnabled:M,stableIdToShopId:c,remoteShopsConfigMap:f}),T=ai(_,m);return{...h,enabled:h.enabled||h.remoteConfigMissing&&!!T?.token,rate:T}}),v=F.some(({enabled:_})=>_)?Yn(F,({rate:_})=>_?.amount??0,({enabled:_,shopId:m,rate:h})=>_&&h?.token?`${m}:${h.token}`:void 0):new Set;return A.map(({proposedDeliveryLine:_,negotiatedDeliveryLine:m},h)=>di({shippingAddress:e,proposedDeliveryLine:_,externalDeliveryIds:o,destinationChanged:n,negotiatedDeliveryLine:m,filteredMerchandiseStableIds:a,locationAddress:l,geolocationCoordinates:p,proposedAlternateOptions:D,isSubmitForCompletion:s,isPointOfSale:i,isPointOfSaleShipToHome:r,retailLocationId:u,isShippingRequired:y,availableDeliveryAddresses:I,isConstrainedAddress:g,negotiatedSourceIsBuyerProposal:E,extendedAddressMode:S,foldExpectedTotalPriceToZero:v.has(h)}))}function ri({proposedDeliveryLine:e,filteredMerchandiseStableIds:t,marketDrivenShippingEnabled:o,stableIdToShopId:n,remoteShopsConfigMap:s}){const i=cn(e.targetMerchandiseLines,t)[0]?.stableId,r=i?n?.get(i):void 0;if(r){const d=s?.get(r);return{shopId:r,enabled:d?.marketDrivenShippingEnabled??!1,remoteConfigMissing:!d}}return{shopId:"local",enabled:o,remoteConfigMissing:!1}}function ai(e,t){const o=e.deliveryMethodHandle;if(!t||t.status==="not_required"||!o)return;const n=t.methods.find(({handle:s})=>s===o);if(n?.cost)return{amount:n.cost.amount,token:Qn(n)}}function di({shippingAddress:e,proposedDeliveryLine:t,externalDeliveryIds:o,destinationChanged:n,negotiatedDeliveryLine:s,filteredMerchandiseStableIds:i,locationAddress:r,geolocationCoordinates:d,proposedAlternateOptions:a,isSubmitForCompletion:l,isPointOfSale:p,isPointOfSaleShipToHome:u,retailLocationId:y,isShippingRequired:I,availableDeliveryAddresses:g,isConstrainedAddress:S=!1,negotiatedSourceIsBuyerProposal:M=!1,extendedAddressMode:c,foldExpectedTotalPriceToZero:f=!1}){const P=t.targetMerchandiseLines.filter(({stableId:L})=>i.has(L)),C=P.length?P.some(({requiresShipping:L})=>L):void 0,D=s?.targetMerchandiseLines?.some(({requiresShipping:L})=>L),E=C??I??D??!0,{deliveryMethodHandle:A,deliveryMethodTypes:F,deliveryMethodOptions:v,targetMerchandiseLines:_,isCustomRate:m,customDeliveryStrategy:h}=t,T=s?.status==="available"?s?.selectedDeliveryMethodHandle:void 0,k=li({proposedHandle:A,negotiatedHandle:T,canOverwriteNullishProposedHandle:M||S});let x;s?.status==="available"?x=s.methods.find(({handle:Q})=>Q===(A??k))?.isCustomRate??m:x=m;const N=vs({deliveryMethodHandle:k,deliveryMethodOptions:{instructions:v.instructions??a?.instructions,phone:v.phone??a?.phone},isCustomRate:x,isPointOfSale:p,retailLocationId:y,isPointOfSaleShipToHome:u,customDeliveryStrategy:h});ui(N,o);const U=ci({proposedTargetMerchandiseLines:_,filteredMerchandiseStableIds:i,hasMatchingNegotiatedDeliveryLine:!!s,isShippingRequired:I});let R;p&&!u?R=["RETAIL"]:E?R=F:R=["NONE"];const w=R.length>0&&R.every(L=>L==="PICK_UP"),W=R.includes("PICKUP_POINT"),q=E&&!w;let O;const z=g?.find(L=>it(L.address,e,["phone","zoneCode"])),Y=g?.find(L=>it(L.address,e,["phone","zoneCode"])&&Ht(L.address,e));q?W&&r?O=Ne(r,{extendedAddressMode:c}):S?O={deliveryAddressReference:Ue(g[0].address)}:Y?O={deliveryAddressReference:Ue(Y.address)}:l?O={streetAddress:Ve(e,{extendedAddressMode:c})}:O={partialStreetAddress:Ve(e,{extendedAddressMode:c})}:w&&(z?O={deliveryAddressReference:Ue(z.address)}:r?.coordinates?O=Ne(r,{extendedAddressMode:c}):r?.postalCode?O=Ne(r,{extendedAddressMode:c}):d&&r?.countryCode&&(O=Ne({countryCode:r.countryCode,coordinates:d},{extendedAddressMode:c})));const j=mi(s,A,f);return{destination:O,selectedDeliveryStrategy:N,targetMerchandiseLines:U,deliveryMethodTypes:R,expectedTotalPrice:j,destinationChanged:n}}function li({proposedHandle:e,negotiatedHandle:t,canOverwriteNullishProposedHandle:o}){return o?e??t:e}function ui(e,t){t?.externalCheckoutSessionId&&(e.externalCheckoutSessionId=t.externalCheckoutSessionId),t?.externalCustomerId&&(e.externalCustomerId=t.externalCustomerId),t?.externalPromiseId&&(e.externalPromiseId=t.externalPromiseId)}function ci({proposedTargetMerchandiseLines:e,filteredMerchandiseStableIds:t,hasMatchingNegotiatedDeliveryLine:o,isShippingRequired:n}){const s=cn(e,t);return s.length?{lines:s}:n?n&&!o?{any:!0}:{lines:[]}:{any:!0}}function cn(e,t){return e.reduce((o,{stableId:n})=>n&&t.has(n)?[...o,{stableId:n}]:o,[])}function mi(e,t,o=!1){const n={any:!0};if(!e||e.status==="not_required"||!t)return n;const{methods:s}=e,i=s.find(({handle:a})=>a===t)?.cost;if(!i)return n;const r=sn(i.currencyCode);return{value:{amount:(o?0:i.amount).toFixed(r),currencyCode:i.currencyCode}}}function mn(e,t){if(e.anyAllocation)return{anyAllocation:e.anyAllocation};const o=un(t);return{allocated:{allocations:e.allocations.reduce((n,s)=>{const{target:{type:i,amount:r,stableId:d}}=s;if(i==="MERCHANDISELINE"){if(d){if(!o.has(d))return n;n.push({amount:{value:{amount:r.amount.toString(),currencyCode:r.currencyCode}},target:{merchandiseLineTarget:{stableId:d}}})}}else n.push(pi(s));return n},[])}}}function pi(e){const{target:{index:t,amount:{currencyCode:o,amount:n}}}=e;return{amount:{value:{amount:n.toString(),currencyCode:o}},target:{deliveryLineTarget:{atIndex:t}}}}function hi(e,t,o){const n=mn(e,t);return!n.anyAllocation&&!n.allocated.allocations.length&&o?.leaveErrorBreadcrumb("discount.codeDiscountLineForGraphQL.no_allocation",{discountType:e.discount.type,discountTitle:e.discount.title,discountValue:e.discount.value}),{allocationSet:n,discount:{discountWithCode:e.discount.title},required:!0}}function Nt(e){switch(e.value?.typename){case"FixedAmountValue":{const{fixedAmount:{amount:t,currencyCode:o},appliesOnEachItem:n}=e.value;return{fixedAmountValue:{value:{amount:t.toString(),currencyCode:o},appliesOnEachItem:n}}}case"PercentageValue":{const{percentage:t}=e.value;return{percentageValue:{percentage:t.toString()}}}default:return{}}}function yi(e){const{signature:t="",signatureUuid:o=""}=e;return t.length&&o.length?{value:t,uuid:o}:null}function fi(e,t,o){const n=e.discount,s=mn(e,t);return s.anyAllocation||s.allocated.allocations.length?{allocationSet:s,discount:{customDiscount:{targetEntireCart:n.presentationLevel==="CART",title:n.title,de
1scription:n.description??null,value:Nt(n),signature:yi(n),type:n.discountType}},required:!0}:(o?.leaveErrorBreadcrumb("discount.customDiscountLineForGraphQL.no_allocation",{discountType:n.discountType,discountTitle:n.title,discountValue:Nt(n)}),null)}function gi(e){return{allocationSet:{anyAllocation:{totalAmount:{any:!0}}},discount:{discountWithCode:e.title},required:!0}}function vi(e,t,o){return e.lines.reduce((n,s)=>{let i=null;return zn(s)?i=gi(s):s.discount.type==="code"?i=hi(s,t,o):s.discount.type==="custom"&&(i=fi(s,t,o)),i!=null&&n.push(i),n},[])}function bi(e){return{signature:e.signature??void 0,contents:e.contents.map(t=>({signature:t.signature,targetTerms:t.targetTerms,targetLine:t.targetLine===void 0?void 0:{allLines:t.targetLine?.allLines??!1,index:t.targetLine?.index},attributes:t.attributes}))}}function Si(e,t,o){return{message:t??e.note??null,customAttributes:o?.map(({...n})=>n)??e.customAttributes?.map(n=>({key:n.key,value:n.value}))??[]}}function _i(e){return{buyerRefusesDuties:e}}function Ai({hasRegularSubscriptionPaymentTerms:e,isCompleting:t,allowAtNegotiation:o=!1,runningTotal:n,paymentDue:s,checkoutTotal:i,lines:r}){if(!e||!t&&!o||s!=null&&s.currencyCode!==i.currencyCode)return;const d=Ii({runningTotal:n,paymentDue:s,checkoutTotal:i}),a=Math.max(0,B(i.amount-(d?.amount??i.amount))),l=Mi({checkoutTotal:i,reflectedRedeemableAmount:a,lines:r}),p=l.hasPaymentMethodAmount||l.inferredFromConcreteRedeemables;let u=l.amount,y=0,I=Math.min(a,l.amount);const g=new Map,S=new Set;let M=!1;if(r.forEach(c=>{if(c.due||c.method.type!=="giftCard"&&c.method.type!=="redeemable")return;if(!t&&(c.cost==null||c.cost.amount<=0)){M=!0,S.add(c);return}if(!p){if(kt(c)){const P=Math.max(0,B(u));if(P===0){M=!0,S.add(c);return}u=Math.max(0,B(u-P)),y=B(y+P),g.set(c,{amount:P,currencyCode:i.currencyCode});return}M=!0,S.add(c);return}if(c.cost==null){const P=I<=0,C=Math.max(0,B(kt(c)&&P?u:Math.min(I,u)));if(C===0){M=!0,S.add(c);return}u=Math.max(0,B(u-C)),I=Math.max(0,B(I-C)),y=B(y+C),g.set(c,{amount:C,currencyCode:i.currencyCode});return}if(c.cost.amount<=0){M=!0,S.add(c);return}if(c.cost.currencyCode!==i.currencyCode)return;const f=Math.max(0,B(Math.min(c.cost.amount,u)));if(f===0){M=!0,S.add(c);return}u=Math.max(0,B(u-f)),I=Math.max(0,B(I-f)),y=B(y+f),g.set(c,{amount:f,currencyCode:i.currencyCode})}),!(g.size===0&&S.size===0))return{paymentMethodAmount:{amount:{amount:Math.max(0,B(l.amount-y)),currencyCode:i.currencyCode},fillAmount:!M},redeemableAmounts:g,unconstrainedRedeemableLines:S}}function Ii({runningTotal:e,paymentDue:t,checkoutTotal:o}){const n=[t,e].filter(s=>s!=null&&s.currencyCode===o.currencyCode);if(n.length!==0)return n.reduce((s,i)=>i.amount<s.amount?i:s)}function Mi({checkoutTotal:e,reflectedRedeemableAmount:t,lines:o}){const{hasPaymentMethodAmount:n,allocatedPaymentMethodAmount:s,allocatedRedeemableAmount:i}=o.reduce((r,d)=>d.due||d.cost==null||d.cost.currencyCode!==e.currencyCode?r:d.method.type==="giftCard"||d.method.type==="redeemable"?{...r,allocatedRedeemableAmount:B(r.allocatedRedeemableAmount+Math.max(0,d.cost.amount))}:{...r,hasPaymentMethodAmount:!0,allocatedPaymentMethodAmount:B(r.allocatedPaymentMethodAmount+Math.max(0,d.cost.amount))},{hasPaymentMethodAmount:!1,allocatedPaymentMethodAmount:0,allocatedRedeemableAmount:0});return n?{amount:Math.min(e.amount,B(s+i+t)),currencyCode:e.currencyCode,hasPaymentMethodAmount:n,inferredFromConcreteRedeemables:!1}:t>0||i>0?{...e,hasPaymentMethodAmount:n,inferredFromConcreteRedeemables:!0}:{...e,hasPaymentMethodAmount:n,inferredFromConcreteRedeemables:!1}}const wt={any:!0};function Ti({fixSubscriptionRedeemablePaymentAmount:e,hasRegularSubscriptionPaymentTerms:t,line:o,isCompleting:n,paymentDue:s,completionAmount:i,cost:r,coreAllocatesImmediateAmount:d}){if(!e||!t||o.due)return;if(n&&d){const l=s??r;return l==null?void 0:{amount:l,fillAmount:!1}}const a=n?i?.amount??r??s:s;if(a!=null)return{amount:a,fillAmount:n?i?.fillAmount??!0:!1}}class Ci extends Error{constructor(){super(...arguments),this.name="MalformedDateStringError"}}class pn extends Error{constructor(){super(...arguments),this.name="BankPaymentLineDroppedError"}}function Pi(e,t,o){switch(e.name){case"PAYPAL_EXPRESS":{const n=e.walletContent,s=n?.payerApprovedAmount;return{name:"PAYPAL_EXPRESS",walletContent:{paypalWalletContent:{...n?.authAssertionContext&&{authAssertionContext:n.authAssertionContext},email:n?.email??"",payerId:n?.payerId??"",token:n?.token??"",expiresAt:n?.expiresAt??null,merchantId:n?.merchantId??null,currencyCode:n?.currencyCode??null,isVenmo:n?.isVenmo??null,...n?.isVaultWithPurchaseOrder&&{isVaultWithPurchaseOrder:!0},paymentMethodIdentifier:n?.paymentMethodIdentifier??"",...o&&{acceptedSubscriptionTerms:o},...t&&{vaultingAgreement:t},...s&&{payerApprovedAmount:{amount:s.amount,currencyCode:s.currencyCode}}}}}}case"SHOP_PAY":{const n=e.walletContent;if(n==null)return null;const s=n.creditCardInstallments?{installmentsCount:n.creditCardInstallments,intervalType:"MONTH"}:void 0;return{name:"SHOP_PAY",walletContent:{shopPayWalletContent:{sessionToken:n.sessionToken??"",billingAddress:{streetAddress:n.billingAddress},paymentAttributes:n.paymentAttributes,paymentMethod:n.paymentMethod,paymentMethodIdentifier:n.paymentMethodIdentifier??"",addressId:n.addressId,...n.hsaRequested!=null&&{hsaRequested:n.hsaRequested},...s&&{creditCardInstallmentPlan:s},...n.msiEligibleCard&&{msiEligibleCard:n.msiEligibleCard}}}}}case"APPLE_PAY":{const n=e.walletContent;return n==null?null:{name:"APPLE_PAY",walletContent:{applePayWalletContent:{paymentMethodIdentifier:n?.paymentMethodIdentifier,version:n?.version??"",data:n?.data??"",signature:n?.signature??"",lastDigits:n?.lastDigits,cardNetworkBrand:n?.cardNetworkBrand,header:{ephemeralPublicKey:n?.header?.ephemeralPublicKey??"",publicKeyHash:n?.header?.publicKeyHash??"",transactionId:n?.header?.transactionId??"",applicationData:n?.header?.applicationData},...n?.billingAddress&&{billingAddress:n.billingAddress},expiresAt:n?.expiresAt??null}}}}case"GOOGLE_PAY":{const n=e.walletContent;return n==null?null:{name:"GOOGLE_PAY",walletContent:n?{googlePayWalletContent:{protocolVersion:n.protocolVersion,signature:n.signature,signedMessage:n.signedMessage,sessionId:n.sessionId??void 0,...n.paymentMethodIdentifier&&{paymentMethodIdentifier:n.paymentMethodIdentifier},...n.billingAddress&&{billingAddress:{streetAddress:n.billingAddress}}}}:void 0}}case"SHOPIFY_INSTALLMENTS":{const n=e.walletContent;return n==null?null:{name:"SHOPIFY_INSTALLMENTS",walletContent:{shopifyInstallmentsWalletContent:{...n,billingAddress:{streetAddress:n.billingAddress},paymentMethodIdentifier:n.paymentMethodIdentifier}}}}default:throw new $n(`Unable to handle wallet ${e.name}`)}}function ki(e){return e.shopPayApprovalId?{approvalId:e.shopPayApprovalId}:{token:e.token}}function Ei(e,t){return{paymentMethodIdentifier:e.paymentMethodIdentifier,name:e.name,billingAddress:{streetAddress:t}}}function Ri(e,t,o,n,s,i,r,d){const a=e.method.type,l=a==="wallet"&&e.method.name==="SHOP_PAY"&&e.method.walletContent?.shopPayAsPaymentMethodOptIn,p=a==="direct"?e.method:void 0,u=!l&&p?.creditCardInstallments?{installmentsCount:p.creditCardInstallments,intervalType:"MONTH"}:void 0;return{directPaymentMethod:a==="direct"&&e.method.sessionId||l?{paymentMethodIdentifier:l?e.method.walletContent?.paymentMethodIdentifier:e.method.paymentMethodIdentifier,sessionId:l?e.method.walletContent?.sessionId||"":e.method.sessionId||"",billingAddress:{streetAddress:t},...s&&{acceptedSubscriptionTerms:!0},cardSource:l?null:e.method.cardSource||null,...n&&{vaultingAgreement:n},paymentAttributes:l?null:e.method.paymentAttributes,installmentPlan:u}:null,giftCardPaymentMethod:a==="giftCard"&&"code"in e.method?{code:e.method.code,billingAddress:o?{streetAddress:t}:null}:null,ownedGiftCardPaymentMethod:a==="giftCard"&&!("code"in e.method)?{id:e.method.id}:null,redeemablePaymentMethod:a==="redeemable"&&e.method.redemptionContent?Ss(e.method,t):null,walletPaymentMethod:a==="wallet"&&!l?Pi(e.method,n,s):null,walletsPlatformPaymentMethod:a==="walletsPlatformPaymentMethod"?{name:e.method.name,walletParams:e.method.walletParams}:null,...a==="shopWallet"&&{shopWallet:ki(e.method)},localPaymentMethod:a==="local"?Ei(e.method,t):null,paymentOnDeliveryMethod:null,paymentOnDeliveryMethod2:a==="paymentOnDelivery"?{billingAddress:{streetAddress:t},paymentMethodIdentifier:e.method.paymentMethodIdentifier}:null,manualPaymentMethod:a==="manualPayment"?{id:e.method.id,billingAddress:{streetAddress:t},paymentMethodIdentifier:e.method.paymentMethodIdentifier}:null,customPaymentMethod:a==="customManualPayment"?{id:e.method.id,billingAddress:{streetAddress:t},paymentMethodIdentifier:e.method.paymentMethodIdentifier}:null,offsitePaymentMethod:a==="offsite"?{name:e.method.name,paymentMethodIdentifier:e.method.paymentMethodIdentifier,billingAddress:{streetAddress:t}}:null,customOnsitePaymentMethod:a==="customOnsite"?{name:e.method.name,paymentMethodIdentifier:e.method.paymentMethodIdentifier,billingAddress:{streetAddress:t},paymentAttributes:e.method.paymentAttributes??""}:null,deferredPaymentMethod:a==="deferred"&&(i&&r||!i)?{deferredPayment:!0}:null,customerCreditCardPaymentMethod:a===Ge.CreditCard?{token:e.method.token,paymentMethodIdentifier:e.method.paymentMethodIdentifier,...s&&{acceptedSubscriptionTerms:!0},cvvSessionId:e.method.cvvSessionId,...e.method.creditCardInstallments&&{installmentPlan:{installmentsCount:e.method.creditCardInstallments,intervalType:"MONTH"}}}:null,paypalBillingAgreementPaymentMethod:a===Ge.PayPal?{token:e.method.token,paymentMethodIdentifier:e.method.paymentMethodIdentifier,...s&&{acceptedSubscriptionTerms:!0}}:null,remotePaymentInstrument:a==="bank"&&e.method.selectedType&&e.method.selectedToken?(o&&d?.counter({name:"bank_payment_submit_result",value:1,attributes:{hasSelectedToken:"true"},exportImmediately:!0}),{paymentMethodIdentifier:e.method.paymentMethodIdentifier,billingAddress:{streetAddress:t},...n&&{vaultingAgreement:n},paymentCredentials:[{token:e.method.selectedToken,tokenType:e.method.selectedType}]}):(a==="bank"&&o&&(d?.counter({name:"bank_payment_submit_result",value:1,attributes:{hasSelectedToken:"false"},exportImmediately:!0}),d?.error(new pn(`Bank remotePaymentInstrument set to null in getPaymentMethod: selectedToken=${e.method.selectedToken?"present":"missing"}, selectedType=${e.method.selectedType?"present":"missing"}`))),null)}}function Fi(e,t,o,{isCompleting:n=!1,hasSellingPlan:s,hasFixedSellingPlan:i,acceptPaymentVaulting:r,hasPayableDeposit:d,useIntervalForTaxAndPayment:a,fixSubscriptionRedeemablePaymentAmount:l=!1,backendRedeemableCompletionAllocation:p=!1,negotiationRedeemableRecompute:u=!1,observability:y}){const{runningTotal:I,paymentDue:g,deferredTotal:S,checkoutTotal:M,orderDeposit:c,paymentTermsTemplateType:f}
1=e,P=(m,h)=>!m||!h?wt:{value:{amount:m.amount.toString(),currencyCode:m.currencyCode}},C=t.lines.filter(m=>{const{method:{type:h},cost:T}=m;if(h==="other"||h==="noop")return!1;const k=T&&T.amount>0;return h==="giftCard"?(!n||k||s)&&!i:h==="redeemable"?!0:!(g!=null&&!s&&n&&g.amount<=0)}),D=C.some(m=>m.method.type!=="deferred"),E=Wt({hasSellingPlan:s,hasFixedSellingPlan:i,paymentTermsTemplateType:f}),A=()=>f!=null||d||c!=null||!!(S&&S.amount.amount>0)||C.some(m=>m.due!=null||m.method.type==="deferred"),F=M?.currencyCode,v=l&&p&&E&&n&&F!=null&&!A()&&C.some(m=>!m.due&&Et(m)&&m.cost!=null&&m.cost.amount>0&&m.cost.currencyCode===F)&&C.filter(m=>!m.due&&!Et(m)).length===1&&C.some(m=>!m.due&&jn(m));l&&p&&E&&n&&y?.counter({name:"subscription_redeemable_completion_deferral",value:1,attributes:{deferred:String(v)},exportImmediately:!0});const _=M&&l&&!v?Ai({hasRegularSubscriptionPaymentTerms:E,isCompleting:n,allowAtNegotiation:u&&!A(),runningTotal:I,paymentDue:g,checkoutTotal:M,lines:C}):void 0;if(u&&E&&!n){const m=_?.redeemableAmounts.size??0,h=m>0;y?.counter({name:"subscription_redeemable_negotiation_recompute",value:1,attributes:{engaged:String(h),fixEnabled:String(l)}}),y?.log("subscription_redeemable_negotiation_recompute","[Payment] Negotiation-time subscription redeemable recompute",{engaged:h,fixEnabled:l,concreteRedeemableLines:m,hasCheckoutTotal:M!=null,deferredComponent:A()})}return C.map(m=>{const{method:{type:h},cost:T}=m,k=Ri(m,o,n,r,s,d,D,y),x=!!(T&&T.amount>0);if(h==="giftCard"){const R=_?.unconstrainedRedeemableLines.has(m)??!1,w=_?.redeemableAmounts.get(m);return{amount:P(R?void 0:w??T,!R&&(w!=null||x&&n)),paymentMethod:k}}if(h==="redeemable"){const R=_?.unconstrainedRedeemableLines.has(m)??!1,w=_?.redeemableAmounts.get(m),W=R?void 0:w??T,q=k.redeemablePaymentMethod?.redemptionSource,z=!R&&(q==="STORE_CREDIT"||q==="CUSTOM"?w!=null||x&&n:x);return{amount:P(W,z),paymentMethod:k}}const N=M&&Ti({fixSubscriptionRedeemablePaymentAmount:l,hasRegularSubscriptionPaymentTerms:E,line:m,isCompleting:n,paymentDue:g,completionAmount:_?.paymentMethodAmount,cost:T,coreAllocatesImmediateAmount:v});if(N)return we({line:m,paymentMethod:k,amount:N.amount,fillAmount:N.fillAmount,totalTaxRange:e.totalTaxRange,useIntervalForTaxAndPayment:S?!1:a});if(g==null)return{amount:wt,paymentMethod:k};const U=s||d||n&&g.amount>0;if(S&&M){const R=!!m.due;if(l&&(E||c&&M.amount<=0)){const w=n&&M.amount===0,W=w||!!(i||c)&&U&&M.amount>0;return w&&!R&&y?.counter({name:"zero_due_immediate_line_concretized",value:1,exportImmediately:!0}),we({line:m,paymentMethod:k,amount:R?S.amount:M,fillAmount:R?U:W,totalTaxRange:e.totalTaxRange,useIntervalForTaxAndPayment:!1})}return we({line:m,paymentMethod:k,amount:R?S.amount:M,fillAmount:U,totalTaxRange:e.totalTaxRange,useIntervalForTaxAndPayment:!1})}return we({line:m,paymentMethod:k,amount:g,fillAmount:U,totalTaxRange:e.totalTaxRange,useIntervalForTaxAndPayment:a})}).filter((m,h)=>{const T=m&&Object.values(m.paymentMethod).some(Boolean);return n&&!T&&m&&C[h]?.method.type==="bank"&&y?.error(new pn("Bank payment line dropped: all paymentMethod fields are null/falsy in paymentLinesForGraphQL")),!!T})}function Li(e,t){if(!t)return e.amount.toString();const o=t.interval.upperBound.amount-t.interval.lowerBound.amount;return B(e.amount+o).toString()}function we({line:e,paymentMethod:t,amount:o,fillAmount:n,totalTaxRange:s,useIntervalForTaxAndPayment:i}){const r={paymentMethod:t,due:xi(e)};return n?i?{...r,amount:{interval:{upperBound:{amount:Li(o,s),currencyCode:o.currencyCode}}}}:{...r,amount:{value:{amount:o.amount.toString(),currencyCode:o.currencyCode}}}:{...r,amount:{any:!0}}}function xi(e){return e.due&&"time"in e.due?{time:Di(e.due.time)}:e.due}function Di(e){const t=typeof e=="string"?new Date(e):e;if(!(t instanceof Date))return null;try{return t.toISOString()}catch{throw new Ci("Error converting date to ISO string")}}const hn={any:!0};function Ni({totalCost:e,totalTaxRange:t,useIntervalForTaxAndPayment:o}){if(!o)return{value:{amount:e.amount.toString(),currencyCode:e.currencyCode}};const n=t?.interval.upperBound??e;return{interval:{upperBound:{amount:n.amount.toString(),currencyCode:n.currencyCode}}}}function yn(e,t,o){if(e?.status==="available_total_included"&&t?.status==="available_total")return{proposedMixedStateTotalAmount:{proposedTotalAmount:{value:{amount:t.totalDuty.amount.toString(),currencyCode:t.totalDuty.currencyCode}},proposedTotalIncludedAmount:{value:{amount:e.totalIncludedInTarget.amount.toString(),currencyCode:e.totalIncludedInTarget.currencyCode}}},proposedTotalAmount:null,proposedTotalIncludedAmount:null};switch(e?.status){case"available_total_included":return{proposedTotalAmount:null,proposedTotalIncludedAmount:{value:{amount:e.totalIncludedInTarget.amount.toString(),currencyCode:e.totalIncludedInTarget.currencyCode}},proposedMixedStateTotalAmount:null};case"available_total":return{proposedTotalAmount:Ni({useIntervalForTaxAndPayment:o?.useIntervalForTaxAndPayment??!1,totalCost:e.totalCost,totalTaxRange:e.totalTaxRange}),proposedTotalIncludedAmount:null,proposedMixedStateTotalAmount:null};default:return{proposedTotalAmount:hn,proposedTotalIncludedAmount:null,proposedMixedStateTotalAmount:null}}}function wi(e){const o=new Map;return e?.forEach((n,s)=>{switch(n.status){case"available_total_included":return o.set(s,{proposedTotalAmount:null,proposedTotalIncludedAmount:{value:{amount:n.totalIncludedInTarget.amount.toString(),currencyCode:n.totalIncludedInTarget.currencyCode}},proposedMixedStateTotalAmount:null});case"available_total":return o.set(s,{proposedTotalAmount:{value:{amount:n.totalCost.amount.toString(),currencyCode:n.totalCost.currencyCode}},proposedTotalIncludedAmount:null,proposedMixedStateTotalAmount:null});
1case"pending":case"unavailable":return o.set(s,{proposedTotalAmount:hn,proposedTotalIncludedAmount:null,proposedMixedStateTotalAmount:null});default:return rn(n)}}),o}class Oi extends Error{constructor(){super(...arguments),this.name="MissingRemoteSessionTokenError"}}const ne={any:!0},Bi={get:()=>"dedicated"};function Ui({shopId:e,merchandiseLines:t,deliveryTermsInput:o,paymentDetails:n,sessionToken:s,queueToken:i,taxesInput:r,isCompleting:d=!1,shippingAddress:a,isShippingRequired:l,availableDeliveryAddresses:p,primaryPaymentMethod:u,observability:y,extendedAddressMode:I}){if(!s)throw new Oi(`No session token for remote shop: ${e}`);if(o.deliveryLines.length===0&&t.length>0){const m=p?.find(h=>it(h.address,a,["phone"])&&Ht(h.address,a));o.deliveryLines.push({destination:(()=>{if(l)return m?{deliveryAddressReference:Ue(m.address)}:d?{streetAddress:Ve(a,{extendedAddressMode:I})}:{partialStreetAddress:Ve(a,{extendedAddressMode:I})}})(),selectedDeliveryStrategy:{deliveryStrategyMatchingConditions:{estimatedTimeInTransit:ne,shipments:ne},options:{}},targetMerchandiseLines:ne,deliveryMethodTypes:[l?"SHIPPING":"NONE"],expectedTotalPrice:ne,destinationChanged:!1})}const g=r??{proposedTotalAmount:ne},{paymentDue:S,sessionId:M,paymentMethodIdentifier:c,billingAddress:f,cardSource:P,paymentAttributes:C,paymentFlexibilityTermsId:D,preserveBillingAddressExtendedFields:E}=n??{},A=E?Bi:I,F=S&&S.amount>0&&f&&M&&u,v=[];if(F){const m=Yi({primaryPaymentMethod:u,sessionId:M,billingAddress:f,cardSource:P,paymentAttributes:C,paymentMethodIdentifier:c,observability:y,extendedAddressMode:A});m&&v.push({amount:d?{value:{amount:String(S.amount),currencyCode:S.currencyCode}}:ne,paymentMethod:m})}const _={totalAmount:ne,paymentLines:v,...f&&{billingAddress:{streetAddress:ae(f,{extendedAddressMode:A})}},...D&&{paymentFlexibilityTermsId:D}};return{shopId:e,delivery:o,merchandise:{merchandiseLines:t},payment:_,sessionToken:s,queueToken:i,taxes:g}}function Gi({deliveryTermsInputByShop:e,merchandiseByShop:t,perShopSessionToken:o,perShopQueueToken:n,perShopTaxes:s,paymentDetailsByShop:i,isCompleting:r,shippingAddress:d,negotiatedMerchandiseLines:a,availableDeliveryAddresses:l,primaryPaymentMethod:p,observability:u,extendedAddressMode:y}){if(t.size!==0)return{remoteNegotiations:Array.from(t.entries()).map(([I,g])=>{const S=i?.get(I),M=a.filter(({stableId:c})=>g.some(f=>f.stableId===c)).some(c=>c.requiresShipping);return Ui({shopId:I,deliveryTermsInput:e[I]??{deliveryLines:[],noDeliveryRequired:[],useProgressiveRates:!1},merchandiseLines:g,paymentDetails:S,sessionToken:o?.get(I),queueToken:n?.get(I),taxesInput:s.get(I),isCompleting:r,shippingAddress:d,isShippingRequired:M,availableDeliveryAddresses:l,primaryPaymentMethod:p,observability:u,extendedAddressMode:y})})}}function Vi({deliveryInput:e,merchandiseDetails:t,paymentDetailsByShop:o,perShopSessionToken:n,perShopTaxes:s,isCompleting:i,primaryPaymentMethod:r,observability:d,perShopQueueToken:a,extendedAddressMode:l}){const{stableIdToShopId:p,merchandiseLines:u}=t;if(p==null||p.size===0||n==null||n.size===0)return{delivery:e.deliveryTermsInput,merchandiseLines:u};const{localMerchandise:y,remoteMerchandiseByShop:I}=Hi(u,p),{deliveryTermsInputByShop:g,delivery:S}=qi(e.deliveryTermsInput,p),M=Gi({deliveryTermsInputByShop:g,merchandiseByShop:I,perShopSessionToken:n,perShopQueueToken:a,perShopTaxes:s,paymentDetailsByShop:o,isCompleting:i,shippingAddress:e.shippingAddress,negotiatedMerchandiseLines:e.negotiatedMerchandiseLines,availableDeliveryAddresses:e.availableDeliveryAddresses,primaryPaymentMethod:r,observability:d,extendedAddressMode:l});return{delivery:S,merchandiseLines:y,remote:M}}function qi(e,t){const{deliveryLines:o,...n}=e,s={},i=[];return new Set(t.values()).forEach(d=>{s[d]={...n,deliveryLines:[]}}),o.forEach(d=>{const a=d.targetMerchandiseLines.lines?.[0],l=a?t.get(a.stableId??""):void 0,p=l?s[l]:void 0;p?p.deliveryLines.push(d):i.push(d)}),{deliveryTermsInputByShop:s,delivery:{deliveryLines:i,...n}}}function Hi(e,t){const o=[],n=new Map;return e.forEach(s=>{const i=s.stableId==null?void 0:t.get(s.stableId);if(i){const r=n.get(i)||[];n.set(i,[...r,s])}else o.push(s)}),{localMerchandise:o,remoteMerchandiseByShop:n}}function Wi(e,t){return ae({address1:e.address1??void 0,address2:e.address2??void 0,city:e.city,company:e.company??void 0,countryCode:e.countryCode??void 0,firstName:e.firstName??void 0,lastName:e.lastName??void 0,postalCode:e.postalCode??void 0,zoneCode:e.zoneCode??void 0,phone:e.phone??void 0,district:e.extendedFields?.district??void 0,line2:e.extendedFields?.line2??void 0,streetName:e.extendedFields?.streetName??void 0,streetNumber:e.extendedFields?.streetNumber??void 0,subdistrict:e.extendedFields?.subdistrict??void 0},{extendedAddressMode:t})}function Yi({primaryPaymentMethod:e,sessionId:t,billingAddress:o,cardSource:n,paymentAttributes:s,paymentMethodIdentifier:i,observability:r,extendedAddressMode:d}){if(Qi(e))return{directPaymentMethod:{sessionId:t,paymentMethodIdentifier:i,cardSource:n,paymentAttributes:s,billingAddress:{streetAddress:ae(o,{extendedAddressMode:d})}}};if(zi(e)){const a=e.walletContent;return a==null?null:{walletPaymentMethod:{name:"SHOP_PAY",walletContent:{shopPayWalletContent:{sessionToken:t,billingAddress:{streetAddress:Wi(a.billingAddress,d)},paymentAttributes:a.paymentAttributes,paymentMethod:a.paymentMethod,paymentMethodIdentifier:i,addressId:a.addressId,...a.hsaRequested!=null&&{hsaRequested:a.hsaRequested},...a.creditCardInstallments&&{creditCardInstallmentPlan:{installmentsCount:a.creditCardInstallments,intervalType:"MONTH"}},...a.msiEligibleCard&&{msiEligibleCard:a.msiEligibleCard}}}}}}else return r?.log("unexpected_remote_payment_method_type","Expected direct or Shop Pay wallet payment method for remote negotiation",{primaryPaymentMethodType:e.type}),null}function Qi(e){return e.type==="direct"}function zi(e){return e.type==="wallet"&&e.name==="SHOP_PAY"}function ji(e,t){return t==null?e:e.filter(({totalPrice:o})=>o==null||o.currencyCode===t)}function $i(e){if(e===void 0||e.optIn===void 0||e.optIn===!1)return e;const{isAutoOptIn:t,...o}=e.optIn;return{...e,optIn:o}}const Ki=["SHOP_PAY","SHOPIFY_INSTALLMENTS","GOOGLE_PAY"];function fn(e){const t=e?.optIn;return!!(t&&t.isAutoOptIn===!1&&t.vaultPhone==="")}function Ji(e,t,o,n,s){const i=fn(o),r=$i(o);if(!e)return r;if(n)return{optIn:{vaultPhone:i?"":s??"",vaultEmail:"",optInSource:"REMEMBER_ME"}};const d=r?.optIn;let a=d?d.vaultPhone:void 0;if(r?.shopUser?.uuid||(a=i?a??s:a||s),a=a??"",r?.shopUser?.uuid&&r?.optIn===void 0)return r;const p=r===void 0||r.optIn===!1?!1:{...r.optIn,vaultPhone:a,vaultEmail:t?"":r.optIn?.vaultEmail};return{...r,optIn:p}}function Xi({paymentLines:e,shopPayArtifact:t,shopPayRememberMeVisible:o,isManagedByMarketsPro:n,isApplePayInShopPayEnabled:s,isCompleting:i,wallets:r}){const d=!!t?.shopUser?.uuid;if(!o&&!d||r?.escalatedWallet.value||n&&Kn(e))return!1;const l=s&&i;if(Jn(e,"APPLE_PAY")&&!l)return!1;const p=e[0]?.method,u=d&&p?.type==="wallet"&&p.name==="SHOPIFY_INSTALLMENTS";return!((!d||u)&&(p?.type==="wallet"&&Ki.includes(p?.name)||p?.type==="walletsPlatformPaymentMethod"||r?.activeSession.value?.asPaymentMethod===!1)||!(!!(t?.optIn&&!d)||d))}
1class Zi extends Error{constructor(){super(...arguments),this.name="MissingSessionTokenError"}}class er extends Error{constructor(){super(...arguments),this.name="MissingShopPayAlternativePaymentMethodError"}}const tr={any:!0},Ot={get:()=>"dedicated"};function nr(e,t){const{parts:o}=e,n=e.current.value,s=o.paymentLines.value,i=n.runningTotal&&n.runningTotal?.amount<=0,r=$t(n.merchandiseLines?.lines).some(p=>!!p.sellingPlan?.subscriptionDetails);if(!(!i||r||n.deferredTotal?.amount.amount))return!1;const a=zt(n.buyerIdentity?.customerProfile),l=s&&s[0];return!l||l.method.type!=="wallet"||a&&l.method.name==="APPLE_PAY"?!1:["GOOGLE_PAY","APPLE_PAY"].includes(l.method.name)?!0:l.method.name!=="PAYPAL_EXPRESS"?!1:t}function gn(e){return e.find(t=>t.method.type===Ge.CreditCard||t.method.type===Ge.PayPal)}function or(e){return gn(e.parts.paymentLines.peek())?.method.billingAddress}function sr(e){return e.some(({method:t})=>t.type==="wallet"&&t.name==="SHOPIFY_INSTALLMENTS")}function ir(e){return!!e?.some(({paymentMethod:t})=>t.walletPaymentMethod?.name==="SHOPIFY_INSTALLMENTS"||t.walletPaymentMethodConfig?.name==="SHOPIFY_INSTALLMENTS")}function rr(e,t,o){const{parts:n,source:s,facts:i}=e,r=e.current.peek(),d=n.paymentLines.peek(),l=i.delivery?.[0]?.deliveryAddress??n.shippingAddress.peek(),p=n.billingAddress.peek(),u=!p.address1&&i.billingAddress?i.billingAddress:p,y=n.billingAddressOption.peek(),I=r.isShippingRequired,g=ao(s)?i.requiresShipping:I,S=gn(d);if(S)return o?.log("get_negotiation_input_vaulted_payment_billing_address_used","[getPaymentAddress] Using vaulted payment billing address"),S.method.billingAddress;const M=lo(d),c=y==="shipping"&&M,f=(()=>{const P=r.buyerIdentity?.purchasingCompany;if(P){if(y==="billing"&&P.location.billingAddress)return P.location.billingAddress;if(c)return P.location.shippingAddress??l}})();return f?(o?.log("get_negotiation_input_company_location_address_used","[getPaymentAddress] Using company location address"),f):y==="billing-fact"?(o?.log("get_negotiation_input_billing_fact_address_used","[getPaymentAddress] Using billing-fact address"),u):nr(e,t)?(o?.log("get_negotiation_input_wallet_billing_address_used","[getPaymentAddress] Using wallet billing address"),u):g&&c?(o?.log("get_negotiation_input_shipping_address_used","[getPaymentAddress] Using shipping address"),l):(o?.log("get_negotiation_input_default_billing_address_used","[getPaymentAddress] Using default billing address"),u)}function vn(e){return e.current.token??null}function ar({proposedTotalAmount:e,proposedTotalIncludedAmount:t,proposedMixedStateTotalAmount:o}){return{amount:Oe(e),includedAmount:Oe(t),mixedState:o?{amount:Oe(o?.proposedTotalAmount),includedAmount:Oe(o?.proposedTotalIncludedAmount)}:void 0}}function Oe(e){if(!e)return{type:"none"};if(e.any)return{type:"any"};if(e.interval){const t=e.interval.upperBound;return{type:"interval",amount:t?.amount,currencyCode:t?.currencyCode}}return e.value?{type:"value",amount:e.value.amount,currencyCode:e.value.currencyCode}:{type:"unknown"}}function dr(e,t){if(t.mixedState){const o=t.mixedState.amount,n=t.mixedState.includedAmount;if(e==="available_total")return o.type==="value"||o.type==="interval"?Be(o.amount):!0;if(e==="available_total_included")return n.type==="value"||n.type==="interval"?Be(n.amount):!0}if(e==="available_total")return t.amount.type==="value"||t.amount.type==="interval"?Be(t.amount.amount):!0;if(e==="available_total_included"){const o=t.includedAmount.type==="none"?t.mixedState?.includedAmount:t.includedAmount;return o&&o.type==="value"?Be(o.amount):!0}return!0}function Be(e){if(e==null)return!0;const t=Number(e);return Number.isFinite(t)?t===0:!0}function lr({acceptEmailMarketing:e,acceptSmsMarketing:t,smsMarketingPhone:o,smsMarketingCountryCode:n,email:s,isBusinessCustomer:i,emailMarketingConsentGrantReached:r,useMessagingMarketingConsent:d,emailMarketingOptInShown:a}){const l=[];if(i)return l;if(!d&&o&&l.push({sms:{consentState:t?"GRANTED":"DECLINED",value:o,countryCode:n}}),s){const p=ur({acceptEmailMarketing:e,emailMarketingConsentGrantReached:r,emailMarketingOptInShown:a});p&&l.push({email:{consentState:p,value:s}})}return l}function ur({acceptEmailMarketing:e,emailMarketingConsentGrantReached:t,emailMarketingOptInShown:o}
1){if(e)return o&&!t?"PARTIALLY_GRANTED":"GRANTED";if(o)return"DECLINED"}function cr({acceptSmsMarketing:e,smsMarketingPhone:t,countryCode:o,disclosureCountryCode:n,isBusinessCustomer:s,smsMarketingOptInShown:i}){if(!(s||!i))return e?t?{consentState:"GRANTED",phoneNumber:t,...o?{countryCode:o}:{},...n?{disclosureCountryCode:n}:{}}:void 0:{consentState:"DECLINED",...t?{phoneNumber:t}:{},...o?{countryCode:o}:{},...n?{disclosureCountryCode:n}:{}}}function mr({proposedDeliveryLines:e,negotiatedDeliveryNext:t,shipPickupInOneOrderEnabled:o}){if(o){const i=e.filter(r=>!r.value.deliveryMethodTypes.includes("NONE"));return i.length>0&&i.every(r=>r.value.deliveryMethodTypes.includes("PICK_UP"))}const n=mo(t,"ONE_TIME_PURCHASE");return po(n)?.methodType==="PICK_UP"}function pr(e){const t=e.email.peek().trim(),o=e.phone.peek().trim(),n=e.acceptEmailMarketing.peek(),s=e.acceptSmsMarketing.peek(),i=e.smsMarketingPhone.peek(),r=e.purchaseOrderNumber.peek(),d=e.acceptPaymentVaulting.peek(),a=e.shopPayArtifact.peek(),l=e.optionalDuties.peek(),p=e.captcha.peek(),u=e.shippingAddress.peek(),y=e.billingAddress.peek(),I=e.availableRedeemables.peek(),g=e.attribution.peek(),S=e.saleAttributions.peek(),M=e.reduction.peek(),c=e.deliveryLines.peek(),f=e.externalDeliveryIds.peek(),P=e.discountLines.peek(),C=e.merchandiseLines.peek(),D=e.locationAddress.peek(),E=e.useProgressiveRates.peek(),A=e.interfaceFlow.peek(),F=e.tipLines.peek(),v=e.note.peek(),_=e.attributes.peek(),m=e.cartMetafields.peek(),h=e.memberships.peek(),T=e.rememberMe.peek(),k=e.setShippingAddressAsDefault.peek(),x=e.shopPayRememberMeVisible.peek(),N=e.taxExemptions.peek(),U=e.useStoreCreditForSubscriptionRenewals.peek();return{attributes:_,email:t,phoneNumber:o,acceptEmailMarketing:n,acceptSmsMarketing:s,smsMarketingPhone:i,purchaseOrderNumber:r,acceptPaymentVaulting:d,shopPayArtifact:a,optionalDuties:l,captcha:p,shippingAddress:u,billingAddress:y,availableRedeemables:I,attribution:g,saleAttributions:S,reduction:M,proposedDeliveryLines:c,externalDeliveryIds:f,discountLines:P,merchandiseLines:C,locationAddress:D,useProgressiveRates:E,interfaceFlow:A,tipLines:F,note:v,rememberMe:T,setShippingAddressAsDefault:k,shopPayRememberMeVisible:x,cartMetafields:m,memberships:h,taxExemptions:N,useStoreCreditForSubscriptionRenewals:U}}function hr(e){return e.localizationExtensions.peek().map(t=>{const{key:o,value:n}=t.peek();return{key:o,value:n||""}})}function yr(e){return e.deliveryExpectations&&e.deliveryExpectations.status==="filled"&&e.deliveryExpectations.deliveryExpectationLines.filter(t=>t.signedHandle).map(t=>({signedHandle:t.signedHandle}))||[]}class fr extends Error{constructor(){super(...arguments),this.name="DirectPaymentLinesMismatchError"}}function gr(e,t,o){const n=Jo(t);return e.cachedMembershipViolations.value.filter(s=>Xo(s,o,n))}function vr(e,t,o){if(e.status!=="filled")return{memberships:[],violations:[]};const n=gr(t,e,o),s=n.map(r=>r.handle);return{memberships:e.memberships.map(r=>{const d=!s.includes(r.handle);return{handle:r.handle,apply:d?r.apply:!1}}),violations:n}}function br(e){return{memberships:e.map(t=>({handle:t.handle,apply:t.apply}))}}function bn(e,{isCompleting:t=!1,customizeNegotiation:o,observability:n,paymentLinesObservability:s,wallets:i}={}){if(!e.sessionToken)throw new Zi("No session token");const{parts:r,throttle:d,checkout:a}=e,{extendedAddressMode:l}=a.address,p=a.unstable_graphqlDataRequestInfo?.httpRequestInfo?.geolocation?.coordinates??void 0,u=e.shop.shipPickupInOneOrderEnabled,y=e.current.peek().deliveryNext,I=y?.status==="filled"||y?.status==="partial",g=u&&(!I||y.supportsSplitDeliveryMethod)?!0:void 0,S=Xn(e.context.bankIdNumberSignal.peek()),{attributes:M,email:c,phoneNumber:f,acceptEmailMarketing:P,acceptSmsMarketing:C,smsMarketingPhone:D,purchaseOrderNumber:E,acceptPaymentVaulting:A,shopPayArtifact:F,shopPayRememberMeVisible:v,optionalDuties:_,captcha:m,shippingAddress:h,billingAddress:T,availableRedeemables:k,attribution:x,saleAttributions:N,reduction:U,proposedDeliveryLines:R,externalDeliveryIds:w,discountLines:W,merchandiseLines:q,locationAddress:O,useProgressiveRates:z,interfaceFlow:Y,tipLines:j,note:L,rememberMe:Q,setShippingAddressAsDefault:ee,cartMetafields:de,memberships:ye,taxExemptions:qe,useStoreCreditForSubscriptionRenewals:le}=pr(r);let G=r.paymentLines.peek();const te=G[0]?.method,ue=Yt(e.shop),fe=_s({shop:e.shop,checkout:e.checkout,paymentMethods:e.current.peek().paymentMethods}),$=rr(e,fe,n),X=$===or(e)?Ot:l,oe={extendedAddressMode:X};if(t&&F?.shopUser&&As(te,e.current.fields.paymentMethods.peek(),e.shopPay.session.selectedPaymentMethod.value)){const H=Is(te)?te:_r(e.current.fields.paymentMethods.peek(),e.shopPay.session.selectedPaymentMethod.value);H?G=Zn(G,Sr({paymentMethod:H,billingAddress:$,extendedAddressMode:X}),ue):n?.error(new er("Failed to resolve Shop Pay alternative payment method from available payment methods"))}const He=sr(G)||e.shopPay.session.isInstallmentsSelected.value?[]:j,b=e.current.peek(),We=eo({availableDeliveryAddresses:b.availableDeliveryAddresses,mustSelectProvidedAddress:b.mustSelectProvidedAddress}),se=b.shippingAddress,ce=b.contactInfo?.email,Ye=b.merchandiseLines?.lines?.[0]?.totalPrice.currencyCode||b.buyerIdentity?.presentmentCurrency,ge=ji(q,Ye),ve=un(ge),be=Qt(b),Se=!!be?.amount,me=!se||!to(h,se,["phone"]);me&&se?.oneTimeUse&&(h.oneTimeUse=!1);const ie=t&&G.length===1?G[0]:void 0,_e=ie!==void 0&&ie.method.type==="wallet"&&(ie.method.name==="APPLE_PAY"||ie.method.name==="GOOGLE_PAY")&&i?.escalatedWallet.value!=="APPLE_PAY",{proposedTotalAmount:Ae,proposedTotalIncludedAmount:Ie,proposedMixedStateTotalAmount:Me}=yn(b.taxes,b.duties,{useIntervalForTaxAndPayment:_e}),Te=ar({proposedTotalAmount:Ae,proposedTotalIncludedAmount:Ie,proposedMixedStateTotalAmount:Me}),pe=b.allViolations?.map(H=>H.code)??[],Qe=pe.includes("TAX_NEW_TAX_MUST_BE_ACCEPTED"),ze=pe.includes("PAYMENTS_UNACCEPTABLE_PAYMENT_AMOUNT"),je=b.taxes?.status??"missing";n&&t&&dr(je,Te)&&n.log("shop_pay_installments_tax_terms_missing_on_negotiation","[Negotiate] Completing without accepted tax terms",{hasTaxViolation:Qe,hasPaymentAmountViolation:ze,taxProposalSummary:Te,taxes:b.taxes,installmentsPaymentSet:!!e.shopPay.installments.payment.value,violationCodes:pe});const $e=wi(b.remoteTaxDetails?.perShopTaxes),Ce=b.buyerIdentity?.customerProfile,Pe=zt(Ce),he=Ko(r),ke=e.context.emailMarketingOptInShownSignal.value,Ee=e.context.emailMarketingConsentGrantReachedSignal.value||b.emailMarketingConsentGrantReached,Ke=e.context.smsMarketingOptInShownSignal.value,Re=t&&C&&i?.activeSession.value&&e.context.marketingPhoneInputError.peek()?void 0:D,ht=cs({isShippingRequired:a.isShippingRequired.peek(),isPickupSelected:mr({proposedDeliveryLines:R,negotiatedDeliveryNext:y,shipPickupInOneOrderEnabled:u}),shippingCountryCode:h.countryCode,billingCountryCode:T.countryCode}),yt=!!ms(e.shop,ht),Mn=lr({acceptEmailMarketing:P,acceptSmsMarketing:C,smsMarketingPhone:Re,smsMarketingCountryCode:he,email:c,isBusinessCustomer:Pe,emailMarketingConsentGrantReached:Ee,useMe
1ssagingMarketingConsent:yt,emailMarketingOptInShown:ke}),Tn=yt?cr({acceptSmsMarketing:C,smsMarketingPhone:Re,countryCode:he,disclosureCountryCode:ht,isBusinessCustomer:Pe,smsMarketingOptInShown:Ke}):void 0,Cn=!Ke||!C,Pn=e.context.shopPayMobilePhoneInputShownSignal.value,kn=!f&&!h?.phone&&!T?.phone&&!Pn,{isOnePage:En}=e.checkout.configuration.layout,Rn=En.peek()?"one-page":"three-page",ft=b.smsMarketingPhone??"";let Fe;ft===""?Fe="not-in-negotiated":ft===Re?Fe="matches-negotiated":Fe="differs-from-negotiated",n&&Re&&kn&&Cn&&n.log("sms_marketing_phone_sent_without_visible_phone_input","[Proposal] SMS marketing phone included while no phone input was visible",{acceptSmsMarketing:C,checkoutLayout:Rn,contactPhonePresent:!!f,contactEmailPresent:!!c,hasSmsMarketingPhone:!0,isCompleting:t,shopSmsMarketingSetting:e.shop.smsMarketing,smsMarketingOptInShown:Ke,smsMarketingPhoneSource:Fe,sourceType:e.source?.type});const Fn=jt(b.merchandiseLines?.lines),Ln=$t(b.merchandiseLines?.lines).some(H=>H.sellingPlan?.isFixed),xn=b.canUpdateDiscountCodes??!1,gt=Kt({customAttributes:b.customAttributes}),Dn=Jt({customAttributes:b.customAttributes}),Nn=gt&&!!h&&Dn,vt=e.shopPay.session.secureData.value,Je=e.source?.type==="draftOrder",bt=ye?vr(ye,e.context,h):void 0;e.context.cachedMembershipViolations.value=bt?.violations||[];const wn=br(bt?.memberships||[]),Xe=ae($,oe),Ze=Ft(G,$,r.billingAddressOption.peek(),oe,Je)?.streetAddress;if(Ze&&Xe){const K=["address1","city","countryCode","postalCode"].filter(V=>Xe[V]!==Ze[V]);K.length>0&&n?.log("get_negotiation_input_billing_address_mismatch_detected","Billing address mismatch detected between payment lines and billing address inputs",{mismatchedFields:K,paymentLinesBillingAddress:Xe,billingAddress:Ze,billingAddressOption:r.billingAddressOption.peek()})}if(t&&n){const H=b.paymentMethods?.map(V=>V.type==="direct"?{paymentMethodIdentifier:V.paymentMethodIdentifier,name:V.name}:void 0).filter(Boolean),K=G.find(V=>!!(V.method.type==="direct"&&V.method.creditCardLastFourDigits&&V.method.brand))?.method.paymentMethodIdentifier;h.countryCode==="US"&&K&&!H?.some(V=>V?.paymentMethodIdentifier===K)&&n?.error(new fr("Completing with a direct payment line mismatch with seller proposal available payment methods"),{metadata:{value:{buyerDirectPaymentMethodIdentifiers:JSON.stringify(K),availableDirectPaymentMethods:JSON.stringify(H)}}})}const et=Xs({lines:ge}),Le=b.remoteMerchandiseDetails?.stableIdToShopId;t&&no(h.postalCode,h.countryCode)&&n?.log("wallets_shipping_address_postal_code_in_submit_input","Padded postal code detected in shipping address at SubmitForCompletion time",{countryCode:h.countryCode});const St={deliveryLines:ii({shippingAddress:h,proposedDeliveryLines:R,externalDeliveryIds:w,destinationChanged:me,isSubmitForCompletion:t,isPointOfSale:gt,isPointOfSaleShipToHome:Nn,negotiatedDelivery:b.deliveryNext,filteredMerchandiseStableIds:ve,locationAddress:O,geolocationCoordinates:p,retailLocationId:oo({customAttributes:b.customAttributes}),isShippingRequired:b.isShippingRequired,availableDeliveryAddresses:b.availableDeliveryAddresses,isConstrainedAddress:We,extendedAddressMode:l,marketDrivenShippingEnabled:e.shop.marketDrivenShippingEnabled,stableIdToShopId:Le,remoteShopsConfigMap:e.shop.remoteShopsConfigMap}),noDeliveryRequired:[],useProgressiveRates:z,prefetchShippingRatesStrategy:null,interfaceFlow:Y,supportsSplitShipping:a.supportsSplitShipping.value,acceptSplitDelivery:g},_t=!!(Le&&Le.size>0),{delivery:On,merchandise:At,remoteNegotiations:It}=_t?(()=>{const H=new Map,K=e.parts.remotePaymentDetails.peek();if(K&&G.length>0){const{method:Pt}=G.find(nt=>nt.method.type==="direct")??{};for(const[nt,qn]of K){const Hn={...qn,cardSource:Pt?.cardSource??null,paymentAttributes:Pt?.paymentAttributes,billingAddress:$,preserveBillingAddressExtendedFields:X===Ot};H.set(nt,Hn)}}const{delivery:V,merchandiseLines:Gn,remote:Vn}=Vi({deliveryInput:{deliveryTermsInput:St,shippingAddress:h,negotiatedMerchandiseLines:b.merchandiseLines?.lines??[],availableDeliveryAddresses:b.availableDeliveryAddresses}
1,perShopSessionToken:b.remoteSessionDetails?.perShopSessionToken,perShopQueueToken:b.remoteSessionDetails?.perShopQueueToken,perShopTaxes:$e,merchandiseDetails:{merchandiseLines:et.merchandiseLines,stableIdToShopId:Le},paymentDetailsByShop:H,primaryPaymentMethod:te,observability:n,isCompleting:t,extendedAddressMode:l});return{delivery:V,merchandise:{...et,merchandiseLines:Gn},remoteNegotiations:Vn}})():{merchandise:et,delivery:St,remoteNegotiations:void 0},xe=!(_t&&At.merchandiseLines.length===0),Mt=e.checkout.rememberMe.createAccountOptIn.value,Tt=fn(F)?void 0:h.phone||T.phone,Bn=(r.shippingAddress?.dirtyFields?.value?.size??0)>0||(r.billingAddress?.dirtyFields?.value?.size??0)>0,Un=Js({buyerEditedAddress:Bn,shopUserSecureData:vt,shopPayVerificationTrigger:e.shopPay?.session?.verificationTrigger?.value,customerProfile:Ce}),Ct={checkpointData:a.checkpointToken.value,sessionInput:{sessionToken:e.sessionToken},queueToken:vn(d),discounts:{lines:vi({lines:W},q,n),acceptUnexpectedDiscounts:Je?b.acceptUnexpectedDiscounts:xn},...xe?{delivery:On}:{},deliveryExpectations:{deliveryExpectationLines:yr(b)},merchandise:At,memberships:wn,availableRedeemables:ni(k),...xe?{payment:{totalAmount:tr,paymentLines:Fi({runningTotal:b.runningTotal,paymentDue:b.paymentDue,deferredTotal:b.deferredTotal,checkoutTotal:b.checkoutTotal,orderDeposit:be,paymentTermsTemplateType:b.paymentFlexibilityPaymentTermsTemplate?.type,totalTaxRange:b.taxes?.status==="available_total"?b.taxes.totalTaxRange:void 0},{lines:G},ae($,oe),{isCompleting:t,hasSellingPlan:Fn,hasFixedSellingPlan:Ln,acceptPaymentVaulting:A,hasPayableDeposit:Se,useIntervalForTaxAndPayment:_e,fixSubscriptionRedeemablePaymentAmount:ue,backendRedeemableCompletionAllocation:e.shop.hasFlagEnabled(ro),negotiationRedeemableRecompute:io(e.shop),observability:n??s}),billingAddress:Ft(G,$,r.billingAddressOption.peek(),oe,Je),paymentFlexibilityTermsId:b.paymentFlexibilityPaymentTermsTemplate?.id,creditCardBin:S,allowStoreCredit:le}}:{},buyerIdentity:{customer:{presentmentCurrency:b.buyerIdentity?.presentmentCurrency,countryCode:b.buyerIdentity?.countryCode},email:c||void 0,...c?{emailChanged:!ce||ce!==c}:{},phone:f||void 0,phoneCountryCode:he||void 0,marketingConsent:Mn,messagingMarketingConsent:Tn,shopPayOptInPhone:{number:Tt,countryCode:h?.countryCode||T?.countryCode||b.buyerIdentity?.countryCode},shopUserSecureData:vt,prefillSource:Un,rememberMe:Q,setShippingAddressAsDefault:t?ee:void 0},tip:{tipLines:Ms(He)},poNumber:E===""?null:E,...xe?{taxes:{proposedAllocations:null,proposedTotalAmount:Ae,proposedTotalIncludedAmount:Ie,proposedMixedStateTotalAmount:Me,proposedExemptions:qe}}:{},...xe?{note:Si(b,L,M)}:{},localizationExtension:{fields:hr(r)},shopPayArtifact:Mt||Xi({paymentLines:G,shopPayArtifact:F,shopPayRememberMeVisible:v,isManagedByMarketsPro:!!b.managedByMarketsPro,isApplePayInShopPayEnabled:!e.shop.hasFlagEnabled(so),isCompleting:t,wallets:i})?Ji(t,c,F,Mt,Tt):void 0,nonNegotiableTerms:b.nonNegotiableTerms?bi(b.nonNegotiableTerms):null,
1scriptFingerprint:b.scriptFingerprint,transformerFingerprintV2:b.transformerFingerprintV2,optionalDuties:_?_i(_.buyerRefusesDuties):null,attribution:x,captcha:oi(m),reduction:U,saleAttributions:N,alternativePaymentCurrency:ti(b.alternativePaymentCurrency),cartMetafields:de,...It?{remote:It}:{}},tt=o?o(Ct):Ct;return ir(tt.payment?.paymentLines)?{...tt,tip:{tipLines:[]}}:tt}function Sr({paymentMethod:e,billingAddress:t,extendedAddressMode:o}){return{method:{type:"wallet",name:"SHOP_PAY",walletContent:{paymentMethod:"CUSTOM_ONSITE",billingAddress:ae(t,{extendedAddressMode:o}),paymentMethodIdentifier:e.paymentMethodIdentifier||"",paymentAttributes:e.paymentAttributes}}}}function _r(e,t){if(t?.paymentMethod==="CUSTOM_ONSITE"&&"paymentBrands"in t){const n=t.paymentBrands??[],s=e.find(i=>uo(i,n));if(s)return{type:"customOnsite",paymentMethodIdentifier:s.paymentMethodIdentifier,name:s.name,paymentBrands:n}}const o=e.find(n=>co(n));if(o)return{type:"customOnsite",paymentMethodIdentifier:o.paymentMethodIdentifier,name:"iDEAL",paymentBrands:["ideal"]}}const Ar={id:"5c7ad3f62cf3f361adc20527f69feb315c540e12c3354b9ffe4f6732bf0cc82d",type:"mutation",name:"SubmitForCompletion",source:""};function Ir(){return{requestUrl:window.location.href,pageId:window.trekkie?.trekkie?.defaultAttributes?.microSessionId}}function Mr(e){return ho(e??[])?.installmentPlans?.find(n=>n.type==="MSI")?.supportedInstallments??[]}function Tr({paymentDue:e,remotePaymentDue:t,remoteMerchandiseDetails:o}){return!!o?.stableIdToShopId.size&&t?t:e}function Cr({observability:e,userEvents:t,paymentLines:o,paymentMethods:n,paymentDue:s,remotePaymentDue:i,remoteMerchandiseDetails:r,shopId:d,checkoutToken:a}){try{const l=qs(o);if(!l)return;const p=Tr({paymentDue:s,remotePaymentDue:i,remoteMerchandiseDetails:r}),u=p?.amount,y=p?.currencyCode;if(u==null||!y)return;t.monorailEvent({schemaId:"checkout_credit_card_installment_track/1.0",payload:{eventName:"credit_card_installment_submit_attempted",shopId:parseInt(yo(d),10),checkoutToken:a??"",planCount:l,eligiblePlans:Mr(n).join(","),cartTotal:u.toFixed(2),cartCurrency:y}},{exportImmediately:!0})}catch(l){l instanceof Error&&e.error(l)}}function Pr(e){switch(e.parts.postPurchaseInquiryStatus.peek()){case"success":case"done":return"SUCCESS";case"declined":return"DECLINED";case"error":return"ERROR";case"timeout":return"TIMEOUT";default:return}}function Sn({variables:e,errors:t,sellerProposal:o}){if(!Zo(t))return e;const n=ln(o.tax),s=an(o.duty),i=yn(n,s);return{...e,taxes:{...e.taxes,...o.tax?i:{}}}}function kr(e){return e&&e.consolidated.delivery.termsStatus==="PENDING"?e.remoteNegotiations.reduce((t,{result:o})=>{if(ut(o)){const n=o.sellerProposal.delivery;if(n?.__typename==="PendingTerms")return Math.min(t,n.pollDelay)}return t},1/0):1/0}function Er(e){return e&&e.consolidated.payment.termsStatus==="PENDING"?e.remoteNegotiations.reduce((t,{result:o})=>{if(ut(o)){const n=o.sellerProposal.payment;if(n?.__typename==="PendingTerms")return Math.min(t,n.pollDelay)}return t},1/0):1/0}function Rr(e){return e&&e.consolidated.taxes.termsStatus==="PENDING"?e.remoteNegotiations.reduce((t,{result:o})=>{if(ut(o)){const n=o.sellerProposal.tax;if(n?.__typename==="PendingTerms")return Math.min(t,n.pollDelay)}return t},1/0):1/0}const Fr=1e3;function _n(e){if(e?.__typename!=="NegotiationResultAvailable"&&e?.__typename!=="SubmitRejected")return Fr;const{sellerProposal:t}=e,{delivery:o,payment:n,tax:s,taxExemptions:i,merchandiseDiscount:r,remote:d,deliveryDiscount:a,captcha:l,cartCheckoutValidation:p,deliveryExpectations:u,memberships:y,shopCashBalance:I,shopPromotion:g,shopDiscountOffer:S}=t,M=Math.min(kr(d),Rr(d),Er(d),l?.__typename==="PendingTerms"?l.pollDelay:1/0,o.__typename==="PendingTerms"?o.pollDelay:1/0,u?.__typename==="PendingTerms"?u.pollDelay:1/0,n.__typename==="PendingTerms"?n.pollDelay:1/0,s.__typename==="PendingTerms"?s.pollDelay:1/0,i?.__typename==="PendingTerms"?i.pollDelay:1/0,r.__typename==="PendingTerms"?r.pollDelay:1/0,a.__typename==="PendingTerms"?a.pollDelay:1/0,p?.__typename==="PendingTerms"?p.pollDelay:1/0,y?.__typename==="PendingTerms"?y.pollDelay:1/0,I?.__typename==="PendingTerms"?I.pollDelay:1/0,g?.__typename==="PendingTerms"?g.pollDelay:1/0,S?.__typename==="PendingTerms"?S.pollDelay:1/0);return M===1/0?0:M}
1class Lr extends Error{constructor(){super(...arguments),this.name="MissingSourceError"}}class xr extends Error{constructor(){super(...arguments),this.name="ManagedMarketsOnDomesticCheckoutError"}}function An({sellerProposal:e,buyerProposal:t={__typename:"Proposal",buyerIdentity:{__typename:"UnavailableTerms"},merchandise:{__typename:"UnavailableTerms"},isShippingRequired:!0,merchandiseDiscount:{__typename:"FilledDiscountTerms",acceptUnexpectedDiscounts:!1,lines:[]},deliveryDiscount:{__typename:"FilledDiscountTerms",acceptUnexpectedDiscounts:!1,lines:[]},delivery:{__typename:"UnavailableTerms"},subtotalBeforeTaxesAndShipping:{__typename:"AnyConstraint"},runningTotal:{__typename:"AnyConstraint"},total:{__typename:"AnyConstraint"},hasOnlyDeferredShipping:!1,attribution:{__typename:"Attribution",attributions:[]},saleAttributions:{__typename:"SaleAttributions",attributions:[]},legacyAggregatedMerchandiseTermsAsFees:[],legacySubtotalBeforeTaxesShippingAndFees:{__typename:"AnyConstraint"},note:{__typename:"Note",message:null,customAttributes:[]}},violations:o=[],silenceViolations:n=void 0,proposedPaymentLines:s,currentUcp:i,observability:r,shop:d}){const{remoteMerchandise:{remoteBuyerMerchandiseLines:a,remoteSellerMerchandiseLines:l,stableIdToShopId:p},remoteDelivery:u,remotePayment:y}=fo(e?.remote),I=!!e?.remote?.remoteNegotiations.length,[g,S]=I?[Rt(e?.merchandise,l),Rt(t?.merchandise,a)]:[e?.merchandise,t?.merchandise],M=go(e?.remote),c=Xt(o,n),f=vo({sellerProposal:e,buyerProposal:t,negotiationViolations:c,sellerMerchandise:g}),P=Lt(e?.payment,f?.runningTotal);if(!e)throw new Lr("There is no receipt or sellerProposal");const C=e.buyerIdentity.__typename==="UnavailableTerms";e.buyerIdentity.__typename!=="FilledBuyerIdentityTerms"&&r?.leaveErrorBreadcrumb("getNegotiatedPartsForUI: buyer identity terms are unavailable/pending",{__typename:e.buyerIdentity.__typename});const D=Hs(e.buyerIdentity),E=t?.subtotalBeforeTaxesAndShipping,A=e.__typename==="Proposal"?bo(e.subtotalBeforeTaxesAndShipping,E,c,g):void 0,F=t?.legacySubtotalBeforeTaxesShippingAndFees,v=e.__typename==="Proposal"?So(e.legacySubtotalBeforeTaxesShippingAndFees,F,c,g):void 0,_=e.__typename==="Proposal"?_o(e.legacyAggregatedMerchandiseTermsAsFees):{lines:[]},m=t?.runningTotal,h=e.__typename==="Proposal"?Ao(e.runningTotal,m,c,g):void 0,T=Io(e.payment),k=Mo(e.payment),x=e.payment?.__typename==="FilledPaymentTerms"&&e.payment.isImmediateAmountReducedForRedeemables,N=e.__typename==="Proposal"?To(e.deferredTotal??void 0,T?.dueDate??void 0):void 0,{checkoutTotal:U,checkoutTotalBeforeTaxesAndShipping:R,checkoutTotalTaxes:w}=t,W=e.poNumber??void 0,q=e.__typename==="Proposal"?ot(e.checkoutTotal,U,c,g):void 0,O=e.__typename==="Proposal"?ot(e.checkoutTotalBeforeTaxesAndShipping,R,c,g):void 0,z=e.__typename==="Proposal"?ot(e.checkoutTotalTaxes,w,c,g):void 0,Y=e.total&&e.total.__typename!=="AnyConstraint"?De(e.total):void 0,j=e.totalSavings&&e.totalSavings.__typename==="MoneyValueConstraint"?De(e.totalSavings):void 0,L=Co(e.recurringTotals),Q=e.subtotalAfterMerchandiseDiscounts&&e.subtotalAfterMerchandiseDiscounts.__typename!=="AnyConstraint"?De(e.subtotalAfterMerchandiseDiscounts):void 0,ee=e.subtotalBeforeReductions&&e.subtotalBeforeReductions.__typename!=="AnyConstraint"?De(e.subtotalBeforeReductions):void 0,de=e.deliveryExpectations?.__typename==="PendingTerms",ye=e.delivery.__typename==="PendingTerms",qe=e.captcha?.__typename==="PendingTerms",le=Po(g,S,c),G=jt(le.lines),te=ko(le.lines),ue=Lt(e.payment,h),fe=!!Qt({deferredTotal:N,checkoutTotal:q,paymentFlexibilityPaymentTermsTemplate:T})?.amount,$=Eo(e.payment,y.availablePaymentLines),X=Ro({availablePayments:$,hasPayableDeposit:fe}),oe=d.paymentMethodAutoSelectionDisabled,He=Yt(d)&&Wt({hasSellingPlan:G,hasFixedSellingPlan:te,paymentTermsTemplateType:T?.type}),b=Fo({payment:e.payment,sortedPaymentMethods:X,runningTotal:h,paymentDue:ue,deferredTotal:N,checkoutTotal:q,paymentMethodAutoSelectionDisabled:oe,requiresVaulting:G,proposedPaymentLines:s,hasPayableDeposit:fe,hasFixedSellingPlan:te,paymentTermsTemplateType:T?.type,preserveAllocatedImmediatePaymentLineAmount:He,observability:r}),We=e.payment.__typename==="FilledPaymentTerms"?e.payment.paymentMethodHistory:[],se=C?void 0:Ws(e.buyerIdentity),ce=Kt(e.note),Ye=Jt(e.note),ge=ce&&!!e.delivery&&Ye,ve=Lo({delivery:e.delivery,remoteDelivery:u});ve?.countryCode==="US"&&X.some(Ee=>Ee.type==="direct"&&Ee.name==="flow_commerce")&&r?.error(new xr("flow_commerce gateway returned from availablePaymentMethods for domestic shipping address"),{metadata:{value:{availablePaymentMethods:JSON.stringify(X),proposedPaymentLines:JSON.stringify(s),paymentLines:JSON.stringify(b)}}});const be=xo({delivery:e.delivery,deliveryMethods:d.shipPickupInOneOrderEnabled?e.deliveryMethods:void 0,negotiatedMerchandise:g,buyerDelivery:t?.delivery,violations:c,isPointOfSale:ce,isPointOfSaleShipToHome:ge,remoteDelivery:u}),Se=Do(e.attribution),me=Ts(e.attribution),ie=Cs({deliveryExpectations:e.deliveryExpectations}),pt=Se===void 0&&me===void 0?void 0:{...Se,...me},_e=Ps(e.saleAttributions),Ae=ks(e.tip),Ie=Es(e.tip),Me=e.localizationExtension?.fields,Te=e.scriptFingerprint?Rs(e.scriptFingerprint):void 0,pe
1=e.transformerFingerprintV2||void 0,Qe=Fs(e.availableRedeemables),ze=Ls(e.shopCashBalance),je=xs(e.shopPromotion),$e=Ds(e.shopDiscountOffer),Ce=e.checkoutCompletionTarget??"ORDER",Pe="billingAddress"in e.payment?No(e.payment.billingAddress):void 0,he=e.memberships?Ns(e.memberships):void 0,ke=u?.isShippingRequired??e.isShippingRequired??t?.isShippingRequired;return{billingAddress:Pe,...ye?void 0:{deliveryNext:be},sellability:ct({shop:d,sellerProposal:e,missingSellerProposalReason:"Proposal.Unknown",isShippingRequired:ke,observability:r}),deliveryExpectations:de?void 0:ie,shippingAddress:ve,merchandiseLines:le,paymentMethodHistory:We,paymentMethods:X,paymentLines:b,paymentDue:ue,...se?{contactInfo:se}:void 0,duties:an(e.duty),optionalDuties:e.optionalDuties?Ks(e.optionalDuties):void 0,landedCostDetails:e.landedCostDetails?.incotermInformation??void 0,dutiesIncluded:e.dutiesIncluded?e.dutiesIncluded:void 0,taxes:ln(e.tax),remoteTaxDetails:$s(e.remote),taxExemptions:Vo(e.taxExemptions),discountLines:Go({merchandiseDiscount:e.merchandiseDiscount,deliveryDiscount:e.deliveryDiscount}),legacyRepresentProductsAsFees:e.legacyRepresentProductsAsFees,totalSavings:j,subtotal:A,legacySubtotalBeforeTaxesShippingAndFees:v,legacyMerchandiseLinesAsFees:_,runningTotal:h,deferredTotal:N,checkoutTotal:q,checkoutTotalBeforeTaxesAndShipping:O,checkoutTotalTaxes:z,total:Y,purchaseOrderNumber:W,recurringTotals:L,subtotalAfterMerchandiseDiscounts:Q,subtotalBeforeReductions:ee,hasOnlyDeferredShipping:e.hasOnlyDeferredShipping,acceptEmailMarketing:js(e.buyerIdentity),emailMarketingConsentGrantReached:zs(e.buyerIdentity),acceptSmsMarketing:Qs(e.buyerIdentity),smsMarketingPhone:Ys(e.buyerIdentity)??void 0,allViolations:o,buyerIdentity:D,tipOptions:Ae,tipLines:Ie,localizationExtensions:Me,scriptFingerprint:Te,transformerFingerprintV2:pe,attribution:pt,managedByMarketsPro:e.managedByMarketsPro,managedMarketsPaymentProcessor:e.managedMarketsPaymentProcessor,...qe?void 0:{captcha:Uo(e.captcha,c)},availableRedeemables:Qe,shopCashBalance:ze,shopPromotion:je,shopDiscountOffer:$e,saleAttributions:_e,alternativePaymentCurrency:Os(e.alternativePaymentCurrency,b),lpmDisclosure:e.lpmDisclosure??void 0,isImmediateAmountReducedForRedeemables:x,checkoutCompletionTarget:Ce,paymentFlexibilityPaymentTermsTemplate:T,depositConfiguration:k,isShippingRequired:ke,cartMetafields:Bo(e.cartMetafields),customFields:d.hasFlagEnabled(Oo)?ws(e.customFields):void 0,memberships:he,remoteMerchandiseDetails:{stableIdToShopId:p,mergedBuyerProposalMerchandise:S},remotePaymentDetails:y.paymentDetails,remoteSessionDetails:M,remoteConsolidatedTotals:f,remotePaymentDue:P,remoteTotalDetails:wo({remote:e?.remote,negotiationViolations:c,sellerMerchandise:g}),shopPayEnabledForSellerOfRecord:e.shopPayEnabled,ucp:{...i,continueUrl:e.ucp?.continueUrl??void 0}}}function Bt(e){return e.split(".").reduce((o,n)=>{if(n[0]==="$")return o;const s=Dr(n);return o.concat(s)},[])}function Dr(e){const t=e.split("["),o=t[0],n=t[1];if(o===void 0||n===void 0)return[e];const s=n.replace(/[[\]']+/g,"");return[o,Number(s)]}function Ut(e,t){return e.reduce((o,n)=>o!=null&&typeof o=="object"?o[n]:null,t)??null}function Nr(e,t,o){if(es.has(t)){const i=Ut(Bt(e),o);return i?qo(i)??null:null}if(!Ho.has(t))return null;const n=Wo(e);if(!n)return null;const s=Ut(Bt(n.linePath),o);return typeof s?.stableId=="string"?{merchandiseLine:{stableId:s.stableId}}:null}function lt(e,t){return e.reduce((o,n)=>{if(!n.__typename)return o;const{code:s,localizedMessage:i,nonLocalizedMessage:r,localizedMessageHtml:d}=n;let a;"target"in n&&typeof n.target=="string"?a=n.target:"from"in n&&typeof n.from=="string"&&(a=n.from);const l=a?Nr(a,s,t):null,p={code:s,localizedMessage:i,nonLocalizedMessage:r,localizedMessageHtml:d};switch(n.__typename){case"InputValidationError":o.push({...p,type:n.__typename});break;case"RemoveTermViolation":o.push({...p,type:n.__typename,target:n.target,targetEntity:l});break;case"AcceptNewTermViolation":o.push({...p,type:n.__typename,target:n.target});break;case"ConfirmChangeViolation":o.push({...p,type:n.__typename,from:n.from,targetEntity:l,to:n.to});break;case"UnprocessableTermViolation":o.push({...p,type:n.__typename,target:n.target,...l?{targetEntity:l}:{}});break;case"UnresolvableTermViolation":o.push({...p,type:n.__typename,target:n.target});break;case"ApplyChangeViolation":o.push({...p,type:n.__typename,target:n.target,from:n.from,to:n.to,...l?{targetEntity:l}:{}});break;default:{o.push({...p,type:"GenericError"});break}}return o},[])}
1class wr extends Error{constructor(){super(...arguments),this.name="UnknownCompletionTypeError"}}class Or extends mt{constructor(){super(...arguments),this.name="SubmitRejectedMissingContactMethod"}}class Br extends Error{constructor(){super(...arguments),this.name="UnknownMetafieldTypeError"}}const Ur={CheckpointDenied:"SubmitForCompletion.CheckpointDenied",SubmitAlreadyAccepted:"SubmitForCompletion.SubmitAlreadyAccepted",SubmitFailed:"SubmitForCompletion.SubmitFailed",SubmitRejected:"SubmitForCompletion.Unknown",SubmitSuccess:"SubmitForCompletion.SubmitSuccess",SubmittedForCompletion:"SubmitForCompletion.SubmittedForCompletion",Throttled:"SubmitForCompletion.Throttled",TooManyAttempts:"SubmitForCompletion.TooManyAttempts",TooManyRequests:"SubmitForCompletion.TooManyRequests"};function Gr(e){return e==null?"SubmitForCompletion.Unknown":Ur[e]}function Vr({submitForCompletion:e,buyerProposal:t,violations:o,proposedPaymentLines:n,observability:s,negotiator:i}){switch(e.__typename){case"SubmitRejected":return An({sellerProposal:e.sellerProposal,buyerProposal:t,violations:o,proposedPaymentLines:n,currentUcp:i.current.fields.ucp.value,observability:s,shop:i.shop});case"CheckpointDenied":case"SubmitFailed":case"Throttled":case"TooManyAttempts":case"TooManyRequests":return{sellability:ct({shop:i.shop,missingSellerProposalReason:Gr(e.__typename),observability:s})};case"SubmitSuccess":case"SubmitAlreadyAccepted":case"SubmittedForCompletion":return{};default:return{}}}const Gt={ATTEMPTS:5,TIMEOUT:5e3};function In(e){return"receipt"in e&&e.receipt.__typename==="ReceiptNotFound"}function qr(){let e=0,t;return{shouldRetry(o){return In(o)?(e+=1,t??=Date.now(),e<=Gt.ATTEMPTS&&Date.now()-t<=Gt.TIMEOUT):!1},get attempts(){return e}}}function Hr(e){switch(e.valueType.toUpperCase()){case"STRING":return"STRING";case"JSON_STRING":return"JSON_STRING";case"INTEGER":return"INTEGER";default:throw new Br(`Unexpected metafield valueType: ${e.valueType}`)}}function Wr(e){const{extensibility:t}=e.checkout;return t.ui.metafields.value.map(n=>({...n,value:String(n.value),valueType:Hr(n)}))}function Vt({paymentLineTypes:e,status:t,observability:o,interfaceFlow:n,blockedByExtension:s,activeWalletSession:i}){const r=e.at(0);(r==="APPLE_PAY"||r==="GOOGLE_PAY")&&o.counter({name:"wallet_completion_extension_result",value:1,attributes:{wallet_type:r,status:t,interface_flow:n,blocked_by_extension:s,active_wallet_session:i?.wallet,wallet_as_payment_method:i?.asPaymentMethod}})}async function La(e,t,o){const{negotiating:n,isActive:s}=e.start();t.leaveErrorBreadcrumb("[SubmitForCompletion] Running completion interceptors");const i=await e.runInterceptors({negotiationStage:"completion"});if(t.leaveErrorBreadcrumb("[SubmitForCompletion] completion isActive",{isActive:s()}),!s()){const u="[SubmitForCompletion] Blocked due to stale negotiation";return t.leaveErrorBreadcrumb(u),e.observability.log("submit_for_completion_progression_blocked",u,{reason:"stale_negotiation"}),{status:"stale",phase:"interceptors"}}if(!e.source.sourceId){const u=[Yo.MissingSourceId];return t.leaveErrorBreadcrumb("[SubmitForCompletion] Blocked due to missing sourceId",{reasons:u}),{status:"invalid",reasons:u}}const r=e.parts.paymentLines.value.map(u=>u.method.type==="wallet"||u.method.type==="walletsPlatformPaymentMethod"?u.method.name:u.method.type),d=e.checkout.extensibility.ui.search().peek().some(u=>u.capabilities.blockProgress);if(i.behavior==="block"){const{reasons:u,errors:y,context:I}=i;return t.leaveErrorBreadcrumb("[SubmitForCompletion] Blocked by client side interceptors",{reasons:u,paymentLineNames:r,interfaceFlow:e.parts.interfaceFlow.value,activeWalletSession:e.checkout.wallets.activeSession.value}),e.observability.log("submit_for_completion_progression_blocked","[SubmitForCompletion] Blocked by client side interceptors",{reason:"interceptor_block",reasons:u,errors:y,context:I,paymentLineNames:r,interfaceFlow:e.parts.interfaceFlow.value,activeWalletSession:e.checkout.wallets.activeSession.value}),d&&Vt({paymentLineTypes:r,status:"blocked",observability:e.observability,interfaceFlow:e.parts.interfaceFlow.value,blockedByExtension:!!I?.some(g=>g?.extension),activeWalletSession:e.checkout.wallets.activeSession.value}),e.validationErrors.value=y,e.checkout.rememberMe.unstable_setCreateAccountOptIn(!1),{status:"invalid",reasons:u}}else d&&Vt({paymentLineTypes:r,status:"allowed",observability:e.observability,interfaceFlow:e.parts.interfaceFlow.value,activeWalletSession:e.checkout.wallets.activeSession.value});e.validationErrors.value=[],o?.onValidationSuccess?.(),e.track();const a=e.current.peek();Cr({observability:t,userEvents:e.userEvents,paymentLines:e.parts.paymentLines.peek(),paymentMethods:a.paymentMethods,paymentDue:a.paymentDue,remotePaymentDue:a.remotePaymentDue,remoteMerchandiseDetails:a.remoteMerchandiseDetails,shopId:e.shop.id,checkoutToken:e.source.checkoutSessionIdentifier});const l=Qo(e.source,e.persistenceManager),p=e.parts.paymentLines.peek();try{let u;
1try{u=await Zt()}catch(g){return t.leaveErrorBreadcrumb("[SubmitForCompletion] Blocked completion because receipt mapper failed to load",{error:String(g)}),{status:"fetch_failed",reason:"Receipt mapper failed to load before submit for completion",isActionable:!1}}if(!s()){const g="[SubmitForCompletion] Blocked due to stale negotiation";return t.leaveErrorBreadcrumb(g),e.observability.log("submit_for_completion_progression_blocked",g,{reason:"stale_negotiation"}),{status:"stale",phase:"submission"}}const y=n([]);return await(async()=>{let g;const S=qr();do{const M=bn(e,{isCompleting:!0,customizeNegotiation:o?.customizeCompletion,observability:e.observability,wallets:e.checkout.wallets,selectedBillingAddress:e.shopPay.session.selectedBillingAddress.value}),c=zr(M,g),{data:f,error:P}=await e.graphql.mutate(Ar,{variables:{input:c,attemptToken:l,metafields:Wr(e),postPurchaseInquiryResult:Pr(e),analytics:Ir()}});if(!f)return{status:"fetch_failed",reason:P?`${P.message}`:"Submit for completion failed",isActionable:dn(P).actionable};if(In(f.submitForCompletion)){if(!S.shouldRetry(f.submitForCompletion))return{status:"fetch_failed",reason:"Submit for completion returned ReceiptNotFound",isActionable:!1};t.leaveErrorBreadcrumb("[SubmitForCompletion] Receipt not found; retrying completion",{submitForCompletionType:f.submitForCompletion.__typename,receiptNotFoundAttempts:S.attempts}),await at(zo);continue}const C=en(f.submitForCompletion.__typename==="SubmitRejected"?f.submitForCompletion.errors:void 0,f.submitForCompletion.__typename==="SubmitRejected"?f.submitForCompletion.sellerProposal:void 0,f.submitForCompletion.__typename==="SubmitRejected"?f.submitForCompletion.buyerProposal:void 0),D=nn(f.submitForCompletion,C);if(f.submitForCompletion.__typename==="SubmitRejected"&&D.length){g=f.submitForCompletion,await at(_n(f.submitForCompletion));const v=await e.runInterceptors({negotiationStage:"completion"});if(v.behavior==="block"){const _=v.reasons;return t.leaveErrorBreadcrumb("Blocked polled completion",{reasons:_,pendingFields:D}),{status:"invalid",reasons:_}}continue}const E=f?.submitForCompletion.__typename==="SubmitRejected"?f.submitForCompletion.buyerProposal:void 0,A=Vr({submitForCompletion:f.submitForCompletion,buyerProposal:E,violations:C,proposedPaymentLines:p,observability:t,negotiator:e});y({updated:A,buyerProposal:E}),f?.submitForCompletion.__typename==="SubmitRejected"&&C&&C.length>0&&(t.leaveErrorBreadcrumb("Submit for completion was rejected",{violations:C.map(v=>v.code)}),C.some(v=>v.code==="BUYER_IDENTITY_MISSING_CONTACT_METHOD")&&(t.log("submit_for_completion_rejected_with_missing_contact_method","Missing contact method",{proposedEmail:e.parts.email.peek(),negotiatedCustomerProfileEmail:e.current.peek().buyerIdentity?.customerProfile?.email,negotiatedContactInfoEmail:e.current.peek().contactInfo?.email}),t.error(new Or("SubmitForCompletion returned BUYER_IDENTITY_MISSING_CONTACT_METHOD",{groupingHash:Yr(e)}),{severity:"info"})),on(C,e.parts,e.context,e.observability));const F=Qr(f,e,A,C??[],u);return(F.status==="alreadyCompleted"||F.status==="success")&&(e.checkout.configuration.renderContextToken.update(F.renderContextToken??void 0),e.checkout.configuration.update({deferredProfileChangeId:F.configurationRecordId})),F}while(!0)})()}finally{e.checkout.rememberMe.unstable_setCreateAccountOptIn(!1)}}function Yr(e){const t=e.current.peek().buyerIdentity?.customerProfile?.email,o=e.current.peek().contactInfo?.email,n=e.current.peek().buyerIdentity?.customerProfile?.__typename,s=[];return!t&&!o&&e.source.type==="orderEdit"?s.push("orderEditWithBlankNegotiatedEmail"):(e.checkout.configuration.layout.isOnePage.value?s.push("onePage"):s.push("threePage"),e.checkout.wallets.escalatedWallet.value?s.push(e.checkout.wallets.escalatedWallet.value):e.checkout.identity.current.value==="shopPay"?s.push("shopPay"):n==="CustomerProfile"?s.push("customerAccount"):n==="BusinessCustomerProfile"?s.push("businessCustomer"):s.push("guest")),s.join("::")}function Qr({submitForCompletion:e},{throttle:t,persistenceManager:o,router:n,lastJourneyProgression:s,source:i},r,d,a){switch(e.__typename){case"SubmitSuccess":case"SubmitAlreadyAccepted":{const l=a(e.receipt);return(l.status==="processed"||l.status==="failed")&&o&&J(o,i),{status:"success",receipt:l,configurationRecordId:e.configurationRecordId??void 0,renderContextToken:e.renderContextToken??void 0}}case"SubmittedForCompletion":{const l=a(e.receipt,{skipToThankYouPage:!0});return o&&J(o,i),{status:"alreadyCompleted",receipt:l,configurationRecordId:e.configurationRecordId??void 0,renderContextToken:e.renderContextToken??void 0}}case"Throttled":return o&&J(o,i),t.set(rt(e)),{status:"throttled"};case"SubmitRejected":return o&&J(o,i),{status:"rejected",negotiated:r,violations:d,errors:lt(d,e.buyerProposal)};case"TooManyRequests":{o&&J(o,i);const l={type:"failed",negotiationStage:"completion",fetchFailed:!1,reason:"tooManyRequests"};return s.value=l,{status:"tooManyRequests"}}case"SubmitFailed":return o&&J(o,i),{status:"failed",reason:e.reason};case"CheckpointDenied":{o&&J(o,i);const l=typeof window>"u",p=l?n.currentUrl.value.toString():void 0,u=tn(e.redirectUrl,p);return l||window.location.assign(u.href),{status:"denied"}}case"TooManyAttempts":{if(o&&J(o,i),!(typeof window>"u")){const p=new URL(e.redirectUrl);window.location.assign(p.href)}return{status:"denied"}}default:throw o&&J(o,i),new wr(`Unknown submitForCompletion type: ${e.__typename}`)}}function zr(e,t){return t?Sn({variables:e,errors:t.errors,sellerProposal:{tax:t.sellerProposal?.tax,duty:t.sellerProposal?.duty}}):e}const jr={id:"8cf6fd878e15e1a82c73ddf332175321294a86a35c894d5bcedc7a4400c68ebb",type:"query",name:"Proposal",source:""};function $r(e){return{email:Us(e,{emptyContactFallback:void 0})??null,phone:Bs(e,{emptyContactFallback:void 0})??null}}
1class Z extends Error{constructor(){super(...arguments),this.name="StaleNegotiationError"}}class qt extends Error{constructor(){super(...arguments),this.name="MissingNegotiationDataError"}}class Kr extends mt{constructor(){super(...arguments),this.name="NegotiationFailedError"}}class Jr extends mt{constructor(){super(...arguments),this.name="UnactionableNegotiationFailedError",this.unactionable=!0}}class Xr extends Error{constructor(){super(...arguments),this.name="GenericError"}}class Zr extends Error{constructor(){super(...arguments),this.name="UnexpectedNegotiationResult"}}class st extends Error{constructor(){super(...arguments),this.name="EmptyMerchandiseLinesNegotiationResult"}}function ea(e,t){const{lines:o}=e;return o.length>0&&jo(o,t).length===0}function ta(e){return e.ui.search().peek().filter(t=>t.type==="persisted")}function na(e,t,o){if(!ea(e,t))return;const n=ta(o);n.length>0&&o.ui.remove(n.map(s=>s.targetPublicIdentifier),{keepAlive:!1,reason:"remote_only_transition"})}function oa(e){return e.sent+=1,e.sent}function sa({state:e,sendSequence:t,result:o,fromNetwork:n,checkout:s,throttle:i}){if(!n||o?.__typename!=="NegotiationResultAvailable"||t<=e.seen)return;e.seen=t,s.unstable_overwriteCheckpointToken(o.checkpointData??void 0);const r=i.current;r.status==="complete"&&o.queueToken!=null?i.set({...r,token:o.queueToken}):(r.status==="inactive"||r.status==="complete")&&i.set({status:"inactive",token:o.queueToken??void 0})}function ia(e){return!e?.remoteNegotiations||e.remoteNegotiations.length===0?!1:e.remoteNegotiations.some(t=>{if(t.result?.__typename!=="RemoteNegotiationResultAvailable")return!1;const o=t.result.sellerProposal?.merchandise,n=t.result.buyerProposal?.merchandise,s=o?.__typename==="FilledMerchandiseTerms"&&(o.merchandiseLines?.length??0)>0,i=n?.__typename==="FilledMerchandiseTerms"&&(n.merchandiseLines?.length??0)>0;return s||i})}const ra=new Set(["orderEdit","paymentCollection"]);function aa(e,t){if(t.result.__typename!=="NegotiationResultAvailable"||ra.has(e)||t.errors.some(s=>$o.has(s.code)))return!1;const n=t.result.sellerProposal.merchandise;return n.__typename==="FilledMerchandiseTerms"&&n.merchandiseLines.length===0?!ia(t.result.sellerProposal?.remote):!1}async function*da(e,t,o,n={reportedMissingContact:!1,reportedMissingContactCommit:!1}){const{identifier:s,negotiationStage:i}=o,r=e.checkout.wallets.activeSession.peek()?.wallet,d=o.startedInAcceleratedWalletSession??(r==="APPLE_PAY"||r==="GOOGLE_PAY"),{isActive:a,negotiating:l}=e.start();t.leaveErrorBreadcrumb("[Negotiate] Running negotiation interceptors",{identifier:s.toString(),negotiationStage:i});const p=await e.runInterceptors({negotiationStage:i,skipEffects:o.skipStateUpdates});if(!a()){t.leaveErrorBreadcrumb("[Negotiate] Not doing negotiation due to stale negotiation"),yield{status:"stale"};return}if(!o.skipStateUpdates){const{errors:c}=p;e.validationErrors.value=c}if(p.behavior==="block"){const{reasons:c,errors:f,context:P}=p;t.leaveErrorBreadcrumb("[Negotiate] Blocked negotiation",{reasons:c,errors:f,context:P}),yield{status:"invalid",reasons:c};return}let u=bn(e,{customizeNegotiation:o?.customizeNegotiation,paymentLinesObservability:t,selectedBillingAddress:e.shopPay.session.selectedBillingAddress.value}),y;o.skipStateUpdates||(y=l(o.loading));function I(){y?.({updated:{}})}const{graphql:g,throttle:S}=e,M=e.parts.paymentLines.peek();try{let c=!0,f;do{if(!a())throw new Z;!c&&!n.reportedMissingContact&&(n.reportedMissingContact=la({variables:u,negotiator:e,negotiationStage:i,customized:o.customizeNegotiation!=null})),u=ma(u,f);const{dirty:P}=e.track(u),C=!P&&c&&!o.force,D=e.collectPendingNegotiationEventIds(s,i),E=await ps(async()=>{const v=()=>g.staticQuery(jr,{cache:C,variables:u,getCacheKey({id:k},x){return`${k}${ts(x?hs(x):{})}`},...D.length&&{additionalHeaders:{"Shopify-Checkout-Event-Ids":D.join(",")}}}),_=Date.now(),{data:m,error:h}=await e.serializeNegotiationRequest(async()=>{if(!a())throw new Z;u={...u,checkpointData:e.checkout.checkpointToken.value,queueToken:vn(S)},ua({negotiator:e,negotiationStage:i,waitedMs:Date.now()-_}),e.serializedTokenRotation??={sent:0,seen:0};const k=e.serializedTokenRotation,x=oa(k),N=v(),U=N instanceof Promise,R=await N;return sa({state:k,sendSequence:x,result:R.data?.session?.negotiate?.result,fromNetwork:U,checkout:e.checkout,throttle:e.throttle}),R});if(h)throw h;const T=m?.session?.negotiate;if(T==null)throw new qt("negotiation data is missing");if(ca({result:T.result,negotiator:e,negotiationStage:i,customized:o.customizeNegotiation!=null,superseded:!a(),telemetry:n}),!a()){const k="[Negotiate] Negotiation is stale";throw t.leaveErrorBreadcrumb(k),e.observability.log("negotiate_stale_negotiation_detected",k),new Z}if(aa(e.source.type,T))throw new st;return T},{shouldRetry:v=>v!=null&&!(v instanceof Z)&&!(v instanceof st)&&!(v instanceof qt)}),A=E.result,F=E.errors;switch(t.leaveErrorBreadcrumb("[Negotiate] Negotiation completed",{negotiationResult:A.__typename,negotiationViolations:F.map(v=>v.nonLocalizedMessage)}),A.__typename){case"NegotiationResultAvailable":{const v=en(F,A.sellerProposal,A.buyerProposal)??[];e.checkout.unstable_overwriteCheckpointToken(A.checkpointData??void 0),S.set(rt(A));const _=nn(A,v);e.checkout.configuration.renderContextToken.update(A.renderContextToken??void 0),f=E;const m=A.buyerProposal,h=An({sellerProposal:A.sellerProposal,buyerProposal:m,violations:v,silenceViolations:o.silenceViolations,proposedPaymentLines:M,currentUcp:e.current.fields.ucp.value,observability:t,shop:e.shop}),T=Object.entries(h).reduce((L,Q)=>{const[ee,de]=Q;return o.fieldsToResolve?.includes(ee)&&_.includes(ee)?L:{...L,[ee]:de}},{}),k=Xt(v,o.silenceViolations);ns({observability:t,negotiationStage:i,silenceViolations:o.silenceViolations,violations:v,retainedViolations:k,reportedCodes:e.reportedSilencedViolationCodes});const x=on(k,e.parts,e.context,e.observability),{autoResolved:N,blockingProgress:U,informational:R,removingItems:w,invalidInputs:W,mustAcceptTerms:q,unresolvable:O,other:z}=os(k);if(t.leaveErrorBreadcrumb("[Negotiate]: Violation handling result",{silenceViolations:o.silenceViolations,hasErrors:x.hasErrors,requiresRenegotiation:x.requiresRenegotiation,surfacedToBuyer:{blockingProgress:U,informational:R,removingItems:w,invalidInputs:W,mustAcceptTerms:q,unresolvable:O},autoResolved:N,other:z}),x.requiresRenegotiation){yield*da(e,t,{...o,startedInAcceleratedWalletSession:d},n);return}let Y=ss({checkout:e.checkout,shop:e.shop,profileId:A.configurationRecordId??e.checkout.configuration.profileId.peek()});if(Y&&d&&!o.threePageWalletEscalation&&!e.hasPendingThreePageWalletEscalation()){const L=e.checkout.configuration.profileKey.peek();Y=L?.id===Y.id?L:{...Y,requireBusinessCriticalOnly:!1}}const j=await is(()=>{y?.({updated:T,loadingFields:_,buyerProposal:m})},{trigger:"negotiation",profileRequest:Y,graphql:e.graphql,extensibility:e.checkout.extensibility,configuration:e.checkout.configuration,observability:e.observability,userEvents:e.userEvents,isActive:a,runInterceptors:e.runInterceptors.bind(e),validationErrors:e.validationErrors,telemetryContext:{source:e.source,shop:e.shop,sessionToken:e.sessionToken,current:e.current}});if(!a())throw j?.(),new Z;if(j&&Vs(j,["checkout-profile-change"]),na(e.current.fields.merchandiseLines.value??{lines:[]},e.current.fields.remoteMerchandiseDetails.value,e.checkout.extensibility),(rs(v).length||as(v).length)&&e.track(u),!o.skipStateUpdates&&a()&&x.hasErrors){const{inventoryRecoverySignal:L}=e.context,Q=L.value;Q&&!Q.dismissed&&(L.value={...Q,dismissed:!0})}if(yield x.hasErrors?{status:"error",negotiated:e.current.peek(),violations:v,errors:lt(v??[],A.buyerProposal),pendingFields:_}:{status:"success",negotiated:e.current.peek(),violations:v,errors:lt(v??[],A.buyerProposal),pendingFields:_},_.length===0)return;break}case"CheckpointDenied":{y?.({updated:re({negotiator:e,observability:t,typename:A.__typename})});const v=typeof window>"u",_=v?e.router.currentUrl.value.toString():void 0,m=tn(A.redirectUrl,_);v||window.location.assign(m.href),yield{status:"denied"};return}case"Throttled":{y?.({updated:re({negotiator:e,observability:t,typename:A.__typename})}),yield{status:"throttled"},S.set(rt(A));return}case"TooManyRequests":{y?.({updated:re({negotiator:e,observability:t,typename:A.__typename})});const v={type:"failed",negotiationStage:i,fetchFailed:!1,reason:"tooManyRequests"};e.lastJourneyProgression.value=v,yield{status:"tooManyRequests"},e.observability.log("negotiate_result_returned","[Negotiate] Negotiation halted due to too many requests"),e.observability.counter({name:"negotiation_result_too_many_requests",value:1});return}case"SubmittedForCompletion":{y?.({updated:re({negotiator:e,observability:t,typename:A.__typename})});let v;try{v=await Zt()}catch(m){if(!a())throw new Z;const h=A.receipt,T=Gs(h);if(t.leaveErrorBreadcrumb("[Negotiate] Receipt mapper failed to load for already completed negotiation",{error:String(m),receiptType:h.__typename}),T){yield{status:"alreadyCompleted",receipt:T};return}if(h.__typename==="ProcessedReceipt"&&h.orderStatusPageUrl){window.location.replace(h.orderStatusPageUrl);return}yield{status:"fetch_failed",reason:"Receipt mapper failed to load after submitted for completion",isActionable:!1};return}if(!a())throw new Z;yield{status:"alreadyCompleted",receipt:v(A.receipt,{skipToThankYouPage:!0})};return}case"NegotiationResultFailed":{y?.({updated:re({negotiator:e,observability:t,typename:A.__typename})});const v=E.errors.map(_=>_.code);throw A.reportable===!1&&(e.observability.log("negotiate_result_returned",`[Negotiate] Negotiation result failed, violations: ${v.join(",")}`),e.observability.counter({name:"negotiation_result_failed",value:1})),new Xr("Server failed to fulfill the request and to identify the exact issue.",{cause:A.reportable?new Kr(`Negotiation request failed. Violations = ${v.join(",")}`):new Jr(`Negotiation request failed. Violations = ${v.join(",")}`)})}default:throw y?.({updated:re({negotiator:e,observability:t,typename:void 0})}
1),new Zr(`Negotiation result type not implemented yet: ${A.__typename}`)}if(c=!1,o.skipStateUpdates)break;await at(_n(A))}while(!0)}catch(c){if([ys,fs,gs].some(f=>c instanceof f)){const{actionable:f}=dn(c),P=c.message??"Negotiation fetch failed";if(ds(P)||!f){e.observability.log("negotiate_result_error_returned","[Negotiate] Negotiation network error",{reason:P}),e.observability.counter({name:"negotiation_network_error",value:1,attributes:{reason:ls(P)}}),I(),yield{status:"fetch_failed",reason:P,isActionable:f,networkError:!0};return}}if(c instanceof Z){yield{status:"stale"};return}if(c instanceof st){e.checkout.configuration.allowRedirectToStorefront?(e.observability.counter({name:"empty_merchandise_lines_redirect",value:1,attributes:{source:e.source.type}}),us({client:e.client,url:e.url,source:e.source,configuration:e.checkout.configuration})):(I(),yield{status:"stale"});return}throw e.track(),c}}function la({variables:e,negotiator:t,negotiationStage:o,customized:n}){const s=e.buyerIdentity,i=!!t.parts.email.peek().trim()&&s?.email===void 0,r=!!t.parts.phone.peek().trim()&&s?.phone===void 0;if(!i&&!r)return!1;let d="both";r||(d="email"),i||(d="phone");const a={negotiationStage:o,customized:n,channel:d};return t.observability.counter({name:"negotiate_missing_contact_snapshot",value:1,attributes:a}),t.observability.log("negotiate_missing_contact_snapshot","[Negotiate] Poll is about to re-send a snapshot missing the contact method the buyer has since supplied",a),!0}function ua({negotiator:e,negotiationStage:t,waitedMs:o}){if(o<=0)return;let n=">=5000ms";o<100?n="<100ms":o<500?n="100-500ms":o<1e3?n="500-1000ms":o<5e3&&(n="1000-5000ms"),e.observability.counter({name:"negotiation_request_serialized_wait",value:1,attributes:{negotiationStage:t,bucket:n}})}function ca({result:e,negotiator:t,negotiationStage:o,customized:n,superseded:s,telemetry:i}){if(e.__typename!=="NegotiationResultAvailable")return;const r=e.buyerProposal.buyerIdentity;if(r.__typename!=="FilledBuyerIdentityTerms")return;const d=$r(r),a=t.lastNegotiatedContactEcho;if(t.lastNegotiatedContactEcho=d,!i.reportedMissingContact||i.reportedMissingContactCommit)return;const l=!!t.parts.email.peek().trim()&&d.email==null&&!!a?.email,p=!!t.parts.phone.peek().trim()&&d.phone==null&&!!a?.phone;if(!l&&!p)return;i.reportedMissingContactCommit=!0;let u="both";p||(u="email"),l||(u="phone");const y={negotiationStage:o,customized:n,channel:u,superseded:s};t.observability.counter({name:"negotiate_missing_contact_committed",value:1,attributes:y}),t.observability.log("negotiate_missing_contact_committed","[Negotiate] Server committed a poll snapshot missing the contact method a previous response had confirmed",y)}function ma(e,t){return t&&t.result.__typename==="NegotiationResultAvailable"?Sn({variables:e,errors:t.errors,sellerProposal:{tax:t.result.sellerProposal?.tax,duty:t.result.sellerProposal?.duty}}):e}function re({negotiator:e,observability:t,typename:o}){return{sellability:ct({shop:e.shop,missingSellerProposalReason:pa(o),observability:t})}}function pa(e){switch(e){case"CheckpointDenied":return"Proposal.CheckpointDenied";case"NegotiationResultFailed":return"Proposal.NegotiationResultFailed";case"SubmittedForCompletion":return"Proposal.SubmittedForCompletion";case"Throttled":return"Proposal.Throttled";case"TooManyRequests":return"Proposal.TooManyRequests";default:return"Proposal.Unknown"}}export{La as complete,bn as getNegotiationInput,da as negotiate};

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.