/**
 * @package     productive-commerce
 * @author      productiveminds.com
 * @copyright   productiveminds.com
 */

let swiper_var_elementor_enabled_productive_commerce                = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_enabled;
let swiper_var_elementor_slidesPerView_productive_commerce          = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_slidesPerView;
let swiper_var_elementor_slidesBreakPoints_productive_commerce      = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_slidesBreakPoints;
let swiper_var_elementor_effect_productive_commerce                 = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_effect;
let swiper_var_elementor_loop_productive_commerce                   = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_loop;
let swiper_var_elementor_direction_productive_commerce              = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_direction;
let swiper_var_elementor_lazyLoading_productive_commerce            = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_lazyLoading;
let swiper_var_elementor_autoplay_productive_commerce               = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_autoplay;
let swiper_var_elementor_delay_productive_commerce                  = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_delay;
let swiper_var_elementor_pauseOnMouseEnter_productive_commerce      = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_pauseOnMouseEnter;
let swiper_var_elementor_scrollbar_productive_commerce              = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_scrollbar;
let swiper_var_elementor_simulateTouch_productive_commerce          = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_simulateTouch;
let swiper_var_elementor_grabCursor_productive_commerce             = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_grabCursor;
let swiper_var_elementor_slides_margin_productive_commerce          = productiveminds_lib_elementor_productive_commerce_js_name.swiper_var_slides_margin;

const global_elementor_slidesPerViewValue_productive_commerce = swiper_var_elementor_slidesPerView_productive_commerce.split(",");

/* Start:: productive_elementor_widget_wishlist_list */
class Productive_Elementor_Widget_Obj_Wishlist_List extends elementorModules.frontend.handlers.Base {
    update_Productive_Elementor_Widget_Obj_Wishlist_List_Content() {
        let slider_slides_per_view = this.getElementSettings( 'slider_slides_per_view' );
        let swiper_container = document.querySelector( `div[data-id="${this.getID()}"] .swiper_container .productiveminds-wishlist-list-slider.via_elementor_slider` );
        if( (undefined !== swiper_container && null !== swiper_container) && (undefined !== slider_slides_per_view && null !== slider_slides_per_view) ) {
            productive_commerce_init_the_slider( this.getElementSettings, slider_slides_per_view, swiper_container );
        }
    }
    onInit() {
        this.update_Productive_Elementor_Widget_Obj_Wishlist_List_Content();
    }
    onElementChange( propertyName ) {
        if ( 'slider_slides_per_view' === propertyName || 'section_style_each_item_col_gap' === propertyName ) {
            this.update_Productive_Elementor_Widget_Obj_Wishlist_List_Content();
        }
    }
};
window.addEventListener( 'elementor/frontend/init', () => {
    const addHandler = ( $element ) => {
        elementorFrontend.elementsHandler.addHandler( Productive_Elementor_Widget_Obj_Wishlist_List, { $element } );
    };
    elementorFrontend.hooks.addAction( 'frontend/element_ready/productive_elementor_widget_wishlist_list.default', addHandler );
} );
/* End:: productive_elementor_widget_wishlist_list */

