<?php
$header_options = royal_event_storage_get('header_mobile');
$contact_address_1 = trim(royal_event_get_custom_option('contact_address_1'));
$contact_address_2 = trim(royal_event_get_custom_option('contact_address_2'));
$contact_phone = trim(royal_event_get_custom_option('contact_phone'));
$contact_email = trim(royal_event_get_custom_option('contact_email'));
?>
	<div class="header_mobile">
		<div class="content_wrap">
			<div class="menu_button icon-menu"></div>
			<?php 
			royal_event_show_logo(); 
			if ($header_options['woo_cart']){
				if (function_exists('royal_event_exists_woocommerce') && royal_event_exists_woocommerce() && (royal_event_is_woocommerce_page() && royal_event_get_custom_option('show_cart')=='shop' || royal_event_get_custom_option('show_cart')=='always') && !(is_checkout() || is_cart() || defined('WOOCOMMERCE_CHECKOUT') || defined('WOOCOMMERCE_CART'))) { 
					?>
					<div class="menu_main_cart top_panel_icon">
						<?php get_template_part(royal_event_get_file_slug('templates/headers/_parts/contact-info-cart.php')); ?>
					</div>
					<?php
				}
			}
			?>
		</div>
		<div class="side_wrap">
			<div class="close"><?php esc_html_e('Close', 'royal-event'); ?></div>
			<div class="panel_top">
				<nav class="menu_main_nav_area">
					<?php
						$menu_main = royal_event_get_nav_menu('menu_main');
						if (empty($menu_main)) $menu_main = royal_event_get_nav_menu();
						$menu_main = royal_event_set_tag_attrib($menu_main, '<ul>', 'id', 'menu_mobile');
						royal_event_show_layout($menu_main);
					?>
				</nav>
				<?php 
				if ($header_options['search'] && royal_event_get_custom_option('show_search')=='yes')
					royal_event_show_layout(royal_event_sc_search(array()));
				
				if ($header_options['login']) {
					if ( is_user_logged_in() ) {
						?>
						<div class="login"><a href="<?php echo esc_url(wp_logout_url(home_url('/'))); ?>" class="popup_link"><?php esc_html_e('Logout', 'royal-event'); ?></a></div>
						<?php
					} else {
						// Load core messages
						royal_event_enqueue_messages();
						// Load Popup engine
						royal_event_enqueue_popup();
						?><div class="login"><?php do_action('trx_utils_action_login'); ?></div><?php
                        // Anyone can register ?
                        if ( (int) get_option('users_can_register') > 0) {
                            ?><div class="login"><?php do_action('trx_utils_action_register'); ?></div><?php
                        }
					}
				}
				?>
			</div>
			
			<?php if ($header_options['contact_address'] || $header_options['contact_phone_email'] || $header_options['open_hours']) { ?>
			<div class="panel_middle">
				<?php
				if ($header_options['contact_address'] && (!empty($contact_address_1) || !empty($contact_address_2))) {
					?><div class="contact_field contact_address">
								<span class="contact_icon icon-home"></span>
								<span class="contact_label contact_address_1"><?php royal_event_show_layout($contact_address_1); ?></span>
								<span class="contact_address_2"><?php royal_event_show_layout($contact_address_2); ?></span>
							</div><?php
				}
						
				if ($header_options['contact_phone_email'] && (!empty($contact_phone) || !empty($contact_email))) {
					?><div class="contact_field contact_phone">
						<span class="contact_icon icon-phone"></span>
						<span class="contact_label contact_phone"><a href="tel:<?php echo esc_attr($contact_phone); ?>"><?php royal_event_show_layout($contact_phone); ?></a></span>
						<span class="contact_email"><a href="mailto:<?php echo antispambot($contact_email); ?>"><?php royal_event_show_layout($contact_email); ?></a></span>
					</div><?php
				}
				
				royal_event_template_set_args('top-panel-top', array(
					'menu_user_id' => 'menu_user_mobile',
					'top_panel_top_components' => array(
						($header_options['open_hours'] ? 'open_hours' : '')
					)
				));
				get_template_part(royal_event_get_file_slug('templates/headers/_parts/top-panel-top.php'));
				?>
			</div>
			<?php } ?>

			<div class="panel_bottom">
				<?php if ($header_options['socials'] && royal_event_get_custom_option('show_socials')=='yes') { ?>
					<div class="contact_socials">
						<?php royal_event_show_layout(royal_event_sc_socials(array('size'=>'small'))); ?>
					</div>
				<?php } ?>
			</div>
		</div>
		<div class="mask"></div>
	</div>