<?php global $dicom_opt;
/**
 * @package Dicom
*/

if( function_exists('acf_add_options_page') ) {
	$hide_banner    = get_field( 'enable_page_banner' );
	$hide_top_head  = get_field( 'enable_top_header' );
} else {
	$hide_banner  = false;
	$hide_top_head  = false;
}

if ( isset( $dicom_opt['blog_title'] ) ) {
    $hide_blog_banner      = $dicom_opt['hide_blog_banner'];
    $hide_service_banner   = $dicom_opt['hide_service_banner'];
} else {
    $hide_blog_banner      = false;
    $hide_service_banner   = false;
}

// After Hiding Banner add spacing
if( $hide_banner == true || $hide_blog_banner == true  || $hide_service_banner == true ) {
    $nav_class = 'nav-color';
} else {
    $nav_class = '';
} 

if ( class_exists('ACF') && get_field('choose_full_container') == 1 ) {
    $container_class = 'container';
} else {
    $container_class = 'container-fluid'; 
}

// WP admin bar
$hide_wp_nav = 'hide-wp-nav';

// Top header
if( isset( $dicom_opt['email'] ) ):
    $header_btn		    = $dicom_opt['enable_header_btn'];
    $header_btn_text	= $dicom_opt['header_btn_text'];
    $btn_link_type 	    = $dicom_opt['btn_link_type'];

    if( $btn_link_type == 'link_to_page') {
        // Page link
        $btn_link 		= get_page_link( $dicom_opt['btn_page_link'] );
    } else {
        $btn_link	    = $dicom_opt['btn_ex_link'];
    }
else:
    $header_btn		    = false;
    $header_btn_text	= '';
    $btn_link		    = '';
endif;

if( isset( $dicom_opt['search_placeholder_text'] ) && $dicom_opt['search_placeholder_text'] != '' ) {
    $dicom_search_placeholder = $dicom_opt['search_placeholder_text'];
} else {
    $dicom_search_placeholder = esc_html__('Search here', 'dicom');
} 

if( isset( $dicom_opt['btn_text'] ) && $dicom_opt['btn_text'] != '' ) {
    $btn_text = $dicom_opt['btn_text'];
} else {
    $btn_text = esc_html__('Get Start', 'dicom');
} 

if( isset( $dicom_opt['btn_link'] ) && $dicom_opt['btn_link'] != '' ) {
    $btn_link = $dicom_opt['btn_link'];
} else {
    $btn_link = esc_html__('', 'dicom');
} 

