1import{v as e,dJ as t,dK as o,dL as r,dM as i,dN as a,dO as n,c as s,bn as c,n as u,dP as d,aP as l,dQ as m,b$ as h,dR as p,dS as f,dT as y}from"./4b4bc88f.C6QXxWcp.js";import{g as v,T as k,q as b}from"./2c1ab0fe.Bf8FS-kA.js";import{eO as C,w as g,k as S,eP as A,eQ as I,eR as E,eS as T}from"./164ad2e3.BPEX42uv.js";import{u as D}from"./fe885b80.CdgyPrIB.js";import"./app.YmvH25zM.js";import"./d0bb51ec.3dWJ276v.js";import"./f67abd2c.DVYhtaBv.js";import"./60a453ce.Boic_DNC.js";import"./e12db40c.2vh-yzuN.js";import"./9dba8418.bYtorePf.js";var P=(e=>(e.StartedOrder="Started Order",e.StartedOrderRemote="Started Order Remote",e.StartedOrderOncePerCheckout="Started Order Once Per Checkout",e.StartedOrderOncePerCheckoutRemote="Started Order Once Per Checkout Remote",e.CompletedOrder="Completed Order",e.AddedPayment="Added Payment",e.AddedPaymentRemote="Added Payment Remote",e.CheckoutContactPageStarted="Checkout Contact Step Started",e.CheckoutContactInfoSubmitted="Checkout Contact Info Submitted",e.CheckoutContactInfoSubmittedRemote="Checkout Contact Info Submitted Remote",e.CheckoutAddressInfoSubmitted="Checkout Address Info Submitted",e.CheckoutAddressInfoSubmittedRemote="Checkout Address Info Submitted Remote",e.CheckoutShippingPageStarted="Checkout Shipping Step Started",e.CheckoutShippingInfoSubmitted="Checkout Shipping Info Submitted",e.CheckoutShippingInfoSubmittedRemote="Checkout Shipping Info Submitted Remote",e.CheckoutPaymentPageStarted="Checkout Payment Step Started",e.CheckoutOnePageView="Checkout One Page View",e))(P||{});const R="checkout",w=[t,o,r,i,a,n];class M extends Error{constructor(){super(...arguments),this.name="TrekkieError"}}class _{constructor({shop:t,checkoutToken:o="",locale:r,analyticsConfig:a,sourceUrl:n,themeId:s,themeCityHash:c,userEvents:u,s2s:d,monorailRegion:l,getCookie:m},h){if(this.libraryLoaded=!1,this.trekkieLoadedCallback=h,this.analyticsWindow=window,this.tricorder=this.analyticsWindow.ShopifyAnalytics?.lib||this.analyticsWindow.trekkie||[],this.tricorder?.integrations)return this.libraryLoaded=!0,void this.trekkieLoadedCallback(this.analyticsWindow?.ShopifyAnalytics?.lib?.trekkie);const p=parseInt(e(t.id),10),f=w.filter(e=>t.hasFlagEnabled(e)),y=f.includes(i);this.tricorder.ready(()=>{this.libraryLoaded||(this.libraryLoaded=!0,this.shopifyAnalytics={...this.shopifyAnalytics,lib:this.tricorder},this.trekkieLoadedCallback(this.tricorder?.trekkie))}),this.tricorder.load=e=>{if(this.tricorder.config=e,!y){const{assetPath:e,sriHash:o}=t.trekkieLoadConfiguration,r=e&&o,i=document.getElementsByTagName("script")[0],a=document.createElement("script");a.type="text/javascript",a.onerror=function(){const e=document.createElement("script");e.type="text/javascript",e.onerror=function(){const e={schemaId:"trekkie_checkout_load_errors/1.1",payload:{appName:R,shopId:p,themeId:s,contextUrl:window.location.href,sourceUrl:n}};u.monorailEvent(e)},e.async=!0,e.src=n,r&&(e.setAttribute("integrity",o),e.setAttribute("crossorigin","anonymous")),i?.parentNode?.insertBefore(e,i)},a.async=!0,a.src=n,r&&(a.setAttribute("integrity",o),a.setAttribute("crossorigin","anonymous")),i?.parentNode?.insertBefore(a,i)}};const v={appName:R,development:!1,defaultAttributes:{shopId:p,isMerchantRequest:!!m("_ab")||null,themeId:s,themeCityHash:c,contentLanguage:r,currency:t.currencyCode,checkoutToken:o},isServerSideCookieWritingEnabled:!0,enabledBetaFlags:f};l&&(v.monorailRegion=l),this.tricorder.load({Trekkie:v,...a,"Session Attribution":{},S2S:d})}get tricorder(){return this.analyticsWindow?.trekkie}set tricorder(e){if(!this.analyticsWindow)throw new M("AnalyticsWindow is not set.");this.analyticsWindow.trekkie=e}get shopifyAnalytics(){return this.analyticsWindow.ShopifyAnalytics}set shopifyAnalytics(e){if(!this.analyticsWindow)throw new M("AnalyticsWindow is not set.");this.analyticsWindow.ShopifyAnalytics=e}page(e="",t={},o){this.tricorder?.page(e,t,o)}track(e,t,o,r,i){this.tricorder?.track(e,t,o,r,i)}}function N({remoteTotalDetails:e,remoteMerchandiseLinesByShopId:t,emitRemoteEventForShop:o}
1){if(e)for(const[r,i]of e.perShopRemoteTotals.entries())o(t?{remoteTotals:i,remoteMerchandiseLines:t?.get(r)??[]}:{remoteTotals:i})}function O(e){switch(e){case"/":case"/information":return{title:"Checkout - Contact Information",page:"/checkout/contact_information"};case"/shipping":return{title:"Checkout - Shipping",page:"/checkout/shipping"};case"/payment":return{title:"Checkout - Payment",page:"/checkout/payment"};case"/review":return{title:"Checkout - Review",page:"/checkout/review"};case"/processing":return{title:"Checkout - Processing",page:"/checkout/processing"};case"/thank-you":return{title:"Checkout - Receipt",page:"/checkout/thank_you"};case"/stock-problems":return{title:"Checkout - Stock problems",page:"/checkout/stock_problems"};case"/error":return{title:"Checkout - Error",page:"/checkout/error"};case"/no-address-location":return{title:"Checkout - No Address Location",page:"/checkout/no_address_location"};case"/shoppay_login":return{title:"ShopPay - Login",page:"/shop.app/pay/login"};case"/shoppay":return{title:"ShopPay - Payment",page:"/shop.app/pay/payment"};default:return{title:null,page:null}}}function L(e){const t=e?.map(e=>{const t=e.lineAllocations.reduce((e,t)=>(t.allocations.filter(e=>"code"===e.discountDetails.discount.type).forEach(t=>{t.amount.amount>e.amount&&(e.amount=t.amount.amount,e.code=t.discountDetails.title)}),e),{code:void 0,amount:0});return{variantId:h(e.variantId),productId:h(e.productId),productGid:e.productId,category:e.productType,coupon:t.code,currency:e.itemPrice?.currencyCode,name:e.title,price:e.itemPrice?.amount,quantity:e.quantity,brand:e.vendor,variant:e.subtitle,sku:e.sku}});return t}function W(){const{client:e,observability:t,userEvents:o,environment:r,i18n:{locale:i},shop:a,source:n,checkout:{identity:R,negotiator:w}}=s(),M="shopPay"===R.current.value?"trekkie-checkout-one-shop-app":"trekkie-checkout-one",{data:W}=C(),j=W?.session?.activeCheckoutRolloutTreatments?.flatMap(({rolloutId:e,treatmentId:t})=>{const o=c(e),r=c(t);return void 0!==o&&void 0!==r?[{rolloutId:Number(o),treatmentId:Number(r)}]:[]}),F=u(j),B=n.checkoutSessionIdentifier||n.sourceId;let x=void 0===a.theme?.id||null===a.theme?.id?void 0:parseInt(a.theme.id,10);x&&x>Number.MAX_SAFE_INTEGER&&(x=void 0);const z=a.theme?.cityhash,{email:H,phone:V,shippingAddress:U}=w.parts,q=g(),{value:$}=w.current.fields.deliveryNext,G=e.unstable_getSerialization("apiClientId"),Q=e.unstable_getSerialization("apiClientId"),{currentPage:J}=S().value,K=J&&["onePage"].includes(J.id),X=A(),Y=I(),Z=v(new WeakSet).current,{value:ee}=d(),te=ee,oe=D(),re=k(()=>({}),[]),ie=l(),ae=b(e=>{e?ie.value?.defaultAttributes!==e?.defaultAttributes&&ie.setValue({defaultAttributes:e?.defaultAttributes}):t.error(new m("Trekkie is not available"))},[t,ie]),ne=k(()=>{const t=null===z?void 0:z,n=w.current.fields.buyerIdentity.peek(),s={facebookCapiEnabled:a.facebookCapiEnabled,source:M,customerId:h(n?.customerProfile?.id),cartApiClientId:G,apiClientId:Q},c=`${r.services.trekkie.url}/${a.trekkieLoadConfiguration?.assetPath||"s/trekkie.storefront.min.js"}`;return X?null:new _({shop:a,checkoutToken:B,locale:i,analyticsConfig:re,sourceUrl:c,themeId:x,themeCityHash:t,userEvents:o,monorailRegion:"shop_domain",s2s:s,getCookie:t=>e.cookies.get(t)??null},ae)},[a,B,i,re,x,z,o,e.cookies,ae,w,G,Q,M,X,r.services.trekkie.url]),se=b(e=>{const{title:t,page:o}=O(e);t&&o&&oe.value&&ne?.page(t,{path:o})},[ne,oe]),ce=b(e=>{const{title:t,page:o}=O(e);if(!t||!o||!oe.value)return;const r={name:t,path:o};ne?.track(P.CheckoutOnePageView,r,void 0,void 0,{shopifyEmitted:!0})},[ne,oe]),ue=k(()=>{let e={amount:void 0,currencyCode:void 0};return q.value&&"filled"===$?.status&&$.lines.forEach(t=>{if("available"===t.status){const o=t.selectedDeliveryMethodHandle;if(o){const r=t.methods.filter(e=>e.handle===o&&void 0!==e.costAfterDiscounts);e=r.reduce((e,t)=>{const o=void 0===e.amount?0:e.amount;return e.amount=o+t.costAfterDiscounts.amount,e.currencyCode=t.costAfterDiscounts.currencyCode,e},e)}}}),e},[$,q.value]),de=b(()=>{const e=w.current.fields.merchandiseLines.value,t=w.current.fields.remoteMerchandiseDetails.value;if(oe.value){const o=w.current.fields.subtotal.value,r=w.current.fields.subtotalAfterMerchandiseDiscounts.value,i={step:1,products:L(p(e?.lines??[],t)),currency:o?.currencyCode,revenue:o?.amount,subtotalAfterMerchandiseDiscounts:r?.amount,...F.current?.length?{rolloutIds:F.current.map(e=>Number(e.rolloutId)),rolloutTreatmentIds:F.current.map(e=>Number(e.treatmentId))}:{}};ne?.track(P.StartedOrder,i,void 0,void 0,{shopifyEmitted:!0})}te&&N({remoteTotalDetails:w.current.fields.remoteTotalDetails.value,remoteMerchandiseLinesByShopId:f(e?.lines??[],t),emitRemoteEventForShop:({remoteTotals:e,remoteMerchandiseLines:t})=>{const o={step:1,products:t?L(t):[],currency:e?.subtotal?.currencyCode,revenue:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(P.StartedOrderRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ne,w,te,oe,F]),le=b(()=>{const e=w.current.fields.subtotal.value,t=w.current.fields.subtotalAfterMerchandiseDiscounts.value,o=w.current.fields.remoteTotalDetails.value,r=w.current.fields.merchandiseLines.value,i=w.current.fields.remoteMerchandiseDetails.value,a=p(r?.lines??[],i),n=f(r?.lines??[],i);if(oe.value){const o={step:1,products:L(a),currency:e?.currencyCode,revenue:e?.amount,subtotalAfterMerchandiseDiscounts:t?.amount,...F.current?.length?{rolloutIds:F.current.map(e=>Number(e.rolloutId)),rolloutTreatmentIds:F.current.map(e=>Number(e.treatmentId))}:{}};ne?.track(P.StartedOrderOncePerCheckout,o,void 0,void 0,{shopifyEmitted:!0})}te&&N({remoteTotalDetails:o,remoteMerchandiseLinesByShopId:n,emitRemoteEventForShop:({remoteTotals:e,remoteMerchandiseLines:t})=>{const o={step:1,products:t?L(t):[],currency:e?.subtotal?.currencyCode,revenue:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(P.StartedOrderOncePerCheckoutRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ne,w,te,oe,F]),me=b(()=>{const e=q.value;if(!e)return;if(Y.shouldPrevent())return;if(!oe.value)return;const t=w.current.fields.merchandiseLines.value,o=t?.lines&&L(t?.lines),r=e.purchaseOrder,i=h(e.orderIdentity.id),a=i?.toString(),n=r.billingAddress,s=w.current.fields.buyerIdentity.value,c=s?.customerProfile;let u=c?.firstName,d=c?.lastName;
1d||(u=n?.firstName,d=n?.lastName);const l=w.current.fields.total.value,m=w.current.fields.subtotal.value,p=w.current.fields.subtotalAfterMerchandiseDiscounts.value,f=E(w),y=w.current.fields.contactInfo.value,v=w.current.fields.discountLines.value,k=v?.lines.filter(e=>"code"===e.discount.type).map(e=>e.discount.title)||[],b=e.analytics?.checkoutCompletedEventId||void 0,C=e.analytics?.emitConversionEvent||!1;ne?.track(P.CompletedOrder,{customerEventData:{customer:{firstName:u,lastName:d,emailAddress:c?.email??y?.email,phoneNumber:c?.phone??y?.phone},address:{city:n?.city,province:n?.zoneCode,country:n?.countryCode,zip:n?.postalCode}},orderId:i,orderName:a,products:o,total:l?.amount??0,currency:l?.currencyCode,revenue:m?.amount??0,subtotalAfterMerchandiseDiscounts:p?.amount??0,coupon:k[0],tax:f?.amount??0,shipping:ue.amount??0},b,C,{shopifyEmitted:!0}),Y.markAsEmitted()},[q,w,ne,ue.amount,Y,oe]),he=b(()=>{const e=w.current.fields.runningTotal.value,t=w.current.fields.subtotalAfterMerchandiseDiscounts.value,o=w.current.fields.remoteTotalDetails.value;if(oe.value){const o={currency:e?.currencyCode,total:e?.amount,subtotalAfterMerchandiseDiscounts:t?.amount};ne?.track(P.AddedPayment,o,void 0,void 0,{shopifyEmitted:!0})}te&&N({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:e})=>{const t={currency:e?.runningTotal?.currencyCode,total:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(P.AddedPaymentRemote,t,void 0,void 0,{shopifyEmitted:!0})}})},[ne,w,te,oe]),pe=b(()=>{if(oe.value){const{title:e,page:t}=O("/information"),o={name:e,path:t};ne?.track(P.CheckoutContactPageStarted,o,void 0,void 0,{shopifyEmitted:!0})}},[ne,oe]),fe=b(()=>{const e=H.value,t=V.value,o=w.current.fields.subtotalAfterMerchandiseDiscounts.value,r=w.current.fields.remoteTotalDetails.value;if(oe.value){const r={email:e,phone:t,subtotalAfterMerchandiseDiscounts:o?.amount};ne?.track(P.CheckoutContactInfoSubmitted,r,void 0,void 0,{shopifyEmitted:!0})}te&&N({remoteTotalDetails:r,emitRemoteEventForShop:({remoteTotals:o})=>{const r={email:e,phone:t,subtotalAfterMerchandiseDiscounts:o?.subtotal?.amount};ne?.track(P.CheckoutContactInfoSubmittedRemote,r,void 0,void 0,{shopifyEmitted:!0})}})},[ne,H,V,w,te,oe]),ye=b(()=>{const e=U.value,t=w.current.fields.subtotalAfterMerchandiseDiscounts.value,o=w.current.fields.remoteTotalDetails.value;if(oe.value){const o={city:e?.city,country:e?.countryCode,phone:e?.phone,province:e?.zoneCode,postalCode:e?.postalCode,firstName:e?.firstName,lastName:e?.lastName,address1:e?.address1,address2:e?.address2,subtotalAfterMerchandiseDiscounts:t?.amount};ne?.track(P.CheckoutAddressInfoSubmitted,o,void 0,void 0,{shopifyEmitted:!0})}te&&N({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:t})=>{const o={city:e?.city,country:e?.countryCode,phone:e?.phone,province:e?.zoneCode,postalCode:e?.postalCode,firstName:e?.firstName,lastName:e?.lastName,address1:e?.address1,address2:e?.address2,subtotalAfterMerchandiseDiscounts:t?.subtotal?.amount};ne?.track(P.CheckoutAddressInfoSubmittedRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ne,U,w,te,oe]),ve=b(()=>{if(!oe.value)return;const{title:e,page:t}=O("/shipping"),o={name:e,path:t};ne?.track(P.CheckoutShippingPageStarted,o,void 0,void 0,{shopifyEmitted:!0})},[ne,oe]),ke=b(()=>{const e=w.current.fields.runningTotal.value,t=w.current.fields.subtotalAfterMerchandiseDiscounts.value,o=w.current.fields.remoteTotalDetails.value;if(oe.value){const o={total:e?.amount,currency:e?.currencyCode,subtotalAfterMerchandiseDiscounts:t?.amount};ne?.track(P.CheckoutShippingInfoSubmitted,o,void 0,void 0,{shopifyEmitted:!0})}te&&N({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:e})=>{const t={total:e?.runningTotal?.amount,currency:e?.runningTotal?.currencyCode,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(P.CheckoutShippingInfoSubmittedRemote,t,void 0,void 0,{shopifyEmitted:!0})}})},[ne,w,te,oe]),be=b(()=>{if(!oe.value)return;const{title:e,page:t}=O("/payment"),o={name:e,path:t};ne?.track(P.CheckoutPaymentPageStarted,o,void 0,void 0,{shopifyEmitted:!0})},[ne,oe]);T(b(e=>{ie.value.defaultAttributes&&"page_view"===e.type&&se(e.url)},[ie,se])),T(b(e=>{ie.value.defaultAttributes&&"initiate_checkout"===e.type&&de()},[ie,de])),T(b(e=>{ie.value.defaultAttributes&&"initiate_checkout_once_per_checkout"===e.type&&le()},[ie,le])),T(b(e=>{ie.value.defaultAttributes&&"complete_checkout"===e.type&&me()},[ie,me])),T(b(e=>{ie.value.defaultAttributes&&"add_payment_info"===e.type&&he()},[ie,he]));const Ce=v(!1),ge=v(void 0),Se=y(fe,500),Ae=y(ye,500);return T(b(e=>{ie.value.defaultAttributes&&!Z.has(e)&&(Z.add(e),"one_page_checkout_page_view"===e.type&&(ce(e.url),"/"===e.url&&void 0===ge.current&&(pe(),Ce.current=!0)),"section_interaction"===e.type&&K&&("contact"===e.section?(Ce.current&&void 0===ge.current||pe(),Ce.current=!1):"payment"===e.section&&(ke(),be()),ge.current=e.section),"section_complete"===e.type&&("contact"===e.section?Se():"deliveryAddress"===e.section&&Ae()),"shipping_methods_filled"===e.type&&K&&ve(),"page_submit"!==e.type||"shipping"!==e.page||K||ke())},[ie.value.defaultAttributes,K,pe,Z,ce,ke,be,Se,Ae,ve])),null}export{W as default};
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.