<?php

class DDBUILDER_Menu_Module extends ET_Builder_Module {

	public $slug       = 'dondivi_menu';
	public $vb_support = 'on';
	public $icon_path;

	protected $module_credits = array(
		'module_uri' => 'https://dondivi.com/nav-menu',
		'author'     => 'DonDivi',
		'author_uri' => 'https://dondivi.com/',
	);

	public function init() {
		$this->name 		= esc_html__( 'DonDivi Nav Menu', 'dd_builder' );
		$this->child_slug 	= 'dondivi_menu_item';
		$this->icon_path   	= plugin_dir_path( DDB_PLUGIN_PATH ) . 'builder/icon.svg';

		$this->main_css_element	= '%%order_class%%';

		$this->settings_modal_toggles = array(
			'general'    => array(
				'toggles' => array(
					'main_content' 	=> esc_html__( 'Menu', 'et_builder' ),
					'logo'        	=> esc_html__( 'Logo', 'et_builder' ),
				),
			),
			'advanced'   => array(
				'toggles' => array(
					'main_content' 	=> esc_html__( 'Menu', 'et_builder' ),
					'mobile' 		=> esc_html__( 'Mobile Menu', 'et_builder' ),
					'hamburger' 	=> esc_html__( 'Mobile Menu Icon', 'dd_builder' ),
					'logo'        	=> esc_html__( 'Logo', 'et_builder' ),
					'items'			=> esc_html__( 'Menu Items', 'dd_builder' ),
					'items_text' 	=> sprintf( '%1$s %2$s', esc_html__( 'Menu Items', 'dd_builder' ), et_builder_i18n( 'Text' ) ),
					'icon' 			=> sprintf( '%1$s %2$s', esc_html__( 'Menu Items', 'dd_builder' ), esc_html__( 'Image & Icon', 'et_builder' ) ),
				),
			),
		);

		$this->advanced_fields = array(
			'borders' => array(
				'default'=> array(
					'use_radius'	=> false,
				),
			),
			'fonts' => array(
				'item'   => array(
					'label'          => esc_html__( 'Menu Item', 'dd_builder' ),
					'css'            => array(
						'main' => "{$this->main_css_element} .ddb-text, {$this->main_css_element} .ddb-wp-item",
						'hover' => "%%order_class%% .ddb-item:hover .ddb-text, %%order_class%% .ddb-item.active .ddb-text, %%order_class%% .ddb-wp-item:hover, %%order_class%% .ddb-wp-item.active",
					),
					'font_size'       => array(
						'default' => absint( et_get_option( 'body_font_size', '14' ) ) . 'px',
					),
					'line_height'     => array(
						'default' => '1em',
					),
					'hide_text_align' 	=> true,
					'toggle_slug' 		=> 'items_text',
				),
			),
			'image_icon'     => array(
				'image_icon' => array(
					'label'           => esc_html__( 'Menu Items', 'dd_builder' ),
					'css'             => array(
						'main' => '%%order_class%% .ddb-item',
					),
					'toggle_slug'     	=> 'items',
				),
				'logo' => array(
					'label'           => et_builder_i18n( 'Logo' ),
					'css'             => array(
						'main' => '%%order_class%% .ddb-logo',
					),
					'margin_padding' => array(
						'use_padding'	=> false,
					),
					'toggle_slug'     	=> 'logo',
				),
				'mobile_icon' => array(
					'label'           => et_builder_i18n( 'Icon' ),
					'css'             => array(
						'main' => '%%order_class%% .ddb-mobile-icon',
					),
					'toggle_slug'     	=> 'hamburger',
				),
			),
			'text' => false,
		);

		$this->custom_css_fields = array(
			'menu_css' => array(
				'label'    	=> esc_html__( 'Menu', 'et_builder' ),
				'selector' 	=> '%%order_class%% .ddb-menu',
			),
			'mobile_menu_css' => array(
				'label'    	=> esc_html__( 'Mobile Menu', 'et_builder' ),
				'selector' 	=> '%%order_class%% .ddb-mobile-menu',
				'show_if'	=> array('enable_mobile' => 'on'),
			),
			'logo' => array(
				'label'    => esc_html__( 'Logo', 'et_builder' ),
				'selector' => '%%order_class%% .ddb-logo'
			),
			'logo_image' => array(
				'label'    => esc_html__( 'Logo Image', 'divimenus' ),
				'selector' => '%%order_class%% .ddb-logo img'
			),
			'item' => array(
				'label'    	=> esc_html__( 'Menu Item', 'dd_builder' ),
				'selector' 	=> '%%order_class%% .ddb-item', 
			),
			'active_item_css' => array(
				'label'    	=> esc_html__( 'Active Menu Item', 'dd_builder' ),
				'selector' 	=> '%%order_class%% .ddb-item.active', 
			),
		);
	}