/* Start:: productive_elementor_widget_compare_list */
class Productive_Elementor_Widget_Obj_Compare_List extends elementorModules.frontend.handlers.Base {
    update_Productive_Elementor_Widget_Obj_Compare_List_Content() {
        let slider_slides_per_view = this.getElementSettings( 'slider_slides_per_view' );
        let swiper_container = document.querySelector( `div[data-id="${this.getID()}"] .swiper_container .productiveminds-compare-list-slider.via_elementor_slider` );
        if( (undefined !== swiper_container && null !== swiper_container) && (undefined !== slider_slides_per_view && null !== slider_slides_per_view) ) {
            productive_commerce_init_the_slider( this.getElementSettings, slider_slides_per_view, swiper_container );
        }
        let productiveminds_section = `div[data-id="${this.getID()}"] .productiveminds_section.elementor`;
        let productiveminds_section_obj = document.querySelector( productiveminds_section );
        if( undefined !== productiveminds_section_obj && null !== productiveminds_section_obj && undefined !== this.getElementSettings( 'section_content_layout_enable_accordion_toggle' ) ) {
            let section_content_layout_enable_accordion_toggle = this.getElementSettings( 'section_content_layout_enable_accordion_toggle' );
            productive_Toggle_Accodion_Content_Toggle( productiveminds_section_obj, "productive_toggler_compare_list", ".clickable_container_css_class", ".toggle_symbol_container_css_class", ".toggleable_content_css_class", section_content_layout_enable_accordion_toggle);
        }
        let section_toggle_icon_style_val = this.getElementSettings( 'section_toggle_icon_style' );
        if( null !== document.querySelector( `div[data-id="${this.getID()}"] .toggle_symbol_container_css_class` ) && undefined !== section_toggle_icon_style_val && null !== section_toggle_icon_style_val ) {
            const toggle_symbol_container_css_class_val = `div[data-id="${this.getID()}"] .toggle_symbol_container_css_class`;
            this.toggle_symbol_container_css_class_vals = document.querySelectorAll( toggle_symbol_container_css_class_val );
            for( i = 0; i < this.toggle_symbol_container_css_class_vals.length; i++ ) {
                this.toggle_symbol_container_css_class_vals[i].classList.remove( "angled", "arrowed", "plusminused" );
                this.toggle_symbol_container_css_class_vals[i].classList.add(section_toggle_icon_style_val);
            }
        }
    }
    onInit() {
        this.update_Productive_Elementor_Widget_Obj_Compare_List_Content();
    }
    onElementChange( propertyName ) {
        if ( 'slider_slides_per_view' === propertyName || 'section_style_each_item_col_gap' === propertyName || 'section_content_layout_enable_accordion_toggle' === propertyName || 'section_toggle_icon_style' === propertyName ) {
            this.update_Productive_Elementor_Widget_Obj_Compare_List_Content();
        }
    }
};
window.addEventListener( 'elementor/frontend/init', () => {
    const addHandler = ( $element ) => {
        elementorFrontend.elementsHandler.addHandler( Productive_Elementor_Widget_Obj_Compare_List, { $element } );
    };
    elementorFrontend.hooks.addAction( 'frontend/element_ready/productive_elementor_widget_compare_list.default', addHandler );
} );
/* End:: productive_elementor_widget_compare_list */

