@if($community->gift_app_community==0 and $selected_pricing_plan_type!='giftapp')
	<li>
		<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Post Actions</a>
		<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
		
		<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
			<li>
				<a class="nested-submenu-link" href="#" onclick="openTeamCollaboration()">Write a Post</a>
			</li>
			
			<li>
				<a class="nested-submenu-link" href="#" onclick="openTeamCollaboration()">Create a Poll</a>
			</li>
			
			<li>
				<a class="nested-submenu-link" href="#" onclick="openTeamCollaboration()">Upload a Document</a>
			</li>
			
			<li>
				<a class="nested-submenu-link" href="#" onclick="openTeamCollaboration()">Post an Event</a>
			</li>
			
			<li>
				<a class="nested-submenu-link" href="#" onclick="openTeamCollaboration()">Start a Crowdfunding</a>
			</li>
			
			<li>
				<a class="nested-submenu-link" href="#" onclick="openTeamCollaboration()">Write an Article</a>
			</li>
		</ul>
	</li>

	@php
		$taskFeatureIds = ['11','12','13','14'];
		$taskMenuItems = [
			'11' => ['label' => 'Task Management', 'href' => $communityPresenter->url('alltasks')],
			'12' => ['label' => 'Daily Reporting', 'href' => '#'],
			'13' => ['label' => 'Task Complete Report', 'href' => '#'],
			'14' => ['label' => 'Notes', 'href' => $communityPresenter->url('personalnotes')],
		];

		$enabledTaskFeatures = ($menus_activated == 'yes')
			? $taskFeatureIds
			: array_values(array_intersect($taskFeatureIds, $features));
		$enabledTaskLookup = array_fill_keys($enabledTaskFeatures, true);
	@endphp

	@if($menus_activated=='yes' || !empty($enabledTaskFeatures))
		<li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Tasks</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
				@foreach($taskMenuItems as $featureId => $item)
					@if(isset($enabledTaskLookup[$featureId]))
						<li><a href="{{$item['href']}}" class="nested-submenu-link">{{$item['label']}}</a></li>
					@endif
				@endforeach
			</ul>
		</li>
	@endif

	@php
		// Campaign
		$campaignFeatureIds = ['3','16','5','17','18','19'];
		$campaignMenuItems = [
			'3' => ['label' => 'Email', 'href' => $communityPresenter->url('campaigns')],
			'5' => ['label' => 'Forms/Surveys', 'href' => $communityPresenter->url('cmsurveys')],
			'16' => ['label' => 'Contact List', 'href' => $communityPresenter->url('campaignmailingcat')],
			'17' => ['label' => 'Prospects', 'href' => '#'],
			'18' => ['label' => 'Qualified Lead', 'href' => '#'],
			'19' => ['label' => 'Organize Awards', 'href' => $communityPresenter->url('longforms')],
		];
		$enabledCampaignFeatures = [];
		if ($menus_activated == 'yes') {
			$enabledCampaignFeatures = $campaignFeatureIds;
		} else {
			foreach ($campaignFeatureIds as $featureId) {
				if (isset($featuresLookup[$featureId])) {
					$enabledCampaignFeatures[] = $featureId;
				}
			}
		}
		$enabledCampaignLookup = !empty($enabledCampaignFeatures) ? array_fill_keys($enabledCampaignFeatures, true) : [];

		// Customers
		$customerFeatureIds = ['6','20','58'];
		$customerMenuItems = [
			'6' => ['type' => 'link', 'label' => 'Agreement', 'href' => $communityPresenter->url('pdf-sign')],
			'20' => ['type' => 'link', 'label' => 'Engagement', 'href' => '#'],
			'58' => [
				'type' => 'submenu',
				'label' => 'Projects',
                'href' => '#',
				'children' => [
					//['label' => 'Task Type', 'href' => ''],
				],
			],
		];
		$enabledCustomerFeatures = [];
		if ($menus_activated == 'yes') {
			$enabledCustomerFeatures = $customerFeatureIds;
		} else {
			foreach ($customerFeatureIds as $featureId) {
				if (isset($featuresLookup[$featureId])) {
					$enabledCustomerFeatures[] = $featureId;
				}
			}
		}
		$enabledCustomerLookup = !empty($enabledCustomerFeatures) ? array_fill_keys($enabledCustomerFeatures, true) : [];

		// Invoices
		$invoiceFeatureIds = ['10','24','25','26','27'];
		$invoiceMenuItems = [
			'10' => [
				['label' => 'Create Invoice', 'href' => URL::route('community-invoice-create', ['slug' => 0])],
				['label' => 'Sent Invoice', 'href' => URL::route('community-invoices', ['slug' => 0])],
			],
			'24' => [['label' => 'Transaction Details', 'href' => URL::route('my-orders')]],
			'25' => [['label' => 'Payment Report', 'href' => URL::route('community-invoices-received', ['slug' => 0])]],
			'26' => [['label' => 'Connect with Account', 'href' => '#']],
			'27' => [['label' => 'Distribute', 'href' => '#']],
		];
		$enabledInvoiceFeatures = [];
		if ($menus_activated == 'yes') {
			$enabledInvoiceFeatures = $invoiceFeatureIds;
		} else {
			foreach ($invoiceFeatureIds as $featureId) {
				if (isset($featuresLookup[$featureId])) {
					$enabledInvoiceFeatures[] = $featureId;
				}
			}
		}
		$enabledInvoiceLookup = !empty($enabledInvoiceFeatures) ? array_fill_keys($enabledInvoiceFeatures, true) : [];
	@endphp

	@if($menus_activated=='yes' || !empty($enabledCampaignFeatures))
		<li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Campaign</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
				@foreach($campaignMenuItems as $featureId => $item)
					@if(isset($enabledCampaignLookup[$featureId]))
						<li><a href="{{$item['href']}}" class="nested-submenu-link">{{$item['label']}}</a></li>
					@endif
				@endforeach
			</ul>
		</li>
	@endif

	@if($menus_activated=='yes' || !empty($enabledCustomerFeatures))
		<li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Customers</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
				@foreach($customerMenuItems as $featureId => $item)
					@if(isset($enabledCustomerLookup[$featureId]))
						@if($item['type'] === 'link')
							<li><a href="{{$item['href']}}" class="nested-submenu-link">{{$item['label']}}</a></li>
						@else
							<li>
								<a href="#" class="nested-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">{{$item['label']}}</a>
								<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
								<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
									@foreach($item['children'] as $child)
										<li><a href="{{$child['href']}}" class="nested-submenu-link">{{$child['label']}}</a></li>
									@endforeach
								</ul>
							</li>
						@endif
					@endif
				@endforeach
			</ul>
		</li>
	@endif

	@if($menus_activated=='yes' || !empty($enabledInvoiceFeatures))
		<li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Invoices</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
				@foreach($invoiceMenuItems as $featureId => $links)
					@if(isset($enabledInvoiceLookup[$featureId]))
						@foreach($links as $link)
							<li><a href="{{$link['href']}}" class="nested-submenu-link">{{$link['label']}}</a></li>
						@endforeach
					@endif
				@endforeach
			</ul>
		</li>
	@endif

	@php
		$reportFeatureIds = ['28','29','30','31','7','63','33','34','35','36','37'];
		$enabledReportFeatures = [];
		if ($menus_activated == 'yes') {
			$enabledReportFeatures = $reportFeatureIds;
		} else {
			foreach ($reportFeatureIds as $featureId) {
				if (isset($featuresLookup[$featureId])) {
					$enabledReportFeatures[] = $featureId;
				}
			}
		}
		$enabledReportLookup = !empty($enabledReportFeatures) ? array_fill_keys($enabledReportFeatures, true) : [];
		$reportMenuItems = [
			'28' => ['label' => 'Calendar', 'href' => $communityPresenter->url('cmeventscalendar'), 'when' => true],
			'29' => ['label' => 'Events List', 'href' => $communityPresenter->url('ownevents'), 'when' => true],
			'30' => ['label' => 'Crowdfunding List', 'href' => $communityPresenter->url('allcrowdfunding'), 'when' => true],
			'33' => ['label' => 'Polls', 'href' => $communityPresenter->url('surveys'), 'when' => true],
			'34' => ['label' => 'Documents', 'href' => $communityPresenter->url('documentsdashboard'), 'when' => $communityPresenter->canManage()],
			'35' => ['label' => 'Visitor Statistics', 'href' => $communityPresenter->url('visitorsstat'), 'when' => $community->isOwner()],
			'36' => ['label' => 'Members', 'href' => $communityPresenter->url('members'), 'when' => $community->isOwner()],
			'37' => ['label' => 'Unverified Members', 'href' => $communityPresenter->url('unverifiedmembers'), 'when' => $community->isOwner()],
		];
	@endphp

	@if($menus_activated=='yes' || !empty($enabledReportFeatures))
		<li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Reports</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
				@foreach($reportMenuItems as $featureId => $item)
					@if(isset($enabledReportLookup[$featureId]) && !empty($item['when']))
						<li><a href="{{$item['href']}}" class="nested-submenu-link">{{$item['label']}}</a></li>
					@endif
				@endforeach

				@if(isset($enabledReportLookup['31']))
					@php
						$postReviewsCount = $communityPresenter->canManage()
							? $communityPresenter->pendingCommunityActionsCount()
							: $communityPresenter->myPendingCommunityActionsCount();
					@endphp
					@if($communityPresenter->canManage())
						<li>
							<a class="nested-submenu-link" href="{{$communityPresenter->url('membersposts')}}">
								Post Reviews
								@if(!empty($postReviewsCount))
									<span style="margin-top:2px; color: #0707fb; font-weight: bold; padding-left: 7px;">{{$postReviewsCount}}</span>
								@endif
							</a>
						</li>
                        
                        <li>
							<a class="nested-submenu-link" href="{{$communityPresenter->url('pendingstores')}}">
								Store Reviews
								@if(!empty($storeReviewsCount = $communityPresenter->pendingStoresCount()))
									<span style="margin-top:2px; color: #0707fb; font-weight: bold; padding-left: 7px;">{{$storeReviewsCount}}</span>
								@endif
							</a>
						</li>
					@else
						<li>
							<a class="nested-submenu-link" href="{{$communityPresenter->url('myactionrequired')}}">
								Post Reviews
								@if(!empty($postReviewsCount))
									<span style="margin-top:2px; color: #0707fb; font-weight: bold; padding-left: 7px;">{{$postReviewsCount}}</span>
								@endif
							</a>
						</li>
					@endif
				@endif

				@if($communityPresenter->canManage() && isset($enabledReportLookup['7']))
					<li><a class="nested-submenu-link" href="{{$communityPresenter->url('ignoredposts')}}">Ignored Posts</a></li>
				@endif

				@if(!$community->isOwner() && isset($enabledReportLookup['63']))
					<li><a class="nested-submenu-link" href="{{$communityPresenter->url('groupsurveys')}}">Report Reviews</a></li>
				@endif

				@if($newRequests=$communityPresenter->postsOwnershipRequests())
					<li><a class="nested-submenu-link" href="{{$communityPresenter->url('postsrequests')}}">Post Ownership Requests</a></li>
				@endif
			</ul>
		</li>
	@endif

	@php
		// Support
		$supportFeatureIdsForMenuVisibility = ['38','39','40','41','42'];
		$supportMenuItems = [
			'38' => ['label' => 'FAQs', 'href' => '#'],
			'39' => ['label' => 'Tutorials', 'href' => '#'],
			'40' => ['label' => 'Support Chat', 'href' => '#'],
			'41' => ['label' => 'Ticket Management', 'href' => '#'],
			'44' => ['label' => 'Webpages', 'href' => '#'],
		];
		$showSupportMenu = false;
		if ($menus_activated == 'yes') {
			$showSupportMenu = true;
		} else {
			foreach ($supportFeatureIdsForMenuVisibility as $featureId) {
				if (isset($featuresLookup[$featureId])) {
					$showSupportMenu = true;
					break;
				}
			}
		}
		$enabledSupportLookup = [];
		if ($menus_activated == 'yes') {
			$enabledSupportLookup = array_fill_keys(array_keys($supportMenuItems), true);
		} else {
			foreach (array_keys($supportMenuItems) as $featureId) {
				if (isset($featuresLookup[$featureId])) {
					$enabledSupportLookup[$featureId] = true;
				}
			}
		}

		// Settings
		$settingsFeatureIds = ['64','43','44','45','46','32','49','1','50','47','53'];
		$settingsOwnerMenuItems = [
			'64' => ['label' => 'Community Members', 'href' => $communityPresenter->url('invite')],
			'43' => ['label' => 'Webpage | Login with Settings', 'href' => $communityPresenter->url('pages')],
			//'44' => ['label' => 'SEO & Social Sharing', 'href' => $communityPresenter->url('socialfeed')],
			'45' => ['label' => 'Organization Information', 'href' => $communityPresenter->url('pannelsetting')],
			//'46' => ['label' => 'Bank Details', 'href' => $communityPresenter->url('communitybankdetails')],
			'32' => ['label' => 'Community Marketplace', 'href' => $communityPresenter->url('emarketplace')],
			'49' => ['label' => 'Admin Privileges', 'href' => $communityPresenter->url('privilegesettings')],
			'1' => ['label' => 'Corporate Website Design', 'href' => $communityPresenter->url('homepagecontents')],
			//'50' => ['label' => 'Language & Translation', 'href' => $communityPresenter->url('activelanguages')],
			'47' => ['label' => 'Subscription Plan', 'href' => $communityPresenter->url('communitypayment')],
			'53' => ['label' => 'After Login View', 'href' => $communityPresenter->url('mysettings')],
		];
		$settingsNonOwnerMenuItems = [
			'53' => ['label' => 'After Login View', 'href' => $communityPresenter->url('mysettings')],
		];
		$enabledSettingsFeatures = [];
		if ($menus_activated == 'yes') {
			$enabledSettingsFeatures = $settingsFeatureIds;
		} else {
			foreach ($settingsFeatureIds as $featureId) {
				if (isset($featuresLookup[$featureId])) {
					$enabledSettingsFeatures[] = $featureId;
				}
			}
		}
		$enabledSettingsLookup = !empty($enabledSettingsFeatures) ? array_fill_keys($enabledSettingsFeatures, true) : [];
	@endphp

	@if($showSupportMenu)
		<li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Support</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
				@foreach($supportMenuItems as $featureId => $item)
					@if(isset($enabledSupportLookup[$featureId]))
						<li><a href="{{$item['href']}}" class="nested-submenu-link">{{$item['label']}}</a></li>
					@endif
				@endforeach
			</ul>
		</li>
	@endif

	@if($menus_activated=='yes' || !empty($enabledSettingsFeatures) || $community->race_community==1 || $selected_pricing_plan_type=='racing')
		<li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Settings</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
				@php($settingsMenuItems = $community->isOwner() ? $settingsOwnerMenuItems : $settingsNonOwnerMenuItems)
				@foreach($settingsMenuItems as $featureId => $item)
					@if(isset($enabledSettingsLookup[$featureId]))
						<li><a href="{{$item['href']}}" class="nested-submenu-link">{{$item['label']}}</a></li>
					@endif
				@endforeach
                
                @if($community->race_community==1 || $selected_pricing_plan_type=='racing')
                      <li>
                          <a class="nested-submenu-link" href="{{$community->present()->url('racingdashboard')}}">
                               SIM Booking Management
                          </a>
                      </li>
                      
                      <li>
                          <a class="nested-submenu-link" href="{{$community->present()->url('corporateracingdashboard')}}">
                             Group Booking Management
                          </a>
                      </li>
                      
                      <li>
                          <a data-ajaxify="true" class="nested-submenu-link" href="{{$community->present()->url('centerapplications')}}">
                               Center Applications
                          </a>
                      </li>    
                @endif
			</ul>
		</li>
	@endif