	public function get_fields() {
		$helper = new DonDiviBuilderFields();
		$fields = array(
			'direction' => array(
				'label'           	=> esc_html__( 'Direction', 'dd_builder' ),
				'type'            	=> 'select',
				'options'         	=> array(
					'row'  			=> esc_html__( 'Row', 'et_builder' ),
					'column'  		=> esc_html__( 'Column', 'dd_builder' ),
					'row-reverse'  	=> esc_html__( 'Row Reverse', 'dd_builder' ),
					'column-reverse'=> esc_html__( 'Column Reverse', 'dd_builder' )
				),
				'default' 			=> 'row',
				'mobile_options'	=> true,
				'toggle_slug'     	=> 'main_content',
			),
			'enable_mobile' => array(
				'label'            	=> esc_html__( 'Enable Mobile Menu', 'dd_builder' ),
				'type'             	=> 'yes_no_button',
				'options'          	=> $helper->get_yes_no_button_options(),
				'default' 			=> 'off',
				'toggle_slug'     	=> 'main_content',
			),
			'mobile_menu' => array(
				'label'            	=> esc_html__( 'Show Mobile Menu On', 'dd_builder' ),
				'type'            	=> 'multiple_checkboxes',
				'options'         	=> array(
					'phone'   => esc_html__( 'Phone', 'et_builder' ),
					'tablet'  => esc_html__( 'Tablet', 'et_builder' ),
					'desktop' => esc_html__( 'Desktop', 'et_builder' ),
				),
				'show_if' 			=> array('enable_mobile' => 'on'),
				'default' 			=> 'off',
				'toggle_slug'     	=> 'main_content',
			),
			'mobile_font_icon'	=> array(
				'label'            	=> esc_html__( 'Mobile Menu Icon', 'dd_builder' ),
				'type'              => 'select_icon',
				'class'             => array( 'et-pb-font-icon' ),
				'default'			=> '&#xf0c9;||fa||900',
				'hover'				=> 'tabs',
				'mobile_options'	=> true,
				'show_if' 			=> array('enable_mobile' => 'on'),
				'toggle_slug'     	=> 'main_content',
			),
			'alignment' => array(
				'label'           	=> esc_html__( 'Horizontal Alignment', 'dd_builder' ),
				'type'            	=> 'text_align',
				'options'         	=> et_builder_get_text_orientation_options(),
				'options_icon'    	=> 'module_align',
				'default'			=> 'left',
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'main_content',
			),	
			'vertical_alignment' => array( 
				'label'           	=> esc_html__( 'Vertical Alignment', 'dd_builder' ),
				'type'            	=> 'select',
				'options'         	=> array('flex-start' => esc_html__( 'Top', 'et_builder' ), 'center' => esc_html__( 'Middle', 'et_builder' ), 'flex-end' => esc_html__( 'Bottom', 'et_builder' )),
				'default'			=> 'center',
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'main_content',
			),
			'mobile_icon_alignment' => array(
				'label'           	=> esc_html__( 'Horizontal Alignment', 'dd_builder' ),
				'description'     	=> esc_html__( 'Here you can control the alignment of the Menu Items on the main axis.', 'dd_builder' ),
				'type'            	=> 'text_align',
				'options'         	=> et_builder_get_text_orientation_options(),
				'options_icon'    	=> 'module_align',
				'default'			=> 'right',
				'show_if' 			=> array( 'enable_mobile' => 'on' ),
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'hamburger',
			),	
			'mobile_icon_color'	=> array(
				'label'          => esc_html__( 'Color', 'et_builder' ),
				'type'           => 'color-alpha',
				'default'        => et_builder_accent_color(),
				'show_if' 			=> array( 'enable_mobile' => 'on' ),
				'tab_slug'       => 'advanced',
				'toggle_slug'    => 'hamburger',
				'hover'          => 'tabs',
				'mobile_options' => true,
				'sticky'         => true,
			),
			'mobile_icon_font_size'             => array(
				'label'            => esc_html__( 'Icon Size', 'et_builder' ),
				'type'             => 'range',
				'default'          => '24px',
				'default_unit'     => 'px',
				'allowed_units'    => et_builder_get_acceptable_css_string_values( 'font-size' ),
				'show_if' 			=> array( 'enable_mobile' => 'on' ),
				'mobile_options'   => true,
				'sticky'           => true,
				'hover'            => 'tabs',
				'tab_slug'         => 'advanced',
				'toggle_slug'      => 'hamburger',
			),
			'mobile_width' 		=> array(
				'label'           	=> esc_html__( 'Width', 'et_builder' ),
				'type'            	=> 'range',
				'default'         	=> '100%', 
				'default_unit'		=> '%',
				'show_if' 			=> array( 'enable_mobile' => 'on' ),
				'mobile_options'  	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'     	=> 'mobile',			
			),
			'mobile_alignment' => array(
				'label'           	=> esc_html__( 'Alignment', 'et_builder' ),
				'type'            	=> 'text_align',
				'options'         	=> et_builder_get_text_orientation_options( array( 'justified' )),
				'options_icon'    	=> 'module_align',
				'default'			=> 'left',
				'show_if' 			=> array( 'enable_mobile' => 'on' ),
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'mobile',
			),
			'mobile_bg_color'	=> array(
				'label'          	=> esc_html__( 'Background Color', 'et_builder' ),
				'description'    	=> esc_html__( 'Pick a unique color to be used for the menu background color when viewed on a mobile device.', 'et_builder' ),
				'type'           	=> 'color-alpha',
				'custom_color'   	=> true,
				'show_if' 			=> array( 'enable_mobile' => 'on' ),
				'tab_slug'       	=> 'advanced',
				'toggle_slug'    	=> 'mobile',
				'hover'          	=> 'tabs',
				'mobile_options' 	=> true,
				'sticky'         	=> true,
			),
			'mi_fullwidth' => array(
				'label'           	=> esc_html__( 'Force Fullwidth', 'et_builder' ),
				'type'            	=> 'yes_no_button',
				'options'         	=> $helper->get_yes_no_button_options(),	
				'default'			=> 'off',
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'items',	
			),
			'mi_alignment' => array(
				'label'           	=> esc_html__( 'Text Alignment', 'et_builder' ),
				'type'            	=> 'select',
				'options'         	=> array(
					'flex-start' 	=> esc_html__( 'Left', 'et_builder' ), 
					'center' 		=> esc_html__( 'Center', 'et_builder' ), 
					'flex-end' 		=> esc_html__( 'Right', 'et_builder' ),
					'space-between' => esc_html__( 'Space Between', 'et_builder' ),
					'space-around'  => esc_html__( 'Space Around', 'et_builder' ),
				),
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'items',
			),
			'mi_background_color' => array(
				'label'             => esc_html__( 'Background Color', 'et_builder' ),
				'type'              => 'color-alpha',
				'hover'				=> 'tabs',
				'sticky'			=> true,
				'mobile_options'	=> true,
				'tab_slug'          => 'advanced',
				'toggle_slug'       => 'items',			
			),
			'mi_gap' 	=> array(
				'label'           	=> esc_html__( 'Gap', 'dd_builder' ),
				'type'            	=> 'range', 
				'default_unit'		=> 'px',
				'mobile_options'  	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'     	=> 'items',			
			),
			'logo' => array(
				'label'             => esc_html__( 'Logo', 'et_builder' ),
				'description'       => esc_html__( 'Upload an image to display beside your menu.', 'et_builder' ),
				'type'              => 'upload',
				'upload_button_text'=> esc_attr__( 'Upload an image', 'et_builder' ),
				'choose_text'       => esc_attr__( 'Choose an Image', 'et_builder' ),
				'update_text'       => esc_attr__( 'Set As Logo', 'et_builder' ),
				'dynamic_content'   => 'image',
				'hover'            	=> 'tabs',
				'mobile_options'	=> true,
				'sticky'			=> true,
				'toggle_slug'       => 'logo',
			),
			'logo_url' => array(
				'label'  			=> esc_html__( 'Logo Link URL', 'et_builder' ),
				'description'     	=> esc_html__( 'If you would like to make your logo a link, input your destination URL here.', 'et_builder' ),
				'type'            	=> 'text',				
				'toggle_slug'     	=> 'logo',
				'dynamic_content' 	=> 'url',
			),
			'logo_url_new_window' => array(
				'label'            	=> esc_html__( 'URL Opens', 'dd_builder' ),
				'description'      	=> esc_html__( 'Here you can choose whether or not your link opens in a new window', 'et_builder' ),
				'type'             	=> 'select',
				'option_category'  	=> 'configuration',
				'options'          	=> array(
					'off' => esc_html__( 'In The Same Window', 'et_builder' ),
					'on'  => esc_html__( 'In The New Tab', 'et_builder' ),
				),
				'toggle_slug'      	=> 'logo',
				'default' 			=> 'off',
			),
			'logo_position' => array(
				'label'             => esc_html__( 'Placement', 'dd_builder' ),
				'type'            	=> 'select',
				'options'         	=> array(
					'column' 			=> esc_html__( 'Top', 'et_builder' ),
					'row-reverse'  		=> esc_html__( 'Right', 'et_builder' ),
					'column-reverse'  	=> esc_html__( 'Bottom', 'et_builder' ),
					'row'  				=> esc_html__( 'Left', 'et_builder' ),
				),
				'default'			=> 'row',
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'logo',							
			),
			'logo_horizontal' => array(
				'label'           	=> esc_html__( 'Horizontal Alignment', 'dd_builder' ),
				'type'            	=> 'text_align',
				'options'         	=> et_builder_get_text_orientation_options( array( 'justified' ) ),
				'options_icon'    	=> 'module_align',
				'default'			=> 'left',
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'logo',
			),	
			'logo_vertical' => array( 
				'label'           	=> esc_html__( 'Vertical Alignment', 'dd_builder' ),
				'type'            	=> 'select',
				'options'         	=> array('flex-start' => et_builder_i18n( 'Top' ), 'center' => esc_html__( 'Middle', 'dd_builder' ), 'flex-end' => et_builder_i18n( 'Bottom' ) ),
				'options_icon'    	=> 'module_align',
				'default'			=> 'flex-start',
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'logo',
			),
			'logo_width' => array(
				'label'           => esc_html__( 'Logo Width', 'et_builder' ),
				'type'            => 'range',
				'allowed_values'  => et_builder_get_acceptable_css_string_values( 'width' ),
				'default'         => '150px',
				'default_unit'    => 'px',
				'mobile_options'  => true,
				'hover'           => 'tabs',
				'sticky'          => true,
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'logo',
			),
			'menu_wrapper_gap' => array(
				'label'           	=> esc_html__( 'Offset', 'dd_builder' ),
				'type'            	=> 'range', 
				'default_unit'		=> 'px',
				'mobile_options'  	=> true,
				'sticky'			=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'     	=> 'logo',					
			),
		);
		$fields['alt'] = $helper->get_alt_field( '', 'Logo Alt Text' );
		return array_merge( $fields, $helper->get_effect_fields( 'mobile', array( 'enable_mobile' => 'on' ) ) ); 
	}

