@elevateab/sdk 1.2.2 → 1.2.4

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.d.cts CHANGED
@@ -1506,6 +1506,62 @@ interface ElevateProviderSimpleProps {
1506
1506
  */
1507
1507
  declare function ElevateProvider({ storeId, storefrontAccessToken, preventFlickering, flickerTimeout, children, }: ElevateProviderSimpleProps): React.JSX.Element;
1508
1508
 
1509
+ interface AntiFlickerScriptProps {
1510
+ /**
1511
+ * Maximum time (ms) to wait before showing content anyway (failsafe)
1512
+ * @default 3000
1513
+ */
1514
+ timeout?: number;
1515
+ }
1516
+ /**
1517
+ * Anti-flicker script component
1518
+ *
1519
+ * Renders a script tag that prevents content flash during A/B test loading.
1520
+ * Place this in your <head> element before any other scripts.
1521
+ *
1522
+ * @example Hydrogen (app/root.tsx)
1523
+ * ```tsx
1524
+ * import { AntiFlickerScript, ElevateProvider } from "@elevateab/sdk";
1525
+ *
1526
+ * export default function Root() {
1527
+ * return (
1528
+ * <html>
1529
+ * <head>
1530
+ * <AntiFlickerScript />
1531
+ * </head>
1532
+ * <body>
1533
+ * <ElevateProvider storeId="..." preventFlickering={true}>
1534
+ * <Outlet />
1535
+ * </ElevateProvider>
1536
+ * </body>
1537
+ * </html>
1538
+ * );
1539
+ * }
1540
+ * ```
1541
+ *
1542
+ * @example Next.js (app/layout.tsx)
1543
+ * ```tsx
1544
+ * import { AntiFlickerScript } from "@elevateab/sdk";
1545
+ * import { ElevateNextProvider } from "@elevateab/sdk/next";
1546
+ *
1547
+ * export default function RootLayout({ children }) {
1548
+ * return (
1549
+ * <html>
1550
+ * <head>
1551
+ * <AntiFlickerScript />
1552
+ * </head>
1553
+ * <body>
1554
+ * <ElevateNextProvider storeId="..." preventFlickering={true}>
1555
+ * {children}
1556
+ * </ElevateNextProvider>
1557
+ * </body>
1558
+ * </html>
1559
+ * );
1560
+ * }
1561
+ * ```
1562
+ */
1563
+ declare function AntiFlickerScript({ timeout }: AntiFlickerScriptProps): React.JSX.Element;
1564
+
1509
1565
  /**
1510
1566
  * Hook to access Elevate config from context
1511
1567
  */
@@ -1518,4 +1574,4 @@ declare const DEFAULT_CONFIG: {
1518
1574
  cacheDuration: number;
1519
1575
  };
1520
1576
 
1521
- export { type BackendConfig, type BackendTest, type BackendVariation, type BaseTrackingConfig, CART_ATTRIBUTES_UPDATE_MUTATION, COUNTRIES, type CartAttributeInput, type CartAttributesOptions, type CartItemInput, type CartItemPayload, DEFAULT_CONFIG, type ElevateAnalyticsProps, type ElevateConfig, type ElevateContextValue, ElevateProvider, type ElevateProviderProps, type EventPayload, type ExperimentStatus, type GeoLocation, type NoteAttribute, type ParsedViewData, type PreviewState, REGIONS, type Test, type TestAssignment, type TrackAddToCartParams, type TrackCartViewParams, type TrackCheckoutCompletedParams, type TrackCheckoutStartedParams, type TrackPageViewParams, type TrackProductViewParams, type TrackRemoveFromCartParams, type TrackSearchSubmittedParams, type TrackingEvent, type UseExperimentResult, type UsePageViewTrackingParams, VERSION, type Variation, assignAndPersistVariant, assignVariant, buildEabTestsParam, calculateRevenueLift, checkFacebookBrowser, checkFacebookInstagramBrowser, checkInstagramBrowser, checkPinterestBrowser, checkTikTokBrowser, checkVisitorIdParams, cleanCartToken, cleanupCartAttributes, cleanupFlickerPrevention, clearPreviewMode, deleteCookie, detectShopifyCurrency, extractCartToken, extractProductId, extractProductVariantId, extractShopifyId, extractShopifyType, generateExperimentId, getAssignedVariant, getCartAttributesPayload, getCookie, getCountryCode, getDeviceType, getFlickerPreventionScript, getGeoLocation, getJsonCookie, getJsonSessionItem, getPageTypeFromPathname, getPreviewState, getPreviewVariation, getReferrerData, getSessionId, getSessionItem, getTestList, getTrafficSource, getUserAgentNoBrowser, getVisitorId, hasSessionView, hasUniqueView, hashString, hideForFlicker, initAnalytics, initializeSessionId, initializeVisitorId, injectFlickerStyles, isCountryExcluded, isCountryIncluded, isFlickerPreventionActive, isInPreviewMode, isPreviewTest, isShopifyGid, matchesGeoTargeting, parseAddViewData, revealAfterFlicker, roundToTwo, sanitizeString, saveTestList, setCookie, setCountryCode, setGeoLocation, setReferrerData, setSessionItem, setupFlickerPrevention, shouldShowTest, trackAddToCart, trackCartView, trackCheckoutCompleted, trackCheckoutStarted, trackPageView, trackProductView, trackRemoveFromCart, trackSearchSubmitted, trackSessionView, trackUniqueView, trackViews, updateCartAttributes, updateUrlWithTestParams, useElevateConfig, useExperiment, usePageViewTracking, uuidv4, validateConfig };
1577
+ export { AntiFlickerScript, type BackendConfig, type BackendTest, type BackendVariation, type BaseTrackingConfig, CART_ATTRIBUTES_UPDATE_MUTATION, COUNTRIES, type CartAttributeInput, type CartAttributesOptions, type CartItemInput, type CartItemPayload, DEFAULT_CONFIG, type ElevateAnalyticsProps, type ElevateConfig, type ElevateContextValue, ElevateProvider, type ElevateProviderProps, type EventPayload, type ExperimentStatus, type GeoLocation, type NoteAttribute, type ParsedViewData, type PreviewState, REGIONS, type Test, type TestAssignment, type TrackAddToCartParams, type TrackCartViewParams, type TrackCheckoutCompletedParams, type TrackCheckoutStartedParams, type TrackPageViewParams, type TrackProductViewParams, type TrackRemoveFromCartParams, type TrackSearchSubmittedParams, type TrackingEvent, type UseExperimentResult, type UsePageViewTrackingParams, VERSION, type Variation, assignAndPersistVariant, assignVariant, buildEabTestsParam, calculateRevenueLift, checkFacebookBrowser, checkFacebookInstagramBrowser, checkInstagramBrowser, checkPinterestBrowser, checkTikTokBrowser, checkVisitorIdParams, cleanCartToken, cleanupCartAttributes, cleanupFlickerPrevention, clearPreviewMode, deleteCookie, detectShopifyCurrency, extractCartToken, extractProductId, extractProductVariantId, extractShopifyId, extractShopifyType, generateExperimentId, getAssignedVariant, getCartAttributesPayload, getCookie, getCountryCode, getDeviceType, getFlickerPreventionScript, getGeoLocation, getJsonCookie, getJsonSessionItem, getPageTypeFromPathname, getPreviewState, getPreviewVariation, getReferrerData, getSessionId, getSessionItem, getTestList, getTrafficSource, getUserAgentNoBrowser, getVisitorId, hasSessionView, hasUniqueView, hashString, hideForFlicker, initAnalytics, initializeSessionId, initializeVisitorId, injectFlickerStyles, isCountryExcluded, isCountryIncluded, isFlickerPreventionActive, isInPreviewMode, isPreviewTest, isShopifyGid, matchesGeoTargeting, parseAddViewData, revealAfterFlicker, roundToTwo, sanitizeString, saveTestList, setCookie, setCountryCode, setGeoLocation, setReferrerData, setSessionItem, setupFlickerPrevention, shouldShowTest, trackAddToCart, trackCartView, trackCheckoutCompleted, trackCheckoutStarted, trackPageView, trackProductView, trackRemoveFromCart, trackSearchSubmitted, trackSessionView, trackUniqueView, trackViews, updateCartAttributes, updateUrlWithTestParams, useElevateConfig, useExperiment, usePageViewTracking, uuidv4, validateConfig };
package/dist/index.d.ts CHANGED
@@ -1506,6 +1506,62 @@ interface ElevateProviderSimpleProps {
1506
1506
  */
1507
1507
  declare function ElevateProvider({ storeId, storefrontAccessToken, preventFlickering, flickerTimeout, children, }: ElevateProviderSimpleProps): React.JSX.Element;
1508
1508
 
1509
+ interface AntiFlickerScriptProps {
1510
+ /**
1511
+ * Maximum time (ms) to wait before showing content anyway (failsafe)
1512
+ * @default 3000
1513
+ */
1514
+ timeout?: number;
1515
+ }
1516
+ /**
1517
+ * Anti-flicker script component
1518
+ *
1519
+ * Renders a script tag that prevents content flash during A/B test loading.
1520
+ * Place this in your <head> element before any other scripts.
1521
+ *
1522
+ * @example Hydrogen (app/root.tsx)
1523
+ * ```tsx
1524
+ * import { AntiFlickerScript, ElevateProvider } from "@elevateab/sdk";
1525
+ *
1526
+ * export default function Root() {
1527
+ * return (
1528
+ * <html>
1529
+ * <head>
1530
+ * <AntiFlickerScript />
1531
+ * </head>
1532
+ * <body>
1533
+ * <ElevateProvider storeId="..." preventFlickering={true}>
1534
+ * <Outlet />
1535
+ * </ElevateProvider>
1536
+ * </body>
1537
+ * </html>
1538
+ * );
1539
+ * }
1540
+ * ```
1541
+ *
1542
+ * @example Next.js (app/layout.tsx)
1543
+ * ```tsx
1544
+ * import { AntiFlickerScript } from "@elevateab/sdk";
1545
+ * import { ElevateNextProvider } from "@elevateab/sdk/next";
1546
+ *
1547
+ * export default function RootLayout({ children }) {
1548
+ * return (
1549
+ * <html>
1550
+ * <head>
1551
+ * <AntiFlickerScript />
1552
+ * </head>
1553
+ * <body>
1554
+ * <ElevateNextProvider storeId="..." preventFlickering={true}>
1555
+ * {children}
1556
+ * </ElevateNextProvider>
1557
+ * </body>
1558
+ * </html>
1559
+ * );
1560
+ * }
1561
+ * ```
1562
+ */
1563
+ declare function AntiFlickerScript({ timeout }: AntiFlickerScriptProps): React.JSX.Element;
1564
+
1509
1565
  /**
1510
1566
  * Hook to access Elevate config from context
1511
1567
  */
@@ -1518,4 +1574,4 @@ declare const DEFAULT_CONFIG: {
1518
1574
  cacheDuration: number;
1519
1575
  };
1520
1576
 
1521
- export { type BackendConfig, type BackendTest, type BackendVariation, type BaseTrackingConfig, CART_ATTRIBUTES_UPDATE_MUTATION, COUNTRIES, type CartAttributeInput, type CartAttributesOptions, type CartItemInput, type CartItemPayload, DEFAULT_CONFIG, type ElevateAnalyticsProps, type ElevateConfig, type ElevateContextValue, ElevateProvider, type ElevateProviderProps, type EventPayload, type ExperimentStatus, type GeoLocation, type NoteAttribute, type ParsedViewData, type PreviewState, REGIONS, type Test, type TestAssignment, type TrackAddToCartParams, type TrackCartViewParams, type TrackCheckoutCompletedParams, type TrackCheckoutStartedParams, type TrackPageViewParams, type TrackProductViewParams, type TrackRemoveFromCartParams, type TrackSearchSubmittedParams, type TrackingEvent, type UseExperimentResult, type UsePageViewTrackingParams, VERSION, type Variation, assignAndPersistVariant, assignVariant, buildEabTestsParam, calculateRevenueLift, checkFacebookBrowser, checkFacebookInstagramBrowser, checkInstagramBrowser, checkPinterestBrowser, checkTikTokBrowser, checkVisitorIdParams, cleanCartToken, cleanupCartAttributes, cleanupFlickerPrevention, clearPreviewMode, deleteCookie, detectShopifyCurrency, extractCartToken, extractProductId, extractProductVariantId, extractShopifyId, extractShopifyType, generateExperimentId, getAssignedVariant, getCartAttributesPayload, getCookie, getCountryCode, getDeviceType, getFlickerPreventionScript, getGeoLocation, getJsonCookie, getJsonSessionItem, getPageTypeFromPathname, getPreviewState, getPreviewVariation, getReferrerData, getSessionId, getSessionItem, getTestList, getTrafficSource, getUserAgentNoBrowser, getVisitorId, hasSessionView, hasUniqueView, hashString, hideForFlicker, initAnalytics, initializeSessionId, initializeVisitorId, injectFlickerStyles, isCountryExcluded, isCountryIncluded, isFlickerPreventionActive, isInPreviewMode, isPreviewTest, isShopifyGid, matchesGeoTargeting, parseAddViewData, revealAfterFlicker, roundToTwo, sanitizeString, saveTestList, setCookie, setCountryCode, setGeoLocation, setReferrerData, setSessionItem, setupFlickerPrevention, shouldShowTest, trackAddToCart, trackCartView, trackCheckoutCompleted, trackCheckoutStarted, trackPageView, trackProductView, trackRemoveFromCart, trackSearchSubmitted, trackSessionView, trackUniqueView, trackViews, updateCartAttributes, updateUrlWithTestParams, useElevateConfig, useExperiment, usePageViewTracking, uuidv4, validateConfig };
1577
+ export { AntiFlickerScript, type BackendConfig, type BackendTest, type BackendVariation, type BaseTrackingConfig, CART_ATTRIBUTES_UPDATE_MUTATION, COUNTRIES, type CartAttributeInput, type CartAttributesOptions, type CartItemInput, type CartItemPayload, DEFAULT_CONFIG, type ElevateAnalyticsProps, type ElevateConfig, type ElevateContextValue, ElevateProvider, type ElevateProviderProps, type EventPayload, type ExperimentStatus, type GeoLocation, type NoteAttribute, type ParsedViewData, type PreviewState, REGIONS, type Test, type TestAssignment, type TrackAddToCartParams, type TrackCartViewParams, type TrackCheckoutCompletedParams, type TrackCheckoutStartedParams, type TrackPageViewParams, type TrackProductViewParams, type TrackRemoveFromCartParams, type TrackSearchSubmittedParams, type TrackingEvent, type UseExperimentResult, type UsePageViewTrackingParams, VERSION, type Variation, assignAndPersistVariant, assignVariant, buildEabTestsParam, calculateRevenueLift, checkFacebookBrowser, checkFacebookInstagramBrowser, checkInstagramBrowser, checkPinterestBrowser, checkTikTokBrowser, checkVisitorIdParams, cleanCartToken, cleanupCartAttributes, cleanupFlickerPrevention, clearPreviewMode, deleteCookie, detectShopifyCurrency, extractCartToken, extractProductId, extractProductVariantId, extractShopifyId, extractShopifyType, generateExperimentId, getAssignedVariant, getCartAttributesPayload, getCookie, getCountryCode, getDeviceType, getFlickerPreventionScript, getGeoLocation, getJsonCookie, getJsonSessionItem, getPageTypeFromPathname, getPreviewState, getPreviewVariation, getReferrerData, getSessionId, getSessionItem, getTestList, getTrafficSource, getUserAgentNoBrowser, getVisitorId, hasSessionView, hasUniqueView, hashString, hideForFlicker, initAnalytics, initializeSessionId, initializeVisitorId, injectFlickerStyles, isCountryExcluded, isCountryIncluded, isFlickerPreventionActive, isInPreviewMode, isPreviewTest, isShopifyGid, matchesGeoTargeting, parseAddViewData, revealAfterFlicker, roundToTwo, sanitizeString, saveTestList, setCookie, setCountryCode, setGeoLocation, setReferrerData, setSessionItem, setupFlickerPrevention, shouldShowTest, trackAddToCart, trackCartView, trackCheckoutCompleted, trackCheckoutStarted, trackPageView, trackProductView, trackRemoveFromCart, trackSearchSubmitted, trackSessionView, trackUniqueView, trackViews, updateCartAttributes, updateUrlWithTestParams, useElevateConfig, useExperiment, usePageViewTracking, uuidv4, validateConfig };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as ne,b as M,c as m,d,e as ke,f as be,g as $,h as q,i as _e,j as W,k as j,l as Ce,m as J,n as Ge}from"./chunk-XXNIBCJ6.js";import{A as ee,B as Oe,C as Fe,D as Ne,E as ze,c as H,d as x,e as P,f as I,g as Te,h as B,i as Q,j as F,k as xe,l as D,m as Ae,n as Y,o as Se,p as K,q as Ee,r as Ue,s as Ie,t as Re,u as Le,v as X,w as Ve,x as Be,y as De,z as Z}from"./chunk-VUGOZ5MR.js";function ie(e){let t=I("ABAU")||{};t[e]||(t[e]=!0,x("ABAU",JSON.stringify(t)))}function ae(e){let t=F("ABAV")||{};t[e]||(t[e]=!0,B("ABAV",t))}function te(e){ie(e),ae(e)}function Me(e){return!!(F("ABAV")||{})[e]}function $e(e){return!!(I("ABAU")||{})[e]}function qe(){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 se(){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 ce(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/(instagram)[\/ ]([-\w\.]+)/i.test(e)}function ue(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/musical_ly/i.test(e)}function de(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||navigator.vendor||window.opera;return/(pinterest)[\/ ]([-\w\.]+)/i.test(e)}function We(){if(typeof window>"u")return"direct";let e=(document.referrer||"").toLowerCase(),t=e?new URL(e).hostname.replace("www.",""):"",r=window.location.hostname,o=se(),n=ce(),a=ue(),i=de();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 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}=je(n);return e.has("eabUserPreview")&&x("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 He(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 le(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 Qe(e,t,r){if(typeof window>"u")return;let o=new URL(window.location.href),n=le(e,t);n&&o.searchParams.set("eab_tests",n),r&&o.searchParams.set("eabUserId",r),window.history.replaceState({},"",o.toString())}function Ye(){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 Ke(){return N().isPreview}var A={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 x(A.EAB_COUNTRY,t.toUpperCase()),t.toUpperCase();let r=P(A.SHOPIFY_LOCALIZATION);if(r)return r.toUpperCase();let o=P(A.EAB_COUNTRY);if(o)return o.toUpperCase();if(typeof localStorage<"u"){let n=localStorage.getItem(A.EAB_COUNTRY);if(n)return n.toUpperCase()}return null}function Xe(){let e=R(),t=P(A.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 fe(e){let t=e.toUpperCase();x(A.EAB_COUNTRY,t),typeof localStorage<"u"&&localStorage.setItem(A.EAB_COUNTRY,t)}function Ze(e){e.country&&fe(e.country),x(A.EAB_GEO,JSON.stringify(e))}function pe(e,t){let r=t??R();return r?e.map(n=>n.toUpperCase()).includes(r.toUpperCase()):!1}function me(e,t){let r=t??R();return r?e.map(n=>n.toUpperCase()).includes(r.toUpperCase()):!1}function et(e){let t=R();return!e.includeCountries?.length&&!e.excludeCountries?.length?!0:!t||e.excludeCountries?.length&&me(e.excludeCountries,t)?!1:e.includeCountries?.length?pe(e.includeCountries,t):!0}var tt={US:"US",CA:"CA",GB:"GB",AU:"AU",DE:"DE",FR:"FR",JP:"JP",MX:"MX",BR:"BR",IN:"IN"},rt={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 T="eab-prevent-flicker",z="eab-flicker-styles";function ge(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 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 J,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 H,d as x,e as P,f as I,g as xe,h as B,i as Q,j as O,k as Ae,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,x("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 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 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}=Je(n);return e.has("eabUserPreview")&&x("eabUserPreview","true"),e.has("abtid")&&o&&B("eabPreviewTestId",o),{isPreview:r,previewTestId:o,forcedAssignments:a,previewedViews:i}}function He(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 A={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 x(A.EAB_COUNTRY,t.toUpperCase()),t.toUpperCase();let r=P(A.SHOPIFY_LOCALIZATION);if(r)return r.toUpperCase();let o=P(A.EAB_COUNTRY);if(o)return o.toUpperCase();if(typeof localStorage<"u"){let n=localStorage.getItem(A.EAB_COUNTRY);if(n)return n.toUpperCase()}return null}function Ze(){let e=R(),t=P(A.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();x(A.EAB_COUNTRY,t),typeof localStorage<"u"&&localStorage.setItem(A.EAB_COUNTRY,t)}function et(e){e.country&&pe(e.country),x(A.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 T="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=`
2
2
  /* Elevate AB - Flicker Prevention */
3
3
  .${T} {
4
4
  opacity: 0 !important;
@@ -13,7 +13,7 @@ import{a as ne,b as M,c as m,d,e as ke,f as be,g as $,h as q,i as _e,j as W,k as
13
13
  .${T} {
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 ve(e="body"){if(typeof document>"u")return;let t=document.querySelector(e);t&&t.classList.add(T)}function re(e="body"){if(typeof document>"u")return;let t=document.querySelector(e);t&&t.classList.remove(T)}function oe(e="body",t=3e3){if(typeof document>"u")return()=>{};ge(t),ve(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 ot(){if(typeof document>"u")return;let e=document.getElementById(z);e&&e.remove(),document.querySelectorAll(`.${T}`).forEach(r=>r.classList.remove(T))}function nt(){return typeof document>"u"?!1:document.querySelector(`.${T}`)!==null}function it(e=3e3){return`
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(T)}function re(e="body"){if(typeof document>"u")return;let t=document.querySelector(e);t&&t.classList.remove(T)}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(`.${T}`).forEach(r=>r.classList.remove(T))}function it(){return typeof document>"u"?!1:document.querySelector(`.${T}`)!==null}function ne(e=3e3){return`
17
17
  (function() {
18
18
  var style = document.createElement('style');
19
19
  style.id = '${z}';
@@ -21,5 +21,5 @@ import{a as ne,b as M,c as m,d,e as ke,f as be,g as $,h as q,i as _e,j as W,k as
21
21
  document.head.insertBefore(style, document.head.firstChild);
22
22
  document.body && document.body.classList.add('${T}');
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 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 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")),C=new Date().toISOString(),w=sessionStorage.getItem("eabIsFirstVisit")==="true",l=P("localization")||"";return{pixel_event_id:`sh-${H()}`,shop_name:e,timestamp:C,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:J(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 ye(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 C={...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(C,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,C=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:C,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,C=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,C)}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,ye({storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n}))},[s,t,r,o,n,a])}import O from"react";function Ct(e){let{config:t}=M(),[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(!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 _,{useRef as Pe,useCallback as Tt}from"react";var xt=!1,At={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]=_.useState(null),[c,s]=_.useState(null),[u,f]=_.useState(null),v=Pe(null);_.useEffect(()=>(r&&typeof window<"u"&&(v.current=oe("body",o)),()=>{v.current&&v.current()}),[r,o]),_.useEffect(()=>{typeof window>"u"||G({storeId:e,storefrontAccessToken:t})},[e,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)},[]);_.useEffect(()=>{async function w(){try{if(!xt){let he=X(At);i(he),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=_.useMemo(()=>({config:a,storeId:e,storefrontAccessToken:t,isPreviewMode:c?.isPreview??!1,previewTestId:c?.previewTestId??null,countryCode:u}),[a,e,t,c,u]);_.useEffect(()=>{G({storeId:e,storefrontAccessToken:t})},[e,t]);let C=Pe(!1);return _.useEffect(()=>{!t&&!C.current&&(C.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]),_.createElement(ne.Provider,{value:h},n)}var or="1.1.2",nr={enabled:!0,trackingEndpoint:"https://analytics.elevateab.com/track",cacheDuration:3600};export{Oe as CART_ATTRIBUTES_UPDATE_MUTATION,tt as COUNTRIES,nr as DEFAULT_CONFIG,Ge as ElevateAnalytics,St as ElevateProvider,rt as REGIONS,or as VERSION,Z as assignAndPersistVariant,Ee as assignVariant,le as buildEabTestsParam,Le as calculateRevenueLift,se as checkFacebookBrowser,_e as checkFacebookInstagramBrowser,ce as checkInstagramBrowser,de as checkPinterestBrowser,ue as checkTikTokBrowser,Ce as checkVisitorIdParams,q as cleanCartToken,ze as cleanupCartAttributes,ot as cleanupFlickerPrevention,Ye as clearPreviewMode,Te as deleteCookie,ct as detectShopifyCurrency,$ as extractCartToken,ke as extractProductId,be as extractProductVariantId,y as extractShopifyId,at as extractShopifyType,Re as generateExperimentId,De as getAssignedVariant,Fe as getCartAttributesPayload,P as getCookie,R as getCountryCode,qe as getDeviceType,it as getFlickerPreventionScript,Xe as getGeoLocation,I as getJsonCookie,F as getJsonSessionItem,j as getPageTypeFromPathname,N as getPreviewState,He as getPreviewVariation,K as getReferrerData,Y as getSessionId,Q as getSessionItem,Ve as getTestList,We as getTrafficSource,J as getUserAgentNoBrowser,D as getVisitorId,Me as hasSessionView,$e as hasUniqueView,Ue as hashString,ve as hideForFlicker,G as initAnalytics,Ae as initializeSessionId,xe as initializeVisitorId,ge as injectFlickerStyles,me as isCountryExcluded,pe as isCountryIncluded,nt as isFlickerPreventionActive,Ke as isInPreviewMode,Je as isPreviewTest,st as isShopifyGid,et as matchesGeoTargeting,W as parseAddViewData,re as revealAfterFlicker,d as roundToTwo,m as sanitizeString,Be as saveTestList,x as setCookie,fe as setCountryCode,Ze as setGeoLocation,Se as setReferrerData,B as setSessionItem,oe as setupFlickerPrevention,ee as shouldShowTest,gt as trackAddToCart,wt as trackCartView,ht as trackCheckoutCompleted,Pt as trackCheckoutStarted,ye as trackPageView,mt as trackProductView,vt as trackRemoveFromCart,yt as trackSearchSubmitted,ae as trackSessionView,ie as trackUniqueView,te as trackViews,Ne as updateCartAttributes,Qe as updateUrlWithTestParams,M as useElevateConfig,Ct as useExperiment,_t as usePageViewTracking,H as uuidv4,Ie as validateConfig};
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")),C=new Date().toISOString(),w=sessionStorage.getItem("eabIsFirstVisit")==="true",l=P("localization")||"";return{pixel_event_id:`sh-${H()}`,shop_name:e,timestamp:C,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:J(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 C={...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(C,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,C=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:C,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,C=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,C)}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 _,{useRef as he,useCallback as Tt}from"react";var xt=!1,At={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]=_.useState(null),[c,s]=_.useState(null),[u,f]=_.useState(null),v=he(null);_.useEffect(()=>(r&&typeof window<"u"&&(v.current=oe("body",o)),()=>{v.current&&v.current()}),[r,o]),_.useEffect(()=>{typeof window>"u"||G({storeId:e,storefrontAccessToken:t})},[e,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)},[]);_.useEffect(()=>{async function w(){try{if(!xt){let ke=X(At);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=_.useMemo(()=>({config:a,storeId:e,storefrontAccessToken:t,isPreviewMode:c?.isPreview??!1,previewTestId:c?.previewTestId??null,countryCode:u}),[a,e,t,c,u]);_.useEffect(()=>{G({storeId:e,storefrontAccessToken:t})},[e,t]);let C=he(!1);return _.useEffect(()=>{!t&&!C.current&&(C.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]),_.createElement(ie.Provider,{value:h},n)}import Et from"react";function Ut({timeout:e=3e3}){return Et.createElement("script",{dangerouslySetInnerHTML:{__html:ne(e)}})}var cr="1.1.2",ur={enabled:!0,trackingEndpoint:"https://analytics.elevateab.com/track",cacheDuration:3600};export{Ut as AntiFlickerScript,Oe as CART_ATTRIBUTES_UPDATE_MUTATION,rt as COUNTRIES,ur as DEFAULT_CONFIG,Me as ElevateAnalytics,St as ElevateProvider,ot as REGIONS,cr 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,xe 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,J as getUserAgentNoBrowser,D as getVisitorId,$e as hasSessionView,qe as hasUniqueView,Ie as hashString,we as hideForFlicker,G as initAnalytics,Se as initializeSessionId,Ae as initializeVisitorId,ve as injectFlickerStyles,ge as isCountryExcluded,me as isCountryIncluded,it as isFlickerPreventionActive,Xe as isInPreviewMode,He as isPreviewTest,st as isShopifyGid,tt as matchesGeoTargeting,W as parseAddViewData,re as revealAfterFlicker,d as roundToTwo,m as sanitizeString,De as saveTestList,x 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,H as uuidv4,Re as validateConfig};
25
25
  //# sourceMappingURL=index.js.map