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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7036,7 +7036,6 @@ var RebuyWidget = (props) => {
7036
7036
  customTitleLevel = "h2",
7037
7037
  customTitleStyle,
7038
7038
  isCrossSell,
7039
- isHydrogenReact,
7040
7039
  popupTriggerId,
7041
7040
  product,
7042
7041
  productId,
@@ -7280,7 +7279,7 @@ var RebuyWidget = (props) => {
7280
7279
  customTitle,
7281
7280
  customTitleLevel,
7282
7281
  customTitleStyle,
7283
- isHydrogenReact,
7282
+ isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
7284
7283
  isInPopup: true,
7285
7284
  onDismiss: closePopup,
7286
7285
  products,
@@ -7295,7 +7294,7 @@ var RebuyWidget = (props) => {
7295
7294
  customTitleLevel,
7296
7295
  customTitleStyle,
7297
7296
  isCrossSell,
7298
- isHydrogenReact,
7297
+ isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
7299
7298
  isInPopup: settings?.display_type === "popup",
7300
7299
  products,
7301
7300
  settings
@@ -8910,19 +8909,41 @@ var RebuySmartCart = () => {
8910
8909
  var import_rebuy3 = require("@rebuy/rebuy");
8911
8910
  var Utilities5 = __toESM(require("@rebuy/rebuy/utilities"), 1);
8912
8911
  var import_hydrogen7 = require("@shopify/hydrogen");
8913
- var import_react33 = __toESM(require("react"), 1);
8912
+ var import_react34 = require("react");
8913
+
8914
+ // src/context/RebuyWidgetContext.tsx
8915
+ var import_react33 = require("react");
8916
+ var import_jsx_runtime43 = require("react/jsx-runtime");
8917
+ var RebuyWidgetContext = (0, import_react33.createContext)({
8918
+ dataSource: "",
8919
+ isHydrogenReact: false,
8920
+ key: "",
8921
+ limit: 0,
8922
+ metadata: {},
8923
+ options: {},
8924
+ products: [],
8925
+ variant: void 0,
8926
+ variantId: void 0
8927
+ });
8928
+ var useRebuyWidget = () => (0, import_react33.useContext)(RebuyWidgetContext);
8929
+ var RebuyWidgetProvider = ({ children, value }) => {
8930
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(RebuyWidgetContext.Provider, { value, children });
8931
+ };
8932
+
8933
+ // src/widgetContainer/RebuyWidgetContainer.tsx
8934
+ var import_jsx_runtime44 = require("react/jsx-runtime");
8914
8935
  var RebuyWidgetContainerBase = ({ children, ...props }) => {
8915
8936
  const { collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
8916
8937
  const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
8917
- const rebuyContext = (0, import_react33.useContext)(RebuyContext);
8918
- const [rebuyApiClient, setRebuyApiClient] = (0, import_react33.useState)(null);
8919
- const [initialized, setInitialized] = (0, import_react33.useState)(false);
8938
+ const rebuyContext = (0, import_react34.useContext)(RebuyContext);
8939
+ const [rebuyApiClient, setRebuyApiClient] = (0, import_react34.useState)(null);
8940
+ const [initialized, setInitialized] = (0, import_react34.useState)(false);
8920
8941
  const shopifyProductId = product?.id ?? productId ?? null;
8921
8942
  const shopifyVariantId = variant?.id ?? variantId ?? null;
8922
8943
  const shopifyCollectionId = collection?.id ?? collectionId ?? null;
8923
- const [products, setProducts] = (0, import_react33.useState)([]);
8924
- const [metadata, setMetadata] = (0, import_react33.useState)();
8925
- (0, import_react33.useEffect)(() => {
8944
+ const [products, setProducts] = (0, import_react34.useState)([]);
8945
+ const [metadata, setMetadata] = (0, import_react34.useState)();
8946
+ (0, import_react34.useEffect)(() => {
8926
8947
  if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
8927
8948
  const client = new import_rebuy3.RebuyClient(apiKey);
8928
8949
  const currentEndpoint = dataSource || "/api/v1/products/recommended";
@@ -8937,14 +8958,14 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
8937
8958
  setInitialized(true);
8938
8959
  }
8939
8960
  }, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, dataSource]);
8940
- (0, import_react33.useEffect)(() => {
8961
+ (0, import_react34.useEffect)(() => {
8941
8962
  if (rebuyApiClient && rebuyContext?.contextParameters) {
8942
8963
  const currentEndpoint = dataSource || "/api/v1/products/recommended";
8943
8964
  const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, currentEndpoint);
8944
8965
  rebuyApiClient.setContextParameters(filteredParams);
8945
8966
  }
8946
8967
  }, [rebuyApiClient, rebuyContext, dataSource]);
8947
- const request = (0, import_react33.useMemo)(() => {
8968
+ const request = (0, import_react34.useMemo)(() => {
8948
8969
  const req = {
8949
8970
  endpoint: dataSource || "/api/v1/products/recommended",
8950
8971
  params: {}
@@ -8964,7 +8985,7 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
8964
8985
  }
8965
8986
  return req;
8966
8987
  }, [dataSource, shopifyProductId, shopifyVariantId, shopifyCollectionId, limit]);
8967
- (0, import_react33.useEffect)(() => {
8988
+ (0, import_react34.useEffect)(() => {
8968
8989
  let isMounted = true;
8969
8990
  if (!rebuyApiClient || !initialized || configLoadingStatus !== "success") return;
8970
8991
  const fetchData = async () => {
@@ -8997,23 +9018,30 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
8997
9018
  isMounted = false;
8998
9019
  };
8999
9020
  }, [rebuyApiClient, initialized, request, configLoadingStatus]);
9000
- const childrenWithProps = (currentProps) => import_react33.default.Children.map(
9001
- children,
9002
- (child) => import_react33.default.isValidElement(child) ? import_react33.default.cloneElement(child, currentProps) : child
9003
- );
9004
- const childProps = {
9005
- ...props,
9006
- apiKey,
9007
- cacheKey: rebuyConfig?.shop?.cache_key,
9008
- isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact,
9009
- key: product?.id,
9010
- metadata,
9011
- products
9012
- };
9013
9021
  if (configLoadingStatus !== "success" || !rebuyApiClient) {
9014
9022
  return null;
9015
9023
  }
9016
- return childrenWithProps(childProps);
9024
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9025
+ RebuyWidgetProvider,
9026
+ {
9027
+ value: {
9028
+ apiKey: apiKey ?? void 0,
9029
+ cacheKey: rebuyConfig?.shop?.cache_key,
9030
+ dataSource: dataSource || "/api/v1/products/recommended",
9031
+ isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact || false,
9032
+ key: product?.id || "",
9033
+ limit: limit || 0,
9034
+ metadata: metadata || {},
9035
+ options: options || {},
9036
+ product,
9037
+ productId,
9038
+ products,
9039
+ variant,
9040
+ variantId
9041
+ },
9042
+ children
9043
+ }
9044
+ );
9017
9045
  };
9018
9046
  var RebuyWidgetContainer = RebuyWidgetContainerBase;
9019
9047
 
@@ -9022,37 +9050,38 @@ var result23 = { "container": "RebuyCompleteTheLook_container", "productGrid": "
9022
9050
  var RebuyCompleteTheLook_default = result23;
9023
9051
 
9024
9052
  // src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx
9025
- var import_jsx_runtime43 = require("react/jsx-runtime");
9053
+ var import_jsx_runtime45 = require("react/jsx-runtime");
9026
9054
  var RebuyCompleteTheLook = (props) => {
9027
9055
  const {
9028
9056
  addToCartBtnText = "Add to cart",
9029
9057
  addToCartCallback,
9030
- customTitle = `These pair with ${props.product?.title}`,
9058
+ customTitle = `These pair with {product_title}`,
9031
9059
  customTitleLevel = "h2",
9032
- customTitleStyle,
9033
- products = []
9060
+ customTitleStyle
9034
9061
  } = props;
9062
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9063
+ const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
9035
9064
  if (products.length === 0) {
9036
9065
  rebuyDebugLog.log("widget-complete-the-look" /* WIDGET_COMPLETE_THE_LOOK */, "RebuyCompleteTheLook: No products found");
9037
9066
  return null;
9038
9067
  }
9039
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: RebuyCompleteTheLook_default.container, children: [
9040
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9041
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
9068
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("section", { className: RebuyCompleteTheLook_default.container, children: [
9069
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
9070
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
9042
9071
  ProductCard,
9043
9072
  {
9044
9073
  addToCartBtnText,
9045
9074
  addToCartCallback,
9046
- isHydrogenReact: props.isHydrogenReact,
9047
- product,
9075
+ isHydrogenReact,
9076
+ product: product2,
9048
9077
  productCardTitleLevel: getTitleLevel(customTitleLevel, true)
9049
9078
  }
9050
- ) }, product.id)) })
9079
+ ) }, product2.id)) })
9051
9080
  ] });