	public function get_transition_fields_css_props() {
		$fields = parent::get_transition_fields_css_props();

		$fields['mi_background_color'] = array(
			'background-color' => '%%order_class%% .ddb-item, %%order_class%% .ddb-wp-item',
		);
		$fields['logo_width'] = array(
			'width' => '%%order_class%% .ddb-logo img',
		);

		return $fields;
	}

	public function multi_view_filter_value( $raw_value, $args ) {

		$name = isset( $args['name'] ) ? $args['name'] : '';

		if ( $raw_value && ('mobile_font_icon' === $name ) ) {
			return et_pb_get_extended_font_icon_value( $raw_value, true );
		}
		return $raw_value;
	}
	 
	public function render( $attrs, $content, $render_slug ) {
		wp_enqueue_script( 'ddb-menu' );

		$this->generate_styles(
			array(
				'base_attr_name' => 'direction',
				'selector'       => '%%order_class%% .ddb-menu',
				'css_property'   => 'flex-direction',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name'	=> 'mi_background_color',
				'selector'       	=> '%%order_class%% .ddb-item, %%order_class%% .ddb-wp-item',
				'hover_selector'    => '%%order_class%% .ddb-item:hover, %%order_class%% .ddb-item.active, %%order_class%% .ddb-wp-item:hover, %%order_class%% .ddb-wp-item.active',
				'css_property'      => 'background-color',
				'render_slug'       => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name'	=> 'mi_gap',
				'selector'       	=> '%%order_class%% .ddb-menu, %%order_class%% .ddb-mobile-menu',
				'css_property'      => 'gap',
				'render_slug'       => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name'	=> 'mi_alignment',
				'selector'       	=> '%%order_class%% .ddb-item-content',
				'css_property'      => 'justify-content',
				'render_slug'       => $render_slug,
			)
		);

		$helper 		= DonDiviBuilderHelper::get();
		$multi_view 	= et_pb_multi_view_options( $this );
		$dir 			= et_pb_responsive_options()-> get_property_values($this->props, 'direction', $this->props['direction'], true);
		$hali 			= et_pb_responsive_options()-> get_property_values($this->props, 'alignment', $this->props['alignment'], true);
		$vali 			= et_pb_responsive_options()-> get_property_values($this->props, 'vertical_alignment', $this->props['vertical_alignment'], true);
		$fw 			= et_pb_responsive_options()-> get_property_values($this->props, 'mi_fullwidth', $this->props['mi_fullwidth'], true);
		foreach ( et_pb_responsive_options()->get_modes() as $device ) {
			$helper->set_style( 
				$render_slug, 
				'%%order_class%% .ddb-menu', 
				sprintf( 'flex:1;justify-content: %1$s;align-items: %2$s;', 
					$helper->get_flex_alignment('justify', $dir[$device], $hali[$device], $vali[$device]),
					$helper->get_flex_alignment('align', $dir[$device], $hali[$device], $vali[$device])
				),
				substr($device, 0, 1) 
			);
			if ( $fw[$device] === 'on' ) $helper->set_style( 
				$render_slug, 
				'%%order_class%% .ddb-menu > div', 
				$dir[$device] === 'column' || $dir[$device] === 'column-reverse' ? 'width: 100%;' : 'flex:1;',
				substr($device, 0, 1) 
			);	
		}

		if ($this->props['enable_mobile'] === 'on') {
			$this->generate_styles(
				array(
					'base_attr_name' => 'mobile_icon_alignment',
					'selector'       => '%%order_class%% .ddb-mobile-wrapper',
					'css_property'   => 'justify-content',
					'render_slug'    => $render_slug,
				)
			);
			$this->generate_styles(
				array(
					'base_attr_name' => 'mobile_width',
					'selector'       => '%%order_class%% .ddb-mobile-menu',
					'css_property'   => 'width',
					'render_slug'    => $render_slug,
				)
			);
			$this->generate_styles(
				array(
					'base_attr_name' => 'mobile_bg_color',
					'selector'       => '%%order_class%% .ddb-mobile-menu',
					'css_property'   => 'background-color',
					'render_slug'    => $render_slug,
				)
			);
			$mobile_hali = et_pb_responsive_options()-> get_property_values($this->props, 'mobile_alignment', $this->props['mobile_alignment'], true);
			foreach ( et_pb_responsive_options()->get_modes() as $device ) {
				$helper->set_style( $render_slug, '%%order_class%% .ddb-mobile-menu', $this->get_mobile_pos($mobile_hali[$device]), substr($device, 0, 1) );
			}
		}
		
		$menu_classes 	= array('ddb-menu ddb-f ddb-f-w ddb-w-100');
		$mobile_classes = array('ddb-mobile-wrapper ddb-w-100 ddb-none');
		$mobile_wrapper = '';
		if ( $this->props['enable_mobile'] === 'on' ) {
			$display_on = explode( '|', $this->props['mobile_menu'] );
			if ( count($display_on) > 2 ) { 
				if ($display_on[2] === 'on') { $menu_classes[]= 'ddb-hide-desktop'; $mobile_classes[]= 'ddb-show-desktop';}
				if ($display_on[1] === 'on') { $menu_classes[]= 'ddb-hide-tablet'; $mobile_classes[]= 'ddb-show-tablet';}
				if ($display_on[0] === 'on') { $menu_classes[]= 'ddb-hide-phone'; $mobile_classes[]= 'ddb-show-phone';}
				
				$mobile_menu_attrs = array( 'class' => 'ddb-mobile-menu ddb-f ddb-column ddb-abs ddb-none', 'role' => 'menu' );
				$helper->set_effect_attrs( $mobile_menu_attrs, $this->props );
				$mobile_menu = $multi_view->render_element(
					array(
						'tag'	=> 'div',
						'content'	=> $this->props['content'],
						'attrs'     => $mobile_menu_attrs,
					)
				);
				$mobile_wrapper = sprintf('<div class="%3$s">%1$s%2$s</div>',
					$helper->render_icon( array( 
						'module' => $this, 
						'icon_attr' => 'mobile_font_icon', 
						'color_attr' => 'mobile_icon_color', 
						'size_attr' => 'mobile_icon_font_size', 
						'selector' => '%%order_class%% .ddb-mobile-icon', 
						'hover_selector' => '%%order_class%% .ddb-mobile-icon.active',
						'attrs' => array( 'class' => 'ddb-mobile-icon ddb-btn ddb-click' ), 
						'custom' => true 
					) ),
					$mobile_menu, 
					implode(' ', $mobile_classes)
				);
			}
		};
		
		return sprintf( '<div class="ddb-menu-wrapper ddb-f ddb-f-c">%1$s<div class="%4$s" role="menu">%2$s</div>%3$s</div>', 
			$this->render_logo(), $this->props['content'], $mobile_wrapper, implode(' ', $menu_classes)
		);
	}

