<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag; ?>
<?php foreach($attributes->onlyProps([
    'sections' => [], // Secciones existentes (para edición)
    'namePrefix' => 'sections', // Prefijo del input
    'allRules' => [],
]) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
} ?>
<?php $attributes = $attributes->exceptProps([
    'sections' => [], // Secciones existentes (para edición)
    'namePrefix' => 'sections', // Prefijo del input
    'allRules' => [],
]); ?>
<?php foreach (array_filter(([
    'sections' => [], // Secciones existentes (para edición)
    'namePrefix' => 'sections', // Prefijo del input
    'allRules' => [],
]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
} ?>
<?php $__defined_vars = get_defined_vars(); ?>
<?php foreach ($attributes as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
} ?>
<?php unset($__defined_vars); ?>


<div id="rules-modal" class="hidden fixed inset-0 bg-black/40 flex items-center justify-center z-50">
    <div class="bg-white rounded-xl flex flex-col shadow-lg p-6 min-h-[400px] w-[400px]">
        <div class="flex-1">
            <h3 class="text-size-subtitle text-primary100 mb-4">Asignar Controles - Reglas</h3>
            <div id="rules-container" class="space-y-2 max-h-60 overflow-y-auto border border-optional p-2 rounded">
                <?php $__currentLoopData = $allRules; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rule): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if (isset($component)) { $__componentOriginalcad097174496e50484f4459921bbbfd4 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalcad097174496e50484f4459921bbbfd4 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.checkbox','data' => ['label' => $rule->label,'class' => 'rule-checkbox','classCheckbox' => 'rule-checkbox','value' => $rule->id]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.checkbox'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['label' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($rule->label),'class' => 'rule-checkbox','classCheckbox' => 'rule-checkbox','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($rule->id)]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalcad097174496e50484f4459921bbbfd4)): ?>
<?php $attributes = $__attributesOriginalcad097174496e50484f4459921bbbfd4; ?>
<?php unset($__attributesOriginalcad097174496e50484f4459921bbbfd4); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalcad097174496e50484f4459921bbbfd4)): ?>
<?php $component = $__componentOriginalcad097174496e50484f4459921bbbfd4; ?>
<?php unset($__componentOriginalcad097174496e50484f4459921bbbfd4); ?>
<?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
        <div class="flex justify-end gap-2 mt-4">
            <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'cancel','onclick' => 'closeRulesModal()']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'cancel','onclick' => 'closeRulesModal()']); ?>Cancelar <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
            <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'add','onclick' => 'saveRules()']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'add','onclick' => 'saveRules()']); ?>Agregar <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
        </div>
    </div>
</div>

<div class="flex flex-col">
    <ul id="sections-container" class="space-y-2">
        <?php if(count($sections) > 0): ?>
            <?php $__currentLoopData = $sections; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $section): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <li class="section-item item-list-dinamic" data-index="<?php echo e($index); ?>">
                    <span class="icon-drag drag-handle">☰</span>
                    
                    <?php if(!empty($section['id'])): ?>
                        <input type="hidden" name="<?php echo e($namePrefix); ?>[<?php echo e($index); ?>][id]" value="<?php echo e($section['id']); ?>">
                    <?php endif; ?>
                    <input type="text" name="<?php echo e($namePrefix); ?>[<?php echo e($index); ?>][title]"  
                           placeholder="Título de la sección"
                           class="flex-1 input-primary-input input-general" 
                           value="<?php echo e($section['title']); ?>" required>
                    <input type="number" name="<?php echo e($namePrefix); ?>[<?php echo e($index); ?>][order]" 
                           value="<?php echo e($section['order'] ?? $index + 1); ?>"
                           class="!w-20 input-primary-input input-general text-center" required>
                    
                    <?php if(!empty($section['rules'])): ?>
                        <?php $__currentLoopData = $section['rules']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ruleId): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <input type="hidden" name="<?php echo e($namePrefix); ?>[<?php echo e($index); ?>][rules][]" value="<?php echo e($ruleId); ?>">
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                    
                    <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'optional','onclick' => 'openRulesModal('.e($index).')']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'optional','onclick' => 'openRulesModal('.e($index).')']); ?>Asignar reglas <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
                    <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'remove','onclick' => 'removeSection(this)']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'remove','onclick' => 'removeSection(this)']); ?>Eliminar <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
                </li>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php else: ?>
            
            <li class="section-item item-list-dinamic" data-index="0">
                <span class="icon-drag drag-handle">☰</span>
                <input type="text" name="<?php echo e($namePrefix); ?>[0][title]" placeholder="Título de la sección"
                    class="flex-1 input-primary-input input-general" required>
                <input type="number" name="<?php echo e($namePrefix); ?>[0][order]" value="1"
                    class="!w-20 input-primary-input input-general text-center" required>
                
                <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'optional','onclick' => 'openRulesModal(0)']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'optional','onclick' => 'openRulesModal(0)']); ?>Asignar reglas <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
                <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'remove','onclick' => 'removeSection(this)']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'remove','onclick' => 'removeSection(this)']); ?>Eliminar <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
            </li>
        <?php endif; ?>
    </ul>
    <div class="mt-6">
        <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'optional','onclick' => 'addSection()']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'optional','onclick' => 'addSection()']); ?>Agregar sección <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
