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

/** @var \Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name $block */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>

<?php
/** @var \Magento\Catalog\Helper\Data  $catalogHelper */
$catalogHelper = $block->getData('catalogHelper');
if ($_item = $block->getItem()): ?>
    <div class="product-title"><?= $block->escapeHtml($_item->getName()) ?></div>
    <div class="product-sku-block">
        <span><?= $block->escapeHtml(__('SKU')) ?>:</span>
        <?= /* @noEscape */ implode('<br />', $catalogHelper->splitSku($block->getSku())) ?>
    </div>
    <?php if ($block->getOrderOptions()): ?>
        <dl class="item-options">
        <?php foreach ($block->getOrderOptions() as $_option): ?>
            <dt><?= $block->escapeHtml($_option['label']) ?>:</dt>
            <dd>
            <?php if (isset($_option['custom_view']) && $_option['custom_view']): ?>
                <?= $block->escapeHtml($_option['value']) ?>
            <?php else: ?>
                <?= $block->escapeHtml($block->truncateString($_option['value'], 55, '', $_remainder)) ?>
                <?php if ($_remainder):?>
                    ... <span id="<?= $block->escapeHtmlAttr($_id = 'id' . uniqid()) ?>">
                        <?= $block->escapeHtml($_remainder) ?>
                    </span>
                    <?php $escapedId = /* @noEscape */ $block->escapeJs($_id);
                    $scriptString = <<<script
                        require(['prototype'], function(){
                            $('{$escapedId}').hide();
                            $('{$escapedId}').up().observe('mouseover', function(){ $('{$escapedId}').show();});
                            $('{$escapedId}').up().observe('mouseout',  function(){ $('{$escapedId}').hide();});
                        });
script;
                    ?>
                    <?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
                <?php endif;?>
            <?php endif;?>
            </dd>
        <?php endforeach; ?>
        </dl>
    <?php endif; ?>
    <?php if ($block->getLinks()): ?>
        <dl class="item-options">
            <dt><?= $block->escapeHtml($block->getLinksTitle()) ?>:</dt>
            <?php foreach ($block->getLinks()->getPurchasedItems() as $_link): ?>
                <dd><?= $block->escapeHtml($_link->getLinkTitle()) ?>
                    (<?= $block->escapeHtml($_link->getNumberOfDownloadsUsed() . ' / ' .
                        ($_link->getNumberOfDownloadsBought() ? $_link->getNumberOfDownloadsBought() : __('U'))) ?>)
                </dd>
            <?php endforeach; ?>
        </dl>
    <?php endif; ?>
    <?= $block->escapeHtml($_item->getDescription()) ?>
<?php endif; ?>
