<?php
if ( ! defined( 'ABSPATH' ) ) exit;

if(th_advance_product_search()->get_option( 'show_submit' )=='0'){

$barClass='submit-no-active';

}else{

$barClass='submit-active';

}

$icon_clr = esc_html(th_advance_product_search()->get_option( 'icon_clr' ));

$uniqueID   = ++ TH_Advance_Product_Search()->searchInstances;

$layoutType = !empty($args['layout'])  ? $args['layout'] : 'default_style';

if($layoutType == 'default_style'){ ?>

<div id='thaps-search-box' class="thaps-search-box  <?php echo esc_attr($barClass);?>  <?php echo esc_attr($layoutType);?>">

<form class="thaps-search-form" action='<?php echo esc_url( home_url( '/'  ) ); ?>' id='thaps-search-form'  method='get'>

<div class="thaps-from-wrap">

<?php

if(th_advance_product_search()->get_option('show_submit' )=='0'){

  th_advance_product_search_icon_style_svg('icon-style', $icon_clr);

} ?>
   <input id='thaps-search-autocomplete-<?php echo esc_attr($uniqueID); ?>' name='s' placeholder='<?php echo esc_attr(th_advance_product_search()->get_option( 'placeholder_text' ));?>' class="thaps-search-autocomplete thaps-form-control" value='<?php echo esc_attr(get_search_query()); ?>' type='text' title='<?php echo esc_attr_x( 'Search', 'label', 'th-advance-product-search' ); ?>' />

   <?php if(th_advance_product_search()->get_option( 'show_loader' )=='0'){ ?> 

   <div class="thaps-preloader"></div>

  <?php } ?>

   <?php if( th_advance_product_search()->get_option( 'tapsp_enable_voice_search' ) ): ?>
  <button type="button" class="tapsp-voice-btn" aria-label="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>" title="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>">
    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>
  </button>
  <?php endif; ?>

  <?php

  if(th_advance_product_search()->get_option( 'show_submit' )=='1'){?>

    <button id='thaps-search-button' value="<?php echo esc_attr_x( 'Submit','submit button', 'th-advance-product-search' ); ?>" type='submit'>  

   <?php if(th_advance_product_search()->get_option( 'level_submit' )!==''){

        echo esc_html(th_advance_product_search()->get_option( 'level_submit' ));

   }else{ 

       th_advance_product_search_icon_style_svg('icon-style', $icon_clr);

  }?></button> <?php }

    ?>
        <input type="hidden" name="post_type" value="product" />

        <span class="label label-default" id="selected_option"></span>

      </div>

 </form>

 </div>  

<!-- Bar style   -->      

<?php }elseif($layoutType == 'bar_style'){ ?>

<div id='thaps-search-box' class="thaps-search-box <?php echo esc_attr($layoutType);?>">
<form class="thaps-search-form" action='<?php echo esc_url( home_url( '/'  ) ); ?>' id='thaps-search-form'  method='get'>

<div class="thaps-from-wrap">
<button id='thaps-search-button' value="<?php echo esc_attr_x( 'Submit','submit button', 'th-advance-product-search' ); ?>" type='submit'>  
  <?php th_advance_product_search_icon_style_svg('icon-style', $icon_clr);?>
</button>
   <input id='thaps-search-autocomplete-<?php echo esc_attr($uniqueID); ?>' name='s' placeholder='<?php echo esc_attr(th_advance_product_search()->get_option( 'placeholder_text' ));?>' class="thaps-search-autocomplete thaps-form-control" value='<?php echo esc_attr(get_search_query()); ?>' type='text' title='<?php echo esc_attr_x( 'Search', 'label', 'th-advance-product-search' ); ?>' />

  <?php if(th_advance_product_search()->get_option( 'show_loader' )=='0'){ ?> 

   <div class="thaps-preloader"></div>

  <?php } ?>

  <?php if( th_advance_product_search()->get_option( 'tapsp_enable_voice_search' ) ): ?>
  <button type="button" class="tapsp-voice-btn" aria-label="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>" title="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>">
    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>
  </button>
  <?php endif; ?>

        <input type="hidden" name="post_type" value="product" />

        <span class="label label-default" id="selected_option"></span>

      </div>

 </form>

 </div>

<!-- Icon style   -->  

<?php }elseif($layoutType == 'icon_style'){ ?>

<div id='thaps-search-box' class="thaps-search-box <?php echo esc_attr($layoutType);?>">

<?php th_advance_product_search_icon_style_svg('click-icon', $icon_clr);?>

  <div class="thaps-icon-arrow" style=""></div>

 <form class="thaps-search-form" action='<?php echo esc_url( home_url( '/'  ) ); ?>' id='thaps-search-form'  method='get'>
<div class="thaps-from-wrap">

  <?php th_advance_product_search_icon_style_svg('icon-style', $icon_clr);?>

   <input id='thaps-search-autocomplete-<?php echo esc_attr($uniqueID); ?>' name='s' placeholder='<?php echo esc_attr(th_advance_product_search()->get_option( 'placeholder_text' ));?>' class="thaps-search-autocomplete thaps-form-control" value='<?php echo esc_attr(get_search_query()); ?>' type='text' title='<?php echo esc_attr_x( 'Search', 'label', 'th-advance-product-search' ); ?>' />

  <?php if(th_advance_product_search()->get_option( 'show_loader' )=='0'){ ?> 

   <div class="thaps-preloader"></div>

  <?php } ?>

  <?php if( th_advance_product_search()->get_option( 'tapsp_enable_voice_search' ) ): ?>
  <button type="button" class="tapsp-voice-btn" aria-label="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>" title="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>">
    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>
  </button>
  <?php endif; ?>

        <input type="hidden" name="post_type" value="product" />

        <span class="label label-default" id="selected_option"></span>

      </div>

 </form> 

</div>

<!-- mobile flexible -->

<?php }elseif($layoutType == 'flexible-style'){ 

if(wp_is_mobile()){

?>

<div id='thaps-search-box' class="thaps-search-box icon_style <?php echo esc_attr($layoutType);?>">

  <button id='thaps-search-button' value="<?php echo esc_attr_x( 'Submit','submit button', 'th-advance-product-search' ); ?>" type='submit'>  
  <?php th_advance_product_search_icon_style_svg('icon-style', $icon_clr);?>
</button>

  <div class="thaps-icon-arrow" style=""></div>

 <form class="thaps-search-form" action='<?php echo esc_url( home_url( '/'  ) ); ?>' id='thaps-search-form'  method='get'>

<div class="thaps-from-wrap">

  <?php th_advance_product_search_icon_style_svg('icon-style', $icon_clr);?>

   <input id='thaps-search-autocomplete-<?php echo esc_attr($uniqueID); ?>' name='s' placeholder='<?php echo esc_attr(th_advance_product_search()->get_option( 'placeholder_text' ));?>' class="thaps-search-autocomplete thaps-form-control" value='<?php echo esc_attr(get_search_query()); ?>' type='text' title='<?php echo esc_attr_x( 'Search', 'label', 'th-advance-product-search' ); ?>' />

  <?php if(th_advance_product_search()->get_option( 'show_loader' )=='0'){ ?>

   <div class="thaps-preloader"></div>

  <?php } ?>

  <?php if( th_advance_product_search()->get_option( 'tapsp_enable_voice_search' ) ): ?>
  <button type="button" class="tapsp-voice-btn" aria-label="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>" title="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>">
    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>
  </button>
  <?php endif; ?>

        <input type="hidden" name="post_type" value="product" />

        <span class="label label-default" id="selected_option"></span>

</div>

 </form> 

</div>
    <?php } else { ?>

<div id='thaps-search-box' class="thaps-search-box bar_style <?php echo esc_attr($layoutType);?>">
<form class="thaps-search-form" action='<?php echo esc_url( home_url( '/'  ) ); ?>' id='thaps-search-form'  method='get'>

<div class="thaps-from-wrap">

  <button id='thaps-search-button' value="<?php echo esc_attr_x( 'Submit','submit button', 'th-advance-product-search' ); ?>" type='submit'>  
  <?php th_advance_product_search_icon_style_svg('icon-style', $icon_clr);?>
</button>

   <input id='thaps-search-autocomplete-<?php echo esc_attr($uniqueID); ?>' name='s' placeholder='<?php echo esc_attr(th_advance_product_search()->get_option( 'placeholder_text' ));?>' class="thaps-search-autocomplete thaps-form-control" value='<?php echo esc_attr(get_search_query()); ?>' type='text' title='<?php echo esc_attr_x( 'Search', 'label', 'th-advance-product-search' ); ?>' />

  <?php if(th_advance_product_search()->get_option( 'show_loader' )=='0'){ ?>

   <div class="thaps-preloader"></div>

  <?php } ?>

  <?php if( th_advance_product_search()->get_option( 'tapsp_enable_voice_search' ) ): ?>
  <button type="button" class="tapsp-voice-btn" aria-label="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>" title="<?php echo esc_attr_x( 'Voice Search', 'voice button', 'th-advance-product-search' ); ?>">
    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>
  </button>
  <?php endif; ?>

        <input type="hidden" name="post_type" value="product" />

        <span class="label label-default" id="selected_option"></span>

      </div>

 </form>
 
 </div>

<?php } } 