1import{p as e,dH as t,dI as o,dJ as r,dK as i,dL as a,dM as n,a as s,bj as c,j as u,dN as d,aI as l,dO as m,bV as h,dP as p,dQ as f,dR as y}from"./f67abd2c.BTHhdhoM.js";import{g as v,T as k,q as b}from"./2c1ab0fe.RaLGJvq2.js";import{eH as C,v as g,j as S,eI as A,eJ as I,eK as E,eL as D}from"./164ad2e3.bPUx3Fg0.js";import{u as T}from"./fe885b80.i76WZfHf.js";import"./app.CPIYcwpp.js";import"./d0bb51ec.BIqtCEEY.js";import"./60a453ce.BHWO3gHr.js";import"./e12db40c.CeuzD2R-.js";import"./9dba8418.DCzpk36x.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",M=[t,o,r,i,a,n];class _ extends Error{constructor(){super(...arguments),this.name="TrekkieError"}}class w{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=M.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 _("AnalyticsWindow is not set.");this.analyticsWindow.trekkie=e}get shopifyAnalytics(){return this.analyticsWindow.ShopifyAnalytics}set shopifyAnalytics(e){if(!this.analyticsWindow)throw new _("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}){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)=>
1(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 j(){const{client:e,observability:t,userEvents:o,environment:r,i18n:{locale:i},shop:a,source:n,checkout:{identity:R,negotiator:M}}=s(),_="shopPay"===R.current.value?"trekkie-checkout-one-shop-app":"trekkie-checkout-one",{data:j}=C(),W=j?.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(W),x=n.checkoutSessionIdentifier||n.sourceId;let B=void 0===a.theme?.id||null===a.theme?.id?void 0:parseInt(a.theme.id,10);B&&B>Number.MAX_SAFE_INTEGER&&(B=void 0);const H=a.theme?.cityhash,{email:z,phone:V,shippingAddress:U}=M.parts,q=g(),{value:G}=M.current.fields.deliveryNext,J=e.unstable_getSerialization("apiClientId"),K=e.unstable_getSerialization("apiClientId"),{currentPage:$}=S().value,Q=$&&["onePage"].includes($.id),X=A(),Y=I(),Z=v(new WeakSet).current,{value:ee}=d(),te=ee,oe=T(),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===H?void 0:H,n=M.current.fields.buyerIdentity.peek(),s={facebookCapiEnabled:a.facebookCapiEnabled,source:_,customerId:h(n?.customerProfile?.id),cartApiClientId:J,apiClientId:K},c=`${r.services.trekkie.url}/${a.trekkieLoadConfiguration?.assetPath||"s/trekkie.storefront.min.js"}`;return X?null:new w({shop:a,checkoutToken:x,locale:i,analyticsConfig:re,sourceUrl:c,themeId:B,themeCityHash:t,userEvents:o,monorailRegion:"shop_domain",s2s:s,getCookie:t=>e.cookies.get(t)??null},ae)},[a,x,i,re,B,H,o,e.cookies,ae,M,J,K,_,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&&"filled"===G?.status&&G.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},[G,q]),de=b(()=>{const e=M.current.fields.merchandiseLines.value,t=M.current.fields.remoteMerchandiseDetails.value;if(oe.value){const o=M.current.fields.subtotal.value,r=M.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:M.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,M,te,oe,F]),le=b(()=>{const e=M.current.fields.subtotal.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.current.fields.remoteTotalDetails.value,r=M.current.fields.merchandiseLines.value,i=M.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,M,te,oe,F]),me=b(()=>{if(!q)return;if(Y.shouldPrevent())return;if(!oe.value)return;const e=M.current.fields.merchandiseLines.value,t=e?.lines&&L(e?.lines),o=q.purchaseOrder,r=h(q.orderIdentity.id),i=r?.toString(),a=o.billingAddress,n=M.current.fields.buyerIdentity.value,s=n?.customerProfile;let c=s?.firstName,u=s?.lastName;u||(c=a?.firstName,u=a?.lastName);const d=M.current.fields.total.value,l=M.current.fields.subtotal.value,m=M.current.fields.subtotalAfterMerchandiseDiscounts.value,p=E(M),f=M.current.fields.contactInfo.value,y=M.current.fields.discountLines.value,v=y?.lines.filter(e=>"code"===e.discount.type).map(e=>e.discount.title)||[],k=q.analytics?.checkoutCompletedEventId||void 0,b=q.analytics?.emitConversionEvent||!1;ne?.track(P.CompletedOrder,{customerEventData:{customer:{firstName:c,lastName:u,emailAddress:s?.email??f?.email,phoneNumber:s?.phone??f?.phone},address:{city:a?.city,province:a?.zoneCode,country:a?.countryCode,zip:a?.postalCode}},orderId:r,orderName:i,products:t,total:d?.amount??0,currency:d?.currencyCode,revenue:l?.amount??0,subtotalAfterMerchandiseDiscounts:m?.amount??0,coupon:v[0],tax:p?.amount??0,shipping:ue.amount??0},k,b,{shopifyEmitted:!0}),Y.markAsEmitted()}
1,[q,M,ne,ue.amount,Y,oe]),he=b(()=>{const e=M.current.fields.runningTotal.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.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,M,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=z.value,t=V.value,o=M.current.fields.subtotalAfterMerchandiseDiscounts.value,r=M.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,z,V,M,te,oe]),ye=b(()=>{const e=U.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.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,M,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=M.current.fields.runningTotal.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.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,M,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]);D(b(e=>{ie.value.defaultAttributes&&"page_view"===e.type&&se(e.url)},[ie,se])),D(b(e=>{ie.value.defaultAttributes&&"initiate_checkout"===e.type&&de()},[ie,de])),D(b(e=>{ie.value.defaultAttributes&&"initiate_checkout_once_per_checkout"===e.type&&le()},[ie,le])),D(b(e=>{ie.value.defaultAttributes&&"complete_checkout"===e.type&&me()},[ie,me])),D(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 D(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&&Q&&("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&&Q&&ve(),"page_submit"!==e.type||"shipping"!==e.page||Q||ke())},[ie.value.defaultAttributes,Q,pe,Z,ce,ke,be,Se,Ae,ve])),null}export{j 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.