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

/* @var $block \Magento\ConfigurableProduct\Block\Adminhtml\Product\Composite\Fieldset\Configurable */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<?php $_product = $block->getProduct(); ?>
<?php $_attributes = $block->decorateArray($block->getAllowAttributes()); ?>
<?php
/** @var \Magento\Catalog\Helper\Product $productHelper */
$productHelper = $block->getData('productHelper');
?>
<?php $_skipSaleableCheck = $productHelper->getSkipSaleableCheck(); ?>
<?php if (($_product->isSaleable() || $_skipSaleableCheck) && count($_attributes)):?>
<fieldset id="catalog_product_composite_configure_fields_configurable" class="fieldset admin__fieldset">
    <legend class="legend admin__legend">
        <span><?= $block->escapeHtml(__('Associated Products')) ?></span>
    </legend>
    <div class="product-options fieldset admin__fieldset">
        <?php foreach ($_attributes as $_attribute): ?>
            <div class="field admin__field required">
                <label class="label admin__field-label"><?=
                    $block->escapeHtml($_attribute->getProductAttribute()->getStoreLabel($_product->getStoreId()));
                ?></label>
                <div class="control admin__field-control <?php
                if ($_attribute->getDecoratedIsLast()):
                    ?> last<?php
                    endif; ?>">
                    <select name="super_attribute[<?= $block->escapeHtmlAttr($_attribute->getAttributeId()) ?>]"
                            id="attribute<?= $block->escapeHtmlAttr($_attribute->getAttributeId()) ?>"
                            class="admin__control-select required-entry super-attribute-select">
                        <option><?= $block->escapeHtml(__('Choose an Option...')) ?></option>
                    </select>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
</fieldset>
    <?php $config = /* @noEscape */ $block->getJsonConfig();
    $scriptString = <<<script
require([
    "Magento_ConfigurableProduct/js/configurable",
    "Magento_Catalog/catalog/product/composite/configure"
], function(){

    var config = {$config};
    if (window.productConfigure) {
        config.containerId = window.productConfigure.blockFormFields.id;
        if (window.productConfigure.restorePhase) {
            config.inputsInitialized = true;
        }
    }

    ProductConfigure.spConfig = new Product.Config(config);

});
script;
    ?>
    <?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
<?php endif;?>
