import{Xt as e}from"./630ba094.L_X-5TXi.js";import{JD as t,_h as o,gh as n,jh as c,vh as r,xO as a}from"./6ec9a0fa.rdcQt2v8.js";var i=new Map([[6167201,"hydrogen"],[12875497473,"headless"],[88312,"buy_button"],[1354745,"draft_order"]]);function s(e,t,o){const n=new Set([129785,6517121,757165]),r=new Set([3890849,3850711,5198245]);return i.has(e)?i.get(e):n.has(e)?"retail":r.has(e)?"shop_app":t===c.CartPermalink?"permalink":580111===e?"online_store":o}function u({eventName:c,checkoutType:i,walletName:u,progressionStepName:d,redirectSource:p,trackingUnique:k,trackingVisit:y}){const{client:h,checkout:m,consentManager:g,i18n:v,observability:_,userEvents:f,shop:I,source:N}=a(),{id:b}=I,w=m.negotiator.current.fields.buyerIdentity.value?.customerProfile,T=o(c),S=r()?.config?.type,P=parseInt(t(b),10),A=h.unstable_getSerialization("apiClientId")??0,C=k??(h.cookies.get("_shopify_y")||void 0),O=y??(h.cookies.get("_shopify_s")||void 0);return e(()=>{const e=g.analyticsProcessingAllowed.value,o=g.marketingAllowed.value,r=Boolean(e||o),a={eventName:c,buyerConsentAnalyticsAllowed:e,buyerConsentMarketingAllowed:o,progressionStepName:d,userToken:C,walletName:u};if(!("checkout_started"===c&&"ShopifyPay"===u||r)||!T)return _.counter({name:"checkout_lifecycle_events_blocked_by_privacy",value:1,attributes:{eventName:c,application:"checkout-web"}}),void _.log("checkout_lifecycle_events_not_emitting_event","checkout_lifecycle_events.not_emitting_event",{logPayload:a});const k="contact_information"===d?1:void 0,y=l(N.type),h=y?N.sourceId:void 0,I=m.configuration.profileId.value,b=function({eventName:e,walletName:t,shopId:o,checkoutSessionIdentifier:c="default",checkoutProfileId:r,trackingVisitToken:a,userToken:i,sourceId:u,sourceType:l,customerId:d,apiClientId:p=0,checkoutType:k,currency:y,locale:h,progressionStepName:m,progressionStepNumber:g,redirectSource:v,checkoutProtocolType:_,consentManager:f}){const I=n(),N="MERCHANT"===_?{apiName:"mobile_checkout_sdk_merchant",checkoutType:s(p,v,"api")}:{};return{schemaId:"checkout_lifecycle_events/7.7",payload:{checkoutChainToken:c||"default",checkoutProfileId:r,eventName:e,checkoutType:s(p,v),checkoutExperience:t?"wallet":"web",entryPoint:"checkout",checkoutPlatform:"checkout_one",checkoutVersion:[k],walletName:t,apiClientId:p||0,currency:y||I?.currency,shopId:o,customerId:d,sourceId:u,sourceType:l,userToken:i||I?.uniqToken,deprecatedVisitToken:a||I?.visitToken,referrer:I?.referer,userAgent:navigator.userAgent,contentLanguage:h,eventTime:(new Date).toISOString(),progressionStepName:m,progressionStepNumber:g,buyerConsentAnalyticsAllowed:f.analyticsProcessingAllowed.value,buyerConsentSaleOfDataAllowed:f.saleOfDataAllowed.value,buyerConsentMarketingAllowed:f.marketingAllowed.value,...N}}}({eventName:c,walletName:u,shopId:P,checkoutSessionIdentifier:N.checkoutSessionIdentifier,checkoutProfileId:I?parseInt(t(I),10):void 0,trackingVisitToken:O,userToken:C,sourceId:h,sourceType:y,customerId:w?.id?parseInt(t(w.id),10):void 0,apiClientId:A,checkoutType:i,currency:v.currency,locale:v.locale,progressionStepName:d,progressionStepNumber:k,redirectSource:p,checkoutProtocolType:S,consentManager:g}),x=b.payload.entryPoint;_.log("checkout_lifecycle_events_emitting_event","checkout_lifecycle_events.emitting_event",{...a,progressionStepNumber:k,"context.sourceType":N.type,"context.sourceId":N.sourceId,checkoutType:i,entryPoint:x}),f.monorailEvent(b),_.counter({name:"checkout_lifecycle_events_emitted",value:1,attributes:{application:"checkout-web",eventName:c,checkoutType:N.type,isWallet:u?"true":"false",...u?{walletName:u}:{}}})},[c,d,C,u,P,N,m.configuration.profileId,O,w?.id,A,i,v,p,_,f,T,S,g])}function l(e){const t={orderEdit:"order",paymentCollection:"paymentCollection",cartNext:"cart",abandonedCart:"abandoned_cart",simulated:"simulated",draftOrder:"draft_order",buyItNow:void 0,shopPayExternal:void 0,other:void 0};return Object.keys(t).includes(e)?t[e]:void 0}function d(e){return u({eventName:"checkout_progression",checkoutType:a().checkout.configuration.layout.isOnePage.value?"one_page":"three_page",walletName:e,progressionStepName:"contact_information"})}function p(e,t,o,n){return u({eventName:"checkout_started",checkoutType:a().checkout.configuration.layout.isOnePage.value?"one_page":"three_page",walletName:e,redirectSource:t,trackingUnique:o,trackingVisit:n})}export{s as i,d as n,p as r,l as t};