9052
9081
  };
9053
9082
 
9054
9083
  // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
9055
- var import_react35 = require("react");
9084
+ var import_react36 = require("react");
9056
9085
 
9057
9086
  // src/utils/convertToRebuyProduct.tsx
9058
9087
  var convertToRebuyProduct = (isHydrogenReact, product) => {
@@ -9304,19 +9333,19 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
9304
9333
 
9305
9334
  // src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
9306
9335
  var import_hydrogen8 = require("@shopify/hydrogen");
9307
- var import_react34 = require("react");
9336
+ var import_react35 = require("react");
9308
9337
 
9309
9338
  // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.module.css
9310
9339
  var result24 = { "container": "RebuyDynamicBundleProducts_container", "addCartBtnContainer": "RebuyDynamicBundleProducts_addCartBtnContainer", "bundleContainer": "RebuyDynamicBundleProducts_bundleContainer", "select": "RebuyDynamicBundleProducts_select", "bundleItemRowContainer": "RebuyDynamicBundleProducts_bundleItemRowContainer", "unselected": "RebuyDynamicBundleProducts_unselected", "bundleItemRow": "RebuyDynamicBundleProducts_bundleItemRow", "bundleItemInput": "RebuyDynamicBundleProducts_bundleItemInput", "bundleItemLabel": "RebuyDynamicBundleProducts_bundleItemLabel", "bundleImages": "RebuyDynamicBundleProducts_bundleImages", "bundleImage": "RebuyDynamicBundleProducts_bundleImage", "bundleImageDelimiter": "RebuyDynamicBundleProducts_bundleImageDelimiter", "compareAtPrice": "RebuyDynamicBundleProducts_compareAtPrice" };
9311
9340
  var RebuyDynamicBundleProducts_default = result24;
9312
9341
 
9313
9342
  // src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
9314
- var import_jsx_runtime44 = require("react/jsx-runtime");
9343
+ var import_jsx_runtime46 = require("react/jsx-runtime");
9315
9344
  var BundleImages = ({ products }) => {
9316
9345
  const selected = products.filter((product) => product.selected);
9317
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
9346
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
9318
9347
  const image = product.selectedVariant?.image;
9319
- const productImage = image ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9348
+ const productImage = image ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9320
9349
  import_hydrogen8.Image,
9321
9350
  {
9322
9351
  alt: image.altText || `Picture of ${product.title}`,
@@ -9331,14 +9360,14 @@ var BundleImages = ({ products }) => {
9331
9360
  product.title
9332
9361
  );
9333
9362
  const showDelimiter = selected[0]?.id !== product.id;
9334
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react34.Fragment, { children: product.selected && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
9335
- showDelimiter && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: "+" }) }),
9336
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("li", { className: "flex items-center", children: product.default ? (
9363
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_react35.Fragment, { children: product.selected && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
9364
+ showDelimiter && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: "+" }) }),
9365
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("li", { className: "flex items-center", children: product.default ? (
9337
9366
  // Already on product page
9338
9367
  productImage
9339
9368
  ) : (
9340
9369
  // Link to product
9341
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9370
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9342
9371
  RebuyLink,
9343
9372
  {
9344
9373
  ariaLabel: `View ${product.title}`,
@@ -9353,7 +9382,7 @@ var BundleImages = ({ products }) => {
9353
9382
 
9354
9383
  // src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
9355
9384
  var import_hydrogen9 = require("@shopify/hydrogen");
9356
- var import_jsx_runtime45 = require("react/jsx-runtime");
9385
+ var import_jsx_runtime47 = require("react/jsx-runtime");
9357
9386
  var BundlePrice = ({ products }) => {
9358
9387
  const isDisabled = products.filter((product) => product.selected).length < 1;
9359
9388
  const totalBundlePrice = () => {
@@ -9390,12 +9419,12 @@ var BundlePrice = ({ products }) => {
9390
9419
  const price = totalBundlePrice();
9391
9420
  const compareAtPrice = totalBundleCompareAtPrice();
9392
9421
  const CompareAtPrice = ({ data: compareAtPrice2 }) => {
9393
- return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_hydrogen9.Money, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
9422
+ return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_hydrogen9.Money, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
9394
9423
  };
9395
- return products.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("p", { className: "flex items-center gap-2 mb-2", children: [
9396
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: "Total Price:" }),
9397
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_hydrogen9.Money, { as: "span", data: price, withoutTrailingZeros: true }),
9398
- isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CompareAtPrice, { data: compareAtPrice })
9424
+ return products.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("p", { className: "flex items-center gap-2 mb-2", children: [
9425
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Total Price:" }),
9426
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_hydrogen9.Money, { as: "span", data: price, withoutTrailingZeros: true }),
9427
+ isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(CompareAtPrice, { data: compareAtPrice })
9399
9428
  ] }) });
9400
9429
  };
9401
9430
 
@@ -9403,7 +9432,7 @@ var BundlePrice = ({ products }) => {
9403
9432
  var import_clsx14 = __toESM(require("clsx"), 1);
9404
9433
 
9405
9434
  // src/widgets/RebuyDynamicBundleProducts/Select.tsx
9406
- var import_jsx_runtime46 = require("react/jsx-runtime");
9435
+ var import_jsx_runtime48 = require("react/jsx-runtime");
9407
9436
  var Select = ({ onSelectVariant, product }) => {
9408
9437
  const getOptionsLabel = (product2) => {
9409
9438
  const options = product2.variants.nodes[0].selectedOptions;
@@ -9412,30 +9441,30 @@ var Select = ({ onSelectVariant, product }) => {
9412
9441
  const useValues = optionsFromKeys.every((key) => ["name", "value"].includes(key));
9413
9442
  return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
9414
9443
  };
9415
- return product && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9444
+ return product && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
9416
9445
  "select",
9417
9446
  {
9418
9447
  "aria-label": "select variant",
9419
9448
  className: RebuyDynamicBundleProducts_default.select,
9420
9449
  onChange: (e) => onSelectVariant(product, e.target.value),
9421
9450
  value: product.selectedVariant.id,
9422
- children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: id, children: title }, id + "-BundleVariant")) })
9451
+ children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("option", { value: id, children: title }, id + "-BundleVariant")) })
9423
9452
  }
