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

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames(([
    'path' => null,
    'compact' => false,
]));

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(([
    'path' => null,
    'compact' => false,
]), '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
    use App\Support\FileAttachment;

    $hasFile = ! empty($path);
    $name = $hasFile ? FileAttachment::filename($path) : '';
    $kind = $hasFile ? FileAttachment::kind($path) : 'other';
    $inlineUrl = $hasFile ? FileAttachment::url($path, 'inline') : '';
    $downloadUrl = $hasFile ? FileAttachment::url($path, 'attachment') : '';
    $ext = $hasFile ? FileAttachment::extension($path) : '';
?>

<?php if(! $hasFile): ?>
    <span class="text-slate-400">—</span>
<?php else: ?>
    <?php echo $__env->make('partials.file-lightbox', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <div x-data="{}" class="file-preview-card <?php echo e($compact ? 'file-preview-card--compact' : ''); ?>">
        <?php if($kind === 'image'): ?>
            <button type="button"
                    class="file-preview-thumb"
                    @click="$dispatch('open-file-lightbox', { src: '<?php echo e($inlineUrl); ?>', kind: 'image', name: <?php echo \Illuminate\Support\Js::from($name)->toHtml() ?> })">
                <img src="<?php echo e($inlineUrl); ?>" alt="<?php echo e($name); ?>" loading="lazy">
            </button>
        <?php else: ?>
            <span class="file-preview-icon <?php echo e($kind === 'pdf' ? 'file-preview-icon--pdf' : 'file-preview-icon--doc'); ?>">
                <?php if($kind === 'pdf'): ?>
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path stroke-linecap="round" stroke-linejoin="round" d="M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/><path stroke-linecap="round" stroke-linejoin="round" d="M14 3v5h5"/></svg>
                <?php else: ?>
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path stroke-linecap="round" stroke-linejoin="round" d="M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/><path stroke-linecap="round" stroke-linejoin="round" d="M14 3v5h5"/></svg>
                <?php endif; ?>
            </span>
        <?php endif; ?>

        <div class="file-preview-body">
            <p class="file-preview-name" title="<?php echo e($name); ?>"><?php echo e($name); ?></p>
            <div class="file-preview-actions">
                <?php if($kind === 'image'): ?>
                    <button type="button" class="file-preview-link"
                            @click="$dispatch('open-file-lightbox', { src: '<?php echo e($inlineUrl); ?>', kind: 'image', name: <?php echo \Illuminate\Support\Js::from($name)->toHtml() ?> })">
                        Aperçu
                    </button>
                <?php elseif($kind === 'pdf'): ?>
                    <button type="button" class="file-preview-link"
                            @click="$dispatch('open-file-lightbox', { src: '<?php echo e($inlineUrl); ?>', kind: 'pdf', name: <?php echo \Illuminate\Support\Js::from($name)->toHtml() ?> })">
                        Aperçu
                    </button>
                <?php endif; ?>
                <a href="<?php echo e($downloadUrl); ?>" class="file-preview-link file-preview-link--muted">Télécharger</a>
            </div>
        </div>
    </div>
<?php endif; ?>
<?php /**PATH C:\xampp\htdocs\teyssir\resources\views/components/file-preview.blade.php ENDPATH**/ ?>