	private function get_mobile_pos($hali) {    
		return $hali === 'right' ? 'right:0;' : ($hali === 'center' ? 'left:0;right:0; margin:0 auto;' : 'left:0;');
	  }

	private function render_logo() {
		$helper = DonDiviBuilderHelper::get();
		$multi_view = et_pb_multi_view_options( $this );
		if ( $multi_view->has_value( 'logo' ) ) {
			$logo = $helper->render_image( array(
				'module' 	=> $this,
				'img_attr'	=> 'logo',
				'alt_attr' 	=> 'alt',
				'attrs' 	=> array( 'class' => 'ddb-block' ),
				'custom' 	=> true,
			));
			$this->generate_styles(
				array(
					'base_attr_name' 	=> 'logo_position',
					'selector'       	=> '%%order_class%% .ddb-menu-wrapper',
					'css_property'   	=> 'flex-direction',
					'render_slug'    	=> $this->slug,
				)
			);
			$this->generate_styles(
				array(
					'base_attr_name'	=> 'menu_wrapper_gap',
					'selector'       	=> '%%order_class%% .ddb-menu-wrapper',
					'css_property'      => 'gap',
					'render_slug'       => $this->slug,
				)
			);
			$dir 	= et_pb_responsive_options()->get_property_values($this->props, 'logo_position', $this->props['logo_position'], true);
			$hali 	= et_pb_responsive_options()->get_property_values($this->props, 'logo_horizontal', $this->props['logo_horizontal'], true);
			$vali 	= et_pb_responsive_options()->get_property_values($this->props, 'logo_vertical', $this->props['logo_vertical'], true);
			foreach ( et_pb_responsive_options()->get_modes() as $device ) {
				$helper->set_style( 
					$this->slug, 
					'%%order_class%% .ddb-menu-wrapper', 
					sprintf( 'justify-content: %1$s;align-items: %2$s;', 
						$helper->get_flex_alignment('justify', $dir[$device], $hali[$device], $vali[$device]),
						$helper->get_flex_alignment('align', $dir[$device], $hali[$device], $vali[$device])
					),
					substr($device, 0, 1) 
				);
			}
			$this->generate_styles(
				array(
					'base_attr_name'                  => 'logo_width',
					'selector'                        => '%%order_class%% .ddb-logo img',
					'hover_pseudo_selector_location'  => 'suffix',
					'css_property'                    => 'width',
					'render_slug'                     => $this->slug,
				)
			);

			if ( ! empty( $this->props['logo_url'] ) ) {
				$logo = sprintf(
					'<a href="%1$s" %2$s>%3$s</a>',
					esc_url( $this->props['logo_url'] ),
					'on' === $this->props['logo_url_new_window'] ? 'target="_blank"' : '',
					et_core_esc_previously( $logo )
				);
			}
			return sprintf( '<div class="ddb-logo">%1$s</div>', $logo );
		}
		return '';
	}
}

new DDBUILDER_Menu_Module;