<?php
/**
 * Ahead WebSoft Technologies Pvt Ltd.
 * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
 * @license    https://www.socialengine.com/policies
*/
?>

<header class="pulse_header">
	<div class="container pulse_header_inner">
    <div class="header_left">
      <?php if(engine_in_array('logo',$this->options)){ ?>
        <div class="header_logo">
          <?php echo $this->content()->renderWidget("core.menu-logo",array("logo"=>$this->logo)); ?>
        </div>
        <?php if($this->accessibility_option){ ?>
            <div class="header_logo_contrast">
              <?php echo $this->content()->renderWidget("core.menu-logo",array("logo"=>$this->logocontrast)); ?> 
          </div>
        <?php } ?>    
      <?php } ?>
    </div>
    <div class="header_search_wrap">
      <?php if(engine_in_array('search',$this->options)){ ?>
        <div class="header_search">
          <?php echo $this->content()->renderWidget("core.search-mini"); ?>
        </div>
      <?php } ?>
    </div>
    <div class="header_right">
			<?php if($this->viewer->getIdentity()) { ?>
				<div class="dropdown pulse_header_mainmenu_dropdown_container">
					<?php include APPLICATION_PATH . '/application/modules/Pulse/widgets/header/_dashboardmenu.tpl'; ?>
				</div>
			<?php } elseif(engine_in_array('mainMenu',$this->options)) { ?>
				<div class="dropdown pulse_header_mainmenu_dropdown_container">
					<?php include APPLICATION_PATH . '/application/modules/Pulse/widgets/header/_dashboardmenu.tpl'; ?>
				</div>
			<?php } ?>
      <?php if(engine_in_array('miniMenu',$this->options)){ ?>
        <div class="header_menu_mini">
          <?php echo $this->content()->renderWidget("core.menu-mini"); ?>
        </div>
      <?php } ?> 
    </div>

		<?php if(empty($this->viewer->getIdentity())){ ?>
			<div class="header_mobile_menu">
				<a href="javascript:void(0)" id="header_mobile_menu">
					<i class="fi fi-rr-menu-burger"></i>
				</a>
			</div>
		<?php }; ?>
  </div> 
</header>

<script type="text/javascript">
	<?php if(empty($this->viewer->getIdentity())){ ?>
		en4.core.runonce.add(function() {
			document.getElementById('header_mobile_menu')?.addEventListener('click', function () {
				document.body.classList.add('pulse_mobile_menu_open');
				const menu = document.getElementById('menu-profile');
				if (menu) {
					menu.classList.add('open');
					menu.style.display = 'flex';
				}
			});
			document.getElementById('header_mobile_profile_menu_close')?.addEventListener('click', function () {
				document.body.classList.remove('pulse_mobile_menu_open');
				const menu = document.getElementById('menu-profile');
				if (menu) {
					menu.classList.remove('open');
					menu.style.display = 'none';
				}
			});
		});
	<?php }; ?>
	setTimeout(function () {
		scriptJquery('.layout_core_search_mini form input').on('focus blur', function (e) {
				scriptJquery(this).parents('#global_search_form').toggleClass('focused', (e.type === 'focus' || this.value.length > 0));
		}).trigger('blur');
	}, 2000);


	<?php if(!empty($this->navigation)) { ?>
		en4.core.runonce.add(function() {
			AttachEventListerSE("keyup",'.dashboard_search_input',function() {
				var value = scriptJquery(this).val().toLowerCase();
				var hasResult = false;
				scriptJquery('.pulse_header_mainmenu_item').each(function () {
					var section = scriptJquery(this);
					var sectionTitle = section.find('.dashboardmenu_head').text().toLowerCase();
					var items = section.find('.pulse_header_mainmenu_item_link');
					var sectionMatch = sectionTitle.includes(value);
					var itemMatchCount = 0;
					items.each(function () {
						var itemText = scriptJquery(this).text().toLowerCase();
						if (itemText.includes(value)) {
							scriptJquery(this).show();
							itemMatchCount++;
							hasResult = true;
						} else {
							scriptJquery(this).hide();
						}
					});

					//Show section if title matches OR any item matches
					if (sectionMatch || itemMatchCount > 0) {
						section.show();
						hasResult = true;
					} else {
						section.hide();
					}
				});
				//Show/Hide No Result Message
				if (!hasResult) {
					scriptJquery('.dashboard_no_result').show();
				} else {
					scriptJquery('.dashboard_no_result').hide();
				}
			});
		});
	<?php } ?>
</script>