9424
9453
  );
9425
9454
  };
9426
9455
 
9427
9456
  // src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
9428
- var import_jsx_runtime47 = require("react/jsx-runtime");
9457
+ var import_jsx_runtime49 = require("react/jsx-runtime");
9429
9458
  var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
9430
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("ul", { children: products.map((product, index) => {
9459
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("ul", { children: products.map((product, index) => {
9431
9460
  const { availableForSale } = product.selectedVariant;
9432
9461
  const isOutOfStock = !availableForSale;
9433
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
9462
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
9434
9463
  "li",
9435
9464
  {
9436
9465
  className: (0, import_clsx14.default)(RebuyDynamicBundleProducts_default.bundleItemRowContainer, !product.selected && RebuyDynamicBundleProducts_default.unselected),
9437
- children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
9438
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
9466
+ children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
9467
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
9439
9468
  "input",
9440
9469
  {
9441
9470
  checked: product.selected && availableForSale,
@@ -9447,14 +9476,14 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
9447
9476
  value: product.id
9448
9477
  }
9449
9478
  ),
9450
- /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
9451
- /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: RebuyDynamicBundleProducts_default.bundleItemLabel, htmlFor: `${product.id}-toggle`, children: [
9452
- isOutOfStock && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("b", { children: "SOLD OUT" }),
9453
- product.default && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("b", { children: "This item:" }),
9479
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
9480
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("label", { className: RebuyDynamicBundleProducts_default.bundleItemLabel, htmlFor: `${product.id}-toggle`, children: [
9481
+ isOutOfStock && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("b", { children: "SOLD OUT" }),
9482
+ product.default && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("b", { children: "This item:" }),
9454
9483
  product.title,
9455
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant })
9484
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant })
9456
9485
  ] }),
9457
- product.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Select, { onSelectVariant, product })
9486
+ product.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Select, { onSelectVariant, product })
9458
9487
  ] })
