@liquidcommercedev/rmn-sdk 1.4.6-beta.2 → 1.4.6-beta.3

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
@@ -15150,7 +15150,8 @@ class AuthService extends BaseApi {
15150
15150
  }
15151
15151
  }
15152
15152
 
15153
- const ELEMENT_TAG = 'spot-element';
15153
+ const SPOT_ELEMENT_TAG = 'spot-element';
15154
+ const CAROUSEL_ELEMENT_TAG = 'spot-carousel-element';
15154
15155
  const GFONT_PRECONNECT = `
15155
15156
  <link rel="preconnect" href="https://fonts.googleapis.com">
15156
15157
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -15163,7 +15164,7 @@ const GFONT_CORMORANT = `
15163
15164
  `;
15164
15165
 
15165
15166
  class ResizeObserverService {
15166
- constructor({ element, maxSize, minScale = 0.275 }) {
15167
+ constructor({ element, maxSize, minScale }) {
15167
15168
  this.element = element;
15168
15169
  if (!element.parentElement) {
15169
15170
  throw new Error('RmnSdk: Spot element must have a parent container.');
@@ -15230,6 +15231,431 @@ class ResizeObserverService {
15230
15231
  }
15231
15232
  }
15232
15233
 
15234
+ const CAROUSEL_COMPONENT_STYLE = ({ width, height, fluid }) => `
15235
+ :host {
15236
+ position: relative;
15237
+ display: inline-block;
15238
+ margin: 0;
15239
+ overflow: hidden;
15240
+ width: ${fluid ? '100%' : `${width}px`};
15241
+ height: ${fluid ? '100%' : `${height}px`};
15242
+ }
15243
+
15244
+ .slides {
15245
+ position: relative;
15246
+ height: 100%;
15247
+ width: 100%;
15248
+ }
15249
+
15250
+ .slide {
15251
+ display: none;
15252
+
15253
+ justify-content: center;
15254
+ align-items: center;
15255
+ height: 100%;
15256
+ width: 100%;
15257
+ }
15258
+
15259
+ .slide.active {
15260
+ display: flex;
15261
+ }
15262
+
15263
+ .dots {
15264
+ position: absolute;
15265
+ display: flex;
15266
+ align-items: center;
15267
+ gap: 8px;
15268
+ }
15269
+
15270
+ .dots .dot {
15271
+ width: 12px;
15272
+ height: 12px;
15273
+ border-radius: 50%;
15274
+ cursor: pointer;
15275
+ transition: all 0.3s ease;
15276
+ }
15277
+
15278
+ .dots.top-left,
15279
+ .dots.bottom-left {
15280
+ left: 10px;
15281
+ }
15282
+
15283
+ .dots.top-center,
15284
+ .dots.bottom-center {
15285
+ left: 50%;
15286
+ transform: translateX(-50%);
15287
+ }
15288
+
15289
+ .dots.top-right,
15290
+ .dots.bottom-right {
15291
+ right: 10px;
15292
+ }
15293
+
15294
+ .dots.top-left,
15295
+ .dots.top-center,
15296
+ .dots.top-right {
15297
+ top: 10px;
15298
+ }
15299
+
15300
+ .dots.bottom-left,
15301
+ .dots.bottom-center,
15302
+ .dots.bottom-right {
15303
+ bottom: 10px;
15304
+ }
15305
+
15306
+ .dots.middle-left {
15307
+ left: 10px;
15308
+ top: 50%;
15309
+ transform: translateY(-50%);
15310
+ flex-direction: column;
15311
+ }
15312
+
15313
+ .dots.middle-right {
15314
+ right: 10px;
15315
+ top: 50%;
15316
+ transform: translateY(-50%);
15317
+ flex-direction: column;
15318
+ }
15319
+
15320
+ .buttons button {
15321
+ background-color: #00000080;
15322
+ color: #fff;
15323
+ border: none;
15324
+ padding: 10px;
15325
+ cursor: pointer;
15326
+ transition: background-color 0.3s ease;
15327
+ }
15328
+
15329
+ .buttons button:hover {
15330
+ background-color: #000000b3;
15331
+ }
15332
+
15333
+ .buttons.buttons-separate button {
15334
+ position: absolute;
15335
+ top: 50%;
15336
+ transform: translateY(-50%);
15337
+ }
15338
+
15339
+ .buttons.buttons-separate .prev-button {
15340
+ left: 10px;
15341
+ }
15342
+
15343
+ .buttons.buttons-separate .next-button {
15344
+ right: 10px;
15345
+ }
15346
+
15347
+ .buttons.buttons-together {
15348
+ position: absolute;
15349
+ display: flex;
15350
+ gap: 10px;
15351
+ }
15352
+
15353
+ .buttons.buttons-together.top-left,
15354
+ .buttons.buttons-together.bottom-left {
15355
+ left: 10px;
15356
+ }
15357
+
15358
+ .buttons.buttons-together.top-center,
15359
+ .buttons.buttons-together.bottom-center {
15360
+ left: 50%;
15361
+ transform: translateX(-50%);
15362
+ }
15363
+
15364
+ .buttons.buttons-together.top-right,
15365
+ .buttons.buttons-together.bottom-right {
15366
+ right: 10px;
15367
+ }
15368
+
15369
+ .buttons.buttons-together.top-left,
15370
+ .buttons.buttons-together.top-center,
15371
+ .buttons.buttons-together.top-right {
15372
+ top: 10px;
15373
+ }
15374
+
15375
+ .buttons.buttons-together.bottom-left,
15376
+ .buttons.buttons-together.bottom-center,
15377
+ .buttons.buttons-together.bottom-right {
15378
+ bottom: 10px;
15379
+ }
15380
+
15381
+ .buttons.buttons-together.middle-left,
15382
+ .buttons.buttons-together.middle-right {
15383
+ top: 50%;
15384
+ transform: translateY(-50%);
15385
+ flex-direction: column;
15386
+ }
15387
+
15388
+ .buttons.buttons-together.middle-left {
15389
+ left: 10px;
15390
+ }
15391
+
15392
+ .buttons.buttons-together.middle-right {
15393
+ right: 10px;
15394
+ }
15395
+
15396
+ @media (max-width: 768px) {
15397
+ .buttons button {
15398
+ padding: 8px 12px;
15399
+ font-size: 14px;
15400
+ }
15401
+
15402
+ .dots .dot {
15403
+ width: 8px;
15404
+ height: 8px;
15405
+ }
15406
+ }
15407
+ `;
15408
+
15409
+ let CarouselElement;
15410
+ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined') {
15411
+ class CustomCarouselElement extends HTMLElement {
15412
+ constructor() {
15413
+ super();
15414
+ this.currentSlide = 0;
15415
+ this.dotElements = [];
15416
+ this.prevButton = null;
15417
+ this.nextButton = null;
15418
+ this.autoplayInterval = null;
15419
+ this.useDots = false;
15420
+ this.useButtons = false;
15421
+ this.attachShadow({ mode: 'open' });
15422
+ }
15423
+ connectedCallback() {
15424
+ this.initializeOptions();
15425
+ this.setupResizeObserver();
15426
+ this.render();
15427
+ this.setupCarousel();
15428
+ }
15429
+ disconnectedCallback() {
15430
+ var _a;
15431
+ this.stopAutoplay();
15432
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
15433
+ }
15434
+ initializeOptions() {
15435
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
15436
+ this.useDots = ((_a = this.data) === null || _a === void 0 ? void 0 : _a.useDots) === true || typeof ((_b = this.data) === null || _b === void 0 ? void 0 : _b.useDots) === 'object';
15437
+ this.useButtons = ((_c = this.data) === null || _c === void 0 ? void 0 : _c.useButtons) === true || typeof ((_d = this.data) === null || _d === void 0 ? void 0 : _d.useButtons) === 'object';
15438
+ this.autoplay = (_f = (_e = this.data) === null || _e === void 0 ? void 0 : _e.autoplay) !== null && _f !== void 0 ? _f : true;
15439
+ this.interval = (_h = (_g = this.data) === null || _g === void 0 ? void 0 : _g.interval) !== null && _h !== void 0 ? _h : CustomCarouselElement.defaultInterval;
15440
+ this.dotsOptions = {
15441
+ position: 'bottom-center',
15442
+ color: '#d9d9d9',
15443
+ activeColor: '#b5914a',
15444
+ ...(typeof ((_j = this.data) === null || _j === void 0 ? void 0 : _j.useDots) === 'object' ? this.data.useDots : {}),
15445
+ };
15446
+ this.buttonsOptions = {
15447
+ together: false,
15448
+ position: 'middle-sides',
15449
+ textColor: '#000000',
15450
+ backgroundColor: '#ffffff',
15451
+ borderRadius: '50%',
15452
+ prev: 'Prev',
15453
+ next: 'Next',
15454
+ ...(typeof ((_k = this.data) === null || _k === void 0 ? void 0 : _k.useButtons) === 'object' ? this.data.useButtons : {}),
15455
+ };
15456
+ this.validateOptions();
15457
+ }
15458
+ setupResizeObserver() {
15459
+ if (this.data) {
15460
+ this.resizeObserver = new ResizeObserverService({
15461
+ element: this,
15462
+ maxSize: {
15463
+ width: this.data.width,
15464
+ height: this.data.height,
15465
+ },
15466
+ minScale: this.data.minScale,
15467
+ });
15468
+ this.addEventListener('spotSizeChanged', this.handleCarouselSizeChanged.bind(this));
15469
+ }
15470
+ }
15471
+ handleCarouselSizeChanged(event) {
15472
+ console.info('Carousel Size Changed', event);
15473
+ }
15474
+ render() {
15475
+ var _a;
15476
+ if (!this.shadowRoot)
15477
+ return;
15478
+ const style = document.createElement('style');
15479
+ style.textContent = CAROUSEL_COMPONENT_STYLE(this.data);
15480
+ this.shadowRoot.appendChild(style);
15481
+ const slides = this.renderSlides();
15482
+ this.shadowRoot.appendChild(slides);
15483
+ this.slidesContainer = (_a = this.shadowRoot.querySelector('.slides')) !== null && _a !== void 0 ? _a : undefined;
15484
+ if (this.useDots) {
15485
+ const dots = this.renderDots();
15486
+ if (dots)
15487
+ this.shadowRoot.appendChild(dots);
15488
+ }
15489
+ if (this.useButtons) {
15490
+ const buttons = this.renderButtons();
15491
+ if (buttons)
15492
+ this.shadowRoot.appendChild(buttons);
15493
+ }
15494
+ }
15495
+ setupCarousel() {
15496
+ this.setupDots();
15497
+ this.setupButtons();
15498
+ if (this.autoplay) {
15499
+ this.startAutoplay();
15500
+ }
15501
+ this.updateCarousel();
15502
+ }
15503
+ renderSlides() {
15504
+ const slidesContainer = document.createElement('div');
15505
+ slidesContainer.className = 'slides';
15506
+ this.slides.forEach((slide, index) => {
15507
+ const slideElement = document.createElement('div');
15508
+ slideElement.className = `slide ${index === this.currentSlide ? 'active' : ''}`;
15509
+ if (slide instanceof HTMLElement) {
15510
+ slideElement.appendChild(slide);
15511
+ }
15512
+ slidesContainer.appendChild(slideElement);
15513
+ });
15514
+ return slidesContainer;
15515
+ }
15516
+ renderDots() {
15517
+ const dotsContainer = document.createElement('div');
15518
+ dotsContainer.className = `dots ${this.dotsOptions.position}`;
15519
+ this.slides.forEach((_, index) => {
15520
+ const dot = document.createElement('span');
15521
+ dot.className = `dot ${index === this.currentSlide ? 'active' : ''}`;
15522
+ dot.style.backgroundColor = this.dotsOptions.color;
15523
+ dotsContainer.appendChild(dot);
15524
+ });
15525
+ return dotsContainer;
15526
+ }
15527
+ renderButtons() {
15528
+ const buttonsContainer = document.createElement('div');
15529
+ const buttonsClass = this.buttonsOptions.together
15530
+ ? `buttons-together ${this.buttonsOptions.position}`
15531
+ : 'buttons-separate';
15532
+ buttonsContainer.className = `buttons ${buttonsClass}`;
15533
+ this.prevButton = this.createButton('prev-button', this.buttonsOptions.prev);
15534
+ this.nextButton = this.createButton('next-button', this.buttonsOptions.next);
15535
+ buttonsContainer.appendChild(this.prevButton);
15536
+ buttonsContainer.appendChild(this.nextButton);
15537
+ return buttonsContainer;
15538
+ }
15539
+ createButton(className, text) {
15540
+ const button = document.createElement('button');
15541
+ button.className = className;
15542
+ button.textContent = text;
15543
+ button.style.color = this.buttonsOptions.textColor;
15544
+ button.style.backgroundColor = this.buttonsOptions.backgroundColor;
15545
+ button.style.borderRadius = this.buttonsOptions.borderRadius;
15546
+ return button;
15547
+ }
15548
+ setupDots() {
15549
+ if (!this.shadowRoot || !this.useDots)
15550
+ return;
15551
+ this.dotElements = Array.from(this.shadowRoot.querySelectorAll('.dot'));
15552
+ this.dotElements.forEach((dot, index) => {
15553
+ dot.addEventListener('click', () => {
15554
+ this.goToSlide(index);
15555
+ this.resetAutoplay();
15556
+ });
15557
+ });
15558
+ }
15559
+ setupButtons() {
15560
+ var _a, _b;
15561
+ if (!this.useButtons)
15562
+ return;
15563
+ (_a = this.prevButton) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => {
15564
+ this.prevSlide();
15565
+ this.resetAutoplay();
15566
+ });
15567
+ (_b = this.nextButton) === null || _b === void 0 ? void 0 : _b.addEventListener('click', () => {
15568
+ this.nextSlide();
15569
+ this.resetAutoplay();
15570
+ });
15571
+ }
15572
+ nextSlide() {
15573
+ this.goToSlide((this.currentSlide + 1) % this.slides.length);
15574
+ }
15575
+ prevSlide() {
15576
+ this.goToSlide((this.currentSlide - 1 + this.slides.length) % this.slides.length);
15577
+ }
15578
+ goToSlide(index) {
15579
+ this.currentSlide = index;
15580
+ this.updateCarousel();
15581
+ }
15582
+ updateCarousel() {
15583
+ if (!this.slidesContainer)
15584
+ return;
15585
+ const slides = Array.from(this.slidesContainer.children);
15586
+ slides.forEach((slide, index) => {
15587
+ slide.classList.toggle('active', index === this.currentSlide);
15588
+ });
15589
+ this.updateDots();
15590
+ }
15591
+ updateDots() {
15592
+ if (!this.useDots)
15593
+ return;
15594
+ this.dotElements.forEach((dot, index) => {
15595
+ const isActive = index === this.currentSlide;
15596
+ dot.classList.toggle('active', isActive);
15597
+ dot.style.backgroundColor = isActive
15598
+ ? this.dotsOptions.activeColor
15599
+ : this.dotsOptions.color;
15600
+ });
15601
+ }
15602
+ startAutoplay() {
15603
+ this.autoplayInterval = window.setInterval(() => this.nextSlide(), this.interval);
15604
+ }
15605
+ stopAutoplay() {
15606
+ if (this.autoplayInterval !== null) {
15607
+ window.clearInterval(this.autoplayInterval);
15608
+ this.autoplayInterval = null;
15609
+ }
15610
+ }
15611
+ resetAutoplay() {
15612
+ if (this.autoplay) {
15613
+ this.stopAutoplay();
15614
+ this.startAutoplay();
15615
+ }
15616
+ }
15617
+ validateOptions() {
15618
+ this.validatePosition(this.dotsOptions.position, 'dotsPosition', 'bottom-center');
15619
+ this.validateButtonsPosition();
15620
+ }
15621
+ validatePosition(position, optionName, defaultValue) {
15622
+ if (!CustomCarouselElement.validPositions.includes(position)) {
15623
+ console.warn(`Invalid ${optionName}: ${position}. Defaulting to '${defaultValue}'.`);
15624
+ if (optionName === 'dotsPosition') {
15625
+ this.dotsOptions.position = defaultValue;
15626
+ }
15627
+ else if (optionName === 'buttonsPosition') {
15628
+ this.buttonsOptions.position = defaultValue;
15629
+ }
15630
+ }
15631
+ }
15632
+ validateButtonsPosition() {
15633
+ if (this.useButtons) {
15634
+ if (this.buttonsOptions.together) {
15635
+ this.validatePosition(this.buttonsOptions.position, 'buttonsPosition', 'bottom-center');
15636
+ }
15637
+ else if (this.buttonsOptions.position !== 'middle-sides') {
15638
+ console.warn(`Invalid buttonsPosition: ${this.buttonsOptions.position}. When buttons are not together, only 'middle-sides' is allowed. Defaulting to 'middle-sides'.`);
15639
+ this.buttonsOptions.position = 'middle-sides';
15640
+ }
15641
+ }
15642
+ }
15643
+ }
15644
+ CustomCarouselElement.defaultInterval = 5000;
15645
+ CustomCarouselElement.validPositions = [
15646
+ 'top-left',
15647
+ 'top-center',
15648
+ 'top-right',
15649
+ 'bottom-left',
15650
+ 'bottom-center',
15651
+ 'bottom-right',
15652
+ 'middle-left',
15653
+ 'middle-right',
15654
+ 'middle-sides',
15655
+ ];
15656
+ CarouselElement = CustomCarouselElement;
15657
+ }
15658
+
15233
15659
  let SpotElement;
15234
15660
  if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined') {
15235
15661
  class CustomSpotElement extends HTMLElement {
@@ -15269,6 +15695,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15269
15695
  * #########################################################
15270
15696
  */
15271
15697
  handleSpotSizeChanged(event) {
15698
+ console.info('Spot Size Changed', event);
15272
15699
  // Adjust text elements font size based on the scale factor
15273
15700
  this.adjustFontSize(event.detail.scale);
15274
15701
  }
@@ -15311,8 +15738,8 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15311
15738
  const scaleFactor = 1 + (baseFactor - 1) * dampening;
15312
15739
  // Step 3: Define the allowed range for the scale factor
15313
15740
  // This ensures that the font size never changes too drastically
15314
- const minScale = 0.9; // Font will never be smaller than 90% of original
15315
- const maxScale = 1.1; // Font will never be larger than 110% of original
15741
+ const minScale = 0.5; // Font will never be smaller than 90% of original
15742
+ const maxScale = 1.5; // Font will never be larger than 110% of original
15316
15743
  // Step 4: Clamp the scale factor to the defined range
15317
15744
  // Math.min ensures the value doesn't exceed maxScale
15318
15745
  // Math.max ensures the value isn't less than minScale
@@ -15326,15 +15753,9 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15326
15753
  if (!this.shadowRoot || !this.data || !this.content)
15327
15754
  return;
15328
15755
  const style = this.getTemplateStyle(this.data.width, this.data.height);
15329
- const spot = document.createElement('div');
15330
- spot.className = 'spot';
15331
- if (typeof this.content === 'string') {
15332
- spot.innerHTML = this.content;
15333
- }
15334
15756
  if (this.content instanceof HTMLElement) {
15335
- spot.replaceChildren(this.content);
15757
+ this.shadowRoot.replaceChildren(style, this.content);
15336
15758
  }
15337
- this.shadowRoot.replaceChildren(style, spot);
15338
15759
  }
15339
15760
  getTemplateStyle(width, height) {
15340
15761
  const style = document.createElement('style');
@@ -15347,12 +15768,6 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
15347
15768
  width: ${this.data.fluid ? '100%' : `${width}px`};
15348
15769
  height: ${this.data.fluid ? '100%' : `${height}px`};
15349
15770
  }
15350
-
15351
- :host .spot {
15352
- width: 100%;
15353
- height: 100%;
15354
- display: block;
15355
- }
15356
15771
  `;
