(function ($) {
        "use strict";
            var WidgetScrollSequenceHandler = function($scope, $) { 
                let is_editable = elementorFrontend?.isEditMode();
                let toggleFeature = $scope[0].querySelector('.wkit-toggle-pricing-features-table');
let toggleFeatureId = toggleFeature.getAttribute("data-connection-id");

let advancedWget = '';
if(toggleFeatureId){
    advancedWget = document.querySelector('.advanced-'+toggleFeatureId);
}

let togglePricing = toggleFeature.querySelector('.pricing-number'),
    toggleDiscount = toggleFeature.querySelector('.pricing-discount'),
    toggleLink = toggleFeature.querySelector('.toggle-pricing-button-link'),
    toggleProducts = toggleFeature.querySelectorAll('.toggle-text'),
    toggleProductStart = toggleFeature.querySelector('.toggle-products-top-start'),
    toggleProductEnd =  toggleFeature.querySelector('.toggle-products-top-end'),
    toggleTooltip = toggleFeature.querySelector('.toggle-tooltip-text');


let togglePricingOn = Number(togglePricing.getAttribute("data-pricing-on")),
    togglePricingOff = Number(togglePricing.getAttribute("data-pricing-off")),
    toggleDiscountOn = Number(toggleDiscount.getAttribute("data-discount-on")),
    toggleDiscountOff = Number(toggleDiscount.getAttribute("data-discount-off")),
    toggleLinkOn = toggleLink.getAttribute("data-link-on"),
    toggleLinkOnT = toggleLink.getAttribute("data-on-target"),
    toggleLinkOff = toggleLink.getAttribute("data-link-off"),
    toggleLinkOffT = toggleLink.getAttribute("data-off-target"),
    toggleTooltipOn = toggleTooltip.getAttribute("data-tooltip-on"),
    toggleTooltipOff = toggleTooltip.getAttribute("data-tooltip-off");
    console.log(togglePricingOn);
    console.log(togglePricingOff);

let toggleSwitch = toggleFeature.querySelector('.toggle-checkbtn');

toggleProducts.forEach((el,index)=>{
    if(index==0){
         toggleProductStart.classList.add('active'); 
    }
})


toggleSwitch.addEventListener('change', function(){
    let advCindex;
   if(toggleSwitch.checked){
      advCindex = 1;
      togglePricing.textContent = togglePricingOn;
      toggleDiscount.textContent = toggleDiscountOn;
      toggleLink.href = toggleLinkOn;
      toggleLink.target = toggleLinkOnT;
      toggleProductEnd.classList.add('active');
      toggleProductStart.classList.remove('active');
      toggleTooltip.textContent = toggleTooltipOn;
   }else{
      advCindex = 0;
      togglePricing.textContent = togglePricingOff;
      toggleDiscount.textContent = toggleDiscountOff;
      toggleLink.href = toggleLinkOff;
      toggleLink.target = toggleLinkOffT;
      toggleProductStart.classList.add('active');
      toggleProductEnd.classList.remove('active');
      toggleTooltip.textContent = toggleTooltipOff;
   }
   
   // Advanced widget Connection
   if(advancedWget){
      let Button = advancedWget.querySelectorAll('.wkit-button');
      let priCnt = advancedWget.querySelectorAll('.wkit-pricing-content');
      let actBtn  = advancedWget.querySelector('.wkit-button.active');
      if(actBtn){
          actBtn.classList.remove('active')
      }
      Button[advCindex].classList.add('active')
      let actCnt  = advancedWget.querySelector('.wkit-pricing-content.active');
      if(actCnt){
          actCnt.classList.remove('active')
      }
      priCnt[advCindex].classList.add('active')
  }
});
  
            };	
        $(window).on('elementor/frontend/init', function () {
          elementorFrontend.hooks.addAction('frontend/element_ready/wb-nvkmly24.default', WidgetScrollSequenceHandler);
        });
    })(jQuery);