/******/ (() => { // webpackBootstrap
/*!************************************************!*\
  !*** ./src/elementor/js/elementor-frontend.js ***!
  \************************************************/
// This file has been consolidated into news-ticker.js to eliminate redundancy
// All marquee functionality is now handled by the main news-ticker.js file
/**
 * MarqueeX Elementor Frontend Handler
 * Professional animation controller for marquee elements with enhanced performance
 */
(function ($, window) {
  "use strict";

  /**
   * Calculates and applies optimal animation speed for marquee elements
   * @param {jQuery} $element - The Elementor widget element
   */
  const handleMarqueeSpeed = $element => {
    const wrapper = $element.find(".marqueex-marquee-block");
    const animatedTracks = $element.find(".marqueex-marquee-track");
    // Early return if no tracks found
    if (!animatedTracks.length) return;
    const elementConfig = wrapper.data("settings") || {};
    const speedValue = Math.max(1, elementConfig.marquee_speed || wrapper.data("speed") || 10);

    // Determine layout orientation based on viewport and element class
    const isDesktopVertical = window.innerWidth > 767 && animatedTracks.closest(".marqueex-marquee-vertical").length > 0;

    // Calculate total content dimensions with error handling
    let totalContentSize = 0;
    animatedTracks.each(function () {
      const trackElement = this;
      try {
        const size = isDesktopVertical ? trackElement.scrollHeight : trackElement.scrollWidth;
        totalContentSize += Math.max(size, 0);
      } catch (error) {
        console.warn("MarqueeX: Error calculating content size", error);
      }
    });

    // Prevent division by zero and ensure minimum content size
    if (totalContentSize <= 0) {
      totalContentSize = 100; // Fallback minimum size
    }

    // Convert speed setting to animation duration
    const speedMultiplier = 10;
    const pixelsPerSecond = speedValue * speedMultiplier;
    const calculatedDuration = Math.max(1, totalContentSize / pixelsPerSecond);

    // Apply optimized animation duration with smooth transitions
    animatedTracks.each(function () {
      const $track = $(this);

      // Use requestAnimationFrame for smooth updates with proper timing
      requestAnimationFrame(() => {
        // Store current animation progress to maintain continuity
        const computedStyle = window.getComputedStyle(this);
        const currentTransform = computedStyle.transform;
        let currentProgress = 0;
        if (currentTransform && currentTransform !== 'none') {
          const matrix = currentTransform.match(/matrix.*\((.+)\)/);
          if (matrix) {
            const values = matrix[1].split(', ');
            const translateValue = isDesktopVertical ? parseFloat(values[5]) : parseFloat(values[4]);
            currentProgress = Math.abs(translateValue) / totalContentSize;
          }
        }

        // Calculate remaining duration based on current progress
        const remainingProgress = 1 - currentProgress % 1;
        const adjustedDuration = calculatedDuration * remainingProgress;

        // Apply smooth animation with seamless loop
        $track.css({
          "animation-duration": `${adjustedDuration.toFixed(2)}s`,
          "animation-delay": `-${(adjustedDuration * (currentProgress % 1)).toFixed(3)}s`
        });
      });
    });
  };

  // Expose function globally for Elementor integration
  window.handleMarqueeSpeed = handleMarqueeSpeed;
})(jQuery, window);
/******/ })()
;