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

// @codingStandardsIgnoreFile

/** @var $block \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs */
?>
<?php if (!empty($tabs)): ?>
    <?php $tabGroups = [
        \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::BASIC_TAB_GROUP_CODE,
        \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::ADVANCED_TAB_GROUP_CODE,
    ];?>

    <div id="<?= /* @escapeNotVerified */ $block->getId() ?>"
         data-mage-init='{"tabs":{
        "active": "<?= /* @escapeNotVerified */ $block->getActiveTabId() ?>",
        "destination": "#<?= /* @escapeNotVerified */ $block->getDestElementId() ?>",
        "shadowTabs": "<?= /* @escapeNotVerified */ $block->getAllShadowTabs() ?>",
        "tabsBlockPrefix": "<?= /* @escapeNotVerified */ $block->getId() ?>_",
        "tabIdArgument": "active_tab",
        "tabPanelClass": "<?= /* @escapeNotVerified */ $block->getPanelsClass() ?>",
        "excludedPanel": "<?= /* @escapeNotVerified */ $block->getExcludedPanel() ?>",
        "groups": "ul.tabs"
    }}'>
        <?php foreach ($tabGroups as $tabGroupCode): ?>
            <?php
                $tabGroupId = $block->getId() . '-' . $tabGroupCode;
                $isBasic = $tabGroupCode == \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::BASIC_TAB_GROUP_CODE;
                $activeCollapsible = $block->isAdvancedTabGroupActive() ? true : false;
            ?>

            <div class="admin__page-nav <?php if (!$isBasic): ?> <?= '_collapsed' ?> <?php endif;?>"
                data-role="container"
                id="<?= /* @escapeNotVerified */ $tabGroupId ?>"
                <?php if (!$isBasic): ?>
                    data-mage-init='{"collapsible":{
                    "active": "<?= /* @escapeNotVerified */ $activeCollapsible ?>",
                    "openedState": "_show",
                    "closedState": "_hide",
                    "animate": 200,
                    "collapsible": true
                    }}'
                <?php endif;?>>

                <div class="admin__page-nav-title-wrap" <?= /* @escapeNotVerified */ $block->getUiId('title') ?> data-role="title">
                    <div class="admin__page-nav-title <?php if (!$isBasic): ?> <?= '_collapsible' ?><?php endif;?>"
                        data-role="trigger">
                        <strong>
                            <?= /* @escapeNotVerified */ $isBasic ? __('Basic Settings') : __('Advanced Settings') ?>
                        </strong>
                        <span data-role="title-messages" class="admin__page-nav-title-messages"></span>
                    </div>
                </div>

                <ul <?= /* @escapeNotVerified */ $block->getUiId('tab', $tabGroupId) ?> class="tabs admin__page-nav-items" data-role="content">
                    <?php foreach ($tabs as $_tab): ?>
                        <?php /** @var $_tab \Magento\Backend\Block\Widget\Tab\TabInterface */ ?>
                        <?php if (!$block->canShowTab($_tab) || $_tab->getParentTab()
                            || ($_tab->getGroupCode() && $_tab->getGroupCode() != $tabGroupCode)
                            || (!$_tab->getGroupCode() && $isBasic)): continue; endif;?>
                        <?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' . (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) == '#' ? '#' . $block->getTabId($_tab) . '_content' : $block->getTabUrl($_tab) ?>
                        <li class="admin__page-nav-item <?php if ($block->getTabIsHidden($_tab)): ?> <?= "no-display" ?> <?php endif; ?> " <?= /* @escapeNotVerified */ $block->getUiId('tab', 'item', $_tab->getId()) ?>>
                            <a href="<?= /* @escapeNotVerified */ $_tabHref ?>" id="<?= /* @escapeNotVerified */ $block->getTabId($_tab) ?>"
                               name="<?= /* @escapeNotVerified */ $block->getTabId($_tab, false) ?>"
                               title="<?= /* @escapeNotVerified */ $block->getTabTitle($_tab) ?>"
                               class="admin__page-nav-link <?= /* @escapeNotVerified */ $_tabClass ?>"
                               data-tab-type="<?= /* @escapeNotVerified */ $_tabType ?>" <?= /* @escapeNotVerified */ $block->getUiId('tab', 'link', $_tab->getId()) ?>
                            >
                                <span><?= $block->escapeHtml($block->getTabLabel($_tab)) ?></span>
                                <span class="admin__page-nav-item-messages" data-role="item-messages">
                                   <span class="admin__page-nav-item-message _changed">
                                       <span class="admin__page-nav-item-message-icon"></span>
                                       <span class="admin__page-nav-item-message-tooltip">
                                           <?= /* @escapeNotVerified */ __('Changes have been made to this section that have not been saved.') ?>
                                       </span>
                                   </span>
                                   <span class="admin__page-nav-item-message _error">
                                       <span class="admin__page-nav-item-message-icon"></span>
                                       <span class="admin__page-nav-item-message-tooltip">
                                           <?= /* @escapeNotVerified */ __('This tab contains invalid data. Please resolve this before saving.') ?>
                                       </span>
                                   </span>
                                    <span class="admin__page-nav-item-message-loader">
                                       <span class="spinner">
                                           <span></span><span></span><span></span><span></span>
                                           <span></span><span></span><span></span><span></span>
                                       </span>
                                   </span>
                                </span>
                            </a>
                            <div id="<?= /* @escapeNotVerified */ $block->getTabId($_tab) ?>_content" class="no-display"
                                 data-tab-panel="<?= /* @escapeNotVerified */ $_tab->getTabId() ?>"
                                <?= /* @escapeNotVerified */ $block->getUiId('tab', 'content', $_tab->getId()) ?>
                            >
                                <?= /* @escapeNotVerified */ $block->getTabContent($_tab) ?>
                                <?= /* @noEscape */ $block->getAccordion($_tab) ?>
                            </div>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>
