<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames(([
    // Cuántos entornos reciben esta versión ahora mismo.
    'laReciben' => 0,
    // Cuántos elementos tiene dentro.
    'elementos' => 0,
    // El id, cuando el botón está en una fila de un listado. Nulo en las pantallas que
    // miran una sola versión.
    'versionId' => null,
    // 'boton' para la cabecera de una ficha, 'enlace' para la fila de un listado.
    'forma' => 'boton',
]));

foreach ($attributes->all() as $__key => $__value) {
    if (in_array($__key, $__propNames)) {
        $$__key = $$__key ?? $__value;
    } else {
        $__newAttributes[$__key] = $__value;
    }
}

$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);

unset($__propNames);
unset($__newAttributes);

foreach (array_filter(([
    // Cuántos entornos reciben esta versión ahora mismo.
    'laReciben' => 0,
    // Cuántos elementos tiene dentro.
    'elementos' => 0,
    // El id, cuando el botón está en una fila de un listado. Nulo en las pantallas que
    // miran una sola versión.
    'versionId' => null,
    // 'boton' para la cabecera de una ficha, 'enlace' para la fila de un listado.
    'forma' => 'boton',
]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
}

$__defined_vars = get_defined_vars();

foreach ($attributes->all() as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
}

unset($__defined_vars, $__key, $__value); ?>

<?php
    // **La regla, y se evalúa aquí para no consultar nada.** Los dos datos ya los tiene la
    // pantalla: el listado los calcula por fila y la ficha en su cabecera. Llamar al
    // cálculo completo por cada fila serían dos consultas por versión (PRODSECU-198).
    $bloqueado = $laReciben > 0 || $elementos > 0;

    $motivos = [];
    if ($laReciben > 0) {
        $motivos[] = $laReciben === 1 ? 'la recibe 1 entorno' : 'la reciben ' . $laReciben . ' entornos';
    }
    if ($elementos > 0) {
        $motivos[] = $elementos === 1 ? 'tiene 1 elemento' : 'tiene ' . $elementos . ' elementos';
    }

    $titulo = $bloqueado
        ? 'No se puede borrar: ' . implode(' y ', $motivos) . '. Pulsa para ver qué hacer.'
        : 'Borrar esta versión: está vacía y no la recibe ningún entorno';
?>


<?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($forma === 'enlace'): ?>
    
    <button type="button" wire:click="abrirBorrarVersion(<?php echo e($versionId); ?>)"
            title="<?php echo e($titulo); ?>"
            class="inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-[12.5px] font-semibold"
            style="border-color:var(--border-default); background:var(--surface-page);
                   color:<?php echo e($bloqueado ? 'var(--text-subtle)' : 'var(--danger-500)'); ?>;">
        
        <?php if (isset($component)) { $__componentOriginalfdf903d7ccd93920cd8355627b101ee6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalfdf903d7ccd93920cd8355627b101ee6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icono-de-accion','data' => ['nombre' => $bloqueado ? 'bloqueado' : 'borrar','tamano' => 12]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icono-de-accion'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['nombre' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($bloqueado ? 'bloqueado' : 'borrar'),'tamano' => 12]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalfdf903d7ccd93920cd8355627b101ee6)): ?>
<?php $attributes = $__attributesOriginalfdf903d7ccd93920cd8355627b101ee6; ?>
<?php unset($__attributesOriginalfdf903d7ccd93920cd8355627b101ee6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalfdf903d7ccd93920cd8355627b101ee6)): ?>
<?php $component = $__componentOriginalfdf903d7ccd93920cd8355627b101ee6; ?>
<?php unset($__componentOriginalfdf903d7ccd93920cd8355627b101ee6); ?>
<?php endif; ?>
        Borrar
    </button>
<?php else: ?>
    <button type="button" wire:click="abrirBorrarVersion"
            title="<?php echo e($titulo); ?>"
            class="inline-flex items-center gap-1.5 rounded-lg border px-3.5 py-2 text-[13px] font-semibold"
            style="border-color:<?php echo e($bloqueado ? 'var(--border-default)' : 'var(--danger-500)'); ?>;
                   background:var(--surface-page);
                   color:<?php echo e($bloqueado ? 'var(--text-subtle)' : 'var(--danger-500)'); ?>;">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($bloqueado): ?>
            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" class="flex-none">
                <rect width="18" height="11" x="3" y="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>
            </svg>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        Borrar versión
    </button>
<?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
<?php /**PATH /var/www/html/resources/views/components/boton-borrar-version.blade.php ENDPATH**/ ?>