<?php   
  
$wp_customize->add_section('constructionarc_slider_section', array(
    'title'		=>	esc_html__('Home Slider','construction-arc'),
    'priority'  => 15
));
$wp_customize->add_setting('constructionarc_slider_nav', array(
    'transport' => 'postMessage',
    'sanitize_callback' => 'wp_kses_post',
));
$wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_slider_nav', array(
    'type' => 'tab',
    'section' => 'constructionarc_slider_section',
    'buttons' => array(
        array(
            'name' => esc_html__('Content', 'construction-arc'),
            'fields' => array(
                'constructionarc_banner_slider_section',
                'constructionarc_slider_height',
                'constructionarc_slider_type',
                'constructionarc_slider_advance_settings',
                'constructionarc_banner_sliders',
            ),
            'active' => true,
        ),
        array(
            'name' => esc_html__('Style', 'construction-arc'),
            'fields' => array(
                'constructionarc_banner_overlay_color',
                'constructionarc_caption_title_font_size',
                'constructionarc_slider_seperator0',
                'constructionarc_slider_section_seperator',
                'constructionarc_slider_bottom_seperator',
                'constructionarc_slider_bs_color',
                'constructionarc_slider_bs_height',
                'main_slider_controls'
            ),
        ),
        array(
            'name' => esc_html__('Caption', 'construction-arc'),
            'fields' => array(
                'constructionarc_caption_width',
            )
        )
    ),
)));

$wp_customize->add_setting('constructionarc_banner_slider_section', array(
    'default' => 'enable',
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_switch',     
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_banner_slider_section', array(
    'label' => esc_html__('Enable', 'construction-arc'),
    'section' => 'constructionarc_slider_section',
    'switch_label' => array(
        'enable' => esc_html__('Yes', 'construction-arc'),
        'disable' => esc_html__('No', 'construction-arc'),
    ),
)));

$wp_customize->add_setting('constructionarc_slider_height', array(
    'sanitize_callback' => 'absint',
    'default' => 650,
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_slider_height', array(
    'section' => 'constructionarc_slider_section',
    'label' => esc_html__('Slider Height (px)', 'construction-arc'),
    'input_attrs' => array(
        'min' =>400,
        'max' => 900,
        'step' => 1
    )
)));


$wp_customize->add_setting('constructionarc_slider_type', array(
    'default' => 'default',
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_select'
));
$wp_customize->add_control('constructionarc_slider_type', array(
    'section' => 'constructionarc_slider_section',
    'type' => 'radio',
    'label' => esc_html__('Select Type', 'construction-arc'),
    'choices' => array(
        'default' => esc_html__('Default', 'construction-arc'),
        'advance' => esc_html__('Advanced', 'construction-arc'),
    )
));

$wp_customize->add_setting('constructionarc_banner_sliders', array(
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		
    'default' => json_encode(array(
        array(
            'subtitile'  => '',
            'slider_page' => '',
            'button_text' => '',
            'button_url' => '',
            'button_one_text' => '',
            'button_one_url' => '',
            'alignment' => 'center',
        )
    ))
));
$wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize, 'constructionarc_banner_sliders', 
    array(
        'label' 	   => esc_html__('Default Slides Settings', 'construction-arc'),
        'section' 	   => 'constructionarc_slider_section',
        'box_label' => esc_html__('Default Slide Options', 'construction-arc'),
        'add_label' => esc_html__('Add New', 'construction-arc'),
    ),
    array(
        'subtitile' => array(
            'type' => 'text',
            'label' => __("Super Title", 'construction-arc'),
        ),
        'slider_page' => array(
            'type' => 'select',
            'label' => esc_html__('Select Page', 'construction-arc'),
            'options' => $pages
        ),
        'button_wrapper_start' => array(
            'type' => 'wrapper-start',
            'label' => esc_html__('First Button Settings','construction-arc'),
        ),
        'button_text' => array(
            'type' => 'text',
            'label' => esc_html__('Button Text', 'construction-arc'),
            'default' => ''
        ),
        'button_url' => array(
            'type' => 'url',
            'label' => esc_html__('Button Url', 'construction-arc'),
            'default' => ''
        ),
        'button_wrapper_end' => array(
            'type' => 'wrapper-end',
        ),
        'button_wrapper_start2' => array(
            'type' => 'wrapper-start',
            'label' => esc_html__('Second Button Settings','construction-arc'),
        ),
        'button_one_text' => array(
            'type' => 'text',
            'label' => esc_html__('Button Text', 'construction-arc'),
            'default' => ''
        ),
        'button_one_url' => array(
            'type' => 'url',
            'label' => esc_html__('Button Url', 'construction-arc'),
            'default' => ''
        ),
        'button_wrapper_end2' => array(
            'type' => 'wrapper-end',
        ),
        'alignment' => array(
            'type' => 'select',
            'label' => esc_html__("Alignment", 'construction-arc'),
            'default' => 'center',
            'options' => array(
                'start' => esc_html__('Left', 'construction-arc'),
                'center' => esc_html__('Center', 'construction-arc'),
                'end' => esc_html__('Right', 'construction-arc')
            )
        ),
    )
));