<script>
    let sectionIndex = <?php echo e(count($sections) > 0 ? count($sections) : 1); ?>;
    let currentSectionIndex = null;

    function addSection() {
        const container = document.getElementById('sections-container');
        const li = document.createElement('li');
        li.classList.add('section-item', 'item-list-dinamic');
        li.setAttribute("data-index", sectionIndex);

        li.innerHTML = `
            <span class="icon-drag drag-handle">☰</span>
            <input type="text" name="<?php echo e($namePrefix); ?>[${sectionIndex}][title]" 
                   placeholder="Título de la sección" 
                   class="flex-1 input-primary-input input-general" required>
            <input type="number" name="<?php echo e($namePrefix); ?>[${sectionIndex}][order]" 
                   value="${sectionIndex + 1}" 
                   class="!w-20 input-primary-input input-general text-center" required>
            <?php if (isset($component)) { $__componentOriginal8565cc6e3559fc0755ba5bce504752a5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.controls.button','data' => ['type' => 'button','variant' => 'optional','onclick' => 'openRulesModal(${sectionIndex})']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('controls.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','variant' => 'optional','onclick' => 'openRulesModal(${sectionIndex})']); ?>Asignar reglas <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $attributes = $__attributesOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__attributesOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5)): ?>
<?php $component = $__componentOriginal8565cc6e3559fc0755ba5bce504752a5; ?>
<?php unset($__componentOriginal8565cc6e3559fc0755ba5bce504752a5); ?>
<?php endif; ?>
            <button type="button" onclick="removeSection(this)" class="btn parrafo btn-remove">Eliminar</button>
        `;
        container.appendChild(li);
        sectionIndex++;
        updateOrderInputs();
    }

    function removeSection(button) {
        button.parentElement.remove();
        updateOrderInputs();
    }

    const sortable = Sortable.create(document.getElementById('sections-container'), {
        handle: '.drag-handle',
        animation: 150,
        onEnd: function () {
            updateOrderInputs();
        }
    });

    function updateOrderInputs() {
        document.querySelectorAll('#sections-container .section-item').forEach((li, index) => {
            li.querySelector('input[type="number"]').value = index + 1;
        });
    }

    // Modal de reglas
    function openRulesModal(sectionIdx) {
        currentSectionIndex = sectionIdx;

        // Limpiar checkboxes
        document.querySelectorAll('#rules-container .rule-checkbox').forEach(cb => cb.checked = false);

        // Marcar los que ya existen
        const hiddenInputs = document.querySelectorAll(
            `input[name='sections[${sectionIdx}][rules][]']`
        );
        hiddenInputs.forEach(input => {
            const cb = document.querySelector(`#rules-container .rule-checkbox[value="${input.value}"]`);
            if (cb) cb.checked = true;
        });

        document.getElementById('rules-modal').classList.remove('hidden');
    }

    function closeRulesModal() {
        document.getElementById('rules-modal').classList.add('hidden');
        currentSectionIndex = null;
    }

    function saveRules() {
        if (currentSectionIndex === null) return;

        const sectionItem = document.querySelector(`#sections-container .section-item[data-index="${currentSectionIndex}"]`);

        // Eliminar inputs previos
        sectionItem.querySelectorAll(`input[name^="sections[${currentSectionIndex}][rules]"]`).forEach(el => el.remove());

        // Agregar inputs hidden con las reglas seleccionadas
        document.querySelectorAll('#rules-container .rule-checkbox:checked').forEach(cb => {
            const hidden = document.createElement('input');
            hidden.type = "hidden";
            hidden.name = `sections[${currentSectionIndex}][rules][]`;
            hidden.value = cb.value;
            sectionItem.appendChild(hidden);
        });

        closeRulesModal();
    }
</script>
<?php $__env->stopPush(); ?><?php /**PATH /home/cnllsandbox/public_html/house-contract.cnll-sandbox.com/resources/views/components/controls/sections-list.blade.php ENDPATH**/ ?>