if ( !is_404() ) : ?>
    <?php if( $hide_top_head == false ) { ?>
        <div class="top-header-area">
            <div class="container-fluid">
                <div class="row align-items-center">
                    <div class="col-lg-6 col-md-6">
                        <ul class="top-header-contact-info">
                            <?php if( isset( $dicom_opt['phone_num'] ) &&  $dicom_opt['phone_num'] !='' ): ?>
                                <li><i class="<?php echo esc_attr( $dicom_opt['phone_icon'] ); ?>"></i> <a href="<?php echo esc_url( $dicom_opt['phone_link'] ); ?>"><?php echo esc_html( $dicom_opt['phone_num'] ); ?></a></li>
                            <?php endif; ?>

                            <?php if( isset( $dicom_opt['email'] ) &&  $dicom_opt['email'] !='' ): ?>
                                <li><i class="<?php echo esc_attr( $dicom_opt['email_icon'] ); ?>"></i> <a href="<?php echo esc_url( $dicom_opt['email_link'] ); ?>"><?php echo esc_html( $dicom_opt['email'] ); ?></a></li>
                            <?php endif; ?>

                        </ul>
                    </div>
                    <?php if( $header_btn == true && $header_btn_text != '' ): ?>
                        <div class="col-lg-6 col-md-6">
                            <div class="top-header-btn">
                                <a href="<?php echo esc_url( $btn_link ); ?>" class="default-btn"><?php echo esc_html( $header_btn_text ); ?></a>
                            </div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    <?php } ?>

    <div class="navbar-area navbar-area-with-data-science <?php if( !is_front_page() ){ echo esc_attr( $nav_class ); } ?> <?php if ( is_user_logged_in() ) { echo esc_attr( $hide_wp_nav ); } ?>">
        <div class="dibiz-responsive-nav">
            <div class="container">
                <div class="dibiz-responsive-menu">
                    <div class="logo">
                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
                            <?php dicom_mobile_logo(); ?>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <div class="dibiz-nav">
            <div class="<?php echo esc_attr( $container_class ); ?>">
                <nav class="navbar navbar-expand-md navbar-light">
                    <a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>">
                        <?php dicom_black_logo(); ?>
                    </a>

                    <div class="collapse navbar-collapse mean-menu">

                        <?php $primary_nav_arg = [
                            'menu'            => 'primary',
                            'theme_location'  => 'primary',
                            'container'       => null,
                            'menu_class'      => 'navbar-nav',
                            'depth'           => 3,
                            'walker'          => new Dicom_Bootstrap_Navwalker(),
                            'fallback_cb'     => 'Dicom_Bootstrap_Navwalker::fallback',
                        ];
                
                        if ( has_nav_menu('primary') ) :
                            wp_nav_menu( $primary_nav_arg );
                        endif; ?>
                        <?php if( ( isset( $dicom_opt['enable_search'] ) && $dicom_opt['enable_search'] == true ) || ( isset( $dicom_opt['enable_btn_menu'] ) && $dicom_opt['enable_btn_menu'] == true ) ) : ?>
                        <div class="others-option d-flex align-items-center">
                            <?php if( isset( $dicom_opt['enable_search'] ) && $dicom_opt['enable_search'] == true  ): ?>
                                <div class="option-item">
                                    <form class="search-box-area" role="search" method="get" id="search" action="<?php echo esc_url( home_url( '/' ) ); ?>">
                                        <input type="text" class="input-search" placeholder="<?php echo esc_attr( $dicom_search_placeholder ); ?>" value="<?php echo get_search_query(); ?>" name="s" id="s" required>
                                        <button type="submit"><i class="bx bx-search"></i></button>
                                    </form>
                                </div>
                            <?php endif; ?>
                            <?php if( isset( $dicom_opt['enable_btn_menu'] ) && $dicom_opt['enable_btn_menu'] == true  ): ?>
                                <div class="option-item">
                                    <a href="<?php echo esc_url($btn_link); ?>" class="default-btn"><?php echo esc_attr( $btn_text); ?></a>
                                </div>
                            <?php endif; ?>
                        </div>
                        <?php endif; ?>

                    </div>
                </nav>
            </div>
        </div>

        <?php if( ( isset( $dicom_opt['enable_search'] ) && $dicom_opt['enable_search'] == true ) || ( isset( $dicom_opt['enable_btn_menu'] ) && $dicom_opt['enable_btn_menu'] == true ) ) : ?>
            <div class="others-option-for-responsive">
                <div class="container">
                    <div class="dot-menu">
                        <div class="inner">
                            <div class="circle circle-one"></div>
                            <div class="circle circle-two"></div>
                            <div class="circle circle-three"></div>
                        </div>
                    </div>
                    
                    <div class="container">
                        <div class="option-inner">
                            <div class="others-option justify-content-center d-flex align-items-center">
                                <?php if( isset( $dicom_opt['enable_search'] ) && $dicom_opt['enable_search'] == true  ): ?>
                                    <div class="option-item">
                                        <form class="search-box-area" role="search" method="get" id="search1" action="<?php echo esc_url( home_url( '/' ) ); ?>">
                                            <input type="text" class="input-search" placeholder="<?php echo esc_attr( $dicom_search_placeholder ); ?>" value="<?php echo get_search_query(); ?>" name="s" id="s1" required>
                                            <button type="submit"><i class="bx bx-search"></i></button>
                                        </form>
                                    </div>
                                <?php endif; ?>
                                <?php if( isset( $dicom_opt['enable_btn_menu'] ) && $dicom_opt['enable_btn_menu'] == true  ): ?>
                                    <div class="option-item">
                                        <a href="<?php echo esc_url($btn_link); ?>" class="default-btn"><?php echo esc_attr( $btn_text); ?></a>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php endif; ?>
    </div>
<?php endif; ?>