@rebuy/rebuy-hydrogen 3.0.0-beta.17 → 3.0.0-beta.19

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.
Files changed (30) hide show
  1. package/README.md +54 -6
  2. package/dist/components/Timer/Timer.d.ts +1 -1
  3. package/dist/components/Timer/Timer.d.ts.map +1 -1
  4. package/dist/components/Timer/types.d.ts +4 -0
  5. package/dist/components/Timer/types.d.ts.map +1 -1
  6. package/dist/context/RebuyWidgetContext.d.ts +7 -0
  7. package/dist/context/RebuyWidgetContext.d.ts.map +1 -0
  8. package/dist/hooks/useBFCacheReset.d.ts +7 -0
  9. package/dist/hooks/useBFCacheReset.d.ts.map +1 -0
  10. package/dist/index.css +27 -27
  11. package/dist/index.css.map +1 -1
  12. package/dist/index.js +553 -480
  13. package/dist/index.js.map +4 -4
  14. package/dist/index.mjs +319 -246
  15. package/dist/index.mjs.map +4 -4
  16. package/dist/providers/RebuyHydrogenContextProvider.d.ts.map +1 -1
  17. package/dist/providers/RebuyHydrogenReactContextProvider.d.ts.map +1 -1
  18. package/dist/types/widgets.d.ts +172 -170
  19. package/dist/types/widgets.d.ts.map +1 -1
  20. package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -1
  21. package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts.map +1 -1
  22. package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -1
  23. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -1
  24. package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts.map +1 -1
  25. package/dist/widgets/RebuyWidget/RebuyWidget.d.ts.map +1 -1
  26. package/dist/widgets/RebuyWidget/WidgetContent.d.ts +1 -1
  27. package/dist/widgets/RebuyWidget/WidgetContent.d.ts.map +1 -1
  28. package/dist/widgets/RebuyWidget/types.d.ts +2 -0
  29. package/dist/widgets/RebuyWidget/types.d.ts.map +1 -1
  30. package/package.json +1 -9
