<?php
/**
 * Copyright 2014 Adobe
 * All Rights Reserved.
 */

/** @var $block \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>

<div class="fieldset-wrapper" id="product-custom-options-wrapper" data-block="product-custom-options">
    <div class="fieldset-wrapper-title">
        <strong class="title">
            <span><?= $block->escapeHtml(__('Custom Options')) ?></span>
        </strong>
    </div>
    <div class="fieldset-wrapper-content" id="product-custom-options-content"
         data-role="product-custom-options-content">
        <fieldset class="fieldset">
            <div class="messages">
                <div class="message message-error" id="dynamic-price-warning">
                    <div class="message-inner">
                        <div class="message-content">
                            <?= $block->escapeHtml(__(
                                'We can\'t save custom-defined options for bundles with dynamic pricing.'
                            )) ?></div>
                    </div>
                </div>
                <?= /* @noEscape */ $secureRenderer->renderStyleAsTag("display: none;", '#dynamic-price-warning') ?>
            </div>

            <div id="product_options_container" class="sortable-wrapper">
                <div id="product_options_container_top"></div>
                <?= $block->getOptionsBoxHtml() ?>
            </div>

            <div class="actions">
                <?= $block->getChildHtml('import_button') ?>
                <?= $block->getAddButtonHtml() ?>
            </div>
        </fieldset>
    </div>
</div>

<?php $scriptString = <<<script
require(['jquery'], function($){
    var priceType = $('#price_type');
    var priceWarning = $('#dynamic-price-warning');
    if (priceType && priceType.val() == 0 && priceWarning) {
        priceWarning.show();
    }
});
script;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
