<?php
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_SeoRule
 * @copyright   Copyright (c) Mageplaza (http://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */

$_element      = $block->getElement();
$_jsObjectName = $block->getFieldSetId() != null ? $block->getFieldSetId() : $_element->getHtmlId();
?>
<div class="rule-tree mageplaza-seorule-rule-tree">
    <fieldset id="<?= $block->escapeHtmlAttr($_jsObjectName) ?>"
        <?= /** @noEscape */ $_element->serialize(['class']) ?> class="fieldset">
        <legend class="legend"><span><?= $block->escapeHtml($_element->getLegend()) ?></span></legend>
        <br>
        <?php if ($_element->getComment()) : ?>
            <div class="messages">
                <div class="message message-notice"><?= $block->escapeHtml($_element->getComment()) ?></div>
            </div>
        <?php endif; ?>
        <div class="rule-tree-wrapper">
            <?= $_element->getChildrenHtml() ?>
        </div>
    </fieldset>
</div>
<script>
    require([
        "Magento_Rule/rules",
        "prototype"
    ], function (VarienRulesForm) {
        window.<?= /** @noEscape */ $_jsObjectName ?> = new VarienRulesForm('<?= /** @noEscape */ $_jsObjectName ?>', '<?= /** @noEscape */ $block->getNewChildUrl() ?>');
        <?php if ($_element->getReadonly()) : ?>
            <?= $_element->getHtmlId() ?>.
        setReadonly(true);
        <?php endif; ?>
    });
</script>
