@elevateab/sdk 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as ie,b as M,c as m,d,e as be,f as _e,g as $,h as q,i as Ce,j as W,k as J,l as Te,m as H,n as Me}from"./chunk-XXNIBCJ6.js";import{A as ee,B as Oe,C as Ne,D as ze,E as Ge,c as j,d as A,e as P,f as I,g as Ae,h as B,i as Q,j as O,k as xe,l as D,m as Se,n as Y,o as Ee,p as K,q as Ue,r as Ie,s as Re,t as Le,u as Ve,v as X,w as Be,x as De,y as Fe,z as Z}from"./chunk-VUGOZ5MR.js";function ae(e){let t=I("ABAU")||{};t[e]||(t[e]=!0,A("ABAU",JSON.stringify(t)))}function se(e){let t=O("ABAV")||{};t[e]||(t[e]=!0,B("ABAV",t))}function te(e){ae(e),se(e)}function $e(e){return!!(O("ABAV")||{})[e]}function qe(e){return!!(I("ABAU")||{})[e]}function We(){if(typeof navigator>"u")return"desktop";let e=navigator.userAgent||navigator.vendor||window.opera||"",t=e.toLowerCase();return/windows nt.*tablet pc|pixelbook/i.test(e)||/(?:macintosh|windows nt|win(?:95|98)|linux x86_64)/i.test(e)&&!/android|mobile|tablet|ipad|iphone|ipod/i.test(t)?"desktop":/ipad|playbook|tablet|kindle|nexus (7|10)|xoom|sm-t\d+|galaxy tab|tb-\d+|tb\d+[a-z]+|lenovo.*tb|dtab|ideatab|mediapad|matepad|honor.*pad|pad\s+\d+|mi\s+pad|redmi.*pad|xiaomi.*pad|oppo.*pad|oneplus.*pad|opd\d+|tcl.*tab|9\d{3}[a-z]|kobo|archos.*5(?!\d)|ereader|droipad/i.test(e)||/android(?!.*mobile)/i.test(t)&&!/dalvik.*miui|pocophone|mi\s+mix|edge\s+\d+|sm-g9\d+|pixel\s+\d|pixel\s+fold|advan\s+\d{4}/i.test(e)?"tablet":/android.+mobile|iphone|ipod|windows phone|blackberry|mobile|phone|kaios/i.test(t)||/^mobile;/i.test(e)||/dalvik.*miui|pocophone|mi\s+mix|pixel\s+\d|pixel\s+fold/i.test(e)?"mobile":"desktop"}function ce(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i.test(e)}function ue(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/(instagram)[\/ ]([-\w\.]+)/i.test(e)}function de(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/musical_ly/i.test(e)}function le(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/(pinterest)[\/ ]([-\w\.]+)/i.test(e)}function Je(){if(typeof window>"u")return"direct";let e=(document.referrer||"").toLowerCase(),t=e?new URL(e).hostname.replace("www.",""):"",r=window.location.hostname,o=ce(),n=ue(),a=de(),i=le();return o||["facebook.com","fb.com","fb.me","m.facebook.com","l.facebook.com","lm.facebook.com"].includes(t)?"facebook":n||t.includes("instagram")?"instagram":a||["tiktok.com","pangleglobal.com","ads.tiktok.com"].includes(t)?"tiktok":i||t.includes("pinterest")||t==="pin.it"?"pinterest":t.includes("google")?"google":!e||r===t?"direct":"other"}function He(e){let t={},r={};if(!e)return{assignments:t,views:r};let o=e.split("~");for(let n of o){let a=n.split("_");if(a.length>=2){let i=a[0],c=a[1],s=a[2]==="1";t[i]=c,r[i]=s}}return{assignments:t,views:r}}function N(){if(typeof window>"u")return{isPreview:!1,previewTestId:null,forcedAssignments:{},previewedViews:{}};let e=new URLSearchParams(window.location.search),r=(e.get("eabUserPreview")||P("eabUserPreview"))==="true",o=e.get("abtid");o||(o=Q("eabPreviewTestId"));let n=e.get("eab_tests")||"",{assignments:a,views:i}=He(n);return e.has("eabUserPreview")&&A("eabUserPreview","true"),e.has("abtid")&&o&&B("eabPreviewTestId",o),{isPreview:r,previewTestId:o,forcedAssignments:a,previewedViews:i}}function je(e,t){if(!t)return!1;if(e===t)return!0;let r=e.slice(-5);return!!(r===t||t.endsWith(r)||e.endsWith(t))}function Qe(e,t){if(!t.isPreview)return null;if(t.forcedAssignments[e])return t.forcedAssignments[e];let r=e.slice(-5);return t.forcedAssignments[r]?t.forcedAssignments[r]:null}function fe(e,t){return Object.entries(e).map(([r,o])=>{let n=r.slice(-5),a=t[r]?"1":"0";return`${n}_${o}_${a}`}).join("~")}function Ye(e,t,r){if(typeof window>"u")return;let o=new URL(window.location.href),n=fe(e,t);n&&o.searchParams.set("eab_tests",n),r&&o.searchParams.set("eabUserId",r),window.history.replaceState({},"",o.toString())}function Ke(){if(!(typeof document>"u")&&(document.cookie="eabUserPreview=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",typeof sessionStorage<"u"&&sessionStorage.removeItem("eabPreviewTestId"),typeof window<"u")){let e=new URL(window.location.href);e.searchParams.delete("eabUserPreview"),e.searchParams.delete("abtid"),e.searchParams.delete("eab_tests"),window.history.replaceState({},"",e.toString())}}function Xe(){return N().isPreview}var x={SHOPIFY_LOCALIZATION:"localization",EAB_COUNTRY:"eabCountryCode",EAB_GEO:"eabGeoLocation"};function R(){if(typeof window>"u")return null;let t=new URLSearchParams(window.location.search).get("country");if(t)return A(x.EAB_COUNTRY,t.toUpperCase()),t.toUpperCase();let r=P(x.SHOPIFY_LOCALIZATION);if(r)return r.toUpperCase();let o=P(x.EAB_COUNTRY);if(o)return o.toUpperCase();if(typeof localStorage<"u"){let n=localStorage.getItem(x.EAB_COUNTRY);if(n)return n.toUpperCase()}return null}function Ze(){let e=R(),t=P(x.EAB_GEO);if(t)try{let r=JSON.parse(t);return{country:r.country||e,region:r.region,city:r.city}}catch{}return{country:e}}function pe(e){let t=e.toUpperCase();A(x.EAB_COUNTRY,t),typeof localStorage<"u"&&localStorage.setItem(x.EAB_COUNTRY,t)}function et(e){e.country&&pe(e.country),A(x.EAB_GEO,JSON.stringify(e))}function me(e,t){let r=t??R();return r?e.map(n=>n.toUpperCase()).includes(r.toUpperCase()):!1}function ge(e,t){let r=t??R();return r?e.map(n=>n.toUpperCase()).includes(r.toUpperCase()):!1}function tt(e){let t=R();return!e.includeCountries?.length&&!e.excludeCountries?.length?!0:!t||e.excludeCountries?.length&&ge(e.excludeCountries,t)?!1:e.includeCountries?.length?me(e.includeCountries,t):!0}var rt={US:"US",CA:"CA",GB:"GB",AU:"AU",DE:"DE",FR:"FR",JP:"JP",MX:"MX",BR:"BR",IN:"IN"},ot={NORTH_AMERICA:["US","CA","MX"],EUROPE:["GB","DE","FR","IT","ES","NL","BE","AT","CH","PL","SE","NO","DK","FI","IE","PT"],APAC:["AU","NZ","JP","KR","SG","HK","TW","TH","MY","PH","ID","VN","IN"],LATAM:["MX","BR","AR","CL","CO","PE"]};var C="eab-prevent-flicker",z="eab-flicker-styles";function ve(e=3e3){if(typeof document>"u"||document.getElementById(z))return;let t=document.createElement("style");t.id=z,t.textContent=`
1
+ import{a as ie,b as $,c as m,d,e as be,f as _e,g as q,h as W,i as Ce,j as H,k as J,l as Te,m as j,n as Me}from"./chunk-XXNIBCJ6.js";import{A as te,B as Oe,C as Ne,D as ze,E as Ge,c as Q,d as A,e as P,f as I,g as Ae,h as B,i as Y,j as N,k as xe,l as D,m as Se,n as K,o as Ee,p as X,q as Ue,r as Ie,s as Re,t as Le,u as Ve,v as Z,w as Be,x as De,y as Fe,z as ee}from"./chunk-VUGOZ5MR.js";function ae(e){let t=I("ABAU")||{};t[e]||(t[e]=!0,A("ABAU",JSON.stringify(t)))}function se(e){let t=N("ABAV")||{};t[e]||(t[e]=!0,B("ABAV",t))}function re(e){ae(e),se(e)}function $e(e){return!!(N("ABAV")||{})[e]}function qe(e){return!!(I("ABAU")||{})[e]}function We(){if(typeof navigator>"u")return"desktop";let e=navigator.userAgent||navigator.vendor||window.opera||"",t=e.toLowerCase();return/windows nt.*tablet pc|pixelbook/i.test(e)||/(?:macintosh|windows nt|win(?:95|98)|linux x86_64)/i.test(e)&&!/android|mobile|tablet|ipad|iphone|ipod/i.test(t)?"desktop":/ipad|playbook|tablet|kindle|nexus (7|10)|xoom|sm-t\d+|galaxy tab|tb-\d+|tb\d+[a-z]+|lenovo.*tb|dtab|ideatab|mediapad|matepad|honor.*pad|pad\s+\d+|mi\s+pad|redmi.*pad|xiaomi.*pad|oppo.*pad|oneplus.*pad|opd\d+|tcl.*tab|9\d{3}[a-z]|kobo|archos.*5(?!\d)|ereader|droipad/i.test(e)||/android(?!.*mobile)/i.test(t)&&!/dalvik.*miui|pocophone|mi\s+mix|edge\s+\d+|sm-g9\d+|pixel\s+\d|pixel\s+fold|advan\s+\d{4}/i.test(e)?"tablet":/android.+mobile|iphone|ipod|windows phone|blackberry|mobile|phone|kaios/i.test(t)||/^mobile;/i.test(e)||/dalvik.*miui|pocophone|mi\s+mix|pixel\s+\d|pixel\s+fold/i.test(e)?"mobile":"desktop"}function ce(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i.test(e)}function ue(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/(instagram)[\/ ]([-\w\.]+)/i.test(e)}function de(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/musical_ly/i.test(e)}function le(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/(pinterest)[\/ ]([-\w\.]+)/i.test(e)}function He(){if(typeof window>"u")return"direct";let e=(document.referrer||"").toLowerCase(),t=e?new URL(e).hostname.replace("www.",""):"",r=window.location.hostname,o=ce(),n=ue(),a=de(),i=le();return o||["facebook.com","fb.com","fb.me","m.facebook.com","l.facebook.com","lm.facebook.com"].includes(t)?"facebook":n||t.includes("instagram")?"instagram":a||["tiktok.com","pangleglobal.com","ads.tiktok.com"].includes(t)?"tiktok":i||t.includes("pinterest")||t==="pin.it"?"pinterest":t.includes("google")?"google":!e||r===t?"direct":"other"}function Je(e){let t={},r={};if(!e)return{assignments:t,views:r};let o=e.split("~");for(let n of o){let a=n.split("_");if(a.length>=2){let i=a[0],c=a[1],s=a[2]==="1";t[i]=c,r[i]=s}}return{assignments:t,views:r}}function z(){if(typeof window>"u")return{isPreview:!1,previewTestId:null,forcedAssignments:{},previewedViews:{}};let e=new URLSearchParams(window.location.search),r=(e.get("eabUserPreview")||P("eabUserPreview"))==="true",o=e.get("abtid");o||(o=Y("eabPreviewTestId"));let n=e.get("eab_tests")||"",{assignments:a,views:i}=Je(n);return e.has("eabUserPreview")&&A("eabUserPreview","true"),e.has("abtid")&&o&&B("eabPreviewTestId",o),{isPreview:r,previewTestId:o,forcedAssignments:a,previewedViews:i}}function je(e,t){if(!t)return!1;if(e===t)return!0;let r=e.slice(-5);return!!(r===t||t.endsWith(r)||e.endsWith(t))}function Qe(e,t){if(!t.isPreview)return null;if(t.forcedAssignments[e])return t.forcedAssignments[e];let r=e.slice(-5);return t.forcedAssignments[r]?t.forcedAssignments[r]:null}function fe(e,t){return Object.entries(e).map(([r,o])=>{let n=r.slice(-5),a=t[r]?"1":"0";return`${n}_${o}_${a}`}).join("~")}function Ye(e,t,r){if(typeof window>"u")return;let o=new URL(window.location.href),n=fe(e,t);n&&o.searchParams.set("eab_tests",n),r&&o.searchParams.set("eabUserId",r),window.history.replaceState({},"",o.toString())}function Ke(){if(!(typeof document>"u")&&(document.cookie="eabUserPreview=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",typeof sessionStorage<"u"&&sessionStorage.removeItem("eabPreviewTestId"),typeof window<"u")){let e=new URL(window.location.href);e.searchParams.delete("eabUserPreview"),e.searchParams.delete("abtid"),e.searchParams.delete("eab_tests"),window.history.replaceState({},"",e.toString())}}function Xe(){return z().isPreview}var x={SHOPIFY_LOCALIZATION:"localization",EAB_COUNTRY:"eabCountryCode",EAB_GEO:"eabGeoLocation"};function R(){if(typeof window>"u")return null;let t=new URLSearchParams(window.location.search).get("country");if(t)return A(x.EAB_COUNTRY,t.toUpperCase()),t.toUpperCase();let r=P(x.SHOPIFY_LOCALIZATION);if(r)return r.toUpperCase();let o=P(x.EAB_COUNTRY);if(o)return o.toUpperCase();if(typeof localStorage<"u"){let n=localStorage.getItem(x.EAB_COUNTRY);if(n)return n.toUpperCase()}return null}function Ze(){let e=R(),t=P(x.EAB_GEO);if(t)try{let r=JSON.parse(t);return{country:r.country||e,region:r.region,city:r.city}}catch{}return{country:e}}function pe(e){let t=e.toUpperCase();A(x.EAB_COUNTRY,t),typeof localStorage<"u"&&localStorage.setItem(x.EAB_COUNTRY,t)}function et(e){e.country&&pe(e.country),A(x.EAB_GEO,JSON.stringify(e))}function me(e,t){let r=t??R();return r?e.map(n=>n.toUpperCase()).includes(r.toUpperCase()):!1}function ge(e,t){let r=t??R();return r?e.map(n=>n.toUpperCase()).includes(r.toUpperCase()):!1}function tt(e){let t=R();return!e.includeCountries?.length&&!e.excludeCountries?.length?!0:!t||e.excludeCountries?.length&&ge(e.excludeCountries,t)?!1:e.includeCountries?.length?me(e.includeCountries,t):!0}var rt={US:"US",CA:"CA",GB:"GB",AU:"AU",DE:"DE",FR:"FR",JP:"JP",MX:"MX",BR:"BR",IN:"IN"},ot={NORTH_AMERICA:["US","CA","MX"],EUROPE:["GB","DE","FR","IT","ES","NL","BE","AT","CH","PL","SE","NO","DK","FI","IE","PT"],APAC:["AU","NZ","JP","KR","SG","HK","TW","TH","MY","PH","ID","VN","IN"],LATAM:["MX","BR","AR","CL","CO","PE"]};var C="eab-prevent-flicker",G="eab-flicker-styles";function ve(e=3e3){if(typeof document>"u"||document.getElementById(G))return;let t=document.createElement("style");t.id=G,t.textContent=`
2
2
  /* Elevate AB - Flicker Prevention */
3
3
  .${C} {
4
4
  opacity: 0 !important;
@@ -13,13 +13,13 @@ import{a as ie,b as M,c as m,d,e as be,f as _e,g as $,h as q,i as Ce,j as W,k as
13
13
  .${C} {
14
14
  animation: eab-reveal 0s ${e}ms forwards;
15
15
  }
16
- `;let r=document.head||document.getElementsByTagName("head")[0];r.insertBefore(t,r.firstChild)}function we(e="body"){if(typeof document>"u")return;let t=document.querySelector(e);t&&t.classList.add(C)}function re(e="body"){if(typeof document>"u")return;let t=document.querySelector(e);t&&t.classList.remove(C)}function oe(e="body",t=3e3){if(typeof document>"u")return()=>{};ve(t),we(e);let r=!1,o=setTimeout(()=>{r||(console.warn(`[ElevateAB] Flicker prevention timeout (${t}ms) reached. Revealing content. Check if test assignment is completing.`),re(e),r=!0)},t);return()=>{r||(clearTimeout(o),re(e),r=!0)}}function nt(){if(typeof document>"u")return;let e=document.getElementById(z);e&&e.remove(),document.querySelectorAll(`.${C}`).forEach(r=>r.classList.remove(C))}function it(){return typeof document>"u"?!1:document.querySelector(`.${C}`)!==null}function ne(e=3e3){return`
16
+ `;let r=document.head||document.getElementsByTagName("head")[0];r.insertBefore(t,r.firstChild)}function ye(e="body"){if(typeof document>"u")return;let t=document.querySelector(e);t&&t.classList.add(C)}function oe(e="body"){if(typeof document>"u")return;let t=document.querySelector(e);t&&t.classList.remove(C)}function ne(e="body",t=3e3){if(typeof document>"u")return()=>{};ve(t),ye(e);let r=!1,o=setTimeout(()=>{r||(console.warn(`[ElevateAB] Flicker prevention timeout (${t}ms) reached. Revealing content. Check if test assignment is completing.`),oe(e),r=!0)},t);return()=>{r||(clearTimeout(o),oe(e),r=!0)}}function nt(){if(typeof document>"u")return;let e=document.getElementById(G);e&&e.remove(),document.querySelectorAll(`.${C}`).forEach(r=>r.classList.remove(C))}function it(){return typeof document>"u"?!1:document.querySelector(`.${C}`)!==null}function F(e=3e3){return`
17
17
  (function() {
18
18
  var style = document.createElement('style');
19
- style.id = '${z}';
19
+ style.id = '${G}';
20
20
  style.textContent = '.${C}{opacity:0!important;pointer-events:none!important}@keyframes eab-reveal{to{opacity:1;pointer-events:auto}}.${C}{animation:eab-reveal 0s ${e}ms forwards}';
21
21
  document.head.insertBefore(style, document.head.firstChild);
22
22
  document.body && document.body.classList.add('${C}');
23
23
  })();
24
- `.trim()}function y(e){return e?e.includes("gid://")&&e.split("/").pop()||e:""}function at(e){return!e||!e.includes("gid://")?null:e.split("/")[3]||null}function st(e){return!!e&&e.startsWith("gid://shopify/")}function ct(){if(typeof window>"u")return;let e=window.Shopify;if(e?.currency?.active)return e.currency.active}import{useEffect as ye,useRef as kt,useState as bt}from"react";var ut="https://bitter-river-9c62.support-67d.workers.dev",dt="https://d339co84ntxcme.cloudfront.net/Prod/orders",g=null;function G(e){g=e}function S(e){let t=e?.storeId||g?.storeId;return t||(console.warn("[ElevateAB] No storeId provided. Call initAnalytics() first or pass storeId to tracking function."),"")}function lt(e){return Object.entries(e).filter(([,t])=>typeof t=="string").map(([t,r])=>({test_id:t,variant_id:r}))}function ft(e,t){return Object.entries(e).filter(([r])=>typeof t[r]=="string").map(([r])=>({test_id:r,variant_id:t[r]}))}function pt(){return typeof window>"u"?!1:P("eabUserPreview")==="true"||new URLSearchParams(window.location.search).get("eabUserPreview")==="true"}function E(e,t,r){if(typeof window>"u"||pt())return null;let o=navigator.userAgent,n=window.location.pathname,a=J(n,r),{referrer:i,entryPage:c}=K(),s=W({referrer:i,entryPage:c,userAgent:o}),u=I("ABTL")||{},f=I("ABAU")||{},v=lt(u),p=ft(f,u),h=$(localStorage.getItem("shopifyCartId")),_=new Date().toISOString(),w=sessionStorage.getItem("eabIsFirstVisit")==="true",l=P("localization")||"";return{pixel_event_id:`sh-${j()}`,shop_name:e,timestamp:_,event_type:t,client_id:P("_shopify_y")||void 0,visitor_id:D(),session_id:Y(),cart_token:q(h||P("cart")),page_url:window.location.href,page_pathname:n,page_search:window.location.search,referrer_url:i,referrer_source:s?.referrer_source,previous_page:document.referrer,page_entry:c,page_entry_path:s?.page_entry_path,page_type:a,utm_medium:s?.utm_medium,utm_source:s?.utm_source,utm_campaign:s?.utm_campaign,utm_content:s?.utm_content,utm_term:s?.utm_term,gclid:s?.gclid,fbclid:s?.fbclid,pins_campaign_id:s?.pins_campaign_id,epik:s?.epik,browser_info:s?.browser_info,os_info:s?.os_info,device_type:s?.device_type,language:navigator.language,root_route:localStorage.getItem("eabRootRoute")||"",user_agent:o,user_agent_no_browser:H(o),is_first_visit:w,shopify_country:l,ab_test_assignments:v,ab_test_views:p,is_first_order:null}}async function U(e,t=ut){try{let r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0});if(!r.ok)throw new Error(`Worker error: ${r.status}`)}catch(r){console.error("[ElevateAB] Error sending analytics:",r)}}async function Pe(e={}){let t=S(e);if(!t)return;let r=e.hasLocalizedPaths??g?.hasLocalizedPaths,o=e.workerUrl??g?.workerUrl,n=E(t,"page_viewed",r);if(!n)return;let a={...n,cart_currency:e.currency};await U(a,o)}async function mt(e){let t=S(e);if(!t)return;let{productId:r,productVendor:o,productPrice:n,productSku:a,currency:i}=e,c=e.hasLocalizedPaths??g?.hasLocalizedPaths,s=e.workerUrl??g?.workerUrl,u=E(t,"product_viewed",c);if(!u)return;let f={...u,cart_currency:i,product_id:y(r),product_vendor:m(o),product_price:d(n),product_sku:m(a)};await U(f,s)}async function gt(e){let t=S(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:a,productQuantity:i,productSku:c,currency:s,cartId:u}=e,f=e.hasLocalizedPaths??g?.hasLocalizedPaths,v=e.workerUrl??g?.workerUrl,p=e.storefrontAccessToken??g?.storefrontAccessToken,h=E(t,"product_added_to_cart",f);if(!h)return;let _={...h,cart_currency:s,product_id:y(r),variant_id:y(o),product_vendor:m(n),product_price:d(a),product_quantity:i,product_sku:m(c)};if(await U(_,v),u&&p)try{let{updateCartAttributes:w}=await import("./cartAttributes-4XA3JSEP.js");await w(u,{storefrontAccessToken:p})}catch(w){console.error("[ElevateAB] Failed to update cart attributes:",w)}}async function vt(e){let t=S(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:a,productQuantity:i,productSku:c,currency:s}=e,u=e.hasLocalizedPaths??g?.hasLocalizedPaths,f=e.workerUrl??g?.workerUrl,v=E(t,"product_removed_from_cart",u);if(!v)return;let p={...v,cart_currency:s,product_id:y(r),variant_id:y(o),product_vendor:m(n),product_price:d(a),product_quantity:i,product_sku:m(c)};await U(p,f)}async function wt(e){let t=S(e);if(!t)return;let{cartTotalPrice:r,cartTotalQuantity:o,cartItems:n,currency:a}=e,i=e.hasLocalizedPaths??g?.hasLocalizedPaths,c=e.workerUrl??g?.workerUrl,s=E(t,"cart_viewed",i);if(!s)return;let u={...s,cart_currency:a,cart_total_price:d(r),cart_total_quantity:o,cart_items:n?.map(f=>({product_id:y(f.productId),variant_id:y(f.variantId),product_vendor:m(f.productVendor)||"",product_price:d(f.productPrice),product_quantity:f.productQuantity??null,product_sku:m(f.productSku)||""}))};await U(u,c)}async function yt(e){let t=S(e);if(!t)return;let{searchQuery:r,currency:o}=e,n=e.hasLocalizedPaths??g?.hasLocalizedPaths,a=e.workerUrl??g?.workerUrl,i=E(t,"search_submitted",n);if(!i)return;let c={...i,cart_currency:o,search_query:m(r)};await U(c,a)}async function Pt(e){let t=S(e);if(!t)return;let{cartTotalPrice:r,cartSubtotalPrice:o,cartShippingPrice:n,cartTaxAmount:a,cartDiscountAmount:i,customerId:c,cartItems:s,currency:u}=e,f=e.hasLocalizedPaths??g?.hasLocalizedPaths,v=e.workerUrl??g?.workerUrl,p=E(t,"checkout_started",f);if(!p)return;let h=0,_=s?.map(l=>{let k=l.productQuantity??0;return h+=k,{product_id:y(l.productId),variant_id:y(l.variantId),product_vendor:m(l.productVendor)||"",vendor:m(l.productVendor)||"",product_price:d(l.productPrice),total_price:d(l.productPrice),product_quantity:k,quantity:k,product_sku:m(l.productSku)||"",sku:m(l.productSku)||"",total_discount:d(l.totalDiscount)}})||[],w={...p,cart_currency:u,cart_total_price:d(r),cart_subtotal_price:d(o),cart_total_quantity:h,cart_shipping_price:d(n),cart_tax_amount:d(a),cart_discount_amount:d(i),cart_items:_,customer_id:c};await U(w,v)}async function ht(e){let t=S(e);if(!t)return;let{orderId:r,cartTotalPrice:o,cartSubtotalPrice:n,cartShippingPrice:a,cartTaxAmount:i,cartDiscountAmount:c,customerId:s,isFirstOrder:u,noteAttributes:f,cartItems:v,currency:p}=e,h=e.hasLocalizedPaths??g?.hasLocalizedPaths,_=e.ordersWorkerUrl??g?.ordersWorkerUrl??dt,w=E(t,"checkout_completed",h);if(!w)return;let l=0,k=v?.map(b=>{let V=b.productQuantity??0;return l+=V,{product_id:y(b.productId),variant_id:y(b.variantId),product_vendor:m(b.productVendor)||"",vendor:m(b.productVendor)||"",product_price:d(b.productPrice),total_price:d(b.productPrice),product_quantity:V,quantity:V,product_sku:m(b.productSku)||"",sku:m(b.productSku)||"",total_discount:d(b.totalDiscount)}})||[],L={...w,cart_currency:p,cart_total_price:d(o),cart_subtotal_price:d(n),cart_total_quantity:l,cart_shipping_price:d(a),cart_tax_amount:d(i),cart_discount_amount:d(c),cart_items:k,order_id:r,customer_id:s,is_first_order:u??null,note_attributes:f};await U(L,_)}function _t(e){let{storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n,enabled:a=!0,pathname:i}=e,c=kt(null),[s,u]=bt(()=>i||(typeof window<"u"?window.location.pathname:""));ye(()=>{i&&u(i)},[i]),ye(()=>{typeof window>"u"||!a||c.current!==s&&(c.current=s,Pe({storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n}))},[s,t,r,o,n,a])}import F from"react";function Ct(e){let{config:t}=M(),[r,o]=F.useState(null),[n,a]=F.useState(!0),i=F.useMemo(()=>t&&t.tests.find(s=>s.testId===e)||null,[t,e]),c=F.useRef(null);return F.useEffect(()=>{if(t===null)return;if(!i){c.current!==e&&(c.current=e,console.warn(`[ElevateAB] Test not found: ${e}`)),a(!1);return}if(!i.enabled){c.current!==`${e}-disabled`&&(c.current=`${e}-disabled`,console.warn(`[ElevateAB] Test disabled: ${e}`)),a(!1);return}if(!ee(i)){a(!1);return}let s=D(),u=Z(e,i,s);u&&(o(u),te(e)),a(!1)},[t,i,e]),{variant:r,isLoading:n,isControl:r?.isControl??!1,isA:r?.isA??!1,isB:r?.isB??!1,isC:r?.isC??!1,isD:r?.isD??!1}}import T,{useRef as he,useCallback as Tt}from"react";import{jsx as Et}from"react/jsx-runtime";var At=!1,xt={allTests:{"price-test-001":{8606:{variationName:"Control",trafficPercentage:50,isDone:!1,isControl:!0},8607:{variationName:"Sale Price",trafficPercentage:50,isDone:!1,prices:{"41883969519701":{main:"USD",price:{USD:"599.95"},compare:{USD:"699.95"}}}},data:{name:"Snowboard Price Test",isLive:!0,settings:{afterDiscounts:!0},type:"PRICE_PLUS",filters:[],isPersonalization:!1,currencies:["USD"],handles:["the-complete-snowboard"],productIds:["7240161067093"]}},"content-test-001":{"ctrl-001":{variationName:"Control",trafficPercentage:34,isDone:!1,isControl:!0,content:{headline:"Welcome to our store",subheadline:"Shop the best products"}},"var-a-001":{variationName:"Urgency Copy",trafficPercentage:33,isDone:!1,content:{headline:"Limited Time Offer!",subheadline:"Don't miss out - sale ends soon"}},"var-b-001":{variationName:"Value Copy",trafficPercentage:33,isDone:!1,content:{headline:"Premium Quality, Great Value",subheadline:"Free shipping on orders over $50"}},data:{name:"Homepage Headline Test",isLive:!0,settings:{afterDiscounts:!0},type:"CONTENT",filters:[],isPersonalization:!1,pathnames:["/"]}},"custom-code-test-001":{10150:{variationName:"Control",trafficPercentage:50,isDone:!1,customCode:{id:"c11a582c-6b27-4263-941c-8ed123437c6b",js:"console.log('[Elevate] Control variant active');",css:"",pathnames:["*"],excludePathnames:[]},isControl:!0},10151:{variationName:"Enhanced UI",trafficPercentage:50,isDone:!1,customCode:{id:"df71546a-0a5f-4ad0-8d0f-a1bdeab05e84",js:"console.log('[Elevate] Enhanced UI variant'); document.body.style.borderTop = '3px solid #10b981';",css:".hero-section { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }",pathnames:["*"],excludePathnames:[]}},data:{name:"Custom Code Enhancement",isLive:!0,settings:{afterDiscounts:!0},type:"CUSTOM_CODE",filters:[],isPersonalization:!1,pathnames:["*"],excludePathnames:[]}},"split-url-test-001":{"split-ctrl":{variationName:"Control",trafficPercentage:50,isDone:!1,isControl:!0,splitUrlTestLinks:{default:"/collections/all"}},"split-var-a":{variationName:"New Landing Page",trafficPercentage:50,isDone:!1,splitUrlTestLinks:{default:"/collections/featured"}},data:{name:"Landing Page Split Test",isLive:!0,settings:{afterDiscounts:!0},type:"SPLIT_URL",filters:[],isPersonalization:!1,pathnames:["/promo"]}}},selectors:{selectorsV2:[]}};function St({storeId:e,storefrontAccessToken:t,preventFlickering:r=!1,flickerTimeout:o=3e3,children:n}){let[a,i]=T.useState(null),[c,s]=T.useState(null),[u,f]=T.useState(null),v=he(null);T.useEffect(()=>(r&&typeof window<"u"&&(v.current=oe("body",o)),()=>{v.current&&v.current()}),[r,o]),T.useEffect(()=>{typeof window>"u"||G({storeId:e,storefrontAccessToken:t})},[e,t]),T.useEffect(()=>{if(typeof window>"u")return;let w=N();s(w);let l=R();f(l)},[]);let p=Tt(()=>{v.current&&(v.current(),v.current=null)},[]);T.useEffect(()=>{async function w(){try{if(!At){let ke=X(xt);i(ke),p();return}let l=`https://configs.elevateab.com/config/${e}.json`,k=await fetch(l);if(k.status===404){i({tests:[],selectors:void 0}),p();return}if(!k.ok)throw new Error(`Failed to fetch config: ${k.status} ${k.statusText}`);let L=await k.json();if(L.subscriptionPaused){console.error(`[ElevateAB] Subscription is paused or stopped for store: ${e}. `+(L.subscriptionMessage||"A/B tests will not run. Please reactivate your subscription.")),i({tests:[],selectors:void 0}),p();return}if(!(Object.keys(L.allTests||{}).length>0)){i({tests:[],selectors:void 0}),p();return}let V=X(L);i(V),p()}catch(l){console.error("[ElevateAB] Failed to load config:",l),i({tests:[],selectors:void 0}),p()}}w()},[e,p]);let h=T.useMemo(()=>({config:a,storeId:e,storefrontAccessToken:t,isPreviewMode:c?.isPreview??!1,previewTestId:c?.previewTestId??null,countryCode:u}),[a,e,t,c,u]);T.useEffect(()=>{G({storeId:e,storefrontAccessToken:t})},[e,t]);let _=he(!1);return T.useEffect(()=>{!t&&!_.current&&(_.current=!0,console.warn("[ElevateAB] No storefrontAccessToken provided. A/B tests will work, but orders won't be attributed to test variants. Add storefrontAccessToken prop to enable order tracking."))},[t]),Et(ie.Provider,{value:h,children:n})}import{jsx as It}from"react/jsx-runtime";function Ut({timeout:e=3e3}){return It("script",{dangerouslySetInnerHTML:{__html:ne(e)}})}var dr="1.1.2",lr={enabled:!0,trackingEndpoint:"https://analytics.elevateab.com/track",cacheDuration:3600};export{Ut as AntiFlickerScript,Oe as CART_ATTRIBUTES_UPDATE_MUTATION,rt as COUNTRIES,lr as DEFAULT_CONFIG,Me as ElevateAnalytics,St as ElevateProvider,ot as REGIONS,dr as VERSION,Z as assignAndPersistVariant,Ue as assignVariant,fe as buildEabTestsParam,Ve as calculateRevenueLift,ce as checkFacebookBrowser,Ce as checkFacebookInstagramBrowser,ue as checkInstagramBrowser,le as checkPinterestBrowser,de as checkTikTokBrowser,Te as checkVisitorIdParams,q as cleanCartToken,Ge as cleanupCartAttributes,nt as cleanupFlickerPrevention,Ke as clearPreviewMode,Ae as deleteCookie,ct as detectShopifyCurrency,$ as extractCartToken,be as extractProductId,_e as extractProductVariantId,y as extractShopifyId,at as extractShopifyType,Le as generateExperimentId,Fe as getAssignedVariant,Ne as getCartAttributesPayload,P as getCookie,R as getCountryCode,We as getDeviceType,ne as getFlickerPreventionScript,Ze as getGeoLocation,I as getJsonCookie,O as getJsonSessionItem,J as getPageTypeFromPathname,N as getPreviewState,Qe as getPreviewVariation,K as getReferrerData,Y as getSessionId,Q as getSessionItem,Be as getTestList,Je as getTrafficSource,H as getUserAgentNoBrowser,D as getVisitorId,$e as hasSessionView,qe as hasUniqueView,Ie as hashString,we as hideForFlicker,G as initAnalytics,Se as initializeSessionId,xe as initializeVisitorId,ve as injectFlickerStyles,ge as isCountryExcluded,me as isCountryIncluded,it as isFlickerPreventionActive,Xe as isInPreviewMode,je as isPreviewTest,st as isShopifyGid,tt as matchesGeoTargeting,W as parseAddViewData,re as revealAfterFlicker,d as roundToTwo,m as sanitizeString,De as saveTestList,A as setCookie,pe as setCountryCode,et as setGeoLocation,Ee as setReferrerData,B as setSessionItem,oe as setupFlickerPrevention,ee as shouldShowTest,gt as trackAddToCart,wt as trackCartView,ht as trackCheckoutCompleted,Pt as trackCheckoutStarted,Pe as trackPageView,mt as trackProductView,vt as trackRemoveFromCart,yt as trackSearchSubmitted,se as trackSessionView,ae as trackUniqueView,te as trackViews,ze as updateCartAttributes,Ye as updateUrlWithTestParams,M as useElevateConfig,Ct as useExperiment,_t as usePageViewTracking,j as uuidv4,Re as validateConfig};
24
+ `.trim()}function w(e){return e?e.includes("gid://")&&e.split("/").pop()||e:""}function at(e){return!e||!e.includes("gid://")?null:e.split("/")[3]||null}function st(e){return!!e&&e.startsWith("gid://shopify/")}function ct(){if(typeof window>"u")return;let e=window.Shopify;if(e?.currency?.active)return e.currency.active}import{useEffect as we,useRef as kt,useState as bt}from"react";var ut="https://bitter-river-9c62.support-67d.workers.dev",dt="https://d339co84ntxcme.cloudfront.net/Prod/orders",g=null;function M(e){g=e}function S(e){let t=e?.storeId||g?.storeId;return t||(console.warn("[ElevateAB] No storeId provided. Call initAnalytics() first or pass storeId to tracking function."),"")}function lt(e){return Object.entries(e).filter(([,t])=>typeof t=="string").map(([t,r])=>({test_id:t,variant_id:r}))}function ft(e,t){return Object.entries(e).filter(([r])=>typeof t[r]=="string").map(([r])=>({test_id:r,variant_id:t[r]}))}function pt(){return typeof window>"u"?!1:P("eabUserPreview")==="true"||new URLSearchParams(window.location.search).get("eabUserPreview")==="true"}function E(e,t,r){if(typeof window>"u"||pt())return null;let o=navigator.userAgent,n=window.location.pathname,a=J(n,r),{referrer:i,entryPage:c}=X(),s=H({referrer:i,entryPage:c,userAgent:o}),u=I("ABTL")||{},f=I("ABAU")||{},v=lt(u),p=ft(f,u),h=q(localStorage.getItem("shopifyCartId")),_=new Date().toISOString(),y=sessionStorage.getItem("eabIsFirstVisit")==="true",l=P("localization")||"";return{pixel_event_id:`sh-${Q()}`,shop_name:e,timestamp:_,event_type:t,client_id:P("_shopify_y")||void 0,visitor_id:D(),session_id:K(),cart_token:W(h||P("cart")),page_url:window.location.href,page_pathname:n,page_search:window.location.search,referrer_url:i,referrer_source:s?.referrer_source,previous_page:document.referrer,page_entry:c,page_entry_path:s?.page_entry_path,page_type:a,utm_medium:s?.utm_medium,utm_source:s?.utm_source,utm_campaign:s?.utm_campaign,utm_content:s?.utm_content,utm_term:s?.utm_term,gclid:s?.gclid,fbclid:s?.fbclid,pins_campaign_id:s?.pins_campaign_id,epik:s?.epik,browser_info:s?.browser_info,os_info:s?.os_info,device_type:s?.device_type,language:navigator.language,root_route:localStorage.getItem("eabRootRoute")||"",user_agent:o,user_agent_no_browser:j(o),is_first_visit:y,shopify_country:l,ab_test_assignments:v,ab_test_views:p,is_first_order:null}}async function U(e,t=ut){try{let r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0});if(!r.ok)throw new Error(`Worker error: ${r.status}`)}catch(r){console.error("[ElevateAB] Error sending analytics:",r)}}async function Pe(e={}){let t=S(e);if(!t)return;let r=e.hasLocalizedPaths??g?.hasLocalizedPaths,o=e.workerUrl??g?.workerUrl,n=E(t,"page_viewed",r);if(!n)return;let a={...n,cart_currency:e.currency};await U(a,o)}async function mt(e){let t=S(e);if(!t)return;let{productId:r,productVendor:o,productPrice:n,productSku:a,currency:i}=e,c=e.hasLocalizedPaths??g?.hasLocalizedPaths,s=e.workerUrl??g?.workerUrl,u=E(t,"product_viewed",c);if(!u)return;let f={...u,cart_currency:i,product_id:w(r),product_vendor:m(o),product_price:d(n),product_sku:m(a)};await U(f,s)}async function gt(e){let t=S(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:a,productQuantity:i,productSku:c,currency:s,cartId:u}=e,f=e.hasLocalizedPaths??g?.hasLocalizedPaths,v=e.workerUrl??g?.workerUrl,p=e.storefrontAccessToken??g?.storefrontAccessToken,h=E(t,"product_added_to_cart",f);if(!h)return;let _={...h,cart_currency:s,product_id:w(r),variant_id:w(o),product_vendor:m(n),product_price:d(a),product_quantity:i,product_sku:m(c)};if(await U(_,v),u&&p)try{let{updateCartAttributes:y}=await import("./cartAttributes-4XA3JSEP.js");await y(u,{storefrontAccessToken:p})}catch(y){console.error("[ElevateAB] Failed to update cart attributes:",y)}}async function vt(e){let t=S(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:a,productQuantity:i,productSku:c,currency:s}=e,u=e.hasLocalizedPaths??g?.hasLocalizedPaths,f=e.workerUrl??g?.workerUrl,v=E(t,"product_removed_from_cart",u);if(!v)return;let p={...v,cart_currency:s,product_id:w(r),variant_id:w(o),product_vendor:m(n),product_price:d(a),product_quantity:i,product_sku:m(c)};await U(p,f)}async function yt(e){let t=S(e);if(!t)return;let{cartTotalPrice:r,cartTotalQuantity:o,cartItems:n,currency:a}=e,i=e.hasLocalizedPaths??g?.hasLocalizedPaths,c=e.workerUrl??g?.workerUrl,s=E(t,"cart_viewed",i);if(!s)return;let u={...s,cart_currency:a,cart_total_price:d(r),cart_total_quantity:o,cart_items:n?.map(f=>({product_id:w(f.productId),variant_id:w(f.variantId),product_vendor:m(f.productVendor)||"",product_price:d(f.productPrice),product_quantity:f.productQuantity??null,product_sku:m(f.productSku)||""}))};await U(u,c)}async function wt(e){let t=S(e);if(!t)return;let{searchQuery:r,currency:o}=e,n=e.hasLocalizedPaths??g?.hasLocalizedPaths,a=e.workerUrl??g?.workerUrl,i=E(t,"search_submitted",n);if(!i)return;let c={...i,cart_currency:o,search_query:m(r)};await U(c,a)}async function Pt(e){let t=S(e);if(!t)return;let{cartTotalPrice:r,cartSubtotalPrice:o,cartShippingPrice:n,cartTaxAmount:a,cartDiscountAmount:i,customerId:c,cartItems:s,currency:u}=e,f=e.hasLocalizedPaths??g?.hasLocalizedPaths,v=e.workerUrl??g?.workerUrl,p=E(t,"checkout_started",f);if(!p)return;let h=0,_=s?.map(l=>{let k=l.productQuantity??0;return h+=k,{product_id:w(l.productId),variant_id:w(l.variantId),product_vendor:m(l.productVendor)||"",vendor:m(l.productVendor)||"",product_price:d(l.productPrice),total_price:d(l.productPrice),product_quantity:k,quantity:k,product_sku:m(l.productSku)||"",sku:m(l.productSku)||"",total_discount:d(l.totalDiscount)}})||[],y={...p,cart_currency:u,cart_total_price:d(r),cart_subtotal_price:d(o),cart_total_quantity:h,cart_shipping_price:d(n),cart_tax_amount:d(a),cart_discount_amount:d(i),cart_items:_,customer_id:c};await U(y,v)}async function ht(e){let t=S(e);if(!t)return;let{orderId:r,cartTotalPrice:o,cartSubtotalPrice:n,cartShippingPrice:a,cartTaxAmount:i,cartDiscountAmount:c,customerId:s,isFirstOrder:u,noteAttributes:f,cartItems:v,currency:p}=e,h=e.hasLocalizedPaths??g?.hasLocalizedPaths,_=e.ordersWorkerUrl??g?.ordersWorkerUrl??dt,y=E(t,"checkout_completed",h);if(!y)return;let l=0,k=v?.map(b=>{let V=b.productQuantity??0;return l+=V,{product_id:w(b.productId),variant_id:w(b.variantId),product_vendor:m(b.productVendor)||"",vendor:m(b.productVendor)||"",product_price:d(b.productPrice),total_price:d(b.productPrice),product_quantity:V,quantity:V,product_sku:m(b.productSku)||"",sku:m(b.productSku)||"",total_discount:d(b.totalDiscount)}})||[],L={...y,cart_currency:p,cart_total_price:d(o),cart_subtotal_price:d(n),cart_total_quantity:l,cart_shipping_price:d(a),cart_tax_amount:d(i),cart_discount_amount:d(c),cart_items:k,order_id:r,customer_id:s,is_first_order:u??null,note_attributes:f};await U(L,_)}function _t(e){let{storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n,enabled:a=!0,pathname:i}=e,c=kt(null),[s,u]=bt(()=>i||(typeof window<"u"?window.location.pathname:""));we(()=>{i&&u(i)},[i]),we(()=>{typeof window>"u"||!a||c.current!==s&&(c.current=s,Pe({storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n}))},[s,t,r,o,n,a])}import O from"react";function Ct(e){let{config:t}=$(),[r,o]=O.useState(null),[n,a]=O.useState(!0),i=O.useMemo(()=>t&&t.tests.find(s=>s.testId===e)||null,[t,e]),c=O.useRef(null);return O.useEffect(()=>{if(t===null)return;if(!i){c.current!==e&&(c.current=e,console.warn(`[ElevateAB] Test not found: ${e}`)),a(!1);return}if(!i.enabled){c.current!==`${e}-disabled`&&(c.current=`${e}-disabled`,console.warn(`[ElevateAB] Test disabled: ${e}`)),a(!1);return}if(!te(i)){a(!1);return}let s=D(),u=ee(e,i,s);u&&(o(u),re(e)),a(!1)},[t,i,e]),{variant:r,isLoading:n,isControl:r?.isControl??!1,isA:r?.isA??!1,isB:r?.isB??!1,isC:r?.isC??!1,isD:r?.isD??!1}}import T,{useRef as he,useCallback as Tt}from"react";import{jsx as Et,jsxs as Ut}from"react/jsx-runtime";var At=!1,xt={allTests:{"price-test-001":{8606:{variationName:"Control",trafficPercentage:50,isDone:!1,isControl:!0},8607:{variationName:"Sale Price",trafficPercentage:50,isDone:!1,prices:{"41883969519701":{main:"USD",price:{USD:"599.95"},compare:{USD:"699.95"}}}},data:{name:"Snowboard Price Test",isLive:!0,settings:{afterDiscounts:!0},type:"PRICE_PLUS",filters:[],isPersonalization:!1,currencies:["USD"],handles:["the-complete-snowboard"],productIds:["7240161067093"]}},"content-test-001":{"ctrl-001":{variationName:"Control",trafficPercentage:34,isDone:!1,isControl:!0,content:{headline:"Welcome to our store",subheadline:"Shop the best products"}},"var-a-001":{variationName:"Urgency Copy",trafficPercentage:33,isDone:!1,content:{headline:"Limited Time Offer!",subheadline:"Don't miss out - sale ends soon"}},"var-b-001":{variationName:"Value Copy",trafficPercentage:33,isDone:!1,content:{headline:"Premium Quality, Great Value",subheadline:"Free shipping on orders over $50"}},data:{name:"Homepage Headline Test",isLive:!0,settings:{afterDiscounts:!0},type:"CONTENT",filters:[],isPersonalization:!1,pathnames:["/"]}},"custom-code-test-001":{10150:{variationName:"Control",trafficPercentage:50,isDone:!1,customCode:{id:"c11a582c-6b27-4263-941c-8ed123437c6b",js:"console.log('[Elevate] Control variant active');",css:"",pathnames:["*"],excludePathnames:[]},isControl:!0},10151:{variationName:"Enhanced UI",trafficPercentage:50,isDone:!1,customCode:{id:"df71546a-0a5f-4ad0-8d0f-a1bdeab05e84",js:"console.log('[Elevate] Enhanced UI variant'); document.body.style.borderTop = '3px solid #10b981';",css:".hero-section { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }",pathnames:["*"],excludePathnames:[]}},data:{name:"Custom Code Enhancement",isLive:!0,settings:{afterDiscounts:!0},type:"CUSTOM_CODE",filters:[],isPersonalization:!1,pathnames:["*"],excludePathnames:[]}},"split-url-test-001":{"split-ctrl":{variationName:"Control",trafficPercentage:50,isDone:!1,isControl:!0,splitUrlTestLinks:{default:"/collections/all"}},"split-var-a":{variationName:"New Landing Page",trafficPercentage:50,isDone:!1,splitUrlTestLinks:{default:"/collections/featured"}},data:{name:"Landing Page Split Test",isLive:!0,settings:{afterDiscounts:!0},type:"SPLIT_URL",filters:[],isPersonalization:!1,pathnames:["/promo"]}}},selectors:{selectorsV2:[]}};function St({storeId:e,storefrontAccessToken:t,preventFlickering:r=!1,flickerTimeout:o=3e3,children:n}){let[a,i]=T.useState(null),[c,s]=T.useState(null),[u,f]=T.useState(null),v=he(null);T.useEffect(()=>(r&&typeof window<"u"&&(v.current=ne("body",o)),()=>{v.current&&v.current()}),[r,o]),T.useEffect(()=>{typeof window>"u"||M({storeId:e,storefrontAccessToken:t})},[e,t]),T.useEffect(()=>{if(typeof window>"u")return;let y=z();s(y);let l=R();f(l)},[]);let p=Tt(()=>{v.current&&(v.current(),v.current=null)},[]);T.useEffect(()=>{async function y(){try{if(!At){let ke=Z(xt);i(ke),p();return}let l=`https://configs.elevateab.com/config/${e}.json`,k=await fetch(l);if(k.status===404){i({tests:[],selectors:void 0}),p();return}if(!k.ok)throw new Error(`Failed to fetch config: ${k.status} ${k.statusText}`);let L=await k.json();if(L.subscriptionPaused){console.error(`[ElevateAB] Subscription is paused or stopped for store: ${e}. `+(L.subscriptionMessage||"A/B tests will not run. Please reactivate your subscription.")),i({tests:[],selectors:void 0}),p();return}if(!(Object.keys(L.allTests||{}).length>0)){i({tests:[],selectors:void 0}),p();return}let V=Z(L);i(V),p()}catch(l){console.error("[ElevateAB] Failed to load config:",l),i({tests:[],selectors:void 0}),p()}}y()},[e,p]);let h=T.useMemo(()=>({config:a,storeId:e,storefrontAccessToken:t,isPreviewMode:c?.isPreview??!1,previewTestId:c?.previewTestId??null,countryCode:u}),[a,e,t,c,u]);T.useEffect(()=>{M({storeId:e,storefrontAccessToken:t})},[e,t]);let _=he(!1);return T.useEffect(()=>{!t&&!_.current&&(_.current=!0,console.warn("[ElevateAB] No storefrontAccessToken provided. A/B tests will work, but orders won't be attributed to test variants. Add storefrontAccessToken prop to enable order tracking."))},[t]),Ut(ie.Provider,{value:h,children:[r&&Et("script",{dangerouslySetInnerHTML:{__html:F(o)}}),n]})}import{jsx as Rt}from"react/jsx-runtime";function It({timeout:e=3e3}){return Rt("script",{dangerouslySetInnerHTML:{__html:F(e)}})}var lr="1.1.2",fr={enabled:!0,trackingEndpoint:"https://analytics.elevateab.com/track",cacheDuration:3600};export{It as AntiFlickerScript,Oe as CART_ATTRIBUTES_UPDATE_MUTATION,rt as COUNTRIES,fr as DEFAULT_CONFIG,Me as ElevateAnalytics,St as ElevateProvider,ot as REGIONS,lr as VERSION,ee as assignAndPersistVariant,Ue as assignVariant,fe as buildEabTestsParam,Ve as calculateRevenueLift,ce as checkFacebookBrowser,Ce as checkFacebookInstagramBrowser,ue as checkInstagramBrowser,le as checkPinterestBrowser,de as checkTikTokBrowser,Te as checkVisitorIdParams,W as cleanCartToken,Ge as cleanupCartAttributes,nt as cleanupFlickerPrevention,Ke as clearPreviewMode,Ae as deleteCookie,ct as detectShopifyCurrency,q as extractCartToken,be as extractProductId,_e as extractProductVariantId,w as extractShopifyId,at as extractShopifyType,Le as generateExperimentId,Fe as getAssignedVariant,Ne as getCartAttributesPayload,P as getCookie,R as getCountryCode,We as getDeviceType,F as getFlickerPreventionScript,Ze as getGeoLocation,I as getJsonCookie,N as getJsonSessionItem,J as getPageTypeFromPathname,z as getPreviewState,Qe as getPreviewVariation,X as getReferrerData,K as getSessionId,Y as getSessionItem,Be as getTestList,He as getTrafficSource,j as getUserAgentNoBrowser,D as getVisitorId,$e as hasSessionView,qe as hasUniqueView,Ie as hashString,ye as hideForFlicker,M as initAnalytics,Se as initializeSessionId,xe as initializeVisitorId,ve as injectFlickerStyles,ge as isCountryExcluded,me as isCountryIncluded,it as isFlickerPreventionActive,Xe as isInPreviewMode,je as isPreviewTest,st as isShopifyGid,tt as matchesGeoTargeting,H as parseAddViewData,oe as revealAfterFlicker,d as roundToTwo,m as sanitizeString,De as saveTestList,A as setCookie,pe as setCountryCode,et as setGeoLocation,Ee as setReferrerData,B as setSessionItem,ne as setupFlickerPrevention,te as shouldShowTest,gt as trackAddToCart,yt as trackCartView,ht as trackCheckoutCompleted,Pt as trackCheckoutStarted,Pe as trackPageView,mt as trackProductView,vt as trackRemoveFromCart,wt as trackSearchSubmitted,se as trackSessionView,ae as trackUniqueView,re as trackViews,ze as updateCartAttributes,Ye as updateUrlWithTestParams,$ as useElevateConfig,Ct as useExperiment,_t as usePageViewTracking,Q as uuidv4,Re as validateConfig};
25
25
  //# sourceMappingURL=index.js.map