$id = "slider";
$wp_customize->add_setting("constructionarc_{$id}_advance_settings", array(
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		
    'default' => json_encode(array(
        array(
            'block_image'      => '',
            'block_subtitile'  => '',
            'block_title'      => '',
            'block_desc'       => '',
            'button_text'       => '',
            'button_url'        => '',
            'button_one_text'   => '',
            'button_one_url'    => '',
            'alignment'         => 'center',
        )
    ))
));
$wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize, "constructionarc_{$id}_advance_settings", 
    array(
        'label' 	   => esc_html__('Advanced Slides Settings', 'construction-arc'),
        'section' 	   => "constructionarc_{$id}_section",
        'box_label' => esc_html__('Advanced Slide Settings', 'construction-arc'),
        'add_label' => esc_html__('Add New Slide', 'construction-arc'),
    ),
    array(
        'block_image' => array(
            'type' => 'upload',
            'label' => __("Upload Image", 'construction-arc'),
        ),
        'block_subtitile' => array(
            'type' => 'text',
            'label' => __("Super Title", 'construction-arc'),
        ),
        'block_title' => array(
            'type' => 'text',
            'label' => __("Title", 'construction-arc'),
        ),
        'block_desc' => array(
            'type' => 'textarea',
            'label' => __("Short Description", 'construction-arc'),
        ),
        'button_wrapper_start' => array(
            'type' => 'wrapper-start',
            'label' => esc_html__('First Button Settings','construction-arc'),
        ),
        'button_text' => array(
            'type' => 'text',
            'label' => esc_html__('First Button Text', 'construction-arc'),
            'default' => ''
        ),
        'button_url' => array(
            'type' => 'url',
            'label' => esc_html__('First Button Url', 'construction-arc'),
            'default' => ''
        ),
        'button_wrapper_end' => array(
            'type' => 'wrapper-end',
        ),
        'button_wrapper_start2' => array(
            'type' => 'wrapper-start',
            'label' => esc_html__('Second Button Settings','construction-arc'),
        ),
        'button_one_text' => array(
            'type' => 'text',
            'label' => esc_html__('Second Button Text', 'construction-arc'),
            'default' => ''
        ),
        'button_one_url' => array(
            'type' => 'url',
            'label' => esc_html__('Second Button Url', 'construction-arc'),
            'default' => ''
        ),
        'button_wrapper_end2' => array(
            'type' => 'wrapper-end',
        ),
        'alignment' => array(
            'type' => 'select',
            'label' => esc_html__("Alignment", 'construction-arc'),
            'default' => 'center',
            'options' => array(
                'start' => esc_html__('Left', 'construction-arc'),
                'center' => esc_html__('Center', 'construction-arc'),
                'end' => esc_html__('Right', 'construction-arc')
            )
        ),
    )
));

$wp_customize->add_setting('constructionarc_banner_overlay_color', array(
    'default' => 'rgba(0, 0, 0, 0.35)',
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_color_alpha',
));
$wp_customize->add_control(new constructionarc_Alpha_Color_Control($wp_customize, 'constructionarc_banner_overlay_color', array(
    'label' => esc_html__('Background Overlay Color', 'construction-arc'),
    'section' => 'constructionarc_slider_section'
)));

