PageSourceSearch

https://xenadu.com/cdn/shopifycloud/checkout-web/assets/c1/embed-2026-08-25.DOEeGdu2.js

js xenadu.com collected 2026-09-26 04:58:18 UTC 33,501 bytes, 1 lines download raw bytes

1var re=s=>{throw TypeError(s)};var F=(s,e,t)=>e.has(s)||re("Cannot "+t);var u=(s,e,t)=>(F(s,e,"read from private field"),t?t.call(s):e.get(s)),_=(s,e,t)=>e.has(s)?re("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),E=(s,e,t,n)=>(F(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t),d=(s,e,t)=>(F(s,e,"access private method"),t);import{o as oe,c as Ve,j as ae}from"./esnext-vendor.B9Da21W6.js";import{fV as qe,fZ as Be,h as Ge,H as ze,i as pe,fW as T,fc as N,fX as We,fd as Ke,fY as R}from"./addresses-is-address-empty.Bn2lNY_L.js";import{U as $e,E as Xe,b as Ze,O as Qe,a as Je,R as et,c as tt,d as st,i as nt,e as it,D as rt,f as ot,I as at,g as ut,h as ct,j as lt,k as dt,l as pt}from"./ucp-shared.CB5djrmK.js";import{E as ht,c as mt,g as he,d as ue,e as ft,f as yt}from"./embed-deferred.B7xD-_a4.js";import{a as _t,i as gt}from"./proposal-delegated-payment-instrument.Gc2rhfd3.js";import{I as bt,i as vt}from"./graphql-PaymentSessionMutation.CAXCwUvV.js";import{b as Et,a as Ct,c as D,s as It,P as Rt}from"./embed-browser.CEXD5vfZ.js";import{B as At}from"./legacy-client.4Pk7vtv3.js";import{g as Pt}from"./shared-embed-client-shared.Cdh2Jybq.js";import"./app.DbSrjjlA.js";import"./redemption-promotions.DicFJEgz.js";import"./shared-buyer-consent.B_gDyRCR.js";import"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";var f,m,g,P,I,k,a,me,fe,ye,C,_e,ge,be,ve,Ee,j,Ce,H,Y,Ie;const w=class w{constructor(e,t){_(this,a);_(this,f);_(this,m);_(this,g);_(this,P);_(this,I);_(this,k);this.version=w.version,E(this,f,e),E(this,k,t),E(this,m,new $e({context:e,toMinorUnits:h,findSelectedInstrument:n=>d(this,a,C).call(this,n),includeShopPromotion:!0})),E(this,g,new Xe({extensions:[u(this,m)],getCheckout:()=>u(this,I).peek()})),E(this,P,oe(()=>{const n=d(this,a,Ie).call(this);return n?u(this,g).decorateCheckout(n):void 0})),E(this,I,oe(()=>{const n=u(this,P).value;return n&&de(n,u(this,a,me))}))}get ucpCheckout(){return u(this,I)}get shopCash(){return u(this,m).shopCash}get shopDiscountOffer(){return u(this,m).shopDiscountOffer}isShopDiscountOfferUnsettled(){return u(this,m).isShopDiscountOfferUnsettled()}mapEvent(e){return u(this,g).mapEvent(e,()=>d(this,a,ye).call(this,e))}mapResponse(e,t){switch(e){case"ec.ready":return Kt(t)?d(this,a,be).call(this,t):void 0;case"ec.fulfillment.address_change_request":return Xt(t)?Zt(t,u(this,f)):void 0;case"ec.payment.instruments_change_request":return zt(t)?d(this,a,_e).call(this,t):void 0;case"ec.payment.credential_request":return Wt(t)?d(this,a,ge).call(this,t):void 0;case"ec.window.open_request":return $t(t)?!0:void 0;default:return}}parseIncomingRequest(e){const t=u(this,g).parseIncomingRequest(e);if(t)return t;switch(e.method){case"ec.submit":return d(this,a,ve).call(this,e);case"ec.update":return d(this,a,Ee).call(this,e);default:return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unknown method: ${e.method}`}}}}}buildSubmitResponse(e){const t=d(this,a,j).call(this);if(t?.order)return{jsonrpc:"2.0",id:e,result:{ucp:d(this,a,H).call(this),checkout:t,...d(this,a,Ce).call(this)}}}buildAckResponse(e){return{jsonrpc:"2.0",id:e,result:{ucp:d(this,a,H).call(this)}}}buildErrorResponse(e,t){const{code:n,content:i,severity:r}=kt(t,u(this,g));return{jsonrpc:"2.0",id:e,result:{ucp:d(this,a,Y).call(this),messages:[{type:"error",code:n,content:i,content_type:"plain",severity:r}]}}}};f=new WeakMap,m=new WeakMap,g=new WeakMap,P=new WeakMap,I=new WeakMap,k=new WeakMap,a=new WeakSet,me=function(){return Et({context:u(this,f),targetType:u(this,k)})},fe=function(){return Ct({context:u(this,f),targetType:u(this,k)})},ye=function(e){const t=u(this,I).peek();switch(e.type){case"checkout.ready":return t?{jsonrpc:"2.0",method:"ec.ready",id:D(),params:{delegate:Array.from(u(this,f).embed.delegations.allowed)}}:void 0;case"checkout.start":return t?{jsonrpc:"2.0",method:"ec.start",params:{checkout:t}}:void 0;case"checkout.error":{const n=e.severity??"requires_buyer_input",i={type:"error",code:e.code?.toLowerCase()??"unknown_error",content:e.message??"",content_type:"plain",severity:n,path:e.path};return n==="unrecoverable"?{jsonrpc:"2.0",method:"ec.error",params:{error:{ucp:d(this,a,Y).call(this),messages:[i]}}}:t?{jsonrpc:"2.0",method:"ec.messages.change",params:{checkout:{...t,messages:[...t.messages??[],i]}}}:void 0}case"checkout.addressChangeStart":return t?{jsonrpc:"2.0",id:D(),method:"ec.fulfillment.address_change_request",params:{checkout:t}}:void 0;case"checkout.paymentMethodChangeStart":return t?{jsonrpc:"2.0",id:D(),method:"ec.payment.instruments_change_request",params:{checkout:t}}:void 0;case"checkout.submitStart":return t?{jsonrpc:"2.0",id:D(),method:"ec.payment.credential_request",params:{checkout:t}}:void 0;case"checkout.windowOpen":return{jsonrpc:"2.0",id:D(),method:"ec.window.open_request",params:{url:e.url}};case"checkout.messagesChange":return t?{jsonrpc:"2.0",method:"ec.messages.change",params:{checkout:t}}:void 0;case"checkout.paymentChange":return t?{jsonrpc:"2.0",method:"ec.payment.change",params:{checkout:t}}:void 0;case"checkout.lineItemsChange":return t?{jsonrpc:"2.0",method:"ec.line_items.change",params:{checkout:t}}:void 0;case"checkout.buyerChange":return t?{jsonrpc:"2.0",method:"ec.buyer.change",params:{checkout:t}}:void 0;case"checkout.fulfillmentChange":return t?{jsonrpc:"2.0",method:"ec.fulfillment.change",params:{checkout:t}}:void 0;case"checkout.totalsChange":return t?{jsonrpc:"2.0",method:"ec.totals.change",params:{checkout:t}}:void 0;case"checkout.complete":{const n=d(this,a,j).call(this);return n?.order?{jsonrpc:"2.0",method:"ec.complete",params:{checkout:n}}:void 0}default:return}},C=function({instruments:e,selectedInstrumentId:t,hasCredential:n}){if(!e?.length)return;const i=u(this,f).checkout.proposal.negotiated.fields.ucp.value?.paymentHandlers?.map(r=>r.id)??[];return e.find(r=>{const o=typeof t=="string"?r.id===t:r.selected===!0;return typeof r.id!="string"||typeof r.handler_id!="string"||!o||typeof r.display?.last_digits!="str
1ing"||typeof r.display?.brand!="string"||r.billing_address==null?(i.includes(r.handler_id)||u(this,f).observability.log("InvalidHandlerId","Payment instrument has an invalid handler ID",{handler_id:r.handler_id}),!1):n?r.credential!=null&&typeof r.credential.token=="string":!0})},_e=function(e){const{instruments:t,selected_instrument_id:n}=e.checkout?.payment??{};return{ucpPaymentInstrument:d(this,a,C).call(this,{instruments:t,selectedInstrumentId:n})}},ge=function(e){return{ucpPaymentInstrument:d(this,a,C).call(this,{instruments:e.checkout?.payment?.instruments,hasCredential:!0})}},be=function(e){if(e.upgrade!=null&&e.upgrade.port!=null&&e.upgrade.port instanceof MessagePort)return{upgrade:{port:e.upgrade.port}};const{instruments:t,selected_instrument_id:n}=e.checkout?.payment??{};return{upgrade:void 0,ucpPaymentInstrument:d(this,a,C).call(this,{instruments:t,selectedInstrumentId:n})}},ve=function(e){const n=e.params?.checkout?.payment?.instruments,i=d(this,a,C).call(this,{instruments:n,hasCredential:!0});return i?{type:"submit",instrument:i}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:qe.INVALID_PARAMS,message:"Missing payment instrument with credential"}}}},Ee=function(e){const n=e.params?.checkout;if(!n||Object.keys(n).length!==1)return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"ec.update requires exactly one field"}}};const i=Object.keys(n)[0];switch(i){case"fulfillment":{const r=n.fulfillment,o=r?B(r):void 0;return o?{type:"addressUpdate",address:o}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid delivery address"}}}}case"payment":{const r=n.payment,o=d(this,a,C).call(this,{instruments:r?.instruments});return o?{type:"instrumentUpdate",instrument:o}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid payment instrument"}}}}case"buyer":{const r=Nt(n.buyer);return r?{type:"buyerUpdate",buyer:r}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid buyer identity"}}}}default:return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Unknown ec.update field: ${i}`}}}}},j=function(){const e=u(this,P).peek();return e&&de(e,u(this,a,fe))},Ce=function(){if(!u(this,m).enabled)return{};const e=this.shopCash.peek(),t=this.shopDiscountOffer.peek();return{...e?{shop_cash:e}:{},...t?{shop_discount_offer:t}:{}}},H=function(){return{version:this.version,status:"success"}},Y=function(){return{version:this.version,status:"error"}},Ie=function(){const{checkout:e,shop:t,i18n:n,embed:i,negotiationContext:r}=u(this,f),{merchandiseLines:o,runningTotal:c,subtotal:p,discountLines:l,contactInfo:y,taxes:b,duties:O,dutiesIncluded:S,optionalDuties:Pe,landedCostDetails:ke,ucp:Se}=e.proposal.negotiated.fields,{id:G,paymentHandlers:De}=Se.value??{};if(G==null)return;const Oe=wt({contactInfo:y?.value}),z=e.latestReceipt.value,Te=z?.status==="processed"?z.purchaseOrder.paymentLines:void 0,M=ss(Te),W=r?.delegatedPaymentInstrument?.value,Ne=q(e.proposal.proposed.billingAddress.value),we=ts(W,Ne,M,u(this,m)),K=[];for(const x of t.merchantPolicies){const ie=St.get(x.handle);ie&&K.push({type:ie,url:x.url,title:n.translate("shop_policies",{scope:x.handle.replace(/-/g,"_")})})}const{lineItems:Me,itemsDiscountAmount:Le}=os({lines:o.value?.lines}),v=[],L=rs(o.value?.lines)??p.value;v.push({type:"subtotal",display_text:"Subtotal",amount:h(L)}),L!=null&&v.push(...us({currencyCode:L.currencyCode,discountLines:l?.value,itemsDiscountAmount:Le}));const $=cs({checkout:e});$!=null&&v.push({type:"fulfillment",display_text:"Shipping",amount:h($)});const X=b.value,Z=e.proposal.facts.tax??(X?.status==="available_total"?X.totalTax:void 0);Z!=null&&v.push({type:"tax",display_text:"Taxes",amount:h(Z)});const Q=O.value,J=Pe.value,xe=S.value||e.proposal.facts.dutiesIncluded,Fe=!!(J?.refuseDutiesPermitted&&J?.buyerRefusesDuties)&&ke.value?.incoterm===bt.Ddu,Ue=Q?.status==="available_total"?Q.totalDuty:null,ee=xe||Fe?null:e.proposal.facts.duty??Ue;ee!=null&&(u(this,m).enabled||t.hasFlagEnabled(Be))&&v.push({type:"duty",display_text:"Duties",amount:h(ee)});
1const te=c.value,je=te?.currencyCode??"USD";v.push({type:"total",display_text:"Total",amount:h(te)});const se=Jt({checkout:e}),He=Ae(W,M,u(this,m)),Ye=[...se.keys(),...He?[ns(M)]:[]],ne=Ze({discountLines:l?.value,toMinorUnits:h,hiddenCodeTitle:n.translate("order_summary.discount_title")});return{ucp:Ot({embed:i,ucpPaymentHandlers:De}),id:G,status:Tt({checkout:e,violationMessageMap:se}),buyer:Oe,line_items:Me,links:K,messages:Ye,currency:je,totals:v,payment:{instruments:we},fulfillment:{methods:Mt({checkout:e})},order:Gt({checkout:e}),...ne&&{discounts:ne}}},w.version="2026-08-25";let A=w;function kt(s,e){const t=e.mapError(s);return t||(s instanceof ht?{code:"invalid_state_error",content:"Checkout not initialized",severity:"unrecoverable"}:s instanceof mt?{code:"invalid_state_error",content:"Payment instrument credential missing",severity:"recoverable"}:s instanceof he?{code:"payment_failed",content:"Checkout submission failed",severity:"recoverable"}:{code:"internal_error",content:"Internal error",severity:"unrecoverable"})}const St=new Map([["terms-of-service","terms_of_service"],["privacy-policy","privacy_policy"],["refund-policy","refund_policy"],["shipping-policy","shipping_policy"]]),Dt=new Map([["MERCHANDISE_OUT_OF_STOCK","out_of_stock"],["MERCHANDISE_OUT_OF_STOCK_IN_CONTEXT","out_of_stock"],["MERCHANDISE_NOT_ENOUGH_STOCK_AVAILABLE","out_of_stock"],["MERCHANDISE_INVENTORY_NOT_FOUND","out_of_stock"],["DELIVERY_OUT_OF_STOCK_AT_ORIGIN_LOCATION","out_of_stock"],["MERCHANDISE_NOT_APPLICABLE","item_unavailable"],["MERCHANDISE_NOT_FOUND","item_unavailable"],["MERCHANDISE_PRODUCT_NOT_PUBLISHED","item_unavailable"],["MERCHANDISE_PRODUCT_NOT_PUBLISHED_IN_BUYER_LOCATION","item_unavailable"],["MERCHANDISE_PRODUCT_VARIANT_NOT_FOUND","item_unavailable"],["DELIVERY_NO_DELIVERY_STRATEGY_AVAILABLE_FOR_MERCHANDISE_LINE","address_undeliverable"],["DELIVERY_ZONE_NOT_FOUND","address_undeliverable"],["DELIVERY_ZONE_REQUIRED_FOR_COUNTRY","address_undeliverable"],["PAYMENTS_CREDIT_CARD_GENERIC","payment_failed"],["PAYMENTS_CREDIT_CARD_BASE_GATEWAY_NOT_SUPPORTED","payment_failed"],["PAYMENTS_PROPOSED_GATEWAY_UNAVAILABLE","payment_failed"],["PAYMENTS_CREDIT_CARD_BASE_EXPIRED","payment_failed"],["PAYMENTS_CREDIT_CARD_YEAR_EXPIRED","payment_failed"],["PAYMENTS_PAYMENT_METHOD_INCOMPATIBLE_WITH_PAYMENT_TERMS","payment_failed"],...rt]);function Ot({embed:s,ucpPaymentHandlers:e}){const t={};for(const n of e??[]){const{name:i}=n;i&&(t[i]??=[],t[i].push(n))}return{version:A.version,services:{"dev.ucp.shopping":[{version:A.version,transport:"embedded",schema:"https://ucp.dev/2026-08-25/services/shopping/embedded.openrpc.json",config:{delegate:Array.from(s.delegations.allowed)}}]},capabilities:{"dev.ucp.shopping.discount":[{version:A.version,extends:"dev.ucp.shopping.checkout",spec:"https://ucp.dev/2026-08-25/specification/discount",schema:"https://ucp.dev/2026-08-25/schemas/shopping/discount.json"}]},payment_handlers:t}}function Tt({checkout:s,violationMessageMap:e}){const{shippingAddress:t,isShippingRequired:n}=s.proposal.negotiated.fields,i=s.latestReceipt.value?.status;if(i==="processed")return"completed";if(i==="processing"||i==="processing_remote_checkouts"||i==="action_required")return"complete_in_progress";if(Array.from(e.entries()).some(([l,y])=>l.type==="error"&&!it.has(y.code)))return"incomplete";const o=!!n?.value,c=!!t?.value;return o&&!c?"incomplete":"ready_for_complete"}function Nt(s){if(s==null||typeof s!="object"||Array.isArray(s))return;const e=new Set(["email","phone_number"]),t=s;if(Object.keys(t).some(r=>!e.has(r)))return;const n=Object.prototype.hasOwnProperty.call(t,"email"),i=Object.prototype.hasOwnProperty.call(t,"phone_number");if(!(n&&typeof t.email!="string")&&!(i&&typeof t.phone_number!="string")&&!(!n&&!i))return{...n?{email:t.email}:{},...i?{phone_number:t.phone_number}:{}}}function wt({contactInfo:s}){const{email:e,phone:t}=s??{};return{...e?{email:e}:{},...t?{phone_number:t}:{}}}function Mt({checkout:s}){const{merchandiseLines:{value:e},deliveryNext:{value:t},shippingAddress:{value:n}}=s.proposal.negotiated.fields;if(t?.status!=="filled"||!t.lines)return Lt(e);const r=t.lines.filter(Vt).filter(p=>p.methods.some(l=>Ft(l.methodType))&&p.targetMerchandiseLines?.some(l=>l.requiresShipping));if(!r.length)return[];const o=xt(r),c=[];for(const p of o){const l=r.filter(S=>Re(S)===p),y=l.map(Ht),b=[...new Set(y.flatMap(S=>S.line_item_ids))],O=Ut(p,l,n);c.push({id:p,type:p,line_item_ids:b,...O&&{destinations:[O]},groups:y})}return c}function Lt(s){const e=s?.lines?.filter(t=>t.requiresShipping)?.map(t=>V(t))??[];return e.length===0?[]:[{id:"shipping",type:"shipping",line_item_ids:e,destinations:[],groups:[]}]}function xt(s){const e=new Set;for(const t of s){const n=Re(t);n&&e.add(n)}return Array.from(e)}function Re(s){const e=s.methods[0];if(e)return pe(e.methodType)?"pickup":"shipping"}function Ft(s){return s==="SHIPPING"||s==="LOCAL"||pe(s)}function Ut(s,e,t){if(s==="shipping")return t?Bt(t):void 0;for(const n of e)if(n.selectedDeliveryMethodHandle){const i=n.methods.find(r=>r.handle===n.selectedDeliveryMethodHandle);if(i)return jt(i)}}function jt(s){const e=s.pickupLocation;if(e)return{id:s.handle,type:"business_location",name:e.name??"",address:q(e.address)}}function Ht(s){return{id:s.id??"",line_item_ids:qt(s),options:s.methods.map(Yt),...s.selectedDeliveryMethodHandle&&{selected_option_id:s.selectedDeliveryMethodHandle}}}function Yt(s){return{id:s.handle,title:s.title,...s.description&&{description:{plain:s.description}},...s.carrierName&&{carrier:s.carrierName},...s.minDeliveryDateTime&&{earliest_fulfillment_time:s.minDeliveryDateTime},...s.maxDeliveryDateTime&&{latest_fulfillment_time:s.maxDeliveryDateTime},totals:[{type:"fulfillment",amount:h(s.costAfterDiscounts)}]}}function V(s){return s.id??`gid://shopify/CartLine/${s.variantId}`}function Vt(s){return s.status==="available"}function qt(s){return s.targetMerchandiseLines?.filter(e=>e.requiresShipping).map(e=>V(e))??[]}function q(s){return{first_name:s.firstName,last_name:s.lastName,phone_number:s.phone,street_address:s.address1,extended_address:s.address2,address_locality:s.city,address_regi
1on:s.zoneCode,address_country:s.countryCode,postal_code:s.postalCode}}function Bt(s){return{...q(s),id:`shipping-${s.countryCode}-${s.postalCode}`.replace(/\s+/g,""),type:"shipping_address"}}function Gt({checkout:s}){const e=s.latestReceipt.value;if(e?.status!=="processed")return;const t=e.orderIdentity.buyerIdentifier;return{id:Ge("Order",ze(e.orderIdentity.id)),...t?{label:t}:{},permalink_url:e.confirmationPage.url}}function zt(s){return!s||typeof s!="object"?!1:Array.isArray(s.checkout?.payment?.instruments)}function Wt(s){return!s||typeof s!="object"?!1:s.checkout?.payment?.instruments?.find(n=>n.credential!=null)!=null}function Kt(s){return s!=null&&typeof s=="object"}function $t(s){return s!=null&&typeof s=="object"}function Xt(s){if(!s||typeof s!="object")return!1;const t=s.checkout?.fulfillment;return t?B(t)!=null:!1}function Zt(s,e){const t=s.checkout?.fulfillment,n=t?B(t):void 0;return n?{cart:{delivery:{addresses:[{address:Qt(n),oneTimeUse:!1,selected:!0}]}}}:{cart:void 0,errors:void 0}}function B(s){if(Array.isArray(s.methods))for(const e of s.methods){if(!e||typeof e!="object")continue;const{type:t,destinations:n,selected_destination_id:i}=e;if(t!=="shipping"||!Array.isArray(n))continue;const r=typeof i=="string"?i:null;if(r){const o=n.find(c=>U(c)&&typeof c.id=="string"&&c.id===r);if(o&&U(o))return o}for(const o of n){if(!U(o))continue;const c=typeof o.id=="string"?o.id:void 0;if(r==null||c&&r===c||n.length===1)return o}}}function U(s){if(!s||typeof s!="object")return!1;const e=s;return typeof e.street_address=="string"||typeof e.address_locality=="string"||typeof e.address_region=="string"||typeof e.address_country=="string"||typeof e.postal_code=="string"||typeof e.first_name=="string"||typeof e.last_name=="string"}function Qt(s,e){return{firstName:s.first_name,lastName:s.last_name,phone:s.phone_number,address1:s.street_address,address2:s.extended_address,city:s.address_locality,countryCode:s.address_country,provinceCode:s.address_region,zip:s.postal_code}}function Jt({checkout:s}){const e=new Map,t=s.proposal.negotiated.fields.allViolations.value??[];for(const n of t){if(Qe.has(n.__typename)||Je.has(n.code))continue;let i,r;et.has(n.__typename)?(i="requires_buyer_review",r=n.code.toLowerCase()):tt.has(n.code)?(i="recoverable",r=n.code.toLowerCase()):(i="requires_buyer_input",r=st.has(n.code)?n.code.toLowerCase():"requires_buyer_input");const o=Dt.get(n.code);o&&(r=o);const c="target"in n?n.target:void 0,p=n.localizedMessage||n.nonLocalizedMessage,l=nt(n.code)?{type:"warning",content_type:"plain",code:o??n.code.toLowerCase(),content:p,path:c}:{type:"error",severity:i,content_type:"plain",code:r,content:p,path:c};e.set(l,n)}return e}function es(s){return{first_name:s.firstName,last_name:s.lastName,phone_number:s.phone,street_address:s.address1,extended_address:s.address2,address_locality:s.city,address_country:s.country,address_region:s.province,postal_code:s.zip}}function ts(s,e,t,n){return s?Ae(s,t,n)?[]:_t(s)?is({instrument:s,proposalBillingAddress:e}):[{...s,selected:!0,...e&&{billing_address:e}}]:[]}function Ae(s,e,t){return e?s?!(t.shouldSuppressReceiptWalletAsExpressCheckout()||gt(s)&&s.handler_id==="gpay"&&e==="google_pay"):!0:!1}const ce={APPLE_PAY:"apple_pay",GOOGLE_PAY:"google_pay",SHOP_PAY:"shop_pay",SHOPIFY_INSTALLMENTS:"shop_pay",PAYPAL_EXPRESS:"paypal",VENMO:"venmo",AMAZON_PAY:"amazon_pay",AMAZON_PAY_CLASSIC:"amazon_pay",FACEBOOK_PAY:"facebook_pay",amazon_pay:"amazon_pay",buy_with_prime:"buy_with_prime"};function ss(s){const e=s?.find(n=>n.method.type==="wallet"||n.method.type==="walletsPlatformPaymentMethod"&&n.method.name in ce);if(e)return ce[e.method.name];if(s?.some(n=>n.method.type==="redeemable"&&n.method.redemptionSource==="SHOP_CASH"))return"shop_pay"}function ns(s){return{type:"info",path:"$.payment",code:"express_checkout",content_type:"plain",content:s}}function is({instrument:s,proposalBillingAddress:e}){return[{id:s.externalReferenceId,handler_id:"shopify.card",type:"card",selected:!0,display:{last_digits:s.lastDigits,brand:s.brand?.toLowerCase()},cardholder_name:s.cardHolderName,expiry_month:s.month,expiry_year:s.year,billing_address:e??(s.billingAddress?es(s.billingAddress):void 0)}]}const le=new Map;function rs(s){if(s)return s.reduce((e,t)=>
1{const n=t.itemPrice;if(!n)return e;const i=n.amount*t.quantity;return e?{...e,amount:e.amount+i}:{...n,amount:i}},void 0)}function os({lines:s}){if(!s?.length)return{lineItems:[],itemsDiscountAmount:0};let e=0;return{lineItems:s.map(n=>{const i=n.itemPrice,r=i?{...i,amount:i.amount*n.quantity}:void 0,o=as(n.lineAllocations),c=[];r&&c.push({type:"subtotal",amount:h(r)}),o!==0&&r&&(e+=o,c.push({type:"items_discount",amount:h({...r,amount:-o})}));const p=r&&o!==0?{...r,amount:r.amount-o}:n.totalPrice;return c.push({type:"total",amount:h(p)}),{id:V(n),parent_id:n.parentRelationship?.parent?.id??void 0,quantity:n.quantity,item:{id:n.variantId,title:n.title,price:h(i),...n.image?.url?{image_url:n.image.url}:{}},totals:c}}),itemsDiscountAmount:e}}function as(s){return s.reduce((e,t)=>{const n=t.allocations.reduce((i,{amount:r})=>i+r.amount,0);return e+n},0)}function us({currencyCode:s,discountLines:e,itemsDiscountAmount:t}){let n=0;if(e?.lines?.length){for(const r of e.lines)if(vt(r))for(const o of r.allocations)o.target.type==="DELIVERYLINE"&&(n+=o.target.amount.amount)}const i=[];return t>0&&i.push({type:"items_discount",display_text:"Discounts",amount:h({amount:-t,currencyCode:s})}),n>0&&i.push({type:"discount",display_text:"Discount",amount:h({amount:-n,currencyCode:s})}),i}function cs({checkout:s}){const{deliveryNext:e}=s.proposal.negotiated.fields,t=e.value;if(t?.status!=="filled"||!t.lines)return;let n=0,i;for(const r of t.lines){if(r.status!=="available")continue;const o=r.selectedDeliveryMethodHandle;if(!o)continue;const c=r.methods.find(p=>p.handle===o);c?.costAfterDiscounts&&(n+=c.costAfterDiscounts.amount,i??=c.costAfterDiscounts.currencyCode)}if(i!=null)return{amount:n,currencyCode:i}}function h(s){if(!s)return 0;let e=le.get(s.currencyCode);e||(e=new Intl.NumberFormat("en",{style:"decimal",currency:s.currencyCode,useGrouping:!1}),le.set(s.currencyCode,e));const t=Ve(s.currencyCode),[n,i=""]=e.format(s.amount).split(".");return Number(n+i.padEnd(t,"0"))}function de(s,{redactPII:e,redactIdKey:t}){const n=e?ls(s):s;return t?{...n,id:It(n.id)}:n}function ls(s){const{buyer:e,payment:t,...n}=s;return{...n,...s.fulfillment&&{fulfillment:ds(s.fulfillment)},...s.order&&{order:ps(s.order)}}}function ds(s){return{...s,methods:s.methods.map(e=>{const{destinations:t,selected_destination_id:n,...i}=e;return i})}}function ps(s){return{...s,permalink_url:"about:blank"}}const hs=1e4;class Ts extends At{constructor(e){super(e),this.version="2026-08-25",this.#s=new ot,this.#o=!1,this.#a=!1,this.#n=null,this.#l=!1,this.#m=new at({observability:e.observability}),this.#e=new Rt({observability:e.observability}),this.#t=new A(e,this.#e.targetType),this.#i=new ut([new ct({context:this.context,mapper:this.#t,transport:this.#e,resizeObserver:this.#m,incomingRequests:{submitShopPay:t=>this.#s.submitShopPay(t),applyRedemption:t=>this.#s.applyRedemption(t),applyShopPromotionSelection:t=>this.#s.applyShopPromotionSelection(t)},waitForPendingNegotiations:()=>this.waitForPendingNegotiations(),waitForSkeletonRemoved:()=>this.waitForSkeletonRemoved()})]),this.#e.onRequest(t=>this.#I(t)),this.observability.bridgeInitialized()}get embedderOrigin(){return this.#e.embedderOrigin}get embedderHostname(){const e=this.embedderOrigin;if(e)try{return new URL(e).hostname}catch{return}}#e;#t;#s;#o;#a;#n;#r;#p;#h;#u;#c;#l;#m;#i;unstable_providePreactContext(e){super.unstable_providePreactContext(e),this.#s.initialize({...this.context,...e,shopPaySubmitPreflight:()=>this.#r?.(),addPaymentError:n=>this.addPaymentError(n),removePaymentError:n=>this.removePaymentError(n)}).catch(n=>{this.observability.enqueuedApplyPaymentInstrumentError(n)});const t=this.context.checkout.proposal.negotiated.fields.ucp;t.value={...t.peek()}}unstable_setShopPaySubmitPreflight(e){return this.#r=e,()=>{this.#r===e&&(this.#r=void 0)}}async ready(){if(this.#e.isLoopback){if(this.context.environment.debug.logging&&this.context.client.initialRequest.url.searchParams.has("skip_ec_ready")){this.observability.skipEcReady();return}if(!await this.#v())return}this.#E();let e=this.#t.mapEvent({type:"checkout.ready"});if(!e)return;const t=await this.#f(e);let n=this.#t.mapResponse(e.method,t);if(n?.upgrade?.port instanceof MessagePort){if(this.observability.readyMessagePortUpgrade(),this.#e.upgrade(n.upgrade.port),e=this.#t.mapEvent({type:"checkout.ready"}),!e)return;const r=await this.#f(e);n=this.#t.mapResponse(e.method,r)}const i=n?.ucpPaymentInstrument;i&&(this.observability.readyPaymentInstrument(),await this.#s.applyInstrument(i)),lt(n)&&(this.observability.readyCartUpdate(Object.keys(n.cart).join(",")),this.applyCart(n.cart))}async start(){const e=this.#t.mapEvent({type:"checkout.start"});e&&(this.#e.notify(e),this.#_(),this.#i.start(),this.observability.checkoutStarted({embedder:this.context.embed.embedder,buyerEmail:this.context.checkout.proposal.proposed.email.peek(),hasPaymentInstrument:this.hasDelegatedPaymentInstrument()}),this.#g())}async resumeFromReceipt(){await this.#v()&&(this.#E(),this.#_(),this.#g())}async complete(){if(this.#C()){const t=new ue;this.observability.unauthenticatedIframe(t.message);return}if(this.#o){this.observability.completedEventSkipped();return}if(this.#o=!0,this.observability.checkoutCompleted(),this.#n){const t=this.#t.buildSubmitResponse(this.#n);this.#n=null,t&&(this.observability.submitResponseSent(t.id),this.#e.send(t));return}const e=this.#t.mapEvent({type:"checkout.complete"});e&&(this.observability.completedEventEmitted(),this.#e.notify(e))}error(e){const t=this.#t.mapEvent({type:"checkout.error",code:e.code,message:e.message,severity:e.severity,path:e.path});t&&this.#e.notify(t)}async addressChangeStart(e){const t=this.#t.mapEvent({type:"checkout.addressChangeStart",addressType:e});if(!t)return;const n=await this.#e.request(t,{singleFlight:!0});return this.#t.mapResponse(t.method,n)}async paymentMethodChangeStart(){this.removePaymentError(T.PaymentDelegationError);try{const e=this.#t.mapEvent({type:"checkout.paymentMethodChangeStart"});if(!e)return;const t=await this.#e.request(e,{singleFlight:!0}),n=this.#t.mapResponse(e.method,t);return n?.ucpPaymentInstrument&&await this.#s.applyInstrument(n.ucpPaymentInstrument),n}catch(e){return this.#y(e,"payment.instruments_change")}}async submitStart(){this.removePaymentError(T.PaymentDelegationError);try{await this.waitForPendingNegotiations();const e=this.#t.mapEvent({type:"checkout.submitStart"});if(!e)return;const t=await this.#e.request(e,{timeoutMs:Pt(this.context.embed.embedder),singleFlight:!0}),n=this.#t.mapResponse(e.method,t);if(n?.ucpPaymentInstrument){const i=await this.#s.submit(n.ucpPaymentInstrument);this.#d(i)}return n}catch(e){return this.#y(e,"payment.credential")}}async windowOpenRequest(e){const t=this.#t.mapEvent({type:"checkout.windowOpen",url:e});if(t)try{await this.#e.request(t)}catch(n){if(n instanceof N&&n.errorCode===We.WINDOW_OPEN_REJECTED){this.observability.windowOpenRejected(e,n.errorMessage);return}this.observability.windowOpenError(e,n)}}beforeunload(){this.#i.beforeunload()}dialogChange(e){this.#i.dialogChange(e)}async requestShopPaySessionRevalidation(){return await this.#i.requestShopPaySessionRevalidation()??!0}shopPaySessionRevalidationChange(e){this.#i.shopPaySessionRevalidationChange(e)}cleanup(){this.#i.cleanup(),this.#e.cleanup(),this.#s.cleanup(),this.#p?.(),this.#h?.(),this.#l=!0}async#f(e){try{return await this.#e.request(e,{timeoutMs:hs})}catch(t){throw t instanceof N&&(this.observability.handshakeError(t.errorCode,t.errorMessage),this.cleanup()),t}}#y(e,t){if(e instanceof N&&e.isUserCancelledError){this.observability.paymentDelegationCancelled();return}if(e instanceof Ke){this.observability.paymentDelegationTimeout(t,e.message),this.addPaymentError(T.PaymentDelegationError);return}if(e instanceof N&&e.isInternalError){this.observability.paymentDelegationError(t,e.message),this.addPaymentError(T.PaymentDelegationError);return}this.observability.paymentDelegationUnexpectedError(t,e instanceof Error?e.message:String(e))}async#I(e){const{embed:t}=this.context;try{const n=this.#t.parseIncomingRequest(e);
1if("errorResponse"in n){this.observability.incomingRequestValidationFailed(e.id),this.#e.send(n.errorResponse);return}if(await this.#i.handleIncomingRequest(n,{requestId:e.id,markSubmitPending:()=>{this.#n=e.id},onSubmitAttempt:r=>this.#d(r),sendAckResponse:()=>{this.#e.send(this.#t.buildAckResponse(e.id))}}))return;if(n.type!=="submit"&&!this.#i.canHandleIncomingRequest(n.type))throw new ft(t.embedder);switch(n.type){case"submit":{this.#n=e.id;const r=await this.#s.submit(n.instrument);this.#d(r);break}case"addressUpdate":await this.#s.applyAddress(n.address),this.#e.send(this.#t.buildAckResponse(e.id));break;case"buyerUpdate":await this.#s.applyBuyer(n.buyer),this.#e.send(this.#t.buildAckResponse(e.id));break;case"instrumentUpdate":await this.#s.applyInstrument(n.instrument),this.#e.send(this.#t.buildAckResponse(e.id));break}}catch(n){this.#n=null,this.observability.incomingRequestError(e.id,n);try{this.#e.send(this.#t.buildErrorResponse(e.id,n))}catch{}}}#_(){let e;this.#h=ae(()=>{const t=this.#t.ucpCheckout.value;if(!e){e=t,this.#c=t?.totals;return}if(t){if(!ms(e.line_items,t.line_items)){const n=this.#t.mapEvent({type:"checkout.lineItemsChange"});n&&this.#e.notify(n)}if(!R(e.buyer,t.buyer)){const n=this.#t.mapEvent({type:"checkout.buyerChange"});n&&this.#e.notify(n)}if(!R(e.fulfillment,t.fulfillment)){const n=this.#t.mapEvent({type:"checkout.fulfillmentChange"});n&&this.#e.notify(n)}if(!fs(e.payment,t.payment)){const n=this.#t.mapEvent({type:"checkout.paymentChange"});n&&this.#e.notify(n)}if(this.#i.checkoutChange(e,t),!R(e.messages,t.messages)){const n=this.context.checkout.proposal.negotiated.fields.allViolations.value??[],i=!!this.context.negotiationContext?.delegatedPaymentInstrument?.peek();if(n.some(o=>dt.has(o.code)||i&&pt.has(o.code))){const o=this.#t.mapEvent({type:"checkout.messagesChange"});o&&this.#e.notify(o)}}R(e.totals,t.totals)||this.#R(),t.status==="ready_for_complete"&&!this.#a&&(this.#a=!0,this.observability.readyForComplete()),e=t}})}#R(){this.#u||(this.#u=this.#A())}async#A(){try{await this.waitForPendingNegotiations()}finally{this.#u=void 0}if(this.#l)return;const e=this.#t.ucpCheckout.peek()?.totals;if(e&&!R(this.#c,e)){this.#c=e;const t=this.#t.mapEvent({type:"checkout.totalsChange"});t&&this.#e.notify(t)}}#d(e){if(!e)return;const t=this.#n;if(e.status==="success"||e.status==="alreadyCompleted"){this.#i.onSubmit({type:"attemptSucceeded",result:e,requestId:t});return}e.status==="blocked"?this.observability.submitBlocked(t??"none",e.reason):this.observability.submitFailed(t??"none",e.reason);const n=this.#i.onSubmit({type:"attemptFailed",failure:e,requestId:t});n?.type!=="errorResponse"||!t||(this.#n=null,this.#e.send(this.#t.buildErrorResponse(t,n.error)))}#g(){if(this.context.checkout.latestReceipt.peek()?.status==="processed"){this.complete(),this.#b();return}let e=!0;this.#p=ae(()=>{const t=this.context.checkout.latestReceipt.value;if(e)e=!1;else if(t?.status==="failed"&&t.failure.type==="payment"){const i="code"in t.failure?String(t.failure.code).toLowerCase():"unknown";this.error({code:"PAYMENT_ERROR",message:i,severity:"recoverable",path:"$.payment",timestamp:Date.now()})}if(t?.status==="failed"){const i="code"in t.failure?t.failure.code:"unknown";this.observability.receiptError(t.failure.type,i)}if(t?.status==="failed"&&this.#n){const i=this.#n;this.#n=null,this.observability.submitReceiptFailed(i,t.failure.type),this.#e.send(this.#t.buildErrorResponse(i,new he(t.failure.type)));return}t&&t.status==="processed"&&(this.complete(),this.#b())})}#b(){this.context.checkout.configuration.isUniversalCheckoutFinalizer||this.cleanup()}async#v(){if(!this.#e.isLoopback)return!0;const e=await this.#e.waitForTarget();if(this.#e.isDisposed)return!1;if(e==="loopback"){const t=new yt("No embedder transport detected. Checkout was loaded in embedded mode but no parent frame or native bridge was found.");throw this.observability.noTransportDetected(t.message,this.#e.environmentSnapshot),t}return!0}#E(){if(!this.#C())return;const e=new ue;throw this.observability.unauthenticatedIframe(e.message),e}#C(){return this.#e.isIframe&&!this.context.embed.isAuthenticated}}function ms(s,e){return s===e?!0:s.length!==e.length?!1:s.every((t,n)=>{const i=e[n];return t.id===i.id&&t.quantity===i.quantity&&t.parent_id===i.parent_id&&t.item.id===i.item.id&&t.item.title===i.item.title&&t.item.image_url===i.item.image_url})}function fs(s,e){if(s===e)return!0;
1if(!s||!e)return!1;const t=s.instruments??[],n=e.instruments??[];return t.length!==n.length?!1:t.every((i,r)=>{const o=n[r],c=Object.keys(i).filter(l=>l!=="credential"),p=Object.keys(o).filter(l=>l!=="credential");return c.length!==p.length?!1:c.every(l=>{if(!(l in o))return!1;const y=i[l],b=o[l];return y===b?!0:typeof y=="object"&&typeof b=="object"?R(y,b):!1})})}export{Ts as Ucp2026_08_25Client};

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.