PageSourceSearch

https://piccalio.com/cdn/shopifycloud/checkout-web/assets/c1/MobileCheckoutSdkProvider.Ifr2RJYV.js

js piccalio.com collected 2026-09-25 23:45:25 UTC 10,023 bytes, 1 lines download raw bytes

1import{T as h,q as H,u as p,h as P}from"./esnext-vendor.B9Da21W6.js";import{cA as R,Q as U,S as k,aq as B,cB as I}from"./addresses-is-address-empty.Bn2lNY_L.js";import{p as N,M as O,P as q}from"./utils-useViolationsHandler.BE3Ij9oJ.js";import{cI as A,cJ as F}from"./hydrate.DZ4YTm7p.js";import{c as x,a as V,m as Y,b as D,g as v,d as _,e as f,f as C,u as M,h as W,i as j,j as z,k as G,C as J,l as g,n as L,o as Q}from"./utils-checkoutProtocolLinkInterceptor.ClHzy100.js";import{i as X}from"./graphql-PaymentSessionMutation.CAXCwUvV.js";import"./app.DbSrjjlA.js";import"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import"./hooks-useReplaceShopPayInHistory.DPpLejwu.js";import"./shared-receipt-merchandise-lines.DEXSlNem.js";const b=50;class Z{constructor(t){this.customEventNamespace="MobileCheckoutSdk",this.#e=new Map,this.#n=new Map,this.#t=t}#t;#e;#n;postMessageToConsumer(t){return R(this.#t,t)}addEventListener(t,n){window.addEventListener(`${this.customEventNamespace}.${t}`,n,!1);let o=this.#e.get(t);o==null&&(o=new Set,this.#e.set(t,o)),o.add(n);const i=this.#n.get(t);if(i?.length){this.#n.delete(t),this.#t.log("mobile_checkout_sdk_client_message_replayed",`Replaying ${i.length} buffered '${t}' message(s) on first listener attach.`,{messageKey:t,queueDepth:i.length});for(const s of i)window.dispatchEvent(new CustomEvent(`${this.customEventNamespace}.${t}`,s))}}removeEventListener(t,n){window.removeEventListener(`${this.customEventNamespace}.${t}`,n);const o=this.#e.get(t);o!=null&&(o.delete(n),o.size===0&&this.#e.delete(t))}postMessage(t,n){const o=`${this.customEventNamespace}.${t}`;if((this.#e.get(t)?.size??0)===0){const s=this.#n.get(t)??[];s.length>=b&&(s.shift(),this.#t.log("mobile_checkout_sdk_client_message_buffer_overflow",`Inbound message buffer for '${t}' exceeded ${b} entries; dropping oldest.`,{messageKey:t,cap:b})),s.push(n),this.#n.set(t,s),this.#t.log("mobile_checkout_sdk_client_message_buffered",`Buffered '${t}' message — no listener attached yet.`,{messageKey:t,queueDepth:s.length});return}window.dispatchEvent(new CustomEvent(o,n))}dispatchMessage(t,n){this.postMessage(t,n)}}function T(){return U(A)}const K=({children:e,version:t,mapDefaults:n,eventListenersHook:o,eventMessageMapper:i})=>{const{client:s}=T(),c=o(),{observability:a}=k(),l=h(()=>{const d=r=>{if(s){const m=i(r);m?(a.log("mobile_checkout_sdk_message_posted","MobileCheckoutSdkVersionedSchemaContext - sending post message to client",{handlerId:m.handlerId,post_message_body:m.body}),N(s,m)):a.log("mobile_checkout_sdk_message_posted",`MobileCheckoutSdkVersionedSchemaContext - failed to map event ${r.type}`,{event:r})}};return{schema:{version:t,eventMessageMapper:i,eventListeners:c,defaultsMapper:r=>n(r,d),postMessageHandler:d}}},[c,t,i,s,n,a]);return e(l)};function ee(e){if(!(!e||e.lines.length===0))return e.lines.reduce((t,n)=>{if(!X(n))return t;const o=n.amount;return o?{amount:t.amount+o.amount,currencyCode:o.currencyCode}:t},{amount:0,currencyCode:""})}function te({total:e,subtotal:t,taxes:n,discountLines:o,shipping:i}){return{total:e,subtotal:t,taxes:V(n),discounts:ee(o),shipping:x(i)}}function ne(e){return{image:e.image?Y(e.image):void 0,quantity:e.quantity,title:e.title,price:e.totalPrice,merchandiseId:e.variantId,productId:e.productId}}function oe({flowType:e,negotiated:t,receipt:n}){const o=E(t,n),{confirmationPage:i,purchaseOrder:{email:s,phone:c,shippingAddress:a,billingAddress:l,paymentLines:d},orderIdentity:{id:u}}=n,r=i.url;return{flowType:e,confirmationURL:r,orderDetails:{id:u,cart:o,email:s,phone:c,shippingAddress:a,billingAddress:l,paymentMethods:_(d),deliveries:D(v(t,n).delivery,a)},thankYouPageUrl:r,orderId:u,cart:o}}function E(e,t){const n=v(e,t);return{lines:n.merchandiseLines?.lines?.map(ne)??[],price:te({total:n.total,subtotal:n.subtotal,taxes:n.taxes,discountLines:n.discountLines,shipping:n.delivery})}}function ie(e){return{orderId:e.orderIdentity.id,thankYouPageUrl:e.confirmationPage.url}}function se(e){return{handlerId:"completed",body:{flowType:e.flowType,cart:E(e.negotiated,e.receipt),...ie(e.receipt)}}}function re(e){switch(e.type){case"completed":return se(e);case"checkoutBlockingEvent":return f(e)}}function ae(){return{}}function ce({flowType:e,negotiated:t,receipt:n}){const o=E(t,n),{confirmationPage:i,purchaseOrder:{email:s,shippingAddress:c,billingAddress:a,paymentLines:l},orderIdentity:{id:d}}=n,u=i.url;
1return{flowType:e,confirmationURL:u,orderDetails:{id:d,cart:o,email:s||"",shippingAddress:c,billingAddress:a,paymentMethods:_(l)},thankYouPageUrl:u,orderId:d,cart:o}}function de(e){return{handlerId:"completed",body:{...ce(e)}}}function ue(e){switch(e.type){case"completed":return de(e);case"checkoutBlockingEvent":return f(e)}}function le(){return{}}function pe(){const e=window.navigator.userAgent;return/iPhone|iOS/i.test(e)?"ios":/iPad/i.test(e)?"ipad":/Android/i.test(e)?"android":"unknown"}function he(e){const t={preloading:"false"};if(e&&typeof e=="object"&&!(e instanceof Map)){const n=e;"preloading"in n&&typeof n.preloading=="string"&&(t.preloading=n.preloading)}return t}function S(){const{observability:e,mobileCheckoutSdk:t}=k(),{config:n}=t,o=H(i=>{const s=pe(),c={...he(i.detail.tags),os_platform:s,checkoutVariant:n.variant??"",schemaVersion:n.schema??"",sdkVersion:n.version??""};i.detail?.type==="histogram"&&i.detail?.name==="checkout_finished_loading"&&!isNaN(i.detail?.value)?e.histogram({name:"csk_finished_loading",value:i.detail.value,attributes:c}):e.log("checkout_sheet_kit_invalid_instrumentation_event_received",'An "instrumentation" event was sent to checkout with invalid data.',{event:i,os_platform:s,config:n})},[e,n]);return h(()=>({messageKey:"instrumentation",handler:o}),[o])}function me(){const e=M(),t=S();return h(()=>({instrumentation:t,presented:e}),[t,e])}function ge(e){return{handlerId:"completed",body:{...oe(e)}}}function fe(e){switch(e.type){case"completed":return ge(e);case"checkoutBlockingEvent":return f(e);case"webPixels":return C(e)}}function ke({total:e,subtotal:t,taxes:n,discountLines:o,shipping:i}){return{total:e,subtotal:t,taxes:V(n),discounts:be(o),shipping:x(i)}}function be(e){if(e)return e.lines.reduce((t,n)=>{const o=n,i=o.amount;return!o||!i||t.push(ve(o.discount,i)),t},[])}function ve(e,t){const n=e.value;let o,i;switch(n?.typename){case"PercentageValue":{o="percentage",i=n.percentage;break}case"FixedAmountValue":{o="fixedAmount",i=n.fixedAmount.amount;break}default:o=void 0,i=void 0}return{title:e.title,amount:t,valueType:o,value:i,applicationType:e.type}}function _e({flowType:e,cartToken:t,negotiated:n,receipt:o}){const{confirmationPage:i,purchaseOrder:{email:s,phone:c,shippingAddress:a,billingAddress:l,paymentLines:d},orderIdentity:{id:u}}=o,r=v(n,o),m=ke({total:r.total,subtotal:r.subtotal,taxes:r.taxes,discountLines:r.discountLines,shipping:r.delivery}),w=W(t,r.merchandiseLines,m),y=i.url;return{flowType:e,confirmationURL:y,orderDetails:{id:u,cart:w,email:s,phone:c,shippingAddress:a,billingAddress:l,paymentMethods:_(d),deliveries:D(r.delivery,a)},thankYouPageUrl:y,orderId:u,cart:w}}function $(e){return{handlerId:"completed",body:{..._e(e)}}}function Ce(e){switch(e.type){case"completed":return $(e);case"checkoutBlockingEvent":return f(e);case"webPixels":return C(e)}}function Me(){const e=M(),t=S();return h(()=>({instrumentation:t,presented:e}),[t,e])}function Ee(e){switch(e.type){case"completed":return $(e);case"checkoutBlockingEvent":return f(e);case"webPixels":return C(e);case"expired":return G(e);case"configuration":return z(e);case"unrecoverable":return j(e)}}function Se(){const e=M(),t=S();return h(()=>({instrumentation:t,presented:e}),[t,e])}class we extends Error{constructor(){super(...arguments),this.name="CheckoutSdkSchemaVersionError"}}const ye={"5.1":{mapDefaults:g,eventListenersHook:ae,eventMessageMapper:re},"5.3":{mapDefaults:g,eventListenersHook:le,eventMessageMapper:ue},"7.0":{mapDefaults:g,eventListenersHook:me,eventMessageMapper:fe},"8.0":{mapDefaults:g,eventListenersHook:Me,eventMessageMapper:Ce},"8.1":{mapDefaults:g,eventListenersHook:Se,eventMessageMapper:Ee}},Pe=({children:e})=>{const{schemaVersion:t}=T(),{observability:n}=k(),o=Ie(t,n);return p(Le,{version:o,children:i=>p(O.Provider,{value:i,children:[p(J,{}),e]})})};function Ie(e,t){return e&&B.has(e)?e:(t?.error(new we(`Invalid checkout SDK schema version requested: ${e}. Using latest schema version: ${I}`)),I)}const Le=({children:e,version:t})=>{const{mapDefaults:n,eventListenersHook:o,eventMessageMapper:i}=ye[t];return p(K,{version:t,mapDefaults:n,eventListenersHook:o,eventMessageMapper:i,children:e})},Ne=({children:e})=>{const{observability:t,mobileCheckoutSdk:n}=k(),o=h(()=>new Z(t),[t]),i=F();P(()=>{n.enabled&&n.config.variant&&t?.addErrorMetadata("mobileCheckoutSdk",{variant:n.config.variant,version:n.config.version,schemaVersion:n.config.schema})},[t,n]),P(()=>{if(n.variant.recovery){t.log("mobile_checkout_sdk_recovery_bridge_setup_skipped","MobileCheckoutSdkProvider - recovery mode, skipping setup");return}return n.enabled&&!window.MobileCheckoutSdk&&(t.log("mobile_checkout_sdk_provider_bridge_set","MobileCheckoutSdkProvider - setting window.MobileCheckoutSdk and emitting ready event"),window.MobileCheckoutSdk=o,window.dispatchEvent(new Event("mobileCheckoutBridgeReady")),window.addEventListener("click",L)),()=>{t.log("mobile_checkout_sdk_provider_bridge_deleted","MobileCheckoutSdkProvider - deleting window.MobileCheckoutSdk"),delete window.MobileCheckoutSdk,window.removeEventListener("click",L)}},[o,n,t]),n.config.type="MERCHANT",n.config.pixelEventsMode=n.config.variant==="STANDARD_RECOVERY"?"DISABLED":"FORWARD_TO_CLIENT";const s=h(()=>({client:n.enabled?o:null,schemaVersion:n.config.schema||void 0,config:n.config}),[n,o]);return t.log("mobile_checkout_sdk_provider_context_value_computed","MobileCheckoutSdkProvider - computed context value",s),Q(n.enabled,i),p(A.Provider,{value:s,children:p(q,{children:n.enabled&&!n.variant.recovery?p(Pe,{children:e}):e})})};export{Ne as MobileCheckoutSdkProvider};

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.