15357
15772
  return style;
15358
15773
  }
@@ -15369,24 +15784,43 @@ class ElementService {
15369
15784
  *
15370
15785
  * This method is only available in browser environments.
15371
15786
  *
15372
- * @param {ICreateFinalElementParams} params - The parameters to create the final element.
15787
+ * @param {ICreateSpotElementParams} params - The parameters to create the final element.
15373
15788
  *
15374
15789
  * @return {HTMLElement | null} - The html element or null if the browser environment is not available.
15375
15790
  */
15376
- createFinalElement({ content, config }) {
15791
+ createSpotElement({ content, config }) {
15377
15792
  var _a;
15378
15793
  if (!this.ensureBrowserEnvironmentAndDefineElement()) {
15379
15794
  return null;
15380
15795
  }
15381
- const element = document.createElement(ELEMENT_TAG);
15382
- element.data = {
15383
- width: config.width,
15384
- height: config.height,
15385
- minScale: config === null || config === void 0 ? void 0 : config.minScale,
15796
+ const spot = document.createElement(SPOT_ELEMENT_TAG);
15797
+ spot.data = {
15386
15798
  fluid: (_a = config === null || config === void 0 ? void 0 : config.fluid) !== null && _a !== void 0 ? _a : false,
15799
+ ...config,
15387
15800
  };
15388
- element.content = content;
15389
- return element;
15801
+ spot.content = content;
15802
+ return spot;
15803
+ }
15804
+ /**
15805
+ * Creates the carousel html element based on the provided slides and configs using shadow dom.
15806
+ *
15807
+ * This method is only available in browser environments.
15808
+ *
15809
+ * @param {ICreateCarouselElementParams} params - The parameters to create the final element.
15810
+ *
15811
+ * @return {HTMLElement | null} - The html element or null if the browser environment is not available.
15812
+ */
15813
+ createCarouselElement({ slides, config, }) {
15814
+ if (!this.ensureBrowserEnvironmentAndDefineElement()) {
15815
+ return null;
15816
+ }
15817
+ const carousel = document.createElement(CAROUSEL_ELEMENT_TAG);
15818
+ carousel.data = {
15819
+ fluid: false,
15820
+ ...config,
15821
+ };
15822
+ carousel.slides = slides;
15823
+ return carousel;
15390
15824
  }
15391
15825
  /**
15392
15826
  * Overrides the spot colors with the provided colors.
@@ -15416,428 +15850,35 @@ class ElementService {
15416
15850
  console.warn('LiquidCommerce Rmn Sdk: Methods which create elements are only available in browser environments.');
15417
15851
  return false;
15418
15852
  }
15419
- if (!window.customElements.get(ELEMENT_TAG)) {
15420
- window.customElements.define(ELEMENT_TAG, SpotElement);
15853
+ if (!window.customElements.get(SPOT_ELEMENT_TAG)) {
15854
+ window.customElements.define(SPOT_ELEMENT_TAG, SpotElement);
15855
+ }
15856
+ if (!window.customElements.get(CAROUSEL_ELEMENT_TAG)) {
15857
+ window.customElements.define(CAROUSEL_ELEMENT_TAG, CarouselElement);
15421
15858
  }
15422
15859
  return true;
15423
15860
  }
15424
15861
  }
15425
15862
 
15426
- const CAROUSEL_COMPONENT_STYLE = `
15427
- :host {
15428
- position: relative;
15429
- display: inline-block;
15430
- margin: 0;
15431
- overflow: hidden;
15432
- height: 100%;
15433
- width: 100%;
15434
- }
15435
-
15436
- .carousel-slides {
15437
- position: relative;
15438
- height: 100%;
15439
- width: 100%;
15440
- }
15441
-
15442
- .carousel-slide {
15443
- display: none;
15444
-
15445
- justify-content: center;
15446
- align-items: center;
15447
- height: 100%;
15448
- width: 100%;
15449
- }
15450
-
15451
- .carousel-slide.active {
15452
- display: flex;
15453
- }
15454
-
15455
- .carousel-dots {
15456
- position: absolute;
15457
- display: flex;
15458
- align-items: center;
15459
- gap: 8px;
15460
- }
15461
-
15462
- .carousel-dots .dot {
15463
- width: 12px;
15464
- height: 12px;
15465
- border-radius: 50%;
15466
- cursor: pointer;
15467
- transition: all 0.3s ease;
15468
- }
15469
-
15470
- .carousel-dots.top-left,
15471
- .carousel-dots.bottom-left {
15472
- left: 10px;
15473
- }
15474
-
15475
- .carousel-dots.top-center,
15476
- .carousel-dots.bottom-center {
15477
- left: 50%;
15478
- transform: translateX(-50%);
15479
- }
15480
-
15481
- .carousel-dots.top-right,
15482
- .carousel-dots.bottom-right {
15483
- right: 10px;
15484
- }
15485
-
15486
- .carousel-dots.top-left,
15487
- .carousel-dots.top-center,
15488
- .carousel-dots.top-right {
15489
- top: 10px;
15490
- }
15491
-
15492
- .carousel-dots.bottom-left,
15493
- .carousel-dots.bottom-center,
15494
- .carousel-dots.bottom-right {
15495
- bottom: 10px;
15496
- }
15497
-
15498
- .carousel-dots.middle-left {
15499
- left: 10px;
15500
- top: 50%;
15501
- transform: translateY(-50%);
15502
- flex-direction: column;
15503
- }
15504
-
15505
- .carousel-dots.middle-right {
15506
- right: 10px;
15507
- top: 50%;
15508
- transform: translateY(-50%);
15509
- flex-direction: column;
15510
- }
15511
-
15512
- .carousel-buttons button {
15513
- background-color: #00000080;
15514
- color: #fff;
15515
- border: none;
15516
- padding: 10px;
15517
- cursor: pointer;
15518
- transition: background-color 0.3s ease;
15519
- }
15520
-
15521
- .carousel-buttons button:hover {
15522
- background-color: #000000b3;
15523
- }
15524
-
15525
- .carousel-buttons.buttons-separate button {
15526
- position: absolute;
15527
- top: 50%;
15528
- transform: translateY(-50%);
15529
- }
15530
-
15531
- .carousel-buttons.buttons-separate .prev-button {
15532
- left: 10px;
15533
- }
15534
-
15535
- .carousel-buttons.buttons-separate .next-button {
15536
- right: 10px;
15537
- }
15538
-
15539
- .carousel-buttons.buttons-together {
15540
- position: absolute;
15541
- display: flex;
15542
- gap: 10px;
15543
- }
15544
-
15545
- .carousel-buttons.buttons-together.top-left,
15546
- .carousel-buttons.buttons-together.bottom-left {
15547
- left: 10px;
15548
- }
15549
-
15550
- .carousel-buttons.buttons-together.top-center,
15551
- .carousel-buttons.buttons-together.bottom-center {
15552
- left: 50%;
15553
- transform: translateX(-50%);
15554
- }
15555
-
15556
- .carousel-buttons.buttons-together.top-right,
15557
- .carousel-buttons.buttons-together.bottom-right {
15558
- right: 10px;
15559
- }
15560
-
15561
- .carousel-buttons.buttons-together.top-left,
15562
- .carousel-buttons.buttons-together.top-center,
15563
- .carousel-buttons.buttons-together.top-right {
15564
- top: 10px;
15565
- }
15566
-
15567
- .carousel-buttons.buttons-together.bottom-left,
15568
- .carousel-buttons.buttons-together.bottom-center,
15569
- .carousel-buttons.buttons-together.bottom-right {
15570
- bottom: 10px;
15571
- }
15572
-
15573
- .carousel-buttons.buttons-together.middle-left,
15574
- .carousel-buttons.buttons-together.middle-right {
15575
- top: 50%;
15576
- transform: translateY(-50%);
15577
- flex-direction: column;
15578
- }
15579
-
15580
- .carousel-buttons.buttons-together.middle-left {
15581
- left: 10px;
15582
- }
15583
-
15584
- .carousel-buttons.buttons-together.middle-right {
15585
- right: 10px;
15586
- }
15587
-
15588
- @media (max-width: 768px) {
15589
- .carousel-buttons button {
15590
- padding: 8px 12px;
15591
- font-size: 14px;
15592
- }
15593
-
15594
- .carousel-dots .dot {
15595
- width: 8px;
15596
- height: 8px;
15597
- }
15598
- }
15599
- `;
15600
-
15601
- class CarouselComponent {
15602
- constructor(slides, options = {}) {
15603
- var _a, _b;
15604
- this.currentSlide = 0;
15605
- this.dotElements = [];
15606
- this.prevButton = null;
15607
- this.nextButton = null;
15608
- this.autoplayInterval = null;
15609
- this.slides = slides;
15610
- this.autoplay = (_a = options.autoplay) !== null && _a !== void 0 ? _a : true;
15611
- this.interval = (_b = options.interval) !== null && _b !== void 0 ? _b : 10000;
15612
- this.dotsOptions = this.initializeDotOptions(options.useDots);
15613
- this.buttonsOptions = this.initializeButtonOptions(options.useButtons);
15614
- this.validateOptions();
15615
- this.carousel = document.createElement('div');
15616
- this.carousel.className = 'carousel';
15617
- this.shadowRoot = this.carousel.attachShadow({ mode: 'open' });
15618
- this.render();
15619
- this.slidesContainer = this.shadowRoot.querySelector('.carousel-slides');
15620
- this.setupCarousel();
15621
- }
15622
- // Public method to get the carousel element
15623
- getElement() {
15624
- return this.carousel;
15625
- }
15626
- // Main setup methods
15627
- render() {
15628
- const style = document.createElement('style');
15629
- style.textContent = CAROUSEL_COMPONENT_STYLE;
15630
- this.shadowRoot.appendChild(style);
15631
- this.shadowRoot.appendChild(this.renderSlides());
15632
- if (this.dotsOptions) {
15633
- const dots = this.renderDots();
15634
- if (dots)
15635
- this.shadowRoot.appendChild(dots);
15636
- }
15637
- if (this.buttonsOptions) {
15638
- const buttons = this.renderButtons();
15639
- if (buttons)
15640
- this.shadowRoot.appendChild(buttons);
15641
- }
15642
- }
15643
- setupCarousel() {
15644
- this.setupDots();
15645
- this.setupButtons();
15646
- if (this.autoplay) {
15647
- this.startAutoplay();
15648
- }
15649
- this.updateCarousel();
15650
- }
15651
- // Rendering methods
15652
- renderSlides() {
15653
- const slidesContainer = document.createElement('div');
15654
- slidesContainer.className = 'carousel-slides';
15655
- this.slides.forEach((slide, index) => {
15656
- const slideElement = document.createElement('div');
15657
- slideElement.className = `carousel-slide ${index === this.currentSlide ? 'active' : ''}`;
15658
- if (typeof slide === 'string') {
15659
- slideElement.innerHTML = slide;
15660
- }
15661
- else if (slide instanceof HTMLElement) {
15662
- slideElement.appendChild(slide);
15663
- }
15664
- slidesContainer.appendChild(slideElement);
15665
- });
15666
- return slidesContainer;
15667
- }
15668
- renderDots() {
15669
- if (!this.dotsOptions)
15670
- return null;
15671
- const dotsContainer = document.createElement('div');
15672
- dotsContainer.className = `carousel-dots ${this.dotsOptions.position}`;
15673
- this.slides.forEach((_, index) => {
15674
- if (!this.dotsOptions)
15675
- return;
15676
- const dot = document.createElement('span');
15677
- dot.className = `dot ${index === this.currentSlide ? 'active' : ''}`;
15678
- dot.style.backgroundColor = this.dotsOptions.color;
15679
- dotsContainer.appendChild(dot);
15680
- });
15681
- return dotsContainer;
15682
- }
15683
- renderButtons() {
15684
- if (!this.buttonsOptions)
15685
- return null;
15686
- const buttonsContainer = document.createElement('div');
15687
- const buttonsClass = this.buttonsOptions.together
15688
- ? `buttons-together ${this.buttonsOptions.position}`
15689
- : 'buttons-separate';
15690
- buttonsContainer.className = `carousel-buttons ${buttonsClass}`;
15691
- this.prevButton = document.createElement('button');
15692
- this.prevButton.className = 'prev-button';
15693
- this.prevButton.textContent = this.buttonsOptions.prev;
15694
- this.prevButton.style.color = this.buttonsOptions.textColor;
15695
- this.prevButton.style.backgroundColor = this.buttonsOptions.backgroundColor;
15696
- this.prevButton.style.borderRadius = this.buttonsOptions.borderRadius;
15697
- buttonsContainer.appendChild(this.prevButton);
15698
- this.nextButton = document.createElement('button');
15699
- this.nextButton.className = 'next-button';
15700
- this.nextButton.textContent = this.buttonsOptions.next;
15701
- this.nextButton.style.color = this.buttonsOptions.textColor;
15702
- this.nextButton.style.backgroundColor = this.buttonsOptions.backgroundColor;
15703
- this.nextButton.style.borderRadius = this.buttonsOptions.borderRadius;
15704
- buttonsContainer.appendChild(this.nextButton);
15705
- return buttonsContainer;
15706
- }
15707
- // Setup methods
15708
- setupDots() {
15709
- if (this.dotsOptions) {
15710
- this.dotElements = Array.from(this.shadowRoot.querySelectorAll('.dot'));
15711
- this.dotElements.forEach((dot, index) => {
15712
- dot.addEventListener('click', () => {
15713
- this.goToSlide(index);
15714
- this.resetAutoplay();
15715
- });
15716
- });
15717
- }
15718
- }
15719
- setupButtons() {
15720
- var _a, _b;
15721
- if (this.buttonsOptions) {
15722
- (_a = this.prevButton) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => {
15723
- this.prevSlide();
15724
- this.resetAutoplay();
15725
- });
15726
- (_b = this.nextButton) === null || _b === void 0 ? void 0 : _b.addEventListener('click', () => {
15727
- this.nextSlide();
15728
- this.resetAutoplay();
15729
- });
15730
- }
15731
- }
15732
- // Navigation methods
15733
- nextSlide() {
15734
- this.goToSlide((this.currentSlide + 1) % this.slides.length);
15735
- }
15736
- prevSlide() {
15737
- this.goToSlide((this.currentSlide - 1 + this.slides.length) % this.slides.length);
15738
- }
15739
- goToSlide(index) {
15740
- this.currentSlide = index;
15741
- this.updateCarousel();
15742
- }
15743
- // Update methods
15744
- updateCarousel() {
15745
- const slides = Array.from(this.slidesContainer.children);
15746
- slides.forEach((slide, index) => {
15747
- if (index === this.currentSlide) {
15748
- slide.classList.add('active');
15749
- }
15750
- else {
15751
- slide.classList.remove('active');
15752
- }
15753
- });
15754
- this.updateDots();
15755
- }
15756
- updateDots() {
15757
- this.dotElements.forEach((dot, index) => {
15758
- const isActive = index === this.currentSlide;
15759
- dot.classList.toggle('active', isActive);
15760
- if (!this.dotsOptions)
15761
- return;
15762
- dot.style.backgroundColor = isActive ? this.dotsOptions.activeColor : this.dotsOptions.color;
15763
- });
15764
- }
15765
- // Autoplay methods
15766
- startAutoplay() {
15767
- this.autoplayInterval = window.setInterval(() => this.nextSlide(), this.interval);
15768
- }
15769
- stopAutoplay() {
15770
- if (this.autoplayInterval !== null) {
15771
- window.clearInterval(this.autoplayInterval);
15772
- this.autoplayInterval = null;
15773
- }
15774
- }
15775
- resetAutoplay() {
15776
- if (this.autoplay) {
15777
- this.stopAutoplay();
15778
- this.startAutoplay();
15779
- }
15780
- }
15781
- // Initialization and validation methods
15782
- initializeDotOptions(useDots) {
15783
- var _a, _b, _c;
15784
- return !useDots
15785
- ? false
15786
- : {
15787
- position: (_a = useDots === null || useDots === void 0 ? void 0 : useDots.position) !== null && _a !== void 0 ? _a : 'bottom-center',
15788
- color: (_b = useDots === null || useDots === void 0 ? void 0 : useDots.color) !== null && _b !== void 0 ? _b : '#d9d9d9',
15789
- activeColor: (_c = useDots === null || useDots === void 0 ? void 0 : useDots.activeColor) !== null && _c !== void 0 ? _c : '#b5914a',
15790
- };
15791
- }
15792
- initializeButtonOptions(useButtons) {
15793
- var _a, _b, _c, _d, _e, _f, _g;
15794
- return !useButtons
15795
- ? false
15796
- : {
15797
- position: (_a = useButtons === null || useButtons === void 0 ? void 0 : useButtons.position) !== null && _a !== void 0 ? _a : 'middle-sides',
15798
- together: (_b = useButtons === null || useButtons === void 0 ? void 0 : useButtons.together) !== null && _b !== void 0 ? _b : false,
15799
- textColor: (_c = useButtons === null || useButtons === void 0 ? void 0 : useButtons.textColor) !== null && _c !== void 0 ? _c : '#000000',
15800
- backgroundColor: (_d = useButtons === null || useButtons === void 0 ? void 0 : useButtons.backgroundColor) !== null && _d !== void 0 ? _d : '#ffffff',
15801
- borderRadius: (_e = useButtons === null || useButtons === void 0 ? void 0 : useButtons.borderRadius) !== null && _e !== void 0 ? _e : '50%',
15802
- prev: (_f = useButtons === null || useButtons === void 0 ? void 0 : useButtons.prev) !== null && _f !== void 0 ? _f : 'Prev',
15803
- next: (_g = useButtons === null || useButtons === void 0 ? void 0 : useButtons.next) !== null && _g !== void 0 ? _g : 'Next',
15804
- };
15805
- }
15806
- validateOptions() {
15807
- const validPositions = [
15808
- 'top-left',
15809
- 'top-center',
15810
- 'top-right',
15811
- 'bottom-left',
15812
- 'bottom-center',
15813
- 'bottom-right',
15814
- 'middle-left',
15815
- 'middle-right',
15816
- 'middle-sides',
15817
- ];
15818
- this.validateDotsPosition(validPositions);
15819
- this.validateButtonsPosition(validPositions);
15820
- }
15821
- validateDotsPosition(validPositions) {
15822
- if (this.dotsOptions && !validPositions.includes(this.dotsOptions.position)) {
15823
- console.warn(`Invalid dotsPosition: ${this.dotsOptions.position}. Defaulting to 'bottom-center'.`);
15824
- this.dotsOptions.position = 'bottom-center';
15825
- }
15826
- }
15827
- validateButtonsPosition(validPositions) {
15828
- if (this.buttonsOptions) {
15829
- if (this.buttonsOptions.together) {
15830
- if (!validPositions.includes(this.buttonsOptions.position)) {
15831
- console.warn(`Invalid buttonsPosition: ${this.buttonsOptions.position}. Defaulting to 'bottom-center'.`);
15832
- this.buttonsOptions.position = 'bottom-center';
15833
- }
15834
- }
15835
- else if (this.buttonsOptions.position !== 'middle-sides') {
15836
- console.warn(`Invalid buttonsPosition: ${this.buttonsOptions.position}. When buttons are not together, only 'middle-sides' is allowed. Defaulting to 'middle-sides'.`);
15837
- this.buttonsOptions.position = 'middle-sides';
15838
- }
15839
- }
15863
+ function linearGradientColorStop(overlay, fallback) {
15864
+ if (!overlay || overlay.length === 0) {
15865
+ return fallback;
15840
15866
  }
15867
+ return overlay.map(({ color, colorStop }) => `${color} ${colorStop}`).join(', ');
15868
+ }
15869
+ function spotHtmlStringToElement(htmlString) {
15870
+ const spot = document.createElement('div');
15871
+ spot.className = 'spot';
15872
+ spot.innerHTML = htmlString;
15873
+ Object.assign(spot.style, {
15874
+ position: 'relative',
15875
+ display: 'block',
15876
+ width: '100%',
15877
+ height: '100%',
15878
+ margin: '0',
15879
+ padding: '0',
15880
+ });
15881
+ return spot;
15841
15882
  }
15842
15883
 
15843
15884
  const STYLES$i = ({ primaryImage, secondaryImage }) => `
@@ -16690,13 +16731,6 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot, config) {
16690
16731
  `;
16691
16732
  }
16692
16733
 
16693
- function linearGradientColorStop(overlay, fallback) {
16694
- if (!overlay || overlay.length === 0) {
16695
- return fallback;
16696
- }
16697
- return overlay.map(({ color, colorStop }) => `${color} ${colorStop}`).join(', ');
16698
- }
16699
-
16700
16734
  const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }, { prefix, overlay }) => {
16701
16735
  const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 40%');
16702
16736
  return `
@@ -17291,7 +17325,9 @@ function rbLargeCategoryImageToutTemplate(spot, config) {
17291
17325
  `;
17292
17326
  }
17293
17327
 
17294
- const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage }, { prefix }) => `
17328
+ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage }, { prefix, overlay }) => {
17329
+ const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
17330
+ return `
17295
17331
  <style>
17296
17332
  :host {
17297
17333
  min-width: 320px;
@@ -17307,10 +17343,9 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17307
17343
  border-radius: 5px;
17308
17344
  overflow: hidden;
17309
17345
  cursor: pointer;
17310
- background-image: url("${mobilePrimaryImage}");
17346
+ background-image: linear-gradient(to top, ${linearGradient}), url("${mobilePrimaryImage}");
17311
17347
  background-size: cover;
17312
17348
  background-position: center;
17313
- background-blend-mode: overlay;
17314
17349
  background-repeat: no-repeat;
17315
17350
  }
17316
17351
 
@@ -17331,7 +17366,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17331
17366
 
17332
17367
  @media (min-width: 640px) {
17333
17368
  .${prefix}__content {
17334
- background-image: url("${primaryImage}");
17369
+ background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
17335
17370
  }
17336
17371
  }
17337
17372
 
@@ -17354,6 +17389,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
17354
17389
  }
17355
17390
  </style>
17356
17391
  `;
17392
+ };
17357
17393
  function rbNavigationBannerTemplate(spot, config) {
17358
17394
  const { prefix = '' } = config;
17359
17395
  return `
@@ -17509,7 +17545,7 @@ function rbSmallDiscoverToutTemplate(spot, config) {
17509
17545
  *
17510
17546
  * @return {string} - The spot html string.
17511
17547
  */
17512
- const GET_SPOT_TEMPLATE_HTML_STRING = (spot, config) => {
17548
+ const SPOT_TEMPLATE_HTML_ELEMENT = (spot, config) => {
17513
17549
  const templates = {
17514
17550
  // Reserve Bar Spot Templates
17515
17551
  [exports.RMN_SPOT_TYPE.RB_HOMEPAGE_HERO_THREE_TILE]: {
@@ -17568,15 +17604,16 @@ const GET_SPOT_TEMPLATE_HTML_STRING = (spot, config) => {
17568
17604
  };
17569
17605
  const spotVariants = templates[spot.spot];
17570
17606
  if (!spotVariants) {
17571
- return '';
17607
+ return null;
17572
17608
  }
17573
17609
  const variantTemplate = spotVariants[spot.variant];
17574
17610
  if (!variantTemplate) {
17575
- return '';
17611
+ return null;
17576
17612
  }
17577
17613
  // Generate a random prefix to avoid conflicts with other elements.
17578
17614
  const prefix = 's' + Math.random().toString(36).substring(6);
17579
- return variantTemplate(spot, { ...config, prefix });
17615
+ const spotHtmlString = variantTemplate(spot, { ...config, prefix });
17616
+ return spotHtmlStringToElement(spotHtmlString);
17580
17617
  };
17581
17618
 
17582
17619
  const SELECTION_API_PATH = '/spots/selection';
@@ -17629,8 +17666,8 @@ class LiquidCommerceRmnClient {
17629
17666
  /**
17630
17667
  * Injects the spot elements into their provided placement.
17631
17668
  *
17632
- * @param {IInjectSpotElement[]} data - The spot elements data.
17633
- * @param {IInjectSpotsConfig} config - The configuration object.
17669
+ * @param {IInjectSpotElement[]} data - The spot element's data.
17670
+ * @param {IInjectSpotElementConfig} config - The configuration object.
17634
17671
  *
17635
17672
  * @return {Promise<void>} - A promise that resolves when the spot elements are injected.
17636
17673
  */
@@ -17646,7 +17683,10 @@ class LiquidCommerceRmnClient {
17646
17683
  count: (_a = item === null || item === void 0 ? void 0 : item.count) !== null && _a !== void 0 ? _a : 1,
17647
17684
  });
17648
17685
  });
17649
- const response = await this.spotSelection({ spots: spotSelectionRequest });
17686
+ const response = await this.spotSelection({
17687
+ spots: spotSelectionRequest,
17688
+ url: config === null || config === void 0 ? void 0 : config.url,
17689
+ });
17650
17690
  const normalizedData = this.normalizeDataSpotType(data);
17651
17691
  for (const item of normalizedData) {
17652
17692
  const spots = response[item.spotType];
@@ -17673,20 +17713,40 @@ class LiquidCommerceRmnClient {
17673
17713
  *
17674
17714
  * @param {HTMLElement} placement - The placement element.
17675
17715
  * @param {ISpot[]} spots - The spot data.
17676
- * @param {IInjectSpotsConfig} config - The configuration object.
17716
+ * @param {IInjectSpotElementConfig} config - The configuration object.
17677
17717
  *
17678
17718
  * @return {void}
17679
17719
  */
17680
17720
  injectCarouselSpotElement(placement, spots, config) {
17721
+ var _a;
17681
17722
  const carouselSlides = [];
17682
17723
  for (const spotItem of spots) {
17683
17724
  const spot = this.elementService.overrideSpotColors(spotItem, config === null || config === void 0 ? void 0 : config.colors);
17684
- const content = GET_SPOT_TEMPLATE_HTML_STRING(spot, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
17725
+ const content = SPOT_TEMPLATE_HTML_ELEMENT(spot, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
17726
+ if (!content) {
17727
+ console.warn(`RmnSdk: Failed to inject carousel spot element. Could not create element for type "${spot.spot}".`);
17728
+ return;
17729
+ }
17685
17730
  carouselSlides.push(content);
17686
17731
  }
17687
- const carousel = new CarouselComponent(carouselSlides, config === null || config === void 0 ? void 0 : config.carousel);
17688
- const carouselElement = carousel.getElement();
17689
- placement.appendChild(carouselElement);
17732
+ const { maxWidth, maxHeight } = spots.reduce((max, spot) => ({
17733
+ maxWidth: Math.max(max.maxWidth, spot.width),
17734
+ maxHeight: Math.max(max.maxHeight, spot.height),
17735
+ }), { maxWidth: 0, maxHeight: 0 });
17736
+ const carouselElement = this.elementService.createCarouselElement({
17737
+ slides: carouselSlides,
17738
+ config: {
17739
+ width: maxWidth,
17740
+ height: maxHeight,
17741
+ 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
17742
+ ...config === null || config === void 0 ? void 0 : config.carousel,
17743
+ },
17744
+ });
17745
+ if (!carouselElement) {
17746
+ console.warn(`RmnSdk: Failed to inject spot carousel element. Could not create spot carousel element.`);
17747
+ return;
17748
+ }
17749
+ placement.replaceChildren(carouselElement);
17690
17750
  }
17691
17751
  /**
17692
17752
  * Injects a single spot element into the provided placement.
@@ -17694,27 +17754,31 @@ class LiquidCommerceRmnClient {
17694
17754
  * @param {IInjectSpotElement} injectItem - The inject item data.
17695
17755
  * @param {HTMLElement} placement - The placement element.
17696
17756
  * @param {ISpot} spot - The spot data.
17697
- * @param {IInjectSpotsConfig} config - The configuration object.
17757
+ * @param {IInjectSpotElementConfig} config - The configuration object.
17698
17758
  *
17699
17759
  * @return {void}
17700
17760
  */
17701
17761
  injectOneSpotElement(injectItem, placement, spot, config) {
17762
+ var _a;
17702
17763
  const spotData = this.elementService.overrideSpotColors(spot, config === null || config === void 0 ? void 0 : config.colors);
17703
- const content = GET_SPOT_TEMPLATE_HTML_STRING(spotData, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
17704
- const spotElement = this.elementService.createFinalElement({
17764
+ const content = SPOT_TEMPLATE_HTML_ELEMENT(spotData, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
17765
+ if (!content) {
17766
+ console.warn(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`);
17767
+ return;
17768
+ }
17769
+ const spotElement = this.elementService.createSpotElement({
17705
17770
  content,
17706
17771
  config: {
17707
- fluid: true,
17708
17772
  width: spot.width,
17709
17773
  height: spot.height,
17710
- minScale: config === null || config === void 0 ? void 0 : config.minScale,
17774
+ 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
17711
17775
  },
17712
17776
  });
17713
17777
  if (!spotElement) {
17714
17778
  console.warn(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`);
17715
17779
  return;
17716
17780
  }
17717
- placement.appendChild(spotElement);
17781
+ placement.replaceChildren(spotElement);
17718
17782
  }
17719
17783
  /**
17720
17784
  * Normalizes the spot type data by adding a number suffix to the spot type.
@@ -17751,6 +17815,38 @@ async function RmnClient(apiKey, config) {
17751
17815
  const credentials = await authService.initialize();
17752
17816
  return new LiquidCommerceRmnClient(credentials);
17753
17817
  }
17818
+ /**
17819
+ * Creates the spot html element based on the provided data using shadow dom.
17820
+ *
17821
+ * This method is useful when you are initializing the client in a non-browser environment.
17822
+ * When you request a spot selection, you will receive the spot data in server-side and return them to the client.
17823
+ * Then you can use this function to create the spot html element based on the provided data without the need of the RmnClient instance.
17824
+ *
17825
+ * @param {ISpot} spot - The spot data.
17826
+ * @param {IRmnCreateSpotElementConfig} config - The configuration object.
17827
+ *
17828
+ * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
17829
+ */
17830
+ function RmnCreateSpotElement(spot, config) {
17831
+ var _a;
17832
+ const elementService = ElementService.getInstance();
17833
+ const spotData = elementService.overrideSpotColors(spot, config === null || config === void 0 ? void 0 : config.colors);
17834
+ const content = SPOT_TEMPLATE_HTML_ELEMENT(spotData, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
17835
+ if (!content) {
17836
+ console.warn(`RmnSdk: Failed to create spot element for type "${spotData.spot}".`);
17837
+ return null;
17838
+ }
17839
+ return elementService.createSpotElement({
17840
+ content,
17841
+ config: {
17842
+ fluid: true,
17843
+ width: spot.width,
17844
+ height: spot.height,
17845
+ 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
17846
+ },
17847
+ });
17848
+ }
17754
17849
 
17755
17850
  exports.LiquidCommerceRmnClient = LiquidCommerceRmnClient;
17756
17851
  exports.RmnClient = RmnClient;
17852
+ exports.RmnCreateSpotElement = RmnCreateSpotElement;