9459
9488
  ] })
9460
9489
  },
@@ -9464,20 +9493,19 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
9464
9493
  };
9465
9494
 
9466
9495
  // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
9467
- var import_jsx_runtime48 = require("react/jsx-runtime");
9496
+ var import_jsx_runtime50 = require("react/jsx-runtime");
9468
9497
  var RebuyDynamicBundleProducts = (props) => {
9469
9498
  const {
9470
9499
  addToCartBtnText = "Add to cart",
9471
9500
  addToCartCallback,
9472
- customTitle = `These pair with ${props.product?.title}`,
9501
+ customTitle = `These pair with {product_title}`,
9473
9502
  customTitleLevel = "h2",
9474
- customTitleStyle,
9475
- isHydrogenReact,
9476
- product,
9477
- products = []
9503
+ customTitleStyle
9478
9504
  } = props;
9479
- const [bundleProducts, setBundleProducts] = (0, import_react35.useState)([]);
9480
- (0, import_react35.useEffect)(() => {
9505
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9506
+ const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
9507
+ const [bundleProducts, setBundleProducts] = (0, import_react36.useState)([]);
9508
+ (0, import_react36.useEffect)(() => {
9481
9509
  const mainProduct = convertToRebuyProduct(isHydrogenReact || false, product);
9482
9510
  const formattedProducts = products.map((product2) => {
9483
9511
  return {
@@ -9488,14 +9516,14 @@ var RebuyDynamicBundleProducts = (props) => {
9488
9516
  });
9489
9517
  setBundleProducts([mainProduct, ...formattedProducts]);
9490
9518
  }, [product, products, isHydrogenReact]);
9491
- const onToggleBundleItem = (0, import_react35.useCallback)(
9519
+ const onToggleBundleItem = (0, import_react36.useCallback)(
9492
9520
  (product2) => {
9493
9521
  product2.selected = !product2.selected;
9494
9522
  setBundleProducts([...bundleProducts]);
9495
9523
  },
9496
9524
  [bundleProducts]
9497
9525
  );
9498
- const onSelectVariant = (0, import_react35.useCallback)(
9526
+ const onSelectVariant = (0, import_react36.useCallback)(
9499
9527
  (product2, variant_id) => {
9500
9528
  const variant = product2.variants.nodes.find(({ id }) => id === variant_id);
9501
9529
  if (variant) {
@@ -9510,12 +9538,12 @@ var RebuyDynamicBundleProducts = (props) => {
9510
9538
  rebuyDebugLog.log("widget-dynamic-bundle-products" /* WIDGET_DYNAMIC_BUNDLE_PRODUCTS */, "RebuyDynamicBundleProducts: No products found");
9511
9539
  return null;
9512
9540
  }
9513
- return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("section", { className: RebuyDynamicBundleProducts_default.container, children: [
9514
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9515
- /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
9516
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BundleImages, { products: bundleProducts }),
9517
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BundlePrice, { products: bundleProducts }),
9518
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
9541
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("section", { className: RebuyDynamicBundleProducts_default.container, children: [
9542
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
9543
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
9544
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(BundleImages, { products: bundleProducts }),
9545
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(BundlePrice, { products: bundleProducts }),
9546
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
9519
9547
  AddToCartBtn,
9520
9548
  {
9521
9549
  addToCartBtnText,
@@ -9527,7 +9555,7 @@ var RebuyDynamicBundleProducts = (props) => {
9527
9555
  })
9528
9556
  }
9529
9557
  ) }),
9530
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
9558
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
9531
9559
  BundleSelection,
9532
9560
  {
9533
9561
  onSelectVariant,
@@ -9541,7 +9569,7 @@ var RebuyDynamicBundleProducts = (props) => {
9541
9569
 
9542
9570
  // src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
9543
9571
  var import_hydrogen_react3 = require("@shopify/hydrogen-react");
9544
- var import_react36 = require("react");
9572
+ var import_react37 = require("react");
9545
9573
 
9546
9574
  // src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
9547
9575
  var import_hydrogen10 = require("@shopify/hydrogen");
@@ -9551,7 +9579,7 @@ var result25 = { "container": "RebuyProductAddOns_container", "productAddOnsList
9551
9579
  var RebuyProductAddOns_default = result25;
9552
9580
 
9553
9581
  // src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
9554
- var import_jsx_runtime49 = require("react/jsx-runtime");
9582
+ var import_jsx_runtime51 = require("react/jsx-runtime");
9555
9583
  var RebuyProductAddOnCard = ({
9556
9584
  handleChange,
9557
9585
  learnMoreText,
@@ -9560,8 +9588,8 @@ var RebuyProductAddOnCard = ({
9560
9588
  titleLevel
9561
9589
  }) => {
9562
9590
  const { availableForSale, image } = product.selectedVariant || {};
9563
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
9564
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
9591
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
9592
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9565
9593
  "input",
9566
9594
  {
9567
9595
  checked: Boolean(product.selected),
@@ -9574,7 +9602,7 @@ var RebuyProductAddOnCard = ({
9574
9602
  value: ""
9575
9603
  }
9576
9604
  ),
9577
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
9605
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9578
9606
  import_hydrogen10.Image,
9579
9607
  {
9580
9608
  alt: image.altText || `Picture of ${product.title}`,
@@ -9583,11 +9611,11 @@ var RebuyProductAddOnCard = ({
9583
9611
  width: 300
9584
9612
  }
9585
9613
  ) }),
9586
- /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
9587
- !availableForSale && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
9588
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Title, { level: titleLevel, text: product.title }),
9589
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
9590
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
9614
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
9615
+ !availableForSale && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
9616
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Title, { level: titleLevel, text: product.title }),
9617
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
9618
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9591
9619
  RebuyLink,
9592
9620
  {
9593
9621
  ariaLabel: `View ${product.title}`,
@@ -9601,28 +9629,28 @@ var RebuyProductAddOnCard = ({
9601
9629
  };
9602
9630
 
9603
9631
  // src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
9604
- var import_jsx_runtime50 = require("react/jsx-runtime");
9632
+ var import_jsx_runtime52 = require("react/jsx-runtime");
9605
9633
  var RebuyProductAddOns = (props) => {
9606
9634
  const {
9635
+ addToCartBtnText = "Add to cart",
9607
9636
  addToCartCallback,
9608
- customTitle = `These pair with ${props.product?.title}`,
9637
+ customTitle = `These pair with {product_title}`,
9609
9638
  customTitleLevel = "h2",
9610
9639
  customTitleStyle,
9611
9640
  includeMainProduct = false,
9612
- isHydrogenReact,
9613
9641
  learnMoreText = "Learn more",
9614
9642
  outOfStockText = "Out of stock",
9615
- product,
9616
- products = [],
9617
- addToCartBtnText = "Add to cart",
9618
9643
  subtotalText = "Add-ons Subtotal: ",
9619
- withProductText = `With ${product?.title}: `
9644
+ withProductText = `With {product_title}: `
9620
9645
  } = props;
9621
- const [addedItems, setAddedItems] = (0, import_react36.useState)(products);
9622
- const [subtotalWithProduct, setSubtotalWithProduct] = (0, import_react36.useState)();
9623
- const [subtotalWithOutProduct, setSubtotalWithOutProduct] = (0, import_react36.useState)();
9646
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9647
+ const productTitleClean = customTitle.replace("{product_title}", product?.title ?? "");
9648
+ const withProductTextClean = withProductText.replace("{product_title}", product?.title ?? "");
9649
+ const [addedItems, setAddedItems] = (0, import_react37.useState)(products);
9650
+ const [subtotalWithProduct, setSubtotalWithProduct] = (0, import_react37.useState)();
9651
+ const [subtotalWithOutProduct, setSubtotalWithOutProduct] = (0, import_react37.useState)();
9624
9652
  const convertedProduct = convertToRebuyProduct(isHydrogenReact || false, product);
9625
- (0, import_react36.useEffect)(() => {
9653
+ (0, import_react37.useEffect)(() => {
9626
9654
  let initialTotal = 0;
9627
9655
  let currencyCode = "USD";
9628
9656
  products.map((product2) => {
@@ -9652,7 +9680,7 @@ var RebuyProductAddOns = (props) => {
9652
9680
  setAddedItems(products);
9653
9681
  }
9654
9682
  }, [products, product, isHydrogenReact, includeMainProduct]);
9655
- const handleChange = (0, import_react36.useCallback)(
9683
+ const handleChange = (0, import_react37.useCallback)(
9656
9684
  (event, product2) => {
9657
9685
  const newProducts = [...products];
9658
9686
  const productIndex = newProducts.findIndex((p) => p.id === product2.id);
@@ -9671,7 +9699,7 @@ var RebuyProductAddOns = (props) => {
9671
9699
  },
9672
9700
  [products]
9673
9701
  );
9674
- (0, import_react36.useEffect)(() => {
9702
+ (0, import_react37.useEffect)(() => {
9675
9703
  let total = 0;
9676
9704
  let currencyCode = "USD";
9677
9705
  addedItems.forEach((item) => {
@@ -9697,9 +9725,9 @@ var RebuyProductAddOns = (props) => {
9697
9725
  rebuyDebugLog.log("widget-product-add-ons" /* WIDGET_PRODUCT_ADD_ONS */, "RebuyProductAddOns: No products found");
9698
9726
  return null;
9699
9727
  }
9700
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.container, children: [
9701
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9702
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
9728
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.container, children: [
9729
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitleClean }),
9730
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
9703
9731
  RebuyProductAddOnCard,
9704
9732
  {
9705
9733
  handleChange,
@@ -9709,16 +9737,16 @@ var RebuyProductAddOns = (props) => {
9709
9737
  titleLevel: getTitleLevel(customTitleLevel, true)
9710
9738
  }
9711
9739
  ) }, product2.id)) }),
9712
- /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
9713
- /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
9740
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
9741
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
9714
9742
  subtotalText,
9715
- subtotalWithOutProduct && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_hydrogen_react3.Money, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
9743
+ subtotalWithOutProduct && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_hydrogen_react3.Money, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
9716
9744
  ] }),
9717
- includeMainProduct && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
9718
- withProductText,
9719
- subtotalWithProduct && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_hydrogen_react3.Money, { data: subtotalWithProduct, withoutTrailingZeros: true })
9745
+ includeMainProduct && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
9746
+ withProductTextClean,
9747
+ subtotalWithProduct && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_hydrogen_react3.Money, { data: subtotalWithProduct, withoutTrailingZeros: true })
9720
9748
  ] }),
9721
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
9749
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
9722
9750
  AddToCartBtn,
9723
9751
  {
9724
9752
  addToCartBtnText,
@@ -9728,7 +9756,7 @@ var RebuyProductAddOns = (props) => {
9728
9756
  moneyData: subtotalWithProduct,
9729
9757
  selectedVariants: addedItems.map((item) => item.selectedVariant)
9730
9758
  }
9731
- ) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
9759
+ ) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
9732
9760
  AddToCartBtn,
9733
9761
  {
9734
9762
  addToCartBtnText,
@@ -9748,39 +9776,40 @@ var result26 = { "container": "RebuyProductRecommendations_container", "productG
9748
9776
  var RebuyProductRecommendations_default = result26;
9749
9777
 
9750
9778
  // src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx
9751
- var import_jsx_runtime51 = require("react/jsx-runtime");
9779
+ var import_jsx_runtime53 = require("react/jsx-runtime");
9752
9780
  var RebuyProductRecommendations = (props) => {
9753
9781
  const {
9754
9782
  addToCartBtnText = "Add to cart",
9755
9783
  addToCartCallback,
9756
- customTitle = `These pair with ${props.product?.title}`,
9784
+ customTitle = `These pair with {product_title}`,
9757
9785
  customTitleLevel = "h2",
9758
- customTitleStyle,
9759
- products = []
9786
+ customTitleStyle
9760
9787
  } = props;
9788
+ const { isHydrogenReact, product, products } = useRebuyWidget();
9789
+ const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
9761
9790
  if (products.length === 0) {
9762
9791
  rebuyDebugLog.log("widget-product-recommendations" /* WIDGET_PRODUCT_RECOMMENDATIONS */, "RebuyProductRecommendations: No products found");
9763
9792
  return null;
9764
9793
  }
9765
- return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("section", { className: RebuyProductRecommendations_default.container, children: [
9766
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9767
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9794
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("section", { className: RebuyProductRecommendations_default.container, children: [
9795
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
9796
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
9768
9797
  ProductCard,
9769
9798
  {
9770
9799
  addToCartBtnText,
9771
9800
  addToCartCallback,
9772
- isHydrogenReact: props.isHydrogenReact,
9773
- product,
9801
+ isHydrogenReact,
9802
+ product: product2,
9774
9803
  productCardTitleLevel: getTitleLevel(customTitleLevel, true)
9775
9804
  }
9776
- ) }, product.id)) })
9805
+ ) }, product2.id)) })
9777
9806
  ] });
9778
9807
  };
9779
9808
 
9780
9809
  // src/widgets/RebuyProductViewed/RebuyProductViewed.tsx
9781
9810
  var import_rebuy4 = require("@rebuy/rebuy");
9782
9811
  var Utilities6 = __toESM(require("@rebuy/rebuy/utilities"), 1);
9783
- var import_react37 = require("react");
9812
+ var import_react38 = require("react");
9784
9813
 
9785
9814
  // src/zustandStores/productViewed.ts
9786
9815
  var import_zustand2 = require("zustand");
@@ -9795,12 +9824,12 @@ var useProductViewedStore = (0, import_zustand2.create)((set) => ({
9795
9824
  var RebuyProductViewed = ({ ...props }) => {
9796
9825
  const { apiKey: apiKeyFromContext } = useRebuyConfig();
9797
9826
  const { customerId, product, productHandle, productId } = props;
9798
- const [event, setEvent] = (0, import_react37.useState)(null);
9799
- const [Rebuy, setRebuy] = (0, import_react37.useState)(null);
9827
+ const [event, setEvent] = (0, import_react38.useState)(null);
9828
+ const [Rebuy, setRebuy] = (0, import_react38.useState)(null);
9800
9829
  const shopifyProductId = product?.id ?? productId ?? null;
9801
- const [initialized, setInitialized] = (0, import_react37.useState)(false);
9830
+ const [initialized, setInitialized] = (0, import_react38.useState)(false);
9802
9831
  const { setCustomerId, setUuid } = useProductViewedStore();
9803
- const request = (0, import_react37.useMemo)(() => {
9832
+ const request = (0, import_react38.useMemo)(() => {
9804
9833
  const request2 = {
9805
9834
  parameters: {}
9806
9835
  };
@@ -9814,7 +9843,7 @@ var RebuyProductViewed = ({ ...props }) => {
9814
9843
  }
9815
9844
  return request2;
9816
9845
  }, [productHandle, shopifyProductId]);
9817
- (0, import_react37.useEffect)(() => {
9846
+ (0, import_react38.useEffect)(() => {
9818
9847
  const recordView = async () => {
9819
9848
  if (!Rebuy) {
9820
9849
  return;
@@ -9850,14 +9879,14 @@ var RebuyProductViewed = ({ ...props }) => {
9850
9879
  // src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
9851
9880
  var import_rebuy5 = require("@rebuy/rebuy");
9852
9881
  var import_hydrogen11 = require("@shopify/hydrogen");
9853
- var import_react38 = require("react");
9882
+ var import_react39 = require("react");
9854
9883
 
9855
9884
  // src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.module.css
9856
9885
  var result27 = { "rebuy-recently-viewed-products-container": "RebuyRecentlyViewedProducts_rebuy-recently-viewed-products-container", "product-grid": "RebuyRecentlyViewedProducts_product-grid" };
9857
9886
  var RebuyRecentlyViewedProducts_default = result27;
9858
9887
 
9859
9888
  // src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
9860
- var import_jsx_runtime52 = require("react/jsx-runtime");
9889
+ var import_jsx_runtime54 = require("react/jsx-runtime");
9861
9890
  var RebuyRecentlyViewedProducts = (props) => {
9862
9891
  const {
9863
9892
  addToCartBtnText = "Add to cart",
@@ -9871,14 +9900,14 @@ var RebuyRecentlyViewedProducts = (props) => {
9871
9900
  } = props;
9872
9901
  const { customerId, uuid } = useProductViewedStore();
9873
9902
  const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
9874
- const rebuyContext = (0, import_react38.useContext)(RebuyContext);
9875
- const [rebuyApiClient, setRebuyApiClient] = (0, import_react38.useState)(null);
9876
- const [initialized, setInitialized] = (0, import_react38.useState)(false);
9877
- const [products, setProducts] = (0, import_react38.useState)([]);
9878
- const [metadata, setMetadata] = (0, import_react38.useState)();
9903
+ const rebuyContext = (0, import_react39.useContext)(RebuyContext);
9904
+ const [rebuyApiClient, setRebuyApiClient] = (0, import_react39.useState)(null);
9905
+ const [initialized, setInitialized] = (0, import_react39.useState)(false);
9906
+ const [products, setProducts] = (0, import_react39.useState)([]);
9907
+ const [metadata, setMetadata] = (0, import_react39.useState)();
9879
9908
  const rebuyConfigKey = rebuyConfig?.shop?.cache_key;
9880
9909
  const endpoint = customerId && customerId !== "" ? `/api/v1/products/viewed?key=${rebuyConfigKey}&customer_id=${customerId}` : `/api/v1/products/viewed?key=${rebuyConfigKey}&uuid=${uuid}`;
9881
- (0, import_react38.useEffect)(() => {
9910
+ (0, import_react39.useEffect)(() => {
9882
9911
  if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
9883
9912
  const client = new import_rebuy5.RebuyClient(apiKey);
9884
9913
  if (rebuyContext?.contextParameters) {
@@ -9892,13 +9921,13 @@ var RebuyRecentlyViewedProducts = (props) => {
9892
9921
  setInitialized(true);
9893
9922
  }
9894
9923
  }, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, uuid, endpoint]);
9895
- (0, import_react38.useEffect)(() => {
9924
+ (0, import_react39.useEffect)(() => {
9896
9925
  if (rebuyApiClient && rebuyContext?.contextParameters) {
9897
9926
  const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, endpoint);
9898
9927
  rebuyApiClient.setContextParameters(filteredParams);
9899
9928
  }
9900
9929
  }, [rebuyApiClient, rebuyContext, uuid, endpoint]);
9901
- const request = (0, import_react38.useMemo)(() => {
9930
+ const request = (0, import_react39.useMemo)(() => {
9902
9931
  const req = {
9903
9932
  endpoint,
9904
9933
  params: {}
@@ -9909,7 +9938,7 @@ var RebuyRecentlyViewedProducts = (props) => {
9909
9938
  }
9910
9939
  return req;
9911
9940
  }, [limit, uuid, endpoint]);
9912
- (0, import_react38.useEffect)(() => {
9941
+ (0, import_react39.useEffect)(() => {
9913
9942
  let isMounted = true;
9914
9943
  if (!rebuyApiClient || !initialized || configLoadingStatus !== "success") return;
9915
9944
  const fetchData = async () => {
@@ -9946,9 +9975,9 @@ var RebuyRecentlyViewedProducts = (props) => {
9946
9975
  rebuyDebugLog.log("widget-recently-viewed-products" /* WIDGET_RECENTLY_VIEWED_PRODUCTS */, "RebuyRecentlyViewedProducts: No products found");
9947
9976
  return null;
9948
9977
  }
9949
- return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyRecentlyViewedProducts_default["rebuy-recently-viewed-products-container"], children: [
9950
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9951
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("ul", { className: RebuyRecentlyViewedProducts_default["product-grid"], children: products?.map((product) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
9978
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: RebuyRecentlyViewedProducts_default["rebuy-recently-viewed-products-container"], children: [
9979
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
9980
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("ul", { className: RebuyRecentlyViewedProducts_default["product-grid"], children: products?.map((product) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
9952
9981
  ProductCard,
9953
9982
  {
9954
9983
  addToCartBtnText,