function productive_commerce_init_the_slider( elementSettings, slider_slides_per_view, the_slide_container ) {
    
    /* Start with desktop breakpoint */
    /* parseFloat( global_elementor_slidesPerViewValue_productive_commerce[4] ); */
    let slider_slides_per_view_desktop =  parseFloat( global_elementor_slidesPerViewValue_productive_commerce[4] );
    if( undefined !== slider_slides_per_view ) {
        slider_slides_per_view_desktop     = slider_slides_per_view;
    }
    
    /* parseFloat( global_elementor_slidesPerViewValue_productive_commerce[5] ); */
    let slider_slides_per_view_widescreen = slider_slides_per_view_desktop;
    if( undefined !== elementSettings( 'slider_slides_per_view_widescreen' ) ) {
        slider_slides_per_view_widescreen       = elementSettings( 'slider_slides_per_view_widescreen' );
    }
    
    /* parseFloat( global_elementor_slidesPerViewValue_productive_commerce[3] ); */
    let slider_slides_per_view_tablet_extra =  slider_slides_per_view;
    if( undefined !== elementSettings( 'slider_slides_per_view_tablet_extra' ) ) {
        slider_slides_per_view_tablet_extra     = elementSettings( 'slider_slides_per_view_tablet_extra' );
    }

    /* parseFloat( global_elementor_slidesPerViewValue_productive_commerce[2] ); */
    let slider_slides_per_view_tablet =  parseFloat( global_elementor_slidesPerViewValue_productive_commerce[2] );
    if( undefined !== elementSettings( 'slider_slides_per_view_tablet' ) ) {
        slider_slides_per_view_tablet     = elementSettings( 'slider_slides_per_view_tablet' );
    }

    /* parseFloat( global_elementor_slidesPerViewValue_productive_commerce[1] ); */
    let slider_slides_per_view_mobile_extra =  slider_slides_per_view_tablet;
    if( undefined !== elementSettings( 'slider_slides_per_view_mobile_extra' ) ) {
        slider_slides_per_view_mobile_extra     = elementSettings( 'slider_slides_per_view_mobile_extra' );
    }

    let slider_slides_per_view_mobile =  parseFloat( global_elementor_slidesPerViewValue_productive_commerce[0] );
    if( undefined !== elementSettings( 'slider_slides_per_view_mobile' ) ) {
        slider_slides_per_view_mobile     = elementSettings( 'slider_slides_per_view_mobile' );
    }
    
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_effect' ) ) {
        swiper_var_elementor_effect_productive_commerce     = elementSettings( 'section_slider_settings_swiper_var_effect' );
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_direction' ) ) {
        swiper_var_elementor_direction_productive_commerce     = elementSettings( 'section_slider_settings_swiper_var_direction' );
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_autoplay' ) ) {
        swiper_var_elementor_autoplay_productive_commerce     = false;
        if( 'true' === elementSettings( 'section_slider_settings_swiper_var_autoplay' ) ) {
            swiper_var_elementor_autoplay_productive_commerce     = true;
        }
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_simulateTouch' ) ) {
        swiper_var_elementor_simulateTouch_productive_commerce     = false;
        if( 'true' === elementSettings( 'section_slider_settings_swiper_var_simulateTouch' ) ) {
            swiper_var_elementor_simulateTouch_productive_commerce     = true;
        }
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_delay' ) ) {
        swiper_var_elementor_delay_productive_commerce     = elementSettings( 'section_slider_settings_swiper_var_delay' );
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_loop' ) ) {
        swiper_var_elementor_loop_productive_commerce     = false;
        if( 'true' === elementSettings( 'section_slider_settings_swiper_var_loop' ) ) {
            swiper_var_elementor_loop_productive_commerce     = true;
        }
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_pauseOnMouseEnter' ) ) {
        swiper_var_elementor_pauseOnMouseEnter_productive_commerce     = false;
        if( 'true' === elementSettings( 'section_slider_settings_swiper_var_pauseOnMouseEnter' ) ) {
            swiper_var_elementor_pauseOnMouseEnter_productive_commerce     = true;
        }
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_lazyLoading' ) ) {
        swiper_var_elementor_lazyLoading_productive_commerce     = false;
        if( 'true' === elementSettings( 'section_slider_settings_swiper_var_lazyLoading' ) ) {
            swiper_var_elementor_lazyLoading_productive_commerce     = true;
        }
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_grabCursor' ) ) {
        swiper_var_elementor_grabCursor_productive_commerce     = false;
        if( 'true' === elementSettings( 'section_slider_settings_swiper_var_grabCursor' ) ) {
            swiper_var_elementor_grabCursor_productive_commerce     = true;
        }
    }
    if( undefined !== elementSettings( 'section_slider_settings_swiper_var_scrollbar' ) ) {
        swiper_var_elementor_scrollbar_productive_commerce     = false;
        if( 'true' === elementSettings( 'section_slider_settings_swiper_var_scrollbar' ) ) {
            swiper_var_elementor_scrollbar_productive_commerce     = true;
        }
    }
    
    let swiper_var_elementor_slides_margin_productive_commerce_col_gap = swiper_var_elementor_slides_margin_productive_commerce;
    if( undefined !== elementSettings( 'section_style_each_item_col_gap' ) ) {
        swiper_var_elementor_slides_margin_productive_commerce_col_gap = productive_Common_Js_Each_Slider_Item_Col_Gap( elementSettings( 'section_style_each_item_col_gap' ) );
    }
    
    if( null === swiper_var_elementor_slides_margin_productive_commerce_col_gap || undefined === swiper_var_elementor_slides_margin_productive_commerce_col_gap || swiper_var_elementor_slides_margin_productive_commerce_col_gap.includes('NaN') ) {
        swiper_var_elementor_slides_margin_productive_commerce_col_gap = swiper_var_elementor_slides_margin_productive_commerce;
    }
    
    let swiper_var_elementor_slidesPerView_productive_commerce = slider_slides_per_view_mobile+", "+slider_slides_per_view_mobile_extra+", "+slider_slides_per_view_tablet+", "+slider_slides_per_view_tablet_extra+", "+slider_slides_per_view_desktop+", "+slider_slides_per_view_widescreen;
    productive_Common_Js_Slider(the_slide_container, swiper_var_elementor_enabled_productive_commerce, swiper_var_elementor_slidesPerView_productive_commerce, swiper_var_elementor_slidesBreakPoints_productive_commerce, swiper_var_elementor_effect_productive_commerce, swiper_var_elementor_loop_productive_commerce, swiper_var_elementor_direction_productive_commerce, swiper_var_elementor_lazyLoading_productive_commerce, swiper_var_elementor_autoplay_productive_commerce, swiper_var_elementor_delay_productive_commerce, swiper_var_elementor_pauseOnMouseEnter_productive_commerce, swiper_var_elementor_scrollbar_productive_commerce, swiper_var_elementor_simulateTouch_productive_commerce, swiper_var_elementor_grabCursor_productive_commerce, swiper_var_elementor_slides_margin_productive_commerce_col_gap );

}