package/dist/index.mjs CHANGED
@@ -265,9 +265,26 @@ var useRebuyConfig = () => {
265
265
  import { createContext as createContext2 } from "react";
266
266
  var RebuyContext = createContext2(null);
267
267
 
268
+ // src/hooks/useBFCacheReset.ts
269
+ import { useEffect as useEffect2, useState as useState2 } from "react";
270
+ var useBFCacheReset = () => {
271
+ const [resetKey, setResetKey] = useState2(() => Date.now());
272
+ useEffect2(() => {
273
+ const handlePageShow = (event) => {
274
+ if (event.persisted) {
275
+ console.log("[useBFCacheReset] B/F cache detected, triggering reset");
276
+ setResetKey(Date.now());
277
+ }
278
+ };
279
+ window.addEventListener("pageshow", handlePageShow);
280
+ return () => window.removeEventListener("pageshow", handlePageShow);
281
+ }, []);
282
+ return resetKey;
283
+ };
284
+
268
285
  // src/smart-cart/context/SmartCartContext.tsx
269
286
  import { isEqual as isEqual2 } from "lodash-es";
270
- import { createContext as createContext3, useCallback, useContext as useContext2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
287
+ import { createContext as createContext3, useCallback, useContext as useContext2, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
271
288
  import { useShallow } from "zustand/react/shallow";
272
289
 
273
290
  // src/smart-cart/store/tieredProgressBarStore.ts
@@ -2105,7 +2122,7 @@ var SmartCartProvider = ({
2105
2122
  storefrontAccessToken
2106
2123
  }) => {
2107
2124
  const rebuyContext = useContext2(RebuyContext);
2108
- const [isVisible, setIsVisible] = useState2(false);
2125
+ const [isVisible, setIsVisible] = useState3(false);
2109
2126
  const showCart = useCallback(() => setIsVisible(true), []);
2110
2127
  const hideCart = useCallback(() => setIsVisible(false), []);
2111
2128
  const toggleCart = useCallback(() => setIsVisible((prev) => !prev), []);
@@ -2207,12 +2224,12 @@ var SmartCartProvider = ({
2207
2224
  const tpbComponentConfig = config?.components?.find((comp) => comp.type === "tiered_progress_bar");
2208
2225
  return tpbComponentConfig?.settings ?? null;
2209
2226
  }, [config]);
2210
- useEffect2(() => {
2227
+ useEffect3(() => {
2211
2228
  if (progressBarSettings && isCartReady && shopifyDomain && storefrontAccessToken) {
2212
2229
  tpbInit(progressBarSettings, shopifyDomain, storefrontAccessToken);
2213
2230
  }
2214
2231
  }, [progressBarSettings, isCartReady, shopifyDomain, storefrontAccessToken, tpbInit]);
2215
- useEffect2(() => {
2232
+ useEffect3(() => {
2216
2233
  const currentTpbState = useTieredProgressBarStore.getState();
2217
2234
  const newTpbIsCartReady = isCartReady;
2218
2235
  if (!isEqual2(currentTpbState.cartData, mappedStorefrontCartData) || currentTpbState.isCartReady !== newTpbIsCartReady) {
@@ -2351,7 +2368,7 @@ var SmartCartProvider = ({
2351
2368
  );
2352
2369
  }
2353
2370
  }, [mappedStorefrontCartData]);
2354
- useEffect2(() => {
2371
+ useEffect3(() => {
2355
2372
  const conditions = {
2356
2373
  activeBarConfigPresent: !!activeBarConfig,
2357
2374
  cartDataIsEqual: isEqual2(tpbInternalCartData, mappedStorefrontCartData),
@@ -2726,6 +2743,7 @@ var RebuyHydrogenContext = ({
2726
2743
  shop,
2727
2744
  sourceHydrogenCart
2728
2745
  }) => {
2746
+ const resetKey = useBFCacheReset();
2729
2747
  const {
2730
2748
  apiKey,
2731
2749
  fetchError: configFetchError,
@@ -2767,7 +2785,8 @@ var RebuyHydrogenContext = ({
2767
2785
  shopifyDomain: shopifyDomainForSmartCart,
2768
2786
  storefrontAccessToken,
2769
2787
  children
2770
- }
2788
+ },
2789
+ `smart-cart-${resetKey}`
2771
2790
  ) : /* @__PURE__ */ jsxs2(Fragment, { children: [
2772
2791
  enableSmartCart && !hasAllSmartCartPrerequisites && !warningLogged2.current && (() => {
2773
2792
  console.warn(
@@ -2825,7 +2844,7 @@ var RebuyHydrogenContextProvider = ({
2825
2844
  // src/providers/RebuyHydrogenReactContextProvider.tsx
2826
2845
  import * as Utilities3 from "@rebuy/rebuy/utilities";
2827
2846
  import { CartProvider, ShopifyProvider, useCart } from "@shopify/hydrogen-react";
2828
- import { useEffect as useEffect3, useMemo as useMemo4, useRef as useRef4 } from "react";
2847
+ import { useEffect as useEffect4, useMemo as useMemo4, useRef as useRef4 } from "react";
2829
2848
  import { useLocation as useLocation2 } from "react-router";
2830
2849
 
2831
2850
  // src/queries/cart.queries.ts
@@ -3369,6 +3388,7 @@ var RebuyHydrogenReactContext = ({
3369
3388
  publicPrimaryDomain,
3370
3389
  publicStorefrontToken
3371
3390
  }) => {
3391
+ const resetKey = useBFCacheReset();
3372
3392
  const {
3373
3393
  apiKey,
3374
3394
  fetchError: configFetchError,
@@ -3436,7 +3456,7 @@ var RebuyHydrogenReactContext = ({
3436
3456
  const shopifyDomainForSmartCart = configShopDomain || rebuyConfig?.shop?.domain || "";
3437
3457
  const storefrontAccessToken = publicStorefrontToken || rebuyConfig?.shop?.storefront_access_token || "";
3438
3458
  const hasAllSmartCartPrerequisites = enableSmartCart && configLoadingStatus === "success" && !!rebuyConfig && !!(smartCartConfig && apiKey && shopifyDomainForSmartCart && storefrontAccessToken);
3439
- useEffect3(() => {
3459
+ useEffect4(() => {
3440
3460
  if (configLoadingStatus === "loading") return;
3441
3461
  const smartCartDetails = enableSmartCart ? {
3442
3462
  hasAllSmartCartPrerequisites,
@@ -3473,7 +3493,8 @@ var RebuyHydrogenReactContext = ({
3473
3493
  shopifyDomain: shopifyDomainForSmartCart,
3474
3494
  storefrontAccessToken,
3475
3495
  children
3476
- }
3496
+ },
3497
+ `smart-cart-react-${resetKey}`
3477
3498
  ) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
3478
3499
  enableSmartCart && !hasAllSmartCartPrerequisites && !warningLogged2.current && (() => {
3479
3500
  console.warn(
@@ -3612,14 +3633,14 @@ var RebuyHydrogenReactContextProvider = ({
3612
3633
 
3613
3634
  // src/smart-cart/components/SmartCartContainer/SmartCartContainer.tsx
3614
3635
  import clsx13 from "clsx";
3615
- import React11, { useCallback as useCallback14, useEffect as useEffect21, useMemo as useMemo20, useRef as useRef13 } from "react";
3636
+ import React11, { useCallback as useCallback14, useEffect as useEffect22, useMemo as useMemo20, useRef as useRef13 } from "react";
3616
3637
 
3617
3638
  // src/smart-cart/components/_Layouts/AnchorSlot.tsx
3618
3639
  import { useMemo as useMemo19 } from "react";
3619
3640
 
3620
3641
  // src/smart-cart/components/AnnouncementBar/AnnouncementBar.tsx
3621
3642
  import DOMPurify from "dompurify";
3622
- import React, { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef5, useState as useState3 } from "react";
3643
+ import React, { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef5, useState as useState4 } from "react";
3623
3644
 
3624
3645
  // src/smart-cart/components/ScreenReaderText/ScreenReaderText.tsx
3625
3646
  import { jsx as jsx7 } from "react/jsx-runtime";
@@ -3635,14 +3656,14 @@ var AUTOPLAY_INTERVAL = 5e3;
3635
3656
  var DRAG_THRESHOLD = 50;
3636
3657
  var AnnouncementBar = React.memo(({ componentConfig }) => {
3637
3658
  const { isVisible } = useSmartCart();
3638
- const [currentSlideIndex, setCurrentSlideIndex] = useState3(0);
3639
- const [isPaused, setIsPaused] = useState3(false);
3640
- const [isFocused, setIsFocused] = useState3(false);
3659
+ const [currentSlideIndex, setCurrentSlideIndex] = useState4(0);
3660
+ const [isPaused, setIsPaused] = useState4(false);
3661
+ const [isFocused, setIsFocused] = useState4(false);
3641
3662
  const intervalRef = useRef5(null);
3642
3663
  const containerRef = useRef5(null);
3643
- const [isDragging, setIsDragging] = useState3(false);
3644
- const [startX, setStartX] = useState3(0);
3645
- const [dragOffset, setDragOffset] = useState3(0);
3664
+ const [isDragging, setIsDragging] = useState4(false);
3665
+ const [startX, setStartX] = useState4(0);
3666
+ const [dragOffset, setDragOffset] = useState4(0);
3646
3667
  const sanitizedMessages = useMemo5(() => {
3647
3668
  const settings = componentConfig?.settings;
3648
3669
  const rawMessages = settings?.messages ?? [];
@@ -3674,11 +3695,11 @@ var AnnouncementBar = React.memo(({ componentConfig }) => {
3674
3695
  },
3675
3696
  [messageCount]
3676
3697
  );
3677
- useEffect4(() => {
3698
+ useEffect5(() => {
3678
3699
  startTimer();
3679
3700
  return clearTimer;
3680
3701
  }, [startTimer, isPaused, isVisible, isFocused]);
3681
- useEffect4(() => {
3702
+ useEffect5(() => {
3682
3703
  if (!isVisible) {
3683
3704
  setCurrentSlideIndex(0);
3684
3705
  setIsPaused(false);
@@ -3814,7 +3835,7 @@ AnnouncementBar.displayName = "AnnouncementBar";
3814
3835
 
3815
3836
  // src/smart-cart/components/CartItem/CartItem.tsx
3816
3837
  import clsx from "clsx";
3817
- import { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo7, useState as useState5 } from "react";
3838
+ import { useCallback as useCallback4, useEffect as useEffect6, useMemo as useMemo7, useState as useState6 } from "react";
3818
3839
  import { useFetcher } from "react-router";
3819
3840
 
3820
3841
  // src/components/RebuyLink/RebuyLink.tsx
@@ -3825,7 +3846,7 @@ var RebuyLink = ({ ariaLabel, children, className, handle, onClick, role = "link
3825
3846
  };
3826
3847
 
3827
3848
  // src/smart-cart/hooks/useCartItemFeatures.ts
3828
- import { useCallback as useCallback3, useMemo as useMemo6, useState as useState4 } from "react";
3849
+ import { useCallback as useCallback3, useMemo as useMemo6, useState as useState5 } from "react";
3829
3850
 
3830
3851
  // src/smart-cart/utils/imageUtils.ts
3831
3852
  var sizeImage = (src, size) => {
@@ -3854,7 +3875,7 @@ var mapCartAttributes = (attributes) => {
3854
3875
  }));
3855
3876
  };
3856
3877
  var useCartItemFeatures = ({ config, line }) => {
3857
- const [isBundleExpanded, setIsBundleExpanded] = useState4(false);
3878
+ const [isBundleExpanded, setIsBundleExpanded] = useState5(false);
3858
3879
  const productTitle = useMemo6(() => line.merchandise.product.title, [line.merchandise.product.title]);
3859
3880
  const variantTitle = useMemo6(
3860
3881
  () => line.merchandise.title !== "Default Title" ? line.merchandise.title : null,
@@ -4247,12 +4268,12 @@ var Spinner = ({ className }) => /* @__PURE__ */ jsx10("span", { className: clsx
4247
4268
  var CartItem = ({ line }) => {
4248
4269
  const { config, isCartBusy, isHydrogenReact, removeItem, updateItem } = useSmartCart();
4249
4270
  const itemFetcher = useFetcher();
4250
- const [isIncreasing, setIsIncreasing] = useState5(false);
4251
- const [isDecreasing, setIsDecreasing] = useState5(false);
4252
- const [isRemoving, setIsRemoving] = useState5(false);
4253
- const [isAdjustingBMSM, setIsAdjustingBMSM] = useState5(false);
4254
- const [isSwitchingSubscription, setIsSwitchingSubscription] = useState5(false);
4255
- const [switchingDirection, setSwitchingDirection] = useState5(null);
4271
+ const [isIncreasing, setIsIncreasing] = useState6(false);
4272
+ const [isDecreasing, setIsDecreasing] = useState6(false);
4273
+ const [isRemoving, setIsRemoving] = useState6(false);
4274
+ const [isAdjustingBMSM, setIsAdjustingBMSM] = useState6(false);
4275
+ const [isSwitchingSubscription, setIsSwitchingSubscription] = useState6(false);
4276
+ const [switchingDirection, setSwitchingDirection] = useState6(null);
4256
4277
  const { toggleCart } = useSmartCart();
4257
4278
  const {
4258
4279
  actions: itemActionsLogic,
@@ -4450,7 +4471,7 @@ var CartItem = ({ line }) => {
4450
4471
  sts.isCurrentlySubscription,
4451
4472
  sts.availableFrequencies
4452
4473
  ]);
4453
- useEffect5(() => {
4474
+ useEffect6(() => {
4454
4475
  const resetLocalSpinners = () => {
4455
4476
  setIsIncreasing(false);
4456
4477
  setIsDecreasing(false);
@@ -4751,7 +4772,7 @@ var CartItemList = ({ componentConfig }) => {
4751
4772
 
4752
4773
  // src/smart-cart/components/CartNoteInput/CartNoteInput.tsx
4753
4774
  import clsx2 from "clsx";
4754
- import React2, { useCallback as useCallback5, useEffect as useEffect6, useMemo as useMemo8, useRef as useRef6, useState as useState6 } from "react";
4775
+ import React2, { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo8, useRef as useRef6, useState as useState7 } from "react";
4755
4776
  import { useFetcher as useFetcher2 } from "react-router";
4756
4777
 
4757
4778
  // src/smart-cart/components/CartNoteInput/CartNoteInput.module.css
@@ -4776,10 +4797,10 @@ var CartNoteInput = React2.memo(({ componentConfig }) => {
4776
4797
  const placeholder = settings?.language?.notes_placeholder ?? "Your notes...";
4777
4798
  const limitChars = settings?.limit_characters ?? true;
4778
4799
  const maxLength = settings?.max_length ?? 200;
4779
- const [currentNoteValue, setCurrentNoteValue] = useState6(cartData?.note || "");
4780
- const [isTextareaVisible, setIsTextareaVisible] = useState6(!!cartData?.note);
4781
- const [isSaving, setIsSaving] = useState6(false);
4782
- const [saveMessage, setSaveMessage] = useState6(null);
4800
+ const [currentNoteValue, setCurrentNoteValue] = useState7(cartData?.note || "");
4801
+ const [isTextareaVisible, setIsTextareaVisible] = useState7(!!cartData?.note);
4802
+ const [isSaving, setIsSaving] = useState7(false);
4803
+ const [saveMessage, setSaveMessage] = useState7(null);
4783
4804
  const saveMessageTimerRef = useRef6(null);
4784
4805
  const currentCartNoteFromCtx = cartData?.note || "";
4785
4806
  const isNoteChanged = currentNoteValue.trim() !== currentCartNoteFromCtx.trim();
@@ -4789,7 +4810,7 @@ var CartNoteInput = React2.memo(({ componentConfig }) => {
4789
4810
  return noteFetcher.state !== "idle" || isSaving;
4790
4811
  }, [isHydrogenReact, isGlobalCartLoading, noteFetcher.state, isSaving]);
4791
4812
  const canSave = isNoteChanged && !isLoadingCombined;
4792
- useEffect6(() => {
4813
+ useEffect7(() => {
4793
4814
  const noteFromCart = cartData?.note || "";
4794
4815
  if (!isTextareaFocusedRef.current && !isSaving && noteFromCart !== currentNoteValue) {
4795
4816
  setCurrentNoteValue(noteFromCart);
@@ -4798,7 +4819,7 @@ var CartNoteInput = React2.memo(({ componentConfig }) => {
4798
4819
  } else if (!noteFromCart && isTextareaVisible && !isSaving && !currentNoteValue.trim()) {
4799
4820
  }
4800
4821
  }, [cartData?.note, isSaving, currentNoteValue, isTextareaVisible]);
4801
- useEffect6(() => {
4822
+ useEffect7(() => {
4802
4823
  return () => {
4803
4824
  if (saveMessageTimerRef.current) clearTimeout(saveMessageTimerRef.current);
4804
4825
  };
@@ -4871,7 +4892,7 @@ var CartNoteInput = React2.memo(({ componentConfig }) => {
4871
4892
  },
4872
4893
  [handleSave]
4873
4894
  );
4874
- useEffect6(() => {
4895
+ useEffect7(() => {
4875
4896
  if (isHydrogenReact) {
4876
4897
  if (!isGlobalCartLoading && isSaving) {
4877
4898
  setIsSaving(false);
@@ -5008,7 +5029,7 @@ CartNoteInput.displayName = "CartNoteInput";
5008
5029
 
5009
5030
  // src/smart-cart/components/CartSubtotal/CartSubtotal.tsx
5010
5031
  import clsx3 from "clsx";
5011
- import React3, { useCallback as useCallback6, useMemo as useMemo9, useState as useState7 } from "react";
5032
+ import React3, { useCallback as useCallback6, useMemo as useMemo9, useState as useState8 } from "react";
5012
5033
 
5013
5034
  // src/smart-cart/components/CartSubtotal/CartSubtotal.module.css
5014
5035
  var result6 = { "rebuy-cart-subtotal": "CartSubtotal_rebuy-cart-subtotal", "rebuy-cart-subtotal--simple": "CartSubtotal_rebuy-cart-subtotal--simple", "rebuy-cart-subtotal__label": "CartSubtotal_rebuy-cart-subtotal__label", "rebuy-cart-subtotal__amount-wrapper": "CartSubtotal_rebuy-cart-subtotal__amount-wrapper", "rebuy-cart-subtotal__price--compare-at": "CartSubtotal_rebuy-cart-subtotal__price--compare-at", "rebuy-cart-subtotal__price--final": "CartSubtotal_rebuy-cart-subtotal__price--final", "rebuy-cart-subtotal--with-summary": "CartSubtotal_rebuy-cart-subtotal--with-summary", "rebuy-cart-subtotal__row": "CartSubtotal_rebuy-cart-subtotal__row", "rebuy-cart-subtotal__discount-summary": "CartSubtotal_rebuy-cart-subtotal__discount-summary", "rebuy-cart-subtotal__discount-summary-header": "CartSubtotal_rebuy-cart-subtotal__discount-summary-header", "rebuy-cart-subtotal__discount-summary-icon": "CartSubtotal_rebuy-cart-subtotal__discount-summary-icon", "rebuy-cart-subtotal__discount-summary--expanded": "CartSubtotal_rebuy-cart-subtotal__discount-summary--expanded", "rebuy-cart-subtotal__discount-summary-details": "CartSubtotal_rebuy-cart-subtotal__discount-summary-details", "rebuy-cart-subtotal__discount-summary-item": "CartSubtotal_rebuy-cart-subtotal__discount-summary-item" };
@@ -5030,7 +5051,7 @@ var getDiscountAllocationTitle = (alloc) => {
5030
5051
  };
5031
5052
  var CartSubtotalComponent = ({ componentConfig }) => {
5032
5053
  const { cartData } = useSmartCart();
5033
- const [isDiscountSummaryExpanded, setIsDiscountSummaryExpanded] = useState7(false);
5054
+ const [isDiscountSummaryExpanded, setIsDiscountSummaryExpanded] = useState8(false);
5034
5055
  const settings = useMemo9(
5035
5056
  () => componentConfig?.settings ?? {},
5036
5057
  [componentConfig?.settings]
@@ -5238,7 +5259,7 @@ var CartTitleBar = React4.memo(() => {
5238
5259
  CartTitleBar.displayName = "CartTitleBar";
5239
5260
 
5240
5261
  // src/smart-cart/components/CheckoutArea/CheckoutArea.tsx
5241
- import React5, { useCallback as useCallback7, useEffect as useEffect7, useMemo as useMemo11, useState as useState8 } from "react";
5262
+ import React5, { useCallback as useCallback7, useEffect as useEffect8, useMemo as useMemo11, useState as useState9 } from "react";
5242
5263
  import { useFetcher as useFetcher3 } from "react-router";
5243
5264
 
5244
5265
  // src/smart-cart/components/CheckoutArea/CheckoutArea.module.css
@@ -5259,9 +5280,9 @@ var CheckoutArea = React5.memo(({ componentConfig }) => {
5259
5280
  } = useSmartCart();
5260
5281
  const termsFetcher = useFetcher3();
5261
5282
  const settings = componentConfig.settings;
5262
- const [termsAccepted, setTermsAccepted] = useState8(false);
5263
- const [processingSource, setProcessingSource] = useState8(null);
5264
- useEffect7(() => {
5283
+ const [termsAccepted, setTermsAccepted] = useState9(false);
5284
+ const [processingSource, setProcessingSource] = useState9(null);
5285
+ useEffect8(() => {
5265
5286
  const termsAttr = cartData?.attributes?.find((attr) => attr.key === "Terms and Conditions");
5266
5287
  const acceptedInCart = termsAttr?.value === "Accepted";
5267
5288
  if (processingSource !== "terms" && termsAccepted !== acceptedInCart) {
@@ -5367,7 +5388,7 @@ var CheckoutArea = React5.memo(({ componentConfig }) => {
5367
5388
  termsFetcher,
5368
5389
  cartData?.attributes
5369
5390
  ]);
5370
- useEffect7(() => {
5391
+ useEffect8(() => {
5371
5392
  if (processingSource === "terms") {
5372
5393
  if (isHydrogenReact && !isGlobalCartLoading) {
5373
5394
  setProcessingSource(null);
@@ -5550,7 +5571,7 @@ CheckoutArea.displayName = "CheckoutArea";
5550
5571
  import { RebuyClient as RebuyClient2 } from "@rebuy/rebuy";
5551
5572
  import * as Utilities4 from "@rebuy/rebuy/utilities";
5552
5573
  import { flattenConnection as flattenConnection3 } from "@shopify/hydrogen";
5553
- import { useContext as useContext3, useEffect as useEffect13, useMemo as useMemo13, useRef as useRef7, useState as useState15 } from "react";
5574
+ import { useContext as useContext3, useEffect as useEffect14, useMemo as useMemo13, useRef as useRef7, useState as useState16 } from "react";
5554
5575
 
5555
5576
  // src/assets/Close.tsx
5556
5577
  import { jsx as jsx17 } from "react/jsx-runtime";
@@ -5559,10 +5580,10 @@ var Close = () => {
5559
5580
  };
5560
5581
 
5561
5582
  // src/hooks/useBreakpoint.ts
5562
- import { useEffect as useEffect8, useState as useState9 } from "react";
5583
+ import { useEffect as useEffect9, useState as useState10 } from "react";
5563
5584
  var useBreakpoint = (settings) => {
5564
- const [breakpoint, setBreakpoint] = useState9("medium");
5565
- useEffect8(() => {
5585
+ const [breakpoint, setBreakpoint] = useState10("medium");
5586
+ useEffect9(() => {
5566
5587
  if (!settings?.breakpoints) return;
5567
5588
  const handleResize = () => {
5568
5589
  const width = window.innerWidth;
@@ -5595,7 +5616,7 @@ var useBreakpoint = (settings) => {
5595
5616
  };
5596
5617
 
5597
5618
  // src/hooks/usePopupTrigger.tsx
5598
- import { useCallback as useCallback8, useEffect as useEffect9 } from "react";
5619
+ import { useCallback as useCallback8, useEffect as useEffect10 } from "react";
5599
5620
  var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showPopup, setShowPopup, setPopupShownOnce) => {
5600
5621
  const delayInMs = settings?.display_type === "popup" ? (settings?.popup_delay || 0) * 1e3 : 0;
5601
5622
  const popupTrigger = settings?.popup_trigger;
@@ -5606,7 +5627,7 @@ var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showP
5606
5627
  setPopupShownOnce(true);
5607
5628
  }, delayInMs);
5608
5629
  }, [delayInMs, setShowPopup, setPopupShownOnce, settings]);
5609
- useEffect9(() => {
5630
+ useEffect10(() => {
5610
5631
  if (!settings || settings.display_type !== "popup" || popupTrigger !== "load" || popupShownOnce) return;
5611
5632
  const timer = setTimeout(() => {
5612
5633
  setShowPopup(true);
@@ -5614,7 +5635,7 @@ var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showP
5614
5635
  }, delayInMs);
5615
5636
  return () => clearTimeout(timer);
5616
5637
  }, [popupTrigger, popupShownOnce, delayInMs, setShowPopup, setPopupShownOnce, settings]);
5617
- useEffect9(() => {
5638
+ useEffect10(() => {
5618
5639
  if (!settings || settings.display_type !== "popup" || popupTrigger !== "add_to_cart" || !popupTriggerId) return;
5619
5640
  const selector = `#${popupTriggerId}`;
5620
5641
  const handleCartAdd = () => {
@@ -5646,7 +5667,7 @@ var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showP
5646
5667
  });
5647
5668
  };
5648
5669
  }, [popupTrigger, popupTriggerId, showPopup, showPopupWithDelay, settings]);
5649
- useEffect9(() => {
5670
+ useEffect10(() => {
5650
5671
  if (!settings || settings.display_type !== "popup" || popupTrigger !== "submit") return;
5651
5672
  const selector = "form";
5652
5673
  const handleSubmit = () => {
@@ -5662,7 +5683,7 @@ var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showP
5662
5683
  });
5663
5684
  };
5664
5685
  }, [popupTrigger, showPopupWithDelay, settings]);
5665
- useEffect9(() => {
5686
+ useEffect10(() => {
5666
5687
  if (!settings || settings.display_type !== "popup" || popupTrigger !== "exit") return;
5667
5688
  const handleExitIntent = (e) => {
5668
5689
  if (e.clientY <= 0 && !popupShownOnce) {
@@ -6063,7 +6084,7 @@ var defaultProductCardSettings = {
6063
6084
 
6064
6085
  // src/components/ProductCard/ProductCard.tsx
6065
6086
  import { Image } from "@shopify/hydrogen";
6066
- import { useCallback as useCallback9, useMemo as useMemo12, useState as useState12 } from "react";
6087
+ import { useCallback as useCallback9, useMemo as useMemo12, useState as useState13 } from "react";
6067
6088
 
6068
6089
  // src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx
6069
6090
  import { CartForm, Money } from "@shopify/hydrogen";
@@ -6251,7 +6272,7 @@ var RebuyProductPrice = ({ selectedVariant, settingsDiscount }) => {
6251
6272
  };
6252
6273
 
6253
6274
  // src/components/QuantityInput/QuantityInput.tsx
6254
- import { useState as useState10 } from "react";
6275
+ import { useState as useState11 } from "react";
6255
6276
 
6256
6277
  // src/components/QuantityInput/QuantityInput.module.css
6257
6278
  var result11 = { "rebuy-quantity__container": "QuantityInput_rebuy-quantity__container", "rebuy-quantity__select": "QuantityInput_rebuy-quantity__select" };
@@ -6265,7 +6286,7 @@ var QuantityInput = ({
6265
6286
  maxValue = 10,
6266
6287
  minValue = 1
6267
6288
  }) => {
6268
- const [quantity, setQuantity] = useState10(defaultQuantity);
6289
+ const [quantity, setQuantity] = useState11(defaultQuantity);
6269
6290
  const handleChange = (event) => {
6270
6291
  const newValue = parseInt(event.target.value, 10);
6271
6292
  setQuantity(newValue);
@@ -6289,7 +6310,7 @@ var QuantityInput = ({
6289
6310
 
6290
6311
  // src/components/VariantSelect/VariantSelect.tsx
6291
6312
  import clsx5 from "clsx";
6292
- import { useEffect as useEffect10, useState as useState11 } from "react";
6313
+ import { useEffect as useEffect11, useState as useState12 } from "react";
6293
6314
 
6294
6315
  // src/components/VariantSelect/VariantSelect.module.css
6295
6316
  var result12 = { "rebuy-variant__container": "VariantSelect_rebuy-variant__container", "rebuy-variant__select": "VariantSelect_rebuy-variant__select", "rebuy-variant__select-option": "VariantSelect_rebuy-variant__select-option", "rebuy-variant__buttons": "VariantSelect_rebuy-variant__buttons", "rebuy-variant__button": "VariantSelect_rebuy-variant__button", "rebuy-variant__button--selected": "VariantSelect_rebuy-variant__button--selected" };
@@ -6298,8 +6319,8 @@ var VariantSelect_default = result12;
6298
6319
  // src/components/VariantSelect/VariantSelect.tsx
6299
6320
  import { jsx as jsx23 } from "react/jsx-runtime";
6300
6321
  var VariantSelect = ({ handleSelectedVariant, product, selectedId, style = "select" }) => {
6301
- const [selectedVariantId, setSelectedVariantId] = useState11(selectedId || product.variants.nodes[0]?.id);
6302
- useEffect10(() => {
6322
+ const [selectedVariantId, setSelectedVariantId] = useState12(selectedId || product.variants.nodes[0]?.id);
6323
+ useEffect11(() => {
6303
6324
  if (selectedId && selectedId !== selectedVariantId) {
6304
6325
  setSelectedVariantId(selectedId);
6305
6326
  }
@@ -6390,9 +6411,9 @@ var ProductCard = ({
6390
6411
  settings = defaultProductCardSettings,
6391
6412
  variantOptionsText
6392
6413
  }) => {
6393
- const [selectedVariant, setSelectedVariant] = useState12(product.variants.nodes[0]);
6394
- const [selectedQuantity, setSelectedQuantity] = useState12(settings?.quantityInput?.default_quantity || 1);
6395
- const [interactionStatus, setInteractionStatus] = useState12("ready");
6414
+ const [selectedVariant, setSelectedVariant] = useState13(product.variants.nodes[0]);
6415
+ const [selectedQuantity, setSelectedQuantity] = useState13(settings?.quantityInput?.default_quantity || 1);
6416
+ const [interactionStatus, setInteractionStatus] = useState13("ready");
6396
6417
  const { toggleCart } = useSmartCart();
6397
6418
  const displayImage = selectedVariant.image || product.featuredImage;
6398
6419
  const handleSelectedVariant = useCallback9((product2, variant_id) => {
@@ -6454,8 +6475,8 @@ var ProductCard = ({
6454
6475
  if (isSelectionRequiredBeforeAddToCart) {
6455
6476
  setInteractionStatus("selecting");
6456
6477
  } else {
6457
- if (isInPopup && onPopupDismiss) {
6458
- onPopupDismiss();
6478
+ if (isInPopup) {
6479
+ onPopupDismiss?.();
6459
6480
  }
6460
6481
  }
6461
6482
  }, [isSelectionRequiredBeforeAddToCart, isInPopup, onPopupDismiss]);
@@ -6624,7 +6645,7 @@ var ProductCard = ({
6624
6645
  addToCartCallback,
6625
6646
  disableShopifyAddAction: isSelectionRequiredBeforeAddToCart,
6626
6647
  isHydrogenReact,
6627
- onClickAction: handlePrimaryAction,
6648
+ onClickAction: isSelectionRequiredBeforeAddToCart ? handlePrimaryAction : void 0,
6628
6649
  quantity: selectedQuantity,
6629
6650
  selectedVariants: isSelectionRequiredBeforeAddToCart ? [] : [selectedVariant]
6630
6651
  }
@@ -6645,7 +6666,7 @@ var ProductCard = ({
6645
6666
  };
6646
6667
 
6647
6668
  // src/components/ProductCarousel/ProductCarousel.tsx
6648
- import { useEffect as useEffect11, useState as useState13 } from "react";
6669
+ import { useEffect as useEffect12, useState as useState14 } from "react";
6649
6670
 
6650
6671
  // src/components/ProductCarousel/ProductCarousel.module.css
6651
6672
  var result15 = { "rebuy-carousel": "ProductCarousel_rebuy-carousel", "rebuy-carousel__container": "ProductCarousel_rebuy-carousel__container", "rebuy-carousel__slide": "ProductCarousel_rebuy-carousel__slide", "rebuy-carousel__controls": "ProductCarousel_rebuy-carousel__controls", "rebuy-carousel__prev": "ProductCarousel_rebuy-carousel__prev", "rebuy-carousel__next": "ProductCarousel_rebuy-carousel__next", "rebuy-carousel__pagination": "ProductCarousel_rebuy-carousel__pagination", "rebuy-carousel__dot": "ProductCarousel_rebuy-carousel__dot", "rebuy-carousel__grid": "ProductCarousel_rebuy-carousel__grid" };
@@ -6667,10 +6688,10 @@ var ProductCarousel = ({
6667
6688
  showPagination = true,
6668
6689
  variantOptionsText
6669
6690
  }) => {
6670
- const [currentSlide, setCurrentSlide] = useState13(0);
6671
- const [totalSlides, setTotalSlides] = useState13(0);
6672
- const [repeatedProducts, setRepeatedProducts] = useState13([]);
6673
- useEffect11(() => {
6691
+ const [currentSlide, setCurrentSlide] = useState14(0);
6692
+ const [totalSlides, setTotalSlides] = useState14(0);
6693
+ const [repeatedProducts, setRepeatedProducts] = useState14([]);
6694
+ useEffect12(() => {
6674
6695
  if (products.length === 0) {
6675
6696
  setRepeatedProducts([]);
6676
6697
  return;
@@ -6683,7 +6704,7 @@ var ProductCarousel = ({
6683
6704
  }
6684
6705
  setRepeatedProducts(repeated);
6685
6706
  }, [products, columns]);
6686
- useEffect11(() => {
6707
+ useEffect12(() => {
6687
6708
  if (repeatedProducts.length && columns) {
6688
6709
  setTotalSlides(Math.ceil(repeatedProducts.length / columns));
6689
6710
  }
@@ -6744,7 +6765,7 @@ var ProductCarousel = ({
6744
6765
 
6745
6766
  // src/components/Timer/Timer.tsx
6746
6767
  import clsx7 from "clsx";
6747
- import { useCallback as useCallback10, useEffect as useEffect12, useState as useState14 } from "react";
6768
+ import { useCallback as useCallback10, useEffect as useEffect13, useState as useState15 } from "react";
6748
6769
 
6749
6770
  // src/components/Timer/Timer.module.css
6750
6771
  var result16 = { "rebuy-timer__container": "Timer_rebuy-timer__container", "rebuy-timer__text": "Timer_rebuy-timer__text", "rebuy-timer__title": "Timer_rebuy-timer__title", "rebuy-timer__display": "Timer_rebuy-timer__display", "rebuy-timer__display--urgent": "Timer_rebuy-timer__display--urgent", "rebuy-timer__minutes": "Timer_rebuy-timer__minutes", "rebuy-timer__seconds": "Timer_rebuy-timer__seconds", "rebuy-timer__separator": "Timer_rebuy-timer__separator" };
@@ -6752,10 +6773,19 @@ var Timer_default = result16;
6752
6773
 
6753
6774
  // src/components/Timer/Timer.tsx
6754
6775
  import { jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
6755
- var Timer = ({ action, durationMinutes, durationSeconds, isPopup = false, onDismiss, title }) => {
6776
+ var Timer = ({
6777
+ action,
6778
+ cartCount,
6779
+ checkoutUrl,
6780
+ durationMinutes,
6781
+ durationSeconds,
6782
+ isPopup = false,
6783
+ onDismiss,
6784
+ title
6785
+ }) => {
6756
6786
  const initialTotalSeconds = (durationMinutes || 0) * 60 + (durationSeconds || 0);
6757
- const [totalSeconds, setTotalSeconds] = useState14(initialTotalSeconds);
6758
- const [timerActive, setTimerActive] = useState14(true);
6787
+ const [totalSeconds, setTotalSeconds] = useState15(initialTotalSeconds);
6788
+ const [timerActive, setTimerActive] = useState15(true);
6759
6789
  const minutes = Math.floor(totalSeconds / 60);
6760
6790
  const seconds = totalSeconds % 60;
6761
6791
  const formattedMinutes = String(minutes).padStart(2, "0");
@@ -6769,7 +6799,14 @@ var Timer = ({ action, durationMinutes, durationSeconds, isPopup = false, onDism
6769
6799
  }
6770
6800
  break;
6771
6801
  case "checkout":
6772
- window.location.href = "/checkout";
6802
+ if (checkoutUrl && cartCount && cartCount > 0) {
6803
+ window.location.href = checkoutUrl;
6804
+ } else {
6805
+ console.warn("Timer: No checkout URL available for checkout action");
6806
+ if (isPopup && onDismiss) {
6807
+ onDismiss();
6808
+ }
6809
+ }
6773
6810
  break;
6774
6811
  case "cart":
6775
6812
  window.location.href = "/cart";
@@ -6778,8 +6815,8 @@ var Timer = ({ action, durationMinutes, durationSeconds, isPopup = false, onDism
6778
6815
  default:
6779
6816
  break;
6780
6817
  }
6781
- }, [action, isPopup, onDismiss]);
6782
- useEffect12(() => {
6818
+ }, [action, checkoutUrl, isPopup, onDismiss]);
6819
+ useEffect13(() => {
6783
6820
  if (!timerActive) return;
6784
6821
  const interval = setInterval(() => {
6785
6822
  setTotalSeconds((prevSeconds) => {
@@ -6856,6 +6893,8 @@ var RebuyWidget_default = result17;
6856
6893
  import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
6857
6894
  var WidgetContent = ({
6858
6895
  addToCartCallback,
6896
+ cartCount,
6897
+ checkoutUrl,
6859
6898
  customTitle,
6860
6899
  customTitleLevel,
6861
6900
  customTitleStyle,
@@ -6949,6 +6988,8 @@ var WidgetContent = ({
6949
6988
  Timer,
6950
6989
  {
6951
6990
  action: settings?.timer.action,
6991
+ cartCount,
6992
+ checkoutUrl,
6952
6993
  durationMinutes: settings?.timer.duration_minutes,
6953
6994
  durationSeconds: settings?.timer.duration_seconds,
6954
6995
  isPopup: settings?.display_type === "popup",
@@ -6986,7 +7027,6 @@ var RebuyWidget = (props) => {
6986
7027
  customTitleLevel = "h2",
6987
7028
  customTitleStyle,
6988
7029
  isCrossSell,
6989
- isHydrogenReact,
6990
7030
  popupTriggerId,
6991
7031
  product,
6992
7032
  productId,
@@ -6995,26 +7035,26 @@ var RebuyWidget = (props) => {
6995
7035
  widgetId
6996
7036
  } = props;
6997
7037
  const { apiKey: apiKeyFromConfig, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
6998
- const [settings, setSettings] = useState15(null);
6999
- const [loadingSettings, setLoadingSettings] = useState15(true);
7000
- const [error, setError] = useState15(null);
7001
- const [showPopup, setShowPopup] = useState15(false);
7002
- const [popupShownOnce, setPopupShownOnce] = useState15(false);
7038
+ const [settings, setSettings] = useState16(null);
7039
+ const [loadingSettings, setLoadingSettings] = useState16(true);
7040
+ const [error, setError] = useState16(null);
7041
+ const [showPopup, setShowPopup] = useState16(false);
7042
+ const [popupShownOnce, setPopupShownOnce] = useState16(false);
7003
7043
  const popupRef = useRef7(null);
7004
- const [clientInstance, setClientInstance] = useState15(null);
7044
+ const [clientInstance, setClientInstance] = useState16(null);
7005
7045
  const rebuyGeneralContext = useContext3(RebuyContext);
7006
7046
  const generalContextParams = rebuyGeneralContext?.contextParameters;
7007
7047
  const mainCacheKey = rebuyConfig?.shop?.cache_key;
7008
7048
  const generalContextCacheKey = generalContextParams?.cache_key;
7009
7049
  const cacheKeyToUse = mainCacheKey || generalContextCacheKey || "";
7010
- const [initialized, setInitialized] = useState15(false);
7050
+ const [initialized, setInitialized] = useState16(false);
7011
7051
  const shopifyProductId = product?.id ?? productId ?? null;
7012
7052
  const shopifyVariantId = variant?.id ?? variantId ?? null;
7013
- const [products, setProducts] = useState15([]);
7053
+ const [products, setProducts] = useState16([]);
7014
7054
  const currentBreakpoint = useBreakpoint(settings);
7015
7055
  const shouldHideWidget = settings?.layout?.[currentBreakpoint]?.style === "none";
7016
7056
  usePopupTrigger(settings, popupTriggerId, widgetId, popupShownOnce, showPopup, setShowPopup, setPopupShownOnce);
7017
- useEffect13(() => {
7057
+ useEffect14(() => {
7018
7058
  if (!clientInstance && apiKeyFromConfig && configLoadingStatus === "success") {
7019
7059
  const client = new RebuyClient2(apiKeyFromConfig);
7020
7060
  if (generalContextParams) {
@@ -7025,12 +7065,12 @@ var RebuyWidget = (props) => {
7025
7065
  setInitialized(true);
7026
7066
  }
7027
7067
  }, [clientInstance, apiKeyFromConfig, configLoadingStatus, generalContextParams]);
7028
- useEffect13(() => {
7068
+ useEffect14(() => {
7029
7069
  if (!clientInstance || !generalContextParams) return;
7030
7070
  const filteredParams = filterContextForWidgetEndpoints(generalContextParams, settings?.endpoint);
7031
7071
  clientInstance.setContextParameters(filteredParams);
7032
7072
  }, [clientInstance, generalContextParams, settings]);
7033
- useEffect13(() => {
7073
+ useEffect14(() => {
7034
7074
  if (configLoadingStatus === "loading") {
7035
7075
  return;
7036
7076
  }
@@ -7125,7 +7165,7 @@ var RebuyWidget = (props) => {
7125
7165
  }
7126
7166
  return req;
7127
7167
  }, [settings, shopifyProductId, shopifyVariantId, cartProductIds, cartVariantIds]);
7128
- useEffect13(() => {
7168
+ useEffect14(() => {
7129
7169
  let isMounted = true;
7130
7170
  if (!clientInstance || !initialized || !settings || configLoadingStatus !== "success") return;
7131
7171
  const fetchData = async () => {
@@ -7177,7 +7217,7 @@ var RebuyWidget = (props) => {
7177
7217
  apiKeyFromConfig,
7178
7218
  cacheKeyToUse
7179
7219
  ]);
7180
- useEffect13(() => {
7220
+ useEffect14(() => {
7181
7221
  if (!showPopup) return;
7182
7222
  const handleClickOutside = (event) => {
7183
7223
  if (popupRef.current && !popupRef.current.contains(event.target)) {
@@ -7227,10 +7267,12 @@ var RebuyWidget = (props) => {
7227
7267
  closePopup();
7228
7268
  }, 0);
7229
7269
  },
7270
+ cartCount: generalContextParams?.cart_count || 0,
7271
+ checkoutUrl: generalContextParams?.checkoutUrl,
7230
7272
  customTitle,
7231
7273
  customTitleLevel,
7232
7274
  customTitleStyle,
7233
- isHydrogenReact,
7275
+ isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
7234
7276
  isInPopup: true,
7235
7277
  onDismiss: closePopup,
7236
7278
  products,
@@ -7241,11 +7283,12 @@ var RebuyWidget = (props) => {
7241
7283
  WidgetContent,
7242
7284
  {
7243
7285
  addToCartCallback,
7286
+ checkoutUrl: generalContextParams?.checkoutUrl,
7244
7287
  customTitle,
7245
7288
  customTitleLevel,
7246
7289
  customTitleStyle,
7247
7290
  isCrossSell,
7248
- isHydrogenReact,
7291
+ isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
7249
7292
  isInPopup: settings?.display_type === "popup",
7250
7293
  products,
7251
7294
  settings
@@ -7265,7 +7308,7 @@ var CrossSell = ({ componentConfig }) => {
7265
7308
  };
7266
7309
 
7267
7310
  // src/smart-cart/components/CustomCode/CustomCodeBlock.tsx
7268
- import React6, { useEffect as useEffect14, useMemo as useMemo14, useRef as useRef8 } from "react";
7311
+ import React6, { useEffect as useEffect15, useMemo as useMemo14, useRef as useRef8 } from "react";
7269
7312
 
7270
7313
  // src/utils/nonceManager.ts
7271
7314
  var cachedNonce = void 0;
@@ -7344,7 +7387,7 @@ var CustomCodeBlock = React6.memo(({ componentConfig }) => {
7344
7387
  const executedCodeRef = useRef8(null);
7345
7388
  const componentId = componentConfig.component_id;
7346
7389
  const htmlCode = useMemo14(() => componentConfig.settings?.html_code ?? null, [componentConfig.settings?.html_code]);
7347
- useEffect14(() => {
7390
+ useEffect15(() => {
7348
7391
  const container = containerRef.current;
7349
7392
  if (htmlCode && container && executedCodeRef.current !== htmlCode) {
7350
7393
  const timerId = setTimeout(() => {
@@ -7380,20 +7423,20 @@ CustomCodeBlock.displayName = "CustomCodeBlock";
7380
7423
 
7381
7424
  // src/smart-cart/components/DiscountCodeInput/DiscountCodeInput.tsx
7382
7425
  import clsx8 from "clsx";
7383
- import React7, { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo16, useRef as useRef9, useState as useState17 } from "react";
7426
+ import React7, { useCallback as useCallback12, useEffect as useEffect17, useMemo as useMemo16, useRef as useRef9, useState as useState18 } from "react";
7384
7427
  import { useFetcher as useFetcher4 } from "react-router";
7385
7428
 
7386
7429
  // src/smart-cart/hooks/useDiscountManager.ts
7387
- import { useCallback as useCallback11, useEffect as useEffect15, useMemo as useMemo15, useState as useState16 } from "react";
7430
+ import { useCallback as useCallback11, useEffect as useEffect16, useMemo as useMemo15, useState as useState17 } from "react";
7388
7431
  var GENERIC_ERROR_CODE_MESSAGE = "{{code}} is not valid for this cart.";
7389
7432
  var useDiscountManager = () => {
7390
7433
  const { cartData, error: cartErrorFromCtx, getComponentConfigByType } = useSmartCart();
7391
- const [isProcessing, setIsProcessing] = useState16(false);
7392
- const [currentError, setCurrentError] = useState16(null);
7393
- const [appliedCodesState, setAppliedCodesState] = useState16([]);
7434
+ const [isProcessing, setIsProcessing] = useState17(false);
7435
+ const [currentError, setCurrentError] = useState17(null);
7436
+ const [appliedCodesState, setAppliedCodesState] = useState17([]);
7394
7437
  const componentConfig = useMemo15(() => getComponentConfigByType("discount_code"), [getComponentConfigByType]);
7395
7438
  const settings = useMemo15(() => componentConfig?.settings ?? null, [componentConfig]);
7396
- useEffect15(() => {
7439
+ useEffect16(() => {
7397
7440
  const codesFromApi = cartData?.discountCodes?.filter((dc) => dc.applicable).map((dc) => dc.code) ?? [];
7398
7441
  if (JSON.stringify(codesFromApi) !== JSON.stringify(appliedCodesState)) {
7399
7442
  setAppliedCodesState(codesFromApi);
@@ -7487,9 +7530,9 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
7487
7530
  setIsProcessing: setDiscountManagerIsProcessing,
7488
7531
  settings
7489
7532
  } = useDiscountManager();
7490
- const [inputValue, setInputValue] = useState17("");
7491
- const [isInputFocused, setIsInputFocused] = useState17(false);
7492
- const [isLocallyProcessing, setIsLocallyProcessing] = useState17(false);
7533
+ const [inputValue, setInputValue] = useState18("");
7534
+ const [isInputFocused, setIsInputFocused] = useState18(false);
7535
+ const [isLocallyProcessing, setIsLocallyProcessing] = useState18(false);
7493
7536
  const inputRef = useRef9(null);
7494
7537
  const hasItems = getItemCount() > 0;
7495
7538
  const lang = useMemo16(
@@ -7586,7 +7629,7 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
7586
7629
  setDiscountManagerError
7587
7630
  ]
7588
7631
  );
7589
- useEffect16(() => {
7632
+ useEffect17(() => {
7590
7633
  if (isHydrogenReact) {
7591
7634
  if (!isGlobalCartLoading && isLocallyProcessing) {
7592
7635
  setIsLocallyProcessing(false);
@@ -7753,10 +7796,10 @@ var LoginButton = React8.memo(() => {
7753
7796
  LoginButton.displayName = "LoginButton";
7754
7797
 
7755
7798
  // src/smart-cart/components/SmartCartApp/SmartCartApp.tsx
7756
- import React9, { useEffect as useEffect18, useMemo as useMemo17, useRef as useRef10 } from "react";
7799
+ import React9, { useEffect as useEffect19, useMemo as useMemo17, useRef as useRef10 } from "react";
7757
7800
 
7758
7801
  // src/smart-cart/hooks/useSmartCartApps.ts
7759
- import { useEffect as useEffect17, useState as useState18 } from "react";
7802
+ import { useEffect as useEffect18, useState as useState19 } from "react";
7760
7803
 
7761
7804
  // src/smart-cart/types/smart-cart-app.ts
7762
7805
  import { z as z2 } from "zod";
@@ -7778,11 +7821,11 @@ var smartCartAppMerchantConfigSchema = z2.object({
7778
7821
  // src/smart-cart/hooks/useSmartCartApps.ts
7779
7822
  var useSmartCartApps = () => {
7780
7823
  const { apiKey, cacheKey, config, shopifyDomain } = useSmartCart();
7781
- const [enrichedApps, setEnrichedApps] = useState18(/* @__PURE__ */ new Map());
7782
- const [isLoading, setIsLoading] = useState18(false);
7783
- const [error, setError] = useState18(null);
7824
+ const [enrichedApps, setEnrichedApps] = useState19(/* @__PURE__ */ new Map());
7825
+ const [isLoading, setIsLoading] = useState19(false);
7826
+ const [error, setError] = useState19(null);
7784
7827
  const initialAppsConfig = config?.apps;
7785
- useEffect17(() => {
7828
+ useEffect18(() => {
7786
7829
  let isMounted = true;
7787
7830
  const fetchAndEnrichApps = async () => {
7788
7831
  if (!initialAppsConfig || initialAppsConfig.length === 0) {
@@ -7975,7 +8018,7 @@ var SmartCartApp = React9.memo(({ componentConfig }) => {
7975
8018
  const appData = appId !== null ? enrichedApps.get(appId) : null;
7976
8019
  const enabledAppData = appData?.enabled ? appData : null;
7977
8020
  const scriptContent = enabledAppData?.script ?? null;
7978
- useEffect18(() => {
8021
+ useEffect19(() => {
7979
8022
  const container = containerRef.current;
7980
8023
  if (container && scriptContent && executedScriptRef.current !== scriptContent) {
7981
8024
  const timerId = setTimeout(() => {
@@ -8030,7 +8073,7 @@ SmartCartApp.displayName = "SmartCartApp";
8030
8073
 
8031
8074
  // src/smart-cart/components/TieredProgressBar/TieredProgressBar.tsx
8032
8075
  import clsx10 from "clsx";
8033
- import React10, { useCallback as useCallback13, useEffect as useEffect19, useMemo as useMemo18, useState as useState19 } from "react";
8076
+ import React10, { useCallback as useCallback13, useEffect as useEffect20, useMemo as useMemo18, useState as useState20 } from "react";
8034
8077
  import { useFetcher as useFetcher5 } from "react-router";
8035
8078
  import { useShallow as useShallow2 } from "zustand/shallow";
8036
8079
 
@@ -8238,7 +8281,7 @@ import { jsx as jsx36, jsxs as jsxs20 } from "react/jsx-runtime";
8238
8281
  var TieredProgressBar = React10.memo(() => {
8239
8282
  const { hydrogenReactCartActions, isCartBusy, isHydrogenReact } = useSmartCart();
8240
8283
  const tpbUserActionFetcher = useFetcher5();
8241
- const [showDebugPanel, setShowDebugPanel] = useState19(false);
8284
+ const [showDebugPanel, setShowDebugPanel] = useState20(false);
8242
8285
  const {
8243
8286
  _lastFetchedBarId,
8244
8287
  activeBarConfig,
@@ -8283,7 +8326,7 @@ var TieredProgressBar = React10.memo(() => {
8283
8326
  const shouldDisableGiftActions = useMemo18(() => {
8284
8327
  return isCartBusy || productFetchStatus === "loading";
8285
8328
  }, [isCartBusy, productFetchStatus]);
8286
- useEffect19(() => {
8329
+ useEffect20(() => {
8287
8330
  if (isHydrogenReact) {
8288
8331
  const hReactLinesAdd = hydrogenReactCartActions?.linesAdd;
8289
8332
  const hReactLinesRemove = hydrogenReactCartActions?.linesRemove;
@@ -8324,7 +8367,7 @@ var TieredProgressBar = React10.memo(() => {
8324
8367
  rebuyDebugLog.log("smart-cart-tpb" /* SC_TPB */, "Set Remix fetcher submit functions for TPB.");
8325
8368
  }
8326
8369
  }, [isHydrogenReact, hydrogenReactCartActions, tpbUserActionFetcher, setSubmitFunctions]);
8327
- useEffect19(() => {
8370
+ useEffect20(() => {
8328
8371
  if (userActionError) {
8329
8372
  const timer = setTimeout(() => clearUserActionError(), 5e3);
8330
8373
  return () => clearTimeout(timer);
@@ -8644,10 +8687,10 @@ import clsx11 from "clsx";
8644
8687
  import { useRef as useRef11 } from "react";
8645
8688
 
8646
8689
  // src/smart-cart/hooks/useIsScrolled.ts
8647
- import { useEffect as useEffect20, useState as useState20 } from "react";
8690
+ import { useEffect as useEffect21, useState as useState21 } from "react";
8648
8691
  var useIsScrolled = (scrollElementRef) => {
8649
- const [isScrolled, setIsScrolled] = useState20(false);
8650
- useEffect20(() => {
8692
+ const [isScrolled, setIsScrolled] = useState21(false);
8693
+ useEffect21(() => {
8651
8694
  const scrollElement = scrollElementRef.current;
8652
8695
  if (!scrollElement) return;
8653
8696
  const handleScroll = () => {
@@ -8760,7 +8803,7 @@ var SmartCartContainer = ({ containerId }) => {
8760
8803
  previousFocusRef.current.focus();
8761
8804
  }
8762
8805
  }, [hideCart]);
8763
- useEffect21(() => {
8806
+ useEffect22(() => {
8764
8807
  if (isVisible) {
8765
8808
  previousFocusRef.current = document.activeElement;
8766
8809
  const closeButton = containerRef.current?.querySelector("#rebuy-cart-close");
@@ -8769,7 +8812,7 @@ var SmartCartContainer = ({ containerId }) => {
8769
8812
  }
8770
8813
  }
8771
8814
  }, [isVisible]);
8772
- useEffect21(() => {
8815
+ useEffect22(() => {
8773
8816
  if (isVisible) {
8774
8817
  document.body.classList.add("rebuy-smart-cart-open");
8775
8818
  } else {
@@ -8860,19 +8903,41 @@ var RebuySmartCart = () => {
8860
8903
  import { RebuyClient as RebuyClient3 } from "@rebuy/rebuy";
8861
8904
  import * as Utilities5 from "@rebuy/rebuy/utilities";
8862
8905
  import { flattenConnection as flattenConnection4 } from "@shopify/hydrogen";
8863
- import React12, { useContext as useContext4, useEffect as useEffect22, useMemo as useMemo21, useState as useState21 } from "react";
8906
+ import { useContext as useContext5, useEffect as useEffect23, useMemo as useMemo21, useState as useState22 } from "react";
8907
+
8908
+ // src/context/RebuyWidgetContext.tsx
8909
+ import { createContext as createContext4, useContext as useContext4 } from "react";
8910
+ import { jsx as jsx43 } from "react/jsx-runtime";
8911
+ var RebuyWidgetContext = createContext4({
8912
+ dataSource: "",
8913
+ isHydrogenReact: false,
8914
+ key: "",
8915
+ limit: 0,
8916
+ metadata: {},
8917
+ options: {},
8918
+ products: [],
8919
+ variant: void 0,
8920
+ variantId: void 0
8921
+ });
8922
+ var useRebuyWidget = () => useContext4(RebuyWidgetContext);
8923
+ var RebuyWidgetProvider = ({ children, value }) => {
8924
+ return /* @__PURE__ */ jsx43(RebuyWidgetContext.Provider, { value, children });
8925
+ };
8926
+
8927
+ // src/widgetContainer/RebuyWidgetContainer.tsx
8928
+ import { jsx as jsx44 } from "react/jsx-runtime";
8864
8929
  var RebuyWidgetContainerBase = ({ children, ...props }) => {
8865
8930
  const { collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
8866
8931
  const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
8867
- const rebuyContext = useContext4(RebuyContext);
8868
- const [rebuyApiClient, setRebuyApiClient] = useState21(null);
8869
- const [initialized, setInitialized] = useState21(false);
8932
+ const rebuyContext = useContext5(RebuyContext);
8933
+ const [rebuyApiClient, setRebuyApiClient] = useState22(null);
8934
+ const [initialized, setInitialized] = useState22(false);
8870
8935
  const shopifyProductId = product?.id ?? productId ?? null;
8871
8936
  const shopifyVariantId = variant?.id ?? variantId ?? null;
8872
8937
  const shopifyCollectionId = collection?.id ?? collectionId ?? null;
8873
- const [products, setProducts] = useState21([]);
8874
- const [metadata, setMetadata] = useState21();
8875
- useEffect22(() => {
8938
+ const [products, setProducts] = useState22([]);
8939
+ const [metadata, setMetadata] = useState22();
8940
+ useEffect23(() => {
8876
8941
  if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
8877
8942
  const client = new RebuyClient3(apiKey);
8878
8943
  const currentEndpoint = dataSource || "/api/v1/products/recommended";
@@ -8887,7 +8952,7 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
8887
8952
  setInitialized(true);
8888
8953
  }
8889
8954
  }, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, dataSource]);
8890
- useEffect22(() => {
8955
+ useEffect23(() => {
8891
8956
  if (rebuyApiClient && rebuyContext?.contextParameters) {
8892
8957
  const currentEndpoint = dataSource || "/api/v1/products/recommended";
8893
8958
  const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, currentEndpoint);
@@ -8914,7 +8979,7 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
8914
8979
  }
8915
8980
  return req;
8916
8981
  }, [dataSource, shopifyProductId, shopifyVariantId, shopifyCollectionId, limit]);
8917
- useEffect22(() => {
8982
+ useEffect23(() => {
8918
8983
  let isMounted = true;
8919
8984
  if (!rebuyApiClient || !initialized || configLoadingStatus !== "success") return;
8920
8985
  const fetchData = async () => {
@@ -8947,23 +9012,30 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
8947
9012
  isMounted = false;
8948
9013
  };
8949
9014
  }, [rebuyApiClient, initialized, request, configLoadingStatus]);
8950
- const childrenWithProps = (currentProps) => React12.Children.map(
8951
- children,
8952
- (child) => React12.isValidElement(child) ? React12.cloneElement(child, currentProps) : child
8953
- );
8954
- const childProps = {
8955
- ...props,
8956
- apiKey,
8957
- cacheKey: rebuyConfig?.shop?.cache_key,
8958
- isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact,
8959
- key: product?.id,
8960
- metadata,
8961
- products
8962
- };
8963
9015
  if (configLoadingStatus !== "success" || !rebuyApiClient) {
8964
9016
  return null;
8965
9017
  }
8966
- return childrenWithProps(childProps);
9018
+ return /* @__PURE__ */ jsx44(
9019
+ RebuyWidgetProvider,
9020
+ {
9021
+ value: {
9022
+ apiKey: apiKey ?? void 0,
9023
+ cacheKey: rebuyConfig?.shop?.cache_key,
9024
+ dataSource: dataSource || "/api/v1/products/recommended",
9025
+ isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact || false,
9026
+ key: product?.id || "",
9027
+ limit: limit || 0,
9028
+ metadata: metadata || {},
9029
+ options: options || {},
9030
+ product,
9031
+ productId,
9032
+ products,
9033
+ variant,
9034
+ variantId
9035
+ },
9036
+ children
9037
+ }
9038
+ );
8967
9039
  };
8968
9040
  var RebuyWidgetContainer = RebuyWidgetContainerBase;
8969
9041
 
@@ -8972,37 +9044,38 @@ var result23 = { "container": "RebuyCompleteTheLook_container", "productGrid": "
8972
9044
  var RebuyCompleteTheLook_default = result23;
8973
9045
 
8974
9046
  // src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx
8975
- import { jsx as jsx43, jsxs as jsxs25 } from "react/jsx-runtime";
9047
+ import { jsx as jsx45, jsxs as jsxs25 } from "react/jsx-runtime";
8976
9048
  var RebuyCompleteTheLook = (props) => {
8977
9049
  const {
8978
9050
  addToCartBtnText = "Add to cart",
8979
9051
  addToCartCallback,
8980
- customTitle = `These pair with ${props.product?.title}`,
9052
+ customTitle = `These pair with {product_title}`,
8981
9053
  customTitleLevel = "h2",
8982
- customTitleStyle,
8983
- products = []
9054
+ customTitleStyle
8984
9055
  } = props;
9056
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9057
+ const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
8985
9058
  if (products.length === 0) {
8986
9059
  rebuyDebugLog.log("widget-complete-the-look" /* WIDGET_COMPLETE_THE_LOOK */, "RebuyCompleteTheLook: No products found");
8987
9060
  return null;
8988
9061
  }
8989
9062
  return /* @__PURE__ */ jsxs25("section", { className: RebuyCompleteTheLook_default.container, children: [
8990
- /* @__PURE__ */ jsx43(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
8991
- /* @__PURE__ */ jsx43("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product) => /* @__PURE__ */ jsx43("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ jsx43(
9063
+ /* @__PURE__ */ jsx45(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
9064
+ /* @__PURE__ */ jsx45("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product2) => /* @__PURE__ */ jsx45("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ jsx45(
8992
9065
  ProductCard,
8993
9066
  {
8994
9067
  addToCartBtnText,
8995
9068
  addToCartCallback,
8996
- isHydrogenReact: props.isHydrogenReact,
8997
- product,
9069
+ isHydrogenReact,
9070
+ product: product2,
8998
9071
  productCardTitleLevel: getTitleLevel(customTitleLevel, true)
8999
9072
  }
9000
- ) }, product.id)) })
9073
+ ) }, product2.id)) })
9001
9074
  ] });
9002
9075
  };
9003
9076
 
9004
9077
  // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
9005
- import { useCallback as useCallback15, useEffect as useEffect23, useState as useState22 } from "react";
9078
+ import { useCallback as useCallback15, useEffect as useEffect24, useState as useState23 } from "react";
9006
9079
 
9007
9080
  // src/utils/convertToRebuyProduct.tsx
9008
9081
  var convertToRebuyProduct = (isHydrogenReact, product) => {
@@ -9261,12 +9334,12 @@ var result24 = { "container": "RebuyDynamicBundleProducts_container", "addCartBt
9261
9334
  var RebuyDynamicBundleProducts_default = result24;
9262
9335
 
9263
9336
  // src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
9264
- import { Fragment as Fragment12, jsx as jsx44, jsxs as jsxs26 } from "react/jsx-runtime";
9337
+ import { Fragment as Fragment12, jsx as jsx46, jsxs as jsxs26 } from "react/jsx-runtime";
9265
9338
  var BundleImages = ({ products }) => {
9266
9339
  const selected = products.filter((product) => product.selected);
9267
- return /* @__PURE__ */ jsx44("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
9340
+ return /* @__PURE__ */ jsx46("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
9268
9341
  const image = product.selectedVariant?.image;
9269
- const productImage = image ? /* @__PURE__ */ jsx44(
9342
+ const productImage = image ? /* @__PURE__ */ jsx46(
9270
9343
  Image2,
9271
9344
  {
9272
9345
  alt: image.altText || `Picture of ${product.title}`,
@@ -9281,14 +9354,14 @@ var BundleImages = ({ products }) => {
9281
9354
  product.title
9282
9355
  );
9283
9356
  const showDelimiter = selected[0]?.id !== product.id;
9284
- return /* @__PURE__ */ jsx44(Fragment11, { children: product.selected && /* @__PURE__ */ jsxs26(Fragment12, { children: [
9285
- showDelimiter && /* @__PURE__ */ jsx44("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ jsx44("span", { children: "+" }) }),
9286
- /* @__PURE__ */ jsx44("li", { className: "flex items-center", children: product.default ? (
9357
+ return /* @__PURE__ */ jsx46(Fragment11, { children: product.selected && /* @__PURE__ */ jsxs26(Fragment12, { children: [
9358
+ showDelimiter && /* @__PURE__ */ jsx46("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ jsx46("span", { children: "+" }) }),
9359
+ /* @__PURE__ */ jsx46("li", { className: "flex items-center", children: product.default ? (
9287
9360
  // Already on product page
9288
9361
  productImage
9289
9362
  ) : (
9290
9363
  // Link to product
9291
- /* @__PURE__ */ jsx44(
9364
+ /* @__PURE__ */ jsx46(
9292
9365
  RebuyLink,
9293
9366
  {
9294
9367
  ariaLabel: `View ${product.title}`,
@@ -9303,7 +9376,7 @@ var BundleImages = ({ products }) => {
9303
9376
 
9304
9377
  // src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
9305
9378
  import { Money as Money4 } from "@shopify/hydrogen";
9306
- import { jsx as jsx45, jsxs as jsxs27 } from "react/jsx-runtime";
9379
+ import { jsx as jsx47, jsxs as jsxs27 } from "react/jsx-runtime";
9307
9380
  var BundlePrice = ({ products }) => {
9308
9381
  const isDisabled = products.filter((product) => product.selected).length < 1;
9309
9382
  const totalBundlePrice = () => {
@@ -9340,12 +9413,12 @@ var BundlePrice = ({ products }) => {
9340
9413
  const price = totalBundlePrice();
9341
9414
  const compareAtPrice = totalBundleCompareAtPrice();
9342
9415
  const CompareAtPrice = ({ data: compareAtPrice2 }) => {
9343
- return compareAtPrice2 && /* @__PURE__ */ jsx45(Money4, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
9416
+ return compareAtPrice2 && /* @__PURE__ */ jsx47(Money4, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
9344
9417
  };
9345
- return products.length > 0 && /* @__PURE__ */ jsx45("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ jsxs27("p", { className: "flex items-center gap-2 mb-2", children: [
9346
- /* @__PURE__ */ jsx45("span", { children: "Total Price:" }),
9347
- /* @__PURE__ */ jsx45(Money4, { as: "span", data: price, withoutTrailingZeros: true }),
9348
- isDiscounted(price, compareAtPrice) && /* @__PURE__ */ jsx45(CompareAtPrice, { data: compareAtPrice })
9418
+ return products.length > 0 && /* @__PURE__ */ jsx47("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ jsxs27("p", { className: "flex items-center gap-2 mb-2", children: [
9419
+ /* @__PURE__ */ jsx47("span", { children: "Total Price:" }),
9420
+ /* @__PURE__ */ jsx47(Money4, { as: "span", data: price, withoutTrailingZeros: true }),
9421
+ isDiscounted(price, compareAtPrice) && /* @__PURE__ */ jsx47(CompareAtPrice, { data: compareAtPrice })
9349
9422
  ] }) });
9350
9423
  };
9351
9424
 
@@ -9353,7 +9426,7 @@ var BundlePrice = ({ products }) => {
9353
9426
  import clsx14 from "clsx";
9354
9427
 
9355
9428
  // src/widgets/RebuyDynamicBundleProducts/Select.tsx
9356
- import { jsx as jsx46 } from "react/jsx-runtime";
9429
+ import { jsx as jsx48 } from "react/jsx-runtime";
9357
9430
  var Select = ({ onSelectVariant, product }) => {
9358
9431
  const getOptionsLabel = (product2) => {
9359
9432
  const options = product2.variants.nodes[0].selectedOptions;
@@ -9362,30 +9435,30 @@ var Select = ({ onSelectVariant, product }) => {
9362
9435
  const useValues = optionsFromKeys.every((key) => ["name", "value"].includes(key));
9363
9436
  return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
9364
9437
  };
9365
- return product && /* @__PURE__ */ jsx46(
9438
+ return product && /* @__PURE__ */ jsx48(
9366
9439
  "select",
9367
9440
  {
9368
9441
  "aria-label": "select variant",
9369
9442
  className: RebuyDynamicBundleProducts_default.select,
9370
9443
  onChange: (e) => onSelectVariant(product, e.target.value),
9371
9444
  value: product.selectedVariant.id,
9372
- children: /* @__PURE__ */ jsx46("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ jsx46("option", { value: id, children: title }, id + "-BundleVariant")) })
9445
+ children: /* @__PURE__ */ jsx48("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ jsx48("option", { value: id, children: title }, id + "-BundleVariant")) })
9373
9446
  }
9374
9447
  );
9375
9448
  };
9376
9449
 
9377
9450
  // src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
9378
- import { jsx as jsx47, jsxs as jsxs28 } from "react/jsx-runtime";
9451
+ import { jsx as jsx49, jsxs as jsxs28 } from "react/jsx-runtime";
9379
9452
  var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
9380
- return /* @__PURE__ */ jsx47("ul", { children: products.map((product, index) => {
9453
+ return /* @__PURE__ */ jsx49("ul", { children: products.map((product, index) => {
9381
9454
  const { availableForSale } = product.selectedVariant;
9382
9455
  const isOutOfStock = !availableForSale;
9383
- return /* @__PURE__ */ jsx47(
9456
+ return /* @__PURE__ */ jsx49(
9384
9457
  "li",
9385
9458
  {
9386
9459
  className: clsx14(RebuyDynamicBundleProducts_default.bundleItemRowContainer, !product.selected && RebuyDynamicBundleProducts_default.unselected),
9387
9460
  children: /* @__PURE__ */ jsxs28("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
9388
- /* @__PURE__ */ jsx47(
9461
+ /* @__PURE__ */ jsx49(
9389
9462
  "input",
9390
9463
  {
9391
9464
  checked: product.selected && availableForSale,
@@ -9399,12 +9472,12 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
9399
9472
  ),
9400
9473
  /* @__PURE__ */ jsxs28("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
9401
9474
  /* @__PURE__ */ jsxs28("label", { className: RebuyDynamicBundleProducts_default.bundleItemLabel, htmlFor: `${product.id}-toggle`, children: [
9402
- isOutOfStock && /* @__PURE__ */ jsx47("b", { children: "SOLD OUT" }),
9403
- product.default && /* @__PURE__ */ jsx47("b", { children: "This item:" }),
9475
+ isOutOfStock && /* @__PURE__ */ jsx49("b", { children: "SOLD OUT" }),
9476
+ product.default && /* @__PURE__ */ jsx49("b", { children: "This item:" }),
9404
9477
  product.title,
9405
- /* @__PURE__ */ jsx47(RebuyProductPrice, { selectedVariant: product.selectedVariant })
9478
+ /* @__PURE__ */ jsx49(RebuyProductPrice, { selectedVariant: product.selectedVariant })
9406
9479
  ] }),
9407
- product.variants.nodes.length > 1 && /* @__PURE__ */ jsx47(Select, { onSelectVariant, product })
9480
+ product.variants.nodes.length > 1 && /* @__PURE__ */ jsx49(Select, { onSelectVariant, product })
9408
9481
  ] })
9409
9482
  ] })
9410
9483
  },
@@ -9414,20 +9487,19 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
9414
9487
  };
9415
9488
 
9416
9489
  // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
9417
- import { jsx as jsx48, jsxs as jsxs29 } from "react/jsx-runtime";
9490
+ import { jsx as jsx50, jsxs as jsxs29 } from "react/jsx-runtime";
9418
9491
  var RebuyDynamicBundleProducts = (props) => {
9419
9492
  const {
9420
9493
  addToCartBtnText = "Add to cart",
9421
9494
  addToCartCallback,
9422
- customTitle = `These pair with ${props.product?.title}`,
9495
+ customTitle = `These pair with {product_title}`,
9423
9496
  customTitleLevel = "h2",
9424
- customTitleStyle,
9425
- isHydrogenReact,
9426
- product,
9427
- products = []
9497
+ customTitleStyle
9428
9498
  } = props;
9429
- const [bundleProducts, setBundleProducts] = useState22([]);
9430
- useEffect23(() => {
9499
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9500
+ const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
9501
+ const [bundleProducts, setBundleProducts] = useState23([]);
9502
+ useEffect24(() => {
9431
9503
  const mainProduct = convertToRebuyProduct(isHydrogenReact || false, product);
9432
9504
  const formattedProducts = products.map((product2) => {
9433
9505
  return {
@@ -9461,11 +9533,11 @@ var RebuyDynamicBundleProducts = (props) => {
9461
9533
  return null;
9462
9534
  }
9463
9535
  return /* @__PURE__ */ jsxs29("section", { className: RebuyDynamicBundleProducts_default.container, children: [
9464
- /* @__PURE__ */ jsx48(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9536
+ /* @__PURE__ */ jsx50(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
9465
9537
  /* @__PURE__ */ jsxs29("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
9466
- /* @__PURE__ */ jsx48(BundleImages, { products: bundleProducts }),
9467
- /* @__PURE__ */ jsx48(BundlePrice, { products: bundleProducts }),
9468
- /* @__PURE__ */ jsx48("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ jsx48(
9538
+ /* @__PURE__ */ jsx50(BundleImages, { products: bundleProducts }),
9539
+ /* @__PURE__ */ jsx50(BundlePrice, { products: bundleProducts }),
9540
+ /* @__PURE__ */ jsx50("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ jsx50(
9469
9541
  AddToCartBtn,
9470
9542
  {
9471
9543
  addToCartBtnText,
@@ -9477,7 +9549,7 @@ var RebuyDynamicBundleProducts = (props) => {
9477
9549
  })
9478
9550
  }
9479
9551
  ) }),
9480
- /* @__PURE__ */ jsx48(
9552
+ /* @__PURE__ */ jsx50(
9481
9553
  BundleSelection,
9482
9554
  {
9483
9555
  onSelectVariant,
@@ -9491,7 +9563,7 @@ var RebuyDynamicBundleProducts = (props) => {
9491
9563
 
9492
9564
  // src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
9493
9565
  import { Money as Money5 } from "@shopify/hydrogen-react";
9494
- import { useCallback as useCallback16, useEffect as useEffect24, useState as useState23 } from "react";
9566
+ import { useCallback as useCallback16, useEffect as useEffect25, useState as useState24 } from "react";
9495
9567
 
9496
9568
  // src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
9497
9569
  import { Image as Image3 } from "@shopify/hydrogen";
@@ -9501,7 +9573,7 @@ var result25 = { "container": "RebuyProductAddOns_container", "productAddOnsList
9501
9573
  var RebuyProductAddOns_default = result25;
9502
9574
 
9503
9575
  // src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
9504
- import { jsx as jsx49, jsxs as jsxs30 } from "react/jsx-runtime";
9576
+ import { jsx as jsx51, jsxs as jsxs30 } from "react/jsx-runtime";
9505
9577
  var RebuyProductAddOnCard = ({
9506
9578
  handleChange,
9507
9579
  learnMoreText,
@@ -9510,8 +9582,8 @@ var RebuyProductAddOnCard = ({
9510
9582
  titleLevel
9511
9583
  }) => {
9512
9584
  const { availableForSale, image } = product.selectedVariant || {};
9513
- return /* @__PURE__ */ jsx49("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ jsxs30("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
9514
- /* @__PURE__ */ jsx49(
9585
+ return /* @__PURE__ */ jsx51("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ jsxs30("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
9586
+ /* @__PURE__ */ jsx51(
9515
9587
  "input",
9516
9588
  {
9517
9589
  checked: Boolean(product.selected),
@@ -9524,7 +9596,7 @@ var RebuyProductAddOnCard = ({
9524
9596
  value: ""
9525
9597
  }
9526
9598
  ),
9527
- /* @__PURE__ */ jsx49("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ jsx49(
9599
+ /* @__PURE__ */ jsx51("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ jsx51(
9528
9600
  Image3,
9529
9601
  {
9530
9602
  alt: image.altText || `Picture of ${product.title}`,
@@ -9534,10 +9606,10 @@ var RebuyProductAddOnCard = ({
9534
9606
  }
9535
9607
  ) }),
9536
9608
  /* @__PURE__ */ jsxs30("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
9537
- !availableForSale && /* @__PURE__ */ jsx49("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
9538
- /* @__PURE__ */ jsx49(Title, { level: titleLevel, text: product.title }),
9539
- /* @__PURE__ */ jsx49(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
9540
- /* @__PURE__ */ jsx49(
9609
+ !availableForSale && /* @__PURE__ */ jsx51("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
9610
+ /* @__PURE__ */ jsx51(Title, { level: titleLevel, text: product.title }),
9611
+ /* @__PURE__ */ jsx51(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
9612
+ /* @__PURE__ */ jsx51(
9541
9613
  RebuyLink,
9542
9614
  {
9543
9615
  ariaLabel: `View ${product.title}`,
@@ -9551,28 +9623,28 @@ var RebuyProductAddOnCard = ({
9551
9623
  };
9552
9624
 
9553
9625
  // src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
9554
- import { jsx as jsx50, jsxs as jsxs31 } from "react/jsx-runtime";
9626
+ import { jsx as jsx52, jsxs as jsxs31 } from "react/jsx-runtime";
9555
9627
  var RebuyProductAddOns = (props) => {
9556
9628
  const {
9629
+ addToCartBtnText = "Add to cart",
9557
9630
  addToCartCallback,
9558
- customTitle = `These pair with ${props.product?.title}`,
9631
+ customTitle = `These pair with {product_title}`,
9559
9632
  customTitleLevel = "h2",
9560
9633
  customTitleStyle,
9561
9634
  includeMainProduct = false,
9562
- isHydrogenReact,
9563
9635
  learnMoreText = "Learn more",
9564
9636
  outOfStockText = "Out of stock",
9565
- product,
9566
- products = [],
9567
- addToCartBtnText = "Add to cart",
9568
9637
  subtotalText = "Add-ons Subtotal: ",
9569
- withProductText = `With ${product?.title}: `
9638
+ withProductText = `With {product_title}: `
9570
9639
  } = props;
9571
- const [addedItems, setAddedItems] = useState23(products);
9572
- const [subtotalWithProduct, setSubtotalWithProduct] = useState23();
9573
- const [subtotalWithOutProduct, setSubtotalWithOutProduct] = useState23();
9640
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9641
+ const productTitleClean = customTitle.replace("{product_title}", product?.title ?? "");
9642
+ const withProductTextClean = withProductText.replace("{product_title}", product?.title ?? "");
9643
+ const [addedItems, setAddedItems] = useState24(products);
9644
+ const [subtotalWithProduct, setSubtotalWithProduct] = useState24();
9645
+ const [subtotalWithOutProduct, setSubtotalWithOutProduct] = useState24();
9574
9646
  const convertedProduct = convertToRebuyProduct(isHydrogenReact || false, product);
9575
- useEffect24(() => {
9647
+ useEffect25(() => {
9576
9648
  let initialTotal = 0;
9577
9649
  let currencyCode = "USD";
9578
9650
  products.map((product2) => {
@@ -9621,7 +9693,7 @@ var RebuyProductAddOns = (props) => {
9621
9693
  },
9622
9694
  [products]
9623
9695
  );
9624
- useEffect24(() => {
9696
+ useEffect25(() => {
9625
9697
  let total = 0;
9626
9698
  let currencyCode = "USD";
9627
9699
  addedItems.forEach((item) => {
@@ -9648,8 +9720,8 @@ var RebuyProductAddOns = (props) => {
9648
9720
  return null;
9649
9721
  }
9650
9722
  return /* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.container, children: [
9651
- /* @__PURE__ */ jsx50(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9652
- /* @__PURE__ */ jsx50("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ jsx50("li", { children: /* @__PURE__ */ jsx50(
9723
+ /* @__PURE__ */ jsx52(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitleClean }),
9724
+ /* @__PURE__ */ jsx52("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ jsx52("li", { children: /* @__PURE__ */ jsx52(
9653
9725
  RebuyProductAddOnCard,
9654
9726
  {
9655
9727
  handleChange,
@@ -9662,13 +9734,13 @@ var RebuyProductAddOns = (props) => {
9662
9734
  /* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
9663
9735
  /* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
9664
9736
  subtotalText,
9665
- subtotalWithOutProduct && /* @__PURE__ */ jsx50(Money5, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
9737
+ subtotalWithOutProduct && /* @__PURE__ */ jsx52(Money5, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
9666
9738
  ] }),
9667
9739
  includeMainProduct && /* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
9668
- withProductText,
9669
- subtotalWithProduct && /* @__PURE__ */ jsx50(Money5, { data: subtotalWithProduct, withoutTrailingZeros: true })
9740
+ withProductTextClean,
9741
+ subtotalWithProduct && /* @__PURE__ */ jsx52(Money5, { data: subtotalWithProduct, withoutTrailingZeros: true })
9670
9742
  ] }),
9671
- /* @__PURE__ */ jsx50("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ jsx50(
9743
+ /* @__PURE__ */ jsx52("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ jsx52(
9672
9744
  AddToCartBtn,
9673
9745
  {
9674
9746
  addToCartBtnText,
@@ -9678,7 +9750,7 @@ var RebuyProductAddOns = (props) => {
9678
9750
  moneyData: subtotalWithProduct,
9679
9751
  selectedVariants: addedItems.map((item) => item.selectedVariant)
9680
9752
  }
9681
- ) : /* @__PURE__ */ jsx50(
9753
+ ) : /* @__PURE__ */ jsx52(
9682
9754
  AddToCartBtn,
9683
9755
  {
9684
9756
  addToCartBtnText,
@@ -9698,39 +9770,40 @@ var result26 = { "container": "RebuyProductRecommendations_container", "productG
9698
9770
  var RebuyProductRecommendations_default = result26;
9699
9771
 
9700
9772
  // src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx
9701
- import { jsx as jsx51, jsxs as jsxs32 } from "react/jsx-runtime";
9773
+ import { jsx as jsx53, jsxs as jsxs32 } from "react/jsx-runtime";
9702
9774
  var RebuyProductRecommendations = (props) => {
9703
9775
  const {
9704
9776
  addToCartBtnText = "Add to cart",
9705
9777
  addToCartCallback,
9706
- customTitle = `These pair with ${props.product?.title}`,
9778
+ customTitle = `These pair with {product_title}`,
9707
9779
  customTitleLevel = "h2",
9708
- customTitleStyle,
9709
- products = []
9780
+ customTitleStyle
9710
9781
  } = props;
9782
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9783
+ const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
9711
9784
  if (products.length === 0) {
9712
9785
  rebuyDebugLog.log("widget-product-recommendations" /* WIDGET_PRODUCT_RECOMMENDATIONS */, "RebuyProductRecommendations: No products found");
9713
9786
  return null;
9714
9787
  }
9715
9788
  return /* @__PURE__ */ jsxs32("section", { className: RebuyProductRecommendations_default.container, children: [
9716
- /* @__PURE__ */ jsx51(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9717
- /* @__PURE__ */ jsx51("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product) => /* @__PURE__ */ jsx51("li", { children: /* @__PURE__ */ jsx51(
9789
+ /* @__PURE__ */ jsx53(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
9790
+ /* @__PURE__ */ jsx53("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product2) => /* @__PURE__ */ jsx53("li", { children: /* @__PURE__ */ jsx53(
9718
9791
  ProductCard,
9719
9792
  {
9720
9793
  addToCartBtnText,
9721
9794
  addToCartCallback,
9722
- isHydrogenReact: props.isHydrogenReact,
9723
- product,
9795
+ isHydrogenReact,
9796
+ product: product2,
9724
9797
  productCardTitleLevel: getTitleLevel(customTitleLevel, true)
9725
9798
  }
9726
- ) }, product.id)) })
9799
+ ) }, product2.id)) })
9727
9800
  ] });
9728
9801
  };
9729
9802
 
9730
9803
  // src/widgets/RebuyProductViewed/RebuyProductViewed.tsx
9731
9804
  import { RebuyClient as RebuyClient4 } from "@rebuy/rebuy";
9732
9805
  import * as Utilities6 from "@rebuy/rebuy/utilities";
9733
- import { useEffect as useEffect25, useMemo as useMemo22, useState as useState24 } from "react";
9806
+ import { useEffect as useEffect26, useMemo as useMemo22, useState as useState25 } from "react";
9734
9807
 
9735
9808
  // src/zustandStores/productViewed.ts
9736
9809
  import { create as create2 } from "zustand";
@@ -9745,10 +9818,10 @@ var useProductViewedStore = create2((set) => ({
9745
9818
  var RebuyProductViewed = ({ ...props }) => {
9746
9819
  const { apiKey: apiKeyFromContext } = useRebuyConfig();
9747
9820
  const { customerId, product, productHandle, productId } = props;
9748
- const [event, setEvent] = useState24(null);
9749
- const [Rebuy, setRebuy] = useState24(null);
9821
+ const [event, setEvent] = useState25(null);
9822
+ const [Rebuy, setRebuy] = useState25(null);
9750
9823
  const shopifyProductId = product?.id ?? productId ?? null;
9751
- const [initialized, setInitialized] = useState24(false);
9824
+ const [initialized, setInitialized] = useState25(false);
9752
9825
  const { setCustomerId, setUuid } = useProductViewedStore();
9753
9826
  const request = useMemo22(() => {
9754
9827
  const request2 = {
@@ -9764,7 +9837,7 @@ var RebuyProductViewed = ({ ...props }) => {
9764
9837
  }
9765
9838
  return request2;
9766
9839
  }, [productHandle, shopifyProductId]);
9767
- useEffect25(() => {
9840
+ useEffect26(() => {
9768
9841
  const recordView = async () => {
9769
9842
  if (!Rebuy) {
9770
9843
  return;
@@ -9800,14 +9873,14 @@ var RebuyProductViewed = ({ ...props }) => {
9800
9873
  // src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
9801
9874
  import { RebuyClient as RebuyClient5 } from "@rebuy/rebuy";
9802
9875
  import { flattenConnection as flattenConnection5 } from "@shopify/hydrogen";
9803
- import { useContext as useContext5, useEffect as useEffect26, useMemo as useMemo23, useState as useState25 } from "react";
9876
+ import { useContext as useContext6, useEffect as useEffect27, useMemo as useMemo23, useState as useState26 } from "react";
9804
9877
 
9805
9878
  // src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.module.css
9806
9879
  var result27 = { "rebuy-recently-viewed-products-container": "RebuyRecentlyViewedProducts_rebuy-recently-viewed-products-container", "product-grid": "RebuyRecentlyViewedProducts_product-grid" };
9807
9880
  var RebuyRecentlyViewedProducts_default = result27;
9808
9881
 
9809
9882
  // src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
9810
- import { jsx as jsx52, jsxs as jsxs33 } from "react/jsx-runtime";
9883
+ import { jsx as jsx54, jsxs as jsxs33 } from "react/jsx-runtime";
9811
9884
  var RebuyRecentlyViewedProducts = (props) => {
9812
9885
  const {
9813
9886
  addToCartBtnText = "Add to cart",
@@ -9821,14 +9894,14 @@ var RebuyRecentlyViewedProducts = (props) => {
9821
9894
  } = props;
9822
9895
  const { customerId, uuid } = useProductViewedStore();
9823
9896
  const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
9824
- const rebuyContext = useContext5(RebuyContext);
9825
- const [rebuyApiClient, setRebuyApiClient] = useState25(null);
9826
- const [initialized, setInitialized] = useState25(false);
9827
- const [products, setProducts] = useState25([]);
9828
- const [metadata, setMetadata] = useState25();
9897
+ const rebuyContext = useContext6(RebuyContext);
9898
+ const [rebuyApiClient, setRebuyApiClient] = useState26(null);
9899
+ const [initialized, setInitialized] = useState26(false);
9900
+ const [products, setProducts] = useState26([]);
9901
+ const [metadata, setMetadata] = useState26();
9829
9902
  const rebuyConfigKey = rebuyConfig?.shop?.cache_key;
9830
9903
  const endpoint = customerId && customerId !== "" ? `/api/v1/products/viewed?key=${rebuyConfigKey}&customer_id=${customerId}` : `/api/v1/products/viewed?key=${rebuyConfigKey}&uuid=${uuid}`;
9831
- useEffect26(() => {
9904
+ useEffect27(() => {
9832
9905
  if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
9833
9906
  const client = new RebuyClient5(apiKey);
9834
9907
  if (rebuyContext?.contextParameters) {
@@ -9842,7 +9915,7 @@ var RebuyRecentlyViewedProducts = (props) => {
9842
9915
  setInitialized(true);
9843
9916
  }
9844
9917
  }, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, uuid, endpoint]);
9845
- useEffect26(() => {
9918
+ useEffect27(() => {
9846
9919
  if (rebuyApiClient && rebuyContext?.contextParameters) {
9847
9920
  const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, endpoint);
9848
9921
  rebuyApiClient.setContextParameters(filteredParams);
@@ -9859,7 +9932,7 @@ var RebuyRecentlyViewedProducts = (props) => {
9859
9932
  }
9860
9933
  return req;
9861
9934
  }, [limit, uuid, endpoint]);
9862
- useEffect26(() => {
9935
+ useEffect27(() => {
9863
9936
  let isMounted = true;
9864
9937
  if (!rebuyApiClient || !initialized || configLoadingStatus !== "success") return;
9865
9938
  const fetchData = async () => {
@@ -9897,8 +9970,8 @@ var RebuyRecentlyViewedProducts = (props) => {
9897
9970
  return null;
9898
9971
  }
9899
9972
  return /* @__PURE__ */ jsxs33("div", { className: RebuyRecentlyViewedProducts_default["rebuy-recently-viewed-products-container"], children: [
9900
- /* @__PURE__ */ jsx52(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9901
- /* @__PURE__ */ jsx52("ul", { className: RebuyRecentlyViewedProducts_default["product-grid"], children: products?.map((product) => /* @__PURE__ */ jsx52("li", { children: /* @__PURE__ */ jsx52(
9973
+ /* @__PURE__ */ jsx54(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9974
+ /* @__PURE__ */ jsx54("ul", { className: RebuyRecentlyViewedProducts_default["product-grid"], children: products?.map((product) => /* @__PURE__ */ jsx54("li", { children: /* @__PURE__ */ jsx54(
9902
9975
  ProductCard,
9903
9976
  {
9904
9977
  addToCartBtnText,