<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

use Magento\Framework\Escaper;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

/**
 * @var SecureHtmlRenderer $secureRenderer
 * @var Escaper $escaper
 */
?>
<?php if (!empty($tabs)): ?>
    <?php $blockId = $block->getId() ?>
<div id="<?= $escaper->escapeHtmlAttr($blockId) ?>" class="hidden">
<ul  class="tabs-horiz">
    <?php foreach ($tabs as $_tab): ?>
        <?php $tabId = $block->getTabId($_tab) ?>
        <?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' .
            ($_tab->getClass() !== null ? (preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') : '') ?>
        <?php $_tabType = (!preg_match('/\s?ajax\s?/', $_tabClass) && $block->getTabUrl($_tab) != '#') ? 'link' : '' ?>
        <?php $_tabHref = $block->getTabUrl($_tab) == '#' ?
            '#' . $tabId . '_content' :
            $block->getTabUrl($_tab) ?>
    <li>
        <a href="<?= $escaper->escapeUrl($_tabHref) ?>"
           id="<?= $escaper->escapeHtmlAttr($tabId) ?>"
           title="<?= $escaper->escapeHtmlAttr($block->getTabTitle($_tab)) ?>"
           class="<?= $escaper->escapeHtmlAttr($_tabClass) ?>"
           data-tab-type="<?= $escaper->escapeHtmlAttr($_tabType) ?>">
            <span>
                <span class="changed"
                      title="<?= $escaper->escapeHtmlAttr(__(
                          'The information in this tab has been changed.'
                      )) ?>"></span>
                <span class="error"
                      title="<?= $escaper->escapeHtmlAttr(__(
                          'This tab contains invalid data. Please resolve this before saving.'
                      )) ?>"></span>
                <span class="loader"
                      title="<?= $escaper->escapeHtmlAttr(__('Loading...')) ?>"></span>
                <?= $escaper->escapeHtml($block->getTabLabel($_tab)) ?>
            </span>
        </a>
        <div id="<?= $escaper->escapeHtmlAttr($tabId) ?>_content">
            <?= /* @noEscape */ $block->getTabContent($_tab) ?>
        </div>
        <?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
            'display:none',
            '#' . $escaper->escapeJs($tabId) . '_content'
        ); ?>
    </li>
    <?php endforeach; ?>
</ul>
</div>
    <?php $scriptString = <<<script
require(["jquery","mage/backend/tabs"], function($){
    $(function() {
        $('#{$escaper->escapeJs($blockId)}').tabs({
            active: '{$escaper->escapeJs($block->getActiveTabId())}',
            destination: '#{$escaper->escapeJs($block->getDestElementId())}',
            shadowTabs: {$block->getAllShadowTabs()}
        });
        $('#{$escaper->escapeJs($blockId)}').removeClass('hidden');
    });
});
script;
    ?>
    <?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
<?php endif; ?>
