* @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
/**
 * =========================================================================================================
 * IMPORTANT: The scope of this layout file is the `var  \Joomla\Module\Menu\Administrator\Menu\CssMenu` object
 * and NOT the module context.
 * =========================================================================================================
 */
/** @var  \Joomla\Module\Menu\Administrator\Menu\CssMenu  $this */
$class         = 'item';
$currentParams = $current->getParams();
// Build the CSS class suffix
if (!$this->enabled) {
    $class .= ' disabled';
} elseif ($current->type == 'separator') {
    $class = $current->title ? 'menuitem-group' : 'divider';
} elseif ($current->hasChildren()) {
    $class .= ' parent';
}
if ($current->level == 1) {
    $class .= ' item-level-1';
} elseif ($current->level == 2) {
    $class .= ' item-level-2';
} elseif ($current->level == 3) {
    $class .= ' item-level-3';
}
// Set the correct aria role and print the item
if ($current->type == 'separator') {
    echo '
';
} else {
    echo '';
}
// Print a link if it exists
$linkClass  = [];
$dataToggle = '';
$iconClass  = '';
$itemIconClass = '';
$itemImage  = '';
if ($current->hasChildren()) {
    $linkClass[] = 'has-arrow';
    if ($current->level > 2) {
        $dataToggle  = ' data-bs-toggle="dropdown"';
    }
} else {
    $linkClass[] = 'no-dropdown';
}
// Implode out $linkClass for rendering
$linkClass = ' class="' . implode(' ', $linkClass) . '" ';
// Get the menu link
$link = $current->link;
// Get the menu image class
$itemIconClass = $currentParams->get('menu_icon');
// Get the menu image
$itemImage = $currentParams->get('menu_image');
// Get the menu icon
$icon      = $this->getIconClass($current);
$iconClass = ($icon != '' && $current->level == 1) ? '' : '';
$ajax      = !empty($current->ajaxbadge) ? '' : '';
$iconImage = $current->icon;
$homeImage = '';
if ($iconClass === '' && $itemIconClass) {
    $iconClass = '';
}
if ($iconImage) {
    if (substr($iconImage, 0, 6) == 'class:' && substr($iconImage, 6) == 'icon-home') {
        $iconImage = '';
        $iconImage .= '' . Text::_('JDEFAULT') . '';
    } elseif (substr($iconImage, 0, 6) == 'image:') {
        $iconImage = ' ' . substr($iconImage, 6) . '';
    } else {
        $iconImage = '';
    }
}
$itemImage = (empty($itemIconClass) && $itemImage) ? '  . $itemImage . ') ' : '';
// If the item image is not set, the item title would not have margin. Here we add it.
if ($icon == '' && $iconClass == '' && $current->level == 1 && $current->target == '') {
    $iconClass = '';
}
if ($link != '' && $current->target != '') {
    echo ''
        . $iconClass
        . '' . $ajax . '';
} elseif ($link != '' && $current->type !== 'separator') {
    echo ''
        . $iconClass
        . '' . $iconImage . '';
} elseif ($current->title != '' && $current->type !== 'separator') {
    echo ''
        . $iconClass
        . '' . $ajax . '';
} elseif ($current->title != '' && $current->type === 'separator') {
    echo '' . $ajax;
} else {
    echo '' . Text::_($current->title) . '' . $ajax;
}
if ($currentParams->get('menu-quicktask') && (int) $this->params->get('shownew', 1) === 1) {
    $params = $current->getParams();
    $user = $this->application->getIdentity();
    $link = $params->get('menu-quicktask');
    $icon = $params->get('menu-quicktask-icon', 'plus');
    $title = $params->get('menu-quicktask-title', 'MOD_MENU_QUICKTASK_NEW');
    $permission = $params->get('menu-quicktask-permission');
    $scope = $current->scope !== 'default' ? $current->scope : null;
    if (!$permission || $user->authorise($permission, $scope)) {
        echo '';
    }
}
if (!empty($current->dashboard)) {
    $titleDashboard = Text::sprintf('MOD_MENU_DASHBOARD_LINK', Text::_($current->title));
    // Prepare the Dashboard icon. We use our own icon, not Fontawesome
    $pathDashboard = 'media/templates/administrator/atum/images/icons/dashboard.svg';
    $attrDashboard = [
        'loading'     => 'eager',
        'decoding'    => 'async',
        'aria-hidden' => 'true',
        'class'       => 'atum-dashboard',
        'height'      => '18',
    ];
    $iconDashboard = HTMLHelper::_('image', $pathDashboard, '', $attrDashboard, false, 0);
    echo '';
}
// Recurse through children if they exist
if ($this->enabled && $current->hasChildren()) {
    if ($current->level > 1) {
        $id = $current->id ? ' id="menu-' . strtolower($current->id) . '"' : '';
        echo '
 ' : '';
// If the item image is not set, the item title would not have margin. Here we add it.
if ($icon == '' && $iconClass == '' && $current->level == 1 && $current->target == '') {
    $iconClass = '';
}
if ($link != '' && $current->target != '') {
    echo ''
        . $iconClass
        . '' . $ajax . '';
} elseif ($link != '' && $current->type !== 'separator') {
    echo ''
        . $iconClass
        . '' . $iconImage . '';
} elseif ($current->title != '' && $current->type !== 'separator') {
    echo ''
        . $iconClass
        . '' . $ajax . '';
} elseif ($current->title != '' && $current->type === 'separator') {
    echo '' . $ajax;
} else {
    echo '' . Text::_($current->title) . '' . $ajax;
}
if ($currentParams->get('menu-quicktask') && (int) $this->params->get('shownew', 1) === 1) {
    $params = $current->getParams();
    $user = $this->application->getIdentity();
    $link = $params->get('menu-quicktask');
    $icon = $params->get('menu-quicktask-icon', 'plus');
    $title = $params->get('menu-quicktask-title', 'MOD_MENU_QUICKTASK_NEW');
    $permission = $params->get('menu-quicktask-permission');
    $scope = $current->scope !== 'default' ? $current->scope : null;
    if (!$permission || $user->authorise($permission, $scope)) {
        echo '';
    }
}
if (!empty($current->dashboard)) {
    $titleDashboard = Text::sprintf('MOD_MENU_DASHBOARD_LINK', Text::_($current->title));
    // Prepare the Dashboard icon. We use our own icon, not Fontawesome
    $pathDashboard = 'media/templates/administrator/atum/images/icons/dashboard.svg';
    $attrDashboard = [
        'loading'     => 'eager',
        'decoding'    => 'async',
        'aria-hidden' => 'true',
        'class'       => 'atum-dashboard',
        'height'      => '18',
    ];
    $iconDashboard = HTMLHelper::_('image', $pathDashboard, '', $attrDashboard, false, 0);
    echo '';
}
// Recurse through children if they exist
if ($this->enabled && $current->hasChildren()) {
    if ($current->level > 1) {
        $id = $current->id ? ' id="menu-' . strtolower($current->id) . '"' : '';
        echo '' . "\n";
    } else {
        echo '' . "\n";
    }
    // WARNING: Do not use direct 'include' or 'require' as it is important to isolate the scope for each call
    $this->renderSubmenu(__FILE__, $current);
    echo "
\n";
}
echo "
\n";