$wp_customize->add_setting('constructionarc_caption_title_font_size', array(
    'sanitize_callback' => 'absint',
    'default' => 45,
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_caption_title_font_size', array(
    'section' => 'constructionarc_slider_section',
    'label' => esc_html__('Title Font Size', 'construction-arc'),
    'input_attrs' => array(
        'min' =>20,
        'max' => 80,
        'step' => 1
    )
)));

$wp_customize->add_setting('constructionarc_caption_width', array(
    'sanitize_callback' => 'absint',
    'default' => 70,
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_caption_width', array(
    'section' => 'constructionarc_slider_section',
    'label' => esc_html__('Caption Width (%)', 'construction-arc'),
    'input_attrs' => array(
        'min' =>50,
        'max' => 100,
        'step' => 1
    )
)));

$wp_customize->add_setting('main_slider_controls',
    array(
        'sanitize_callback' => 'constructionarc_themes_sanitize_field_background',
        'transport' => 'postMessage',
        'default'           => json_encode(array(
            'navtype'       => 'both',
            'navstyle'      => 'arrowstyle',
            'dotstyle'      => 'dotstyle',
            'loop'          => 1,
            'autoplay'      => 1,
            'easing'        => 'fadeOut',
            'drag'          => 1,
            'speed'         => 500,
            'pause'         => 5000
        )),
    )
);
$wp_customize->add_control(new constructionarc_Themes_Custom_Control_Group( $wp_customize, 'main_slider_controls',
        array(
            'label'    => esc_html__( 'Slider Controls', 'construction-arc' ),
            'section'  => 'constructionarc_slider_section',
        ),
        array(
            'navtype'      => array(
                'type'  => 'select',
                'label' => esc_html__( 'Navigation', 'construction-arc' ),
                'options' => array(
                    'both' => esc_html__("Arrows and Dots", 'construction-arc'),
                    'arrows' => esc_html__("Arrows", 'construction-arc'),
                    'dots' => esc_html__("Dots", 'construction-arc'),
                    'none' => esc_html__("None", 'construction-arc'),
                )
            ),
            'navstyle'      => array(
                'type'  => 'select',
                'label' => esc_html__( 'Nav Style', 'construction-arc' ),
                'options' => array(
                    'imagestyle' => esc_html__("Images", 'construction-arc'),
                    'arrowstyle' => esc_html__("Arrows", 'construction-arc'),
                )
            ),
            'dotstyle'      => array(
                'type'  => 'select',
                'label' => esc_html__( 'Dots Style', 'construction-arc' ),
                'options' => array(
                    'numberstyle' => esc_html__("Number", 'construction-arc'),
                    'dotstyle' => esc_html__("Dots", 'construction-arc'),
                )
            ),
            'loop'      => array(
                'type'  => 'checkbox',
                'label' => esc_html__( 'Loop', 'construction-arc' ),
            ),
            'autoplay' => array(
                'type'  => 'checkbox',
                'label' => esc_html__( 'Auto Play', 'construction-arc' ),
            ),
            'drag' => array(
                'type'  => 'checkbox',
                'label' => esc_html__( 'Drag', 'construction-arc' ),
            ),
            'easing'      => array(
                'type'  => 'select',
                'label' => esc_html__( 'Easing', 'construction-arc' ),
                'options' => array(
                    'fadeOut' => __("fadeOut", 'construction-arc'),
                    'fadeIn' => __("fadeIn", 'construction-arc'),
                    'slide' => __("Slide", 'construction-arc'),
                )
            ),
            'speed'      => array(
                'type'  => 'number',
                'label' => esc_html__( 'Transition Speed (ms)', 'construction-arc' ),
            ),
            'pause'      => array(
                'type'  => 'number',
                'label' => esc_html__( 'Autoplay Speed', 'construction-arc' ),
            )
        )
    )
);


