@liquidcommercedev/rmn-sdk 1.4.6-beta.5 → 1.4.6-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -56,9 +56,9 @@ exports.RMN_FILTER_PROPERTIES = void 0;
56
56
  })(exports.RMN_FILTER_PROPERTIES || (exports.RMN_FILTER_PROPERTIES = {}));
57
57
  exports.RMN_SPOT_EVENT = void 0;
58
58
  (function (RMN_SPOT_EVENT) {
59
+ RMN_SPOT_EVENT["INJECT_SPOTS"] = "INJECT_SPOTS";
59
60
  RMN_SPOT_EVENT["MOUNTED"] = "MOUNTED";
60
61
  RMN_SPOT_EVENT["UNMOUNTED"] = "UNMOUNTED";
61
- RMN_SPOT_EVENT["RESIZED"] = "RESIZED";
62
62
  RMN_SPOT_EVENT["IMPRESSION"] = "IMPRESSION";
63
63
  RMN_SPOT_EVENT["CLICK"] = "CLICK";
64
64
  RMN_SPOT_EVENT["PURCHASE"] = "PURCHASE";
@@ -15246,9 +15246,9 @@ class ResizeObserverService {
15246
15246
  newWidth = Math.min(containerWidth, this.maxSize.width);
15247
15247
  newHeight = newWidth / this.aspectRatio;
15248
15248
  // If the height exceeds the container, adjust based on height
15249
- if (newHeight > containerHeight) {
15250
- newHeight = containerHeight;
15251
- newWidth = newHeight * this.aspectRatio;
15249
+ if (newWidth > containerWidth) {
15250
+ newWidth = containerWidth;
15251
+ newHeight = containerHeight * this.aspectRatio;
15252
15252
  }
15253
15253
  // Ensure we're not going below minimum dimensions
15254
15254
  newWidth = Math.max(newWidth, this.minSize.width);
@@ -15275,6 +15275,36 @@ class ResizeObserverService {
15275
15275
  }
15276
15276
  }
15277
15277
 
15278
+ function calculateScaleFactor(elementScale) {
15279
+ // Step 1: Apply square root for non-linear scaling
15280
+ // This creates a more gradual scaling effect, especially for larger changes
15281
+ // For example:
15282
+ // - elementScale of 0.25 (1/4 size) becomes 0.5
15283
+ // - elementScale of 1 (unchanged) remains 1
15284
+ // - elementScale of 4 (4x size) becomes 2
15285
+ const baseFactor = Math.sqrt(elementScale);
15286
+ // Step 2: Apply additional dampening to further soften the scaling effect
15287
+ // The dampening factor (0.5) can be adjusted:
15288
+ // - Lower values (closer to 0) make scaling more subtle
15289
+ // - Higher values (closer to 1) make scaling more pronounced
15290
+ const dampening = 0.35;
15291
+ // Calculate the scaleFactor:
15292
+ // 1. (baseFactor - 1) represents the change from the original size
15293
+ // 2. Multiply by dampening to reduce the effect
15294
+ // 3. Add 1 to center the scaling around the original size
15295
+ // For example, if baseFactor is 2:
15296
+ // scaleFactor = 1 + (2 - 1) * 0.5 = 1.5
15297
+ const scaleFactor = 1 + (baseFactor - 1) * dampening;
15298
+ // Step 3: Define the allowed range for the scale factor
15299
+ // This ensures that the font size never changes too drastically
15300
+ const minScale = 0.35; // Font will never be smaller than 50% of original
15301
+ const maxScale = 1.5; // Font will never be larger than 150% of original
15302
+ // Step 4: Clamp the scale factor to the defined range
15303
+ // Math.min ensures the value doesn't exceed maxScale
15304
+ // Math.max ensures the value isn't less than minScale
15305
+ return Math.max(minScale, Math.min(maxScale, scaleFactor));
15306
+ }
15307
+
15278
15308
  const CAROUSEL_COMPONENT_STYLE = ({ width, height, fluid }) => `
15279
15309
  :host {
15280
15310
  position: relative;
@@ -15462,6 +15492,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15462
15492
  this.autoplayInterval = null;
15463
15493
  this.useDots = false;
15464
15494
  this.useButtons = false;
15495
+ this.originalFontSizes = new Map();
15465
15496
  this.attachShadow({ mode: 'open' });
15466
15497
  }
15467
15498
  connectedCallback() {
@@ -15500,7 +15531,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15500
15531
  this.validateOptions();
15501
15532
  }
15502
15533
  setupResizeObserver() {
15503
- if (this.data) {
15534
+ if (this.data && !this.data.fluid) {
15504
15535
  this.resizeObserver = new ResizeObserverService({
15505
15536
  element: this,
15506
15537
  maxSize: {
@@ -15512,9 +15543,29 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15512
15543
  this.addEventListener('spotSizeChanged', this.handleCarouselSizeChanged.bind(this));
15513
15544
  }
15514
15545
  }
15515
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
15516
- handleCarouselSizeChanged(_event) {
15517
- // console.info('Carousel Size Changed', event);
15546
+ handleCarouselSizeChanged(event) {
15547
+ const isRBSpot = 'rbHeroadaksda'.startsWith('rb');
15548
+ if (!isRBSpot) {
15549
+ // Adjust text elements font size based on the scale factor
15550
+ this.adjustFontSize(event.detail.scale);
15551
+ }
15552
+ }
15553
+ adjustFontSize(elementScale) {
15554
+ var _a;
15555
+ const scaleFactor = calculateScaleFactor(elementScale);
15556
+ // Find all text elements within the shadow root
15557
+ const elements = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('h1, h2, h3, h4, p, span');
15558
+ elements === null || elements === void 0 ? void 0 : elements.forEach((element) => {
15559
+ if (element instanceof HTMLElement) {
15560
+ if (!this.originalFontSizes.has(element)) {
15561
+ const originalSize = parseFloat(window.getComputedStyle(element).fontSize);
15562
+ this.originalFontSizes.set(element, originalSize);
15563
+ }
15564
+ const originalSize = this.originalFontSizes.get(element);
15565
+ const newFontSize = originalSize * scaleFactor;
15566
+ element.style.fontSize = `${newFontSize}px`;
15567
+ }
15568
+ });
15518
15569
  }
15519
15570
  render() {
15520
15571
  var _a;
@@ -15723,7 +15774,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15723
15774
  * #########################################################
15724
15775
  */
15725
15776
  setupResizeObserver() {
15726
- if (this.data) {
15777
+ if (this.data && !this.data.fluid) {
15727
15778
  this.resizeObserver = new ResizeObserverService({
15728
15779
  element: this,
15729
15780
  maxSize: {
@@ -15740,13 +15791,16 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15740
15791
  * #########################################################
15741
15792
  */
15742
15793
  handleSpotSizeChanged(event) {
15743
- // console.info('Spot Size Changed', event);
15744
- // Adjust text elements font size based on the scale factor
15745
- this.adjustFontSize(event.detail.scale);
15794
+ var _a, _b, _c;
15795
+ const isRBSpot = (_c = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.spot) === null || _b === void 0 ? void 0 : _b.startsWith('rb')) !== null && _c !== void 0 ? _c : false;
15796
+ if (!isRBSpot) {
15797
+ // Adjust text elements font size based on the scale factor
15798
+ this.adjustFontSize(event.detail.scale);
15799
+ }
15746
15800
  }
15747
15801
  adjustFontSize(elementScale) {
15748
15802
  var _a;
15749
- const scaleFactor = this.calculateScaleFactor(elementScale);
15803
+ const scaleFactor = calculateScaleFactor(elementScale);
15750
15804
  // Find all text elements within the shadow root
15751
15805
  const elements = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('h1, h2, h3, h4, p, span');
15752
15806
  elements === null || elements === void 0 ? void 0 : elements.forEach((element) => {
@@ -15761,35 +15815,6 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15761
15815
  }
15762
15816
  });
15763
15817
  }
15764
- calculateScaleFactor(elementScale) {
15765
- // Step 1: Apply square root for non-linear scaling
15766
- // This creates a more gradual scaling effect, especially for larger changes
15767
- // For example:
15768
- // - elementScale of 0.25 (1/4 size) becomes 0.5
15769
- // - elementScale of 1 (unchanged) remains 1
15770
- // - elementScale of 4 (4x size) becomes 2
15771
- const baseFactor = Math.sqrt(elementScale);
15772
- // Step 2: Apply additional dampening to further soften the scaling effect
15773
- // The dampening factor (0.5) can be adjusted:
15774
- // - Lower values (closer to 0) make scaling more subtle
15775
- // - Higher values (closer to 1) make scaling more pronounced
15776
- const dampening = 0.5;
15777
- // Calculate the scaleFactor:
15778
- // 1. (baseFactor - 1) represents the change from the original size
15779
- // 2. Multiply by dampening to reduce the effect
15780
- // 3. Add 1 to center the scaling around the original size
15781
- // For example, if baseFactor is 2:
15782
- // scaleFactor = 1 + (2 - 1) * 0.5 = 1.5
15783
- const scaleFactor = 1 + (baseFactor - 1) * dampening;
15784
- // Step 3: Define the allowed range for the scale factor
15785
- // This ensures that the font size never changes too drastically
15786
- const minScale = 0.5; // Font will never be smaller than 90% of original
15787
- const maxScale = 1.5; // Font will never be larger than 110% of original
15788
- // Step 4: Clamp the scale factor to the defined range
15789
- // Math.min ensures the value doesn't exceed maxScale
15790
- // Math.max ensures the value isn't less than minScale
15791
- return Math.max(minScale, Math.min(maxScale, scaleFactor));
15792
- }
15793
15818
  /**
15794
15819
  * Spot element rendering
15795
15820
  * #########################################################
@@ -15840,6 +15865,7 @@ class ElementService {
15840
15865
  }
15841
15866
  const spot = document.createElement(SPOT_ELEMENT_TAG);
15842
15867
  spot.data = {
15868
+ spot: config === null || config === void 0 ? void 0 : config.spot,
15843
15869
  fluid: (_a = config === null || config === void 0 ? void 0 : config.fluid) !== null && _a !== void 0 ? _a : false,
15844
15870
  ...config,
15845
15871
  };
@@ -15861,6 +15887,7 @@ class ElementService {
15861
15887
  }
15862
15888
  const carousel = document.createElement(CAROUSEL_ELEMENT_TAG);
15863
15889
  carousel.data = {
15890
+ spot: config === null || config === void 0 ? void 0 : config.spot,
15864
15891
  fluid: false,
15865
15892
  ...config,
15866
15893
  };
@@ -16745,12 +16772,7 @@ function wideSkyscraperV1Template(spot) {
16745
16772
 
16746
16773
  const STYLES$7 = ({ primaryImage, mobilePrimaryImage = primaryImage }, { prefix }) => `
16747
16774
  <style>
16748
- :host {
16749
- min-width: 320px;
16750
- min-height: 223px;
16751
- }
16752
-
16753
- .${prefix}__content {
16775
+ .${prefix} {
16754
16776
  display: block;
16755
16777
  width: 100%;
16756
16778
  height: 100%;
@@ -16759,10 +16781,11 @@ const STYLES$7 = ({ primaryImage, mobilePrimaryImage = primaryImage }, { prefix
16759
16781
  background-repeat: no-repeat;
16760
16782
  background-position: center;
16761
16783
  cursor: pointer;
16784
+ container-type: inline-size;
16762
16785
  }
16763
16786
 
16764
- @media (min-width: 640px) {
16765
- .${prefix}__content {
16787
+ @container (min-width: 640px) {
16788
+ .${prefix} {
16766
16789
  background-image: url("${primaryImage}");
16767
16790
  }
16768
16791
  }
@@ -16772,7 +16795,7 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot, config) {
16772
16795
  const { prefix = '' } = config;
16773
16796
  return `
16774
16797
  ${STYLES$7(spot, config)}
16775
- <div class="${prefix}__content"></div>
16798
+ <div class="${prefix}"></div>
16776
16799
  `;
16777
16800
  }
16778
16801
 
@@ -16781,16 +16804,6 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
16781
16804
  return `
16782
16805
  <style>
16783
16806
  .${prefix} {
16784
- min-width: 320px;
16785
- min-height: 388px;
16786
- width: 100%;
16787
- height: 100%;
16788
- display: block;
16789
- position: relative;
16790
- container-type: inline-size;
16791
- }
16792
-
16793
- .${prefix}__content {
16794
16807
  display: flex;
16795
16808
  flex-direction: column;
16796
16809
  justify-content: flex-end;
@@ -16805,6 +16818,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
16805
16818
  box-sizing: border-box;
16806
16819
  color: ${textColor};
16807
16820
  cursor: pointer;
16821
+ container-type: inline-size;
16808
16822
  }
16809
16823
 
16810
16824
  .${prefix}__text {
@@ -16849,17 +16863,17 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
16849
16863
  transition: background-color 0.3s ease;
16850
16864
  }
16851
16865
 
16852
- .${prefix}__content:hover .cta-button {
16866
+ .${prefix}:hover .cta-button {
16853
16867
  background-color: ${ctaBorderColor.length === 7 ? `${ctaBorderColor}15` : `${ctaBorderColor}`};
16854
16868
  }
16855
16869
 
16856
- @media (min-width: 640px) {
16857
- .${prefix}__content {
16870
+ @container (min-width: 640px) {
16871
+ .${prefix} {
16858
16872
  background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
16859
16873
  }
16860
16874
  }
16861
16875
 
16862
- @media (min-width: 768px) {
16876
+ @container (min-width: 768px) {
16863
16877
  .${prefix}__primary-image {
16864
16878
  width: 66.66666%;
16865
16879
  height: 100%;
@@ -16870,7 +16884,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
16870
16884
  height: 100%;
16871
16885
  width: 33.33333%;
16872
16886
  }
16873
-
16887
+
16874
16888
  .${prefix}__secondary-image {
16875
16889
  width: 100%;
16876
16890
  height: 50%;
@@ -16879,7 +16893,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
16879
16893
  .${prefix}__header {
16880
16894
  font-size: 22px;
16881
16895
  }
16882
-
16896
+
16883
16897
  .${prefix}__description {
16884
16898
  font-size: 12px;
16885
16899
  }
@@ -16889,7 +16903,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
16889
16903
  }
16890
16904
  }
16891
16905
 
16892
- @media (min-width: 1024px) {
16906
+ @container (min-width: 1024px) {
16893
16907
  .${prefix}__header {
16894
16908
  font-size: 24px;
16895
16909
  }
@@ -16903,11 +16917,11 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
16903
16917
  }
16904
16918
  }
16905
16919
 
16906
- @media (min-width: 1280px) {
16920
+ @container (min-width: 1280px) {
16907
16921
  .${prefix}__header {
16908
16922
  font-size: 28px;
16909
16923
  }
16910
-
16924
+
16911
16925
  .${prefix}__description {
16912
16926
  font-size: 14px;
16913
16927
  }
@@ -16927,13 +16941,11 @@ function rbHomepageHeroFullImageTemplate(spot, config) {
16927
16941
  ${GFONT_CORMORANT}
16928
16942
  ${STYLES$6(spot, config)}
16929
16943
  <div class="${prefix}">
16930
- <div class="${prefix}__content">
16931
- <div class="${prefix}__text">
16932
- ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
16933
- ${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
16934
- ${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
16935
- </div>
16936
- </div>
16944
+ <div class="${prefix}__text">
16945
+ ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
16946
+ ${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
16947
+ ${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
16948
+ </div>
16937
16949
  </div>
16938
16950
  `;
16939
16951
  }
@@ -16941,8 +16953,6 @@ function rbHomepageHeroFullImageTemplate(spot, config) {
16941
16953
  const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextColor = textColor, primaryImage, mobilePrimaryImage = primaryImage, secondaryImage, mobileSecondaryImage = secondaryImage, }, { prefix }) => `
16942
16954
  <style>
16943
16955
  .${prefix} {
16944
- min-width: 320px;
16945
- min-height: 388px;
16946
16956
  width: 100%;
16947
16957
  height: 100%;
16948
16958
  display: block;
@@ -16954,7 +16964,7 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
16954
16964
  width: 100%;
16955
16965
  height: 100%;
16956
16966
  display: flex;
16957
- flex-direction: column;
16967
+ flex-direction: column;
16958
16968
  background-color: transparent;
16959
16969
  gap: 5px;
16960
16970
  color: inherit;
@@ -17041,7 +17051,7 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
17041
17051
  opacity: 0.8;
17042
17052
  }
17043
17053
 
17044
- @media (min-width: 640px) {
17054
+ @container (min-width: 640px) {
17045
17055
  .${prefix}__primary-image {
17046
17056
  background-image: url("${primaryImage}");
17047
17057
  }
@@ -17051,7 +17061,7 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
17051
17061
  }
17052
17062
  }
17053
17063
 
17054
- @media (min-width: 768px) {
17064
+ @container (min-width: 768px) {
17055
17065
  .${prefix}__content {
17056
17066
  flex-direction: row;
17057
17067
  }
@@ -17076,6 +17086,39 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
17076
17086
  width: 100%;
17077
17087
  height: 50%;
17078
17088
  }
17089
+ .${prefix}__header {
17090
+ font-size: 22px;
17091
+ }
17092
+ .${prefix}__description {
17093
+ font-size: 12px;
17094
+ }
17095
+ .${prefix}__cta-button {
17096
+ font-size: 12px;
17097
+ }
17098
+ }
17099
+
17100
+ @container (min-width: 1024px) {
17101
+ .${prefix}__header {
17102
+ font-size: 24px;
17103
+ }
17104
+ .${prefix}__description {
17105
+ font-size: 13px;
17106
+ }
17107
+ .${prefix}__cta-button {
17108
+ font-size: 13px;
17109
+ }
17110
+ }
17111
+
17112
+ @container (min-width: 1280px) {
17113
+ .${prefix}__header {
17114
+ font-size: 28px;
17115
+ }
17116
+ .${prefix}__description {
17117
+ font-size: 14px;
17118
+ }
17119
+ .${prefix}__cta-button {
17120
+ font-size: 14px;
17121
+ }
17079
17122
  }
17080
17123
  </style>
17081
17124
  `;
@@ -17105,23 +17148,15 @@ function rbHomepageHeroThreeTileTemplate(spot, config) {
17105
17148
  const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextColor = textColor, primaryImage, mobilePrimaryImage = primaryImage, }, { prefix }) => `
17106
17149
  <style>
17107
17150
  .${prefix} {
17108
- min-width: 320px;
17109
- min-height: 388px;
17110
- width: 100%;
17111
- height: 100%;
17112
- display: block;
17113
- position: relative;
17114
- container-type: inline-size;
17115
- }
17116
-
17117
- .${prefix}__content {
17118
17151
  width: 100%;
17119
17152
  height: 100%;
17120
17153
  display: flex;
17121
- flex-direction: column-reverse;
17154
+ flex-direction: column-reverse;
17122
17155
  background-color: transparent;
17123
17156
  gap: 5px;
17124
17157
  cursor: pointer;
17158
+ container-type: inline-size;
17159
+ position: relative;
17125
17160
  }
17126
17161
 
17127
17162
  .${prefix}__image {
@@ -17166,7 +17201,7 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
17166
17201
  font-style: normal;
17167
17202
  font-weight: 400;
17168
17203
  }
17169
-
17204
+
17170
17205
  .${prefix}__cta-button {
17171
17206
  color: ${ctaTextColor};
17172
17207
  background-color: transparent;
@@ -17187,25 +17222,57 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
17187
17222
  opacity: 0.8;
17188
17223
  }
17189
17224
 
17190
- @media (min-width: 640px) {
17225
+ @container (min-width: 640px) {
17191
17226
  .${prefix}__image {
17192
17227
  background-image: url("${primaryImage}");
17193
17228
  }
17194
17229
  }
17195
- @media (min-width: 768px) {
17196
- .${prefix}__content {
17230
+
17231
+ @container (min-width: 768px) {
17232
+ .${prefix} {
17197
17233
  flex-direction: row;
17198
17234
  }
17199
-
17200
17235
  .${prefix}__image {
17201
17236
  width: 66.66666%;
17202
17237
  height: 100%;
17203
17238
  }
17204
-
17205
17239
  .${prefix}__text {
17206
17240
  width: 33.33333%;
17207
17241
  height: 100%;
17208
17242
  }
17243
+ .${prefix}__header {
17244
+ font-size: 22px;
17245
+ }
17246
+ .${prefix}__description {
17247
+ font-size: 12px;
17248
+ }
17249
+ .${prefix}__cta-button {
17250
+ font-size: 12px;
17251
+ }
17252
+ }
17253
+
17254
+ @container (min-width: 1024px) {
17255
+ .${prefix}__header {
17256
+ font-size: 24px;
17257
+ }
17258
+ .${prefix}__description {
17259
+ font-size: 13px;
17260
+ }
17261
+ .${prefix}__cta-button {
17262
+ font-size: 13px;
17263
+ }
17264
+ }
17265
+
17266
+ @container (min-width: 1280px) {
17267
+ .${prefix}__header {
17268
+ font-size: 28px;
17269
+ }
17270
+ .${prefix}__description {
17271
+ font-size: 14px;
17272
+ }
17273
+ .${prefix}__cta-button {
17274
+ font-size: 14px;
17275
+ }
17209
17276
  }
17210
17277
  </style>
17211
17278
  `;
@@ -17217,14 +17284,12 @@ function rbHomepageHeroTwoTileTemplate(spot, config) {
17217
17284
  ${GFONT_CORMORANT}
17218
17285
  ${STYLES$4(spot, config)}
17219
17286
  <div class="${prefix}">
17220
- <div class="${prefix}__content">
17221
- <div class="${prefix}__text">
17222
- ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
17223
- ${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
17224
- ${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
17225
- </div>
17226
- <div class="${prefix}__image"></div>
17287
+ <div class="${prefix}__text">
17288
+ ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
17289
+ ${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
17290
+ ${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
17227
17291
  </div>
17292
+ <div class="${prefix}__image"></div>
17228
17293
  </div>
17229
17294
  `;
17230
17295
  }
@@ -17233,12 +17298,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
17233
17298
  const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
17234
17299
  return `
17235
17300
  <style>
17236
- :host {
17237
- min-width: 320px;
17238
- min-height: 334px;
17239
- }
17240
-
17241
- .${prefix}__content {
17301
+ .${prefix} {
17242
17302
  width: 100%;
17243
17303
  height: 100%;
17244
17304
  display: flex;
@@ -17252,6 +17312,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
17252
17312
  overflow: hidden;
17253
17313
  cursor: pointer;
17254
17314
  color: ${textColor};
17315
+ container-type: inline-size;
17255
17316
  }
17256
17317
 
17257
17318
  .${prefix}__text {
@@ -17298,17 +17359,17 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
17298
17359
  font-weight: 400;
17299
17360
  }
17300
17361
 
17301
- .${prefix}__content:hover .${prefix}__cta-button {
17362
+ .${prefix}:hover .${prefix}__cta-button {
17302
17363
  background-color: ${ctaBorderColor.length === 7 ? `${ctaBorderColor}15` : `${ctaBorderColor}`};
17303
17364
  }
17304
17365
 
17305
- @media (min-width: 640px) {
17306
- .${prefix}__content {
17366
+ @container (min-width: 640px) {
17367
+ .${prefix} {
17307
17368
  background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
17308
17369
  }
17309
17370
  }
17310
17371
 
17311
- @media (min-width: 768px) {
17372
+ @container (min-width: 768px) {
17312
17373
  .${prefix}__text {
17313
17374
  padding: 25px;
17314
17375
  }
@@ -17327,7 +17388,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
17327
17388
  }
17328
17389
  }
17329
17390
 
17330
- @media (min-width: 1024px) {
17391
+ @container (min-width: 1024px) {
17331
17392
  .${prefix}__text {
17332
17393
  padding: 30px;
17333
17394
  }
@@ -17345,7 +17406,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
17345
17406
  }
17346
17407
  }
17347
17408
 
17348
- @media (min-width: 1280px) {
17409
+ @container (min-width: 1280px) {
17349
17410
  .${prefix}__cta-button {
17350
17411
  font-size: 14px;
17351
17412
  }
@@ -17360,7 +17421,7 @@ function rbLargeCategoryImageToutTemplate(spot, config) {
17360
17421
  ${GFONT_SOURCE_SANS_3}
17361
17422
  ${GFONT_CORMORANT}
17362
17423
  ${STYLES$3(spot, config)}
17363
- <div class="${prefix}__content">
17424
+ <div class="${prefix}">
17364
17425
  <div class="${prefix}__text">
17365
17426
  ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
17366
17427
  ${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
@@ -17374,12 +17435,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17374
17435
  const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
17375
17436
  return `
17376
17437
  <style>
17377
- :host {
17378
- min-width: 320px;
17379
- min-height: 150px;
17380
- }
17381
-
17382
- .${prefix}__content {
17438
+ .${prefix} {
17383
17439
  width: 100%;
17384
17440
  height: 100%;
17385
17441
  display: flex;
@@ -17392,6 +17448,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17392
17448
  background-size: cover;
17393
17449
  background-position: center;
17394
17450
  background-repeat: no-repeat;
17451
+ container-type: inline-size;
17395
17452
  }
17396
17453
 
17397
17454
  .${prefix}__text {
@@ -17409,25 +17466,25 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17409
17466
  margin: 0;
17410
17467
  }
17411
17468
 
17412
- @media (min-width: 640px) {
17413
- .${prefix}__content {
17469
+ @container (min-width: 640px) {
17470
+ .${prefix} {
17414
17471
  background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
17415
17472
  }
17416
17473
  }
17417
17474
 
17418
- @media (min-width: 768px) {
17475
+ @container (min-width: 768px) {
17419
17476
  .${prefix}__header {
17420
17477
  font-size: 22px;
17421
17478
  }
17422
17479
  }
17423
17480
 
17424
- @media (min-width: 1024px) {
17481
+ @container (min-width: 1024px) {
17425
17482
  .${prefix}__header {
17426
17483
  font-size: 24px;
17427
17484
  }
17428
17485
  }
17429
17486
 
17430
- @media (min-width: 1280px) {
17487
+ @container (min-width: 1280px) {
17431
17488
  .${prefix}__header {
17432
17489
  font-size: 28px;
17433
17490
  }
@@ -17441,7 +17498,7 @@ function rbNavigationBannerTemplate(spot, config) {
17441
17498
  ${GFONT_PRECONNECT}
17442
17499
  ${GFONT_SOURCE_SANS_3}
17443
17500
  ${STYLES$2(spot, config)}
17444
- <div class="${prefix}__content">
17501
+ <div class="${prefix}">
17445
17502
  <div class="${prefix}__text">
17446
17503
  ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
17447
17504
  </div>
@@ -17453,12 +17510,7 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17453
17510
  const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
17454
17511
  return `
17455
17512
  <style>
17456
- :host {
17457
- min-width: 165px;
17458
- min-height: 300px;
17459
- }
17460
-
17461
- .${prefix}__content {
17513
+ .${prefix} {
17462
17514
  width: 100%;
17463
17515
  height: 100%;
17464
17516
  display: flex;
@@ -17471,6 +17523,7 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17471
17523
  border-radius: 5px;
17472
17524
  overflow: hidden;
17473
17525
  cursor: pointer;
17526
+ container-type: inline-size;
17474
17527
  }
17475
17528
 
17476
17529
  .${prefix}__text {
@@ -17485,12 +17538,11 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17485
17538
  font-family: "Source Sans 3", system-ui;
17486
17539
  font-style: normal;
17487
17540
  font-weight: 400;
17488
- line-height: normal;
17489
17541
  margin: 0;
17490
17542
  }
17491
17543
 
17492
- @media (min-width: 640px) {
17493
- .${prefix}__content {
17544
+ @container (min-width: 640px) {
17545
+ .${prefix} {
17494
17546
  background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
17495
17547
  }
17496
17548
  }
@@ -17503,7 +17555,7 @@ function rbSmallCategoryImageToutTemplate(spot, config) {
17503
17555
  ${GFONT_PRECONNECT}
17504
17556
  ${GFONT_CORMORANT}
17505
17557
  ${STYLES$1(spot, config)}
17506
- <div class="${prefix}__content">
17558
+ <div class="${prefix}">
17507
17559
  <div class="${prefix}__text">
17508
17560
  ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
17509
17561
  </div>
@@ -17513,12 +17565,7 @@ function rbSmallCategoryImageToutTemplate(spot, config) {
17513
17565
 
17514
17566
  const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }, { prefix }) => `
17515
17567
  <style>
17516
- :host {
17517
- min-width: 165px;
17518
- min-height: 250px;
17519
- }
17520
-
17521
- .${prefix}__content {
17568
+ .${prefix} {
17522
17569
  width: 100%;
17523
17570
  height: 100%;
17524
17571
  background-color: ${backgroundColor};
@@ -17526,6 +17573,7 @@ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primar
17526
17573
  display: flex;
17527
17574
  flex-direction: column;
17528
17575
  border-radius: 5px;
17576
+ container-type: inline-size;
17529
17577
  }
17530
17578
 
17531
17579
  .${prefix}__image {
@@ -17557,11 +17605,10 @@ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primar
17557
17605
  font-family: "Source Sans 3", system-ui;
17558
17606
  font-style: normal;
17559
17607
  font-weight: 400;
17560
- line-height: normal;
17561
17608
  margin: 0;
17562
17609
  }
17563
17610
 
17564
- @media (min-width: 640px) {
17611
+ @container (min-width: 640px) {
17565
17612
  .${prefix}__image {
17566
17613
  background-image: url("${primaryImage}");
17567
17614
  }
@@ -17574,7 +17621,7 @@ function rbSmallDiscoverToutTemplate(spot, config) {
17574
17621
  ${GFONT_PRECONNECT}
17575
17622
  ${GFONT_CORMORANT}
17576
17623
  ${STYLES(spot, config)}
17577
- <div class="${prefix}__content">
17624
+ <div class="${prefix}">
17578
17625
  <div class="${prefix}__image"></div>
17579
17626
  <div class="${prefix}__text">
17580
17627
  ${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
@@ -17755,8 +17802,6 @@ class EventService {
17755
17802
  element,
17756
17803
  impressionTracked: false,
17757
17804
  });
17758
- // Handle resize observer
17759
- // this.handleResizeObserver(placementId, spot, element);
17760
17805
  // Handle intersection observer
17761
17806
  this.handleIntersectionObserver(placementId, spot, element);
17762
17807
  // Attach click event listener
@@ -17794,35 +17839,6 @@ class EventService {
17794
17839
  this.activeSpots.delete(spotId);
17795
17840
  }
17796
17841
  }
17797
- // private handleResizeObserver(placementId: string, spot: ISpot, element: HTMLElement): void {
17798
- // // this.resizeObserver = new ResizeObserverService({
17799
- // // element,
17800
- // // maxSize: {
17801
- // // width: spot.width,
17802
- // // height: spot.height,
17803
- // // },
17804
- // // minScale: 0.25,
17805
- // // });
17806
- //
17807
- // const sizeChangedCb = (event: ISizeChangedEvent) => {
17808
- // // Publish spot resized event
17809
- // this.pubSub.publish(RMN_SPOT_EVENT.RESIZED, {
17810
- // placementId,
17811
- // spotId: spot.id,
17812
- // scale: event.detail.scale,
17813
- // previousDimensions: {
17814
- // width: event.detail.width,
17815
- // height: event.detail.height,
17816
- // },
17817
- // currentDimensions: {
17818
- // width: event.detail.newWidth,
17819
- // height: event.detail.newHeight,
17820
- // },
17821
- // });
17822
- // };
17823
- //
17824
- // element.addEventListener('spotSizeChanged', sizeChangedCb as EventListener);
17825
- // }
17826
17842
  handleIntersectionObserver(placementId, spot, element) {
17827
17843
  const spotIsVisibleCb = async () => {
17828
17844
  var _a, _b;
@@ -17898,19 +17914,19 @@ class SelectionService extends BaseApi {
17898
17914
  *
17899
17915
  * @param {ISpotSelectionParams} data - Spots selection parameters.
17900
17916
  *
17901
- * @return {Promise<ISpots>} - The spots response object.
17917
+ * @return {Promise<ISpots | { error: string }>} - The spots response object.
17902
17918
  */
17903
17919
  async spotSelection(data) {
17904
17920
  const { isOk, val, isErr } = await this.post(SELECTION_API_PATH, data, {});
17905
17921
  if (isErr) {
17906
- throw new Error(`There was an error during spot selection: (${isErr === null || isErr === void 0 ? void 0 : isErr.errorMessage})`);
17922
+ return { error: `There was an error during spot selection: (${isErr === null || isErr === void 0 ? void 0 : isErr.errorMessage})` };
17907
17923
  }
17908
17924
  if (isOk && val && val.data && (val === null || val === void 0 ? void 0 : val.refresh.token)) {
17909
17925
  this.authInfo.authenticated = true;
17910
17926
  this.authInfo.token = val.refresh.token;
17911
17927
  return val.data.spots;
17912
17928
  }
17913
- throw new Error('Spot selection response was not successful');
17929
+ return { error: 'Spot selection response was not successful' };
17914
17930
  }
17915
17931
  }
17916
17932
 
@@ -17927,7 +17943,7 @@ class LiquidCommerceRmnClient {
17927
17943
  *
17928
17944
  * @param {ISpotSelectionParams} params - Spots selection parameters.
17929
17945
  *
17930
- * @return {Promise<ISpots>} - The spots response object.
17946
+ * @return {Promise<ISpots | {error : string}>} - The spots response object.
17931
17947
  */
17932
17948
  async spotSelection(params) {
17933
17949
  return this.selectionService.spotSelection(params);
@@ -17941,31 +17957,51 @@ class LiquidCommerceRmnClient {
17941
17957
  */
17942
17958
  async injectSpotElement(params) {
17943
17959
  var _a;
17944
- const { inject, config } = params;
17960
+ const config = params.config;
17961
+ let inject = params.inject;
17962
+ this.eventService.publish(exports.RMN_SPOT_EVENT.INJECT_SPOTS, {
17963
+ isLoading: true,
17964
+ isCompleted: false,
17965
+ error: null,
17966
+ });
17945
17967
  if (!inject.length) {
17946
- console.warn('RmnSdk: Failed to inject spot element. Please provide at least one spot element to inject.');
17968
+ this.eventError('RmnSdk: Failed to inject spot element. Please provide at least one spot element to inject.');
17969
+ return;
17970
+ }
17971
+ const hasDuplicatePlacementIds = this.preventDuplicateSpotPlacementIds(inject);
17972
+ if (!hasDuplicatePlacementIds) {
17973
+ return;
17974
+ }
17975
+ inject = this.preventNonExistentSpotTypes(inject);
17976
+ const response = await this.spotSelectionRequest({ ...params, inject });
17977
+ if (typeof response === 'object' && 'error' in response) {
17978
+ this.eventError(response.error);
17947
17979
  return;
17948
17980
  }
17949
- this.preventDuplicateSpotPlacementIds(inject);
17950
- const response = await this.spotSelectionRequest(params);
17951
17981
  for (const item of inject) {
17952
17982
  const itemConfig = (_a = item.config) !== null && _a !== void 0 ? _a : config;
17953
17983
  const spots = response[item.placementId];
17954
17984
  if (!(spots === null || spots === void 0 ? void 0 : spots.length)) {
17955
- console.warn(`RmnSdk: Failed to inject spot element. No spots found for type "${item.spotType}".`);
17985
+ this.eventError(`RmnSdk: Failed to inject spot element. No spots found for type "${item.spotType}".`, { placementId: item.placementId, type: item.spotType });
17956
17986
  continue;
17957
17987
  }
17958
17988
  const placementId = item.placementId.replace('#', '');
17959
17989
  const placement = document.getElementById(placementId);
17960
17990
  if (!placement) {
17961
- console.warn(`RmnSdk: Failed to inject spot element. Placement not found for id "#${placementId}".`);
17991
+ this.eventError(`RmnSdk: Failed to inject spot element. Placement not found for id "#${placementId}".`, { placementId, type: item.spotType });
17962
17992
  continue;
17963
17993
  }
17964
17994
  if (spots.length === 1) {
17965
- this.injectOneSpotElement(item, placement, spots[0], itemConfig);
17995
+ const isInjected = this.injectOneSpotElement(item, placement, spots[0], itemConfig);
17996
+ if (!isInjected) {
17997
+ continue;
17998
+ }
17966
17999
  }
17967
18000
  if (spots.length > 1) {
17968
- this.injectCarouselSpotElement(placement, spots, itemConfig);
18001
+ const isInjected = this.injectCarouselSpotElement(placement, spots, itemConfig);
18002
+ if (!isInjected) {
18003
+ continue;
18004
+ }
17969
18005
  }
17970
18006
  }
17971
18007
  }
@@ -17982,7 +18018,7 @@ class LiquidCommerceRmnClient {
17982
18018
  *
17983
18019
  * @param {IInjectSpotElementParams} params - Parameters for injecting spot elements.
17984
18020
  *
17985
- * @return {Promise<ISpots>} - The spots response object.
18021
+ * @return {Promise<ISpots | {error: string}>} - The spots response object.
17986
18022
  */
17987
18023
  async spotSelectionRequest(params) {
17988
18024
  const { inject, filter, config } = params;
@@ -18014,8 +18050,8 @@ class LiquidCommerceRmnClient {
18014
18050
  const spot = this.elementService.overrideSpotColors(spotItem, config === null || config === void 0 ? void 0 : config.colors);
18015
18051
  const content = SPOT_TEMPLATE_HTML_ELEMENT(spot, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
18016
18052
  if (!content) {
18017
- console.warn(`RmnSdk: Failed to inject carousel spot element. Could not create element for type "${spot.spot}".`);
18018
- return;
18053
+ this.eventError(`RmnSdk: Failed to inject carousel spot element. Could not create element for type "${spot.spot}".`, { placementId: placement.id, type: spot.spot });
18054
+ continue;
18019
18055
  }
18020
18056
  this.eventSpotElement({
18021
18057
  spot,
@@ -18031,6 +18067,7 @@ class LiquidCommerceRmnClient {
18031
18067
  const carouselElement = this.elementService.createCarouselElement({
18032
18068
  slides: carouselSlides,
18033
18069
  config: {
18070
+ fluid: config === null || config === void 0 ? void 0 : config.fluid,
18034
18071
  width: maxWidth,
18035
18072
  height: maxHeight,
18036
18073
  minScale: (_a = config === null || config === void 0 ? void 0 : config.minScale) !== null && _a !== void 0 ? _a : 0.25, // Scale down to 25% of the original size
@@ -18038,10 +18075,11 @@ class LiquidCommerceRmnClient {
18038
18075
  },
18039
18076
  });
18040
18077
  if (!carouselElement) {
18041
- console.warn(`RmnSdk: Failed to inject spot carousel element. Could not create spot carousel element.`);
18042
- return;
18078
+ this.eventError(`RmnSdk: Failed to inject spot carousel element. Could not create spot carousel element.`, { placementId: placement.id });
18079
+ return false;
18043
18080
  }
18044
18081
  placement.replaceChildren(carouselElement);
18082
+ return true;
18045
18083
  }
18046
18084
  /**
18047
18085
  * Injects a single spot element into the provided placement.
@@ -18058,20 +18096,22 @@ class LiquidCommerceRmnClient {
18058
18096
  const spotData = this.elementService.overrideSpotColors(spot, config === null || config === void 0 ? void 0 : config.colors);
18059
18097
  const content = SPOT_TEMPLATE_HTML_ELEMENT(spotData, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
18060
18098
  if (!content) {
18061
- console.warn(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`);
18062
- return;
18099
+ this.eventError(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`, { placementId: injectItem.placementId, type: injectItem.spotType });
18100
+ return false;
18063
18101
  }
18064
18102
  const spotElement = this.elementService.createSpotElement({
18065
18103
  content,
18066
18104
  config: {
18105
+ fluid: config === null || config === void 0 ? void 0 : config.fluid,
18106
+ spot: spot.spot,
18067
18107
  width: spot.width,
18068
18108
  height: spot.height,
18069
18109
  minScale: (_a = config === null || config === void 0 ? void 0 : config.minScale) !== null && _a !== void 0 ? _a : 0.25, // Scale down to 25% of the original size
18070
18110
  },
18071
18111
  });
18072
18112
  if (!spotElement) {
18073
- console.warn(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`);
18074
- return;
18113
+ this.eventError(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`, { placementId: injectItem.placementId, type: injectItem.spotType });
18114
+ return false;
18075
18115
  }
18076
18116
  this.eventSpotElement({
18077
18117
  spot,
@@ -18079,6 +18119,7 @@ class LiquidCommerceRmnClient {
18079
18119
  element: spotElement,
18080
18120
  });
18081
18121
  placement.replaceChildren(spotElement);
18122
+ return true;
18082
18123
  }
18083
18124
  eventSpotElement({ spot, placementId, element, }) {
18084
18125
  this.eventService.registerSpot({
@@ -18100,10 +18141,33 @@ class LiquidCommerceRmnClient {
18100
18141
  const placementIds = new Set();
18101
18142
  for (const item of inject) {
18102
18143
  if (placementIds.has(item.placementId)) {
18103
- throw new Error(`RmnSdk: Duplicate placement id (${item.placementId}) found. Please provide a unique placement id for each spot element.`);
18144
+ this.eventError(`RmnSdk: Duplicate placement id (${item.placementId}) found. Please provide a unique placement id for each spot element.`, { placementId: item.placementId, type: item.spotType });
18145
+ return false;
18104
18146
  }
18105
18147
  placementIds.add(item.placementId);
18106
18148
  }
18149
+ return true;
18150
+ }
18151
+ preventNonExistentSpotTypes(inject) {
18152
+ const newInject = [];
18153
+ for (const item of inject) {
18154
+ if (!Object.values(exports.RMN_SPOT_TYPE).includes(item.spotType)) {
18155
+ this.eventError(`RmnSdk: Invalid spot type (${item.spotType}) found. Please provide a valid spot type for each spot element.`, { placementId: item.placementId, type: item.spotType });
18156
+ continue;
18157
+ }
18158
+ newInject.push(item);
18159
+ }
18160
+ return newInject;
18161
+ }
18162
+ eventError(error, spot) {
18163
+ this.eventService.publish(exports.RMN_SPOT_EVENT.INJECT_SPOTS, {
18164
+ isLoading: false,
18165
+ isCompleted: true,
18166
+ error: {
18167
+ message: error,
18168
+ spot,
18169
+ },
18170
+ });
18107
18171
  }
18108
18172
  }
18109
18173
  /**