1var e,t,n,s,r,i,o,a,c,u,p,d,l,h,m,f,y,g,b=e=>{throw TypeError(e)},v=(e,t,n)=>t.has(e)||b("Cannot "+n),_=(e,t,n)=>(v(e,t,"read from private field"),n?n.call(e):t.get(e)),k=(e,t,n)=>t.has(e)?b("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),C=(e,t,n,s)=>(v(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),w=(e,t,n)=>(v(e,t,"access private method"),n);import{G as E,c as I,j as P}from"./2c1ab0fe.GMbxnz74.js";import{fM as R,h as S,J as A,fN as x,fO as j,fP as q,fQ as D,fR as T}from"./4c290a1e.DMQ9xOwP.js";import{U as M,E as O,D as L,b as N,O as U,a as F,R as H,c as z,d as W,i as Y,e as B,f as V,I as $,g as K,h as G,j as J,k as X,l as Z}from"./24dc440e.fcXyHnOF.js";import{E as Q,a as ee,b as te,c as ne,d as se,e as re}from"./5c5c2e96.D7xkIHuT.js";import{c as ie,d as oe}from"./e477f96c.DJuIaq7S.js";import{i as ae}from"./0a7dffce.BcNpdEJk.js";import{b as ce,a as ue,c as pe,s as de,P as le}from"./711bf263.CXsAdxw9.js";import{B as he}from"./9c523c9d.MigMTTTS.js";import{g as me}from"./e592f8b9.DUn4Te8e.js";import"./app.DGSHpWaV.js";import"./bff2ff9b.Cy_si-5k.js";import"./21cc90a2.Ccyorzx_.js";const fe=class c{constructor(u,d){k(this,o),k(this,e),k(this,t),k(this,n),k(this,s),k(this,r),k(this,i),this.version=c.version,C(this,e,u),C(this,i,d),C(this,t,new M({context:u,toMinorUnits:Ne,findSelectedInstrument:e=>w(this,o,p).call(this,e)})),C(this,n,new O({extensions:[_(this,t)],getCheckout:()=>_(this,r).peek()})),C(this,s,E(()=>{const s=function({checkout:e,shop:t,i18n:n,embed:s,negotiationContext:r},i){const{merchandiseLines:o,runningTotal:a,subtotal:c,discountLines:u,contactInfo:p,taxes:d,ucp:l}=e.proposal.negotiated.fields,{id:h,paymentHandlers:m}=l.value??{};if(null==h)return;const f=function({contactInfo:e}){const{email:t,phone:n}=e??{};return{...t?{email:t}:{},...n?{phone_number:n}:{}}}({contactInfo:p?.value}),y=e.latestReceipt.value,g=function(e){const t=e?.find(e=>"wallet"===e.method.type||"walletsPlatformPaymentMethod"===e.method.type&&e.method.name in Oe);if(t)return Oe[t.method.name];const n=e?.some(e=>"redeemable"===e.method.type&&"SHOP_CASH"===e.method.redemptionSource);return n?"shop_pay":void 0}("processed"===y?.status?y.purchaseOrder.paymentLines:void 0),b=r?.delegatedPaymentInstrument?.value,v=function(e,t,n,s){return e?Me(e,n,s)?[]:oe(e)?function({instrument:e,proposalBillingAddress:t}){return[{id:e.externalReferenceId,handler_id:"shopify.card",type:"card",selected:!0,display:{last_digits:e.lastDigits,brand:e.brand?.toLowerCase()},cardholder_name:e.cardHolderName,expiry_month:e.month,expiry_year:e.year,billing_address:t}]}({instrument:e,proposalBillingAddress:t}):[{...e,selected:!0,billing_address:t}]:[]}(b,xe(e.proposal.proposed.billingAddress.value),g,i),_=[];for(const O of t.merchantPolicies){const e=ge.get(O.handle);e&&_.push({type:e,url:O.url,title:n.translate("shop_policies",{scope:O.handle.replace(/-/g,"_")})})}const k="microsoft"!==s.embedder,{lineItems:C,itemsDiscountAmount:w}=function({lines:e,specCompliantDiscounts:t}){if(!e?.length)return{lineItems:[],itemsDiscountAmount:0};let n=0;return{lineItems:e.map(e=>{const s=e.itemPrice,r=s?{...s,amount:s.amount*e.quantity}:void 0,i=function(e,t){return e.reduce((e,n)=>e+n.allocations.reduce((e,{discountDetails:{discount:n},amount:s})=>t||"discountCodeTrigger"!==n.type?e+s.amount:e,0),0)}(e.lineAllocations,t),o=[];r&&o.push({type:"subtotal",amount:Ne(r)}),0!==i&&r&&(t&&(n+=i),o.push({type:t?"items_discount":"discount",amount:Ne({...r,amount:t?i:-i})}));const a=t&&r&&0!==i?{...r,amount:r.amount-i}:e.totalPrice;return o.push({type:"total",amount:Ne(a)}),{id:Re(e),parent_id:e.parentRelationship?.parent?.id??void 0,quantity:e.quantity,item:{id:e.variantId,title:e.title,price:Ne(s),...e.image?.url?{image_url:e.image.url}:{}},totals:o}}),itemsDiscountAmount:n}}({lines:o.value?.lines,specCompliantDiscounts:k}),E=[],I=c.value,P=(k?(R=o.value?.lines,R?R.reduce((e,t)=>{const n=t.itemPrice;if(!n)return e;const s=n.amount*t.quantity;return e?{...e,amount:e.amount+s}:{...n,amount:s}},void 0):void 0):void 0)??I;var R;if(null!=P&&E.push({type:"subtotal",display_text:"Subtotal",amount:Ne(P)}),k&&null!=P&&E.push(...function({currencyCode:e,discountLines:t,itemsDiscountAmount:n}){let s=0;if(t?.lines?.length)for(const i of t.lines)if(ae(i))for(const e of i.allocations)"DELIVERYLINE"===e.target.type&&(s+=e.target.amount.amount);const r=[];return n>0&&r.push({type:"items_discount",display_text:"Discounts",amount:Ne({amount:n,currencyCode:e})}),s>0&&r.push({type:"discount",display_text:"Discount",amount:Ne({amount:s,currencyCode:e})}),r}({currencyCode:P.currencyCode,discountLines:u?.value,itemsDiscountAmount:w})),k){const t=function({checkout:e}){const{deliveryNext:t}=e.proposal.negotiated.fields,n=t.value;if("filled"!==n?.status||!n.lines)return;let s,r=0;for(const i of n.lines){if("available"!==i.status)continue;const e=i.selectedDeliveryMethodHandle;if(!e)continue;const t=i.methods.find(t=>t.handle===e);t?.costAfterDiscounts&&(r+=t.costAfterDiscounts.amount,s??=t.costAfterDiscounts.currencyCode)}return null==s?void 0:{amount:r,currencyCode:s}}({checkout:e});null!=t&&E.push({type:"fulfillment",display_text:"Shipping",amount:Ne(t)})}const S=d.value,A=e.proposal.facts.tax??("available_total"===S?.status?S.totalTax:void 0);null!=A&&E.push({type:"tax",display_text:"Taxes",amount:Ne(A)});const x=a.value;null!=x&&E.push({type:"total",display_text:"Total",amount:Ne(x)});const j=k,q=function({checkout:e,discountExtensionEnabled:t}){const n=new Map,s=e.proposal.negotiated.fields.allViolations.value??[];for(const r of s){if(U.has(r.__typename))continue;if(F.has(r.code))continue;let e,s;H.has(r.__typename)?(e="requires_buyer_review",s=r.code.toLowerCase()):z.has(r.code)?(e="recoverable",s=r.code.toLowerCase()):(e="requires_buyer_input",s=W.has(r.code)?r.code.toLowerCase():"requires_buyer_input");const i="target"in r?r.target:void 0,o=r.localizedMessage||r.nonLocalizedMessage;if(t&&Y(r.code)){const e=Te.get(r.code);n.set({type:"warning",content_type:"plain",code:e??r.code.toLowerCase(),content:o,path:i},r);continue}n.set({type:"error",severity:e,content_type:"plain",code:s,content:o,path:i},r)}return n}({checkout:e,discountExtensionEnabled:j}),D=[...q.keys(),...Me(b,g,i)?[(M=g,{type:"info",path:"$.payment",code:"express_checkout",content_type:"plain",content:M})]:[]],T=j?N({discountLines:u?.value,toMinorUnits:Ne,hiddenCodeTitle:n.translate("order_summary.discount_title")}):void 0;var M;return{ucp:be({embed:s,ucpPaymentHandlers:m,discountExtensionEnabled:j}),id:h,status:ve({checkout:e,violationMessageMap:q}),buyer:f,line_items:C,links:_,messages:D,currency:a.value?.currencyCode??"USD",totals:E,payment:{instruments:v},fulfillment:{methods:ke({checkout:e})},order:je({checkout:e,embed:s}),...T&&{discounts:T}}}(_(this,e),_(this,t));return s?_(this,n).decorateCheckout(s):void 0})),C(this,r,E(()=>{const e=_(this,s).value;return e&&_e(e,_(this,o,a))}))}get ucpCheckout(){return _(this,r)}get shopCash(){return _(this,t).shopCash}get shopDiscountOffer(){return _(this,t).shopDiscountOffer}
1isShopDiscountOfferUnsettled(){return _(this,t).isShopDiscountOfferUnsettled()}mapEvent(e){return _(this,n).mapEvent(e,()=>w(this,o,u).call(this,e))}mapResponse(t,n){switch(t){case"ec.ready":if(!function(e){return null!=e&&"object"==typeof e}(n))return;return w(this,o,h).call(this,n);case"ec.fulfillment.address_change_request":if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e,n=t.checkout?.fulfillment;return!!n&&null!=qe(n)}(n))return;return function(e){const t=e.checkout?.fulfillment,n=t?qe(t):void 0;return n?{cart:{delivery:{addresses:[{address:(s=n,{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}),oneTimeUse:!1,selected:!0}]}}}:{cart:void 0,errors:void 0};var s}(n,_(this,e));case"ec.payment.instruments_change_request":if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e;return Array.isArray(t.checkout?.payment?.instruments)}(n))return;return w(this,o,d).call(this,n);case"ec.payment.credential_request":if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e,n=t.checkout?.payment?.instruments?.find(e=>null!=e.credential);return null!=n}(n))return;return w(this,o,l).call(this,n);case"ec.window.open_request":if(!function(e){return null!=e&&"object"==typeof e}(n))return;return!0;default:return}}parseIncomingRequest(e){const t=_(this,n).parseIncomingRequest(e);if(t)return t;switch(e.method){case"ec.submit":return w(this,o,m).call(this,e);case"ec.update":return w(this,o,f).call(this,e);default:return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unknown method: ${e.method}`}}}}}buildSubmitResponse(e){const t=w(this,o,y).call(this);if(t?.order)return{jsonrpc:"2.0",id:e,result:{checkout:t,...w(this,o,g).call(this)}}}buildErrorResponse(e,t){if(t instanceof Q)return{jsonrpc:"2.0",id:e,error:{code:R.INVALID_PARAMS,message:"Checkout not initialized"}};if(t instanceof ee)return{jsonrpc:"2.0",id:e,error:{code:R.INVALID_PARAMS,message:"Invalid payment instrument credential"}};const s=_(this,n).mapError(t);return s?{jsonrpc:"2.0",id:e,error:{code:"recoverable"===s.severity?s.code:R.INTERNAL,message:s.content,data:{severity:s.severity,..."submit_blocked"===s.code?{reason:s.content}:{}}}}:{jsonrpc:"2.0",id:e,error:{code:R.INTERNAL,message:"Internal error"}}}};e=new WeakMap,t=new WeakMap,n=new WeakMap,s=new WeakMap,r=new WeakMap,i=new WeakMap,o=new WeakSet,a=function(){return ce({context:_(this,e),targetType:_(this,i)})},c=function(){return ue({context:_(this,e),targetType:_(this,i)})},u=function(t){const n=_(this,r).peek();switch(t.type){case"checkout.ready":if(!n)return;return{jsonrpc:"2.0",method:"ec.ready",id:pe(),params:{delegate:Array.from(_(this,e).embed.delegations.allowed)}};case"checkout.start":if(!n)return;return{jsonrpc:"2.0",method:"ec.start",params:{checkout:n}};case"checkout.error":{if(!n)return;const e={type:"error",code:t.code?.toLowerCase()??"unknown_error",content:t.message??"",content_type:"plain",severity:t.severity??"requires_buyer_input",path:t.path};return{jsonrpc:"2.0",method:"ec.messages.change",params:{checkout:{...n,messages:[...n.messages??[],e]}}}}case"checkout.addressChangeStart":if(!n)return;return{jsonrpc:"2.0",id:pe(),method:"ec.fulfillment.address_change_request",params:{checkout:n}};case"checkout.paymentMethodChangeStart":if(!n)return;return{jsonrpc:"2.0",id:pe(),method:"ec.payment.instruments_change_request",params:{checkout:n}};case"checkout.submitStart":if(!n)return;return{jsonrpc:"2.0",id:pe(),method:"ec.payment.credential_request",params:{checkout:n}};case"checkout.windowOpen":return{jsonrpc:"2.0",id:pe(),method:"ec.window.open_request",params:{url:t.url}};case"checkout.messagesChange":if(!n)return;return{jsonrpc:"2.0",method:"ec.messages.change",params:{checkout:n}};case"checkout.paymentChange":if(!n)return;return{jsonrpc:"2.0",method:"ec.payment.change",params:{checkout:n}};case"checkout.lineItemsChange":if(!n)return;return{jsonrpc:"2.0",method:"ec.line_items.change",params:{checkout:n}};case"checkout.buyerChange":if(!n)return;return{jsonrpc:"2.0",method:"ec.buyer.change",params:{checkout:n}};case"checkout.fulfillmentChange":if(!n)return;return{jsonrpc:"2.0",method:"ec.fulfillment.change",params:{checkout:n}};case"checkout.totalsChange":if(!n)return;return{jsonrpc:"2.0",method:"ec.totals.change",params:{checkout:n}};case"checkout.complete":{const e=w(this,o,y).call(this);if(!e?.order)return;return{jsonrpc:"2.0",method:"ec.complete",params:{checkout:e}}}default:return}},p=function({instruments:t,hasCredential:n}){if(!t?.length)return;const s=_(this,e).checkout.proposal.negotiated.fields.ucp.value?.paymentHandlers?.map(e=>e.id)??[];return t.find(t=>"string"!=typeof t.id||"string"!=typeof t.handler_id||!0!==t.selected||"string"!=typeof t.display?.last_digits||"string"!=typeof t.display?.brand||null==t.billing_address?(s.includes(t.handler_id)||_(this,e).observability.log("InvalidHandlerId","Payment instrument has an invali
1d handler ID",{handler_id:t.handler_id}),!1):!n||null!=t.credential&&"string"==typeof t.credential.token)},d=function(e){const{instruments:t}=e.checkout?.payment??{};return{ucpPaymentInstrument:w(this,o,p).call(this,{instruments:t})}},l=function(e){return{ucpPaymentInstrument:w(this,o,p).call(this,{instruments:e.checkout?.payment?.instruments,hasCredential:!0})}},h=function(e){if(null!=e.upgrade&&null!=e.upgrade.port&&e.upgrade.port instanceof MessagePort)return{upgrade:{port:e.upgrade.port}};const{instruments:t}=e.checkout?.payment??{};return{upgrade:void 0,ucpPaymentInstrument:w(this,o,p).call(this,{instruments:t})}},m=function(e){const t=e.params,n=t?.checkout?.payment?.instruments,s=w(this,o,p).call(this,{instruments:n,hasCredential:!0});return s?{type:"submit",instrument:s}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:R.INVALID_PARAMS,message:"Missing payment instrument with credential"}}}},f=function(e){const t=e.params,n=t?.checkout;if(!n||1!==Object.keys(n).length)return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"ec.update requires exactly one field"}}};const s=Object.keys(n)[0];switch(s){case"fulfillment":{const t=n.fulfillment,s=t?qe(t):void 0;return s?{type:"addressUpdate",address:s}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid delivery address"}}}}case"payment":{const t=n.payment,s=w(this,o,p).call(this,{instruments:t?.instruments});return s?{type:"instrumentUpdate",instrument:s}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid payment instrument"}}}}case"buyer":{const t=function(e){if(null==e||"object"!=typeof e||Array.isArray(e))return;const t=new Set(["email","phone_number"]),n=e;if(Object.keys(n).some(e=>!t.has(e)))return;const s=Object.prototype.hasOwnProperty.call(n,"email"),r=Object.prototype.hasOwnProperty.call(n,"phone_number");return s&&"string"!=typeof n.email||r&&"string"!=typeof n.phone_number||!s&&!r?void 0:{...s?{email:n.email}:{},...r?{phone_number:n.phone_number}:{}}}(n.buyer);return t?{type:"buyerUpdate",buyer:t}:{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: ${s}`}}}}},y=function(){const e=_(this,s).peek();return e&&_e(e,_(this,o,c))},g=function(){if(!_(this,t).enabled)return{};const e=this.shopCash.peek(),n=this.shopDiscountOffer.peek();return{...e?{shop_cash:e}:{},...n?{shop_discount_offer:n}:{}}},fe.version="2026-01-23";let ye=fe;const ge=new Map([["terms-of-service","terms_of_service"],["privacy-policy","privacy_policy"],["refund-policy","refund_policy"],["shipping-policy","shipping_policy"]]);function be({embed:e,ucpPaymentHandlers:t,discountExtensionEnabled:n}){const s={};for(const r of t??[]){const{name:e}=r;e&&(s[e]??=[],s[e].push(r))}return{version:ye.version,transports:{embedded:{schema:"https://ucp.dev/2026-01-23/services/shopping/embedded.json",delegations:Array.from(e.delegations.allowed)}},capabilities:n?{"dev.ucp.shopping.discount":[{version:ye.version,extends:"dev.ucp.shopping.checkout",spec:"https://ucp.dev/2026-01-23/specification/discount",schema:"https://ucp.dev/2026-01-23/schemas/shopping/discount.json"}]}:{},payment_handlers:s}}function ve({checkout:e,violationMessageMap:t}){const{shippingAddress:n,isShippingRequired:s}=e.proposal.negotiated.fields,r=e.latestReceipt.value?.status;if("processed"===r)return"completed";if("processing"===r||"processing_remote_checkouts"===r||"action_required"===r)return"complete_in_progress";if(Array.from(t.entries()).some(([e,t])=>"error"===e.type&&!B.has(t.code)))return"incomplete";const i=Boolean(s?.value),o=Boolean(n?.value);return i&&!o?"incomplete":"ready_for_complete"}function _e(e,{redactPII:t,redactIdKey:n}){const s=t?function(e){const{buyer:t,payment:n,...s}=e;return{...s,...e.fulfillment&&{fulfillment:(i=e.fulfillment,{...i,methods:i.methods.map(e=>{const{destinations:t,selected_destination_id:n,...s}=e;return s})})},...e.order&&{order:(r=e.order,{...r,permalink_url:"about:blank"})}};var r,i}(e):e;return n?{...s,id:de(s.id)}:s}function ke({checkout:e}){const{merchandiseLines:{value:t},deliveryNext:{value:n},shippingAddress:{value:s}}=e.proposal.negotiated.fields;if("filled"!==n?.status||!n.lines)return function(e){const t=e?.lines?.filter(e=>e.requiresShipping)?.map(e=>Re(e))??[];return 0===t.length?[]:[{id:"shipping",type:"shipping",line_item_ids:t,destinations:[],groups:[]}]}(t);const r=n.lines.filter(Se).filter(e=>e.methods.some(e=>
1{return"SHIPPING"===(t=e.methodType)||"LOCAL"===t||"PICK_UP"===t||"PICKUP_POINT"===t;var t})&&e.targetMerchandiseLines?.some(e=>e.requiresShipping));if(!r.length)return[];const i=function(e){const t=new Set;for(const n of e){const e=Ce(n);e&&t.add(e)}return Array.from(t)}(r),o=[];for(const a of i){const e=r.filter(e=>Ce(e)===a),t=e.map(Ie),n=[...new Set(t.flatMap(e=>e.line_item_ids))],i=we(a,e,s);o.push({id:a,type:a,line_item_ids:n,...i&&{destinations:[i]},groups:t})}return o}function Ce(e){const t=e.methods[0];var n;if(t)return"PICK_UP"===(n=t.methodType)||"PICKUP_POINT"===n?"pickup":"shipping"}function we(e,t,n){if("shipping"===e){if(!n)return;return{...xe(s=n),id:`shipping-${s.countryCode}-${s.postalCode}`.replace(/\s+/g,"")}}var s;for(const r of t)if(r.selectedDeliveryMethodHandle){const e=r.methods.find(e=>e.handle===r.selectedDeliveryMethodHandle);if(e)return Ee(e)}}function Ee(e){const t=e.pickupLocation;if(t)return{id:e.handle,name:t.name??"",address:xe(t.address)}}function Ie(e){return{id:e.id??"",line_item_ids:Ae(e),options:e.methods.map(Pe),...e.selectedDeliveryMethodHandle&&{selected_option_id:e.selectedDeliveryMethodHandle}}}function Pe(e){return{id:e.handle,title:e.title,...e.description&&{description:e.description},...e.carrierName&&{carrier:e.carrierName},...e.minDeliveryDateTime&&{earliest_fulfillment_time:e.minDeliveryDateTime},...e.maxDeliveryDateTime&&{latest_fulfillment_time:e.maxDeliveryDateTime},totals:[{type:"fulfillment",amount:Ne(e.costAfterDiscounts)}]}}function Re(e){return e.id??`gid://shopify/CartLine/${e.variantId}`}function Se(e){return"available"===e.status}function Ae(e){return e.targetMerchandiseLines?.filter(e=>e.requiresShipping).map(e=>Re(e))??[]}function xe(e){return{first_name:e.firstName,last_name:e.lastName,phone_number:e.phone,street_address:e.address1,extended_address:e.address2,address_locality:e.city,address_region:e.zoneCode,address_country:e.countryCode,postal_code:e.postalCode}}function je({checkout:e,embed:t}){const n=e.latestReceipt.value;if("processed"===n?.status)return{id:"microsoft"===t.embedder?n.orderIdentity.id:S("Order",A(n.orderIdentity.id)),permalink_url:n.confirmationPage.url}}function qe(e){if(Array.isArray(e.methods))for(const t of e.methods){if(!t||"object"!=typeof t)continue;const{type:e,destinations:n,selected_destination_id:s}=t;if("shipping"!==e||!Array.isArray(n))continue;const r="string"==typeof s?s:null;if(r){const e=n.find(e=>De(e)&&"string"==typeof e.id&&e.id===r);if(e&&De(e))return e}for(const t of n){if(!De(t))continue;const e="string"==typeof t.id?t.id:void 0;if(null==r||e&&r===e||1===n.length)return t}}}function De(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.street_address||"string"==typeof t.address_locality||"string"==typeof t.address_region||"string"==typeof t.address_country||"string"==typeof t.postal_code||"string"==typeof t.first_name||"string"==typeof t.last_name}const Te=new Map(L);function Me(e,t,n){return!(!t||e&&(n.shouldSuppressReceiptWalletAsExpressCheckout()||ie(e)&&"gpay"===e.handler_id&&"google_pay"===t))}const Oe={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"};const Le=new Map;function Ne(e){if(!e)return 0;let t=Le.get(e.currencyCode);t||(t=new Intl.NumberFormat("en",{style:"decimal",currency:e.currencyCode,useGrouping:!1}),Le.set(e.currencyCode,t));const n=I(e.currencyCode),[s,r=""]=t.format(e.amount).split(".");return Number(s+r.padEnd(n,"0"))}class Ue extends he{constructor(e){super(e),this.version="2026-01-23",this.#e=new V,this.#t=!1,this.#n=!1,this.#s=null,this.#r=!1,this.#i=new $({observability:e.observability}),this.#o=new le({observability:e.observability}),this.#a=new ye(e,this.#o.targetType),this.#c=new K([new G({context:this.context,mapper:this.#a,transport:this.#o,resizeObserver:this.#i,incomingRequests:{submitShopPay:e=>this.#e.submitShopPay(e),applyRedemption:e=>this.#e.applyRedemption(e)},waitForPendingNegotiations:()=>this.waitForPendingNegotiations(),waitForSkeletonRemoved:()=>this.waitForSkeletonRemoved()})]),this.#o.onRequest(e=>this.#u(e)),this.observability.bridgeInitialized()}get embedderHostname(){const e=this.#o.embedderOrigin;if(e)try{return new URL(e).hostname}catch{return}}#o;#a;#e;#t;#n;#s;#p;#d;#l;#h;#r;#i;#c;unstable_providePreactContext(e){super.unstable_providePreactContext(e),this.#e.initialize({...this.context,...e,addPaymentError:e=>this.addPaymentError(e),removePaymentError:e=>this.removePaymentError(e)}).catch(e=>{this.observability.enqueuedApplyPaymentInstrumentError(e)});const t=this.context.checkout.proposal.negotiated.fields.ucp;t.value={...t.peek()}}async ready(){if(this.#o.isLoopback){if(this.context.environment.debug.logging&&this.context.client.initialRequest.url.searchParams.has("skip_ec_ready"))return void this.observability.skipEcReady();if(!(await this.#m()))return}this.#f();let e=this.#a.mapEvent({type:"checkout.ready"});if(!e)return;const t=await this.#o.request(e,{timeoutMs:1e4});let n=this.#a.mapResponse(e.method,t);if(n?.upgrade?.port instanceof MessagePort){if(this.observability.readyMessagePortUpgrade(),this.#o.upgrade(n.upgrade.port),e=this.#a.mapEvent({type:"checkout.ready"}),!e)return;const t=await this.#o.request(e,{timeoutMs:1e4});n=this.#a.mapResponse(e.method,t)}const s=n?.ucpPaymentInstrument;s&&(this.observability.readyPaymentInstrument(),await this.#e.applyInstrument(s)),J(n)&&(this.observability.readyCartUpdate(Object.keys(n.cart).join(",")),this.applyCart(n.cart))}async start(){const e=this.#a.mapEvent({type:"checkout.start"});e&&(this.#o.notify(e),this.#y(),this.#c.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.#m()&&(this.#f(),this.#y(),this.#g())}
1async complete(){if(this.#b()){const e=new te;return void this.observability.unauthenticatedIframe(e.message)}if(this.#t)return void this.observability.completedEventSkipped();if(this.#t=!0,this.observability.checkoutCompleted(),this.#s){const e=this.#a.buildSubmitResponse(this.#s);return this.#s=null,void(e&&(this.observability.submitResponseSent(e.id),this.#o.send(e)))}const e=this.#a.mapEvent({type:"checkout.complete"});e&&(this.observability.completedEventEmitted(),this.#o.notify(e))}error(e){const t=this.#a.mapEvent({type:"checkout.error",code:e.code,message:e.message,severity:e.severity,path:e.path});t&&this.#o.notify(t)}async addressChangeStart(e){const t=this.#a.mapEvent({type:"checkout.addressChangeStart",addressType:e});if(!t)return;const n=await this.#o.request(t);return this.#a.mapResponse(t.method,n)}async paymentMethodChangeStart(){this.removePaymentError(x.PaymentDelegationError);try{const e=this.#a.mapEvent({type:"checkout.paymentMethodChangeStart"});if(!e)return;const t=await this.#o.request(e),n=this.#a.mapResponse(e.method,t);return n?.ucpPaymentInstrument&&await this.#e.applyInstrument(n.ucpPaymentInstrument),n}catch(e){return this.#v(e,"payment.instruments_change")}}async submitStart(){this.removePaymentError(x.PaymentDelegationError);try{await this.waitForPendingNegotiations();const e=this.#a.mapEvent({type:"checkout.submitStart"});if(!e)return;const t=await this.#o.request(e,{timeoutMs:me(this.context.embed.embedder)}),n=this.#a.mapResponse(e.method,t);return n?.ucpPaymentInstrument&&await this.#e.submit(n.ucpPaymentInstrument),n}catch(e){return this.#v(e,"payment.credential")}}async windowOpenRequest(e){const t=this.#a.mapEvent({type:"checkout.windowOpen",url:e});if(t)try{await this.#o.request(t)}catch(n){if(n instanceof j&&n.errorCode===q.WINDOW_OPEN_REJECTED)return void this.observability.windowOpenRejected(e,n.errorMessage);this.observability.windowOpenError(e,n)}}beforeunload(){this.#c.beforeunload()}dialogChange(e){this.#c.dialogChange(e)}showToast(e){return this.#c.showToast(e)}async requestShopPaySessionRevalidation(){return await this.#c.requestShopPaySessionRevalidation()??!0}shopPaySessionRevalidationChange(e){this.#c.shopPaySessionRevalidationChange(e)}cleanup(){this.#c.cleanup(),this.#o.cleanup(),this.#e.cleanup(),this.#p?.(),this.#d?.(),this.#r=!0}#v(e,t){if(!(e instanceof j&&e.isUserCancelledError))return e instanceof D?(this.observability.paymentDelegationTimeout(t,e.message),void this.addPaymentError(x.PaymentDelegationError)):e instanceof j&&e.isInternalError?(this.observability.paymentDelegationError(t,e.message),void this.addPaymentError(x.PaymentDelegationError)):void this.observability.paymentDelegationUnexpectedError(t,e instanceof Error?e.message:String(e));this.observability.paymentDelegationCancelled()}async#u(e){const{embed:t}=this.context;try{const n=this.#a.parseIncomingRequest(e);if("errorResponse"in n)return this.observability.incomingRequestValidationFailed(e.id),void this.#o.send(n.errorResponse);if(await this.#c.handleIncomingRequest(n,{requestId:e.id,markSubmitPending:()=>{this.#s=e.id},onSubmitAttempt:()=>{},sendAckResponse:()=>{this.#o.send({jsonrpc:"2.0",id:e.id,result:{}})}}))return;if("submit"!==n.type&&!this.#c.canHandleIncomingRequest(n.type))throw new ne(t.embedder);switch(n.type){case"submit":this.#s=e.id,await this.#e.submit(n.instrument);break;case"addressUpdate":await this.#e.applyAddress(n.address),this.#o.send({jsonrpc:"2.0",id:e.id,result:{}});break;case"buyerUpdate":await this.#e.applyBuyer(n.buyer),this.#o.send({jsonrpc:"2.0",id:e.id,result:{}});break;case"instrumentUpdate":await this.#e.applyInstrument(n.instrument),this.#o.send({jsonrpc:"2.0",id:e.id,result:{}})}}catch(n){this.#s=null,this.observability.incomingRequestError(e.id,n);try{this.#o.send(this.#a.buildErrorResponse(e.id,n))}catch{}}}#y(){let e;this.#d=P(()=>{const t=this.#a.ucpCheckout.value;if(!e)return e=t,void(this.#h=t?.totals);if(t){if(!function(e,t){return e===t||e.length===t.length&&e.every((e,n)=>{const s=t[n];return e.id===s.id&&e.quantity===s.quantity&&e.parent_id===s.parent_id&&e.item.id===s.item.id&&e.item.title===s.item.title&&e.item.image_url===s.item.image_url})}(e.line_items,t.line_items)){const e=this.#a.mapEvent({type:"checkout.lineItemsChange"});e&&this.#o.notify(e)}if(!T(e.buyer,t.buyer)){const e=this.#a.mapEvent({type:"checkout.buyerChange"});e&&this.#o.notify(e)}if(!T(e.fulfillment,t.fulfillment)){const e=this.#a.mapEvent({type:"checkout.fulfillmentChange"});e&&this.#o.notify(e)}if(!function(e,t){if(e===t)return!0;
1if(!e||!t)return!1;const n=e.instruments??[],s=t.instruments??[];return n.length===s.length&&n.every((e,t)=>{const n=s[t],r=Object.keys(e).filter(e=>"credential"!==e),i=Object.keys(n).filter(e=>"credential"!==e);return r.length===i.length&&r.every(t=>{if(!(t in n))return!1;const s=e[t],r=n[t];return s===r||"object"==typeof s&&"object"==typeof r&&T(s,r)})})}(e.payment,t.payment)){const e=this.#a.mapEvent({type:"checkout.paymentChange"});e&&this.#o.notify(e)}if(this.#c.checkoutChange(e,t),!T(e.messages,t.messages)){const e=this.context.checkout.proposal.negotiated.fields.allViolations.value??[],t=Boolean(this.context.negotiationContext?.delegatedPaymentInstrument?.peek());if(e.some(e=>X.has(e.code)||t&&Z.has(e.code))){const e=this.#a.mapEvent({type:"checkout.messagesChange"});e&&this.#o.notify(e)}}T(e.totals,t.totals)||this.#_(),"ready_for_complete"!==t.status||this.#n||(this.#n=!0,this.observability.readyForComplete()),e=t}})}#_(){this.#l||(this.#l=this.#k())}async#k(){try{await this.waitForPendingNegotiations()}finally{this.#l=void 0}if(this.#r)return;const e=this.#a.ucpCheckout.peek()?.totals;if(e&&!T(this.#h,e)){this.#h=e;const t=this.#a.mapEvent({type:"checkout.totalsChange"});t&&this.#o.notify(t)}}#g(){if("processed"===this.context.checkout.latestReceipt.peek()?.status)return this.complete(),void this.cleanup();let e=!0;this.#p=P(()=>{const t=this.context.checkout.latestReceipt.value;if(e)e=!1;else if("failed"===t?.status&&"payment"===t.failure.type){const e="code"in t.failure?String(t.failure.code).toLowerCase():"unknown";this.error({code:"PAYMENT_ERROR",message:e,severity:"recoverable",path:"$.payment",timestamp:Date.now()})}if("failed"===t?.status){const e="code"in t.failure?t.failure.code:"unknown";this.observability.receiptError(t.failure.type,e)}if("failed"===t?.status&&this.#s){const e=this.#s;return this.#s=null,this.observability.submitReceiptFailed(e,t.failure.type),void this.#o.send(this.#a.buildErrorResponse(e,new re(t.failure.type)))}t&&"processed"===t.status&&(this.complete(),this.cleanup())})}async#m(){if(!this.#o.isLoopback)return!0;const e=await this.#o.waitForTarget();if(this.#o.isDisposed)return!1;if("loopback"===e){const e=new se("No embedder transport detected. Checkout was loaded in embedded mode but no parent frame or native bridge was found.");throw this.observability.noTransportDetected(e.message,this.#o.environmentSnapshot),e}return!0}#f(){if(!this.#b())return;const e=new te;throw this.observability.unauthenticatedIframe(e.message),e}#b(){return this.#o.isIframe&&!this.context.embed.isAuthenticated}}export{Ue as Ucp2026_01_23Client};
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.