$wp_customize->add_setting("constructionarc_slider_seperator0", array(
    'sanitize_callback' => 'sanitize_text_field',
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Separator_Control($wp_customize, "constructionarc_slider_seperator0", array(
    'section' => "constructionarc_slider_section",
)));

$wp_customize->add_setting("constructionarc_slider_section_seperator", array(
    'transport' => 'postMessage',
    'sanitize_callback' => 'sanitize_text_field',
    'default' => 'no',
));
$wp_customize->add_control("constructionarc_slider_section_seperator", array(
    'section' => "constructionarc_slider_section",
    'type' => 'select',
    'label' => esc_html__('Select Separator', 'construction-arc'),
    'choices' => array(
        'no' => esc_html__('Disable', 'construction-arc'),
        'bottom' => esc_html__('Bottom Separator', 'construction-arc'),
    )
));

$wp_customize->add_setting("constructionarc_slider_bottom_seperator", array(
    'sanitize_callback' => 'sanitize_text_field',
    'default' => 'curv-8',
    'transport' => 'postMessage'
));
$wp_customize->add_control("constructionarc_slider_bottom_seperator", array(
    'section' => "constructionarc_slider_section",
    'type' => 'select',
    'label' => esc_html__('Bottom Separator', 'construction-arc'),
    'choices' => constructionarc_themes_svg_seperator(),
));

$wp_customize->add_setting("constructionarc_slider_bs_color", array(
    'default' => '',
    'sanitize_callback' => 'constructionarc_themes_sanitize_color_alpha',
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Alpha_Color_Control($wp_customize, "constructionarc_slider_bs_color", array(
    'section' => "constructionarc_slider_section",
    'label' => esc_html__('Bottom Separator Color', 'construction-arc'),
)));


$wp_customize->add_setting("constructionarc_slider_bs_height", array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_number_blank',
    'default' => 60,
    'transport' => 'postMessage'
));
$wp_customize->add_setting("constructionarc_slider_bs_height_tablet", array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_number_blank',
    'default' => 40,
    'transport' => 'postMessage'
));
$wp_customize->add_setting("constructionarc_slider_bs_height_mobile", array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_number_blank',
    'default' => 20,
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Range_Slider_Control($wp_customize, "constructionarc_slider_bs_height", array(
    'section' => "constructionarc_slider_section",
    'transport' => 'postMessage',
    'label' => esc_html__('Bottom Separator Height', 'construction-arc'),
    'input_attrs' => array(
        'min' => 20,
        'max' => 400,
        'step' => 1,
    ),
    'settings' => array(
        'desktop' => "constructionarc_slider_bs_height",
        'tablet' => "constructionarc_slider_bs_height_tablet",
        'mobile' => "constructionarc_slider_bs_height_mobile",
    )
)));


$wp_customize->add_setting('constructionarc_pro_slider', array(
    'sanitize_callback' => 'constructionarc_sanitize_text'
));
$wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_slider', array(
    'section' => 'constructionarc_slider_section',
    'label' => esc_html__('For More Settings,', 'construction-arc'),
    'choices' => array(
        esc_html__('Add Unlimited slider Items', 'construction-arc'),
        esc_html__('Advanced Level of Customization', 'construction-arc'),
        esc_html__('Select Different Slider Types Video, Single Banner & Revolution', 'construction-arc'),
        esc_html__('Get Options to Enter Revolution Slider Shortcode', 'construction-arc'),
        esc_html__('Get Change SuperTitle, Title, Description & Button Color', 'construction-arc'),
        esc_html__('Caption Background Color Options', 'construction-arc'),
        esc_html__('Caption Text Alignment Options', 'construction-arc'),
        esc_html__('Customize Margin & Padding', 'construction-arc'),
        esc_html__('Adjust Slider Height & Font Size', 'construction-arc'),
        esc_html__('Option to configure slider pause and duration', 'construction-arc'),
    ),
    'priority' => 250,
)));

$wp_customize->selective_refresh->add_partial( 'constructionarc_slider_refresh', array (
    'settings' => array(
        'constructionarc_banner_slider_section',
        'constructionarc_slider_type',
        'constructionarc_banner_sliders',
        'constructionarc_slider_advance_settings',
        'main_slider_controls',
        'constructionarc_slider_section_seperator',
        'constructionarc_slider_bottom_seperator'
    ),
    'selector' => '.constructionarc-banner-wrapper',
    'fallback_refresh' => true,
	'container_inclusive' => true,
    'render_callback' => function () {
        if( get_theme_mod( 'constructionarc_banner_slider_section' ) === 'enable' ) {
            return do_action('constructionarc_themes_slider_type');
        }
    }
));