@elseif($community->gift_app_community==1 ||  $selected_pricing_plan_type=='giftapp')
	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/overview')}}">Account</a>
	</li>

	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/fundaccount')}}">Top-Up</a>
	</li>

	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/sendfund')}}">Send</a>
	</li>

	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/requestfund')}}">Request</a>
	</li>

	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/giftpurchase')}}">Gift Cycle</a>
	</li>

	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/bankdetails')}}">Bank Details</a>
	</li>

	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/cashoutmoney')}}">Cashout Money</a>
	</li>

	<li>
		<a class="id-submenu-link" href="{{$communityPresenter->url('gifts/sendfundusers')}}">Contacts</a>
	</li>

	<li>
		<a class="id-submenu-link">
			<div>
				<span class="gift_referral_codes_heading" style="text-decoration:none;">Invitation Link:</span>
				<?php
					$my_gifts=$communityPresenter->getMyAllGifts($community->id,Auth::user()->id);
				?>

				@if(count($my_gifts)>0)
					@foreach($my_gifts as $gft)
						<span class="gift_referral_code_show post-url-copy" data-id="{{$gft->id}}-gift" title="Click to Copy">${{number_format((float)$gft->amount, 2, '.', '')}}</span>

						 <span style="display:none" id="postUrlToCopy{{$gft->id}}-gift">{{$communityPresenter->url('gift/contribute')}}/{{$gft->id}}</span>

						 <span class="postUrlcopyMessage GiftReferrUrlcopyMessage" id="postUrlcopyMessage{{$gft->id}}-gift">Link Copied</span>
					@endforeach	
				@else
					<?php
						$usr_gifts=$communityPresenter->getMyAllGifts($community->id,126);
					?>

					@foreach($usr_gifts as $gft)
						<span class="gift_referral_code_show post-url-copy" data-id="{{$gft->id}}-gift" title="Click to Copy">copy invitation link</span>

						 <span style="display:none" id="postUrlToCopy{{$gft->id}}-gift">{{$communityPresenter->url('gift/contribute')}}/{{$gft->id}}</span>

						 <span class="postUrlcopyMessage GiftReferrUrlcopyMessage" id="postUrlcopyMessage{{$gft->id}}-gift">Link Copied</span>
					@endforeach	
				@endif

				@if(count($my_gifts)>0)
					<div class="gift_referral_codes_heading" style="text-decoration: none; margin-left: 0px;">Select a donation amount </div>
				@endif
			</div>
		</a>
	</li>

	@if($community->isOwner())
		<!--<li>
			<a class="id-submenu-link" href="{{$communityPresenter->url('panneldashboard')}}">Organization Settings</a>
		</li>-->
        
        <li>
			<a href="#" style="color:#000" class="id-submenu-link" onclick="event.preventDefault(); toggleNestedSubmenu(this); return false;">Settings</a>
			<i class="nested-menu-arrow fa fa-chevron-down" style="position: absolute; right: 20px; top: 10px; cursor: pointer;"></i>
			
			<ul class="nested-submenu" style="max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out;">
            	<li><a href="{{$community->present()->url('managegifts')}}" class="nested-submenu-link">Manage Gifts</a></li>
                <li><a href="{{$community->present()->url('giftscreated')}}" class="nested-submenu-link">Purchased Gifts</a></li>
                <li><a href="{{$community->present()->url('giftsdashboard')}}" class="nested-submenu-link">Account Overview</a></li>				
                <li><a href="{{$community->present()->url('cashoutrequests')}}" class="nested-submenu-link">Cashout Requests</a></li>				
                @if($community->take_payment_in_own_account==1)
                	<li><a href="{{$community->present()->url('paymentsettings')}}" class="nested-submenu-link">Payment Settings</a></li>			
                @endif
                
                @if($community->activate_advertisement==1)
                	 <li><a href="{{$community->present()->url('advertisements/manage')}}" class="nested-submenu-link">Advertisements</a></li>			
                @endif
                
                <li><a href="{{$community->present()->url('communitybankdetails')}}" class="nested-submenu-link">Bank Details</a></li>			
                
				<li><a href="{{$community->present()->url('communitypayment')}}" class="nested-submenu-link">Subscription Plans</a></li>		
                
                <li><a href="{{$community->present()->url('homepagecontents')}}" class="nested-submenu-link">Corporate Website Design</a></li>		
                
                 @if($community->show_ai_chatbox==1)
                    <li><a href="{{$community->present()->url('aichatbot')}}" class="nested-submenu-link">AI Chatbot Setting</a></li>					  
			  @endif			
			</ul>
		</li>
	@endif
@endif
