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

// phpcs:disable Magento2.Templates.ThisInTemplate
// phpcs:disable Squiz.PHP.GlobalKeyword.NotAllowed
?>
<?php
    $_order  = $block->getOrder();
    $_source = $block->getSource();
    $_fullInfo = $this->helper(\Magento\Tax\Helper\Data::class)->getCalculatedTaxes($_source);
    global $taxIter;
    $taxIter++;
?>

<?php if ($_fullInfo && $block->displayFullSummary()) : ?>
        <?php foreach ($_fullInfo as $info) : ?>
            <?php
                $percent    = $info['percent'];
                $amount     = $info['tax_amount'];
                $baseAmount = $info['base_tax_amount'];
                $title      = $info['title'];
            ?>
            <tr class="totals tax details details-<?= (int) $taxIter ?><?= ($block->getIsPlaneMode()) ? ' plane' : '' ?>">
                <td <?= /* @noEscape */ $block->getLabelProperties() ?>>
                    <?= $block->escapeHtml($title) ?>
                    <?php if ($percent !== null) : ?>
                        (<?= (float) $percent ?>%)
                    <?php endif; ?>
                    <br />
                </td>
                <td <?= /* @noEscape */ $block->getValueProperties() ?> rowspan="1">
                    <?= /* @noEscape */ $_order->formatPrice($amount) ?>
                </td>
            </tr>
        <?php endforeach; ?>
<?php endif; ?>

<?php if ($block->displayFullSummary() && $_fullInfo && !$block->getIsPlaneMode()) : ?>
<tr class="totals-tax-summary">
<?php elseif ($block->displayFullSummary() && $_fullInfo && $block->getIsPlaneMode()) : ?>
<tr class="totals-tax-summary plane">
<?php else : ?>
<tr class="totals-tax">
<?php endif; ?>
	<td></td>
    <td></td>
    <td></td>
    <td <?= /* @noEscape */ $block->getLabelProperties() ?> scope="row" align="right" style="padding:3px 9px">
        <?php if ($block->displayFullSummary()) : ?>
            <div class="detailed"><?= $block->escapeHtml(__('Tax')) ?></div>
        <?php else : ?>
            <?= $block->escapeHtml(__('Tax')) ?>
        <?php endif; ?>
    </td>
    <td <?= /* @noEscape */ $block->getValueProperties() ?> data-th="<?= $block->escapeHtmlAttr(__('Tax')) ?>" align="right" style="padding:3px 9px">
        <?= /* @noEscape */ $_order->formatPrice($_source->getTaxAmount()) ?>
    </td>
</tr>
